Index: .fossil-settings/ignore-glob
==================================================================
--- .fossil-settings/ignore-glob
+++ .fossil-settings/ignore-glob
@@ -18,15 +18,16 @@
 */config.cache
 */config.log
 */config.status
 */tkConfig.sh
 */wish*
-*/tktest*
+*/tktest
 */versions.vc
 */version.vc
 */libtk.vfs
-*/libtk_*.zip
+*/libtk*.zip
+*/tkUuid.h
 html
 macosx/configure
 win/Debug*
 win/Release*
 win/*.manifest

ADDED   .github/ISSUE_TEMPLATE.md
Index: .github/ISSUE_TEMPLATE.md
==================================================================
--- /dev/null
+++ .github/ISSUE_TEMPLATE.md
@@ -0,0 +1,3 @@
+Important Note
+==========
+Please do not file issues with Tk on Github. They are unlikely to be noticed in a timely fashion. Tk issues are hosted in the [tk fossil repository on core.tcl-lang.org](https://core.tcl-lang.org/tk/tktnew); please post them there.

ADDED   .github/PULL_REQUEST_TEMPLATE.md
Index: .github/PULL_REQUEST_TEMPLATE.md
==================================================================
--- /dev/null
+++ .github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,3 @@
+Important Note
+==========
+Please do not file pull requests with Tk on Github. They are unlikely to be noticed in a timely fashion. Tk issues (including patches) are hosted in the [tk fossil repository on core.tcl-lang.org](https://core.tcl-lang.org/tk/tktnew); please post them there.

ADDED   .github/workflows/linux-build.yml
Index: .github/workflows/linux-build.yml
==================================================================
--- /dev/null
+++ .github/workflows/linux-build.yml
@@ -0,0 +1,156 @@
+name: Linux
+on: [push]
+permissions:
+  contents: read
+defaults:
+  run:
+    shell: bash
+    working-directory: tk/unix
+env:
+  ERROR_ON_FAILURES: 1
+jobs:
+  build:
+    runs-on: ubuntu-22.04
+    strategy:
+      matrix:
+        compiler:
+          - "gcc"
+          - "clang"
+        cfgopt:
+          - ""
+          - "CFLAGS=-DTK_NO_DEPRECATED=1"
+          - "--disable-shared"
+          - "--disable-xft"
+          - "--disable-xss"
+          - "--enable-symbols"
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          path: tk
+      - name: Checkout Tcl
+        uses: actions/checkout@v3
+        with:
+          repository: tcltk/tcl
+          ref: core-8-6-branch
+          path: tcl
+      - name: Setup Environment (compiler=${{ matrix.compiler }})
+        run: |
+          sudo apt-get install tcl8.6-dev libxss-dev
+          mkdir "$HOME/install dir"
+          touch tk/doc/man.macros tk/generic/tkStubInit.c
+          echo "CFGOPT=$CFGOPT --with-tcl=/usr/lib/tcl8.6" --disable-zipfs >> $GITHUB_ENV
+          echo "CC=$COMPILER" >> $GITHUB_ENV
+          echo "TOOL_DIR=$(cd tcl/tools;pwd)" >> $GITHUB_ENV
+          echo "BUILD_CONFIG_ID=$OPTS" >> $GITHUB_ENV
+        working-directory: "."
+        env:
+          CFGOPT: ${{ matrix.cfgopt }}
+          COMPILER: ${{ matrix.compiler }}
+          OPTS: ${{ matrix.compiler }}${{ matrix.cfgopt }}
+      - name: Configure (opts=${{ matrix.cfgopt }})
+        run: |
+          ./configure $CFGOPT "--prefix=$HOME/install dir" || {
+            cat config.log
+            echo "::error::Failure during Configure"
+            exit 1
+          }
+      - name: Build
+        run: |
+          make binaries libraries || {
+            echo "::error::Failure during Build"
+            exit 1
+          }
+      - name: Build Test Harness
+        run: |
+          make tktest || {
+            echo "::error::Failure during Build"
+            exit 1
+          }
+      - name: Test-Drive Installation
+        run: |
+          make install || {
+            echo "::error::Failure during Install"
+            exit 1
+          }
+      - name: Create Distribution Package
+        run: |
+          make dist || {
+            echo "::error::Failure during Distribute"
+            exit 1
+          }
+      - name: Convert Documentation to HTML
+        run: |
+          make html-tk TOOL_DIR=$TOOL_DIR || {
+            echo "::error::Failure during Distribute"
+            exit 1
+          }
+      - name: Discover Version ID
+        if: ${{ env.BUILD_CONFIG_ID == 'gcc' }}
+        run: |
+          cd /tmp/dist
+          echo "VERSION=`ls -d tk* | sed 's/tk//'`" >> $GITHUB_ENV
+      - name: Upload Source Distribution
+        if: ${{ env.BUILD_CONFIG_ID == 'gcc-no' }}
+        uses: actions/upload-artifact@v2
+        with:
+          name: Tk ${{ env.VERSION }} Source distribution (snapshot)
+          path: |
+            /tmp/dist/tk*
+            !/tmp/dist/tk*/html/**
+      - name: Upload Documentation Distribution
+        if: ${{ env.BUILD_CONFIG_ID == 'gcc-no' }}
+        uses: actions/upload-artifact@v2
+        with:
+          name: Tk ${{ env.VERSION }} HTML documentation (snapshot)
+          path: /tmp/dist/tk*/html
+  test:
+    runs-on: ubuntu-20.04
+    strategy:
+      matrix:
+        compiler:
+          - "gcc"
+        cfgopt:
+          - ""
+          - "--enable-symbols"
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          path: tk
+      - name: Setup Environment (compiler=${{ matrix.compiler }})
+        run: |
+          sudo apt-get install tcl8.6-dev libxss-dev xvfb libicu-dev
+          mkdir "$HOME/install dir"
+          touch tk/doc/man.macros tk/generic/tkStubInit.c
+          echo "CFGOPT=$CFGOPT --with-tcl=/usr/lib/tcl8.6 --disable-zipfs" >> $GITHUB_ENV
+          echo "CC=$COMPILER" >> $GITHUB_ENV
+        working-directory: "."
+        env:
+          CFGOPT: ${{ matrix.cfgopt }}
+          COMPILER: ${{ matrix.compiler }}
+      - name: Configure ${{ matrix.cfgopt }}
+        run: |
+          ./configure $CFGOPT "--prefix=$HOME/install dir" || {
+            cat config.log
+            echo "::error::Failure during Configure"
+            exit 1
+          }
+      - name: Build
+        run: |
+          make binaries libraries tktest || {
+            echo "::error::Failure during Build"
+            exit 1
+          }
+      - name: Run Tests
+        run: |
+          xvfb-run --auto-servernum make test-classic | tee out-classic.txt
+          xvfb-run --auto-servernum make test-ttk | tee out-ttk.txt
+          grep -q "Failed	0" out-classic.txt || {
+            echo "::error::Failure during Test"
+            exit 1
+          }
+          grep -q "Failed	0" out-ttk.txt || {
+            echo "::error::Failure during Test"
+            exit 1
+          }

ADDED   .github/workflows/linux-with-tcl8-build.yml
Index: .github/workflows/linux-with-tcl8-build.yml
==================================================================
--- /dev/null
+++ .github/workflows/linux-with-tcl8-build.yml
@@ -0,0 +1,188 @@
+name: Linux (with Tcl 8.7)
+on: [push]
+permissions:
+  contents: read
+defaults:
+  run:
+    shell: bash
+    working-directory: tk/unix
+env:
+  ERROR_ON_FAILURES: 1
+jobs:
+  build:
+    runs-on: ubuntu-22.04
+    strategy:
+      matrix:
+        compiler:
+          - "gcc"
+          - "clang"
+        cfgopt:
+          - ""
+          - "CFLAGS=-DTK_NO_DEPRECATED=1"
+          - "--disable-shared"
+          - "--disable-xft"
+          - "--disable-xss"
+          - "--enable-symbols"
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          path: tk
+      - name: Checkout Tcl
+        uses: actions/checkout@v3
+        with:
+          repository: tcltk/tcl
+          ref: core-8-branch
+          path: tcl
+      - name: Setup Environment (compiler=${{ matrix.compiler }})
+        run: |
+          sudo apt-get install libxss-dev
+          mkdir "$HOME/install dir"
+          touch tk/doc/man.macros tk/generic/tkStubInit.c
+          echo "CFGOPT=$CFGOPT" >> $GITHUB_ENV
+          echo "CC=$COMPILER" >> $GITHUB_ENV
+          echo "TOOL_DIR=$(cd tcl/tools;pwd)" >> $GITHUB_ENV
+          echo "BUILD_CONFIG_ID=$OPTS" >> $GITHUB_ENV
+        working-directory: "."
+        env:
+          CFGOPT: ${{ matrix.cfgopt }}
+          COMPILER: ${{ matrix.compiler }}
+          OPTS: ${{ matrix.compiler }}${{ matrix.cfgopt }}
+      - name: Configure and Build Tcl
+        run: |
+          ./configure ${CFGOPT} "--prefix=$HOME/install dir" || {
+            cat config.log
+            echo "::warning::Failure during Tcl Configure"
+            exit 1
+          }
+          make all install  || {
+            echo "::warning::Failure during Tcl Build"
+            exit 1
+          }
+          echo "TCL_CONFIG_PATH=`pwd`" >> $GITHUB_ENV
+        working-directory: tcl/unix
+      - name: Configure (opts=${{ matrix.cfgopt }})
+        run: |
+          ./configure $CFGOPT --with-tcl=$TCL_CONFIG_PATH "--prefix=$HOME/install dir" || {
+            cat config.log
+            echo "::error::Failure during Configure"
+            exit 1
+          }
+      - name: Build
+        run: |
+          make binaries libraries || {
+            echo "::error::Failure during Build"
+            exit 1
+          }
+      - name: Build Test Harness
+        run: |
+          make tktest || {
+            echo "::error::Failure during Build"
+            exit 1
+          }
+      - name: Test-Drive Installation
+        run: |
+          make install || {
+            echo "::error::Failure during Install"
+            exit 1
+          }
+      - name: Create Distribution Package
+        run: |
+          make dist || {
+            echo "::error::Failure during Distribute"
+            exit 1
+          }
+      - name: Convert Documentation to HTML
+        run: |
+          make html-tk TOOL_DIR=$TOOL_DIR || {
+            echo "::error::Failure during Distribute"
+            exit 1
+          }
+      - name: Discover Version ID
+        if: ${{ env.BUILD_CONFIG_ID == 'gcc' }}
+        run: |
+          cd /tmp/dist
+          echo "VERSION=`ls -d tk* | sed 's/tk//'`" >> $GITHUB_ENV
+      - name: Upload Source Distribution
+        if: ${{ env.BUILD_CONFIG_ID == 'gcc' }}
+        uses: actions/upload-artifact@v2
+        with:
+          name: Tk ${{ env.VERSION }} Source distribution (snapshot)
+          path: |
+            /tmp/dist/tk*
+            !/tmp/dist/tk*/html/**
+      - name: Upload Documentation Distribution
+        if: ${{ env.BUILD_CONFIG_ID == 'gcc' }}
+        uses: actions/upload-artifact@v2
+        with:
+          name: Tk ${{ env.VERSION }} HTML documentation (snapshot)
+          path: /tmp/dist/tk*/html
+  test:
+    runs-on: ubuntu-20.04
+    strategy:
+      matrix:
+        compiler:
+          - "gcc"
+        cfgopt:
+          - ""
+          - "--enable-symbols"
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          path: tk
+      - name: Checkout Tcl
+        uses: actions/checkout@v3
+        with:
+          repository: tcltk/tcl
+          ref: core-8-branch
+          path: tcl
+      - name: Setup Environment (compiler=${{ matrix.compiler }})
+        run: |
+          sudo apt-get install libxss-dev xvfb libicu-dev
+          mkdir "$HOME/install dir"
+          touch tk/doc/man.macros tk/generic/tkStubInit.c
+          echo "CFGOPT=$CFGOPT" >> $GITHUB_ENV
+          echo "CC=$COMPILER" >> $GITHUB_ENV
+        working-directory: "."
+        env:
+          CFGOPT: ${{ matrix.cfgopt }}
+          COMPILER: ${{ matrix.compiler }}
+      - name: Configure and Build Tcl
+        run: |
+          ./configure ${CFGOPT} "--prefix=$HOME/install dir" || {
+            cat config.log
+            echo "::warning::Failure during Tcl Configure"
+            exit 1
+          }
+          make all install  || {
+            echo "::warning::Failure during Tcl Build"
+            exit 1
+          }
+          echo "TCL_CONFIG_PATH=`pwd`" >> $GITHUB_ENV
+        working-directory: tcl/unix
+      - name: Configure ${{ matrix.cfgopt }}
+        run: |
+          ./configure $CFGOPT --with-tcl=$TCL_CONFIG_PATH "--prefix=$HOME/install dir" || {
+            cat config.log
+            echo "::error::Failure during Configure"
+            exit 1
+          }
+      - name: Build
+        run: |
+          make binaries libraries tktest || {
+            echo "::error::Failure during Build"
+            exit 1
+          }
+      - name: Run Tests
+        run: |
+          xvfb-run --auto-servernum make test-classic | tee out-classic.txt
+          xvfb-run --auto-servernum make test-ttk | tee out-ttk.txt
+          grep -q "Failed	0" out-classic.txt || {
+            echo "::error::Failure during Test"
+            exit 1
+          }
+          grep -q "Failed	0" out-ttk.txt || {
+            echo "::error::Failure during Test"
+            exit 1
+          }

ADDED   .github/workflows/linux-with-tcl9-build.yml
Index: .github/workflows/linux-with-tcl9-build.yml
==================================================================
--- /dev/null
+++ .github/workflows/linux-with-tcl9-build.yml
@@ -0,0 +1,174 @@
+name: Linux (with Tcl 9.0)
+on: [push]
+permissions:
+  contents: read
+defaults:
+  run:
+    shell: bash
+    working-directory: tk/unix
+env:
+  ERROR_ON_FAILURES: 1
+jobs:
+  build:
+    runs-on: ubuntu-22.04
+    strategy:
+      matrix:
+        compiler:
+          - "gcc"
+          - "clang"
+        cfgopt:
+          - ""
+          - "CFLAGS=-DTK_NO_DEPRECATED=1"
+          - "--disable-shared"
+          - "--disable-xft"
+          - "--disable-xss"
+          - "--enable-symbols"
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          path: tk
+      - name: Checkout Tcl
+        uses: actions/checkout@v3
+        with:
+          repository: tcltk/tcl
+          ref: main
+          path: tcl
+      - name: Setup Environment (compiler=${{ matrix.compiler }})
+        run: |
+          sudo apt-get install libxss-dev
+          mkdir "$HOME/install dir"
+          touch tk/doc/man.macros tk/generic/tkStubInit.c
+          echo "CFGOPT=$CFGOPT" >> $GITHUB_ENV
+          echo "CC=$COMPILER" >> $GITHUB_ENV
+          echo "TOOL_DIR=$(cd tcl/tools;pwd)" >> $GITHUB_ENV
+          echo "BUILD_CONFIG_ID=$OPTS" >> $GITHUB_ENV
+        working-directory: "."
+        env:
+          CFGOPT: ${{ matrix.cfgopt }}
+          COMPILER: ${{ matrix.compiler }}
+          OPTS: ${{ matrix.compiler }}${{ matrix.cfgopt }}
+      - name: Configure and Build Tcl
+        run: |
+          ./configure ${CFGOPT} "--prefix=$HOME/install dir" || {
+            cat config.log
+            echo "::warning::Failure during Tcl Configure"
+            exit 1
+          }
+          make all install  || {
+            echo "::warning::Failure during Tcl Build"
+            exit 1
+          }
+          echo "TCL_CONFIG_PATH=`pwd`" >> $GITHUB_ENV
+        working-directory: tcl/unix
+      - name: Configure (opts=${{ matrix.cfgopt }})
+        run: |
+          ./configure $CFGOPT --with-tcl=$TCL_CONFIG_PATH "--prefix=$HOME/install dir" || {
+            cat config.log
+            echo "::error::Failure during Configure"
+            exit 1
+          }
+      - name: Build
+        run: |
+          make binaries libraries || {
+            echo "::error::Failure during Build"
+            exit 1
+          }
+      - name: Build Test Harness
+        run: |
+          make tktest || {
+            echo "::error::Failure during Build"
+            exit 1
+          }
+      - name: Test-Drive Installation
+        run: |
+          make install || {
+            echo "::error::Failure during Install"
+            exit 1
+          }
+      - name: Create Distribution Package
+        run: |
+          make dist || {
+            echo "::error::Failure during Distribute"
+            exit 1
+          }
+      - name: Convert Documentation to HTML
+        run: |
+          make html-tk TOOL_DIR=$TOOL_DIR || {
+            echo "::error::Failure during Distribute"
+            exit 1
+          }
+      - name: Discover Version ID
+        if: ${{ env.BUILD_CONFIG_ID == 'gcc' }}
+        run: |
+          cd /tmp/dist
+          echo "VERSION=`ls -d tk* | sed 's/tk//'`" >> $GITHUB_ENV
+  test:
+    runs-on: ubuntu-20.04
+    strategy:
+      matrix:
+        compiler:
+          - "gcc"
+        cfgopt:
+          - ""
+          - "--enable-symbols"
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          path: tk
+      - name: Checkout Tcl
+        uses: actions/checkout@v3
+        with:
+          repository: tcltk/tcl
+          ref: main
+          path: tcl
+      - name: Setup Environment (compiler=${{ matrix.compiler }})
+        run: |
+          sudo apt-get install libxss-dev xvfb libicu-dev
+          mkdir "$HOME/install dir"
+          touch tk/doc/man.macros tk/generic/tkStubInit.c
+          echo "CFGOPT=$CFGOPT" >> $GITHUB_ENV
+          echo "CC=$COMPILER" >> $GITHUB_ENV
+        working-directory: "."
+        env:
+          CFGOPT: ${{ matrix.cfgopt }}
+          COMPILER: ${{ matrix.compiler }}
+      - name: Configure and Build Tcl
+        run: |
+          ./configure ${CFGOPT} "--prefix=$HOME/install dir" || {
+            cat config.log
+            echo "::warning::Failure during Tcl Configure"
+            exit 1
+          }
+          make all install  || {
+            echo "::warning::Failure during Tcl Build"
+            exit 1
+          }
+          echo "TCL_CONFIG_PATH=`pwd`" >> $GITHUB_ENV
+        working-directory: tcl/unix
+      - name: Configure ${{ matrix.cfgopt }}
+        run: |
+          ./configure $CFGOPT --with-tcl=$TCL_CONFIG_PATH "--prefix=$HOME/install dir" || {
+            cat config.log
+            echo "::error::Failure during Configure"
+            exit 1
+          }
+      - name: Build
+        run: |
+          make binaries libraries tktest || {
+            echo "::error::Failure during Build"
+            exit 1
+          }
+      - name: Run Tests
+        run: |
+          xvfb-run --auto-servernum make test-classic | tee out-classic.txt
+          xvfb-run --auto-servernum make test-ttk | tee out-ttk.txt
+          grep -q "Failed	0" out-classic.txt || {
+            echo "::error::Failure during Test"
+            exit 1
+          }
+          grep -q "Failed	0" out-ttk.txt || {
+            echo "::error::Failure during Test"
+            exit 1
+          }

ADDED   .github/workflows/mac-build.yml
Index: .github/workflows/mac-build.yml
==================================================================
--- /dev/null
+++ .github/workflows/mac-build.yml
@@ -0,0 +1,164 @@
+name: macOS
+on: [push]
+permissions:
+  contents: read
+env:
+  ERROR_ON_FAILURES: 1
+jobs:
+  xcode:
+    runs-on: macos-11
+    defaults:
+      run:
+        shell: bash
+        working-directory: tk/macosx
+    steps:
+      - name: Check out Tk
+        uses: actions/checkout@v3
+        with:
+          path: tk
+      - name: Check out Tcl
+        uses: actions/checkout@v3
+        with:
+          repository: tcltk/tcl
+          ref: core-8-6-branch
+          path: tcl
+      - name: Prepare checked out repositories
+        run: |
+          touch tk/generic/tkStubInit.c
+          mkdir build
+          echo "BUILD_DIR=`cd build && pwd`" >> $GITHUB_ENV
+          echo "DESTDIR=`cd build && pwd`" >> $GITHUB_ENV
+        working-directory: .
+      - name: Build Tcl
+        run: |
+          make all
+        working-directory: tcl/macosx
+      - name: Build
+        run: |
+          make all install || {
+            echo "::error::Failure during Build"
+            exit 1
+          }
+      - name: Run Tests
+        run: |
+          make test | tee out.txt
+          nmatches=$( grep -c "Failed	0" out.txt )
+          if [ $nmatches -lt 4 ]
+          then
+            echo "::error::Failure during Test"
+            exit 1
+          fi
+  clang:
+    runs-on: macos-11
+    strategy:
+      matrix:
+        symbols:
+          - 'no'
+          - 'mem'
+        options:
+          - '--enable-aqua'
+          - '--disable-aqua'
+    defaults:
+      run:
+        shell: bash
+        working-directory: tk/unix
+    steps:
+      - name: Check out Tk
+        uses: actions/checkout@v3
+        with:
+          path: tk
+      - name: Check out Tcl
+        uses: actions/checkout@v3
+        with:
+          repository: tcltk/tcl
+          ref: core-8-6-branch
+          path: tcl
+      - name: Prepare checked out repositories
+        env:
+          SET_DISPLAY: ${{ contains(matrix.options, '--disable-aqua') }}
+        run: |
+          touch tkStubInit.c
+          mkdir "$HOME/install dir"
+          echo "USE_XVFB=$SET_DISPLAY" >> $GITHUB_ENV
+        working-directory: tk/generic
+      - name: Add X11 (if required)
+        if: ${{ env.USE_XVFB == 'true' }}
+        run: |
+          brew install --cask xquartz
+          sudo /opt/X11/libexec/privileged_startx || true
+        working-directory: .
+      - name: Build Tcl
+        # Note that macOS is always a 64 bit platform
+        run: |
+          ./configure --enable-64bit ${CFGOPT} "--prefix=$HOME/install dir" || {
+            cat config.log
+            echo "::error::Failure during Tcl Configure"
+            exit 1
+          }
+          make all || {
+            echo "::error::Failure during Tcl Build"
+            exit 1
+          }
+          make install || {
+            echo "::error::Failure during Tcl Install"
+            exit 1
+          }
+        working-directory: tcl/unix
+        env:
+          CFGOPT: --enable-symbols=${{ matrix.symbols }}
+      - name: Configure (symbols=${{ matrix.symbols }} ${{matrix.options }})
+        # Note that macOS is always a 64 bit platform
+        run: |
+          ./configure --enable-64bit ${CFGOPT} "--prefix=$HOME/install dir" --disable-xft || {
+            cat config.log
+            echo "::error::Failure during Configure"
+            exit 1
+          }
+        env:
+          CFGOPT: --enable-symbols=${{ matrix.symbols }} ${{matrix.options }}
+      - name: Build
+        run: |
+          make all tktest || {
+            echo "::error::Failure during Build"
+            exit 1
+          }
+      - name: Run Tests
+        run: |
+          if [ $USE_XVFB == true ]; then
+            function runXvfb {
+              PATH=$PATH:/opt/X11/bin
+              Xvfb $1 &
+              XVFB_PID=$!
+              echo Launched Xvfb $1 as process $XVFB_PID >&2
+              trap "echo killing process $XVFB_PID... >&2; kill $XVFB_PID" 0
+              export DISPLAY=$1
+              sleep 2
+            }
+          else
+            function runXvfb {
+              echo Xvfb not used, this is a --enable-aqua build
+            }
+          fi
+          ( runXvfb :0; make test-classic; exit $? ) | tee out-classic.txt || {
+            echo "::error::Failure during Test (classic)"
+            exit 1
+          }
+          ( runXvfb :0; make test-ttk; exit $? ) | tee out-ttk.txt || {
+            echo "::error::Failure during Test (ttk)"
+            exit 1
+          }
+          cat out-classic.txt | grep -q "Failed	0" || {
+            echo "::error::Failure in classic test results"
+            exit 1
+          }
+          cat out-ttk.txt | grep -q "Failed	0" || {
+            echo "::error::Failure in ttk test results"
+            exit 1
+          }
+      - name: Carry out trial installation
+        run: |
+          make install || {
+            cat config.log
+            echo "::error::Failure during Install"
+            exit 1
+          }

ADDED   .github/workflows/onefiledist.yml
Index: .github/workflows/onefiledist.yml
==================================================================
--- /dev/null
+++ .github/workflows/onefiledist.yml
@@ -0,0 +1,215 @@
+name: Build Binaries
+on: [push]
+permissions:
+  contents: read
+jobs:
+  linux:
+    name: Linux
+    runs-on: ubuntu-20.04
+    defaults:
+      run:
+        shell: bash
+    env:
+      CC: gcc
+      CFGOPT: --disable-symbols --disable-shared
+    steps:
+      - name: Checkout Tk
+        uses: actions/checkout@v3
+        with:
+          path: tk
+      - name: Checkout Tcl 8.7
+        uses: actions/checkout@v3
+        with:
+          repository: tcltk/tcl
+          ref: core-8-branch
+          path: tcl
+      - name: Setup Environment
+        run: |
+          sudo apt-get install libxss-dev
+          touch tcl/generic/tclStubInit.c tcl/generic/tclOOStubInit.c
+          touch tk/generic/tkStubInit.c
+          echo "INST_DIR=$(cd install;pwd)" >> $GITHUB_ENV
+          echo "VER_PATH=$(cd tcl/tools; pwd)/addVerToFile.tcl" >> $GITHUB_ENV
+        working-directory: "."
+      - name: Configure Tcl
+        run: |
+          ./configure $CFGOPT --enable-zipfs --prefix=$INST_DIR
+        working-directory: tcl/unix
+      - name: Build & Install Tcl
+        run: |
+          make binaries libraries install
+          make shell SCRIPT="$VER_PATH $GITHUB_ENV"
+        working-directory: tcl/unix
+      - name: Configure Tk
+        run: |
+          ./configure $CFGOPT --with-tcl=$INST_DIR/lib --prefix=$INST_DIR
+        working-directory: tk/unix
+      - name: Build & Install Tk
+        run: |
+          make binaries libraries install
+        working-directory: tk/unix
+        # TODO: need the Tk version separately for distro naming below
+      - name: Package
+        run: |
+          cp bin/wish8.7 ${BUILD_NAME}
+          chmod +x ${BUILD_NAME}
+          tar -cf ${BUILD_NAME}.tar ${BUILD_NAME}
+        working-directory: ${{ env.INST_DIR }}
+        env:
+          BUILD_NAME: wish${{ env.TCL_PATCHLEVEL }}_snapshot
+      - name: Upload
+        uses: actions/upload-artifact@v3
+        with:
+          name: Wish ${{ env.TCL_PATCHLEVEL }} Linux single-file build (snapshot)
+          path: ${{ env.INST_DIR }}/*.tar
+      - name: Describe Installation Zip Contents
+        if: ${{ always() }}
+        run: |
+          unzip -l wish${{ env.TCL_PATCHLEVEL }}_snapshot || true
+        working-directory: ${{ env.INST_DIR }}
+  macos:
+    name: macOS
+    runs-on: macos-11
+    defaults:
+      run:
+        shell: bash
+    env:
+      CC: gcc
+      CFGOPT: --disable-symbols --disable-shared --enable-64bit
+    steps:
+      - name: Checkout Tk
+        uses: actions/checkout@v3
+        with:
+          path: tk
+      - name: Checkout Tcl 8.7
+        uses: actions/checkout@v3
+        with:
+          repository: tcltk/tcl
+          ref: core-8-branch
+          path: tcl
+      - name: Checkout create-dmg
+        uses: actions/checkout@v3
+        with:
+          repository: create-dmg/create-dmg
+          ref: v1.0.8
+          path: create-dmg
+      - name: Setup Environment
+        run: |
+          mkdir -p install/contents
+          touch tcl/generic/tclStubInit.c tcl/generic/tclOOStubInit.c
+          touch tk/generic/tkStubInit.c
+          echo "INST_DIR=$(cd install;pwd)" >> $GITHUB_ENV
+          echo "VER_PATH=$(cd tcl/tools; pwd)/addVerToFile.tcl" >> $GITHUB_ENV
+          echo "CREATE_DMG=$(cd create-dmg;pwd)/create-dmg" >> $GITHUB_ENV
+          echo "CFLAGS=-arch x86_64 -arch arm64e" >> $GITHUB_ENV
+        working-directory: "."
+      - name: Configure Tcl
+        run: |
+          ./configure $CFGOPT --enable-zipfs --prefix=$INST_DIR
+        working-directory: tcl/unix
+      - name: Build & Install Tcl
+        run: |
+          make binaries libraries install
+          make shell SCRIPT="$VER_PATH $GITHUB_ENV"
+        working-directory: tcl/unix
+      - name: Configure Tk
+        run: |
+          ./configure $CFGOPT --with-tcl=$INST_DIR/lib --prefix=$INST_DIR \
+              --enable-aqua
+        working-directory: tk/unix
+      - name: Build & Install Tk
+        run: |
+          make binaries libraries install
+        working-directory: tk/unix
+        # TODO: need the Tk version separately for distro naming below
+      - name: Package
+        run: |
+          cp ../tk/unix/wish contents/${BUILD_NAME}
+          chmod +x contents/${BUILD_NAME}
+          cat > contents/README.txt <<EOF
+          This is a single-file executable developer preview of Tcl/Tk $TCL_PATCHLEVEL
+
+          It is not intended as an official release at all, so it is unsigned and unnotarized.
+          Use strictly at your own risk.
+
+          To run it, you need to copy the executable out and run:
+              xattr -d com.apple.quarantine ${BUILD_NAME}
+          to mark the executable as runnable on your machine.
+          EOF
+          $CREATE_DMG \
+              --volname "TclTk $TCL_PATCHLEVEL (snapshot)" \
+              --window-pos 200 120 \
+              --window-size 800 400 \
+              "TclTk-$TCL_PATCHLEVEL-(snapshot).dmg" \
+              "contents/"
+        working-directory: ${{ env.INST_DIR }}
+        env:
+          BUILD_NAME: wish${{ env.TCL_PATCHLEVEL }}_snapshot
+      - name: Upload
+        uses: actions/upload-artifact@v3
+        with:
+          name: Wish ${{ env.TCL_PATCHLEVEL }} macOS single-file build (snapshot)
+          path: ${{ env.INST_DIR }}/*.dmg
+  win:
+    name: Windows
+    runs-on: windows-latest
+    defaults:
+      run:
+        shell: msys2 {0}
+    env:
+      CC: gcc
+      CFGOPT: --disable-symbols --disable-shared
+    steps:
+      - name: Install MSYS2
+        uses: msys2/setup-msys2@v2
+        with:
+          msystem: MINGW64
+          install: git mingw-w64-x86_64-toolchain make zip
+      - name: Checkout Tk
+        uses: actions/checkout@v3
+        with:
+          path: tk
+      - name: Checkout Tcl 8.7
+        uses: actions/checkout@v3
+        with:
+          repository: tcltk/tcl
+          ref: core-8-branch
+          path: tcl
+      - name: Setup Environment
+        run: |
+          mkdir -p install/combined
+          touch tcl/generic/tclStubInit.c tcl/generic/tclOOStubInit.c
+          touch tk/generic/tkStubInit.c
+          echo "INST_DIR=$(cd install;pwd)" >> $GITHUB_ENV
+          echo "VER_PATH=$(cd tcl/tools; pwd)/addVerToFile.tcl" >> $GITHUB_ENV
+        working-directory: "."
+      - name: Configure Tcl
+        run: |
+          ./configure $CFGOPT --enable-zipfs --prefix=$INST_DIR
+        working-directory: tcl/win
+      - name: Build & Install Tcl
+        run: |
+          make binaries libraries install
+          $INST_DIR/bin/tclsh* $VER_PATH $GITHUB_ENV
+        working-directory: tcl/win
+      - name: Configure Tk
+        run: |
+          ./configure $CFGOPT --with-tcl=$INST_DIR/lib --prefix=$INST_DIR
+        working-directory: tk/win
+      - name: Build & Install Tk
+        run: |
+          make all install
+          echo "TK_BIN=`pwd`/`echo wish*.exe`" >> $GITHUB_ENV
+        working-directory: tk/win
+        # TODO: need the Tk version separately for distro naming below
+      - name: Package
+        run: |
+          cp ${TK_BIN} combined/${BUILD_NAME}.exe
+        working-directory: install
+        env:
+          BUILD_NAME: wish${{ env.TCL_PATCHLEVEL }}_snapshot
+      - name: Upload
+        uses: actions/upload-artifact@v3
+        with:
+          name: Wish ${{ env.TCL_PATCHLEVEL }} Windows single-file build (snapshot)
+          path: install/combined/wish${{ env.TCL_PATCHLEVEL }}_snapshot.exe

ADDED   .github/workflows/win-build.yml
Index: .github/workflows/win-build.yml
==================================================================
--- /dev/null
+++ .github/workflows/win-build.yml
@@ -0,0 +1,162 @@
+name: Windows
+on: [push]
+permissions:
+  contents: read
+env:
+  ERROR_ON_FAILURES: 1
+jobs:
+  msvc:
+    runs-on: windows-2019
+    defaults:
+      run:
+        shell: powershell
+        working-directory: tk/win
+    # Using powershell means we need to explicitly stop on failure
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          path: tk
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          repository: tcltk/tcl
+          ref: core-8-branch
+          path: tcl
+      - name: Init MSVC
+        uses: ilammy/msvc-dev-cmd@v1
+      - name: Make Install Location
+        working-directory: tcl
+        run: |
+          echo "TCLDIR=`pwd`" >> $GITHUB_ENV
+          cd ..
+          mkdir install
+          cd install
+          echo "INSTALLDIR=`pwd`" >> $GITHUB_ENV
+      - name: Build Tcl
+        run: |
+          &nmake -f makefile.vc release install
+          if ($lastexitcode -ne 0) {
+             throw "nmake exit code: $lastexitcode"
+          }
+        working-directory: tcl/win
+      - name: Build
+        run: |
+          &nmake -f makefile.vc all
+          if ($lastexitcode -ne 0) {
+             throw "nmake exit code: $lastexitcode"
+          }
+      - name: Build Test Harness
+        run: |
+          &nmake -f makefile.vc tktest
+          if ($lastexitcode -ne 0) {
+             throw "nmake exit code: $lastexitcode"
+          }
+      - name: Run Tests
+        run: |
+          nmake -f makefile.vc test-classic | tee out-classic.txt || {
+            echo "::error::Failure during Test"
+            exit 1
+          }
+          nmake -f makefile.vc test-ttk | tee out-ttk.txt || {
+            echo "::error::Failure during Test"
+            exit 1
+          }
+          grep -q "Failed	0" out-classic.txt || {
+            echo "::error::Failure during Test"
+            exit 1
+          }
+          grep -q "Failed	0" out-ttk.txt || {
+            echo "::error::Failure during Test"
+            exit 1
+          }
+        env:
+          CI_BUILD_WITH_MSVC: 1
+        shell: bash
+      - name: Build Help
+        run: |
+          &nmake -f makefile.vc htmlhelp
+          if ($lastexitcode -ne 0) {
+             throw "nmake exit code: $lastexitcode"
+          }
+      - name: Install
+        run: |
+          &nmake -f makefile.vc install
+          if ($lastexitcode -ne 0) {
+             throw "nmake exit code: $lastexitcode"
+          }
+  gcc:
+    runs-on: windows-2019
+    defaults:
+      run:
+        shell: msys2 {0}
+        working-directory: win
+    strategy:
+      matrix:
+        symbols:
+          - "no"
+          - "mem"
+          - "all"
+    steps:
+      - name: Install MSYS2
+        uses: msys2/setup-msys2@v2
+        with:
+          msystem: MINGW64
+          install: git mingw-w64-x86_64-toolchain make zip
+      - name: Checkout
+        uses: actions/checkout@v3
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          repository: tcltk/tcl
+          ref: core-8-6-branch
+          path: tcl
+      - name: Prepare
+        run: |
+          touch tkStubInit.c
+          touch "${HOME}/forWinDialog-5.12.7"
+          mkdir "${HOME}/install_dir"
+          echo "INSTALL_DIR=${HOME}/install_dir" >> $GITHUB_ENV
+        working-directory: generic
+      - name: Configure and Build Tcl
+        run: |
+          ./configure ${CFGOPT} "--prefix=$INSTALL_DIR" || {
+            cat config.log
+            echo "::warning::Failure during Tcl Configure"
+            exit 1
+          }
+          make all install  || {
+            echo "::warning::Failure during Tcl Build"
+            exit 1
+          }
+          echo "TCL_CONFIG_PATH=`pwd`" >> $GITHUB_ENV
+        env:
+          CFGOPT: --enable-64bit --enable-symbols=${{ matrix.symbols }}
+        working-directory: tcl/win
+      - name: Configure (symbols=${{ matrix.symbols }})
+        run: |
+          ./configure ${CFGOPT} "--prefix=$HOME/INSTALL_DIR" "--with-tcl=$TCL_CONFIG_PATH" || {
+            cat config.log
+            echo "::error::Failure during Configure"
+            exit 1
+          }
+        env:
+          CFGOPT: --enable-64bit --enable-symbols=${{ matrix.symbols }}
+      - name: Build
+        run: |
+          make all tktest || {
+            echo "::error::Failure during Build"
+            exit 1
+          }
+      - name: Run Tests
+        run: |
+          make test-classic | tee out-classic.txt
+          make test-ttk | tee out-ttk.txt
+          grep -q "Failed	0" out-classic.txt || {
+            echo "::error::Failure during Test"
+            exit 1
+          }
+          grep -q "Failed	0" out-ttk.txt || {
+            echo "::error::Failure during Test"
+            exit 1
+          }

Index: .gitignore
==================================================================
--- .gitignore
+++ .gitignore
@@ -24,15 +24,16 @@
 html
 manifest.uuid
 _FOSSIL_
 */tkConfig.sh
 */wish*
-*/tktest*
+*/tktest
 */versions.vc
 */version.vc
-*/libtcl.vfs
-*/libtcl_*.zip
+*/libtk.vfs
+*/libtk*.zip
+*/tkUuid.h
 libtommath/bn.ilg
 libtommath/bn.ind
 libtommath/pretty.build
 libtommath/tommath.src
 libtommath/*.log

Index: .travis.yml
==================================================================
--- .travis.yml
+++ .travis.yml
@@ -11,16 +11,21 @@
       - gcc-mingw-w64-i686
       - gcc-mingw-w64-x86-64
       - gcc-multilib
       - tcl8.6-dev
       - libx11-dev
+      - libnotify-dev
+      - libglib2.0-dev
+      - libxss-dev
       - xvfb
   homebrew:
     packages:
       - tcl-tk
-    casks:
-      - xquartz
+      - libnotify
+      - glib
+#   casks:
+#     - xquartz
 jobs:
   include:
 # Testing on Linux GCC
     - name: "Linux/GCC/Shared"
       os: linux
@@ -56,10 +61,20 @@
         - xvfb
       compiler: gcc
       env:
         - BUILD_DIR=unix
         - CFGOPT="--disable-xft"
+      script: *x11gui
+    - name: "Linux/GCC/Shared/no-libnotify"
+      os: linux
+      dist: focal
+      services:
+        - xvfb
+      compiler: gcc
+      env:
+        - BUILD_DIR=unix
+        - CFGOPT="--disable-libnotify"
       script: *x11gui
     - name: "Linux/GCC/Shared/bionic"
       os: linux
       dist: bionic
       services:
@@ -179,57 +194,35 @@
       os: osx
       osx_image: xcode12
       env:
         - BUILD_DIR=unix
         - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib CC=clang++ --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include CPPFLAGS=-D__private_extern__=extern"
-    - name: "macOS/Xcode 12/Shared"
-      os: osx
-      osx_image: xcode12
-      env:
-        - BUILD_DIR=unix
-        - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include"
-      install:
-        - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1)
-      script: &mactest
-        - make all tktest
     - name: "macOS/Xcode 12/Static"
       os: osx
       osx_image: xcode12
       env:
         - BUILD_DIR=unix
         - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua --disable-shared CFLAGS=-I/usr/local/opt/tcl-tk/include"
-      install:
-        - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1)
-      script: *mactest
     - name: "macOS/Xcode 12/Debug"
       os: osx
       osx_image: xcode12
       env:
         - BUILD_DIR=unix
         - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua --enable-symbols CFLAGS=-I/usr/local/opt/tcl-tk/include"
-      install:
-        - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1)
-      script: *mactest
-    - name: "macOS/Xcode 12/Shared/XQuartz"
-      os: osx
-      osx_image: xcode12
-      env:
-        - BUILD_DIR=unix
-        - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --disable-corefoundation --x-includes=/opt/X11/include --x-libraries=/opt/X11/lib CFLAGS=-I/usr/local/opt/tcl-tk/include"
-      install:
-        - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1)
-      script: *mactest
+#   - name: "macOS/Xcode 12/Shared/XQuartz"
+#     os: osx
+#     osx_image: xcode12
+#     env:
+#       - BUILD_DIR=unix
+#       - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --disable-corefoundation --x-includes=/opt/X11/include --x-libraries=/opt/X11/lib CFLAGS=-I/usr/local/opt/tcl-tk/include"
 # Older MacOS versions
     - name: "macOS/Xcode 11/Shared"
       os: osx
       osx_image: xcode11.7
       env:
         - BUILD_DIR=unix
         - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include CPPFLAGS=-mmacosx-version-min=10.14"
-      install:
-        - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1)
-      script: *mactest
     - name: "macOS/Xcode 10/Shared"
       os: osx
       osx_image: xcode10.3
       addons:
         homebrew:
@@ -237,13 +230,10 @@
             - tcl-tk
           update: true
       env:
         - BUILD_DIR=unix
         - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include CPPFLAGS=-mmacosx-version-min=10.14"
-      install:
-        - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1)
-      script: *mactest
     - name: "macOS/Xcode 9/Shared"
       os: osx
       osx_image: xcode9.4
       addons:
         homebrew:
@@ -251,13 +241,10 @@
             - tcl-tk
           update: true
       env:
         - BUILD_DIR=unix
         - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include CPPFLAGS=-mmacosx-version-min=10.13"
-      install:
-        - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1)
-      script: *mactest
 # Test on Windows with MSVC native
 #   - name: "Windows/MSVC/Shared"
 #     os: windows
 #     compiler: cl
 #     env: &vcenv
@@ -290,9 +277,17 @@
   - mkdir "$HOME/install dir"
   - ./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 1)
 script:
   - make all tktest
   - make install
+before_cache:
+  - |-
+      case $TRAVIS_OS_NAME in
+        osx)
+          brew cleanup
+          ;;
+      esac
 cache:
   directories:
+  - $HOME/Library/Caches/Homebrew
   - $HOME/AppData/Local/Temp/chocolatey
   - $HOME/AppData/Local/Apps/Tcl86

Index: ChangeLog
==================================================================
--- ChangeLog
+++ ChangeLog
@@ -3201,11 +3201,11 @@
 	fonts to use for measurements.
 
 2009-03-25  Jan Nijtmans  <nijtmans@users.sf.net>
 
 	* doc/wish.1:		Bring doc and demos in line with
-	* library/demos/hello:	http://wiki.tcl.tk/812
+	* library/demos/hello:	https://wiki.tcl-lang.org/page/exec+magic
 	* library/demos/rmt
 	* library/demos/square
 	* library/demos/tcolor
 	* library/demos/timer
 	* library/demos/widget

Index: README.md
==================================================================
--- README.md
+++ README.md
@@ -1,32 +1,41 @@
 # README:  Tk
 
-This is the **Tk 8.7a4** source distribution.
+This is the **Tk 8.7a6** source distribution.
 
 You can get any source release of Tk from [our distribution
 site](https://sourceforge.net/projects/tcl/files/Tcl/).
 
+8.6 (production release, daily build)
+[![Build Status](https://github.com/tcltk/tk/workflows/Linux/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Linux%22+branch%3Acore-8-6-branch)
+[![Build Status](https://github.com/tcltk/tk/workflows/Windows/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Windows%22+branch%3Acore-8-6-branch)
+[![Build Status](https://github.com/tcltk/tk/workflows/macOS/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tk/actions?query=workflow%3A%22macOS%22+branch%3Acore-8-6-branch)
+<br>
+8.7 (in development, daily build))
+[![Build Status](https://github.com/tcltk/tk/workflows/Linux/badge.svg?branch=main)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Linux%22+branch%3Amain)
+[![Build Status](https://github.com/tcltk/tk/workflows/Windows/badge.svg?branch=main)](https://github.com/tcltk/tk/actions?query=workflow%3A%22Windows%22+branch%3Amain)
+[![Build Status](https://github.com/tcltk/tk/workflows/macOS/badge.svg?branch=main)](https://github.com/tcltk/tk/actions?query=workflow%3A%22macOS%22+branch%3Amain)
 
 ## <a id="intro">1.</a> Introduction
 
 This directory contains the sources and documentation for Tk, a
 cross-platform GUI toolkit implemented with the Tcl scripting language.
 
 For details on features, incompatibilities, and potential problems with
-this release, see [the Tcl/Tk 8.7 Web page](https://www.tcl.tk/software/tcltk/8.7.html)
+this release, see [the Tcl/Tk 8.7 Web page](https://www.tcl-lang.org/software/tcltk/8.7.html)
 or refer to the "changes" file in this directory, which contains a
 historical record of all changes to Tk.
 
 Tk is maintained, enhanced, and distributed freely by the Tcl community.
 Source code development and tracking of bug reports and feature requests
-takes place at [core.tcl-lang.org](https://core.tcl-lang.org/).
+take place at [core.tcl-lang.org](https://core.tcl-lang.org/).
 Tcl/Tk release and mailing list services are [hosted by
 SourceForge](https://sourceforge.net/projects/tcl/)
 with the Tcl Developer Xchange hosted at
 [www.tcl-lang.org](https://www.tcl-lang.org).
 
-Tk is a freely available open source package.  You can do virtually
+Tk is a freely available open-source package.  You can do virtually
 anything you like with it, such as modifying it, redistributing it,
 and selling it either in whole or in part.  See the file
 `license.terms` for complete information.
 
 ## <a id="tcl">2.</a> See Tcl README.md

Index: changes
==================================================================
--- changes
+++ changes
@@ -7435,11 +7435,11 @@
 
 2017-04-13 \u escaped content in msg files converted to true utf-8 (nijtmans)
 
 2017-08-28 (TIP 166) Extended color notation for alpha channel (bachmann)
 
---- Released 8.7a1, September 8, 2017 --- http://core.tcl.tk/tk/ for details
+--- Released 8.7a1, September 8, 2017 --- https://core.tcl-lang.org/tk/ for details
 
 2017-08-24 (bug)[f1a3ca] Memory leak in [text] B-tree (edhume3)
 
 2017-08-24 (bug)[ee40fd] Report [console] init errors (the)
 
@@ -7720,10 +7720,215 @@
 
 2019-11-19 (new) Partial Emoji support in text displays (nijtmans,culler)
 
 - Released 8.6.10, Nov 21, 2019 - https://core.tcl-lang.org/tk/ for details
 
+2019-11-25 (bug)[a95373] TkKeyEvent platform variations (werner)
+
+2019-11-26 (bug) workaround Win bug so test bind-34.3 passes (nijtmans)
+
+2019-12-03 Aqua: white cursors in dark mode (culler)
+
+2019-12-04 (bug)[749bd9] Aqua: systemControlAccentColor (bll,culler)
+
+2019-12-14 (bug)[b3b56a] ttk respect -cursor option (vogel)
+
+2019-12-14 (bug)[b094cb] Win: $tv -show grows widget width 1 pixel (vogel)
+
+2019-12-14 (bug)[02a694] spinbox options used wrong db names (vogel)
+
+2020-01-11 (bug)[2b8fa6] MouseWheel for ttk::scrollbar (oehlmann)
+
+2020-01-18 (bug)[1771594] icursor and scrollregion, canvText-14.7 (vogel)
+
+2020-01-18 (bug)[587937] tag list ops preserve list order (vogel)
+
+2020-01-18 (bug)[2830360] lose invalid state at focus event, entry-10.1 (vogel)
+
+2020-01-18 (bug)[077d49] string table options support null ok (vogel)
+
+2020-01-18 (bug)[bf93d0] Aqua: unresponsive menubar (culler)
+
+2020-01-31 (bug)[a196fb] restore support for unthreaded Tcl (porter,sebres)
+
+2020-02-09 (bug)[90a4d7] fontconfig crash when no font installed (vogel)
+
+2020-02-24 (bug) Aqua: incomplete floating window display (walzer)
+
+2020-03-11 (bug)[fb2ec3] OSX 10.15+: full screen options (nicolas,walzer)
+
+2020-03-12 (bug)[08e2f8] focus on unmapped windows, focus-7.1 (vogel)
+
+2020-03-12 (bug)[2edd84] [$c postscript] result management (gavilan)
+
+2020-03-22 (bug)[98662d] restore TK_MAC_DEBUG_DRAWING build (chavez)
+
+2020-03-29 (bug)[655fe2] tearoff menu redraw artifacts (vogel)
+
+2020-04-03 (bug)[efbedd] Aqua: compund button-like widget appearance (chavez)
+
+2020-04-14 (bug)[87bade] Aqua: improved dealing with PressAndHold (culler)
+
+2020-04-14 (bug)[376788] X: stop crash w/Noto Color Emoji font (nijtmans)
+
+2020-04-15 (bug)[89354d] Aqua: text color w/o clipping (culler)
+
+2020-04-15 (new) Aqua: assign Button 3 to the middle button (chavez)
+
+2020-04-25 (bug)[3519111] treeview horizontal scroll, entry-2.1.1 (vogel)
+
+2020-04-25 (bug)[141881] treeview vertical scroll, treeview-9.2 (vogel)
+
+2020-05-01 (bug)[2712f4] X: crash angled text w/o Xft, canvText-20.2 (vogel)
+
+2020-05-01 (bug)[cd8714] Win: long angled text (chavez)
+
+2020-05-09 (bug)[88c9e0] treeview -selectmode none focus ring (gavilan)
+
+2020-05-12 (new) Aqua: Rewrite of the Key event system (culler)
+
+2020-05-12 (bug)[411359] Aqua: stop crashes/zombies related to TouchBar (culler)
+
+2020-05-12 (new) Aqua: systemLinkColor (chavez)
+
+2020-05-16 (bug)[40ada9] crash when active button is destroyed (chavez)
+
+2020-05-28 (bug)[3c6660,601cea,4b50b7] Win10: ttk scale (nemethi,lanam)
+
+2020-06-08 (bug)[2790615] Some callbacks not eval'd in global scope (nijtmans)
+
+2020-06-25 Aqua: Update OSX version tests to support Big Sur (culler)
+
+2020-06-27 (bug)[6920b2] dup in spinbox -values causes trouble (lanam)
+
+2020-06-27 (bug)[5c51be] invalid mem read buffer in Tk_PhotoPut* (chavez)
+
+2020-06-27 (bug)[16ef16] restore bind sequence support, bind-33.(16-21) (vogel)
+
+2020-07-02 (bug)[2d2459] default style for combobox (bll)
+
+2020-07-06 (bug)[40e4bf] double free, entry-19.21 (vogel)
+
+2020-07-06 (bug)[e3888d] grab & warp, bind-36.1 (vogel)
+
+2020-07-12 (bug)[2442314] fontchooser i18n (nijtmans)
+
+2020-07-13 (bug)[7655f6] [*entry]: selected text drawing reform (chavez)
+
+2020-07-14 (bug)[09abd7] workaround invalid key codes from Debian 10 (vogel)
+
+2020-07-20 (bug)[cf3853] Aqua: improve bounds on non-Retina displays (chavez)
+
+2020-08-01 Aqua: [winfo rgb] light and dark mode support (culler)
+
+2020-08-15 (bug)[315104] Aqua: appearance change virtual events (culler)
+
+2020-08-21 (bug)[291699] mouse binding for scrollbar grip (bll)
+
+2020-09-08 (bug)[6c2425] buffer bounds violation (chavez)
+
+2020-09-08 (bug)[2a6d63] OSX 10.6 crash (hellstrom,culler)
+
+2020-09-08 (bug)[420feb] undefined behavior due to alignment (chavez,nijtmans)
+
+2020-09-10 (bug)[ab1fea] Aqua init issues (culler)
+
+2020-09-14 (bug)[71e18c] Aqua: crash in full screen toggle (culler)
+
+2020-09-18 (bug)[4f4f03] Aqua: mouse drags across title bar (nab,culler)
+
+2020-09-21 (bug)[d91e05] select/copy in disabled text (bll)
+
+2020-09-27 (TIP #581) disfavor Master/Slave terminology (nijtmans)
+
+2020-09-30 (bug)[59cba3] win: improve theme detection (bll,nijtmans)
+
+2020-10-06 (bug)[175a6e] Aqua: support tiled windows (culler)
+
+2020-10-07 (bug)[1fa8c3] Aqua: crash on resize during display (nab,culler)
+
+2020-10-16 (bug)[c2483b] Aqua: consistent finalization (culler,nijtmans)
+
+2020-11-06 (bug)[c9ebac] Aqua: use standard about dialog (culler)
+
+2020-11-07 (bug)[4ebcc0] sticky fontchooser options (roseman,vogel)
+
+2020-11-10 (bug)[f9fa92] Aqua: crash in color caching scheme (culler)
+
+2020-11-20 (bug)[7185d2] Aqua: fixes to special menu support (culler)
+
+2020-11-24 (bug)[4a40c6] Aqua: [wm manage] frame offset (chavez)
+
+2020-12-04 (bug)[3ef77f] Aqua dark mode combobox focus ring (walzer,culler)
+
+2020-12-15 (bug)[80e4c6] Aqua: progressbar animation (nab,culler)
+
+2020-12-24 (bug)[6157a8] Aqua: file dialog -filetypes (davis,culler)
+
+- Released 8.6.11, Dec 31, 2020 - https://core.tcl-lang.org/tk/ for details
+
+2021-01-04 (bug)[19fb7a] Mac: [tk_messageBox] use proper icons (ericwb,culler)
+
+2021-01-11 (bug)[7beaed] ttk::bindMouseWheel syntax error (nemethi)
+
+2021-01-15 (new) support 4 new keycodes: CodeInput, SingleCandidate,
+	MultipleCandidate, PreviousCandidate (nijtmans)
+
+2021-01-18 (new) Portable keycodes: OE, oe, Ydiaeresis (nijtmans)
+
+2021-01-27 (bug)[bdcab8] Mac crash on non-BMP menu label (nab,culler)
+
+2021-02-07 (bug)[9e1312] <Enter> to parent after child destroyed (leunissen)
+
+2021-02-10 (bug)[d3cd4c] more robust notebook processing (nemethi)
+
+2021-02-25 (bug)[234ee4] crash in [clipboard get] invalid encoding (nijtmans)
+
+2021-02-25 (bug)[be9cad] Poor trace housekeeping -> tkwait segfault (michael)
+
+2021-03-02 (bug)[1626ed] Mac: crash with dead key as menu accelerator (culler)
+
+2021-03-22 (bug)[9b6065] restore Tcl [update], see window-2.12 (leunissen)
+
+2021-04-07 (bug)[58222c] Mac: entry and spinbox bg colors (chavez,culler)
+
+2021-04-18 (bug)[34db75,ea876b] cursor motion in peer text (vogel)
+
+2021-04-26 (bug)[c97464] memleak in TkpDrawAngledChars (nab,culler)
+
+2021-04-29 Mac: explicit backing CALayer to fix rendering issues (culler)
+
+2021-05-02 Mac: respect key repeat system setting (culler)
+
+2021-05-10 (bug)[171ba7] crash when grab and focus are not coordinated (culler)
+
+2021-05-24 crash due to failed transient record housekeeping (culler)
+
+2021-05-25 (bug)[7bda98] Mac: <Double-1> bindings fire twice on app activation
+
+2021-06-03 (bug)[4401d3] Mac: improved support of pixel formats (chavez,culler)
+
+2021-06-03 (bug)[8ecc3e] Mac: window exposed by Mission Control (chavez,culler)
+
+2021-06-04 (bug)[099109] segfault reusing a container toplevel (culler)
+
+2021-06-22 (bug)[4efbfe] static package init order in wish (werner)
+
+2021-09-21 (bug)[033886] Win: hang in font loading (e-paine,vogel)
+
+2021-10-14 (bug)[8ebed3] multi-thread safety in Xft use (werner)
+
+2021-10-22 (new)[TIP 608] New virtual event <<TkWorldChanged>> (griffin)
+
+2021-10-27 (bug) file dialog compatibility with Mac OS 12 (culler)
+
+2021-10-29 (bug) Mac: stop crash when non-Tk windows go full screen (werner)
+
+2021-10-30 (bug)[6ea0b3] Mac: grab from menu makes dead window (culler)
+
+- Released 8.6.12, Nov 5, 2021 - https://core.tcl-lang.org/tk/ for details
+
 Changes to 8.7a3 include all changes to the 8.6 line through 8.6.10,
 plus the following, which focuses on the high-level feature changes
 in this changeset (new minor version) rather than bug fixes:
 
 2017-11-25 [TIP 161] $menu -tearoff default changed to false (roseman,vogel)
@@ -7739,11 +7944,11 @@
 
 2018-11-03 [TIP 512] Deprecate stub for Tk_MainEx() (nijtmans)
 
 2018-11-06 [TIP 415] New option -height for [$canvas create arc] (geard)
 
-2018-11-06 [TIP 518] New event <<NoMangedChild>> (oehlmann)
+2018-11-06 [TIP 518] New event <<NoManagedChild>> (oehlmann)
 
 2019-04-14 [TIP 164] New subcommand [$canvas rotate] (fellows)
 
 2019-04-14 [TIP 507] New photo image format 'svg' (zaumseil)
 
@@ -7755,6 +7960,83 @@
 
 2019-06-15 [TIP 528] Deprecate Tk_Offset() (nijtmans)
 
 2019-08-19 [TIP 545] Revised options for photo image format 'svg' (oehlmann)
 
---- Released 8.7a3, November 25, 2019 --- http://core.tcl.tk/tk/ for details
+--- Released 8.7a3, November 25, 2019 --- https://core.tcl-lang.org/tk/ for details
+
+Changes to 8.7a5 include all changes to the 8.6 line through 8.6.11,
+plus the following, which focuses on the high-level feature changes
+in this changeset (new minor version) rather than bug fixes:
+
+2020-02-22 [TIP 565] Gracefully ignore non-existent tags in canvas raise/lower
+
+2020-02-22 [TIP 564] Specify ttk font sizes in points on X11
+
+2020-02-24 [TIP 563] Scrollwheel on Horizontal Scrollbar Scrolls Without Shift too
+
+2020-02-28 [TIP 557] C++ support
+
+2020-03-12 (bug)[355180] solve XKeycodeToKeysym deprecation
+        *** POTENTIAL INCOMPATIBILITY -- Tk 8.7 now requires X11R6 ***
+
+2020-03-18 [TIP 569] Eliminate comments that serve lint
+
+2020-05-17 [d87dc2] Remove TkMacOSXGetStringObjFromCFString()
+
+2020-05-24 [TIP 574] Add a 'tag delete' command to the ttk::treeview widget
+
+2020-06-27 (bug)[50ed1e] spinbox with duplicate values
+
+2020-07-03 [TIP 578] Death to TCL_DBGX
+
+2020-08-23 (bug)[bb85d2] valgrind on TIP 489
+
+2020-08024 (bug)[d30c21] default colors for TIP 496
+
+2020-09-02 [TIP 580] Export Tk_GetDoublePixelsFromObj and 5 more
+
+2020-10-21 [TIP 474] Uniform mouse wheel events
+
+2020-11-15 [TIP 584] Better introspection for ttk
+
+2020-11-16 [TIP 588] Unicode for (X11) keysyms
+
+2020-12-03 [TIP 590] Recommend lowercase package names
+
+2020-12-09 (bug)[d6e9b4] SVG memory overflow
+
+2020-12-11 [TIP 591] Rotate ttk::notebook window with mousewheel on tab
+
+2020-12-12 [TIP 325] System tray and system notification
+
+2021-01-08 [TIP 592] End support: Windows XP, Server 2003, Vista, Server 2008
+
+2021-01-08 (bug)[822330] Prevent buffer overflow in SVG image.
+
+2021-01-28 (bug)[237971] 'end' argument to [$canvas insert]
+
+2021-02-25 (bug)[be9cad] crash in [tkwait]
+
+2021-02-27 [TIP 529] Add metadata dictionary property to tk photo image
+
+2021-03-02 (bug)[1626ed] Aqua crash: dead keys as meny accelerator
+
+2021-03-29 (bug)[9b6065] Restore Tcl [update] when Tk is destroyed
+
+2021-04-08 (bug)[58222c] background colors
+
+2021-04-09 [TIP 595] Unicode-aware/case-sensitive Loadable Library handling
+
+2021-04-21 (bug)[cde766] update scrollbars on treeview
+
+2021-04-26 (bug)[c97464] memleak in aqua fonts
+
+2021-05-02 (bug)[2ecb09] Follow Mac OSX Key-repeat setting
+
+2021-05-03 (bug)[8a5086] ttk::entry issue
+
+2021-05-22 (bug)[3e3360] bind substitution %S
+
+2021-05-25 (bug)[7bda98] aqua: double click bind with changing focus
+
+- Released 8.7a5, Jun 18, 2021 --- https://core.tcl-lang.org/tcl/ for details -

Index: doc/3DBorder.3
==================================================================
--- doc/3DBorder.3
+++ doc/3DBorder.3
@@ -7,21 +7,30 @@
 '\"
 .TH Tk_Alloc3DBorderFromObj 3 8.1 Tk "Tk Library Procedures"
 .so man.macros
 .BS
 .SH NAME
-Tk_Alloc3DBorderFromObj, Tk_Get3DBorder, Tk_Get3DBorderFromObj, Tk_Draw3DRectangle, Tk_Fill3DRectangle, Tk_Draw3DPolygon, Tk_Fill3DPolygon, Tk_3DVerticalBevel, Tk_3DHorizontalBevel, Tk_SetBackgroundFromBorder, Tk_NameOf3DBorder, Tk_3DBorderColor, Tk_3DBorderGC, Tk_Free3DBorderFromObj, Tk_Free3DBorder \- draw borders with three-dimensional appearance
+Tk_Alloc3DBorderFromObj, Tk_ClipDrawableToRect, Tk_DrawHighlightBorder, Tk_Get3DBorder, fBTk_Get3DBorderColors, Tk_Get3DBorderFromObj, Tk_Draw3DRectangle, Tk_Fill3DRectangle, Tk_Draw3DPolygon, Tk_Fill3DPolygon, Tk_3DVerticalBevel, Tk_3DHorizontalBevel, Tk_SetBackgroundFromBorder, Tk_NameOf3DBorder, Tk_3DBorderColor, Tk_3DBorderGC, Tk_Free3DBorderFromObj, Tk_Free3DBorder \- draw borders with three-dimensional appearance
 .SH SYNOPSIS
 .nf
 \fB#include <tk.h>\fR
 .sp
 Tk_3DBorder
 \fBTk_Alloc3DBorderFromObj(\fIinterp, tkwin, objPtr\fB)\fR
 .sp
+void
+\fBTk_ClipDrawableToRect(\fIdisplay, drawable, x, y, width, height\fB)\fR
+.sp
+void
+\fBTk_DrawHighlightBorder(\fItkwin, fgGC, bgGC, highlightWidth, drawable\fB)\fR
+.sp
 Tk_3DBorder
 \fBTk_Get3DBorder(\fIinterp, tkwin, colorName\fB)\fR
 .sp
+void
+\fBTk_Get3DBorderColors(\fIborder, bgColorPtr, darkColorPtr, lightColorPtr\fB)\fR
+.sp
 Tk_3DBorder
 \fBTk_Get3DBorderFromObj(\fItkwin, objPtr\fB)\fR
 .sp
 void
 \fBTk_Draw3DRectangle(\fItkwin, drawable, border, x, y, width, height, borderWidth, relief\fB)\fR
@@ -88,10 +97,12 @@
 Height of rectangle describing border or bevel, in pixels.
 .AP int borderWidth in
 Width of border in pixels. Positive means border is inside rectangle
 given by \fIx\fR, \fIy\fR, \fIwidth\fR, \fIheight\fR, negative means
 border is outside rectangle.
+.AP int highlightWidth in
+Width of ring around the outside of the widget if the widget has received the input focus.
 .AP int relief in
 Indicates 3-D position of interior of value relative to exterior;
 should be \fBTK_RELIEF_RAISED\fR, \fBTK_RELIEF_SUNKEN\fR, \fBTK_RELIEF_GROOVE\fR,
 \fBTK_RELIEF_SOLID\fR, or \fBTK_RELIEF_RIDGE\fR (may also be \fBTK_RELIEF_FLAT\fR
 for \fBTk_Fill3DRectangle\fR).
@@ -131,10 +142,20 @@
 Non-zero means this bevel forms the top side of the value;  zero means
 it forms the bottom side.
 .AP int which in
 Specifies which of the border's graphics contexts is desired.
 Must be \fBTK_3D_FLAT_GC\fR, \fBTK_3D_LIGHT_GC\fR, or \fBTK_3D_DARK_GC\fR.
+.AP XColor *bgColorPtr out
+Pointer to location in which to store the background color of the given border.
+.AP XColor *darkColorPtr out
+Pointer to location in which to store the color for darker areas of the given border.
+.AP XColor *lightColorPtr out
+Pointer to location in which to store the color for lighter areas of the given border.
+.AP GC fgGC in
+Foreground X graphics context.
+.AP GC fgGC in
+Background X graphics context.
 .BE
 .SH DESCRIPTION
 .PP
 These procedures provide facilities for drawing window borders in a
 way that produces a three-dimensional appearance.
@@ -156,15 +177,28 @@
 interpreter \fIinterp\fR.
 If it returns successfully, \fBTk_Alloc3DBorderFromObj\fR caches
 information about the return value in \fIobjPtr\fR, which speeds up
 future calls to \fBTk_Alloc3DBorderFromObj\fR with the same \fIobjPtr\fR
 and \fItkwin\fR.
+.PP
+\fBTk_ClipDrawableToRect\fR will clip all drawing into the drawable d to the given rectangle. If width or height are negative, reset to no clipping.
+Subsequent drawing into d is offset and clipped as specified.
+The function is only used when \fBTK_NO_DOUBLE_BUFFERING\fR is specified at compile time.
+.PP
+\fBTk_DrawHighlightBorder\fR draws a rectangular ring around the outside of a widget
+to indicate that it has received the input focus.
+On the Macintosh, this puts a 1 pixel border in the bgGC color between
+the widget and the focus ring, except in the case where highlightWidth
+is 1, in which case the border is left out.
+For proper Mac L&F, use highlightWidth of 3.
 .PP
 \fBTk_Get3DBorder\fR is identical to \fBTk_Alloc3DBorderFromObj\fR except
 that the color is specified with a string instead of a value.  This
 prevents \fBTk_Get3DBorder\fR from caching the return value, so
 \fBTk_Get3DBorder\fR is less efficient than \fBTk_Alloc3DBorderFromObj\fR.
+.PP
+\fBTk_Get3DBorderColors\fR returns the used colors of the given border.
 .PP
 \fBTk_Get3DBorderFromObj\fR returns the token for an existing border, given
 the window and color name used to create the border.
 \fBTk_Get3DBorderFromObj\fR does not actually create the border; it must
 already have been created with a previous call to

Index: doc/AddOption.3
==================================================================
--- doc/AddOption.3
+++ doc/AddOption.3
@@ -1,7 +1,7 @@
 '\"
-'\" Copyright (c) 1998-2000 by Scriptics Corporation.
+'\" Copyright (c) 1998-2000 Scriptics Corporation.
 '\" All rights reserved.
 '\"
 .TH Tk_AddOption 3 "" Tk "Tk Library Procedures"
 .so man.macros
 .BS
@@ -11,23 +11,30 @@
 .nf
 \fB#include <tk.h>\fR
 .sp
 void
 \fBTk_AddOption\fR(\fItkwin, name, value, priority\fR)
+.sp
+void
+\fBTk_GetSystemDefault\fR(\fItkwin, dbName, className\fR)
 .SH ARGUMENTS
 .AP Tk_Window tkwin in
 Token for window.
 .AP "const char" *name in
 Multi-element name of option.
 .AP "const char" *value in
 Value of option.
+.AP "const char" *dbName in
+The option database name.
+.AP "const char" *className in
+The name of the option class.
 .AP int priority in
 Overall priority level to use for option.
 .BE
 .SH DESCRIPTION
 .PP
-This procedure is invoked to add an option to the database
+\fBTk_AddOption\fR is invoked to add an option to the database
 associated with \fItkwin\fR's main window.  \fIName\fR
 contains the option being specified and consists of names and/or
 classes separated by asterisks or dots, in the usual X format.
 \fIValue\fR contains the text string to associate with \fIname\fR;
 this value will be returned in calls to \fBTk_GetOption\fR.
@@ -44,7 +51,9 @@
 \fB.Xdefaults\fR, resource databases loaded into the X server, or
 user-specific startup files.
 .IP 80
 Used for options specified interactively after the application starts
 running.
+\fBTk_GetSystemDefault\fR return a Tk_Uid string representation of the given \fIdbname\fR and \fIclassName\fR of a configuration option.
+Returns NULL if there are no system defaults that match this pair.
 .SH KEYWORDS
 class, name, option, add

Index: doc/CrtPhImgFmt.3
==================================================================
--- doc/CrtPhImgFmt.3
+++ doc/CrtPhImgFmt.3
@@ -7,28 +7,36 @@
 '\"
 '\" Author: Paul Mackerras (paulus@cs.anu.edu.au),
 '\"	    Department of Computer Science,
 '\"	    Australian National University.
 '\"
-.TH Tk_CreatePhotoImageFormat 3 8.5 Tk "Tk Library Procedures"
+.TH Tk_CreatePhotoImageFormat 3 8.7 Tk "Tk Library Procedures"
 .so man.macros
 .BS
 .SH NAME
 Tk_CreatePhotoImageFormat \- define new file format for photo images
 .SH SYNOPSIS
 .nf
 \fB#include <tk.h>\fR
+.sp
+.VS 8.7
+\fBTk_CreatePhotoImageFormatVersion3\fR(\fIformatVersion3Ptr\fR)
+.VE 8.7
 .sp
 \fBTk_CreatePhotoImageFormat\fR(\fIformatPtr\fR)
 .SH ARGUMENTS
-.AS "const Tk_PhotoImageFormat" *formatPtr
+.AS "const Tk_PhotoImageFormatVersion3" *formatVersion3Ptr
+.VS 8.7
+.AP "const Tk_PhotoImageFormatVersion3" *formatVersion3Ptr in
+Structure that defines the new file format including metadata functionality.
+.VE 8.7
 .AP "const Tk_PhotoImageFormat" *formatPtr in
 Structure that defines the new file format.
 .BE
 .SH DESCRIPTION
 .PP
-\fBTk_CreatePhotoImageFormat\fR is invoked to define a new file format
+\fBTk_CreatePhotoImageFormatVersion3\fR is invoked to define a new file format
 for image data for use with photo images.  The code that implements an
 image file format is called an image file format handler, or
 handler for short.  The photo image code
 maintains a list of handlers that can be used to read and
 write data to or from a file.  Some handlers may also
@@ -35,27 +43,34 @@
 support reading image data from a string or converting image data to a
 string format.
 The user can specify which handler to use with the \fB\-format\fR
 image configuration option or the \fB\-format\fR option to the
 \fBread\fR and \fBwrite\fR photo image subcommands.
+.PP
+The alternate version 2 function \fBTk_CreatePhotoImageFormat\fR has
+identical functionality, but does not allow the handler to get or return
+the metadata dictionary of the image.
+It is described in section \fBVERSION 2 INTERFACE\fR below.
 .PP
 An image file format handler consists of a collection of procedures
-plus a Tk_PhotoImageFormat structure, which contains the name of the
-image file format and pointers to six procedures provided by the
-handler to deal with files and strings in this format.  The
-Tk_PhotoImageFormat structure contains the following fields:
+plus a \fBTk_PhotoImageFormatVersion3\fR structure, which contains the
+name of the image file format and pointers to six procedures provided
+by the handler to deal with files and strings in this format.  The
+Tk_PhotoImageFormatVersion3 structure contains the following fields:
+.VS 8.7
 .CS
-typedef struct Tk_PhotoImageFormat {
+typedef struct Tk_PhotoImageFormatVersion3 {
     const char *\fIname\fR;
-    Tk_ImageFileMatchProc *\fIfileMatchProc\fR;
-    Tk_ImageStringMatchProc *\fIstringMatchProc\fR;
-    Tk_ImageFileReadProc *\fIfileReadProc\fR;
-    Tk_ImageStringReadProc *\fIstringReadProc\fR;
-    Tk_ImageFileWriteProc *\fIfileWriteProc\fR;
-    Tk_ImageStringWriteProc *\fIstringWriteProc\fR;
-} \fBTk_PhotoImageFormat\fR;
+    Tk_ImageFileMatchProcVersion3 *\fIfileMatchProc\fR;
+    Tk_ImageStringMatchProcVersion3 *\fIstringMatchProc\fR;
+    Tk_ImageFileReadProcVersion3 *\fIfileReadProc\fR;
+    Tk_ImageStringReadProcVersion3 *\fIstringReadProc\fR;
+    Tk_ImageFileWriteProcVersion3 *\fIfileWriteProc\fR;
+    Tk_ImageStringWriteProcVersion3 *\fIstringWriteProc\fR;
+} \fBTk_PhotoImageFormatVersion3\fR;
 .CE
+.VE 8.7
 .PP
 The handler need not provide implementations of all six procedures.
 For example, the procedures that handle string data would not be
 provided for a format in which the image data are stored in binary,
 and could therefore contain null characters.  If any procedure is not
@@ -65,58 +80,68 @@
 procedure, and the \fIstringMatchProc\fR procedure if it provides the
 \fIstringReadProc\fR procedure.
 .SS NAME
 .PP
 \fIformatPtr->name\fR provides a name for the image type.
-Once \fBTk_CreatePhotoImageFormat\fR returns, this name may be used
-in the \fB\-format\fR photo image configuration and subcommand option.
+Once \fBTk_CreatePhotoImageFormatVersion3\fR returns, this name may be
+used in the \fB\-format\fR photo image configuration and subcommand
+option.
 The manual page for the photo image (photo(n)) describes how image
 file formats are chosen based on their names and the value given to
 the \fB\-format\fR option. The first character of \fIformatPtr->name\fR
 must not be an uppercase character from the ASCII character set
 (that is, one of the characters \fBA\fR-\fBZ\fR).  Such names are used
 only for legacy interface support (see below).
+.VS 8.7
 .SS FILEMATCHPROC
 .PP
 \fIformatPtr->fileMatchProc\fR provides the address of a procedure for
 Tk to call when it is searching for an image file format handler
 suitable for reading data in a given file.
 \fIformatPtr->fileMatchProc\fR must match the following prototype:
 .CS
-typedef int \fBTk_ImageFileMatchProc\fR(
+typedef int \fBTk_ImageFileMatchProcVersion3\fR(
+        Tcl_Interp *\fIinterp\fR,
         Tcl_Channel \fIchan\fR,
         const char *\fIfileName\fR,
         Tcl_Obj *\fIformat\fR,
+        Tcl_Obj *\fImetadataIn\fR,
         int *\fIwidthPtr\fR,
         int *\fIheightPtr\fR,
-        Tcl_Interp *\fIinterp\fR);
+        Tcl_Obj *\fImetadataOut\fR);
 .CE
 The \fIfileName\fR argument is the name of the file containing the
 image data, which is open for reading as \fIchan\fR.  The
 \fIformat\fR argument contains the value given for the
 \fB\-format\fR option, or NULL if the option was not specified.
+\fBmetadataIn\fR and \fBmetadataOut\fR inputs and returns a metadata
+dictionary as described in section \fBMETADATA INTERFACE\fR below.
 If the data in the file appears to be in the format supported by this
 handler, the \fIformatPtr->fileMatchProc\fR procedure should store the
 width and height of the image in *\fIwidthPtr\fR and *\fIheightPtr\fR
 respectively, and return 1.  Otherwise it should return 0.
 .SS STRINGMATCHPROC
 .PP
-\fIformatPtr->stringMatchProc\fR provides the address of a procedure for
-Tk to call when it is searching for an image file format handler for
+\fIformatPtr->stringMatchProc\fR provides the address of a procedure
+for Tk to call when it is searching for an image file format handler
 suitable for reading data from a given string.
 \fIformatPtr->stringMatchProc\fR must match the following prototype:
 .CS
-typedef int \fBTk_ImageStringMatchProc\fR(
+typedef int \fBTk_ImageStringMatchProcVersion3\fR(
+        Tcl_Interp *\fIinterp\fR,
         Tcl_Obj *\fIdata\fR,
         Tcl_Obj *\fIformat\fR,
+        Tcl_Obj *\fImetadataIn\fR,
         int *\fIwidthPtr\fR,
         int *\fIheightPtr\fR,
-        Tcl_Interp *\fIinterp\fR);
+        Tcl_Obj *\fImetadataOut\fR);
 .CE
 The \fIdata\fR argument points to the object containing the image
 data.  The \fIformat\fR argument contains the value given for
 the \fB\-format\fR option, or NULL if the option was not specified.
+\fBmetadataIn\fR and \fBmetadataOut\fR inputs and returns a metadata
+dictionary as described in section \fBMETADATA INTERFACE\fR below.
 If the data in the string appears to be in the format supported by
 this handler, the \fIformatPtr->stringMatchProc\fR procedure should
 store the width and height of the image in *\fIwidthPtr\fR and
 *\fIheightPtr\fR respectively, and return 1.  Otherwise it should
 return 0.
@@ -129,14 +154,16 @@
 typedef int \fBTk_ImageFileReadProc\fR(
         Tcl_Interp *\fIinterp\fR,
         Tcl_Channel \fIchan\fR,
         const char *\fIfileName\fR,
         Tcl_Obj *\fIformat\fR,
+        Tcl_Obj *\fImetadataIn\fR,
         PhotoHandle \fIimageHandle\fR,
         int \fIdestX\fR, int \fIdestY\fR,
         int \fIwidth\fR, int \fIheight\fR,
-        int \fIsrcX\fR, int \fIsrcY\fR);
+        int \fIsrcX\fR, int \fIsrcY\fR,
+        Tcl_Obj *\fImetadataOut\fR);
 .CE
 The \fIinterp\fR argument is the interpreter in which the command was
 invoked to read the image; it should be used for reporting errors.
 The image data is in the file named \fIfileName\fR, which is open for
 reading as \fIchan\fR.  The \fIformat\fR argument contains the
@@ -146,38 +173,44 @@
 \fIimageHandle\fR.  The subimage of the data in the file is of
 dimensions \fIwidth\fR x \fIheight\fR and has its top-left corner at
 coordinates (\fIsrcX\fR,\fIsrcY\fR).  It is to be stored in the photo
 image with its top-left corner at coordinates
 (\fIdestX\fR,\fIdestY\fR) using the \fBTk_PhotoPutBlock\fR procedure.
+\fBmetadataIn\fR and \fBmetadataOut\fR inputs and returns a metadata
+dictionary as described in section \fBMETADATA INTERFACE\fR below.
 The return value is a standard Tcl return value.
 .SS STRINGREADPROC
 .PP
-\fIformatPtr->stringReadProc\fR provides the address of a procedure for
-Tk to call to read data from a string into a photo image.
+\fIformatPtr->stringReadProc\fR provides the address of a procedure
+for Tk to call to read data from a string into a photo image.
 \fIformatPtr->stringReadProc\fR must match the following prototype:
 .CS
 typedef int \fBTk_ImageStringReadProc\fR(
         Tcl_Interp *\fIinterp\fR,
         Tcl_Obj *\fIdata\fR,
         Tcl_Obj *\fIformat\fR,
+        Tcl_Obj *\fImetadataIn\fR,
         PhotoHandle \fIimageHandle\fR,
         int \fIdestX\fR, int \fIdestY\fR,
         int \fIwidth\fR, int \fIheight\fR,
-        int \fIsrcX\fR, int \fIsrcY\fR);
+        int \fIsrcX\fR, int \fIsrcY\fR,
+        Tcl_Obj *\fImetadataOut\fR);
 .CE
 The \fIinterp\fR argument is the interpreter in which the command was
 invoked to read the image; it should be used for reporting errors.
 The \fIdata\fR argument points to the image data in object form.
 The \fIformat\fR argument contains the
 value given for the \fB\-format\fR option, or NULL if the option was
-not specified.  The image data in the string, or a subimage of it, is to
-be read into the photo image identified by the handle
+not specified.  The image data in the string, or a subimage of it, is
+to be read into the photo image identified by the handle
 \fIimageHandle\fR.  The subimage of the data in the string is of
 dimensions \fIwidth\fR x \fIheight\fR and has its top-left corner at
 coordinates (\fIsrcX\fR,\fIsrcY\fR).  It is to be stored in the photo
 image with its top-left corner at coordinates
 (\fIdestX\fR,\fIdestY\fR) using the \fBTk_PhotoPutBlock\fR procedure.
+\fBmetadataIn\fR and \fBmetadataOut\fR inputs and returns a metadata
+dictionary as described in section \fBMETADATA INTERFACE\fR below.
 The return value is a standard Tcl return value.
 .SS FILEWRITEPROC
 .PP
 \fIformatPtr->fileWriteProc\fR provides the address of a procedure for
 Tk to call to write data from a photo image to a file.
@@ -185,10 +218,11 @@
 .CS
 typedef int \fBTk_ImageFileWriteProc\fR(
         Tcl_Interp *\fIinterp\fR,
         const char *\fIfileName\fR,
         Tcl_Obj *\fIformat\fR,
+        Tcl_Obj *\fImetadataIn\fR,
         Tk_PhotoImageBlock *\fIblockPtr\fR);
 .CE
 The \fIinterp\fR argument is the interpreter in which the command was
 invoked to write the image; it should be used for reporting errors.
 The image data to be written are in memory and are described by the
@@ -199,20 +233,24 @@
 value given for the \fB\-format\fR option, or NULL if the option was
 not specified.  The format string can contain extra characters
 after the name of the format.  If appropriate, the
 \fIformatPtr->fileWriteProc\fR procedure may interpret these
 characters to specify further details about the image file.
+\fBmetadataIn\fR may contain metadata keys that a driver may include
+into the output data.
 The return value is a standard Tcl return value.
 .SS STRINGWRITEPROC
 .PP
-\fIformatPtr->stringWriteProc\fR provides the address of a procedure for
-Tk to call to translate image data from a photo image into a string.
+\fIformatPtr->stringWriteProc\fR provides the address of a procedure
+for Tk to call to translate image data from a photo image into a
+string.
 \fIformatPtr->stringWriteProc\fR must match the following prototype:
 .CS
 typedef int \fBTk_ImageStringWriteProc\fR(
         Tcl_Interp *\fIinterp\fR,
         Tcl_Obj *\fIformat\fR,
+        Tcl_Obj *\fImetadataIn\fR,
         Tk_PhotoImageBlock *\fIblockPtr\fR);
 .CE
 The \fIinterp\fR argument is the interpreter in which the command was
 invoked to convert the image; it should be used for reporting errors.
 The image data to be converted are in memory and are described by the
@@ -223,11 +261,205 @@
 value given for the \fB\-format\fR option, or NULL if the option was
 not specified.  The format string can contain extra characters
 after the name of the format.  If appropriate, the
 \fIformatPtr->stringWriteProc\fR procedure may interpret these
 characters to specify further details about the image file.
+\fBmetadataIn\fR may contain metadata keys that a driver may include
+into the output data.
 The return value is a standard Tcl return value.
+.PP
+.SH "METADATA INTERFACE"
+.PP
+Image formats contain a description of the image bitmap and may
+contain additional information like image resolution or comments.
+Image metadata may be read from image files and passed to the script
+level by including dictionary keys into the metadata property of the
+image. Image metadata may be written to image data on file write or
+image data output.
+.PP
+.PP
+.SS "METADATA KEYS"
+.PP
+The metadata may contain any key.
+A driver will handle only a set of dictionary keys documented in the
+documentation. See the photo image manual page for currently defined
+keys for the system drivers.
+.PP
+The following rules may give guidance to name metadata keys:
+.RS
+Abreviation are in upper case
+.RE
+.RS
+Words are in US English in small case (except proper nouns)
+.RE
+.RS
+Vertical DPI is expressed as DPI/aspect. The reason is, that some
+image formats may feature aspect and no resolution value.
+.RE
+.SS "METADATA INPUT"
+.PP
+Each driver function gets a Tcl object pointer \fBmetadataIn\fR as
+parameter. This parameter serves to input a metadata dict to the
+driver function.
+It may be NULL to flag that the metadata dict is empty.
+.PP
+A typical driver code snipped to check for a metadata key is:
+.CS
+if (NULL != metadataIn) {
+    Tcl_Obj *itemData;
+    Tcl_DictObjGet(interp, metadataIn, Tcl_NewStringObj("Comment",-1), &itemData));
+.CE
+.PP
+The \-metadata command option data of the following commands is passed
+to the driver: \fBimage create\fR, \fBconfigure\fR, \fBput\fR,
+\fBread\fR, \fBdata\fR and \fBwrite\fR.
+If no \-metadata command option available or not given, the metadata
+property of the image is passed to the driver using the following
+commands: \fBcget\fR, \fBconfigure\fR, \fBdata\fR and \fBwrite\fR.
+.PP
+Note that setting the \-metadata property of an image using
+\fBconfigure\fR without any other option does not invoke any driver
+function.
+.PP
+The metadata dictionary is not suited to pass options to the driver
+related to the bitmap representation, as the image bitmap is not
+recreated on a metadata change. The format string should be used for
+this purpose.
+.PP
+.SS "METADATA OUTPUT"
+.PP
+The image match and read driver functions may set keys in a prepared
+matadata dict to return them.
+Those functions get a Tcl object pointer \fBmetadataOut\fR as
+parameter.
+metadataOut may be NULL to indicate, that no metadata return is
+attended(\fBput\fR, \fBread\fR subcommands).
+\fBmetadataOut\fR is initialized to an empty unshared dict object if
+metadata return is attended (\fBimage create\fR command, \fBconfigure\fR
+subcommand). The driver may set dict keys in this object to return
+metadata.
+If a match function succeeds, the metadataOut pointer is passed to the
+corresponding read function.
+.PP
+A sample driver code snippet is:
+.CS
+if (NULL != metadataOut) {
+    Tcl_DictObjPut(NULL, metadataOut, Tcl_NewStringObj("XMP",-1), Tcl_NewStringObj(xmpMetadata);
+.CE
+.PP
+The metadata keys returned by the driver are merged into the present
+metadata property of the image or into the metadata dict given by the
+\fB\-metadata\fR command line option.
+At the script level, the command \fBimage create\fR and the
+\fBconfigure\fR method may return metadata from the driver.
+.PP
+Format string options or metadata keys may influence the creation of
+metadata within the driver.
+For example, the creation of an expensive metadata key may depend on a
+format string option or on a metadata input key.
+.PP
+.VE 8.7
+.SH "VERSION 2 INTERFACE"
+.PP
+Version 2 Interface does not include the possibility for the driver to
+use the metadata dict for input or output.
+.SS SYNOPSIS
+\fB#include <tk.h>\fR
+.sp
+\fBTk_CreatePhotoImageFormat\fR(\fIformatPtr\fR)
+.SS ARGUMENTS
+.AS "const Tk_PhotoImageFormat" *formatPtr
+.AP "const Tk_PhotoImageFormat" *formatPtr in
+Structure that defines the new file format.
+.BE
+.SS DESCRIPTION
+A driver using the version 2 interface invokes \fBTk_CreatePhotoImageFormat\fR
+for driver registration. The Tk_PhotoImageFormat structure
+contains the following fields:
+.CS
+typedef struct Tk_PhotoImageFormat {
+    const char *\fIname\fR;
+    Tk_ImageFileMatchProc *\fIfileMatchProc\fR;
+    Tk_ImageStringMatchProc *\fIstringMatchProc\fR;
+    Tk_ImageFileReadProc *\fIfileReadProc\fR;
+    Tk_ImageStringReadProc *\fIstringReadProc\fR;
+    Tk_ImageFileWriteProc *\fIfileWriteProc\fR;
+    Tk_ImageStringWriteProc *\fIstringWriteProc\fR;
+} \fBTk_PhotoImageFormat\fR;
+.CE
+.PP
+.SS FILEMATCHPROC
+.PP
+\fIformatPtr->fileMatchProc\fR must match the following prototype:
+.CS
+typedef int \fBTk_ImageFileMatchProc\fR(
+        Tcl_Channel \fIchan\fR,
+        const char *\fIfileName\fR,
+        Tcl_Obj *\fIformat\fR,
+        int *\fIwidthPtr\fR,
+        int *\fIheightPtr\fR,
+        Tcl_Interp *\fIinterp\fR);
+.CE
+.PP
+.SS STRINGMATCHPROC
+.PP
+\fIformatPtr->stringMatchProc\fR must match the following prototype:
+.CS
+typedef int \fBTk_ImageStringMatchProc\fR(
+        Tcl_Obj *\fIdata\fR,
+        Tcl_Obj *\fIformat\fR,
+        int *\fIwidthPtr\fR,
+        int *\fIheightPtr\fR,
+        Tcl_Interp *\fIinterp\fR);
+.CE
+.SS FILEREADPROC
+.PP
+\fIformatPtr->fileReadProc\fR must match the following prototype:
+.CS
+typedef int \fBTk_ImageFileReadProc\fR(
+        Tcl_Interp *\fIinterp\fR,
+        Tcl_Channel \fIchan\fR,
+        const char *\fIfileName\fR,
+        Tcl_Obj *\fIformat\fR,
+        PhotoHandle \fIimageHandle\fR,
+        int \fIdestX\fR, int \fIdestY\fR,
+        int \fIwidth\fR, int \fIheight\fR,
+        int \fIsrcX\fR, int \fIsrcY\fR);
+.CE
+.SS STRINGREADPROC
+.PP
+\fIformatPtr->stringReadProc\fR must match the following prototype:
+.CS
+typedef int \fBTk_ImageStringReadProc\fR(
+        Tcl_Interp *\fIinterp\fR,
+        Tcl_Obj *\fIdata\fR,
+        Tcl_Obj *\fIformat\fR,
+        PhotoHandle \fIimageHandle\fR,
+        int \fIdestX\fR, int \fIdestY\fR,
+        int \fIwidth\fR, int \fIheight\fR,
+        int \fIsrcX\fR, int \fIsrcY\fR);
+.CE
+.SS FILEWRITEPROC
+.PP
+\fIformatPtr->fileWriteProc\fR must match the following prototype:
+.CS
+typedef int \fBTk_ImageFileWriteProc\fR(
+        Tcl_Interp *\fIinterp\fR,
+        const char *\fIfileName\fR,
+        Tcl_Obj *\fIformat\fR,
+        Tk_PhotoImageBlock *\fIblockPtr\fR);
+.CE
+.SS STRINGWRITEPROC
+.PP
+\fIformatPtr->stringWriteProc\fR must match the following prototype:
+.CS
+typedef int \fBTk_ImageStringWriteProc\fR(
+        Tcl_Interp *\fIinterp\fR,
+        Tcl_Obj *\fIformat\fR,
+        Tk_PhotoImageBlock *\fIblockPtr\fR);
+.CE
+.PP
 .SH "LEGACY INTERFACE SUPPORT"
 .PP
 In Tk 8.2 and earlier, the definition of all the function pointer
 types stored in fields of a \fBTk_PhotoImageFormat\fR struct were
 incompatibly different.  Legacy programs and libraries dating from

Index: doc/GetHINSTANCE.3
==================================================================
--- doc/GetHINSTANCE.3
+++ doc/GetHINSTANCE.3
@@ -1,7 +1,7 @@
 '\"
-'\" Copyright (c) 1998-2000 by Scriptics Corporation.
+'\" Copyright (c) 1998-2000 Scriptics Corporation.
 '\" All rights reserved.
 '\"
 .TH Tk_GetHISTANCE 3 "" Tk "Tk Library Procedures"
 .so man.macros
 .BS

Index: doc/GetHWND.3
==================================================================
--- doc/GetHWND.3
+++ doc/GetHWND.3
@@ -1,7 +1,7 @@
 '\"
-'\" Copyright (c) 1998-2000 by Scriptics Corporation.
+'\" Copyright (c) 1998-2000 Scriptics Corporation.
 '\" All rights reserved.
 '\"
 .TH HWND 3 8.0 Tk "Tk Library Procedures"
 .so man.macros
 .BS

Index: doc/Grab.3
==================================================================
--- doc/Grab.3
+++ doc/Grab.3
@@ -1,7 +1,7 @@
 '\"
-'\" Copyright (c) 1998-2000 by Scriptics Corporation.
+'\" Copyright (c) 1998-2000 Scriptics Corporation.
 '\" All rights reserved.
 '\"
 .TH Tk_Grab 3 "" Tk "Tk Library Procedures"
 .so man.macros
 .BS

Index: doc/HWNDToWindow.3
==================================================================
--- doc/HWNDToWindow.3
+++ doc/HWNDToWindow.3
@@ -1,7 +1,7 @@
 '\"
-'\" Copyright (c) 1998-2000 by Scriptics Corporation.
+'\" Copyright (c) 1998-2000 Scriptics Corporation.
 '\" All rights reserved.
 '\"
 .TH Tk_HWNDToWindow 3 "" Tk "Tk Library Procedures"
 .so man.macros
 .BS

Index: doc/Inactive.3
==================================================================
--- doc/Inactive.3
+++ doc/Inactive.3
@@ -1,7 +1,7 @@
 '\"
-'\" Copyright (c) 1998-2000 by Scriptics Corporation.
+'\" Copyright (c) 1998-2000 Scriptics Corporation.
 '\" All rights reserved.
 '\"
 .TH Tk_GetUserInactiveTime 3 8.5 Tk "Tk Library Procedures"
 .so man.macros
 .BS

Index: doc/MainWin.3
==================================================================
--- doc/MainWin.3
+++ doc/MainWin.3
@@ -15,16 +15,30 @@
 \fB#include <tk.h>\fR
 .sp
 Tk_Window
 \fBTk_MainWindow\fR(\fIinterp\fR)
 .sp
+void
+\fBTk_SetMainMenubar\fR(\fIinterp, tkwin, menuName\fR)
+.sp
+void
+\fBTk_SetWindowMenubar\fR(\fIinterp, tkwin, oldMenuName, menuName\fR)
+.sp
 int
 \fBTk_GetNumMainWindows\fR()
 .SH ARGUMENTS
 .AS Tcl_Interp *pathName
 .AP Tcl_Interp *interp in/out
 Interpreter associated with the application.
+.AP Tk_Window tkwin in
+Token for main window.
+.AP const char *menuName in
+The name of the new menubar that the toplevel needs to be set to.
+NULL means that their is no menu now.
+.AP const char *oldMenuName in
+The name of the menubar previously set in this toplevel.
+NULL means no menu was set previously.
 .BE
 .SH DESCRIPTION
 .PP
 A main window is a special kind of toplevel window used as the
 outermost window in an application.
@@ -34,7 +48,14 @@
 associated with \fIinterp\fR then \fBTk_MainWindow\fR returns NULL and
 leaves an error message in interpreter \fIinterp\fR's result.
 .PP
 \fBTk_GetNumMainWindows\fR returns a count of the number of main
 windows currently open in the current thread.
+\fBTk_SetMainMenubar\fR
+Called when a toplevel widget is brought to front. On the Macintosh,
+sets up the menubar that goes accross the top of the main monitor. On
+other platforms, nothing is necessary.
+\fBTk_SetWindowMenubar\fR associates a menu with a window.
+The old menu clones for the menubar are thrown away, and a handler is
+set up to allocate the new ones.
 .SH KEYWORDS
 application, main window

Index: doc/SetOptions.3
==================================================================
--- doc/SetOptions.3
+++ doc/SetOptions.3
@@ -331,21 +331,27 @@
 nor \fIclientData\fR.
 .TP
 \fBTK_OPTION_ANCHOR\fR
 The value must be a standard anchor position such as \fBne\fR or
 \fBcenter\fR.  The internal form is a Tk_Anchor value like the ones
-returned by \fBTk_GetAnchorFromObj\fR.
+returned by \fBTk_GetAnchorFromObj\fR.  This option type supports the \fBTK_OPTION_NULL_OK\fR
+flag; if the empty string is specified as the value for the option,
+the integer relief value is set to \fBTK_ANCHOR_NULL\fR.
 .TP
 \fBTK_OPTION_BITMAP\fR
 The value must be a standard Tk bitmap name. The internal form is a
 Pixmap token like the ones returned by \fBTk_AllocBitmapFromObj\fR.
 This option type requires \fItkwin\fR to be supplied to procedures
 such as \fBTk_SetOptions\fR, and it supports the \fBTK_OPTION_NULL_OK\fR flag.
 .TP
 \fBTK_OPTION_BOOLEAN\fR
 The value must be a standard boolean value such as \fBtrue\fR or
-\fBno\fR.  The internal form is an integer with value 0 or 1.
+\fBno\fR.  The internal form is an integer with value 0 or 1.  Note: if the
+\fIobjOffset\fR field is not used then information about the original value
+of this option will be lost.  This option type supports the
+\fBTK_OPTION_NULL_OK\fR flag; if a NULL value is set, the internal
+representation is set to -1.
 .TP
 \fBTK_OPTION_BORDER\fR
 The value must be a standard color name such as \fBred\fR or \fB#ff8080\fR.
 The internal form is a Tk_3DBorder token like the ones returned
 by \fBTk_Alloc3DBorderFromObj\fR.
@@ -375,11 +381,11 @@
 .TP
 \fBTK_OPTION_DOUBLE\fR
 The string value must be a floating-point number in
 the format accepted by \fBstrtol\fR.  The internal form is a C
 \fBdouble\fR value.  This option type supports the \fBTK_OPTION_NULL_OK\fR
-flag; if a NULL value is set, the internal representation is set to zero.
+flag; if a NULL value is set, the internal representation is set to NaN.
 .TP
 \fBTK_OPTION_END\fR
 Marks the end of the template.  There must be a Tk_OptionSpec structure
 with \fItype\fR \fBTK_OPTION_END\fR at the end of each template.  If the
 \fIclientData\fR field of this structure is not NULL, then it points to
@@ -397,33 +403,36 @@
 .TP
 \fBTK_OPTION_INT\fR
 The string value must be an integer in the format accepted by
 \fBstrtol\fR (e.g. \fB0\fR and \fB0x\fR prefixes may be used to
 specify octal or hexadecimal numbers, respectively).  The internal
-form is a C \fBint\fR value.
+form is a C \fBint\fR value.  This option type supports the \fBTK_OPTION_NULL_OK\fR
+flag; if a NULL value is set, the internal representation is set to INT_MIN.
 .TP
 \fBTK_OPTION_JUSTIFY\fR
 The value must be a standard justification value such as \fBleft\fR.
 The internal form is a Tk_Justify like the values returned by
-\fBTk_GetJustifyFromObj\fR.
+\fBTk_GetJustifyFromObj\fR.  This option type supports the \fBTK_OPTION_NULL_OK\fR
+flag; if the empty string is specified as the value for the option,
+the integer relief value is set to \fBTK_JUSTIFY_NULL\fR.
 .TP
 \fBTK_OPTION_PIXELS\fR
 The value must specify a screen distance such as \fB2i\fR or \fB6.4\fR.
 The internal form is an integer value giving a
 distance in pixels, like the values returned by
 \fBTk_GetPixelsFromObj\fR.  Note: if the \fIobjOffset\fR field is not
 used then information about the original value of this option will be lost.
 See \fBOBJOFFSET VS. INTERNALOFFSET\fR below for details.  This option
 type supports the \fBTK_OPTION_NULL_OK\fR flag; if a NULL value is set, the
-internal representation is set to zero.
+internal representation is set to INT_MIN.
 .TP
 \fBTK_OPTION_RELIEF\fR
 The value must be standard relief such as \fBraised\fR.
 The internal form is an integer relief value such as
 \fBTK_RELIEF_RAISED\fR.  This option type supports the \fBTK_OPTION_NULL_OK\fR
-flag; if the empty string is specified as the value for the option,
-the integer relief value is set to \fBTK_RELIEF_NULL\fR.
+flag; if a NULL value is set, the internal representation is set to
+\fBTK_RELIEF_NULL\fR.
 .TP
 \fBTK_OPTION_STRING\fR
 The value may be any string.  The internal form is a (char *) pointer
 that points to a dynamically allocated copy of the value.
 This option type supports the \fBTK_OPTION_NULL_OK\fR flag.

Index: doc/TextLayout.3
==================================================================
--- doc/TextLayout.3
+++ doc/TextLayout.3
@@ -106,12 +106,13 @@
 .AP int lastChar in
 The index of the last character up to which to draw.  The character
 specified by \fIlastChar\fR itself will not be drawn.  A number less
 than 0 means to draw all characters in the text layout.
 .AP int underline in
-Index of the single character to underline in the text layout, or a number
-less than 0 for no underline.
+Index of the single character to underline in the text layout, or a
+negative number counting backwards from the end of the string. Any
+out-of-range number (e.g. INT_MIN) means no underline.
 .AP int index in
 The index of the character whose bounding box is desired.  The bounding
 box is computed with respect to the upper-left hand corner of the text layout.
 .AP int "*xPtr, *yPtr" out
 Filled with the upper-left hand corner, in pixels, of the bounding box

ADDED   doc/WinUtil.3
Index: doc/WinUtil.3
==================================================================
--- /dev/null
+++ doc/WinUtil.3
@@ -0,0 +1,64 @@
+'\"
+'\" Copyright (c) 1990-1993 The Regents of the University of California.
+'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+.TH Tk_ConfigureWindow 3 4.0 Tk "Tk Library Procedures"
+.so man.macros
+.BS
+.SH NAME
+Tk_GetOtherWindow, Tk_MakeContainer, Tk_MakeWindow, Tk_UseWindow \- window utility functions
+.SH SYNOPSIS
+.nf
+\fB#include <tk.h>\fR
+.sp
+Tk_Window
+\fBTk_GetOtherWindow(\fItkwin\fB)\fR
+.sp
+\fBTk_MakeContainer(\fItkwin\fB)\fR
+.sp
+\fBTk_MakeWindow(\fItkwin, parent\fB)\fR
+.sp
+int
+\fBTk_UseWindow(\fIinterp, tkwin, string\fB)\fR
+.SH ARGUMENTS
+.AS XSetWindowAttributes borderWidth
+.AP Tcl_Interp * interp in
+Interpreter associated with the application.
+.AP Tk_Window tkwin in
+Token for window.
+.AP Window parent in
+Parent window.
+.AP "const char" *string in
+String identifying an X window to use for \fItkwin\fR; must be an integer value.
+.BE
+.SH DESCRIPTION
+.PP
+If both the container and embedded window are in the same process,
+\fBTk_GetOtherWindow\fR will return either one, given the other.
+If winPtr is a container, the return value is the token for the
+embedded window, and vice versa. If the "other" window isn't in this
+process, NULL is returned.
+.PP
+\fBTk_MakeContainer\fR is called to indicate that a particular window will be a
+container for an embedded application. This changes certain aspects of
+the window's behavior, such as whether it will receive events anymore.
+.PP
+\fBTk_MakeWindow\fR creates an actual window system window object based on the
+current attributes of the specified TkWindow. It returns the handle to the new
+window, or None on failure.
+.PP
+\fBTk_UseWindow\fR causes a Tk window to use a given X window as its
+parent window, rather than the root window for the screen. It is
+invoked by an embedded application to specify the window in which it
+is embedded.
+.PP
+The return value is normally TCL_OK. If an error occurs (such as
+string not being a valid window spec), then the return value is
+TCL_ERROR and an error message is left in the interp's result if
+interp is non-NULL.
+.PP
+.SH KEYWORDS
+parent, window

Index: doc/bind.n
==================================================================
--- doc/bind.n
+++ doc/bind.n
@@ -1,9 +1,9 @@
 '\"
 '\" Copyright (c) 1990 The Regents of the University of California.
 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
-'\" Copyright (c) 1998 by Scriptics Corporation.
+'\" Copyright (c) 1998 Scriptics Corporation.
 '\"
 '\" See the file "license.terms" for information on usage and redistribution
 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 '\"
 .TH bind n 8.0 Tk "Tk Built-In Commands"
@@ -51,17 +51,17 @@
 arbitrary set of binding tags to a window, the default binding
 tags provide the following behavior:
 .IP \(bu 3
 If a tag is the name of an internal window the binding applies
 to that window.
+.IP \(bu 3
+If the tag is the name of a class of widgets, such as \fBButton\fR,
+the binding applies to all widgets in that class.
 .IP \(bu 3
 If the tag is the name of a toplevel window the binding applies
 to the toplevel window and all its internal windows.
 .IP \(bu 3
-If the tag is the name of a class of widgets, such as \fBButton\fR,
-the binding applies to all widgets in that class;
-.IP \(bu 3
 If \fItag\fR has the value \fBall\fR,
 the binding applies to all windows in the application.
 .SH "EVENT PATTERNS"
 .PP
 The \fIsequence\fR argument specifies a sequence of one or more
@@ -104,12 +104,12 @@
 Modifiers consist of any of the following values:
 .DS
 .ta 6c
 \fBControl\fR	\fBMod1\fR, \fBM1\fR, \fBCommand\fR
 \fBAlt\fR	\fBMod2\fR, \fBM2\fR, \fBOption\fR
-\fBShift\fR	\fBMod3\fR, \fBM3\fR
-\fBLock\fR	\fBMod4\fR, \fBM4\fR
+\fBShift\fR	\fBMod3\fR, \fBM3\fR, \fBNum\fR
+\fBLock\fR	\fBMod4\fR, \fBM4\fR, \fBFn\fR
 \fBExtended\fR	\fBMod5\fR, \fBM5\fR
 \fBButton1\fR, \fBB1\fR	\fBMeta\fR, \fBM\fR
 \fBButton2\fR, \fBB2\fR	\fBDouble\fR
 \fBButton3\fR, \fBB3\fR	\fBTriple\fR
 \fBButton4\fR, \fBB4\fR	\fBQuadruple\fR
@@ -147,12 +147,12 @@
 pattern, all of the events must occur close together in time and without
 substantial mouse motion in between.  For example, \fB<Double\-Button\-1>\fR
 is equivalent to \fB<Button\-1><Button\-1>\fR with the extra time and space
 requirement.
 .PP
-The \fBCommand\fR and \fBOption\fR modifiers are equivalents of \fBMod1\fR
-resp. \fBMod2\fR, they correspond to Macintosh-specific modifier keys.
+The \fBCommand\fR, \fBOption\fR, \fBNum\fR and \fBFn\fRmodifiers are equivalents
+of \fBMod1\fR up to \fBMod4\fR, they correspond to Macintosh-specific modifier keys.
 .PP
 The \fBExtended\fR modifier is, at present, specific to Windows.  It
 appears on events that are associated with the keys on the
 .QW "extended keyboard" .
 On a US keyboard, the extended keys include the \fBAlt\fR

Index: doc/canvas.n
==================================================================
--- doc/canvas.n
+++ doc/canvas.n
@@ -1254,11 +1254,12 @@
 \fB\-activefill \fIcolor\fR
 .TP
 \fB\-disabledfill \fIcolor\fR
 .
 Specifies the color to be used to fill item's area.
-in its normal, active, and disabled states,
+in its normal, active, and disabled states.
+The even-odd fill rule is used.
 \fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR.
 For the line item, it specifies the color of the line drawn.
 For the text item, it specifies the foreground color of the text.
 If \fIcolor\fR is an empty string (the default for all canvas items
 except line and text), then the item will not be filled.
@@ -1762,11 +1763,11 @@
 If the smoothing method is \fBraw\fR, this indicates that the polygon
 should also be drawn as a curve but where the list of coordinates is
 such that the first coordinate pair (and every third coordinate pair
 thereafter) is a knot point on a cubic Bezier curve, and the other
 coordinates are control points on the cubic Bezier curve. Straight
-line segments can be venerated within a curve by making control points
+line segments can be generated within a curve by making control points
 equal to their neighbouring knot points. If the last point is not the
 second point of a pair of control points, the point is repeated (one or two
 times) so that it also becomes the second point of a pair of control
 points (the associated knot point will be the first control point).
 .TP

Index: doc/chooseDirectory.n
==================================================================
--- doc/chooseDirectory.n
+++ doc/chooseDirectory.n
@@ -1,7 +1,7 @@
 '\"
-'\" Copyright (c) 1998-2000 by Scriptics Corporation.
+'\" Copyright (c) 1998-2000 Scriptics Corporation.
 '\" All rights reserved.
 '\"
 .TH tk_chooseDirectory n 8.3 Tk "Tk Built-In Commands"
 .so man.macros
 .BS

Index: doc/colors.n
==================================================================
--- doc/colors.n
+++ doc/colors.n
@@ -1,7 +1,7 @@
 '\"
-'\" Copyright (c) 1998-2000 by Scriptics Corporation.
+'\" Copyright (c) 1998-2000 Scriptics Corporation.
 '\" Copyright (c) 2003 ActiveState Corporation.
 '\" Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
 '\" Copyright (c) 2008 Donal K. Fellows
 '\"
 .TH colors n 8.3 Tk "Tk Built-In Commands"

Index: doc/console.n
==================================================================
--- doc/console.n
+++ doc/console.n
@@ -21,11 +21,11 @@
 Tk toolkit loaded, and control over this interpreter is given through
 the \fBconsole\fR command.  The behaviour of the console window is
 defined mainly through the contents of the \fIconsole.tcl\fR file in
 the Tk library. Except for TkAqua, this command is not available when
 Tk is loaded into a tclsh interpreter with
-.QW "\fBpackage require Tk\fR" ,
+.QW "\fBpackage require tk\fR" ,
 as a conventional terminal is expected to be present in that case.
 In TkAqua, this command is disabled when there is a startup script
 and stdin is \fB/dev/null\fR (as is the case e.g. when a bundled application
 embedding Tk is started by the macOS Launcher).  To enable the command
 in that case, define the environment variable \fBTK_CONSOLE\fR.  This can be

Index: doc/cursors.n
==================================================================
--- doc/cursors.n
+++ doc/cursors.n
@@ -1,7 +1,7 @@
 '\"
-'\" Copyright (c) 1998-2000 by Scriptics Corporation.
+'\" Copyright (c) 1998-2000 Scriptics Corporation.
 '\" All rights reserved.
 '\"
 '\" Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
 '\"
 .TH cursors n 8.3 Tk "Tk Built-In Commands"

Index: doc/event.n
==================================================================
--- doc/event.n
+++ doc/event.n
@@ -340,10 +340,19 @@
 .TP
 \fB<<ThemeChanged>>\fR
 This is sent to all widgets when the ttk theme changed. The ttk
 widgets listen to this event and redisplay themselves when it fires.
 The legacy widgets ignore this event.
+.TP
+\fB<<TkWorldChanged>>\fR
+.
+This event is sent to all widgets when a font is changed, for example,
+by the use of [font configure].  The user_data field (%d) will have the
+value "FontChanged".  For other system wide changes, this event will
+be sent to all widgets, and the user_data field will indicate the
+cause of the change.  NOTE: all tk and ttk widgets already handle this
+event internally.
 .TP
 \fB<<TraverseIn>>\fR
 This is sent to a widget when the focus enters the widget because of a
 user-driven
 .QW "tab to widget"

Index: doc/grid.n
==================================================================
--- doc/grid.n
+++ doc/grid.n
@@ -309,11 +309,11 @@
 causes only the content in the row (or column) specified by \fIvalue\fR
 to be returned.
 .TP
 \fBgrid slaves \fIwindow\fR ?\fI\-option value\fR?
 .
-Synonym for . \fBgrid content \fIwindow\fR ?\fI\-option value\fR?
+Synonym for \fBgrid content \fIwindow\fR ?\fI\-option value\fR?.
 .SH "RELATIVE PLACEMENT"
 .PP
 The \fBgrid\fR command contains a limited set of capabilities that
 permit layouts to be created without specifying the row and column
 information for each content.  This permits content to be rearranged,

Index: doc/image.n
==================================================================
--- doc/image.n
+++ doc/image.n
@@ -91,12 +91,24 @@
 .TP
 \fBphoto\fR
 Displays a variety of full-color images, using dithering to
 approximate colors on displays with limited color capabilities.
 See the \fBphoto\fR manual entry for more information.
+.TP
+\fBnsimage\fR
+This type is only available in the Aqua platform.  It is a full-color
+image which may be created from a named system image.  It has options
+designed to facilitate the use of these images in buttons.  An
+\fBnsimage\fR can be based on an a \fItemplate image\fR, which is an
+anti-aliased 2-color image format that automatically interchanges
+black and white in response to changes between the light and dark
+modes on macOS.  An \fBnsimage\fR can also generate an alternate
+\fIpressed\fR variant which is lighter in dark mode and darker in
+light mode.  These are for use in image buttons. See the \fBnsimage\fR
+manual entry for more information.
 .SH "SEE ALSO"
-bitmap(n), options(n), photo(n)
+bitmap(n), options(n), photo(n), nsimage(n)
 .SH KEYWORDS
 height, image, types of images, width
 '\" Local Variables:
 '\" mode: nroff
 '\" End:

Index: doc/keysyms.n
==================================================================
--- doc/keysyms.n
+++ doc/keysyms.n
@@ -1,7 +1,7 @@
 '\"
-'\" Copyright (c) 1998-2000 by Scriptics Corporation.
+'\" Copyright (c) 1998-2000 Scriptics Corporation.
 '\" All rights reserved.
 '\"
 .TH keysyms n 8.3 Tk "Tk Built-In Commands"
 .so man.macros
 .BS
@@ -10,11 +10,11 @@
 keysyms \- keysyms recognized by Tk
 .BE
 .SH DESCRIPTION
 .PP
 Tk recognizes many keysyms when specifying key bindings (e.g.,
-.QW "\fBbind\fR \fB. <Key-\fR\fIkeysym\fR\fB>\fR" ).
+.QW "\fBbind\fR \fB. <\fR\fIkeysym\fR\fB>\fR" ).
 The following list enumerates the
 keysyms that will be recognized by Tk.  Note that not all keysyms will
 be valid on all platforms, and some keysyms are also available on
 platforms that have a different native name for that key.
 For example, on Unix systems, the presence
@@ -22,25 +22,25 @@
 keyboard modifier map.  This list shows keysyms along with their
 decimal and hexadecimal values.
 .PP
 .CS
 space                               32     0x20
-exclam                              33     0x21
+! (exclam)                          33     0x21
 quotedbl                            34     0x22
 numbersign                          35     0x23
 dollar                              36     0x24
-percent                             37     0x25
-ampersand                           38     0x26
-apostrophe                          39     0x27
-parenleft                           40     0x28
-parenright                          41     0x29
-asterisk                            42     0x2A
-plus                                43     0x2B
-comma                               44     0x2C
+% (percent)                         37     0x25
+& (ampersand)                       38     0x26
+' (apostrophe)                      39     0x27
+( (parenleft)                       40     0x28
+) (parenright)                      41     0x29
+* (asterisk)                        42     0x2A
++ (plus)                            43     0x2B
+, (comma)                           44     0x2C
 minus                               45     0x2D
-period                              46     0x2E
-slash                               47     0x2F
+. (period)                          46     0x2E
+/ (slash)                           47     0x2F
 0                                   48     0x30
 1                                   49     0x31
 2                                   50     0x32
 3                                   51     0x33
 4                                   52     0x34
@@ -47,17 +47,17 @@
 5                                   53     0x35
 6                                   54     0x36
 7                                   55     0x37
 8                                   56     0x38
 9                                   57     0x39
-colon                               58     0x3A
+: (colon)                           58     0x3A
 semicolon                           59     0x3B
 less                                60     0x3C
-equal                               61     0x3D
+= (equal)                           61     0x3D
 greater                             62     0x3E
-question                            63     0x3F
-at                                  64     0x40
+? (question)                        63     0x3F
+@ (at)                              64     0x40
 A                                   65     0x41
 B                                   66     0x42
 C                                   67     0x43
 D                                   68     0x44
 E                                   69     0x45
@@ -83,13 +83,13 @@
 Y                                   89     0x59
 Z                                   90     0x5A
 bracketleft                         91     0x5B
 backslash                           92     0x5C
 bracketright                        93     0x5D
-asciicircum                         94     0x5E
-underscore                          95     0x5F
-grave                               96     0x60
+^ (asciicircum)                     94     0x5E
+_ (underscore)                      95     0x5F
+` (grave)                           96     0x60
 a                                   97     0x61
 b                                   98     0x62
 c                                   99     0x63
 d                                  100     0x64
 e                                  101     0x65
@@ -113,120 +113,120 @@
 w                                  119     0x77
 x                                  120     0x78
 y                                  121     0x79
 z                                  122     0x7A
 braceleft                          123     0x7B
-bar                                124     0x7C
+| (bar)                            124     0x7C
 braceright                         125     0x7D
-asciitilde                         126     0x7E
+~ (asciitilde)                     126     0x7E
 nobreakspace                       160     0xA0
-exclamdown                         161     0xA1
-cent                               162     0xA2
-sterling                           163     0xA3
-currency                           164     0xA4
-yen                                165     0xA5
-brokenbar                          166     0xA6
-section                            167     0xA7
-diaeresis                          168     0xA8
-copyright                          169     0xA9
-ordfeminine                        170     0xAA
-guillemotleft                      171     0xAB
-notsign                            172     0xAC
+\(r! (exclamdown)                     161     0xA1
+\(ct (cent)                           162     0xA2
+\(Po (sterling)                       163     0xA3
+\(Cs (currency)                       164     0xA4
+\(Ye (yen)                            165     0xA5
+\(bb (brokenbar)                      166     0xA6
+\(sc (section)                        167     0xA7
+\(ad (diaeresis)                      168     0xA8
+\(co (copyright)                      169     0xA9
+\(Of (ordfeminine)                    170     0xAA
+\(Fo (guillemotleft)                  171     0xAB
+\(no (notsign)                        172     0xAC
 hyphen                             173     0xAD
-registered                         174     0xAE
-macron                             175     0xAF
-degree                             176     0xB0
-plusminus                          177     0xB1
-twosuperior                        178     0xB2
-threesuperior                      179     0xB3
-acute                              180     0xB4
-mu                                 181     0xB5
-paragraph                          182     0xB6
-periodcentered                     183     0xB7
-cedilla                            184     0xB8
-onesuperior                        185     0xB9
-masculine                          186     0xBA
-guillemotright                     187     0xBB
-onequarter                         188     0xBC
-onehalf                            189     0xBD
-threequarters                      190     0xBE
-questiondown                       191     0xBF
-Agrave                             192     0xC0
-Aacute                             193     0xC1
-Acircumflex                        194     0xC2
-Atilde                             195     0xC3
-Adiaeresis                         196     0xC4
-Aring                              197     0xC5
-AE                                 198     0xC6
-Ccedilla                           199     0xC7
-Egrave                             200     0xC8
-Eacute                             201     0xC9
-Ecircumflex                        202     0xCA
-Ediaeresis                         203     0xCB
-Igrave                             204     0xCC
-Iacute                             205     0xCD
-Icircumflex                        206     0xCE
-Idiaeresis                         207     0xCF
-ETH                                208     0xD0
-Ntilde                             209     0xD1
-Ograve                             210     0xD2
-Oacute                             211     0xD3
-Ocircumflex                        212     0xD4
-Otilde                             213     0xD5
-Odiaeresis                         214     0xD6
-multiply                           215     0xD7
-Oslash                             216     0xD8
-Ugrave                             217     0xD9
-Uacute                             218     0xDA
-Ucircumflex                        219     0xDB
-Udiaeresis                         220     0xDC
-Yacute                             221     0xDD
-THORN                              222     0xDE
-ssharp                             223     0xDF
-agrave                             224     0xE0
-aacute                             225     0xE1
-acircumflex                        226     0xE2
-atilde                             227     0xE3
-adiaeresis                         228     0xE4
-aring                              229     0xE5
-ae                                 230     0xE6
-ccedilla                           231     0xE7
-egrave                             232     0xE8
-eacute                             233     0xE9
-ecircumflex                        234     0xEA
-ediaeresis                         235     0xEB
-igrave                             236     0xEC
-iacute                             237     0xED
-icircumflex                        238     0xEE
-idiaeresis                         239     0xEF
-eth                                240     0xF0
-ntilde                             241     0xF1
-ograve                             242     0xF2
-oacute                             243     0xF3
-ocircumflex                        244     0xF4
-otilde                             245     0xF5
-odiaeresis                         246     0xF6
-division                           247     0xF7
-oslash                             248     0xF8
-ugrave                             249     0xF9
-uacute                             250     0xFA
-ucircumflex                        251     0xFB
-udiaeresis                         252     0xFC
-yacute                             253     0xFD
-thorn                              254     0xFE
-ydiaeresis                         255     0xFF
+\(rg (registered)                     174     0xAE
+\(a- (macron)                         175     0xAF
+\(de (degree)                         176     0xB0
+\(+- (plusminus)                      177     0xB1
+\(S2 (twosuperior)                    178     0xB2
+\(S3 (threesuperior)                  179     0xB3
+\(aa (acute)                          180     0xB4
+\(mc (mu)                             181     0xB5
+\(ps (paragraph)                      182     0xB6
+\(pc (periodcentered)                 183     0xB7
+\(ac (cedilla)                        184     0xB8
+\(S1 (onesuperior)                    185     0xB9
+\(Om (masculine)                      186     0xBA
+\(Fc (guillemotright)                 187     0xBB
+\(14 (onequarter)                     188     0xBC
+\(12 (onehalf)                        189     0xBD
+\(34 (threequarters)                  190     0xBE
+\(r? (questiondown)                   191     0xBF
+\(`A (Agrave)                         192     0xC0
+\('A (Aacute)                         193     0xC1
+\(^A (Acircumflex)                    194     0xC2
+\(~A (Atilde)                         195     0xC3
+\(:A (Adiaeresis)                     196     0xC4
+\(oA (Aring)                          197     0xC5
+\(AE (AE)                             198     0xC6
+\(,C (Ccedilla)                       199     0xC7
+\(`E (Egrave)                         200     0xC8
+\('E (Eacute)                         201     0xC9
+\(^E (Ecircumflex)                    202     0xCA
+\(:E (Ediaeresis)                     203     0xCB
+\(`I (Igrave)                         204     0xCC
+\('I (Iacute)                         205     0xCD
+\(^I (Icircumflex)                    206     0xCE
+\(:I (Idiaeresis)                     207     0xCF
+\(-D (ETH)                            208     0xD0
+\(~N (Ntilde)                         209     0xD1
+\(`O (Ograve)                         210     0xD2
+\('O (Oacute)                         211     0xD3
+\(^O (Ocircumflex)                    212     0xD4
+\(~O (Otilde)                         213     0xD5
+\(:O (Odiaeresis)                     214     0xD6
+\(mu (multiply)                       215     0xD7
+\(/O (Oslash)                         216     0xD8
+\(`U (Ugrave)                         217     0xD9
+\('U (Uacute)                         218     0xDA
+\(^U (Ucircumflex)                    219     0xDB
+\(:U (Udiaeresis)                     220     0xDC
+\('Y (Yacute)                         221     0xDD
+\(TP (THORN)                          222     0xDE
+\(ss (ssharp)                         223     0xDF
+\(`a (agrave)                         224     0xE0
+\('a (aacute)                         225     0xE1
+\(^a (acircumflex)                    226     0xE2
+\(~a (atilde)                         227     0xE3
+\(:a (adiaeresis)                     228     0xE4
+\(oa (aring)                          229     0xE5
+\(ae (ae)                             230     0xE6
+\(,c (ccedilla)                       231     0xE7
+\(`e (egrave)                         232     0xE8
+\('e (eacute)                         233     0xE9
+\(^e (ecircumflex)                    234     0xEA
+\(:e (ediaeresis)                     235     0xEB
+\(`i (igrave)                         236     0xEC
+\('i (iacute)                         237     0xED
+\(^i (icircumflex)                    238     0xEE
+\(:i (idiaeresis)                     239     0xEF
+\(Sd (eth)                            240     0xF0
+\(~n (ntilde)                         241     0xF1
+\(`o (ograve)                         242     0xF2
+\('o (oacute)                         243     0xF3
+\(^o (ocircumflex)                    244     0xF4
+\(~o (otilde)                         245     0xF5
+\(:o (odiaeresis)                     246     0xF6
+\(di (division)                       247     0xF7
+\(/o (oslash)                         248     0xF8
+\(`u (ugrave)                         249     0xF9
+\('u (uacute)                         250     0xFA
+\(^u (ucircumflex)                    251     0xFB
+\(:u (udiaeresis)                     252     0xFC
+\('y (yacute)                         253     0xFD
+\(Tp (thorn)                          254     0xFE
+\(:y (ydiaeresis)                     255     0xFF
+.CE
+.CS
 Aogonek                            417     0x1A1
 breve                              418     0x1A2
 Lstroke                            419     0x1A3
 Lcaron                             421     0x1A5
 Sacute                             422     0x1A6
 Scaron                             425     0x1A9
 Scedilla                           426     0x1AA
 Tcaron                             427     0x1AB
 Zacute                             428     0x1AC
-.CE
-.CS
 Zcaron                             430     0x1AE
 Zabovedot                          431     0x1AF
 aogonek                            433     0x1B1
 ogonek                             434     0x1B2
 lstroke                            435     0x1B3
@@ -392,10 +392,12 @@
 kana_RO                           1243     0x4DB
 kana_WA                           1244     0x4DC
 kana_N                            1245     0x4DD
 voicedsound                       1246     0x4DE
 semivoicedsound                   1247     0x4DF
+.CE
+.CS
 Arabic_comma                      1452     0x5AC
 Arabic_semicolon                  1467     0x5BB
 Arabic_question_mark              1471     0x5BF
 Arabic_hamza                      1473     0x5C1
 Arabic_maddaonalef                1474     0x5C2
@@ -427,12 +429,10 @@
 Arabic_feh                        1505     0x5E1
 Arabic_qaf                        1506     0x5E2
 Arabic_kaf                        1507     0x5E3
 Arabic_lam                        1508     0x5E4
 Arabic_meem                       1509     0x5E5
-.CE
-.CS
 Arabic_noon                       1510     0x5E6
 Arabic_ha                         1511     0x5E7
 Arabic_waw                        1512     0x5E8
 Arabic_alefmaksura                1513     0x5E9
 Arabic_yeh                        1514     0x5EA
@@ -542,13 +542,15 @@
 Greek_ALPHAaccent                 1953     0x7A1
 Greek_EPSILONaccent               1954     0x7A2
 Greek_ETAaccent                   1955     0x7A3
 Greek_IOTAaccent                  1956     0x7A4
 Greek_IOTAdieresis                1957     0x7A5
+Greek_IOTAaccentdiaeresis         1958     0x7A6
 Greek_OMICRONaccent               1959     0x7A7
 Greek_UPSILONaccent               1960     0x7A8
 Greek_UPSILONdieresis             1961     0x7A9
+Greek_UPSILONaccentdieresis       1962     0x7AA
 Greek_OMEGAaccent                 1963     0x7AB
 Greek_accentdieresis              1966     0x7AE
 Greek_horizbar                    1967     0x7AF
 Greek_alphaaccent                 1969     0x7B1
 Greek_epsilonaccent               1970     0x7B2
@@ -608,10 +610,12 @@
 Greek_upsilon                     2037     0x7F5
 Greek_phi                         2038     0x7F6
 Greek_chi                         2039     0x7F7
 Greek_psi                         2040     0x7F8
 Greek_omega                       2041     0x7F9
+.CE
+.CS
 leftradical                       2209     0x8A1
 topleftradical                    2210     0x8A2
 horizconnector                    2211     0x8A3
 topintegral                       2212     0x8A4
 botintegral                       2213     0x8A5
@@ -631,12 +635,10 @@
 topvertsummationconnector         2227     0x8B3
 botvertsummationconnector         2228     0x8B4
 toprightsummation                 2229     0x8B5
 botrightsummation                 2230     0x8B6
 rightmiddlesummation              2231     0x8B7
-.CE
-.CS
 lessthanequal                     2236     0x8BC
 notequal                          2237     0x8BD
 greaterthanequal                  2238     0x8BE
 integral                          2239     0x8BF
 therefore                         2240     0x8C0
@@ -814,10 +816,12 @@
 hebrew_zade                       3318     0xCF6
 hebrew_qoph                       3319     0xCF7
 hebrew_resh                       3320     0xCF8
 hebrew_shin                       3321     0xCF9
 hebrew_taw                        3322     0xCFA
+.CE
+.CS
 Thai_kokai                        3489     0xDA1
 Thai_khokhai                      3490     0xDA2
 Thai_khokhuat                     3491     0xDA3
 Thai_khokhwai                     3492     0xDA4
 Thai_khokhon                      3493     0xDA5
@@ -992,41 +996,13 @@
 Hangul_J_YeorinHieuh              3834     0xEFA
 Korean_Won                        3839     0xEFF
 OE                                5052     0x13BC
 oe                                5053     0x13BD
 Ydiaeresis                        5054     0x13BE
-EuroSign                          8364     0x20AC
-3270_Duplicate                   64769     0xFD01
-3270_FieldMark                   64770     0xFD02
-3270_Right2                      64771     0xFD03
-3270_Left2                       64772     0xFD04
-3270_BackTab                     64773     0xFD05
-3270_EraseEOF                    64774     0xFD06
-3270_EraseInput                  64775     0xFD07
-3270_Reset                       64776     0xFD08
-3270_Quit                        64777     0xFD09
-3270_PA1                         64778     0xFD0A
-3270_PA2                         64779     0xFD0B
-3270_PA3                         64780     0xFD0C
-3270_Test                        64781     0xFD0D
-3270_Attn                        64782     0xFD0E
-3270_CursorBlink                 64783     0xFD0F
-3270_AltCursor                   64784     0xFD10
-3270_KeyClick                    64785     0xFD11
-3270_Jump                        64786     0xFD12
-3270_Ident                       64787     0xFD13
-3270_Rule                        64788     0xFD14
-3270_Copy                        64789     0xFD15
-3270_Play                        64790     0xFD16
-3270_Setup                       64791     0xFD17
-3270_Record                      64792     0xFD18
-3270_ChangeScreen                64793     0xFD19
-3270_DeleteWord                  64794     0xFD1A
-3270_ExSelect                    64795     0xFD1B
-3270_CursorSelect                64796     0xFD1C
-3270_PrintScreen                 64797     0xFD1D
-3270_Enter                       64798     0xFD1E
+\(eu (EuroSign)                      8364     0x20AC
+.CE
+.CS
 ISO_Lock                         65025     0xFE01
 ISO_Level2_Latch                 65026     0xFE02
 ISO_Level3_Shift                 65027     0xFE03
 ISO_Level3_Latch                 65028     0xFE04
 ISO_Level3_Lock                  65029     0xFE05
@@ -1163,10 +1139,12 @@
 Pointer_EnableKeys               65273     0xFEF9
 Pointer_Accelerate               65274     0xFEFA
 Pointer_DfltBtnNext              65275     0xFEFB
 Pointer_DfltBtnPrev              65276     0xFEFC
 Pointer_Drag5                    65277     0xFEFD
+.CE
+.CS
 BackSpace                        65288     0xFF08
 Tab                              65289     0xFF09
 Linefeed                         65290     0xFF0A
 Clear                            65291     0xFF0B
 Return                           65293     0xFF0D
@@ -1213,22 +1191,17 @@
 Down                             65364     0xFF54
 Prior                            65365     0xFF55
 Next                             65366     0xFF56
 End                              65367     0xFF57
 Begin                            65368     0xFF58
-Win_L                            65371     0xFF5B
-Win_R                            65372     0xFF5C
-.CE
-.CS
-App                              65373     0xFF5D
 Select                           65376     0xFF60
 Print                            65377     0xFF61
 Execute                          65378     0xFF62
 Insert                           65379     0xFF63
 Undo                             65381     0xFF65
 Redo                             65382     0xFF66
-Menu                             65383     0xFF67
+Menu (App)                       65383     0xFF67
 Find                             65384     0xFF68
 Cancel                           65385     0xFF69
 Help                             65386     0xFF6A
 Break                            65387     0xFF6B
 Mode_switch                      65406     0xFF7E
@@ -1311,12 +1284,12 @@
 Shift_Lock                       65510     0xFFE6
 Meta_L                           65511     0xFFE7
 Meta_R                           65512     0xFFE8
 Alt_L                            65513     0xFFE9
 Alt_R                            65514     0xFFEA
-Super_L                          65515     0xFFEB
-Super_R                          65516     0xFFEC
+Super_L (Win_L)                  65515     0xFFEB
+Super_R (Win_R)                  65516     0xFFEC
 Hyper_L                          65517     0xFFED
 Hyper_R                          65518     0xFFEE
 braille_dot_1                    65521     0xFFF1
 braille_dot_2                    65522     0xFFF2
 braille_dot_3                    65523     0xFFF3
@@ -1326,719 +1299,12 @@
 braille_dot_7                    65527     0xFFF7
 braille_dot_8                    65528     0xFFF8
 braille_dot_9                    65529     0xFFF9
 braille_dot_10                   65530     0xFFFA
 Delete                           65535     0xFFFF
-Ibreve                        16777516     0x100012C
-ibreve                        16777517     0x100012D
-Wcircumflex                   16777588     0x1000174
-wcircumflex                   16777589     0x1000175
-Ycircumflex                   16777590     0x1000176
-ycircumflex                   16777591     0x1000177
-SCHWA                         16777615     0x100018F
-Obarred                       16777631     0x100019F
-Ohorn                         16777632     0x10001A0
-ohorn                         16777633     0x10001A1
-Uhorn                         16777647     0x10001AF
-uhorn                         16777648     0x10001B0
-Zstroke                       16777653     0x10001B5
-zstroke                       16777654     0x10001B6
-EZH                           16777655     0x10001B7
-Ocaron                        16777681     0x10001D1
-ocaron                        16777682     0x10001D2
-Gcaron                        16777702     0x10001E6
-gcaron                        16777703     0x10001E7
-schwa                         16777817     0x1000259
-obarred                       16777845     0x1000275
-ezh                           16777874     0x1000292
-Cyrillic_GHE_bar              16778386     0x1000492
-Cyrillic_ghe_bar              16778387     0x1000493
-Cyrillic_ZHE_descender        16778390     0x1000496
-Cyrillic_zhe_descender        16778391     0x1000497
-Cyrillic_KA_descender         16778394     0x100049A
-Cyrillic_ka_descender         16778395     0x100049B
-Cyrillic_KA_vertstroke        16778396     0x100049C
-Cyrillic_ka_vertstroke        16778397     0x100049D
-Cyrillic_EN_descender         16778402     0x10004A2
-Cyrillic_en_descender         16778403     0x10004A3
-Cyrillic_U_straight           16778414     0x10004AE
-Cyrillic_u_straight           16778415     0x10004AF
-Cyrillic_U_straight_bar       16778416     0x10004B0
-Cyrillic_u_straight_bar       16778417     0x10004B1
-Cyrillic_HA_descender         16778418     0x10004B2
-Cyrillic_ha_descender         16778419     0x10004B3
-Cyrillic_CHE_descender        16778422     0x10004B6
-Cyrillic_che_descender        16778423     0x10004B7
-Cyrillic_CHE_vertstroke       16778424     0x10004B8
-Cyrillic_che_vertstroke       16778425     0x10004B9
-Cyrillic_SHHA                 16778426     0x10004BA
-Cyrillic_shha                 16778427     0x10004BB
-Cyrillic_SCHWA                16778456     0x10004D8
-Cyrillic_schwa                16778457     0x10004D9
-Cyrillic_I_macron             16778466     0x10004E2
-Cyrillic_i_macron             16778467     0x10004E3
-Cyrillic_O_bar                16778472     0x10004E8
-Cyrillic_o_bar                16778473     0x10004E9
-Cyrillic_U_macron             16778478     0x10004EE
-Cyrillic_u_macron             16778479     0x10004EF
-Armenian_AYB                  16778545     0x1000531
-Armenian_BEN                  16778546     0x1000532
-Armenian_GIM                  16778547     0x1000533
-Armenian_DA                   16778548     0x1000534
-Armenian_YECH                 16778549     0x1000535
-Armenian_ZA                   16778550     0x1000536
-Armenian_E                    16778551     0x1000537
-Armenian_AT                   16778552     0x1000538
-Armenian_TO                   16778553     0x1000539
-Armenian_ZHE                  16778554     0x100053A
-Armenian_INI                  16778555     0x100053B
-Armenian_LYUN                 16778556     0x100053C
-Armenian_KHE                  16778557     0x100053D
-Armenian_TSA                  16778558     0x100053E
-Armenian_KEN                  16778559     0x100053F
-Armenian_HO                   16778560     0x1000540
-Armenian_DZA                  16778561     0x1000541
-Armenian_GHAT                 16778562     0x1000542
-Armenian_TCHE                 16778563     0x1000543
-Armenian_MEN                  16778564     0x1000544
-Armenian_HI                   16778565     0x1000545
-Armenian_NU                   16778566     0x1000546
-Armenian_SHA                  16778567     0x1000547
-Armenian_VO                   16778568     0x1000548
-Armenian_CHA                  16778569     0x1000549
-Armenian_PE                   16778570     0x100054A
-Armenian_JE                   16778571     0x100054B
-Armenian_RA                   16778572     0x100054C
-Armenian_SE                   16778573     0x100054D
-Armenian_VEV                  16778574     0x100054E
-Armenian_TYUN                 16778575     0x100054F
-Armenian_RE                   16778576     0x1000550
-Armenian_TSO                  16778577     0x1000551
-Armenian_VYUN                 16778578     0x1000552
-Armenian_PYUR                 16778579     0x1000553
-Armenian_KE                   16778580     0x1000554
-Armenian_O                    16778581     0x1000555
-Armenian_FE                   16778582     0x1000556
-Armenian_apostrophe           16778586     0x100055A
-Armenian_accent               16778587     0x100055B
-Armenian_exclam               16778588     0x100055C
-Armenian_separation_mark      16778589     0x100055D
-Armenian_question             16778590     0x100055E
-Armenian_ayb                  16778593     0x1000561
-Armenian_ben                  16778594     0x1000562
-Armenian_gim                  16778595     0x1000563
-Armenian_da                   16778596     0x1000564
-Armenian_yech                 16778597     0x1000565
-Armenian_za                   16778598     0x1000566
-Armenian_e                    16778599     0x1000567
-Armenian_at                   16778600     0x1000568
-Armenian_to                   16778601     0x1000569
-Armenian_zhe                  16778602     0x100056A
-Armenian_ini                  16778603     0x100056B
-Armenian_lyun                 16778604     0x100056C
-Armenian_khe                  16778605     0x100056D
-Armenian_tsa                  16778606     0x100056E
-Armenian_ken                  16778607     0x100056F
-Armenian_ho                   16778608     0x1000570
-Armenian_dza                  16778609     0x1000571
-Armenian_ghat                 16778610     0x1000572
-Armenian_tche                 16778611     0x1000573
-Armenian_men                  16778612     0x1000574
-Armenian_hi                   16778613     0x1000575
-Armenian_nu                   16778614     0x1000576
-Armenian_sha                  16778615     0x1000577
-Armenian_vo                   16778616     0x1000578
-Armenian_cha                  16778617     0x1000579
-Armenian_pe                   16778618     0x100057A
-Armenian_je                   16778619     0x100057B
-Armenian_ra                   16778620     0x100057C
-Armenian_se                   16778621     0x100057D
-Armenian_vev                  16778622     0x100057E
-Armenian_tyun                 16778623     0x100057F
-Armenian_re                   16778624     0x1000580
-Armenian_tso                  16778625     0x1000581
-Armenian_vyun                 16778626     0x1000582
-Armenian_pyur                 16778627     0x1000583
-Armenian_ke                   16778628     0x1000584
-Armenian_o                    16778629     0x1000585
-Armenian_fe                   16778630     0x1000586
-Armenian_ligature_ew          16778631     0x1000587
-Armenian_full_stop            16778633     0x1000589
-Armenian_hyphen               16778634     0x100058A
-Arabic_madda_above            16778835     0x1000653
-Arabic_hamza_above            16778836     0x1000654
-Arabic_hamza_below            16778837     0x1000655
-Arabic_0                      16778848     0x1000660
-Arabic_1                      16778849     0x1000661
-Arabic_2                      16778850     0x1000662
-Arabic_3                      16778851     0x1000663
-Arabic_4                      16778852     0x1000664
-Arabic_5                      16778853     0x1000665
-Arabic_6                      16778854     0x1000666
-Arabic_7                      16778855     0x1000667
-Arabic_8                      16778856     0x1000668
-Arabic_9                      16778857     0x1000669
-Arabic_percent                16778858     0x100066A
-Arabic_superscript_alef       16778864     0x1000670
-Arabic_tteh                   16778873     0x1000679
-Arabic_peh                    16778878     0x100067E
-Arabic_tcheh                  16778886     0x1000686
-Arabic_ddal                   16778888     0x1000688
-Arabic_rreh                   16778897     0x1000691
-Arabic_jeh                    16778904     0x1000698
-Arabic_veh                    16778916     0x10006A4
-Arabic_keheh                  16778921     0x10006A9
-Arabic_gaf                    16778927     0x10006AF
-Arabic_noon_ghunna            16778938     0x10006BA
-Arabic_heh_doachashmee        16778942     0x10006BE
-Arabic_heh_goal               16778945     0x10006C1
-Farsi_yeh                     16778956     0x10006CC
-Arabic_yeh_baree              16778962     0x10006D2
-Arabic_fullstop               16778964     0x10006D4
-Farsi_0                       16778992     0x10006F0
-Farsi_1                       16778993     0x10006F1
-Farsi_2                       16778994     0x10006F2
-Farsi_3                       16778995     0x10006F3
-Farsi_4                       16778996     0x10006F4
-Farsi_5                       16778997     0x10006F5
-Farsi_6                       16778998     0x10006F6
-Farsi_7                       16778999     0x10006F7
-Farsi_8                       16779000     0x10006F8
-Farsi_9                       16779001     0x10006F9
-Sinh_ng                       16780674     0x1000D82
-Sinh_h2                       16780675     0x1000D83
-Sinh_a                        16780677     0x1000D85
-Sinh_aa                       16780678     0x1000D86
-Sinh_ae                       16780679     0x1000D87
-Sinh_aee                      16780680     0x1000D88
-Sinh_i                        16780681     0x1000D89
-Sinh_ii                       16780682     0x1000D8A
-Sinh_u                        16780683     0x1000D8B
-Sinh_uu                       16780684     0x1000D8C
-Sinh_ri                       16780685     0x1000D8D
-Sinh_rii                      16780686     0x1000D8E
-Sinh_lu                       16780687     0x1000D8F
-Sinh_luu                      16780688     0x1000D90
-Sinh_e                        16780689     0x1000D91
-Sinh_ee                       16780690     0x1000D92
-Sinh_ai                       16780691     0x1000D93
-Sinh_o                        16780692     0x1000D94
-Sinh_oo                       16780693     0x1000D95
-Sinh_au                       16780694     0x1000D96
-Sinh_ka                       16780698     0x1000D9A
-Sinh_kha                      16780699     0x1000D9B
-Sinh_ga                       16780700     0x1000D9C
-Sinh_gha                      16780701     0x1000D9D
-Sinh_ng2                      16780702     0x1000D9E
-Sinh_nga                      16780703     0x1000D9F
-Sinh_ca                       16780704     0x1000DA0
-Sinh_cha                      16780705     0x1000DA1
-Sinh_ja                       16780706     0x1000DA2
-Sinh_jha                      16780707     0x1000DA3
-Sinh_nya                      16780708     0x1000DA4
-Sinh_jnya                     16780709     0x1000DA5
-Sinh_nja                      16780710     0x1000DA6
-Sinh_tta                      16780711     0x1000DA7
-Sinh_ttha                     16780712     0x1000DA8
-Sinh_dda                      16780713     0x1000DA9
-Sinh_ddha                     16780714     0x1000DAA
-Sinh_nna                      16780715     0x1000DAB
-Sinh_ndda                     16780716     0x1000DAC
-Sinh_tha                      16780717     0x1000DAD
-Sinh_thha                     16780718     0x1000DAE
-Sinh_dha                      16780719     0x1000DAF
-Sinh_dhha                     16780720     0x1000DB0
-Sinh_na                       16780721     0x1000DB1
-Sinh_ndha                     16780723     0x1000DB3
-Sinh_pa                       16780724     0x1000DB4
-Sinh_pha                      16780725     0x1000DB5
-Sinh_ba                       16780726     0x1000DB6
-Sinh_bha                      16780727     0x1000DB7
-Sinh_ma                       16780728     0x1000DB8
-Sinh_mba                      16780729     0x1000DB9
-Sinh_ya                       16780730     0x1000DBA
-Sinh_ra                       16780731     0x1000DBB
-Sinh_la                       16780733     0x1000DBD
-Sinh_va                       16780736     0x1000DC0
-Sinh_sha                      16780737     0x1000DC1
-Sinh_ssha                     16780738     0x1000DC2
-Sinh_sa                       16780739     0x1000DC3
-Sinh_ha                       16780740     0x1000DC4
-Sinh_lla                      16780741     0x1000DC5
-Sinh_fa                       16780742     0x1000DC6
-Sinh_al                       16780746     0x1000DCA
-Sinh_aa2                      16780751     0x1000DCF
-Sinh_ae2                      16780752     0x1000DD0
-Sinh_aee2                     16780753     0x1000DD1
-Sinh_i2                       16780754     0x1000DD2
-Sinh_ii2                      16780755     0x1000DD3
-Sinh_u2                       16780756     0x1000DD4
-Sinh_uu2                      16780758     0x1000DD6
-Sinh_ru2                      16780760     0x1000DD8
-Sinh_e2                       16780761     0x1000DD9
-Sinh_ee2                      16780762     0x1000DDA
-Sinh_ai2                      16780763     0x1000DDB
-Sinh_o2                       16780764     0x1000DDC
-Sinh_oo2                      16780765     0x1000DDD
-Sinh_au2                      16780766     0x1000DDE
-Sinh_lu2                      16780767     0x1000DDF
-Sinh_ruu2                     16780786     0x1000DF2
-Sinh_luu2                     16780787     0x1000DF3
-Sinh_kunddaliya               16780788     0x1000DF4
-Georgian_an                   16781520     0x10010D0
-Georgian_ban                  16781521     0x10010D1
-Georgian_gan                  16781522     0x10010D2
-Georgian_don                  16781523     0x10010D3
-Georgian_en                   16781524     0x10010D4
-Georgian_vin                  16781525     0x10010D5
-Georgian_zen                  16781526     0x10010D6
-Georgian_tan                  16781527     0x10010D7
-Georgian_in                   16781528     0x10010D8
-Georgian_kan                  16781529     0x10010D9
-Georgian_las                  16781530     0x10010DA
-Georgian_man                  16781531     0x10010DB
-Georgian_nar                  16781532     0x10010DC
-Georgian_on                   16781533     0x10010DD
-Georgian_par                  16781534     0x10010DE
-Georgian_zhar                 16781535     0x10010DF
-Georgian_rae                  16781536     0x10010E0
-Georgian_san                  16781537     0x10010E1
-Georgian_tar                  16781538     0x10010E2
-Georgian_un                   16781539     0x10010E3
-Georgian_phar                 16781540     0x10010E4
-Georgian_khar                 16781541     0x10010E5
-Georgian_ghan                 16781542     0x10010E6
-Georgian_qar                  16781543     0x10010E7
-Georgian_shin                 16781544     0x10010E8
-Georgian_chin                 16781545     0x10010E9
-Georgian_can                  16781546     0x10010EA
-Georgian_jil                  16781547     0x10010EB
-Georgian_cil                  16781548     0x10010EC
-Georgian_char                 16781549     0x10010ED
-Georgian_xan                  16781550     0x10010EE
-Georgian_jhan                 16781551     0x10010EF
-Georgian_hae                  16781552     0x10010F0
-Georgian_he                   16781553     0x10010F1
-Georgian_hie                  16781554     0x10010F2
-Georgian_we                   16781555     0x10010F3
-Georgian_har                  16781556     0x10010F4
-Georgian_hoe                  16781557     0x10010F5
-Georgian_fi                   16781558     0x10010F6
-Babovedot                     16784898     0x1001E02
-babovedot                     16784899     0x1001E03
-Dabovedot                     16784906     0x1001E0A
-dabovedot                     16784907     0x1001E0B
-Fabovedot                     16784926     0x1001E1E
-fabovedot                     16784927     0x1001E1F
-Lbelowdot                     16784950     0x1001E36
-lbelowdot                     16784951     0x1001E37
-Mabovedot                     16784960     0x1001E40
-mabovedot                     16784961     0x1001E41
-Pabovedot                     16784982     0x1001E56
-pabovedot                     16784983     0x1001E57
-Sabovedot                     16784992     0x1001E60
-sabovedot                     16784993     0x1001E61
-Tabovedot                     16785002     0x1001E6A
-tabovedot                     16785003     0x1001E6B
-Wgrave                        16785024     0x1001E80
-wgrave                        16785025     0x1001E81
-Wacute                        16785026     0x1001E82
-wacute                        16785027     0x1001E83
-Wdiaeresis                    16785028     0x1001E84
-wdiaeresis                    16785029     0x1001E85
-Xabovedot                     16785034     0x1001E8A
-xabovedot                     16785035     0x1001E8B
-Abelowdot                     16785056     0x1001EA0
-abelowdot                     16785057     0x1001EA1
-Ahook                         16785058     0x1001EA2
-ahook                         16785059     0x1001EA3
-Acircumflexacute              16785060     0x1001EA4
-acircumflexacute              16785061     0x1001EA5
-Acircumflexgrave              16785062     0x1001EA6
-acircumflexgrave              16785063     0x1001EA7
-Acircumflexhook               16785064     0x1001EA8
-acircumflexhook               16785065     0x1001EA9
-Acircumflextilde              16785066     0x1001EAA
-acircumflextilde              16785067     0x1001EAB
-Acircumflexbelowdot           16785068     0x1001EAC
-acircumflexbelowdot           16785069     0x1001EAD
-Abreveacute                   16785070     0x1001EAE
-abreveacute                   16785071     0x1001EAF
-Abrevegrave                   16785072     0x1001EB0
-abrevegrave                   16785073     0x1001EB1
-Abrevehook                    16785074     0x1001EB2
-abrevehook                    16785075     0x1001EB3
-Abrevetilde                   16785076     0x1001EB4
-abrevetilde                   16785077     0x1001EB5
-Abrevebelowdot                16785078     0x1001EB6
-abrevebelowdot                16785079     0x1001EB7
-Ebelowdot                     16785080     0x1001EB8
-ebelowdot                     16785081     0x1001EB9
-Ehook                         16785082     0x1001EBA
-ehook                         16785083     0x1001EBB
-Etilde                        16785084     0x1001EBC
-etilde                        16785085     0x1001EBD
-Ecircumflexacute              16785086     0x1001EBE
-ecircumflexacute              16785087     0x1001EBF
-Ecircumflexgrave              16785088     0x1001EC0
-ecircumflexgrave              16785089     0x1001EC1
-Ecircumflexhook               16785090     0x1001EC2
-ecircumflexhook               16785091     0x1001EC3
-Ecircumflextilde              16785092     0x1001EC4
-ecircumflextilde              16785093     0x1001EC5
-Ecircumflexbelowdot           16785094     0x1001EC6
-ecircumflexbelowdot           16785095     0x1001EC7
-Ihook                         16785096     0x1001EC8
-ihook                         16785097     0x1001EC9
-Ibelowdot                     16785098     0x1001ECA
-ibelowdot                     16785099     0x1001ECB
-Obelowdot                     16785100     0x1001ECC
-obelowdot                     16785101     0x1001ECD
-Ohook                         16785102     0x1001ECE
-ohook                         16785103     0x1001ECF
-Ocircumflexacute              16785104     0x1001ED0
-ocircumflexacute              16785105     0x1001ED1
-Ocircumflexgrave              16785106     0x1001ED2
-ocircumflexgrave              16785107     0x1001ED3
-Ocircumflexhook               16785108     0x1001ED4
-ocircumflexhook               16785109     0x1001ED5
-Ocircumflextilde              16785110     0x1001ED6
-ocircumflextilde              16785111     0x1001ED7
-Ocircumflexbelowdot           16785112     0x1001ED8
-ocircumflexbelowdot           16785113     0x1001ED9
-Ohornacute                    16785114     0x1001EDA
-ohornacute                    16785115     0x1001EDB
-Ohorngrave                    16785116     0x1001EDC
-ohorngrave                    16785117     0x1001EDD
-Ohornhook                     16785118     0x1001EDE
-ohornhook                     16785119     0x1001EDF
-Ohorntilde                    16785120     0x1001EE0
-ohorntilde                    16785121     0x1001EE1
-Ohornbelowdot                 16785122     0x1001EE2
-ohornbelowdot                 16785123     0x1001EE3
-Ubelowdot                     16785124     0x1001EE4
-ubelowdot                     16785125     0x1001EE5
-Uhook                         16785126     0x1001EE6
-uhook                         16785127     0x1001EE7
-Uhornacute                    16785128     0x1001EE8
-uhornacute                    16785129     0x1001EE9
-Uhorngrave                    16785130     0x1001EEA
-uhorngrave                    16785131     0x1001EEB
-Uhornhook                     16785132     0x1001EEC
-uhornhook                     16785133     0x1001EED
-Uhorntilde                    16785134     0x1001EEE
-uhorntilde                    16785135     0x1001EEF
-Uhornbelowdot                 16785136     0x1001EF0
-uhornbelowdot                 16785137     0x1001EF1
-Ygrave                        16785138     0x1001EF2
-ygrave                        16785139     0x1001EF3
-Ybelowdot                     16785140     0x1001EF4
-ybelowdot                     16785141     0x1001EF5
-Yhook                         16785142     0x1001EF6
-yhook                         16785143     0x1001EF7
-Ytilde                        16785144     0x1001EF8
-ytilde                        16785145     0x1001EF9
-zerosuperior                  16785520     0x1002070
-foursuperior                  16785524     0x1002074
-fivesuperior                  16785525     0x1002075
-sixsuperior                   16785526     0x1002076
-sevensuperior                 16785527     0x1002077
-eightsuperior                 16785528     0x1002078
-ninesuperior                  16785529     0x1002079
-zerosubscript                 16785536     0x1002080
-onesubscript                  16785537     0x1002081
-twosubscript                  16785538     0x1002082
-threesubscript                16785539     0x1002083
-foursubscript                 16785540     0x1002084
-fivesubscript                 16785541     0x1002085
-sixsubscript                  16785542     0x1002086
-sevensubscript                16785543     0x1002087
-eightsubscript                16785544     0x1002088
-ninesubscript                 16785545     0x1002089
-EcuSign                       16785568     0x10020A0
-ColonSign                     16785569     0x10020A1
-CruzeiroSign                  16785570     0x10020A2
-FFrancSign                    16785571     0x10020A3
-LiraSign                      16785572     0x10020A4
-MillSign                      16785573     0x10020A5
-NairaSign                     16785574     0x10020A6
-PesetaSign                    16785575     0x10020A7
-RupeeSign                     16785576     0x10020A8
-WonSign                       16785577     0x10020A9
-NewSheqelSign                 16785578     0x10020AA
-DongSign                      16785579     0x10020AB
-partdifferential              16785922     0x1002202
-emptyset                      16785925     0x1002205
-elementof                     16785928     0x1002208
-notelementof                  16785929     0x1002209
-containsas                    16785931     0x100220B
-squareroot                    16785946     0x100221A
-cuberoot                      16785947     0x100221B
-fourthroot                    16785948     0x100221C
-dintegral                     16785964     0x100222C
-tintegral                     16785965     0x100222D
-because                       16785973     0x1002235
-notapproxeq                   16785991     0x1002247
-approxeq                      16785992     0x1002248
-notidentical                  16786018     0x1002262
-stricteq                      16786019     0x1002263
-braille_blank                 16787456     0x1002800
-braille_dots_1                16787457     0x1002801
-braille_dots_2                16787458     0x1002802
-braille_dots_12               16787459     0x1002803
-braille_dots_3                16787460     0x1002804
-braille_dots_13               16787461     0x1002805
-braille_dots_23               16787462     0x1002806
-braille_dots_123              16787463     0x1002807
-braille_dots_4                16787464     0x1002808
-braille_dots_14               16787465     0x1002809
-braille_dots_24               16787466     0x100280A
-braille_dots_124              16787467     0x100280B
-braille_dots_34               16787468     0x100280C
-braille_dots_134              16787469     0x100280D
-braille_dots_234              16787470     0x100280E
-braille_dots_1234             16787471     0x100280F
-braille_dots_5                16787472     0x1002810
-braille_dots_15               16787473     0x1002811
-braille_dots_25               16787474     0x1002812
-braille_dots_125              16787475     0x1002813
-braille_dots_35               16787476     0x1002814
-braille_dots_135              16787477     0x1002815
-braille_dots_235              16787478     0x1002816
-braille_dots_1235             16787479     0x1002817
-braille_dots_45               16787480     0x1002818
-braille_dots_145              16787481     0x1002819
-braille_dots_245              16787482     0x100281A
-braille_dots_1245             16787483     0x100281B
-braille_dots_345              16787484     0x100281C
-braille_dots_1345             16787485     0x100281D
-braille_dots_2345             16787486     0x100281E
-braille_dots_12345            16787487     0x100281F
-braille_dots_6                16787488     0x1002820
-braille_dots_16               16787489     0x1002821
-braille_dots_26               16787490     0x1002822
-braille_dots_126              16787491     0x1002823
-braille_dots_36               16787492     0x1002824
-braille_dots_136              16787493     0x1002825
-braille_dots_236              16787494     0x1002826
-braille_dots_1236             16787495     0x1002827
-braille_dots_46               16787496     0x1002828
-braille_dots_146              16787497     0x1002829
-braille_dots_246              16787498     0x100282A
-braille_dots_1246             16787499     0x100282B
-braille_dots_346              16787500     0x100282C
-braille_dots_1346             16787501     0x100282D
-braille_dots_2346             16787502     0x100282E
-braille_dots_12346            16787503     0x100282F
-braille_dots_56               16787504     0x1002830
-braille_dots_156              16787505     0x1002831
-braille_dots_256              16787506     0x1002832
-braille_dots_1256             16787507     0x1002833
-braille_dots_356              16787508     0x1002834
-braille_dots_1356             16787509     0x1002835
-braille_dots_2356             16787510     0x1002836
-braille_dots_12356            16787511     0x1002837
-braille_dots_456              16787512     0x1002838
-braille_dots_1456             16787513     0x1002839
-braille_dots_2456             16787514     0x100283A
-braille_dots_12456            16787515     0x100283B
-braille_dots_3456             16787516     0x100283C
-braille_dots_13456            16787517     0x100283D
-braille_dots_23456            16787518     0x100283E
-braille_dots_123456           16787519     0x100283F
-braille_dots_7                16787520     0x1002840
-braille_dots_17               16787521     0x1002841
-braille_dots_27               16787522     0x1002842
-braille_dots_127              16787523     0x1002843
-braille_dots_37               16787524     0x1002844
-braille_dots_137              16787525     0x1002845
-braille_dots_237              16787526     0x1002846
-braille_dots_1237             16787527     0x1002847
-braille_dots_47               16787528     0x1002848
-braille_dots_147              16787529     0x1002849
-braille_dots_247              16787530     0x100284A
-braille_dots_1247             16787531     0x100284B
-braille_dots_347              16787532     0x100284C
-braille_dots_1347             16787533     0x100284D
-braille_dots_2347             16787534     0x100284E
-braille_dots_12347            16787535     0x100284F
-braille_dots_57               16787536     0x1002850
-braille_dots_157              16787537     0x1002851
-braille_dots_257              16787538     0x1002852
-braille_dots_1257             16787539     0x1002853
-braille_dots_357              16787540     0x1002854
-braille_dots_1357             16787541     0x1002855
-braille_dots_2357             16787542     0x1002856
-braille_dots_12357            16787543     0x1002857
-braille_dots_457              16787544     0x1002858
-braille_dots_1457             16787545     0x1002859
-braille_dots_2457             16787546     0x100285A
-braille_dots_12457            16787547     0x100285B
-braille_dots_3457             16787548     0x100285C
-braille_dots_13457            16787549     0x100285D
-braille_dots_23457            16787550     0x100285E
-braille_dots_123457           16787551     0x100285F
-braille_dots_67               16787552     0x1002860
-braille_dots_167              16787553     0x1002861
-braille_dots_267              16787554     0x1002862
-braille_dots_1267             16787555     0x1002863
-braille_dots_367              16787556     0x1002864
-braille_dots_1367             16787557     0x1002865
-braille_dots_2367             16787558     0x1002866
-braille_dots_12367            16787559     0x1002867
-braille_dots_467              16787560     0x1002868
-braille_dots_1467             16787561     0x1002869
-braille_dots_2467             16787562     0x100286A
-braille_dots_12467            16787563     0x100286B
-braille_dots_3467             16787564     0x100286C
-braille_dots_13467            16787565     0x100286D
-braille_dots_23467            16787566     0x100286E
-braille_dots_123467           16787567     0x100286F
-braille_dots_567              16787568     0x1002870
-braille_dots_1567             16787569     0x1002871
-braille_dots_2567             16787570     0x1002872
-braille_dots_12567            16787571     0x1002873
-braille_dots_3567             16787572     0x1002874
-braille_dots_13567            16787573     0x1002875
-braille_dots_23567            16787574     0x1002876
-braille_dots_123567           16787575     0x1002877
-braille_dots_4567             16787576     0x1002878
-braille_dots_14567            16787577     0x1002879
-braille_dots_24567            16787578     0x100287A
-braille_dots_124567           16787579     0x100287B
-braille_dots_34567            16787580     0x100287C
-braille_dots_134567           16787581     0x100287D
-braille_dots_234567           16787582     0x100287E
-braille_dots_1234567          16787583     0x100287F
-braille_dots_8                16787584     0x1002880
-braille_dots_18               16787585     0x1002881
-braille_dots_28               16787586     0x1002882
-braille_dots_128              16787587     0x1002883
-braille_dots_38               16787588     0x1002884
-braille_dots_138              16787589     0x1002885
-braille_dots_238              16787590     0x1002886
-braille_dots_1238             16787591     0x1002887
-braille_dots_48               16787592     0x1002888
-braille_dots_148              16787593     0x1002889
-braille_dots_248              16787594     0x100288A
-braille_dots_1248             16787595     0x100288B
-braille_dots_348              16787596     0x100288C
-braille_dots_1348             16787597     0x100288D
-braille_dots_2348             16787598     0x100288E
-braille_dots_12348            16787599     0x100288F
-braille_dots_58               16787600     0x1002890
-braille_dots_158              16787601     0x1002891
-braille_dots_258              16787602     0x1002892
-braille_dots_1258             16787603     0x1002893
-braille_dots_358              16787604     0x1002894
-braille_dots_1358             16787605     0x1002895
-braille_dots_2358             16787606     0x1002896
-braille_dots_12358            16787607     0x1002897
-braille_dots_458              16787608     0x1002898
-braille_dots_1458             16787609     0x1002899
-braille_dots_2458             16787610     0x100289A
-braille_dots_12458            16787611     0x100289B
-braille_dots_3458             16787612     0x100289C
-braille_dots_13458            16787613     0x100289D
-braille_dots_23458            16787614     0x100289E
-braille_dots_123458           16787615     0x100289F
-braille_dots_68               16787616     0x10028A0
-braille_dots_168              16787617     0x10028A1
-braille_dots_268              16787618     0x10028A2
-braille_dots_1268             16787619     0x10028A3
-braille_dots_368              16787620     0x10028A4
-braille_dots_1368             16787621     0x10028A5
-braille_dots_2368             16787622     0x10028A6
-braille_dots_12368            16787623     0x10028A7
-braille_dots_468              16787624     0x10028A8
-braille_dots_1468             16787625     0x10028A9
-braille_dots_2468             16787626     0x10028AA
-braille_dots_12468            16787627     0x10028AB
-braille_dots_3468             16787628     0x10028AC
-braille_dots_13468            16787629     0x10028AD
-braille_dots_23468            16787630     0x10028AE
-braille_dots_123468           16787631     0x10028AF
-braille_dots_568              16787632     0x10028B0
-braille_dots_1568             16787633     0x10028B1
-braille_dots_2568             16787634     0x10028B2
-braille_dots_12568            16787635     0x10028B3
-braille_dots_3568             16787636     0x10028B4
-braille_dots_13568            16787637     0x10028B5
-braille_dots_23568            16787638     0x10028B6
-braille_dots_123568           16787639     0x10028B7
-braille_dots_4568             16787640     0x10028B8
-braille_dots_14568            16787641     0x10028B9
-braille_dots_24568            16787642     0x10028BA
-braille_dots_124568           16787643     0x10028BB
-braille_dots_34568            16787644     0x10028BC
-braille_dots_134568           16787645     0x10028BD
-braille_dots_234568           16787646     0x10028BE
-braille_dots_1234568          16787647     0x10028BF
-braille_dots_78               16787648     0x10028C0
-braille_dots_178              16787649     0x10028C1
-braille_dots_278              16787650     0x10028C2
-braille_dots_1278             16787651     0x10028C3
-braille_dots_378              16787652     0x10028C4
-braille_dots_1378             16787653     0x10028C5
-braille_dots_2378             16787654     0x10028C6
-braille_dots_12378            16787655     0x10028C7
-braille_dots_478              16787656     0x10028C8
-braille_dots_1478             16787657     0x10028C9
-braille_dots_2478             16787658     0x10028CA
-braille_dots_12478            16787659     0x10028CB
-braille_dots_3478             16787660     0x10028CC
-braille_dots_13478            16787661     0x10028CD
-braille_dots_23478            16787662     0x10028CE
-braille_dots_123478           16787663     0x10028CF
-braille_dots_578              16787664     0x10028D0
-braille_dots_1578             16787665     0x10028D1
-braille_dots_2578             16787666     0x10028D2
-braille_dots_12578            16787667     0x10028D3
-braille_dots_3578             16787668     0x10028D4
-braille_dots_13578            16787669     0x10028D5
-braille_dots_23578            16787670     0x10028D6
-braille_dots_123578           16787671     0x10028D7
-braille_dots_4578             16787672     0x10028D8
-braille_dots_14578            16787673     0x10028D9
-braille_dots_24578            16787674     0x10028DA
-braille_dots_124578           16787675     0x10028DB
-braille_dots_34578            16787676     0x10028DC
-braille_dots_134578           16787677     0x10028DD
-braille_dots_234578           16787678     0x10028DE
-braille_dots_1234578          16787679     0x10028DF
-braille_dots_678              16787680     0x10028E0
-braille_dots_1678             16787681     0x10028E1
-braille_dots_2678             16787682     0x10028E2
-braille_dots_12678            16787683     0x10028E3
-braille_dots_3678             16787684     0x10028E4
-braille_dots_13678            16787685     0x10028E5
-braille_dots_23678            16787686     0x10028E6
-braille_dots_123678           16787687     0x10028E7
-braille_dots_4678             16787688     0x10028E8
-braille_dots_14678            16787689     0x10028E9
-braille_dots_24678            16787690     0x10028EA
-braille_dots_124678           16787691     0x10028EB
-braille_dots_34678            16787692     0x10028EC
-braille_dots_134678           16787693     0x10028ED
-braille_dots_234678           16787694     0x10028EE
-braille_dots_1234678          16787695     0x10028EF
-braille_dots_5678             16787696     0x10028F0
-braille_dots_15678            16787697     0x10028F1
-braille_dots_25678            16787698     0x10028F2
-braille_dots_125678           16787699     0x10028F3
-braille_dots_35678            16787700     0x10028F4
-braille_dots_135678           16787701     0x10028F5
-braille_dots_235678           16787702     0x10028F6
-braille_dots_1235678          16787703     0x10028F7
-braille_dots_45678            16787704     0x10028F8
-braille_dots_145678           16787705     0x10028F9
-braille_dots_245678           16787706     0x10028FA
-braille_dots_1245678          16787707     0x10028FB
-braille_dots_345678           16787708     0x10028FC
-braille_dots_1345678          16787709     0x10028FD
-braille_dots_2345678          16787710     0x10028FE
-braille_dots_12345678         16787711     0x10028FF
+.CE
+.CS
 SunFA_Grave                  268828416     0x1005FF00
 SunFA_Circum                 268828417     0x1005FF01
 SunFA_Tilde                  268828418     0x1005FF02
 SunFA_Acute                  268828419     0x1005FF03
 SunFA_Diaeresis              268828420     0x1005FF04
@@ -2058,10 +1324,149 @@
 SunAudioRaiseVolume          268828537     0x1005FF79
 SunVideoDegauss              268828538     0x1005FF7A
 SunVideoLowerBrightness      268828539     0x1005FF7B
 SunVideoRaiseBrightness      268828540     0x1005FF7C
 SunPowerSwitchShift          268828541     0x1005FF7D
+XF86BrightnessAuto           268964084     0x100810F4
+XF86DisplayOff               268964085     0x100810F5
+XF86Info                     268964198     0x10081166
+XF86AspectRatio              268964215     0x10081177
+XF86DVD                      268964229     0x10081185
+XF86Audio                    268964232     0x10081188
+XF86ChannelUp                268964242     0x10081192
+XF86ChannelDown              268964243     0x10081193
+XF86Break                    268964251     0x1008119B
+XF86VideoPhone               268964256     0x100811A0
+XF86ZoomReset                268964260     0x100811A4
+XF86Editor                   268964262     0x100811A6
+XF86GraphicsEditor           268964264     0x100811A8
+XF86Presentation             268964265     0x100811A9
+XF86Database                 268964266     0x100811AA
+XF86Voicemail                268964268     0x100811AC
+XF86Addressbook              268964269     0x100811AD
+XF86DisplayToggle            268964271     0x100811AF
+XF86SpellCheck               268964272     0x100811B0
+XF86ContextMenu              268964278     0x100811B6
+XF86MediaRepeat              268964279     0x100811B7
+XF8610ChannelsUp             268964280     0x100811B8
+XF8610ChannelsDown           268964281     0x100811B9
+XF86Images                   268964282     0x100811BA
+XF86NotificationCenter       268964284     0x100811BC
+XF86PickupPhone              268964285     0x100811BD
+XF86HangupPhone              268964286     0x100811BE
+XF86Fn                       268964304     0x100811D0
+XF86Fn_Esc                   268964305     0x100811D1
+XF86FnRightShift             268964325     0x100811E5
+XF86Numeric0                 268964352     0x10081200
+XF86Numeric1                 268964353     0x10081201
+XF86Numeric2                 268964354     0x10081202
+XF86Numeric3                 268964355     0x10081203
+XF86Numeric4                 268964356     0x10081204
+XF86Numeric5                 268964357     0x10081205
+XF86Numeric6                 268964358     0x10081206
+XF86Numeric7                 268964359     0x10081207
+XF86Numeric8                 268964360     0x10081208
+XF86Numeric9                 268964361     0x10081209
+XF86NumericStar              268964362     0x1008120A
+XF86NumericPound             268964363     0x1008120B
+XF86NumericA                 268964364     0x1008120C
+XF86NumericB                 268964365     0x1008120D
+XF86NumericC                 268964366     0x1008120E
+XF86NumericD                 268964367     0x1008120F
+XF86CameraFocus              268964368     0x10081210
+XF86WPSButton                268964369     0x10081211
+XF86CameraZoomIn             268964373     0x10081215
+XF86CameraZoomOut            268964374     0x10081216
+XF86CameraUp                 268964375     0x10081217
+XF86CameraDown               268964376     0x10081218
+XF86CameraLeft               268964377     0x10081219
+XF86CameraRight              268964378     0x1008121A
+XF86AttendantOn              268964379     0x1008121B
+XF86AttendantOff             268964380     0x1008121C
+XF86AttendantToggle          268964381     0x1008121D
+XF86LightsToggle             268964382     0x1008121E
+XF86ALSToggle                268964400     0x10081230
+XF86Buttonconfig             268964416     0x10081240
+XF86Taskmanager              268964417     0x10081241
+XF86Journal                  268964418     0x10081242
+XF86ControlPanel             268964419     0x10081243
+XF86AppSelect                268964420     0x10081244
+XF86Screensaver              268964421     0x10081245
+XF86VoiceCommand             268964422     0x10081246
+XF86Assistant                268964423     0x10081247
+XF86EmojiPicker              268964425     0x10081249
+XF86Dictate                  268964426     0x1008124A
+XF86BrightnessMin            268964432     0x10081250
+XF86BrightnessMax            268964433     0x10081251
+XF86KbdInputAssistPrev       268964448     0x10081260
+XF86KbdInputAssistNext       268964449     0x10081261
+XF86KbdInputAssistPrevgroup  268964450     0x10081262
+XF86KbdInputAssistNextgroup  268964451     0x10081263
+XF86KbdInputAssistAccept     268964452     0x10081264
+XF86KbdInputAssistCancel     268964453     0x10081265
+XF86RightUp                  268964454     0x10081266
+XF86RightDown                268964455     0x10081267
+XF86LeftUp                   268964456     0x10081268
+XF86LeftDown                 268964457     0x10081269
+XF86RootMenu                 268964458     0x1008126A
+XF86MediaTopMenu             268964459     0x1008126B
+XF86Numeric11                268964460     0x1008126C
+XF86Numeric12                268964461     0x1008126D
+XF86AudioDesc                268964462     0x1008126E
+XF863DMode                   268964463     0x1008126F
+XF86NextFavorite             268964464     0x10081270
+XF86StopRecord               268964465     0x10081271
+XF86PauseRecord              268964466     0x10081272
+XF86VOD                      268964467     0x10081273
+XF86Unmute                   268964468     0x10081274
+XF86FastReverse              268964469     0x10081275
+XF86SlowReverse              268964470     0x10081276
+XF86Data                     268964471     0x10081277
+XF86OnScreenKeyboard         268964472     0x10081278
+XF86PrivacyScreenToggle      268964473     0x10081279
+XF86SelectiveScreenshot      268964474     0x1008127A
+XF86Macro1                   268964496     0x10081290
+XF86Macro2                   268964497     0x10081291
+XF86Macro3                   268964498     0x10081292
+XF86Macro4                   268964499     0x10081293
+XF86Macro5                   268964500     0x10081294
+XF86Macro6                   268964501     0x10081295
+XF86Macro7                   268964502     0x10081296
+XF86Macro8                   268964503     0x10081297
+XF86Macro9                   268964504     0x10081298
+XF86Macro10                  268964505     0x10081299
+XF86Macro11                  268964506     0x1008129A
+XF86Macro12                  268964507     0x1008129B
+XF86Macro13                  268964508     0x1008129C
+XF86Macro14                  268964509     0x1008129D
+XF86Macro15                  268964510     0x1008129E
+XF86Macro16                  268964511     0x1008129F
+XF86Macro17                  268964512     0x100812A0
+XF86Macro18                  268964513     0x100812A1
+XF86Macro19                  268964514     0x100812A2
+XF86Macro20                  268964515     0x100812A3
+XF86Macro21                  268964516     0x100812A4
+XF86Macro22                  268964517     0x100812A5
+XF86Macro23                  268964518     0x100812A6
+XF86Macro24                  268964519     0x100812A7
+XF86Macro25                  268964520     0x100812A8
+XF86Macro26                  268964521     0x100812A9
+XF86Macro27                  268964522     0x100812AA
+XF86Macro28                  268964523     0x100812AB
+XF86Macro29                  268964524     0x100812AC
+XF86Macro30                  268964525     0x100812AD
+XF86MacroRecordStart         268964528     0x100812B0
+XF86MacroRecordStop          268964529     0x100812B1
+XF86MacroPresetCycle         268964530     0x100812B2
+XF86MacroPreset1             268964531     0x100812B3
+XF86MacroPreset2             268964532     0x100812B4
+XF86MacroPreset3             268964533     0x100812B5
+XF86KbdLcdMenu1              268964536     0x100812B8
+XF86KbdLcdMenu2              268964537     0x100812B9
+XF86KbdLcdMenu3              268964538     0x100812BA
+XF86KbdLcdMenu4              268964539     0x100812BB
+XF86KbdLcdMenu5              268964540     0x100812BC
 XF86Switch_VT_1              269024769     0x1008FE01
 XF86Switch_VT_2              269024770     0x1008FE02
 XF86Switch_VT_3              269024771     0x1008FE03
 XF86Switch_VT_4              269024772     0x1008FE04
 XF86Switch_VT_5              269024773     0x1008FE05
@@ -2070,10 +1475,12 @@
 XF86Switch_VT_8              269024776     0x1008FE08
 XF86Switch_VT_9              269024777     0x1008FE09
 XF86Switch_VT_10             269024778     0x1008FE0A
 XF86Switch_VT_11             269024779     0x1008FE0B
 XF86Switch_VT_12             269024780     0x1008FE0C
+.CE
+.CS
 XF86Ungrab                   269024800     0x1008FE20
 XF86ClearGrab                269024801     0x1008FE21
 XF86Next_VMode               269024802     0x1008FE22
 XF86Prev_VMode               269024803     0x1008FE23
 XF86LogWindowTree            269024804     0x1008FE24
@@ -2241,13 +1648,14 @@
 XF86Keyboard                 269025203     0x1008FFB3
 XF86WWAN                     269025204     0x1008FFB4
 XF86RFKill                   269025205     0x1008FFB5
 XF86AudioPreset              269025206     0x1008FFB6
 XF86RotationLockToggle       269025207     0x1008FFB7
+XF86FullScreen               269025208     0x1008FFB8
 .CE
 .SH "SEE ALSO"
 bind(n), event(n)
 .SH KEYWORDS
 bind, binding, event, keysym
 '\" Local Variables:
 '\" mode: nroff
 '\" End:

Index: doc/listbox.n
==================================================================
--- doc/listbox.n
+++ doc/listbox.n
@@ -561,11 +561,11 @@
 .IP [16]
 In \fBextended\fR mode, the Escape key cancels the most recent
 selection and restores all the elements in the selected range
 to their previous selection state.
 .IP [17]
-Control-slash selects everything in the widget, except in
+Control-/ selects everything in the widget, except in
 \fBsingle\fR and \fBbrowse\fR modes, in which case it selects
 the active element and deselects everything else.
 .IP [18]
 Control-backslash deselects everything in the widget, except in
 \fBbrowse\fR mode where it has no effect.

Index: doc/menu.n
==================================================================
--- doc/menu.n
+++ doc/menu.n
@@ -38,11 +38,11 @@
 which specifies whether or not the menu should include a tear-off
 entry at the top.  If so, it will exist as entry 0 of the menu and
 the other entries will number starting at 1.  The default menu
 bindings arrange for the menu to be torn off when the tear-off entry
 is invoked.
-This option is ignored under Aqua/Mac OS X, where menus cannot
+This option is ignored under Aqua/MacOS, where menus cannot
 be torn off.
 .OP \-tearoffcommand tearOffCommand TearOffCommand
 If this option has a non-empty value, then it specifies a Tcl command
 to invoke whenever the menu is torn off.  The actual command will
 consist of the value of this option, followed by a space, followed
@@ -52,11 +52,11 @@
 .QW "\fBa b\fR"
 and menu \fB.x.y\fR is torn off to
 create a new menu \fB.x.tearoff1\fR, then the command
 .QW "\fBa b .x.y .x.tearoff1\fR"
 will be invoked.
-This option is ignored under Aqua/Mac OS X, where menus cannot
+This option is ignored under Aqua/MacOS, where menus cannot
 be torn off.
 .OP \-title title Title
 The string will be used to title the window created when this menu is
 torn off. If the title is NULL, then the window will have the title
 of the menubutton or the text of the cascade item from which this menu
@@ -314,31 +314,35 @@
 any of the following forms:
 .TP 12
 \fBactive\fR
 .
 Indicates the entry that is currently active.  If no entry is
-active then this form is equivalent to \fBnone\fR.  This form may
+active then this form is equivalent to \fB{}\fR.  This form may
 not be abbreviated.
 .TP 12
 \fBend\fR
 .
 Indicates the bottommost entry in the menu.  If there are no
-entries in the menu then this form is equivalent to \fBnone\fR.
+entries in the menu then this form is equivalent to \fB{}\fR.
 This form may not be abbreviated.
 .TP 12
 \fBlast\fR
 .
 Same as \fBend\fR.
 .TP 12
-\fBnone\fR
+\fB{}\fR
 .
 Indicates
 .QW "no entry at all" ;
 this is used most commonly with
 the \fBactivate\fR option to deactivate all the entries in the
-menu.  In most cases the specification of \fBnone\fR causes
+menu.  In most cases the specification of \fB{}\fR causes
 nothing to happen in the widget command.
+.TP 12
+\fBnone\fR
+.
+Same as \fB{}\fR
 This form may not be abbreviated.
 .TP 12
 \fB@\fInumber\fR
 .
 In this form, \fInumber\fR is treated as a y-coordinate in the
@@ -369,11 +373,11 @@
 \fIpathName \fBactivate \fIindex\fR
 .
 Change the state of the entry indicated by \fIindex\fR to \fBactive\fR
 and redisplay it using its active colors.
 Any previously-active entry is deactivated.  If \fIindex\fR
-is specified as \fBnone\fR, or if the specified entry is
+is specified as \fB{}\fR or \fBnone\fR, or if the specified entry is
 disabled, then the menu ends up with no active entry.
 Returns an empty string.
 .TP
 \fIpathName \fBadd \fItype \fR?\fIoption value option value ...\fR?
 .
@@ -445,11 +449,11 @@
 information on the format of this list).
 .TP
 \fIpathName \fBindex \fIindex\fR
 .
 Returns the numerical index corresponding to \fIindex\fR, or
-\fBnone\fR if \fIindex\fR was specified as \fBnone\fR.
+\fB{}\fR if \fIindex\fR was specified as \fB{}\fR or \fBnone\fR.
 .TP
 \fIpathName \fBinsert \fIindex type \fR?\fIoption value option value ...\fR?
 .
 Same as the \fBadd\fR widget command except that it inserts the new
 entry just before the entry given by \fIindex\fR, instead of appending
@@ -521,22 +525,22 @@
 supported by all entry types.
 .TP
 \fB\-activebackground \fIvalue\fR
 .
 Specifies a background color to use for displaying this entry when it
-is active.
-If this option is specified as an empty string (the default), then the
+is active. This option is ignored on Aqua/MacOS.
+If it is specified as an empty string (the default), then the
 \fB\-activebackground\fR option for the overall menu is used.
 If the \fBtk_strictMotif\fR variable has been set to request strict
 Motif compliance, then this option is ignored and the \fB\-background\fR
 option is used in its place.
 This option is not available for separator or tear-off entries.
 .TP
 \fB\-activeforeground \fIvalue\fR
 .
 Specifies a foreground color to use for displaying this entry when it
-is active.
+is active.   This option is ignored on Aqua/macOS.
 If this option is specified as an empty string (the default), then the
 \fB\-activeforeground\fR option for the overall menu is used.
 This option is not available for separator or tear-off entries.
 .TP
 \fB\-accelerator \fIvalue\fR
@@ -550,11 +554,12 @@
 .TP
 \fB\-background \fIvalue\fR
 .
 Specifies a background color to use for displaying this entry when it
 is in the normal state (neither active nor disabled).
-If this option is specified as an empty string (the default), then the
+This option is ignored on Aqua/macOS.
+If it is specified as an empty string (the default), then the
 \fB\-background\fR option for the overall menu is used.
 This option is not available for separator or tear-off entries.
 .TP
 \fB\-bitmap \fIvalue\fR
 .
@@ -571,11 +576,11 @@
 \fB\-columnbreak \fIvalue\fR
 .
 When this option is zero, the entry appears below the previous entry. When
 this option is one, the entry appears at the top of a new column in the
 menu.
-This option is ignored on Aqua/Mac OS X, where menus are always a single
+This option is ignored on Aqua/macOS, where menus are always a single
 column.
 .TP
 \fB\-command \fIvalue\fR
 .
 Specifies a Tcl command to execute when the menu entry is invoked.
@@ -601,11 +606,12 @@
 .TP
 \fB\-foreground \fIvalue\fR
 .
 Specifies a foreground color to use for displaying this entry when it
 is in the normal state (neither active nor disabled).
-If this option is specified as an empty string (the default), then the
+This option is ignored on Aqua/macOS.
+If it is specified as an empty string (the default), then the
 \fB\-foreground\fR option for the overall menu is used.
 This option is not available for separator or tear-off entries.
 .TP
 \fB\-hidemargin \fIvalue\fR
 .

Index: doc/menubutton.n
==================================================================
--- doc/menubutton.n
+++ doc/menubutton.n
@@ -22,11 +22,11 @@
 \-borderwidth	\-highlightthickness	\-textvariable
 \-cursor	\-image	\-underline
 \-compound	\-justify	\-wraplength
 .SE
 .SH "WIDGET-SPECIFIC OPTIONS"
-.OP \-direction direction Height
+.OP \-direction direction Direction
 Specifies where the menu is going to be popup up. \fBabove\fR tries to
 pop the menu above the menubutton. \fBbelow\fR tries to pop the menu
 below the menubutton. \fBleft\fR tries to pop the menu to the left of
 the menubutton. \fBright\fR tries to pop the menu to the right of the
 menu button. \fBflush\fR pops the menu directly over the menubutton.

Index: doc/messageBox.n
==================================================================
--- doc/messageBox.n
+++ doc/messageBox.n
@@ -64,13 +64,12 @@
 Makes \fIwindow\fR the logical parent of the message box. The message
 box is displayed on top of its parent window.
 .TP
 \fB\-title\fR \fItitleString\fR
 .
-Specifies a string to display as the title of the message box. This option
-is ignored on Mac OS X, where platform guidelines forbid the use of a title
-on this kind of dialog.
+Specifies a string to display as the title of the message box. The
+default value is an empty string.
 .TP
 \fB\-type\fR \fIpredefinedType\fR
 .
 Arranges for a predefined set of buttons to be displayed. The
 following values are possible for \fIpredefinedType\fR:

ADDED   doc/nsimage.n
Index: doc/nsimage.n
==================================================================
--- /dev/null
+++ doc/nsimage.n
@@ -0,0 +1,129 @@
+'\"
+'\" Copyright (c) 2022 Marc Culler
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+.TH nsimage n 8.7 Tk "Tk Built-In Commands"
+.so man.macros
+.BS
+'\" Note:  do not modify the .SH NAME line immediately below!
+.SH NAME
+nsimage \- A Tk image type for macOS based on the NSImage class.
+.BE
+.SH DESCRIPTION
+The nsimage is implemented as a Tk image type.  The \fBimage\fR
+command is used to create, delete, and query all images, including
+images of type \fBnsimage\fR.  The options that are available are
+specific to the nsimage type and are described below.
+.PP
+The command to create an \fBnsimage\fR:
+.TP
+\fBimage create nsimage \fR?\fIname\fR? ?\fIoption value ...\fR?
+.PP
+creates a new nsimage and a command with the same name and returns its
+name.
+.SH OPTIONS
+.PP
+Valid \fIoptions\fR are:
+.TP
+\fB\-source\fR
+.PP
+The value of the \fB\-source\fR option is a string describing an
+NSimage.  There are several ways to interpret this string, and the
+interpretation is determined by the value of the \fB\-as\fR option.
+This option is required.
+.PP
+.TP
+\fB\-as\fR
+.PP
+There are four possible values for the \fB-as\fR option which specify
+how the source string should be interpreted.  The allowed values and
+their meanings are:
+.IP
+\fBname\fR
+.IP
+The source should be interpreted as the name of a named NSImage
+provided by the system.  This is the default if the -as option is not specified.
+.IP
+\fBfile\fR
+.IP
+The source should be interpreted as a path to an image
+file in one of the formats understood by the NSImage class.
+.IP
+\fBpath\fR
+.IP
+The source should be interpreted as a path to an arbitrary
+file. The type of the file will be examined and the resulting image
+will be the system icon for files of that type.
+.IP
+\fBfiletype\fR
+.IP
+The source is interpreted as a string identifying a
+particular file type.  It may be a filename extension, an Apple Uniform Type
+Identifier or a 4-character OSType value as used in the HFS filesystem.
+.TP
+\fB\-width\fR
+.PP
+The value of the \fIwidth\fR option is an integer specifying the width
+in pixels of the nsimage.  If the width is not specified it will be
+computed from the height so as to preserve the aspect ration.  If
+neither width nor height are specified then the width and height of
+the underlying NSImage will be used.
+.TP
+\fB\-height\fR
+.PP
+The value of the \fIheight\fR option is an integer specifying the
+height in pixels of the nsimage. If the height is not specified it
+will be computed from the height so as to preserve the aspect ration.
+If neither width nor height are specified then the width and height of
+the underlying NSImage will be used.
+.TP
+\fB\-radius\fR
+.PP
+The value of the \fIradius\fR option is an integer.  If non-zero the
+image will be clipped to a rounded rectangle with the same width and
+height as the image, but with circular arcs of the specified radius
+cutting off the corners of the rectangle.
+.TP
+\fB\-ring\fR
+.PP
+The value of the \fIring\fR option is an integer.  If non-zero then it
+specifies the thickness of a focus ring which will be drawn around the
+image using the control accent color specified in the System
+Preferences.  The image is resized to reduce its width and height by
+twice the thickness of the ring.  Note that this may create a small
+amount of distortion.  The aspect ration of a non-square image will
+change slightly.
+.TP
+\fB\-alpha\fR
+.PP
+The value of the \fIalpha\fR option should be a floating point number
+between 0.0 and 1.0.  This alpha value will be applied to each pixel
+of the nsimage, producing a partially transparent image.  The default value
+is 1,0, which makes the image opaque.
+.TP
+\fB\-pressed\fR
+.PP
+The \fIpressed\fR option takes a boolean value.  If the value is true
+or 1 then the image will be algorithmically modified to become darker
+in light mode or lighter in dark mode.  The default is false.  For an
+image button, the primary image should use the value false while the
+pressed image should be the same image but with the \fIpressed\fR
+option set to true.
+.TP
+\fB\-template\fR
+.PP
+The \fItemplate\fR option takes a boolean value.  If the value is true
+or 1 then the image will be marked as being a template image.  This
+means that the system will algorithmically convert the image to a
+light colored image when in dark mode.  For the algorithm to work
+correctly the image must consist only of black pixels with alpha
+values.
+.SH "SEE ALSO"
+image(n), options(n), photo(n)
+.SH KEYWORDS
+height, image, types of images, width
+'\" Local Variables:
+'\" mode: nroff
+'\" End:

Index: doc/pack.n
==================================================================
--- doc/pack.n
+++ doc/pack.n
@@ -164,11 +164,11 @@
 the packing order.
 If \fIwindow\fR has no content then an empty string is returned.
 .TP
 \fBpack slaves \fIwindow\fR
 .
-Synonym for . \fBpack content \fIwindow\fR
+Synonym for \fBpack content \fIwindow\fR.
 .SH "THE PACKER ALGORITHM"
 .PP
 For each container the packer maintains an ordered list of content
 windows called the \fIpacking list\fR.
 The \fB\-in\fR, \fB\-after\fR, and \fB\-before\fR configuration

Index: doc/photo.n
==================================================================
--- doc/photo.n
+++ doc/photo.n
@@ -99,10 +99,20 @@
 .
 Specifies the height of the image, in pixels.  This option is useful
 primarily in situations where the user wishes to build up the contents
 of the image piece by piece.  A value of zero (the default) allows the
 image to expand or shrink vertically to fit the data stored in it.
+.VS 8.7
+.TP
+\fB\-metadata \fImetadata\fR
+.
+Set the metadata dictionary of the image.
+Additional keys may be set within the metadata dictionary of the image,
+if image data is processed due to a \fB\-file\fR or \fB\-data\fR options
+and the driver outputs any metadata keys.
+See section \fBMETADATA DICTIONARY\fR below.
+.VE 8.7
 .TP
 \fB\-palette \fIpalette-spec\fR
 .
 Specifies the resolution of the color cube to be allocated for
 displaying this image, and thus the number of colors used from the
@@ -144,11 +154,11 @@
 .TP
 \fIimageName \fBblank\fR
 .
 Blank the image; that is, set the entire image to have no data, so it
 will be displayed as transparent, and the background of whatever
-window it is displayed in will show through.
+window it is displayed in will show through. The metadata dict of the image is not changed.
 .TP
 \fIimageName \fBcget\fR \fIoption\fR
 .
 Returns the current value of the configuration option given
 by \fIoption\fR.
@@ -167,10 +177,14 @@
 one or more \fIoption\-value\fR pairs are specified, then the command
 modifies the given option(s) to have the given value(s);  in
 this case the command returns an empty string.
 \fIOption\fR may have any of the values accepted by the
 \fBimage create\fR \fBphoto\fR command.
+.VS 8.7
+Note: setting the \fB\-metadata\fR option without any other option
+will not invoke the image format driver to recreate the bitmap.
+.VE 8.7
 .TP
 \fIimageName \fBcopy\fR \fIsourceImage\fR ?\fIoption value(s) ...\fR?
 .
 Copies a region from the image called \fIsourceImage\fR (which must
 be a photo image) to the image called \fIimageName\fR, possibly with
@@ -285,13 +299,22 @@
 .TP
 \fB\-grayscale\fR
 .
 If this options is specified, the data will not contain color
 information. All pixel data will be transformed into grayscale.
-.RE
 .VS 8.7
 .TP
+\fB\-metadata\fR \fImetadata\fR
+.
+Image format handler may use metadata to be included in the returned
+data string.
+The specified \fImetadata\fR is passed to the driver for inclusion in the
+data.
+If no \fB\-metadata\fR option is given, the current metadata of the
+image is used.
+.VE 8.7
+.RE
 \fIimageName \fBget\fR \fIx y\fR ?\fB-withalpha\fR?
 .
 Returns the color of the pixel at coordinates (\fIx\fR,\fIy\fR) in the
 image as a list of three integers between 0 and 255, representing the
 red, green and blue components respectively. If the \fB-withalpha\fR
@@ -320,10 +343,19 @@
 \fIformat-name\fR will be used while searching for an image data
 format handler to read the data.
 Note: the value of this option must be a Tcl list.
 This means that the braces may be omitted if the argument has only one
 word. Also, instead of braces, double quotes may be used for quoting.
+.VS 8.7
+.TP
+\fB\-metadata\fR \fImetadata\fR
+.
+A specified \fImetadata\fR is passed to the image format driver when interpreting
+the data.
+Note: The current metadata of the image is not passed to the format driver
+and is not changed by the command.
+.VE 8.7
 .TP
 \fB\-to \fIx1 y1\fR ?\fIx2 y2\fR?
 .
 Specifies the coordinates of the top-left corner (\fIx1\fR,\fIy1\fR)
 of the region of \fIimageName\fR into which the image data will be
@@ -365,10 +397,19 @@
 specified, the region extends from (\fIx1,y1\fR) to the bottom-right
 corner of the image in the image file.  If all four coordinates are
 specified, they specify diagonally opposite corners or the region.
 The default, if this option is not specified, is the whole of the
 image in the image file.
+.VS 8.7
+.TP
+\fB\-metadata\fR \fImetadata\fR
+.
+A specified \fImetadata\fR is passed to the image format driver when interpreting
+the data.
+Note: The current metadata of the image is not passed to the format driver
+and is not changed by the command.
+.VE 8.7
 .TP
 \fB\-shrink\fR
 .
 If this option, the size of \fIimageName\fR will be reduced, if
 necessary, so that the region into which the image file data are read
@@ -458,10 +499,20 @@
 .TP
 \fB\-grayscale\fR
 .
 If this options is specified, the data will not contain color
 information. All pixel data will be transformed into grayscale.
+.VS 8.7
+.TP
+\fB\-metadata\fR \fBmetadata\fR
+.
+Image format handler may use metadata to be included in the written file.
+The specified \fImetadata\fR is passed to the driver for inclusion in the
+file.
+If no \fB\-metadata\fR option is given, the current metadata of the
+image is used.
+.VE 8.7
 .RE
 .SH "IMAGE FORMATS"
 .PP
 The photo image code is structured to allow handlers for additional
 image file formats to be added easily.  The photo image code maintains
@@ -680,10 +731,43 @@
 this option is used, it specifies the maximum number of shades of
 each primary color to try to allocate.  It can also be used to force
 the image to be displayed in shades of gray, even on a color display,
 by giving a single number rather than three numbers separated by
 slashes.
+.VS 8.7
+.SH "METADATA DICTIONARY"
+.PP
+Each image has a metadata dictionary property.
+This dictionary is not relevant to the bitmap representation of the
+image, but may contain additional information like resolution or
+comments.
+Image format drivers may output metadata when image data is
+parsed, or may use metadata to be included in image files or formats.
+.SS "METADATA KEYS"
+.PP
+Each image format driver supports an individual set of metadata dictionary
+keys. Predefined keys are:
+.TP
+DPI
+.
+Horizontal image resolution in DPI as a double value.
+Supported by format \fBpng\fR.
+.TP
+aspect
+.
+Aspect ratio horizontal divided by vertical as double value.
+Supported by formats \fBgif\fR and \fBpng\fR.
+.TP
+comment
+.
+Image text comment.
+Supported by formats \fBgif\fR and \fBpng\fR.
+.PP
+It is valid to set any key in the metadata dict.
+A format driver will ignore keys it does not handle.
+.PP
+.VE 8.7
 .SH CREDITS
 .PP
 The photo image type was designed and implemented by Paul Mackerras,
 based on his earlier photo widget and some suggestions from
 John Ousterhout.

Index: doc/place.n
==================================================================
--- doc/place.n
+++ doc/place.n
@@ -195,11 +195,11 @@
 Returns a list of all the content windows for which \fIwindow\fR is the container.
 If there is no content for \fIwindow\fR then an empty string is returned.
 .TP
 \fBplace slaves \fIwindow\fR
 .
-Synonym for . \fBplace content \fIwindow\fR
+Synonym for \fBplace content \fIwindow\fR.
 .PP
 If the configuration of a window has been retrieved with
 \fBplace info\fR, that configuration can be restored later by
 first using \fBplace forget\fR to erase any existing information
 for the window and then invoking \fBplace configure\fR with

ADDED   doc/print.n
Index: doc/print.n
==================================================================
--- /dev/null
+++ doc/print.n
@@ -0,0 +1,63 @@
+.\" Text automatically generated by txt2man
+'\"
+'\" Copyright (c) 2021 Kevin Walzer/WordTech Communications LLC.
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+
+.TH tk print n "" Tk "Tk Built-in Commands"
+.so man.macros
+.SH NAME
+print \- Print canvas and text widgets using native dialogs and APIs.
+.SH SYNOPSIS
+\fBtk print \fIwindow\fR
+.
+.SH DESCRIPTION
+.PP
+The \fBtk print\fR command posts a dialog that allows users to print output
+from the \fBcanvas\fR and \fBtext\fR widgets. The printing will be done using
+platform-native APIs and dialogs where available.
+.PP
+The \fBcanvas\fR widget has long supported PostScript export and both
+PostScript and text files can be sent directly to a printer on Unix-like
+systems using the
+.QW "lp"
+and
+.QW "lpr"
+Unix commands, and the \fBtk print\fR command does not supersede that
+functionality; it builds on it. The \fBtk print\fR command is a fuller
+implementation that uses native dialogs on macOS and Windows, and a Tk-based
+dialog that provides parallel functionality on X11.
+.SH PLATFORM NOTES
+.TP
+\fBmacOS\fR
+.
+The Mac implementation uses native print dialogs and relies on the underlying
+Common Unix Printing System (CUPS) to render text output from the text widget
+and PostScript output from the canvas widget to the printer, to a PDF file, or
+a PostScript file.
+.TP
+\fBWindows\fR
+.
+The Windows implementation is based on the GDI (Graphics Device Interface)
+API. Because there are slight differences in how GDI and Tk's \fBcanvas\fR
+widget display graphics, printed output from the \fBcanvas\fR on Windows may
+not be identical to screen rendering.
+.TP
+\fBX11\fR
+.
+The X11 implementation uses a Tk GUI to configure print jobs for sending to a
+printer via the
+.QW "lpr"
+or
+.QW "lp"
+commands. While these commands have a large number of parameters for
+configuring print jobs, printers vary widely in how they support these
+parameters. As a result, only printer selection and number of copies are
+configured as arguments to the print command; many aspects of print rendering,
+such as grayscale or color for the canvas, are instead configured when
+PostScript is generated.
+.SH "SEE ALSO"
+canvas(n), text(n), tk(n)
+.SH KEYWORDS
+print, output, graphics, text, canvas

Index: doc/spinbox.n
==================================================================
--- doc/spinbox.n
+++ doc/spinbox.n
@@ -222,11 +222,11 @@
 .PP
 Also, the \fB-validate\fR option will set itself to \fBnone\fR when the
 spinbox value gets changed because of adjustment of \fB-from\fR or \fB-to\fR
 and the \fB-validatecommand\fR returns false. For instance
 .CS
-     \fIspinbox pathName \-from 1 \-to 10 \-validate all \-vcmd {return 0}\fR
+     \fIspinbox pathName \-from 1 \-to 10 \-validate all \-validatecommand {return 0}\fR
 .CE
 will in fact set the \fB-validate\fR option to \fBnone\fR because the default
 value for the spinbox gets changed (due to the \fB-from\fR and \fB-to\fR
 options) to a value not accepted by the validation script.
 .PP

ADDED   doc/sysnotify.n
Index: doc/sysnotify.n
==================================================================
--- /dev/null
+++ doc/sysnotify.n
@@ -0,0 +1,56 @@
+.\" Text automatically generated by txt2man
+'\"
+'\" Copyright (c) 2020 Kevin Walzer/WordTech Communications LLC.
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+.TH tk sysnotify n "" Tk "Tk Built-In Commands"
+.so man.macros
+.SH NAME
+sysnotify \- Creates a notification window with a title and message.
+.SH SYNOPSIS
+\fBtk sysnotify\fR \fItitle\fR \fImessage\fR
+.BE
+.SH DESCRIPTION
+.PP
+The \fBtk sysnotify\fR command creates a platform-specific system notification alert. Its intent is to provide a brief, unobtrusive notification to the user by popping up a window that briefly appears in a corner of the screen.
+.SH EXAMPLE
+.PP
+Here is an example of the \fBtk sysnotify\fR code:
+.PP
+.CS
+tk sysnotify "Alert" \e
+      "This is just a test of the Tk System Notification Code."
+.CE
+.SH PLATFORM NOTES
+.PP
+The macOS and Windows versions are native implementations using system
+API's. The X11 version has a conditional dependency on libnotify, and
+falls back to a Tcl-only implementation if libnotify is not installed. On
+each platform the notification includes a platform-specific default image to
+accompany the text.
+.TP
+\fBmacOS\fR
+.
+The macOS version will request permission from the user to authorize
+notifications. This must be activated in Apple's System Preferences
+Notifications section.
+.RS
+.PP
+If deploying an application using the standalone version of Wish.app,
+setting the bundle ID in the applications Info.plist file to begin with
+.QW \fBcom\fR
+seems necessary for notifications to work. Using a different prefix
+for the bundle ID, such as something like
+.QW \fBtk.tcl.tkchat\fR ,
+will cause notifications to silently fail.
+.RE
+.TP
+\fBWindows\fR
+.
+The image is taken from the system tray, i.e., \fBsysnotify\fR can only be
+called when a \fBsystray\fR was installed.
+.
+.SH KEYWORDS
+notify, alert

ADDED   doc/systray.n
Index: doc/systray.n
==================================================================
--- /dev/null
+++ doc/systray.n
@@ -0,0 +1,65 @@
+.\" Text automatically generated by txt2man
+'\"
+'\" Copyright (c) 2020 Kevin Walzer/WordTech Communications LLC.
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+.TH tk systray n "" Tk "Tk Built-In Commands"
+.so man.macros
+.SH NAME
+systray \- Creates an icon display in the platform-specific system tray.
+.SH SYNOPSIS
+\fBtk systray create \fI-image image\fR \fI?-text text\fR? \fI?-button1 callback?\fR \fI?-button3 callback?\fR
+.sp
+\fBtk systray configure \fI?option? ?value option value ...?\fR
+.sp
+\fBtk systray destroy\fR
+.BE
+.BE
+.SH DESCRIPTION
+.PP
+The \fBtk systray create\fR command creates an icon in the platform-specific
+tray. The widget is configured with a Tk image for the icon display, an
+optional string for display in a tooltip, and optional callbacks that are
+bound to <Button-1> and <Button-3>.
+.PP
+The \fBtk systray configure\fR command sets one or more options of the systray
+icon. Configurable options are the same as for the \fBcreate\fR subcommand. When
+a single option name is given, the command returns the current valus of this
+option. When no option is given this command returns the list of all options and
+their current value.
+.PP
+ The \fBtk systray destroy\fR command removes the icon from display and
+deallocates it.
+.PP
+From a user-interface standpoint, only one icon per interpreter is
+supported; attempts to create additional icons will return an error. The
+existing tray icon can be modified with different images and
+strings to indicate app state. Loading additional interpreters into a
+running instance of Wish will allow additional icons to be displayed.
+.SH EXAMPLE
+.PP
+Here is an example of the \fBtk systray\fR code:
+.CS
+    image create photo book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+    tk systray create -image book -text "tk systray sample" -button1 {puts "Here is the tk systray output"} -button3 {puts "here is alternate output"}
+.CE
+.PP
+Here is an example of modifying the \fBtk systray\fR icon:
+.CS
+    image create photo book_page -data R0lGODlhCwAPAKIAAP//////AMDAwICAgAAA/wAAAAAAAAAAACwAAAAACwAPAAADMzi6CzAugiAgDGE68aB0RXgRJBFVX0SNpQlUWfahQOvSsgrX7eZJMlQMWBEYj8iQchlKAAA7
+    tk systray configure -image book_page -text "Updated sample" -button1 {puts "Different output from the tk systray"} -button3 {puts "and more different output from the tk systray"}
+.CE
+.SH PLATFORM NOTES
+.PP
+The X11 implementation is supported on a "best efforts" basis because it is
+dependent on the window manager. The "text" flag, which is implemented as
+a tooltip, does not always display if the WM does not support such features;
+the systray icon itself may not even display with some window managers.
+.PP
+On Windows, the Tk image provided in the \fI-image\fR option must be a
+photo image. On other platforms either a bitmap image or a photo image
+may be provided.
+.SH KEYWORDS
+image, callback

Index: doc/text.n
==================================================================
--- doc/text.n
+++ doc/text.n
@@ -845,10 +845,13 @@
 within this application, then the \fBsel\fR tag will be removed from all
 characters in the text.
 .IP [4]
 Whenever the \fBsel\fR tag range changes a virtual event \fB<<Selection>>\fR
 is generated.
+It might also be generated when selection is affected but not actually changed.
+Further, multiple selection changes could happen before events can be processed
+leading to multiple events with the same visible selection.
 .PP
 The \fBsel\fR tag is automatically defined when a text widget is created, and
 it may not be deleted with the
 .QW "\fIpathName \fBtag delete\fR"
 widget command. Furthermore, the \fB\-selectbackground\fR,
@@ -1350,11 +1353,11 @@
 are empty strings.
 .TP
 \fIpathName \fBimage \fIoption \fR?\fIarg ...\fR?
 .
 This command is used to manipulate embedded images. The behavior of the
-command depends on the \fIoption\fR argument that follows the \fBtag\fR
+command depends on the \fIoption\fR argument that follows the \fBimage\fR
 argument. The following forms of the command are currently supported:
 .RS
 .TP
 \fIpathName \fBimage cget \fIindex option\fR
 .
@@ -1732,19 +1735,21 @@
 all the sequences for which bindings have been defined for \fItagName\fR.
 .RS
 .PP
 The only events for which bindings may be specified are those related to the
 mouse and keyboard (such as \fBEnter\fR, \fBLeave\fR, \fBButton\fR,
-\fBMotion\fR, and \fBKey\fR) or virtual events. Event bindings for a text
-widget use the \fBcurrent\fR mark described under \fBMARKS\fR above. An
+\fBMotion\fR, and \fBKey\fR) or virtual events. Mouse and keyboard event
+bindings for a text widget respectively use the \fBcurrent\fR and \fBinsert\fR
+marks described under \fBMARKS\fR above. An
 \fBEnter\fR event triggers for a tag when the tag first becomes present on the
 current character, and a \fBLeave\fR event triggers for a tag when it ceases
 to be present on the current character. \fBEnter\fR and \fBLeave\fR events can
 happen either because the \fBcurrent\fR mark moved or because the character at
 that position changed. Note that these events are different than \fBEnter\fR
-and \fBLeave\fR events for windows. Mouse and keyboard events are directed to
-the current character. If a virtual event is used in a binding, that binding
+and \fBLeave\fR events for windows. Mouse events are directed to the current
+character, while keyboard events are directed to the insert character.
+If a virtual event is used in a binding, that binding
 can trigger only if the virtual event is defined by an underlying
 mouse-related or keyboard-related event.
 .PP
 It is possible for the current character to have multiple tags, and for each
 of them to have a binding for a particular event sequence. When this occurs,
@@ -2031,11 +2036,11 @@
 In the descriptions below,
 .QW word
 is dependent on the value of
 the \fBtcl_wordchars\fR variable.  See \fBtclvars\fR(n).
 .IP [1]
-Clicking mouse button 1 positions the insertion cursor just before the
+Clicking mouse button 1 positions the insertion cursor at the closest edge of the
 character underneath the mouse cursor, sets the input focus to this widget,
 and clears any selection in the widget. Dragging with mouse button 1 strokes
 out a selection between the insertion cursor and the character under the
 mouse.
 .IP [2]

Index: doc/tk.n
==================================================================
--- doc/tk.n
+++ doc/tk.n
@@ -83,10 +83,17 @@
 .RE
 .TP
 \fBtk fontchooser \fIsubcommand\fR ...
 Controls the Tk font selection dialog. For more details see the
 \fBfontchooser\fR manual page.
+.TP
+\fBtk print \fIwindow\fR
+.
+The \fBtk print\fR command posts a dialog that allows users to print output
+from the \fBcanvas\fR and \fBtext\fR widgets. The printing will be done using
+platform-native APIs and dialogs where available. For more details see the
+\fBprint\fR manual page.
 .TP
 \fBtk scaling \fR?\fB\-displayof \fIwindow\fR? ?\fInumber\fR?
 .
 Sets and queries the current scaling factor used by Tk to convert between
 physical units (for example, points, inches, or millimeters) and pixels.  The
@@ -109,10 +116,22 @@
 after the scaling factor is changed will use the new scaling factor, but it
 is undefined whether existing widgets will resize themselves dynamically to
 accommodate the new scaling factor.
 .RE
 .TP
+\fBtk sysnotify \fP \fItitle\fP? \fImessage\fP?
+.
+The \fBtk sysnotify\fP  command creates a platform-specific system
+notification alert. Its intent is to provide a brief, unobtrusive
+notification to the user by popping up a window that briefly appears in a
+corner of the screen. For more details see the \fBsysnotify\fR manual page.
+.TP
+\fBtk systray create\fP \fIsubcommand...\fP
+.
+The \fBtk systray\fP command creates an icon in the platform-specific
+tray. For more details see the \fBsystray\fR manual page.
+.TP
 \fBtk useinputmethods \fR?\fB\-displayof \fIwindow\fR? ?\fIboolean\fR?
 .
 Sets and queries the state of whether Tk should use XIM (X Input Methods)
 for filtering events.  The resulting state is returned.  XIM is used in
 some locales (i.e., Japanese, Korean), to handle special input devices. This
@@ -125,11 +144,11 @@
 .
 Returns the current Tk windowing system, one of
 \fBx11\fR (X11-based), \fBwin32\fR (MS Windows),
 or \fBaqua\fR (Mac OS X Aqua).
 .SH "SEE ALSO"
-busy(n), fontchooser(n), send(n), winfo(n)
+busy(n), fontchooser(n), print(n), send(n), sysnotify(n), systray(n), winfo(n)
 .SH KEYWORDS
-application name, send
+application name, print, send, sysnotify, systray
 '\" Local Variables:
 '\" mode: nroff
 '\" End:

DELETED doc/tk4.0.ps
Index: doc/tk4.0.ps
==================================================================
--- doc/tk4.0.ps
+++ /dev/null
@@ -1,4602 +0,0 @@
-%!
-%%BoundingBox: (atend)
-%%Pages: (atend)
-%%DocumentFonts: (atend)
-%%EndComments
-%%BeginProlog
-%
-% FrameMaker postscript_prolog 3.0, for use with FrameMaker 3.0
-% This postscript_prolog file is Copyright (c) 1986-1991 Frame Technology
-% Corporation.  All rights reserved.  This postscript_prolog file may be
-% freely copied and distributed in conjunction with documents created using
-% FrameMaker.
-% NOTE
-% This file fixes the problem with NeWS printers dithering color output.
-% Any questions should be sent to mickey@magickingdom.eng.sun.com
-%
-% Known Problems:
-%	Due to bugs in Transcript, the 'PS-Adobe-' is omitted from line 1
-/FMversion (3.0) def
-% Set up Color vs. Black-and-White
-
-/FMPrintInColor { % once-thru loop gimmick
-    % See if we're a NeWSprint printer
-     /currentcanvas where {
-        pop systemdict /separationdict known
-	exit
-     } if
-% originally had the following, which should always be false:
-%    /currentcanvas where {
-%        pop currentcanvas /Color known {
-%	    currentcanvas /Color get
-%	    exit
-%        } if
-%    } if
-    systemdict /colorimage known
-    systemdict /currentcolortransfer known and
-exit } loop def
-
-% Uncomment the following line to force b&w on color printer
-%   /FMPrintInColor false def
-/FrameDict 195 dict def
-systemdict /errordict known not {/errordict 10 dict def
-		errordict /rangecheck {stop} put} if
-% The readline in 23.0 doesn't recognize cr's as nl's on AppleTalk
-FrameDict /tmprangecheck errordict /rangecheck get put
-errordict /rangecheck {FrameDict /bug true put} put
-FrameDict /bug false put
-mark
-% Some PS machines read past the CR, so keep the following 3 lines together!
-currentfile 5 string readline
-00
-0000000000
-cleartomark
-errordict /rangecheck FrameDict /tmprangecheck get put
-FrameDict /bug get {
-	/readline {
-		/gstring exch def
-		/gfile exch def
-		/gindex 0 def
-		{
-			gfile read pop
-			dup 10 eq {exit} if
-			dup 13 eq {exit} if
-			gstring exch gindex exch put
-			/gindex gindex 1 add def
-		} loop
-		pop
-		gstring 0 gindex getinterval true
-		} def
-	} if
-/FMVERSION {
-	FMversion ne {
-		/Times-Roman findfont 18 scalefont setfont
-		100 100 moveto
-		(FrameMaker version does not match postscript_prolog!)
-		dup =
-		show showpage
-		} if
-	} def
-/FMLOCAL {
-	FrameDict begin
-	0 def
-	end
-	} def
-	/gstring FMLOCAL
-	/gfile FMLOCAL
-	/gindex FMLOCAL
-	/orgxfer FMLOCAL
-	/orgproc FMLOCAL
-	/organgle FMLOCAL
-	/orgfreq FMLOCAL
-	/yscale FMLOCAL
-	/xscale FMLOCAL
-	/manualfeed FMLOCAL
-	/paperheight FMLOCAL
-	/paperwidth FMLOCAL
-/FMDOCUMENT {
-	array /FMfonts exch def
-	/#copies exch def
-	FrameDict begin
-	0 ne dup {setmanualfeed} if
-	/manualfeed exch def
-	/paperheight exch def
-	/paperwidth exch def
-	/yscale exch def
-	/xscale exch def
-	currenttransfer cvlit /orgxfer exch def
-	currentscreen cvlit /orgproc exch def
-	/organgle exch def /orgfreq exch def
-	setpapername
-	manualfeed {true} {papersize} ifelse
-	{manualpapersize} {false} ifelse
-	{desperatepapersize} if
-	end
-	} def
-	/pagesave FMLOCAL
-	/orgmatrix FMLOCAL
-	/landscape FMLOCAL
-/FMBEGINPAGE {
-	FrameDict begin
-	/pagesave save def
-	3.86 setmiterlimit
-	/landscape exch 0 ne def
-	landscape {
-		90 rotate 0 exch neg translate pop
-		}
-		{pop pop}
-		ifelse
-	xscale yscale scale
-	/orgmatrix matrix def
-	gsave
-	} def
-/FMENDPAGE {
-	grestore
-	pagesave restore
-	end
-	showpage
-	} def
-/FMFONTDEFINE {
-	FrameDict begin
-	findfont
-	ReEncode
-	1 index exch
-	definefont
-	FMfonts 3 1 roll
-	put
-	end
-	} def
-/FMFILLS {
-	FrameDict begin
-	array /fillvals exch def
-	end
-	} def
-/FMFILL {
-	FrameDict begin
-	 fillvals 3 1 roll put
-	end
-	} def
-/FMNORMALIZEGRAPHICS {
-	newpath
-	0.0 0.0 moveto
-	1 setlinewidth
-	0 setlinecap
-	0 0 0 sethsbcolor
-	0 setgray
-	} bind def
-	/fx FMLOCAL
-	/fy FMLOCAL
-	/fh FMLOCAL
-	/fw FMLOCAL
-	/llx FMLOCAL
-	/lly FMLOCAL
-	/urx FMLOCAL
-	/ury FMLOCAL
-/FMBEGINEPSF {
-	end
-	/FMEPSF save def
-	/showpage {} def
-	FMNORMALIZEGRAPHICS
-	[/fy /fx /fh /fw /ury /urx /lly /llx] {exch def} forall
-	fx fy translate
-	rotate
-	fw urx llx sub div fh ury lly sub div scale
-	llx neg lly neg translate
-	} bind def
-/FMENDEPSF {
-	FMEPSF restore
-	FrameDict begin
-	} bind def
-FrameDict begin
-/setmanualfeed {
-%%BeginFeature *ManualFeed True
-	 statusdict /manualfeed true put
-%%EndFeature
-	} def
-/max {2 copy lt {exch} if pop} bind def
-/min {2 copy gt {exch} if pop} bind def
-/inch {72 mul} def
-/pagedimen {
-	paperheight sub abs 16 lt exch
-	paperwidth sub abs 16 lt and
-	{/papername exch def} {pop} ifelse
-	} def
-	/papersizedict FMLOCAL
-/setpapername {
-	/papersizedict 14 dict def
-	papersizedict begin
-	/papername /unknown def
-		/Letter 8.5 inch 11.0 inch pagedimen
-		/LetterSmall 7.68 inch 10.16 inch pagedimen
-		/Tabloid 11.0 inch 17.0 inch pagedimen
-		/Ledger 17.0 inch 11.0 inch pagedimen
-		/Legal 8.5 inch 14.0 inch pagedimen
-		/Statement 5.5 inch 8.5 inch pagedimen
-		/Executive 7.5 inch 10.0 inch pagedimen
-		/A3 11.69 inch 16.5 inch pagedimen
-		/A4 8.26 inch 11.69 inch pagedimen
-		/A4Small 7.47 inch 10.85 inch pagedimen
-		/B4 10.125 inch 14.33 inch pagedimen
-		/B5 7.16 inch 10.125 inch pagedimen
-	end
-	} def
-/papersize {
-	papersizedict begin
-		/Letter {lettertray letter} def
-		/LetterSmall {lettertray lettersmall} def
-		/Tabloid {11x17tray 11x17} def
-		/Ledger {ledgertray ledger} def
-		/Legal {legaltray legal} def
-		/Statement {statementtray statement} def
-		/Executive {executivetray executive} def
-		/A3 {a3tray a3} def
-		/A4 {a4tray a4} def
-		/A4Small {a4tray a4small} def
-		/B4 {b4tray b4} def
-		/B5 {b5tray b5} def
-		/unknown {unknown} def
-	papersizedict dup papername known {papername} {/unknown} ifelse get
-	end
-	/FMdicttop countdictstack 1 add def
-	statusdict begin stopped end
-	countdictstack -1 FMdicttop {pop end} for
-	} def
-/manualpapersize {
-	papersizedict begin
-		/Letter {letter} def
-		/LetterSmall {lettersmall} def
-		/Tabloid {11x17} def
-		/Ledger {ledger} def
-		/Legal {legal} def
-		/Statement {statement} def
-		/Executive {executive} def
-		/A3 {a3} def
-		/A4 {a4} def
-		/A4Small {a4small} def
-		/B4 {b4} def
-		/B5 {b5} def
-		/unknown {unknown} def
-	papersizedict dup papername known {papername} {/unknown} ifelse get
-	end
-	stopped
-	} def
-/desperatepapersize {
-	statusdict /setpageparams known
-		{
-		paperwidth paperheight 0 1
-		statusdict begin
-		{setpageparams} stopped pop
-		end
-		} if
-	} def
-/savematrix {
-	orgmatrix currentmatrix pop
-	} bind def
-/restorematrix {
-	orgmatrix setmatrix
-	} bind def
-/dmatrix matrix def
-/dpi    72 0 dmatrix defaultmatrix dtransform
-    dup mul exch   dup mul add   sqrt def
-/freq dpi 18.75 div 8 div round dup 0 eq {pop 1} if 8 mul dpi exch div def
-/sangle 1 0 dmatrix defaultmatrix dtransform exch atan def
-/DiacriticEncoding [
-/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/.notdef /.notdef /.notdef /.notdef /space /exclam /quotedbl
-/numbersign /dollar /percent /ampersand /quotesingle /parenleft
-/parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
-/two /three /four /five /six /seven /eight /nine /colon /semicolon
-/less /equal /greater /question /at /A /B /C /D /E /F /G /H /I /J /K
-/L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash
-/bracketright /asciicircum /underscore /grave /a /b /c /d /e /f /g /h
-/i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar
-/braceright /asciitilde /.notdef /Adieresis /Aring /Ccedilla /Eacute
-/Ntilde /Odieresis /Udieresis /aacute /agrave /acircumflex /adieresis
-/atilde /aring /ccedilla /eacute /egrave /ecircumflex /edieresis
-/iacute /igrave /icircumflex /idieresis /ntilde /oacute /ograve
-/ocircumflex /odieresis /otilde /uacute /ugrave /ucircumflex
-/udieresis /dagger /.notdef /cent /sterling /section /bullet
-/paragraph /germandbls /registered /copyright /trademark /acute
-/dieresis /.notdef /AE /Oslash /.notdef /.notdef /.notdef /.notdef
-/yen /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/ordfeminine /ordmasculine /.notdef /ae /oslash /questiondown
-/exclamdown /logicalnot /.notdef /florin /.notdef /.notdef
-/guillemotleft /guillemotright /ellipsis /.notdef /Agrave /Atilde
-/Otilde /OE /oe /endash /emdash /quotedblleft /quotedblright
-/quoteleft /quoteright /.notdef /.notdef /ydieresis /Ydieresis
-/fraction /currency /guilsinglleft /guilsinglright /fi /fl /daggerdbl
-/periodcentered /quotesinglbase /quotedblbase /perthousand
-/Acircumflex /Ecircumflex /Aacute /Edieresis /Egrave /Iacute
-/Icircumflex /Idieresis /Igrave /Oacute /Ocircumflex /.notdef /Ograve
-/Uacute /Ucircumflex /Ugrave /dotlessi /circumflex /tilde /macron
-/breve /dotaccent /ring /cedilla /hungarumlaut /ogonek /caron
-] def
-/ReEncode {
-	dup
-	length
-	dict begin
-	{
-	1 index /FID ne
-		{def}
-		{pop pop} ifelse
-	} forall
-	0 eq {/Encoding DiacriticEncoding def} if
-	currentdict
-	end
-	} bind def
-/graymode true def
-	/bwidth FMLOCAL
-	/bpside FMLOCAL
-	/bstring FMLOCAL
-	/onbits FMLOCAL
-	/offbits FMLOCAL
-	/xindex FMLOCAL
-	/yindex FMLOCAL
-	/x FMLOCAL
-	/y FMLOCAL
-/setpattern {
-	 /bwidth  exch def
-	 /bpside  exch def
-	 /bstring exch def
-	 /onbits 0 def  /offbits 0 def
-	 freq sangle landscape {90 add} if
-		{/y exch def
-		 /x exch def
-		 /xindex x 1 add 2 div bpside mul cvi def
-		 /yindex y 1 add 2 div bpside mul cvi def
-		 bstring yindex bwidth mul xindex 8 idiv add get
-		 1 7 xindex 8 mod sub bitshift and 0 ne
-		 {/onbits  onbits  1 add def 1}
-		 {/offbits offbits 1 add def 0}
-		 ifelse
-		}
-		setscreen
-	 {} settransfer
-	 offbits offbits onbits add div FMsetgray
-	/graymode false def
-	} bind def
-/grayness {
-	FMsetgray
-	graymode not {
-		/graymode true def
-		orgxfer cvx settransfer
-		orgfreq organgle orgproc cvx setscreen
-		} if
-	} bind def
-	/HUE FMLOCAL
-	/SAT FMLOCAL
-	/BRIGHT FMLOCAL
-	/Colors FMLOCAL
-FMPrintInColor
-
-	{
-	/HUE 0 def
-	/SAT 0 def
-	/BRIGHT 0 def
-	% array of arrays Hue and Sat values for the separations [HUE BRIGHT]
-	/Colors
-	[[0    0  ]    % black
-	 [0    0  ]    % white
-	 [0.00 1.0]    % red
-	 [0.37 1.0]    % green
-	 [0.60 1.0]    % blue
-	 [0.50 1.0]    % cyan
-	 [0.83 1.0]    % magenta
-	 [0.16 1.0]    % comment / yellow
-	 ] def
-
-	/BEGINBITMAPCOLOR {
-		BITMAPCOLOR} def
-	/BEGINBITMAPCOLORc {
-		BITMAPCOLORc} def
-	/BEGINBITMAPTRUECOLOR {
-		BITMAPTRUECOLOR } def
-	/BEGINBITMAPTRUECOLORc {
-		BITMAPTRUECOLORc } def
-	/K {
-		Colors exch get dup
-		0 get /HUE exch store
-		1 get /BRIGHT exch store
-		  HUE 0 eq BRIGHT 0 eq and
-			{1.0 SAT sub setgray}
-			{HUE SAT BRIGHT sethsbcolor}
-		  ifelse
-		} def
-	/FMsetgray {
-		/SAT exch 1.0 exch sub store
-		  HUE 0 eq BRIGHT 0 eq and
-			{1.0 SAT sub setgray}
-			{HUE SAT BRIGHT sethsbcolor}
-		  ifelse
-		} bind def
-	}
-
-	{
-	/BEGINBITMAPCOLOR {
-		BITMAPGRAY} def
-	/BEGINBITMAPCOLORc {
-		BITMAPGRAYc} def
-	/BEGINBITMAPTRUECOLOR {
-		BITMAPTRUEGRAY } def
-	/BEGINBITMAPTRUECOLORc {
-		BITMAPTRUEGRAYc } def
-	/FMsetgray {setgray} bind def
-	/K {
-		pop
-		} def
-	}
-ifelse
-/normalize {
-	transform round exch round exch itransform
-	} bind def
-/dnormalize {
-	dtransform round exch round exch idtransform
-	} bind def
-/lnormalize {
-	0 dtransform exch cvi 2 idiv 2 mul 1 add exch idtransform pop
-	} bind def
-/H {
-	lnormalize setlinewidth
-	} bind def
-/Z {
-	setlinecap
-	} bind def
-	/fillvals FMLOCAL
-/X {
-	fillvals exch get
-	dup type /stringtype eq
-	{8 1 setpattern}
-	{grayness}
-	ifelse
-	} bind def
-/V {
-	gsave eofill grestore
-	} bind def
-/N {
-	stroke
-	} bind def
-/M {newpath moveto} bind def
-/E {lineto} bind def
-/D {curveto} bind def
-/O {closepath} bind def
-	/n FMLOCAL
-/L {
- 	/n exch def
-	newpath
-	normalize
-	moveto
-	2 1 n {pop normalize lineto} for
-	} bind def
-/Y {
-	L
-	closepath
-	} bind def
-	/x1 FMLOCAL
-	/x2 FMLOCAL
-	/y1 FMLOCAL
-	/y2 FMLOCAL
-	/rad FMLOCAL
-/R {
-	/y2 exch def
-	/x2 exch def
-	/y1 exch def
-	/x1 exch def
-	x1 y1
-	x2 y1
-	x2 y2
-	x1 y2
-	4 Y
-	} bind def
-/RR {
-	/rad exch def
-	normalize
-	/y2 exch def
-	/x2 exch def
-	normalize
-	/y1 exch def
-	/x1 exch def
-	newpath
-	x1 y1 rad add moveto
-	x1 y2 x2 y2 rad arcto
-	x2 y2 x2 y1 rad arcto
-	x2 y1 x1 y1 rad arcto
-	x1 y1 x1 y2 rad arcto
-	closepath
-	16 {pop} repeat
-	} bind def
-/C {
-	grestore
-	gsave
-	R
-	clip
-	} bind def
-	/FMpointsize FMLOCAL
-/F {
-	FMfonts exch get
-	FMpointsize scalefont
-	setfont
-	} bind def
-/Q {
-	/FMpointsize exch def
-	F
-	} bind def
-/T {
-	moveto show
-	} bind def
-/RF {
-	rotate
-	0 ne {-1 1 scale} if
-	} bind def
-/TF {
-	gsave
-	moveto
-	RF
-	show
-	grestore
-	} bind def
-/P {
-	moveto
-	0 32 3 2 roll widthshow
-	} bind def
-/PF {
-	gsave
-	moveto
-	RF
-	0 32 3 2 roll widthshow
-	grestore
-	} bind def
-/S {
-	moveto
-	0 exch ashow
-	} bind def
-/SF {
-	gsave
-	moveto
-	RF
-	0 exch ashow
-	grestore
-	} bind def
-/B {
-	moveto
-	0 32 4 2 roll 0 exch awidthshow
-	} bind def
-/BF {
-	gsave
-	moveto
-	RF
-	0 32 4 2 roll 0 exch awidthshow
-	grestore
-	} bind def
-/G {
-	gsave
-	newpath
-	normalize translate 0.0 0.0 moveto
-	dnormalize scale
-	0.0 0.0 1.0 5 3 roll arc
-	closepath fill
-	grestore
-	} bind def
-/A {
-	gsave
-	savematrix
-	newpath
-	2 index 2 div add exch 3 index 2 div sub exch
-	normalize 2 index 2 div sub exch 3 index 2 div add exch
-	translate
-	scale
-	0.0 0.0 1.0 5 3 roll arc
-	restorematrix
-	stroke
-	grestore
-	} bind def
-	/x FMLOCAL
-	/y FMLOCAL
-	/w FMLOCAL
-	/h FMLOCAL
-	/xx FMLOCAL
-	/yy FMLOCAL
-	/ww FMLOCAL
-	/hh FMLOCAL
-	/FMsaveobject FMLOCAL
-	/FMoptop FMLOCAL
-	/FMdicttop FMLOCAL
-/BEGINPRINTCODE {
-	/FMdicttop countdictstack 1 add def
-	/FMoptop count 4 sub def
-	/FMsaveobject save def
-	userdict begin
-	/showpage {} def
-	FMNORMALIZEGRAPHICS
-	3 index neg 3 index neg translate
-	} bind def
-/ENDPRINTCODE {
-	count -1 FMoptop {pop pop} for
-	countdictstack -1 FMdicttop {pop end} for
-	FMsaveobject restore
-	} bind def
-/gn {
-	0
-	{	46 mul
-		cf read pop
-		32 sub
-		dup 46 lt {exit} if
-		46 sub add
-		} loop
-	add
-	} bind def
-	/str FMLOCAL
-/cfs {
-	/str sl string def
-	0 1 sl 1 sub {str exch val put} for
-	str def
-	} bind def
-/ic [
-	0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0223
-	0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0223
-	0
-	{0 hx} {1 hx} {2 hx} {3 hx} {4 hx} {5 hx} {6 hx} {7 hx} {8 hx} {9 hx}
-	{10 hx} {11 hx} {12 hx} {13 hx} {14 hx} {15 hx} {16 hx} {17 hx} {18 hx}
-	{19 hx} {gn hx} {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12}
-	{13} {14} {15} {16} {17} {18} {19} {gn} {0 wh} {1 wh} {2 wh} {3 wh}
-	{4 wh} {5 wh} {6 wh} {7 wh} {8 wh} {9 wh} {10 wh} {11 wh} {12 wh}
-	{13 wh} {14 wh} {gn wh} {0 bl} {1 bl} {2 bl} {3 bl} {4 bl} {5 bl} {6 bl}
-	{7 bl} {8 bl} {9 bl} {10 bl} {11 bl} {12 bl} {13 bl} {14 bl} {gn bl}
-	{0 fl} {1 fl} {2 fl} {3 fl} {4 fl} {5 fl} {6 fl} {7 fl} {8 fl} {9 fl}
-	{10 fl} {11 fl} {12 fl} {13 fl} {14 fl} {gn fl}
-	] def
-	/sl FMLOCAL
-	/val FMLOCAL
-	/ws FMLOCAL
-	/im FMLOCAL
-	/bs FMLOCAL
-	/cs FMLOCAL
-	/len FMLOCAL
-	/pos FMLOCAL
-/ms {
-	/sl exch def
-	/val 255 def
-	/ws cfs
-	/im cfs
-	/val 0 def
-	/bs cfs
-	/cs cfs
-	} bind def
-400 ms
-/ip {
-	is
-	0
-	cf cs readline pop
-	{	ic exch get exec
-		add
-		} forall
-	pop
-
-	} bind def
-/wh {
-	/len exch def
-	/pos exch def
-	ws 0 len getinterval im pos len getinterval copy pop
-	pos len
-	} bind def
-/bl {
-	/len exch def
-	/pos exch def
-	bs 0 len getinterval im pos len getinterval copy pop
-	pos len
-	} bind def
-/s1 1 string def
-/fl {
-	/len exch def
-	/pos exch def
-	/val cf s1 readhexstring pop 0 get def
-	pos 1 pos len add 1 sub {im exch val put} for
-	pos len
-	} bind def
-/hx {
-	3 copy getinterval
-	cf exch readhexstring pop pop
-	} bind def
-	/h FMLOCAL
-	/w FMLOCAL
-	/d FMLOCAL
-	/lb FMLOCAL
-	/bitmapsave FMLOCAL
-	/is FMLOCAL
-	/cf FMLOCAL
-/wbytes {
-	dup
-	8 eq {pop} {1 eq {7 add 8 idiv} {3 add 4 idiv} ifelse} ifelse
-	} bind def
-/BEGINBITMAPBWc {
-	1 {} COMMONBITMAPc
-	} bind def
-/BEGINBITMAPGRAYc {
-	8 {} COMMONBITMAPc
-	} bind def
-/BEGINBITMAP2BITc {
-	2 {} COMMONBITMAPc
-	} bind def
-/COMMONBITMAPc {
-	/r exch def
-	/d exch def
-	gsave
-	translate rotate scale /h exch def /w exch def
-	/lb w d wbytes def
-	sl lb lt {lb ms} if
-	/bitmapsave save def
-	r
-	/is im 0 lb getinterval def
-	ws 0 lb getinterval is copy pop
-	/cf currentfile def
-	w h d [w 0 0 h neg 0 h]
-	{ip} image
-	bitmapsave restore
-	grestore
-	} bind def
-/BEGINBITMAPBW {
-	1 {} COMMONBITMAP
-	} bind def
-/BEGINBITMAPGRAY {
-	8 {} COMMONBITMAP
-	} bind def
-/BEGINBITMAP2BIT {
-	2 {} COMMONBITMAP
-	} bind def
-/COMMONBITMAP {
-	/r exch def
-	/d exch def
-	gsave
-	translate rotate scale /h exch def /w exch def
-	/bitmapsave save def
-	r
-	/is w d wbytes string def
-	/cf currentfile def
-	w h d [w 0 0 h neg 0 h]
-	{cf is readhexstring pop} image
-	bitmapsave restore
-	grestore
-	} bind def
-	/proc1 FMLOCAL
-	/proc2 FMLOCAL
-	/newproc FMLOCAL
-/Fmcc {
-    /proc2 exch cvlit def
-    /proc1 exch cvlit def
-    /newproc proc1 length proc2 length add array def
-    newproc 0 proc1 putinterval
-    newproc proc1 length proc2 putinterval
-    newproc cvx
-} bind def
-/ngrayt 256 array def
-/nredt 256 array def
-/nbluet 256 array def
-/ngreent 256 array def
-	/gryt FMLOCAL
-	/blut FMLOCAL
-	/grnt FMLOCAL
-	/redt FMLOCAL
-	/indx FMLOCAL
-	/cynu FMLOCAL
-	/magu FMLOCAL
-	/yelu FMLOCAL
-	/k FMLOCAL
-	/u FMLOCAL
-/colorsetup {
-	currentcolortransfer
-	/gryt exch def
-	/blut exch def
-	/grnt exch def
-	/redt exch def
-	0 1 255 {
-		/indx exch def
-		/cynu 1 red indx get 255 div sub def
-		/magu 1 green indx get 255 div sub def
-		/yelu 1 blue indx get 255 div sub def
-		/k cynu magu min yelu min def
-		/u k currentundercolorremoval exec def
-		nredt indx 1 0 cynu u sub max sub redt exec put
-		ngreent indx 1 0 magu u sub max sub grnt exec put
-		nbluet indx 1 0 yelu u sub max sub blut exec put
-		ngrayt indx 1 k currentblackgeneration exec sub gryt exec put
-	} for
-	{255 mul cvi nredt exch get}
-	{255 mul cvi ngreent exch get}
-	{255 mul cvi nbluet exch get}
-	{255 mul cvi ngrayt exch get}
-	setcolortransfer
-	{pop 0} setundercolorremoval
-	{} setblackgeneration
-	} bind def
-	/tran FMLOCAL
-/fakecolorsetup {
-	/tran 256 string def
-	0 1 255 {/indx exch def
-		tran indx
-		red indx get 77 mul
-		green indx get 151 mul
-		blue indx get 28 mul
-		add add 256 idiv put} for
-	currenttransfer
-	{255 mul cvi tran exch get 255.0 div}
-	exch Fmcc settransfer
-} bind def
-/BITMAPCOLOR {
-	/d 8 def
-	gsave
-	translate rotate scale /h exch def /w exch def
-	/bitmapsave save def
-	colorsetup
-	/is w d wbytes string def
-	/cf currentfile def
-	w h d [w 0 0 h neg 0 h]
-	{cf is readhexstring pop} {is} {is} true 3 colorimage
-	bitmapsave restore
-	grestore
-	} bind def
-/BITMAPCOLORc {
-	/d 8 def
-	gsave
-	translate rotate scale /h exch def /w exch def
-	/lb w d wbytes def
-	sl lb lt {lb ms} if
-	/bitmapsave save def
-	colorsetup
-	/is im 0 lb getinterval def
-	ws 0 lb getinterval is copy pop
-	/cf currentfile def
-	w h d [w 0 0 h neg 0 h]
-	{ip} {is} {is} true 3 colorimage
-	bitmapsave restore
-	grestore
-	} bind def
-/BITMAPTRUECOLORc {
-        gsave
-        translate rotate scale /h exch def /w exch def
-        /bitmapsave save def
-
-        /is w string def
-
-        ws 0 w getinterval is copy pop
-        /cf currentfile def
-        w h 8 [w 0 0 h neg 0 h]
-        {ip} {gip} {bip} true 3 colorimage
-        bitmapsave restore
-        grestore
-        } bind def
-/BITMAPTRUECOLOR {
-        gsave
-        translate rotate scale /h exch def /w exch def
-        /bitmapsave save def
-        /is w string def
-        /gis w string def
-        /bis w string def
-        /cf currentfile def
-        w h 8 [w 0 0 h neg 0 h]
-        { cf is readhexstring pop }
-        { cf gis readhexstring pop }
-        { cf bis readhexstring pop }
-        true 3 colorimage
-        bitmapsave restore
-        grestore
-        } bind def
-/BITMAPTRUEGRAYc {
-        gsave
-        translate rotate scale /h exch def /w exch def
-        /bitmapsave save def
-
-        /is w string def
-
-        ws 0 w getinterval is copy pop
-        /cf currentfile def
-        w h 8 [w 0 0 h neg 0 h]
-        {ip gip bip w gray} image
-        bitmapsave restore
-        grestore
-        } bind def
-/ww FMLOCAL
-/r FMLOCAL
-/g FMLOCAL
-/b FMLOCAL
-/i FMLOCAL
-/gray {
-        /ww exch def
-        /b exch def
-        /g exch def
-        /r exch def
-        0 1 ww 1 sub { /i exch def r i get .299 mul g i get .587 mul
-			b i get .114 mul add add r i 3 -1 roll floor cvi put } for
-        r
-        } bind def
-/BITMAPTRUEGRAY {
-        gsave
-        translate rotate scale /h exch def /w exch def
-        /bitmapsave save def
-        /is w string def
-        /gis w string def
-        /bis w string def
-        /cf currentfile def
-        w h 8 [w 0 0 h neg 0 h]
-        { cf is readhexstring pop
-          cf gis readhexstring pop
-          cf bis readhexstring pop w gray}  image
-        bitmapsave restore
-        grestore
-        } bind def
-/BITMAPGRAY {
-	8 {fakecolorsetup} COMMONBITMAP
-	} bind def
-/BITMAPGRAYc {
-	8 {fakecolorsetup} COMMONBITMAPc
-	} bind def
-/ENDBITMAP {
-	} bind def
-end
-	/ALDsave FMLOCAL
-	/ALDmatrix matrix def ALDmatrix currentmatrix pop
-/StartALD {
-	/ALDsave save def
-	 savematrix
-	 ALDmatrix setmatrix
-	} bind def
-/InALD {
-	 restorematrix
-	} bind def
-/DoneALD {
-	 ALDsave restore
-	} bind def
-%%EndProlog
-%%BeginSetup
-(3.0) FMVERSION
-1 1 612 792 0 1 13 FMDOCUMENT
-0 0 /Helvetica-Bold FMFONTDEFINE
-1 0 /Times-Bold FMFONTDEFINE
-2 0 /Times-Italic FMFONTDEFINE
-3 0 /Times-Roman FMFONTDEFINE
-4 0 /Helvetica FMFONTDEFINE
-5 0 /Courier FMFONTDEFINE
-6 0 /Courier-Oblique FMFONTDEFINE
-32 FMFILLS
-0 0 FMFILL
-1 0.1 FMFILL
-2 0.3 FMFILL
-3 0.5 FMFILL
-4 0.7 FMFILL
-5 0.9 FMFILL
-6 0.97 FMFILL
-7 1 FMFILL
-8 <0f1e3c78f0e1c387> FMFILL
-9 <0f87c3e1f0783c1e> FMFILL
-10 <cccccccccccccccc> FMFILL
-11 <ffff0000ffff0000> FMFILL
-12 <8142241818244281> FMFILL
-13 <03060c183060c081> FMFILL
-14 <8040201008040201> FMFILL
-16 1 FMFILL
-17 0.9 FMFILL
-18 0.7 FMFILL
-19 0.5 FMFILL
-20 0.3 FMFILL
-21 0.1 FMFILL
-22 0.03 FMFILL
-23 0 FMFILL
-24 <f0e1c3870f1e3c78> FMFILL
-25 <f0783c1e0f87c3e1> FMFILL
-26 <3333333333333333> FMFILL
-27 <0000ffff0000ffff> FMFILL
-28 <7ebddbe7e7dbbd7e> FMFILL
-29 <fcf9f3e7cf9f3f7e> FMFILL
-30 <7fbfdfeff7fbfdfe> FMFILL
-%%EndSetup
-%%Page: "1" 1
-%%BeginPaperSize: Letter
-%%EndPaperSize
-612 792 0 FMBEGINPAGE
-98.1 675 512.1 675 2 L
-7 X
-0 K
-V
-2 H
-0 Z
-0 X
-N
-98.1 450 512.1 450 2 L
-7 X
-V
-2 Z
-0 X
-N
-98.1 108 512.1 126 R
-7 X
-V
-0 10 Q
-0 X
-(1) 506.54 119.33 T
-1 24 Q
--0.48 (Tk4.0 Overview and Porting Guide) 152.1 605 S
-2 12 Q
-(John Ouster) 152.1 563 T
-(hout) 210.84 563 T
-98.1 135 512.1 423 R
-7 X
-V
-3 10 Q
-0 X
-(Tk version 4.0 is a major new release with many improvements, new features, and bug) 152.1 416.33 T
-(\336xes. This document provides an introduction to the new features and describes the most) 152.1 404.33 T
--0.18 (common problems you are likely to encounter when porting scripts from Tk 3.6, the previ-) 152.1 392.33 P
-(ous release. This is) 152.1 380.33 T
-2 F
-(not) 230.66 380.33 T
-3 F
-( an introduction to Tk: I assume that you are already familiar with) 243.43 380.33 T
-(Tk 3.6 as described in the book) 152.1 368.33 T
-2 F
-(T) 279.79 368.33 T
-(cl and the Tk T) 284.43 368.33 T
-(oolkit) 343.48 368.33 T
-3 F
-(.) 366.24 368.33 T
--0.26 (The good news about Tk 4.0 is that it has many improvements over Tk 3.6. Here are a) 170.1 356.33 P
-(few of the most important new features:) 152.1 344.33 T
-3 12 Q
-(\245) 152.1 329.33 T
-3 10 Q
-(Tk 4.0 includes a general-purpose mechanism for manipulating color images \050Tk 3.6) 162.9 329.33 T
-(supports only monochrome images\051.) 162.9 317.33 T
-3 12 Q
-(\245) 152.1 302.33 T
-3 10 Q
--0.17 (The text widget in Tk 4.0 includes many new features such as tab stops, embedded win-) 162.9 302.33 P
-(dows, horizontal scrolling, and many new formatting options.) 162.9 290.33 T
-3 12 Q
-(\245) 152.1 275.33 T
-3 10 Q
-(The binding mechanism in Tk 4.0 is much more powerful in Tk 3.6.) 162.9 275.33 T
-3 12 Q
-(\245) 152.1 260.33 T
-3 10 Q
-(Motif compliance is much better) 162.9 260.33 T
-(. For example, there is now support for keyboard tra-) 292.82 260.33 T
-(versal and focus highlights.) 162.9 248.33 T
-3 12 Q
-(\245) 152.1 233.33 T
-3 10 Q
-(Many widgets have been improved. For example, buttons and labels can display multi-) 162.9 233.33 T
-(line justi\336ed text, and scales can handle real values.) 162.9 221.33 T
-(The bad news about Tk 4.0 is that it contains several incompatibilities with Tk 3.6.) 170.1 206.33 T
-(Ever since the \336rst release of Tk I have assumed that there would eventually be a major) 152.1 194.33 T
-(new release of Tk with substantial incompatibilities. I knew that I wouldn\325) 152.1 182.33 T
-(t be able to get) 450.06 182.33 T
-(all of the features of Tk right the \336rst time; rather than live forever with all of my early) 152.1 170.33 T
-(mistakes, I wanted to have a chance to correct them. Tk 4.0 is that correction. I apologize) 152.1 158.33 T
--0.05 (for the incompatibilities, but I hope they improve Tk enough to justify the dif) 152.1 146.33 P
--0.05 (\336culties you) 460.55 146.33 P
-44.1 351 98.1 423 C
-35.1 360 197.1 414 R
-7 X
-0 K
-V
-1 9 Q
-0 X
-(FIGURE  1) 35.1 408 T
-(T) 35.1 387 T
-(ABLE  1) 40.43 387 T
-26.1 351 125.1 423 R
-7 X
-V
-40.5 63 571.5 729 C
-FMENDPAGE
-%%EndPage: "1" 2
-%%Page: "2" 2
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(2) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
-(encounter during porting. Tk 4.0 is a one-time correction: we will try very hard to avoid) 152.1 632.33 T
-(substantial incompatibilities \050especially in Tk\325) 152.1 620.3 T
-(s T) 337 620.3 T
-(cl-level interfaces\051 in future releases.) 348.79 620.3 T
--0.4 (Sections 1-1) 170.1 608.3 P
--0.4 (1 cover the major areas of change in Tk 4.0: bindings, focus, text widgets,) 219.02 608.3 P
--0 (Motif compliance, other widget changes, images, color management, event handling, sup-) 152.1 596.26 P
-(port for multiple displays, the) 152.1 584.23 T
-5 F
-(send) 273.14 584.23 T
-3 F
-( command, and the selection. Section 12 summarizes) 297.13 584.23 T
-(several smaller changes. Section 13 lists all of the incompatibilities that af) 152.1 572.19 T
-(fect T) 448.4 572.19 T
-(cl scripts,) 471.29 572.19 T
--0.02 (along with suggestions for how to deal with them. The explanations here are not intended) 152.1 560.16 P
-(to be comprehensive, but rather to introduce you to the issues; for complete information) 152.1 548.12 T
-(on new or modi\336ed commands, refer to the reference documentation that comes with the) 152.1 536.09 T
-(distribution.) 152.1 524.05 T
-98.1 480.7 512.1 483.72 C
-152.1 481.92 512.1 481.92 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 482.21 143.1 482.21 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(1) 134.63 487.72 T
-(Bindings) 152.1 487.72 T
-3 10 Q
--0.35 (The changes for Tk 4.0 that are most likely to af) 152.1 464.03 P
--0.35 (fect existing T) 341.31 464.03 P
--0.35 (cl scripts are those related to) 397.64 464.03 P
-(bindings. The new binding mechanism in Tk 4.0 is much more powerful than that of Tk) 152.1 452 T
-(3.6, particularly in the way it allows behaviors to be combined, but several incompatible) 152.1 439.96 T
-(changes were required to implement the new features. These changes are likely to break) 152.1 427.93 T
-(most Tk 3.6 scripts. Fortunately) 152.1 415.89 T
-(, it is relatively easy to upgrade your bindings to work) 279.16 415.89 T
-(under Tk 4.0.) 152.1 403.86 T
--0.27 (The basic mechanism for bindings is the same as in Tk 3.6. A binding associates a T) 170.1 391.86 P
--0.27 (cl) 502.65 391.86 P
-(script with a particular event \050or sequence of events\051 occurring in one or more windows;) 152.1 379.82 T
--0.11 (the script will be invoked automatically whenever the event sequence occurs in any of the) 152.1 367.79 P
--0.13 (speci\336ed windows. The Tk 4.0 binding mechanism has three major feature changes. First,) 152.1 355.75 P
-(there is a more general mechanism for specifying the relationship between windows and) 152.1 343.72 T
-(bindings, called) 152.1 331.68 T
-2 F
-(binding tags) 217.89 331.68 T
-3 F
-(. Second, the con\337ict resolution mechanism \050which is) 267.6 331.68 T
-(invoked when more than one binding matches an event\051 has been changed to allow more) 152.1 319.65 T
-(than one binding script to execute for a single event. Third, the) 152.1 307.61 T
-5 F
-(Any) 405.81 307.61 T
-3 F
-( modi\336er is now) 423.8 307.61 T
-(implicit in all binding patterns. These changes are discussed separately in the subsections) 152.1 295.58 T
-(that follow) 152.1 283.54 T
-(.) 195.04 283.54 T
--0.16 (Overall, the main ef) 170.1 271.54 P
--0.16 (fect of Tk 4.0\325) 249.37 271.54 P
--0.16 (s binding changes is that it allows more bindings to) 306.06 271.54 P
-(trigger than Tk 3.6 does. Feedback from the T) 152.1 259.51 T
-(cl/Tk community about the Tk 3.6 binding) 335.71 259.51 T
-(mechanism indicated that it was too conservative about triggering bindings. This caused) 152.1 247.47 T
-(the system to lose behaviors relatively easily and made the binding structure fragile. It) 152.1 235.44 T
--0.35 (appears to be easier to deal with too many binding invocations than too few) 152.1 223.4 P
--0.35 (, so Tk 4.0 tries) 449.17 223.4 P
-(to err in this direction.) 152.1 211.37 T
-0 F
-(1.1) 127.41 181.37 T
-(Binding tags) 152.1 181.37 T
-3 F
-(In Tk 3.6 you specify the window\050s\051 for a binding in one of three ways:) 152.1 165.37 T
-3 12 Q
-(\245) 152.1 150.37 T
-3 10 Q
-(Y) 162.9 150.37 T
-(ou give the name of a window) 169.12 150.37 T
-(, such as) 289.49 150.37 T
-5 F
-(.a.b.c) 326.13 150.37 T
-3 F
-(, in which case the binding applies) 362.11 150.37 T
-(only to that window) 162.9 138.33 T
-(.) 242.49 138.33 T
-FMENDPAGE
-%%EndPage: "2" 3
-%%Page: "3" 3
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(1 Bindings) 98.1 668.33 T
-0 F
-(3) 506.54 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 12 Q
-0 X
-(\245) 152.1 632.33 T
-3 10 Q
--0.06 (Y) 162.9 632.33 P
--0.06 (ou give the name of a class, such as) 169.12 632.33 P
-5 F
--0.15 (Button) 313.45 632.33 P
-3 F
--0.06 (, in which case the binding applies to all) 349.43 632.33 P
-(the windows of that class.) 162.9 620.33 T
-3 12 Q
-(\245) 152.1 605.33 T
-3 10 Q
-(Y) 162.9 605.33 T
-(ou specify) 169.12 605.33 T
-5 F
-(all) 212.97 605.33 T
-3 F
-(, in which case the binding applies to all windows.) 230.96 605.33 T
--0.3 (In Tk4.0 you specify the window\050s\051 using a more general mechanism called a) 170.1 590.33 P
-2 F
--0.3 (binding) 479.35 590.33 P
-(tag) 152.1 578.33 T
-3 F
-(. A binding tag may be an arbitrary string, but if it starts with a \322.\323 then it must be the) 164.87 578.33 T
-(name of a window) 152.1 566.33 T
-(. If you specify a class name or) 225.56 566.33 T
-5 F
-(all) 352.4 566.33 T
-3 F
-( as a binding tag, it will usually) 370.39 566.33 T
--0.1 (have the same ef) 152.1 554.33 P
--0.1 (fect as in Tk 3.6, but you may also specify other strings that were not per-) 218.51 554.33 P
-(mitted in Tk 3.6.) 152.1 542.33 T
--0.07 (Each window in Tk 4.0 has a list of binding tags. When an event occurs in a window) 170.1 530.33 P
--0.07 (,) 507.17 530.33 P
--0.19 (Tk fetches the window\325) 152.1 518.33 P
--0.19 (s binding tags and matches the event against all of the bindings for) 245.62 518.33 P
--0.09 (any of the tags. By default, the binding tags for a window consist of the window name, its) 152.1 506.33 P
--0.14 (class name, the name of its nearest toplevel ancestor) 152.1 494.33 P
--0.14 (, and) 359.61 494.33 P
-5 F
--0.33 (all) 381.26 494.33 P
-3 F
--0.14 (. For example, a button win-) 399.25 494.33 P
-(dow named) 152.1 482.33 T
-5 F
-(.b) 200.95 482.33 T
-3 F
-( will have the tags) 212.95 482.33 T
-5 9 Q
-(.b Button . all) 179.1 468 T
-3 10 Q
-(by default and all of the following bindings will apply to the window:) 152.1 454.33 T
-5 9 Q
-(bind .b <Enter> {identify "press here to exit"}) 179.1 440 T
-(bind Button <Button-Release-1> {%W invoke}) 179.1 430 T
-(bind all <Help> {help %W}) 179.1 420 T
-3 10 Q
-(So far) 152.1 406.33 T
-(, this mechanism produces the same behavior as in Tk 3.6 except that bindings cre-) 175.85 406.33 T
-(ated for a toplevel also apply to its descendants \050see Section 1.5 for more on this issue\051.) 152.1 394.33 T
-(Y) 170.1 382.33 T
-(ou can use the) 176.32 382.33 T
-5 F
-(bindtags) 235.71 382.33 T
-3 F
-( command to change the binding tags for a window or) 283.69 382.33 T
-(their order) 152.1 370.33 T
-(. For example, the command) 193.46 370.33 T
-5 9 Q
-(bindtags .b {.b MyButton all}) 179.1 356 T
-3 10 Q
-(will change the binding tags for) 152.1 342.33 T
-5 F
-(.b) 281.46 342.33 T
-3 F
-( to the three values in the list. This provides a simple) 293.45 342.33 T
-(way to make radical changes the behavior of a window) 152.1 330.33 T
-(. After the above command is) 371.55 330.33 T
-(invoked none of the) 152.1 318.33 T
-5 F
-(Button) 234.26 318.33 T
-3 F
-( class bindings will apply to) 270.24 318.33 T
-5 F
-(.b) 384.63 318.33 T
-3 F
-(. Instead, bindings for) 396.63 318.33 T
-5 F
--0.81 (MyButton) 152.1 306.33 P
-3 F
--0.34 ( will apply; this might give the button a totally dif) 200.07 306.33 P
--0.34 (ferent set of behaviors than a) 395.88 306.33 P
-(normal button. In addition, the) 152.1 294.33 T
-5 F
-(bindtags) 276.75 294.33 T
-3 F
-( command removes the \322.\323 tag, so bindings on) 324.72 294.33 T
-(\322.\323 will not apply to) 152.1 282.33 T
-5 F
-(.b) 234.27 282.33 T
-3 F
-(.) 246.27 282.33 T
-(Y) 170.1 270.33 T
-(ou can also place additional tags on a window with the) 176.32 270.33 T
-5 F
-(bindtags) 397.55 270.33 T
-3 F
-( command to) 445.53 270.33 T
-(combine a number of behaviors. For example,) 152.1 258.33 T
-5 9 Q
-(bindtags .b {.b MyButton Button . all}) 179.1 244 T
-3 10 Q
-(gives) 152.1 230.33 T
-5 F
-(.b) 175.7 230.33 T
-3 F
-( the behaviors of) 187.69 230.33 T
-5 F
-(MyButton) 257.08 230.33 T
-3 F
-( bindings as well as those speci\336ed by) 305.06 230.33 T
-5 F
-(Button) 459.96 230.33 T
-3 F
-(bindings.) 152.1 218.33 T
-(Overall, binding tags are similar to the tag mechanisms already used internally by) 170.1 206.33 T
-(canvas and text widgets in Tk 3.6, except that binding tags apply to windows instead of) 152.1 194.33 T
-(graphical objects or textual characters.) 152.1 182.33 T
-FMENDPAGE
-%%EndPage: "3" 4
-%%Page: "4" 4
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(4) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-0 F
-0 X
-(1.2) 127.41 632.33 T
-(Con\337ict resolution) 152.1 632.33 T
-3 F
-(It is possible for several bindings to match a particular event. In Tk 3.6 at most one event) 152.1 616.33 T
-(is actually allowed to trigger: a set of con\337ict resolution rules determines the winner) 152.1 604.22 T
-(. In) 488.27 604.22 T
-(general, a more speci\336c binding takes precedence over a less speci\336c binding. For exam-) 152.1 592.11 T
--0.27 (ple, any binding for a speci\336c widget takes precedence over any class or) 152.1 580 P
-5 F
--0.66 (all) 439.96 580 P
-3 F
--0.27 ( binding, and) 457.95 580 P
-(a binding on) 152.1 567.89 T
-5 F
-(<Control-a>) 204.57 567.89 T
-3 F
-( takes precedence over a binding on) 270.54 567.89 T
-5 F
-(<Key>.) 416.24 567.89 T
-3 F
--0.26 (The mechanism for con\337ict resolution is similar in Tk 4.0 except that one binding can) 170.1 555.89 P
--0.35 (trigger for) 152.1 543.78 P
-2 F
--0.35 (each) 194.7 543.78 P
-3 F
--0.35 ( binding tag on the window where the event occurs. The bindings trigger in) 213.57 543.78 P
-(the order of the tags. Thus if button) 152.1 531.67 T
-5 F
-(.b) 296.17 531.67 T
-3 F
-( has the default binding tags, one binding for) 308.16 531.67 T
-5 F
-(.b) 489.71 531.67 T
-3 F
-(can trigger) 152.1 519.56 T
-(, followed by one for) 194.72 519.56 T
-5 F
-(Button) 281.32 519.56 T
-3 F
-(, followed by one for \322) 317.3 519.56 T
-5 F
-(.) 408.34 519.56 T
-3 F
-(\323, followed by one for) 414.34 519.56 T
-5 F
-(all) 152.1 507.44 T
-3 F
-(. If there are no matching bindings for a given tag then none will trigger) 170.09 507.44 T
-(, and if there) 456.98 507.44 T
-(are several matching bindings for a given tag then a single one is chosen using the same) 152.1 495.33 T
-(rules as in Tk 3.6.) 152.1 483.22 T
-(The philosophy behind binding tags in Tk 4.0 is that each binding tag corresponds to) 170.1 471.22 T
-(an independent behavior) 152.1 459.11 T
-(, so bindings with dif) 249.96 459.11 T
-(ferent tags should usually be additive. Sup-) 334.46 459.11 T
-(pose you de\336ned the following binding:) 152.1 447 T
-5 9 Q
-(bind .b <Enter> {puts "press here to exit"}) 179.1 432.67 T
-3 10 Q
-(This binding will add to the behavior de\336ned by the Button class binding for) 152.1 419 T
-5 F
-(<Enter>) 460.81 419 T
-3 F
-(.) 502.79 419 T
-(In Tk 3.6, the widget-speci\336c binding will replace the class binding, which will break the) 152.1 406.89 T
-(behavior of the button so that it no longer has normal button behavior) 152.1 394.78 T
-(.) 429.71 394.78 T
-(Sometimes there need to be interactions between binding tags. For example, you) 170.1 382.78 T
-(might wish to keep most of the default button behavior for) 152.1 370.67 T
-5 F
-(.b) 388.34 370.67 T
-3 F
-( but replace the default) 400.33 370.67 T
-(behavior for) 152.1 358.56 T
-5 F
-(<ButtonRelease>) 203.72 358.56 T
-3 F
-( with some other behavior) 293.67 358.56 T
-(. T) 397.49 358.56 T
-(o allow bindings to be) 407.9 358.56 T
--0.17 (overridden, Tk 4.0 allows the) 152.1 346.44 P
-5 F
--0.41 (break) 271.44 346.44 P
-3 F
--0.17 ( command to be invoked from inside a binding. This) 301.43 346.44 P
-(causes all remaining binding tags for that binding to be skipped. Consider the following) 152.1 334.33 T
-(binding:) 152.1 322.22 T
-5 9 Q
-(bind .b <ButtonRelease-1> {myRelease .b; break}) 179.1 307.89 T
-3 10 Q
--0.21 (This will cause the) 152.1 294.22 P
-5 F
--0.5 (myRelease) 228.99 294.22 P
-3 F
--0.21 ( procedure to be invoked, then the) 282.96 294.22 P
-5 F
--0.5 (break) 420.28 294.22 P
-3 F
--0.21 ( command will) 450.26 294.22 P
--0.37 (cause the class binding for the event to be skipped \050assuming that the widget name appears) 152.1 282.11 P
-(before its class in the binding tags for) 152.1 270 T
-5 F
-(.b) 304.78 270 T
-3 F
-(\051, along with any bindings for other tags.) 316.77 270 T
-2 F
-(Note:) 119.09 254 T
--0.07 (Y) 152.1 254 P
--0.07 (ou cannot invoke) 156.74 254 P
-6 F
--0.17 (break) 227.31 254 P
-2 F
--0.07 ( fr) 257.29 254 P
--0.07 (om within the) 266.02 254 P
-6 F
--0.17 (myRelease) 322.73 254 P
-2 F
--0.07 ( pr) 376.7 254 P
--0.07 (ocedur) 387.64 254 P
--0.07 (e in the above example:) 415.03 254 P
--0.02 (this will generate a T) 152.1 242.89 P
--0.02 (cl err) 236.05 242.89 P
--0.02 (or) 257.59 242.89 P
--0.02 (. However) 265.37 242.89 P
--0.02 (, you can invoke the command \322) 305.31 242.89 P
-6 F
--0.05 (return -code) 434.25 242.89 P
-(break) 152.1 231.78 T
-2 F
-(\323 in the pr) 182.08 231.78 T
-(ocedur) 223.64 231.78 T
-(e to achieve the same effect as the) 251.03 231.78 T
-6 F
-(break) 389.25 231.78 T
-2 F
-( in the binding script.) 419.23 231.78 T
-0 F
-(1.3) 127.41 202.78 T
-(Implicit Any) 152.1 202.78 T
-3 F
--0.13 (In Tk 3.6 extraneous modi\336ers prevent a binding from matching an event. For example, if) 152.1 186.78 P
-(a binding is de\336ned for) 152.1 174.67 T
-5 F
-(<Button-1>) 247.32 174.67 T
-3 F
-( and the mouse button is pressed with the) 307.29 174.67 T
-5 F
-(Num-) 474.68 174.67 T
-(Lock) 152.1 162.56 T
-3 F
-( key down, then the binding will not match. If you want a binding to trigger even) 176.09 162.56 T
-(when extraneous modi\336ers are present, you must specify the) 152.1 150.45 T
-5 F
-(Any) 396.37 150.45 T
-3 F
-( modi\336er) 414.36 150.45 T
-(, as in) 450.33 150.45 T
-5 F
-(<Any-) 476.42 150.45 T
-(Button-1>) 152.1 138.33 T
-3 F
-(.) 206.07 138.33 T
-FMENDPAGE
-%%EndPage: "4" 5
-%%Page: "5" 5
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(1 Bindings) 98.1 668.33 T
-0 F
-(5) 506.54 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
--0.06 (In Tk 4.0, all bindings have the) 170.1 632.33 P
-5 F
--0.15 (Any) 297.08 632.33 P
-3 F
--0.06 ( modi\336er present implicitly) 315.08 632.33 P
--0.06 (. The) 423.35 632.33 P
-5 F
--0.15 (Any) 446.26 632.33 P
-3 F
--0.06 ( modi\336er is) 464.25 632.33 P
-(still allowed for compatibility) 152.1 620.33 T
-(, but it has no meaning. Thus a binding for) 270.55 620.33 T
-5 F
-(<Button-1>) 443.23 620.33 T
-3 F
-(will match a button press event even if) 152.1 608.33 T
-5 F
-(NumLock) 309.21 608.33 T
-3 F
-(,) 351.19 608.33 T
-5 F
-(Shift) 356.19 608.33 T
-3 F
-(,) 386.17 608.33 T
-5 F
-(Control) 391.17 608.33 T
-3 F
-(, or any combina-) 433.15 608.33 T
-(tion of them. If you wish for a binding not to trigger when a modi\336er is present, you can) 152.1 596.33 T
-(just de\336ne an empty binding for that modi\336er combination. For example,) 152.1 584.33 T
-5 9 Q
-(bind .b <Control-Button-1> {# this script is a no-op}) 179.1 570 T
-3 10 Q
-(creates a binding that will trigger on mouse button presses when the) 152.1 556.33 T
-5 F
-(Control) 426.36 556.33 T
-3 F
-( key is) 468.34 556.33 T
--0.22 (down. If there is also a) 152.1 544.33 P
-5 F
--0.52 (<Button-1>) 244.35 544.33 P
-3 F
--0.22 ( binding for) 334.3 544.33 P
-5 F
--0.52 (.b) 383.35 544.33 P
-3 F
--0.22 (, it will no longer be invoked) 395.34 544.33 P
--0.02 (if the) 152.1 532.33 P
-5 F
--0.05 (Control) 175.37 532.33 P
-3 F
--0.02 ( key is down, due to the con\337ict resolution rules. The script for the above) 217.35 532.33 P
-(binding is just a T) 152.1 520.33 T
-(cl comment, so it has no ef) 223.59 520.33 T
-(fect when it is invoked. Alternatively) 330.84 520.33 T
-(, you) 478.98 520.33 T
-(could use) 152.1 508.33 T
-5 F
-(%s) 192.63 508.33 T
-3 F
-( in the binding script to extract the modi\336er state, then test to see that only) 204.62 508.33 T
-(desired modi\336ers are present.) 152.1 496.33 T
-0 F
-(1.4) 127.41 466.33 T
-(Porting problems: widget bindings vs. class bindings) 152.1 466.33 T
-3 F
--0.38 (Y) 152.1 450.33 P
--0.38 (ou are likely to encounter two problems with bindings when you port Tk 3.6 scripts to Tk) 158.32 450.33 P
--0.18 (4.0: widget bindings vs. class bindings, and events on top-level windows. This section dis-) 152.1 438.33 P
-(cusses the \336rst problem and the following section discusses the second problem.) 152.1 426.33 T
-(In Tk 3.6, if a widget-speci\336c binding matches an event then no class binding will) 170.1 414.33 T
--0.15 (trigger for the event; in Tk 4.0 both bindings will trigger) 152.1 402.33 P
--0.15 (. Because of this change, you will) 375.75 402.33 P
--0.09 (need to modify most of your widget-speci\336c bindings in one of two ways. If a widget-spe-) 152.1 390.33 P
-(ci\336c binding in Tk 3.6 was intended to supplement the class binding, this could only be) 152.1 378.33 T
-(done by duplicating the code of the class binding in the widget binding script. This dupli-) 152.1 366.33 T
--0.02 (cated code is no longer necessary in Tk 4.0 and will probably interfere with the new class) 152.1 354.33 P
-(bindings in Tk 4.0; you should remove the duplicated class code, leaving only the widget-) 152.1 342.33 T
-(speci\336c code in the binding script. If a widget-speci\336c binding in Tk 3.6 was intended to) 152.1 330.33 T
--0.17 (override the class binding, this will no longer occur by default in Tk 4.0; you should add a) 152.1 318.33 P
-5 F
--0.54 (break) 152.1 306.33 P
-3 F
--0.22 ( command at the end of the binding script to prevent the class binding from trigger-) 182.08 306.33 P
-(ing. If a widget binding in Tk 3.6 didn\325) 152.1 294.33 T
-(t con\337ict with a class binding, then you will not) 308.49 294.33 T
-(need to modify it for Tk 4.0. For example, a widget binding for) 152.1 282.33 T
-5 F
-(<Help>) 407.49 282.33 T
-3 F
-( in a text widget) 443.47 282.33 T
-(would not need to be modi\336ed, since it doesn\325) 152.1 270.33 T
-(t con\337ict with a class binding.) 336.53 270.33 T
-0 F
-(1.5) 127.41 240.33 T
-(Porting problems: events on top-levels) 152.1 240.33 T
-3 F
--0.26 (The second binding problem you are likely to encounter in porting Tk 3.6 scripts to Tk 4.0) 152.1 224.33 P
-(is that in Tk 4.0 a binding on a toplevel will match events on any of the internal windows) 152.1 212.33 T
-(within that top-level. For example, suppose you have a binding created as follows:) 152.1 200.33 T
-5 9 Q
-(toplevel .t) 179.1 186 T
-(button .t.b1 ...) 179.1 176 T
-(button .t.b2 ...) 179.1 166 T
-(bind .t <Enter> action) 179.1 156 T
-FMENDPAGE
-%%EndPage: "5" 6
-%%Page: "6" 6
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(6) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
--0.27 (This binding will trigger not only when the mouse enters) 152.1 632.33 P
-5 F
--0.64 (.t) 379.29 632.33 P
-3 F
--0.27 (, but also when it enters either) 391.28 632.33 P
-5 F
-(.t.b1) 152.1 620.33 T
-3 F
-( or) 182.08 620.33 T
-5 F
-(.t.b2) 195.41 620.33 T
-3 F
-(. This is because the binding tags for a window include its nearest) 225.39 620.33 T
-(ancestor toplevel by default. The toplevel is present in the binding tags to make it easy to) 152.1 608.33 T
-(set up accelerator keys that apply in all the windows of a panel. For example,) 152.1 596.33 T
-5 9 Q
-(bind .t <Control-a> {controlAProc %W}) 179.1 582 T
-3 10 Q
-(will cause) 152.1 568.33 T
-5 F
-(controlAProc) 194.85 568.33 T
-3 F
-( to be invoked whenever) 266.81 568.33 T
-5 F
-(Control-a) 367.56 568.33 T
-3 F
-( is typed in any of the) 421.53 568.33 T
--0.12 (windows in) 152.1 556.33 P
-5 F
--0.29 (.t) 200.72 556.33 P
-3 F
--0.12 (. The procedure will receive the name of the focus window as its ar) 212.71 556.33 P
--0.12 (gument.) 479.62 556.33 P
-(Unfortunately) 170.1 544.33 T
-(, if you have created bindings on toplevel windows in your Tk 3.6) 225.52 544.33 T
--0.16 (scripts, they probably expect to trigger only for events in the toplevel, so the bindings will) 152.1 532.33 P
-(misbehave under Tk 4.0. Fortunately you can reproduce the behavior of Tk 3.6 by using) 152.1 520.33 T
-(the) 152.1 508.33 T
-5 F
-(%W) 166.81 508.33 T
-3 F
-( substitution in the binding script. For example, to ensure that) 178.8 508.33 T
-5 F
-(action) 427.28 508.33 T
-3 F
-( is invoked) 463.26 508.33 T
-(only for) 152.1 496.33 T
-5 F
-(Enter) 186.52 496.33 T
-3 F
-( events in a toplevel window itself, create the following binding in place) 216.51 496.33 T
-(of the one above:) 152.1 484.33 T
-5 9 Q
-(bind .t <Enter> {) 179.1 470 T
-(if {"%W" == ".t"} {) 200.63 460 T
-(action) 222.23 450 T
-(}) 200.63 440 T
-(}) 179.1 430 T
-3 10 Q
--0.01 (When an) 152.1 416.33 P
-5 F
--0.03 (Enter) 190.38 416.33 P
-3 F
--0.01 ( event occurs in a descendant of) 220.36 416.33 P
-5 F
--0.03 (.t) 350.45 416.33 P
-3 F
--0.01 ( such as) 362.45 416.33 P
-5 F
--0.03 (.t.x) 396.56 416.33 P
-3 F
--0.01 (, a binding for) 420.54 416.33 P
-5 F
--0.03 (Enter) 479.63 416.33 P
-3 F
-(in) 152.1 404.33 T
-5 F
-(.t.x) 162.37 404.33 T
-3 F
-( will trigger \336rst, if there is one. Then the above binding will trigger) 186.36 404.33 T
-(. Since) 457.58 404.33 T
-5 F
-(%W) 487.29 404.33 T
-3 F
-(will be substituted with) 152.1 392.33 T
-5 F
-(.t.x) 248.17 392.33 T
-3 F
-(, the) 272.15 392.33 T
-5 F
-(if) 291.86 392.33 T
-3 F
-( condition will not be satis\336ed and the binding will) 303.86 392.33 T
-(not do anything.) 152.1 380.33 T
--0.14 ( An alternative solution is to remove the toplevel window from the binding tags of all) 170.1 368.33 P
--0.12 (its internal windows. However) 152.1 356.33 P
--0.12 (, this means that you won\325) 274.03 356.33 P
--0.12 (t be able to take advantage of the) 378.73 356.33 P
-(tag to create key bindings that apply everywhere within the toplevel.) 152.1 344.33 T
-0 F
-(1.6) 127.41 314.33 T
-(Internal bindings in canvases and texts) 152.1 314.33 T
-3 F
-(The same changes in con\337ict resolution described in Section 1.2 also apply to bindings) 152.1 298.33 T
--0.05 (created internally for the items of a canvas or the tags of a text widget. If a canvas item or) 152.1 286.33 P
--0.29 (character of text has multiple tags, then one binding can trigger for each tag on each event.) 152.1 274.33 P
--0.32 (The bindings trigger in the priority order of the tags. Similar porting problems are likely to) 152.1 262.33 P
--0.19 (occur as described in Section 1.4; if a binding for one tag needs to override that of another) 152.1 250.33 P
-(tag, you\325ll need to add a) 152.1 238.33 T
-5 F
-(break) 251.2 238.33 T
-3 F
-( command under Tk 4.0; if a binding for one tag dupli-) 281.18 238.33 T
--0.28 (cated the code from another tag\325) 152.1 226.33 P
--0.28 (s binding, so that they will compose in Tk 3.6, you\325ll have) 279.76 226.33 P
-(to remove the duplicated code in Tk 4.0.) 152.1 214.33 T
-FMENDPAGE
-%%EndPage: "6" 7
-%%Page: "7" 7
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(2 Focus management) 98.1 668.33 T
-0 F
-(7) 506.54 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-98.1 623.98 512.1 627 C
-152.1 625.2 512.1 625.2 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 625.49 143.1 625.49 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(2) 134.63 631 T
-(Focus management) 152.1 631 T
-3 10 Q
-(The input focus is another area where Tk 4.0 contains major changes. Fortunately) 152.1 607.31 T
-(, the) 477.87 607.31 T
--0.09 (focus changes should not require as many modi\336cations to your Tk 3.6 scripts as the bind-) 152.1 595.31 P
-(ing changes.) 152.1 583.31 T
-0 F
-(2.1) 127.41 553.31 T
-(One focus window per toplevel) 152.1 553.31 T
-3 F
-(Tk 3.6 only keeps track of a single focus window for each application, and this results in) 152.1 537.31 T
-(two problems. First, it doesn\325) 152.1 525.31 T
-(t allow an application to use multiple displays since this) 269.64 525.31 T
--0.16 (could result in multiple simultaneous focus windows, one on each display) 152.1 513.31 P
--0.16 (. Second, the Tk) 444.99 513.31 P
-(3.6 model doesn\325) 152.1 501.31 T
-(t work very well for applications that have multiple toplevels: when the) 221.04 501.31 T
-(mouse moves from one toplevel to another) 152.1 489.31 T
-(, the focus window should switch to whatever) 322.7 489.31 T
--0.24 (window had the focus the last time the mouse was in the new toplevel, but Tk 3.6 does not) 152.1 477.31 P
-(remember this information.) 152.1 465.31 T
-(Tk 4.0 corrects both of these problems. It remembers one focus window for each) 170.1 453.31 T
-(toplevel, which can be queried with the) 152.1 441.31 T
-5 F
-(focus -lastfor) 311.98 441.31 T
-3 F
-( command. When the win-) 395.94 441.31 T
-(dow manager gives the focus to a toplevel window \050because the mouse entered the win-) 152.1 429.31 T
-(dow or because you clicked on the window) 152.1 417.31 T
-(, depending on the focus model being used by) 324.38 417.31 T
-(the window manager\051, Tk passes the focus on to the remembered window) 152.1 405.31 T
-(. Several win-) 446.23 405.31 T
-(dows in an application can have the focus at the same time, one on each display the appli-) 152.1 393.31 T
-(cation is using. When asking for the current focus window in the) 152.1 381.31 T
-5 F
-(focus) 413.31 381.31 T
-3 F
-( command, you) 443.29 381.31 T
-(can use the) 152.1 369.31 T
-5 F
-(-displayof) 199 369.31 T
-3 F
-( switch to specify a particular display) 258.97 369.31 T
-(.) 407.66 369.31 T
-(When you set the focus to a window with the) 170.1 357.31 T
-5 F
-(focus) 353.31 357.31 T
-3 F
-( command, Tk remembers that) 383.29 357.31 T
-(window as the most recent focus window for its toplevel. In addition, if the application) 152.1 345.31 T
-(currently has the focus for the window\325) 152.1 333.31 T
-(s display) 309.2 333.31 T
-(, Tk moves the focus to the speci\336ed win-) 343.82 333.31 T
--0.35 (dow; this can be used, for example to move the focus to a dialog when the dialog is posted,) 152.1 321.31 P
-(or to perform keyboard traversal among the toplevels of an application. If the application) 152.1 309.31 T
-(doesn\325) 152.1 297.31 T
-(t currently have the focus for the display) 178.57 297.31 T
-(, then Tk will not normally take the focus) 339.74 297.31 T
-(from its current owner) 152.1 285.31 T
-(. However) 241.2 285.31 T
-(, you can specify the) 282.43 285.31 T
-5 F
-(-force) 367.36 285.31 T
-3 F
-( ar) 403.34 285.31 T
-(gument to) 413.43 285.31 T
-5 F
-(focus) 456.18 285.31 T
-3 F
-( to) 486.17 285.31 T
-(insist that Tk grab the focus for this application \050in general this is probably not a good) 152.1 273.31 T
-(idea, since it may clash with the window manager) 152.1 261.31 T
-(\325) 352.05 261.31 T
-(s focus policy\051.) 354.83 261.31 T
-0 F
-(2.2) 127.41 231.31 T
-(Keyboard traversal) 152.1 231.31 T
-3 F
--0.38 (Tk 4.0 has a much more complete implementation of keyboard traversal than Tk 3.6. In Tk) 152.1 215.31 P
-(3.6 there is built-in support only for keyboard traversal of menus. In Tk 4.0 keyboard tra-) 152.1 203.31 T
-(versal is implemented for all widgets. Y) 152.1 191.31 T
-(ou can type) 311.27 191.31 T
-5 F
-(Tab) 359.85 191.31 T
-3 F
-( to move the focus among the) 377.84 191.31 T
--0.4 (windows within a toplevel and) 152.1 179.31 P
-5 F
--0.95 (Shift+Tab) 275.31 179.31 P
-3 F
--0.4 ( to move in the reverse direction. The order of) 329.28 179.31 P
--0.11 (traversal is de\336ned by the stacking order of widgets, with the lowest widget \336rst in the tra-) 152.1 167.31 P
-(versal order) 152.1 155.31 T
-(. All Tk widgets now provide a) 199 155.31 T
-5 F
-(-takefocus) 326.14 155.31 T
-3 F
-( option, which determines) 386.11 155.31 T
-FMENDPAGE
-%%EndPage: "7" 8
-%%Page: "8" 8
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(8) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
-(whether the window should accept the focus during traversal or be skipped. This option) 152.1 632.33 T
-(has several features; see the) 152.1 620.33 T
-5 F
-(options.n) 265.61 620.33 T
-3 F
-( manual entry for details.) 319.58 620.33 T
-(All of the Tk widgets provide a traversal highlight ring as required by Motif. The) 170.1 608.33 T
-(highlight ring turns dark when the widget has the input focus. Its size and colors are con-) 152.1 596.33 T
-(trolled by the) 152.1 584.33 T
-5 F
-(-highlightthickness) 207.9 584.33 T
-3 F
-(,) 321.84 584.33 T
-5 F
-(-highlightbackground) 326.83 584.33 T
-3 F
-(, and) 446.77 584.33 T
-5 F
-(-) 152.1 572.33 T
-(highlightcolor) 158.1 572.33 T
-3 F
-( options. Y) 242.05 572.33 T
-(ou may notice that widgets appear to have extra space) 285.2 572.33 T
-(around them in Tk 4.0; this is due to the traversal highlight ring, which is normally the) 152.1 560.33 T
-(same color as the background for widgets.) 152.1 548.33 T
-0 F
-(2.3) 127.41 518.33 T
-(Support for focus-follows-mouse) 152.1 518.33 T
-3 F
-(Both Tk 3.6 and Tk 4.0 use an) 152.1 502.33 T
-2 F
-(explicit focus model) 275.91 502.33 T
-3 F
-( within a toplevel. This means that) 355.86 502.33 T
-(moving the mouse among the windows of a toplevel does not normally move the focus;) 152.1 490.33 T
--0.06 (you have to click or perform some other action \050such as pressing) 152.1 478.33 P
-5 F
--0.15 (Tab) 412.26 478.33 P
-3 F
--0.06 (\051 to move the focus.) 430.25 478.33 P
-(Tk 3.6 has no support for an) 152.1 466.33 T
-2 F
-(implicit focus model) 267.58 466.33 T
-3 F
-( where the window under the mouse) 348.64 466.33 T
-(always has the focus. In Tk 4.0 you can invoke the library procedure) 152.1 454.33 T
-5 F
-(tk_focusFol-) 428.83 454.33 T
-(lowsMouse) 152.1 442.33 T
-3 F
-( to switch to an implicit focus model; in this mode whenever the mouse) 206.07 442.33 T
-(enters a new window the focus will switch to that window) 152.1 430.33 T
-(.) 384.07 430.33 T
-0 F
-(2.4) 127.41 400.33 T
-(No default focus window) 152.1 400.33 T
-(, no \322none\323 focus.) 269.45 400.33 T
-3 F
--0.16 (Tk 3.6 has the notion of a default focus window) 152.1 384.33 P
--0.16 (, which receives the focus if the focus win-) 341.56 384.33 P
-(dow is deleted. It is also possible for an application to abandon the input focus by setting) 152.1 372.33 T
-(the focus to) 152.1 360.33 T
-5 F
-(none) 201.23 360.33 T
-3 F
-(. In Tk 4.0 both of these features have been eliminated. There is no) 225.22 360.33 T
-(default focus window) 152.1 348.33 T
-(, and the focus can never be explicitly abandoned. If the focus win-) 238.05 348.33 T
-(dow is destroyed, Tk resets the input focus to the toplevel containing the old focus win-) 152.1 336.33 T
-(dow) 152.1 324.33 T
-(. If the toplevel is destroyed, the window manager will reclaim the focus and move it) 168.66 324.33 T
-(elsewhere.) 152.1 312.33 T
--0.18 (If you really want to abandon the focus in Tk 4.0 so that keyboard events are ignored,) 170.1 300.33 P
-(you can create a dummy window with no key bindings \050set its binding tags to an empty) 152.1 288.33 T
-(string to be sure\051, make sure that is never mapped, and give it the input focus.) 152.1 276.33 T
-0 F
-(2.5) 127.41 246.33 T
-(Better focus events) 152.1 246.33 T
-3 F
--0.13 (Tk 3.6 has a quirky event model for) 152.1 230.33 P
-5 F
--0.32 (FocusIn) 296.77 230.33 P
-3 F
--0.13 ( and) 338.75 230.33 P
-5 F
--0.32 (FocusOut) 357.92 230.33 P
-3 F
--0.13 ( events: when the window) 405.89 230.33 P
--0.23 (manager gives the focus to a toplevel, Tk generates a) 152.1 218.33 P
-5 F
--0.55 (FocusIn) 364.36 218.33 P
-3 F
--0.23 ( event for the toplevel and) 406.33 218.33 P
-(another) 152.1 206.33 T
-5 F
-(FocusIn) 184.57 206.33 T
-3 F
-( event for the focus window) 226.55 206.33 T
-(, but no events for any other windows.) 337.76 206.33 T
-(When the window manager moves the focus somewhere else,) 152.1 194.33 T
-5 F
-(FocusOut) 400.79 194.33 T
-3 F
-( events are gen-) 448.77 194.33 T
--0 (erated for these same two windows. In Tk 4.0,) 152.1 182.33 P
-5 F
--0 (FocusIn) 339.73 182.33 P
-3 F
--0 ( and) 381.71 182.33 P
-5 F
--0 (FocusOut) 401.13 182.33 P
-3 F
--0 ( events are gen-) 449.11 182.33 P
--0.26 (erated in the same way as) 152.1 170.33 P
-5 F
--0.63 (Enter) 255.43 170.33 P
-3 F
--0.26 ( and) 285.41 170.33 P
-5 F
--0.63 (Leave) 304.31 170.33 P
-3 F
--0.26 ( events: when the focus arrives, a) 334.29 170.33 P
-5 F
--0.63 (FocusIn) 467.89 170.33 P
-3 F
--0.05 (event is generated for each window from the toplevel down to the focus window) 152.1 158.33 P
--0.05 (, with dif-) 472.5 158.33 P
-FMENDPAGE
-%%EndPage: "8" 9
-%%Page: "9" 9
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(3 T) 98.1 668.33 T
-(ext widgets) 111.43 668.33 T
-0 F
-(9) 506.54 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
--0.33 (ferent detail \336elds for dif) 152.1 632.33 P
--0.33 (ferent windows \050see Xlib documentation for information on these) 250.53 632.33 P
-(values\051. The reverse happens when the focus leaves a window) 152.1 620.33 T
-(.) 399.57 620.33 T
-0 F
-(2.6) 127.41 590.33 T
-(Porting issues) 152.1 590.33 T
-3 F
-(If you didn\325) 152.1 574.33 T
-(t have any special focus-related code in Tk 3.6, then you shouldn\325) 199.66 574.33 T
-(t need to) 462.9 574.33 T
-(make any changes for 4.0; things will just work better) 152.1 562.33 T
-(. If you wrote code in Tk 3.6 to get) 366.96 562.33 T
-(around the weaknesses with its focus mechanism, then you should remove most or all of) 152.1 550.33 T
-(that code. For example, if you implemented keyboard traversal yourself, or if you built) 152.1 538.33 T
-(your own mechanism to remember a separate focus window for each toplevel and give it) 152.1 526.33 T
-(the input focus whenever the toplevel gets the focus, you can simply remove this code,) 152.1 514.33 T
--0.33 (since Tk 4.0 performs these functions for you. If you wrote code that depends on the weird) 152.1 502.33 P
--0.03 (event model in Tk 3.6, that code will need to be rewritten for Tk 4.0. The Tk 4.0 model is) 152.1 490.33 P
-(general enough to duplicate any ef) 152.1 478.33 T
-(fects that were possible in Tk 3.6.) 289.86 478.33 T
-98.1 434.98 512.1 438 C
-152.1 436.2 512.1 436.2 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 436.49 143.1 436.49 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(3) 134.63 442 T
-(T) 152.1 442 T
-(ext widgets) 158.54 442 T
-3 10 Q
-(T) 152.1 418.31 T
-(ext widgets have under) 157.51 418.31 T
-(gone a major overhaul for Tk 4.0 and they have improved in) 249.76 418.31 T
-(many ways. The changes to text widgets are almost entirely upward-compatible from Tk) 152.1 406.31 T
-(3.6.) 152.1 394.31 T
-0 F
-(3.1) 127.41 364.31 T
-(Embedded windows.) 152.1 364.31 T
-3 F
-(Tk 3.6 supported two kinds of annotations in texts: marks and tags. In Tk 4.0 a third kind) 152.1 348.31 T
--0.04 (of annotation is available: an embedded window) 152.1 336.31 P
--0.04 (. This allows you to embed other widgets) 344.99 336.31 P
-(inside a text widget, mixed in with the text. The text widget acts as a geometry manager) 152.1 324.31 T
-(for these windows, laying them out and wrapping them just as if each embedded window) 152.1 312.31 T
-(were a single character in the text. Y) 152.1 300.31 T
-(ou can even have texts with nothing in them but) 297.64 300.31 T
-(embedded windows. The) 152.1 288.31 T
-5 F
-(window) 254.8 288.31 T
-3 F
-( widget command for text widgets provides several) 290.78 288.31 T
-(options to manage embedded windows.) 152.1 276.31 T
-0 F
-(3.2) 127.41 246.31 T
-(More options for tags.) 152.1 246.31 T
-3 F
-(In Tk 4.0 tags support many new options providing additional control over how informa-) 152.1 230.31 T
-(tion is displayed. Here is a summary of the new options:) 152.1 218.31 T
-3 12 Q
-(\245) 152.1 203.31 T
-3 10 Q
-(Y) 162.9 203.31 T
-(ou can now specify tab stops with the) 169.12 203.31 T
-5 F
-(-tabs) 321.79 203.31 T
-3 F
-( option. Each tab stop can use left, cen-) 351.78 203.31 T
-(ter) 162.9 191.31 T
-(, right, or numeric justi\336cation. T) 173.04 191.31 T
-(ab stops can also be speci\336ed for the widget as a) 305.6 191.31 T
-(whole.) 162.9 179.31 T
-3 12 Q
-(\245) 152.1 164.31 T
-3 10 Q
-(Y) 162.9 164.31 T
-(ou can specify justi\336cation \050left, center or right\051 with the) 169.12 164.31 T
-5 F
-(-justify) 398.12 164.31 T
-3 F
-( option.) 446.09 164.31 T
-FMENDPAGE
-%%EndPage: "9" 10
-%%Page: "10" 10
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(10) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 12 Q
-0 X
-(\245) 152.1 632.33 T
-3 10 Q
-(Y) 162.9 632.33 T
-(ou can now specify line spacing with three options,) 169.12 632.33 T
-5 F
-(-spacing1) 376.75 632.33 T
-3 F
-(,) 430.72 632.33 T
-5 F
-(-spacing2) 435.72 632.33 T
-3 F
-(, and) 489.69 632.33 T
-5 F
-(-) 162.9 620.2 T
-(spacing3) 168.9 620.2 T
-3 F
-(, which control the spacing above a line, between wrapped lines, and) 216.87 620.2 T
-(below a line.) 162.9 608.06 T
-3 12 Q
-(\245) 152.1 593.06 T
-3 10 Q
-(Y) 162.9 593.06 T
-(ou can now specify mar) 169.12 593.06 T
-(gins with the) 264.41 593.06 T
-5 F
-(-lmargin1) 318.55 593.06 T
-3 F
-(,) 372.52 593.06 T
-5 F
-(-lmargin2) 377.52 593.06 T
-3 F
-(, and) 431.49 593.06 T
-5 F
-(-rmargin) 453.42 593.06 T
-3 F
-(options.) 162.9 580.92 T
-3 12 Q
-(\245) 152.1 565.92 T
-3 10 Q
--0.25 (Y) 162.9 565.92 P
--0.25 (ou can now adjust the vertical position of text \050e.g. for superscripts or subscripts\051 with) 169.12 565.92 P
-(the) 162.9 553.79 T
-5 F
-(-offset) 177.61 553.79 T
-3 F
-( option.) 219.59 553.79 T
-3 12 Q
-(\245) 152.1 538.79 T
-3 10 Q
--0.03 (Y) 162.9 538.79 P
--0.03 (ou can now specify the wrapping style \050word wrapping, character wrapping, or none\051) 169.12 538.79 P
-(with the) 162.9 526.65 T
-5 F
-(-wrap) 197.88 526.65 T
-3 F
-( option.) 227.86 526.65 T
-3 12 Q
-(\245) 152.1 511.65 T
-3 10 Q
-(Y) 162.9 511.65 T
-(ou can now request overstriking with the) 169.12 511.65 T
-5 F
-(-overstrike) 334.83 511.65 T
-3 F
-( option.) 400.8 511.65 T
-0 F
-(3.3) 127.41 481.65 T
-(Bindings) 152.1 481.65 T
-3 F
--0.19 (The default bindings for text widgets have been completely rewritten in Tk 4.0. They now) 152.1 465.65 P
-(support almost all of the Motif behavior \050everything except add mode and secondary) 152.1 453.52 T
--0.36 (selections\051. They also include a substantial subset of the Emacs bindings for cursor motion) 152.1 441.38 P
-(and basic editing. The) 152.1 429.24 T
-5 F
-(tk_strictMotif) 242.87 429.24 T
-3 F
-( variable disables the Emacs bindings.) 326.82 429.24 T
-0 F
-(3.4) 127.41 399.24 T
-(Miscellaneous new features) 152.1 399.24 T
-3 F
-(In addition to the major changes described above, text widgets also include the following) 152.1 383.24 T
-(new features:) 152.1 371.11 T
-1 F
-(Horizontal scr) 162.9 356.11 T
-(olling) 224.07 356.11 T
-3 F
-(. T) 247.95 356.11 T
-(ext widgets can now be scrolled horizontally as well as verti-) 258.36 356.11 T
-(cally) 162.9 343.97 T
-(, using the) 181.68 343.97 T
-5 F
-(-) 225.55 343.97 T
-(xscrollcommand) 231.54 343.97 T
-3 F
-( option and the) 315.5 343.97 T
-5 F
-(xview) 377.68 343.97 T
-3 F
-( widget command.) 407.67 343.97 T
-1 F
-(Sear) 162.9 328.97 T
-(ching) 182.15 328.97 T
-3 F
-(. T) 205.48 328.97 T
-(ext widgets have a new) 215.88 328.97 T
-5 F
-(search) 311.64 328.97 T
-3 F
-( widget command, which provides ef) 347.62 328.97 T
-(\336-) 495.67 328.97 T
--0.19 (cient searching of text widgets using either exact matching, glob-style matching, or reg-) 162.9 316.83 P
-(ular expressions. Y) 162.9 304.7 T
-(ou can search forwards or backwards.) 238.79 304.7 T
-1 F
-(Mark gravity) 162.9 289.7 T
-3 F
-(. In Tk 3.6 marks always had \322right gravity\323, which means they stick to) 219.71 289.7 T
-(the character on the right side of the mark; if you insert at the position of a mark, the) 162.9 277.56 T
--0.1 (new character goes before the mark. In Tk 4.0 you can specify whether marks have left) 162.9 265.42 P
-(or right gravity) 162.9 253.29 T
-(.) 222.77 253.29 T
-1 F
-(Scr) 162.9 238.29 T
-(een information) 177.15 238.29 T
-3 F
-(. In Tk 4.0 there are two new widget commands for text widgets) 245.16 238.29 T
-(that return information about the screen layout. The) 162.9 226.15 T
-5 F
-(dlineinfo) 371.92 226.15 T
-3 F
-( widget command) 425.89 226.15 T
-(returns the bounding box of a display line \050all the information displayed on one line of) 162.9 214.02 T
-(the window) 162.9 201.88 T
-(, which may be either a whole line of text or a partial line if wrapping has) 209.16 201.88 T
-(occurred\051. The) 162.9 189.74 T
-5 F
-(bbox) 224.23 189.74 T
-3 F
-( widget command returns the screen area occupied by a single) 248.21 189.74 T
-(character) 162.9 177.61 T
-(.) 198.97 177.61 T
-1 F
-(Extended insert command) 162.9 162.61 T
-3 F
-(. The) 275.06 162.61 T
-5 F
-(insert) 298.1 162.61 T
-3 F
-( widget command now supports an addi-) 334.08 162.61 T
--0.32 (tional ar) 162.9 150.47 P
--0.32 (gument giving a list of tags to apply to the new characters. Y) 195.43 150.47 P
--0.32 (ou can also include) 434 150.47 P
-(several text and tag ar) 162.9 138.33 T
-(guments in a single) 250.42 138.33 T
-5 F
-(insert) 330.38 138.33 T
-3 F
-( command.) 366.36 138.33 T
-FMENDPAGE
-%%EndPage: "10" 11
-%%Page: "11" 11
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(4 Better Motif compliance) 98.1 668.33 T
-0 F
-(1) 501.54 668.33 T
-(1) 506.54 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-1 F
-0 X
-(See command) 162.9 632.33 T
-3 F
-(. There is a new) 222.03 632.33 T
-5 F
-(see) 288.08 632.33 T
-3 F
-( widget command, which adjusts the view in the) 306.07 632.33 T
-(widget if needed to ensure that a particular character is visible in the window) 162.9 620.29 T
-(.) 470.07 620.29 T
-0 F
-(3.5) 127.41 590.29 T
-(Porting issues: tag stickiness, change in end) 152.1 590.29 T
-3 F
-(There are two changes in text widgets that may require modi\336cations to Tk 3.6 scripts.) 152.1 574.29 T
--0.06 (The \336rst change has to do with tag stickiness. In Tk 3.6, tags are sticky to the right: if you) 152.1 562.24 P
-(insert new text just after a tagged range, the new text acquires the tags of the preceding) 152.1 550.19 T
-(character) 152.1 538.14 T
-(. If you insert text before a tagged range in Tk 3.6, the new characters do not) 188.17 538.14 T
--0.34 (acquire the tags of the range. In Tk 4.0, tags are not sticky on either side: new text acquires) 152.1 526.09 P
-(a tag from surrounding characters only if the tag is present on both sides of the insertion) 152.1 514.05 T
-(position. The sticky behavior in Tk 3.6 was rarely useful and special code was often) 152.1 502 T
-(needed to work around it. Y) 152.1 489.95 T
-(ou should be able to eliminate this code in Tk 4.0.) 263.24 489.95 T
-(The second incompatible change in text widgets is that the index) 170.1 477.95 T
-5 F
-(end) 431.32 477.95 T
-3 F
-( now refers to) 449.31 477.95 T
--0.14 (the position just after the \336nal newline in the text, whereas in Tk 3.6 it referred to the posi-) 152.1 465.9 P
--0.1 (tion just before the \336nal newline. This makes it possible to apply tags to the \336nal newline,) 152.1 453.86 P
-(which was not possible in Tk 3.6, but you may need to modify your scripts if you depend) 152.1 441.81 T
-(on the old position of) 152.1 429.76 T
-5 F
-(end) 240.11 429.76 T
-3 F
-(.) 258.1 429.76 T
-98.1 386.4 512.1 389.43 C
-152.1 387.63 512.1 387.63 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 387.92 143.1 387.92 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(4) 134.63 393.43 T
-(Better Motif compliance) 152.1 393.43 T
-3 10 Q
-(All of the widgets have been modi\336ed in Tk 4.0 to improve their Motif compliance. This) 152.1 369.74 T
--0.3 (was done by adding features that were missing and reworking the bindings to comply with) 152.1 357.69 P
-(Motif conventions. I believe that the widgets are now completely Motif compliant except) 152.1 345.64 T
-(for the following missing features:) 152.1 333.6 T
-3 12 Q
-(\245) 152.1 318.6 T
-3 10 Q
-(There is no support for secondary selections.) 162.9 318.6 T
-3 12 Q
-(\245) 152.1 303.6 T
-3 10 Q
-(There is no support for \322add mode\323 in widgets such as texts and listboxes.) 162.9 303.6 T
-3 12 Q
-(\245) 152.1 288.6 T
-3 10 Q
-(There is no support for drag and drop.) 162.9 288.6 T
--0.02 (Please let me know if you \336nd any other discrepancies between the Tk widgets and Motif) 152.1 273.59 P
-(widgets. W) 152.1 261.55 T
-(e plan to eliminate the remaining incompatibilities over the next year or two.) 196.82 261.55 T
-98.1 218.19 512.1 221.21 C
-152.1 219.41 512.1 219.41 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 219.7 143.1 219.7 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(5) 134.63 225.21 T
-(W) 152.1 225.21 T
-(idget changes) 163.31 225.21 T
-3 10 Q
--0.07 (All of the Tk 4.0 widgets have been improved over their 3.6 counterparts, mostly in small) 152.1 201.52 P
--0.23 (and backwards compatible ways. Here is a summary of the widget improvements; see Sec-) 152.1 189.48 P
-(tion 13 for information about incompatible changes.) 152.1 177.43 T
-3 12 Q
-(\245) 152.1 162.43 T
-3 10 Q
-(All widgets now have a) 162.9 162.43 T
-5 F
-(cget) 259.78 162.43 T
-3 F
-( command, which provides an easier way to retrieve the) 283.76 162.43 T
-(value of a con\336guration option. In other situations where con\336guration options are) 162.9 150.38 T
-(used, such as for menu entries or text tags, a) 162.9 138.33 T
-5 F
-(cget) 342.21 138.33 T
-3 F
-( command is also available.) 366.2 138.33 T
-FMENDPAGE
-%%EndPage: "11" 12
-%%Page: "12" 12
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(12) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 12 Q
-0 X
-(\245) 152.1 632.33 T
-3 10 Q
--0.22 (All widgets now have) 162.9 632.33 P
-5 F
--0.53 (-highlightthickness) 251.96 632.33 P
-3 F
--0.22 (,) 365.9 632.33 P
-5 F
--0.53 (-highlightbackground) 370.68 632.33 P
-3 F
--0.22 (, and) 490.61 632.33 P
-5 F
-(-) 162.9 620.33 T
-(highlightcolor) 168.9 620.33 T
-3 F
-( options for displaying a highlight ring when the widget \050or one) 252.85 620.33 T
-(of its descendants\051 has the input focus.) 162.9 608.33 T
-3 12 Q
-(\245) 152.1 593.33 T
-3 10 Q
-(Entry widgets now support justi\336cation and provide a) 162.9 593.33 T
-5 F
-(-show) 379.99 593.33 T
-3 F
-( option for \050not\051 display-) 409.97 593.33 T
-(ing passwords. They will autosize to \336t their text if) 162.9 581.33 T
-5 F
-(-width 0) 369.17 581.33 T
-3 F
-( is speci\336ed.) 417.14 581.33 T
-3 12 Q
-(\245) 152.1 566.33 T
-3 10 Q
--0.16 (The label/button family of widgets now supports multiline text and justi\336cation, includ-) 162.9 566.33 P
-(ing new options) 162.9 554.33 T
-5 F
-(-wraplength) 229.25 554.33 T
-3 F
-( and) 295.22 554.33 T
-5 F
-(-justify) 314.65 554.33 T
-3 F
-(.  These features make the message) 361.97 554.33 T
--0.04 (widget obsolete. There is also a new) 162.9 542.33 P
-5 F
--0.1 (-underline) 310.27 542.33 P
-3 F
--0.04 ( option for highlighting a character) 370.23 542.33 P
-(for keyboard traversal.) 162.9 530.33 T
-3 12 Q
-(\245) 152.1 515.33 T
-3 10 Q
--0.23 (Listboxes now support all of the Motif selection modes, including single selection, mul-) 162.9 515.33 P
-(tiple selection, and multiple disjoint selections, via the) 162.9 503.33 T
-5 F
-(-selectmode) 382.78 503.33 T
-3 F
-( option. They) 448.74 503.33 T
-(will autosize to \336t their contents if) 162.9 491.33 T
-5 F
-(-width 0) 302.54 491.33 T
-3 F
-( or) 350.52 491.33 T
-5 F
-(-height 0) 363.84 491.33 T
-3 F
-( is speci\336ed. There are) 417.81 491.33 T
-(new) 162.9 479.33 T
-5 F
-(see) 182.05 479.33 T
-3 F
-(,) 200.04 479.33 T
-5 F
-(bbox) 205.04 479.33 T
-3 F
-(, and) 229.02 479.33 T
-5 F
-(activate) 250.95 479.33 T
-3 F
-( widget commands.) 298.92 479.33 T
-3 12 Q
-(\245) 152.1 464.33 T
-3 10 Q
-(Canvas polygons now support) 162.9 464.33 T
-5 F
-(-outline) 286.16 464.33 T
-3 F
-( and) 334.14 464.33 T
-5 F
-(-width) 353.57 464.33 T
-3 F
-( options for drawing outlines.) 389.55 464.33 T
-3 12 Q
-(\245) 152.1 449.33 T
-3 10 Q
--0.03 (Scale widgets now support real values as well as integers \050see the) 162.9 449.33 P
-5 F
--0.08 (-resolution) 426.77 449.33 P
-3 F
--0.03 ( and) 492.73 449.33 P
-5 F
--0.54 (-digits) 162.9 437.33 P
-3 F
--0.22 ( options\051, and they have a) 204.88 437.33 P
-5 F
--0.54 (-variable) 308.73 437.33 P
-3 F
--0.22 ( option to link to a T) 362.7 437.33 P
--0.22 (cl variable. They) 442.83 437.33 P
--0.28 (have two new widget commands,) 162.9 425.33 P
-5 F
--0.67 (coords) 297.52 425.33 P
-3 F
--0.28 ( and) 333.5 425.33 P
-5 F
--0.67 (identify) 352.37 425.33 P
-3 F
--0.28 (, and their bindings are now) 399.69 425.33 P
-(de\336ned in T) 162.9 413.33 T
-(cl rather than being hardwired in C code as in Tk 3.6.) 210.5 413.33 T
-3 12 Q
-(\245) 152.1 398.33 T
-3 10 Q
-(Scrollbar widgets now have a new interface to the controlling widget, which provides) 162.9 398.33 T
--0.04 (more \337exibility than the old style \050but the old style is still supported for compatibility\051.) 162.9 386.33 P
-(There is a new option) 162.9 374.33 T
-5 F
-(-jump) 252 374.33 T
-3 F
-( to prevent continuous updates while dragging the slider) 281.98 374.33 T
-(,) 505.88 374.33 T
--0.24 (and a new option) 162.9 362.33 P
-5 F
--0.59 (-elementborderwidth) 232.98 362.33 P
-3 F
--0.24 ( to control the border width of the arrows) 346.92 362.33 P
-(and slider separately from the widget\325) 162.9 350.33 T
-(s outer border) 314.18 350.33 T
-(. There are four new widget com-) 369.14 350.33 T
-(mands,) 162.9 338.33 T
-5 F
-(activate) 193.99 338.33 T
-3 F
-(,) 241.97 338.33 T
-5 F
-(delta) 246.96 338.33 T
-3 F
-(,) 276.95 338.33 T
-5 F
-(fraction) 281.95 338.33 T
-3 F
-(, and) 329.92 338.33 T
-5 F
-(identify) 351.85 338.33 T
-3 F
-(, and the default bindings) 399.17 338.33 T
-(are now de\336ned in T) 162.9 326.33 T
-(cl rather than being hardwired in C code as in Tk 3.6.) 244.91 326.33 T
-3 12 Q
-(\245) 152.1 311.33 T
-3 10 Q
--0.13 (Menu entries now have several new con\336guration options such as) 162.9 311.33 P
-5 F
--0.31 (-foreground) 426.97 311.33 P
-3 F
--0.13 ( and) 492.93 311.33 P
-5 F
--0.41 (-) 162.9 299.33 P
--0.41 (indicatoron) 168.9 299.33 P
-3 F
--0.17 (, and tear) 234.86 299.33 P
--0.17 (-of) 271.23 299.33 P
--0.17 (f menus have been reimplemented to be more Motif-like.) 282.7 299.33 P
-(New menu entries can be created in the middle of a menu using the) 162.9 287.33 T
-5 F
-(insert) 434.36 287.33 T
-3 F
-( widget) 470.34 287.33 T
-(command, and there is a) 162.9 275.33 T
-5 F
-(type) 262.83 275.33 T
-3 F
-( widget command that returns the type of a menu entry) 286.81 275.33 T
-(.) 505.45 275.33 T
-3 12 Q
-(\245) 152.1 260.33 T
-3 10 Q
-(Menubuttons now have a) 162.9 260.33 T
-5 F
-(-indicatoron) 266.16 260.33 T
-3 F
-( option for displaying an option menu indi-) 338.12 260.33 T
--0.38 (cator) 162.9 248.33 P
--0.38 (. There is now support for option menus via the) 182.33 248.33 P
-5 F
--0.91 (tk_optionMenu) 370.9 248.33 P
-3 F
--0.38 ( procedure, and) 448.86 248.33 P
-(popups are simpli\336ed with the) 162.9 236.33 T
-5 F
-(tk_popup) 286.44 236.33 T
-3 F
-( procedure.) 334.42 236.33 T
-3 12 Q
-(\245) 152.1 221.33 T
-3 10 Q
--0.03 (The variable) 162.9 221.33 P
-5 F
--0.07 (tk_strictMotif) 215.57 221.33 P
-3 F
--0.03 ( is used in more places to enforce even stricter Motif) 299.53 221.33 P
-(compliance.) 162.9 209.33 T
-FMENDPAGE
-%%EndPage: "12" 13
-%%Page: "13" 13
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(6 Images) 98.1 668.33 T
-0 F
-(13) 500.99 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-98.1 623.98 512.1 627 C
-152.1 625.2 512.1 625.2 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 625.49 143.1 625.49 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(6) 134.63 631 T
-(Images) 152.1 631 T
-3 10 Q
-(Tk 4.0 contains a general-purpose image mechanism for displaying color pictures and) 152.1 607.31 T
-(other complex objects. There is a new command,) 152.1 595.26 T
-5 F
-(image) 350.84 595.26 T
-3 F
-(, which may be used to create) 380.82 595.26 T
-(image objects. For example, the command) 152.1 583.21 T
-5 9 Q
-(image create photo myFace -f) 179.1 568.88 T
-(ile picture.ppm) 330.09 568.88 T
-3 10 Q
-(creates a new image named) 152.1 555.21 T
-5 F
-(myFace) 264.5 555.21 T
-3 F
-(. The image is of type) 300.48 555.21 T
-5 F
-(photo) 390.14 555.21 T
-3 F
-( \050a full-color represen-) 420.12 555.21 T
-(tation that dithers on monochrome or color) 152.1 543.17 T
-(-mapped displays\051 and the source data for the) 323.46 543.17 T
-(image is in the \336le named) 152.1 531.12 T
-5 F
-(picture.ppm) 257.59 531.12 T
-3 F
-(. Once an image has been created, it can be) 323.56 531.12 T
--0.15 (used in many dif) 152.1 519.07 P
--0.15 (ferent places by specifying a) 218.37 519.07 P
-5 F
--0.36 (-image) 334.46 519.07 P
-3 F
--0.15 ( option. For example, the command) 370.44 519.07 P
-5 9 Q
-(label .l -image myFace) 179.1 504.74 T
-3 10 Q
-(will create a label widget that displays the image, and if) 152.1 491.07 T
-5 F
-(.c) 377.5 491.07 T
-3 F
-( is a canvas widget the com-) 389.49 491.07 T
-(mand) 152.1 479.02 T
-5 9 Q
-(.c create image 400 200 -image myFace) 179.1 464.69 T
-3 10 Q
-(will create an image item in the canvas that displays) 152.1 451.02 T
-5 F
-(myFace) 363.06 451.02 T
-3 F
-(.) 399.04 451.02 T
-(The image mechanism provides a great deal of \337exibility:) 170.1 439.02 T
-3 12 Q
-(\245) 152.1 424.02 T
-3 10 Q
--0.18 (Once an image has been de\336ned, it can be used in many dif) 162.9 424.02 P
--0.18 (ferent places, even on dif) 397.84 424.02 P
--0.18 (fer-) 497.68 424.02 P
-(ent displays.) 162.9 411.98 T
-3 12 Q
-(\245) 152.1 396.98 T
-3 10 Q
-(Images provide image commands, analogous to widget commands, that can be used to) 162.9 396.98 T
-(manipulate the image; any changes in an image are automatically re\337ected in all of its) 162.9 384.93 T
-(instances.) 162.9 372.88 T
-3 12 Q
-(\245) 152.1 357.88 T
-3 10 Q
--0.21 (There can be many dif) 162.9 357.88 P
--0.21 (ferent types of images. Tk 4.0 has two built-in types,) 251.78 357.88 P
-5 F
--0.51 (photo) 463.11 357.88 P
-3 F
--0.21 ( and) 493.1 357.88 P
-5 F
-(bitmap) 162.9 345.83 T
-3 F
-(. Other image types can be de\336ned in C as extensions \050see the documentation) 198.88 345.83 T
--0.16 (for the) 162.9 333.79 P
-5 F
--0.39 (Tk_CreateImageType) 191.44 333.79 P
-3 F
--0.16 ( library procedure\051. The photo image type was imple-) 299.38 333.79 P
-(mented by Paul Mackerras, based on his earlier photo widget.) 162.9 321.74 T
-3 12 Q
-(\245) 152.1 306.74 T
-3 10 Q
-(W) 162.9 306.74 T
-(ithin the photo image type, there can be many dif) 171.93 306.74 T
-(ferent \336le formats. In Tk 4.0, only) 368.29 306.74 T
--0.11 (PPM, PGM, and GIF formats are built-in, but other formats can be added as extensions) 162.9 294.69 P
-(\050see the documentation for the) 162.9 282.64 T
-5 F
-(Tk_CreatePhotoImageFormat) 286.97 282.64 T
-3 F
-( library proce-) 436.89 282.64 T
-(dure\051. Readers for XPM, TIFF) 162.9 270.59 T
-(, and others are available from the T) 284.23 270.59 T
-(cl community) 428.41 270.59 T
-(.) 483.01 270.59 T
-98.1 227.24 512.1 230.26 C
-152.1 228.46 512.1 228.46 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 228.75 143.1 228.75 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(7) 134.63 234.26 T
-(Color management) 152.1 234.26 T
-3 10 Q
-(Tk 3.6 suf) 152.1 210.57 T
-(fers from a relatively weak mechanism for managing colors. It uses only the) 192.73 210.57 T
-(default colormap for a screen, and if all the entries in that colormap \336ll up then Tk) 152.1 198.52 T
-(switches to monochrome mode and \322rounds\323 all future colors to black or white. This) 152.1 186.48 T
-(approach is becoming increasingly unpleasant because of applications such as Frame and) 152.1 174.43 T
-(W) 152.1 162.38 T
-(eb browsers that use up all the entries in the default colormap.) 160.74 162.38 T
-(Tk 4.0 has a much more powerful color management mechanism. If a colormap \336lls) 170.1 150.38 T
-(up, Tk allocates future colors by picking the closest match from the available colors, so) 152.1 138.33 T
-FMENDPAGE
-%%EndPage: "13" 14
-%%Page: "14" 14
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(14) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
-(that it need not revert to monochrome mode. Tk also manages colors better by delaying) 152.1 632.33 T
--0.3 (color allocation until colors are actually needed; in many cases, such as 3D borders, colors) 152.1 620.33 P
-(are never needed. When colors are scarce Tk changes the way it displays beveled borders) 152.1 608.33 T
--0.38 (so that it uses stippling instead of additional colors for the light and dark shadows. Y) 152.1 596.33 P
--0.38 (ou can) 484.01 596.33 P
-(\336nd out whether a colormap has \336lled up using the new command) 152.1 584.33 T
-5 F
-(winfo colormap-) 418.59 584.33 T
-(full) 152.1 572.33 T
-3 F
-(.) 176.09 572.33 T
--0.26 (Tk 4.0 also allows you to allocate new colormaps for toplevel and frame widgets with) 170.1 560.33 P
-(the) 152.1 548.33 T
-5 F
-(-colormap) 166.81 548.33 T
-3 F
-( option, and you change the visual type in these widgets \050with the) 220.78 548.33 T
-5 F
-(-) 152.1 536.33 T
-(visual) 158.1 536.33 T
-3 F
-( option\051 to take advantage of visuals other than the default visual for a screen.) 194.08 536.33 T
-(New commands) 152.1 524.33 T
-5 F
-(winfo visualsavailable) 219.27 524.33 T
-3 F
-( and) 351.2 524.33 T
-5 F
-(wm colormapwindows) 370.63 524.33 T
-3 F
-( have) 478.57 524.33 T
-(been added to help manage colormaps and visuals.) 152.1 512.33 T
-(The default color scheme in Tk 4.0 has changed from a tan palette \050\322bisque\323\051 to a) 170.1 500.33 T
-(gray palette, which seems to becoming standard for Motif. There is a new T) 152.1 488.33 T
-(cl procedure) 454.78 488.33 T
-5 F
--0.36 (tk_setPalette) 152.1 476.33 P
-3 F
--0.15 ( that changes the palette of an application on the \337y) 230.06 476.33 P
--0.15 (, and there is also a) 433.89 476.33 P
-(procedure) 152.1 464.33 T
-5 F
-(tk_bisque) 194.56 464.33 T
-3 F
-( to restore the palette to the old bisque colors.) 248.53 464.33 T
-(The Tk 3.6 color model mechanism is no longer necessary so it has been removed in) 170.1 452.33 T
-(Tk 4.0. If you want to \336nd out whether a screen is monochrome or color) 152.1 440.33 T
-(, you cannot use) 440.38 440.33 T
-(the) 152.1 428.33 T
-5 F
-(tk colormodel) 166.81 428.33 T
-3 F
-( command anymore; use) 244.77 428.33 T
-5 F
-(winfo depth) 345.25 428.33 T
-3 F
-( instead.) 411.22 428.33 T
-98.1 384.98 512.1 388 C
-152.1 386.2 512.1 386.2 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 386.49 143.1 386.49 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(8) 134.63 392 T
-(Event handling: \336leevent and after) 152.1 392 T
-3 10 Q
-(Tk 4.0 contains several improvements in the area of event handling besides those already) 152.1 368.31 T
-(mentioned for bindings:) 152.1 356.31 T
-3 12 Q
-(\245) 152.1 341.31 T
-3 10 Q
-(There is a new command) 162.9 341.31 T
-5 F
-(f) 265.87 341.31 T
-(ileevent) 271.87 341.31 T
-3 F
-( for performing event-driven I/O to and from) 319.84 341.31 T
--0.12 (\336les. The) 162.9 329.31 P
-5 F
--0.29 (f) 202.35 329.31 P
--0.29 (ileevent) 208.35 329.31 P
-3 F
--0.12 ( command is modelled very closely after Mark Diekhans\325) 256.33 329.31 P
-5 F
--0.29 (add-) 488.11 329.31 P
-(input) 162.9 317.31 T
-3 F
-( extension, which has been used widely with Tk 3.6.) 192.88 317.31 T
-3 12 Q
-(\245) 152.1 302.31 T
-3 10 Q
--0.34 (The) 162.9 302.31 P
-5 F
--0.82 (after) 180.6 302.31 P
-3 F
--0.34 ( command has two new options,) 210.58 302.31 P
-5 F
--0.82 (idle) 339.82 302.31 P
-3 F
--0.34 ( and) 363.81 302.31 P
-5 F
--0.82 (cancel) 382.55 302.31 P
-3 F
--0.34 (.) 418.53 302.31 P
-5 F
--0.82 (After idle) 423.19 302.31 P
-3 F
--0.34 ( can be) 482.33 302.31 P
--0.2 (used to schedule a script as an \322idle handler\323, which means it runs the next time that Tk) 162.9 290.31 P
-(enters the event loop and \336nds no work to do.) 162.9 278.31 T
-5 F
-(After cancel) 348.06 278.31 T
-3 F
-( may be used to delete) 420.02 278.31 T
-(a previously-scheduled) 162.9 266.31 T
-5 F
-(after) 257.83 266.31 T
-3 F
-( script, so that it will no longer be invoked.) 287.81 266.31 T
-98.1 222.95 512.1 225.98 C
-152.1 224.18 512.1 224.18 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 224.46 143.1 224.46 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(9) 134.63 229.98 T
-(Multiple displays) 152.1 229.98 T
-3 10 Q
-(Although Tk has always allowed a single application to open windows on several dis-) 152.1 206.29 T
-(plays, the support for multiple displays is weak in Tk 3.6. For example, many of the bind-) 152.1 194.29 T
-(ings break if users work simultaneously in windows on dif) 152.1 182.29 T
-(ferent displays, and) 385.94 182.29 T
-(mechanisms like the selection and the input focus have insuf) 152.1 170.29 T
-(\336cient support for multiple) 394.26 170.29 T
-(displays.) 152.1 158.29 T
-FMENDPAGE
-%%EndPage: "14" 15
-%%Page: "15" 15
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(10 The send command) 98.1 668.33 T
-0 F
-(15) 500.99 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
--0.33 (Tk 4.0 contains numerous modi\336cations to improve the handling of multiple displays.) 170.1 632.33 P
--0.18 (Several commands, such as) 152.1 620.24 P
-5 F
--0.44 (selection) 263.78 620.24 P
-3 F
--0.18 (,) 317.76 620.24 P
-5 F
--0.44 (send) 322.57 620.24 P
-3 F
--0.18 (, and) 346.55 620.24 P
-5 F
--0.44 (focus) 368.12 620.24 P
-3 F
--0.18 (, have a new) 398.1 620.24 P
-5 F
--0.44 (-displayof) 449.82 620.24 P
-3 F
-(ar) 152.1 608.15 T
-(gument so that you can select a particular display) 159.69 608.15 T
-(. In addition, the bindings have been) 356.12 608.15 T
-(reworked to handle interactions occurring simultaneously on dif) 152.1 596.05 T
-(ferent displays. W) 408.13 596.05 T
-(ith Tk) 480.73 596.05 T
-(4.0 it should be possible to create applications that really use multiple displays gracefully) 152.1 583.96 T
-(.) 508.44 583.96 T
-98.1 540.6 512.1 543.63 C
-152.1 541.83 512.1 541.83 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 542.12 143.1 542.12 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(10) 127.96 547.63 T
-(The send command) 152.1 547.63 T
-3 10 Q
--0.2 (The) 152.1 523.94 P
-5 F
--0.48 (send) 169.94 523.94 P
-3 F
--0.2 ( command has been completely overhauled for Tk 4.0 to eliminate several prob-) 193.93 523.94 P
-(lems in Tk 3.6 and add a number of new features:) 152.1 511.85 T
-3 12 Q
-(\245) 152.1 496.85 T
-3 10 Q
-(Tk 3.6 aborts a) 162.9 496.85 T
-5 F
-(send) 225.36 496.85 T
-3 F
-( command if no response is received within 5 seconds; this made) 249.34 496.85 T
-(it very dif) 162.9 484.75 T
-(\336cult to invoke long-running commands. Tk 4.0 eliminates the timeout  and) 202.14 484.75 T
-(uses a dif) 162.9 472.66 T
-(ferent mechanism to tell if the tar) 200.47 472.66 T
-(get application has crashed.) 333.53 472.66 T
-3 12 Q
-(\245) 152.1 457.66 T
-3 10 Q
--0.36 (The) 162.9 457.66 P
-5 F
--0.87 (winfo interps) 180.58 457.66 P
-3 F
--0.36 ( command no longer returns the names of applications that have) 257.66 457.66 P
-(exited or crashed.) 162.9 445.57 T
-3 12 Q
-(\245) 152.1 430.57 T
-3 10 Q
-(Asynchronous sends are possible using the) 162.9 430.57 T
-5 F
-(-async) 336.67 430.57 T
-3 F
-( switch.) 372.65 430.57 T
-3 12 Q
-(\245) 152.1 415.57 T
-3 10 Q
-(Commands can be sent to displays other than that of the root window) 162.9 415.57 T
-(, using the) 439.3 415.57 T
-5 F
-(-) 162.9 403.47 T
-(displayof) 168.9 403.47 T
-3 F
-( switch.) 222.87 403.47 T
-3 12 Q
-(\245) 152.1 388.47 T
-3 10 Q
-(W) 162.9 388.47 T
-(indow server security is now checked on each) 171.93 388.47 T
-5 F
-(send) 357.89 388.47 T
-3 F
-(, so Tk 4.0 deals better with) 381.88 388.47 T
-(changes in the security of the server) 162.9 376.38 T
-(.) 306.12 376.38 T
-3 12 Q
-(\245) 152.1 361.38 T
-3 10 Q
-(More complete error information \050including the) 162.9 361.38 T
-5 F
-(errorCode) 356.09 361.38 T
-3 F
-( and) 410.06 361.38 T
-5 F
-(errorInfo) 429.49 361.38 T
-3 F
-( vari-) 483.46 361.38 T
-(ables\051 is propagated back to the sender after errors.) 162.9 349.29 T
-3 12 Q
-(\245) 152.1 334.29 T
-3 10 Q
-(Y) 162.9 334.29 T
-(ou can query and change the name of an application with the) 169.12 334.29 T
-5 F
-(tk appname) 414.48 334.29 T
-3 F
-( com-) 474.45 334.29 T
-(mand.) 162.9 322.19 T
-(Unfortunately the improvements to the Tk 4.0) 152.1 307.19 T
-5 F
-(send) 338.65 307.19 T
-3 F
-( mechanism required substantial) 362.63 307.19 T
-(changes to the transport protocol for sends; this makes it impossible for Tk 4.0 applica-) 152.1 295.1 T
-(tions to communicate with Tk 3.6 applications via) 152.1 283.01 T
-5 F
-(send) 355.04 283.01 T
-3 F
-(. The new transport protocol is) 379.02 283.01 T
-(more \337exible than the old protocol, so it should be possible to make protocol improve-) 152.1 270.91 T
-(ments in an upward-compatible way) 152.1 258.82 T
-(.) 296.9 258.82 T
-98.1 215.47 512.1 218.49 C
-152.1 216.69 512.1 216.69 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 216.98 143.1 216.98 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(1) 128.62 222.49 T
-(1) 134.63 222.49 T
-(The selection and clipboard) 152.1 222.49 T
-3 10 Q
-(In Tk 3.6 the selection mechanism can deal only with the display of the root window and) 152.1 198.8 T
--0.13 (with the primary selection; there is no support for multiple displays, secondary selections,) 152.1 186.71 P
-(or the clipboard. Tk 4.0 eliminates all of these shortcomings. The) 152.1 174.61 T
-5 F
-(-displayof) 415.82 174.61 T
-3 F
-( option) 475.78 174.61 T
--0.12 (can be used to specify a particular display in the selection command, and there is now full) 152.1 162.52 P
-(access to all of the X selection types. Tk 4.0 also includes a new) 152.1 150.43 T
-5 F
-(clipboard) 411.36 150.43 T
-3 F
-( command) 465.33 150.43 T
-(for manipulating the clipboard.) 152.1 138.33 T
-FMENDPAGE
-%%EndPage: "15" 16
-%%Page: "16" 16
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(16) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-98.1 623.98 512.1 627 C
-152.1 625.2 512.1 625.2 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 625.49 143.1 625.49 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(12) 127.96 631 T
-(Miscellaneous changes) 152.1 631 T
-3 10 Q
-(Here is a quick summary of the remaining changes in Tk 4.0:) 152.1 607.31 T
-3 12 Q
-(\245) 152.1 592.31 T
-3 10 Q
--0.17 (The) 162.9 592.31 P
-5 F
--0.42 (wish) 180.76 592.31 P
-3 F
--0.17 ( application has been modi\336ed so that the) 204.75 592.31 P
-5 F
--0.42 (-f) 371.58 592.31 P
--0.42 (ile) 383.57 592.31 P
-3 F
--0.17 ( switch is no longer needed) 401.56 592.31 P
-(or recommended. This makes) 162.9 580.31 T
-5 F
-(wish) 283.64 580.31 T
-3 F
-( just like) 307.63 580.31 T
-5 F
-(tclsh) 344.56 580.31 T
-3 F
-(, where you specify the script \336le) 374.54 580.31 T
-(as the \336rst ar) 162.9 568.31 T
-(gument to the program, e.g.) 214.07 568.31 T
-5 F
-(wish foo.tcl) 327.33 568.31 T
-3 F
-(. The) 399.29 568.31 T
-5 F
-(-f) 422.33 568.31 T
-(ile) 434.32 568.31 T
-3 F
-( switch is still) 452.31 568.31 T
-(permitted for backward compatibility) 162.9 556.31 T
-(, but its use is deprecated.) 311.87 556.31 T
-3 12 Q
-(\245) 152.1 541.31 T
-5 10 Q
-(Wish) 162.9 541.31 T
-3 F
-( now sets the application\325) 186.89 541.31 T
-(s class from the application name \050what appears in the) 288.49 541.31 T
--0.37 (title bar of the window by default\051, rather than always using) 162.9 529.31 P
-5 F
--0.88 (Tk) 400.9 529.31 P
-3 F
--0.37 ( as the class as in Tk 3.6.) 412.89 529.31 P
-(This makes application-speci\336c options easier to use.) 162.9 517.31 T
-3 12 Q
-(\245) 152.1 502.31 T
-3 10 Q
-(T) 162.9 502.31 T
-(oplevel windows are now resizable by default, whereas in Tk 3.6 they were not. Y) 168.31 502.31 T
-(ou) 496.22 502.31 T
-(can use the) 162.9 490.31 T
-5 F
-(wm resizable) 209.8 490.31 T
-3 F
-( command to make windows non-reiszable.) 281.77 490.31 T
-3 12 Q
-(\245) 152.1 475.31 T
-3 10 Q
-(Tk 4.0 patches around an Xlib bug whereby long-running applications tended to reach) 162.9 475.31 T
-(the end of the space of X resource ids, wrap around to 0 again, and then crash. Tk now) 162.9 463.31 T
-(reuses resource identi\336ers so that wrap-around should never occur) 162.9 451.31 T
-(.) 427.14 451.31 T
-3 12 Q
-(\245) 152.1 436.31 T
-3 10 Q
--0.13 (There is a new) 162.9 436.31 P
-5 F
--0.31 (winfo manager) 223.43 436.31 P
-3 F
--0.13 ( command that tells which geometry manager is con-) 301.08 436.31 P
-(trolling a particular widget.) 162.9 424.31 T
-3 12 Q
-(\245) 152.1 409.31 T
-3 10 Q
-(There is a new) 162.9 409.31 T
-5 F
-(bell) 223.96 409.31 T
-3 F
-( command that does what its name suggests.) 247.94 409.31 T
-3 12 Q
-(\245) 152.1 394.31 T
-3 10 Q
-(There are new) 162.9 394.31 T
-5 F
-(winfo pointerx) 222.56 394.31 T
-3 F
-(,) 306.51 394.31 T
-5 F
-(winfo pointery) 311.51 394.31 T
-3 F
-(, and) 394.81 394.31 T
-5 F
-(winfo pointerxy) 416.74 394.31 T
-3 F
-(commands that can be used to query the position of the mouse pointer) 162.9 382.31 T
-(.) 442.17 382.31 T
-98.1 338.95 512.1 341.98 C
-152.1 340.18 512.1 340.18 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 340.46 143.1 340.46 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(13) 127.96 345.98 T
-(Summary of Incompatibilites) 152.1 345.98 T
-3 10 Q
--0.24 (This section lists all of the incompatible changes in Tk 4.0 that may require changes in T) 152.1 322.29 P
--0.24 (cl) 502.62 322.29 P
--0.22 (scripts written for T) 152.1 310.29 P
--0.22 (cl 3.6. Each incompatibility is described in terms of the problem it pro-) 230.42 310.29 P
-(duces when you run your Tk 3.6 script under Tk 4.0 and a possible work-around. Only) 152.1 298.29 T
-(T) 152.1 286.29 T
-(cl-level incompatibilities are covered here. For incompatible changes at the C level, see) 157.51 286.29 T
-(the) 152.1 274.29 T
-5 F
-(README) 166.81 274.29 T
-3 F
-( and) 202.79 274.29 T
-5 F
-(changes) 222.22 274.29 T
-3 F
-( \336les in the distribution. The problems and solutions are) 264.2 274.29 T
-(roughly in order of importance, with the most important problems \336rst.) 152.1 262.29 T
-1 F
-(Pr) 152.1 247.29 T
-(oblem #1:) 162.46 247.29 T
-3 F
-(When you change the background color of a widget, a small ring in the) 206.88 247.29 T
-(default background color remains around the edge of the widget.) 152.1 235.29 T
-2 F
-(Solution:) 170.1 223.29 T
-3 F
-(This is the focus traversal highlight, whose color is speci\336ed separately) 209.25 223.29 T
-(from) 170.1 211.29 T
-5 F
-(-background) 192.03 211.29 T
-3 F
-(; use the) 257.99 211.29 T
-5 F
-(-highlightbackground) 293.8 211.29 T
-3 F
-( option to change the) 413.74 211.29 T
-(color of the highlight. Or) 170.1 199.29 T
-(, you can set) 269.92 199.29 T
-5 F
-(-highlightthickness) 322.38 199.29 T
-3 F
-( to 0 to eliminate) 436.31 199.29 T
-(the traversal highlight altogether) 170.1 187.29 T
-(.) 299.74 187.29 T
-1 F
-(Pr) 152.1 172.29 T
-(oblem #2:) 162.46 172.29 T
-3 F
-(Bindings de\336ned for a widget no longer replace the corresponding class) 206.88 172.29 T
-(bindings, so unwanted class bindings get invoked in addition to the widget bindings.) 152.1 160.29 T
-FMENDPAGE
-%%EndPage: "16" 17
-%%Page: "17" 17
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(13 Summary of Incompatibilites) 98.1 668.33 T
-0 F
-(17) 500.99 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-2 F
-0 X
-(Solution:) 170.1 632.33 T
-3 F
-(Add a) 209.25 632.33 T
-5 F
-(break) 235.89 632.33 T
-3 F
-( command at the end of the widget binding, or rework the) 265.88 632.33 T
-(widget binding so that it\325) 170.1 620.33 T
-(s OK for the class binding to execute.) 270.05 620.33 T
-1 F
-(Pr) 152.1 605.33 T
-(oblem #3:) 162.46 605.33 T
-3 F
-(Bindings on toplevel windows are invoked when events occur for internal) 206.88 605.33 T
-(windows inside the toplevels.) 152.1 593.33 T
-2 F
-(Solution:) 170.1 581.33 T
-3 F
-(Use the) 209.25 581.33 T
-5 F
-(%W) 242 581.33 T
-3 F
-( substitution to extract the name of the window where the event) 253.99 581.33 T
-(actually occurred, and only execute the rest of the binding script if this matches the) 170.1 569.33 T
-(name of the toplevel.) 170.1 557.33 T
-1 F
--0.15 (Pr) 152.1 542.33 P
--0.15 (oblem #4:) 162.46 542.33 P
-3 F
--0.15 (The) 206.58 542.33 P
-5 F
--0.37 (-command) 224.46 542.33 P
-3 F
--0.15 ( option for a cascade menu entry is no longer invoked when) 272.44 542.33 P
-(the submenu is posted.) 152.1 530.33 T
-2 F
-(Solution:) 170.1 518.33 T
-3 F
-(Use the) 209.25 518.33 T
-5 F
-(-postcommand) 242 518.33 T
-3 F
-( option for the submenu instead.) 313.96 518.33 T
-1 F
-(Pr) 152.1 503.33 T
-(oblem #5:) 162.46 503.33 T
-3 F
-(The) 206.88 503.33 T
-5 F
-(-geometry) 224.92 503.33 T
-3 F
-( option is no longer supported by listboxes, frames, and) 278.89 503.33 T
-(toplevels.) 152.1 491.33 T
-2 F
-(Solution:) 170.1 479.33 T
-3 F
-(Use the) 209.25 479.33 T
-5 F
-(-width) 242 479.33 T
-3 F
-( and) 277.98 479.33 T
-5 F
-(-height) 297.41 479.33 T
-3 F
-( options instead.) 339.39 479.33 T
-1 F
-(Pr) 152.1 464.33 T
-(oblem #6:) 162.46 464.33 T
-3 F
-(The procedure) 206.88 464.33 T
-5 F
-(tk_listboxSingleSelect) 267.38 464.33 T
-3 F
-( no longer exists.) 399.3 464.33 T
-2 F
-(Solution:) 170.1 452.33 T
-3 F
-(Use the) 209.25 452.33 T
-5 F
-(-selectmode) 242 452.33 T
-3 F
-( option on the listbox instead.) 307.96 452.33 T
-1 F
-(Pr) 152.1 437.33 T
-(oblem #7:) 162.46 437.33 T
-3 F
-(Canvases no longer have a) 206.88 437.33 T
-5 F
-(-scrollincrement) 315.96 437.33 T
-3 F
-( option.) 411.91 437.33 T
-2 F
-(Solution:) 170.1 425.33 T
-3 F
-(Use the new) 209.25 425.33 T
-5 F
-(-xscrollincrement) 261.15 425.33 T
-3 F
-( and) 363.09 425.33 T
-5 F
-(-yscrollincrement) 382.52 425.33 T
-3 F
-(options instead.) 170.1 413.33 T
-1 F
-(Pr) 152.1 398.33 T
-(oblem #8:) 162.46 398.33 T
-3 F
-(The) 206.88 398.33 T
-5 F
-(tk colormodel) 224.92 398.33 T
-3 F
-( command no longer exists.) 302.88 398.33 T
-2 F
--0.28 (Solution:) 170.1 386.33 P
-3 F
--0.28 (T) 208.97 386.33 P
--0.28 (o \336nd out whether a window is monochrome or color) 214.37 386.33 P
--0.28 (, use) 424.34 386.33 P
-5 F
--0.68 (winfo depth) 444.6 386.33 P
-3 F
-(to extract the window\325) 170.1 374.33 T
-(s depth; a depth of 1 means monochrome.) 259.76 374.33 T
-1 F
--0.08 (Pr) 152.1 359.33 P
--0.08 (oblem #9:) 162.46 359.33 P
-3 F
--0.08 (The class of Tk applications is no longer) 206.72 359.33 P
-5 F
--0.19 (Tk) 370.97 359.33 P
-3 F
--0.08 (, so options speci\336ed for the) 382.96 359.33 P
-5 F
--0.19 (Tk) 497.69 359.33 P
-3 F
-(class in your) 152.1 347.33 T
-5 F
-(.Xdefaults) 205.12 347.33 T
-3 F
-( \336le are no longer used.) 265.09 347.33 T
-2 F
-(Solution:) 170.1 335.33 T
-3 F
-(Modify your) 209.25 335.33 T
-5 F
-(.Xdefaults) 262.55 335.33 T
-3 F
-( \336le \050and any T) 322.52 335.33 T
-(cl code that sets options\051 to) 382.88 335.33 T
-(specify the name of the application \050with the \336rst letter capitalized\051 as the class) 170.1 323.33 T
-(instead of) 170.1 311.33 T
-5 F
-(Tk) 211.74 311.33 T
-3 F
-(.) 223.73 311.33 T
-1 F
--0.15 (Pr) 152.1 296.33 P
--0.15 (oblem #10:) 162.46 296.33 P
-3 F
--0.15 (When text is added to a text widget just after a tagged area, the new text no) 211.57 296.33 P
-(longer receives the tag.) 152.1 284.33 T
-2 F
--0.1 (Solution:) 170.1 272.33 P
-3 F
--0.1 (Explicitly tag the new text with the desired tags. If you want the tags on the) 209.15 272.33 P
--0.08 (new text to be the same as those at some other point in the text, you can use the) 170.1 260.33 P
-5 F
--0.2 (tag) 488.31 260.33 P
-(names) 170.1 248.33 T
-3 F
-( widget command to query existing tags.) 200.08 248.33 T
-1 F
-(Pr) 152.1 233.33 T
-(oblem #1) 162.46 233.33 T
-(1:) 200.5 233.33 T
-3 F
-(W) 211.33 233.33 T
-(idgets appear lar) 220.36 233.33 T
-(ger than they did in Tk 3.6.) 286.24 233.33 T
-2 F
-(Solution:) 170.1 221.33 T
-3 F
-(There are two issues here. The \336rst is that all widgets now have a focus tra-) 209.25 221.33 T
--0.24 (versal highlight ring that turns dark when the widget has the focus; this is required for) 170.1 209.33 P
-(Motif compliance but you can eliminate it by specifying a 0 value for the) 170.1 197.33 T
-5 F
-( -high-) 462.4 197.33 T
-(lightthickness) 170.1 185.33 T
-3 F
-( option. The second issue is that the default padding for buttons) 254.05 185.33 T
--0.17 (and menubuttons has been increased to match the sizes of Motif widgets. If you don\325) 170.1 173.33 P
--0.17 (t) 506.99 173.33 P
-(mind being dif) 170.1 161.33 T
-(ferent from Motif, you can set the) 228.78 161.33 T
-5 F
-(-padx) 366.45 161.33 T
-3 F
-( and) 396.44 161.33 T
-5 F
-(-) 415.86 161.33 T
-(pady) 421.86 161.33 T
-3 F
-( options back to) 445.85 161.33 T
-FMENDPAGE
-%%EndPage: "17" 18
-%%Page: "18" 18
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(18) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
-(their Tk 3.6 values \050use the) 170.1 632.33 T
-5 F
-(conf) 281.41 632.33 T
-(igure) 305.4 632.33 T
-3 F
-( widget command in Tk 3.6 to see what the) 335.38 632.33 T
-(old values were\051.) 170.1 620.33 T
-1 F
-(Pr) 152.1 605.33 T
-(oblem #12:) 162.46 605.33 T
-3 F
-(Listboxes now return the selection as a string with newlines separating the) 211.88 605.33 T
-(values, rather than a T) 152.1 593.33 T
-(cl, list.) 240.49 593.33 T
-2 F
-(Solution:) 170.1 581.33 T
-3 F
-(Modify your code to handle the new format. Y) 209.25 581.33 T
-(ou can convert the selection) 395.06 581.33 T
-(back into the old list format with a script like the following:) 170.1 569.33 T
-5 9 Q
-(split [selection get] \134n) 179.1 555 T
-1 10 Q
-(Pr) 152.1 541.33 T
-(oblem #13:) 162.46 541.33 T
-3 F
-(Tk 4.0 applications cannot) 211.88 541.33 T
-5 F
-(send) 320.42 541.33 T
-3 F
-( to or be sent from Tk 3.6 applications.) 344.4 541.33 T
-2 F
-(Solution:) 170.1 529.33 T
-3 F
-(The only solution is to upgrade all your applications to Tk 4.0.) 209.25 529.33 T
-1 F
--0.17 (Pr) 152.1 514.33 P
--0.17 (oblem #14:) 162.46 514.33 P
-3 F
--0.17 (In texts,) 211.54 514.33 P
-5 F
--0.4 (end) 245.91 514.33 P
-3 F
--0.17 ( now refers to a position just after the \336nal newline, instead of) 263.9 514.33 P
-(the \336nal newline.) 152.1 502.33 T
-2 F
--0.08 (Solution:) 170.1 490.33 P
-3 F
--0.08 (If you wish to refer to the \336nal newline, use the index) 209.17 490.33 P
-5 F
--0.19 (end-1char) 424.98 490.33 P
-3 F
--0.08 ( instead) 478.95 490.33 P
-(of) 170.1 478.33 T
-5 F
-(end) 180.92 478.33 T
-3 F
-(.) 198.91 478.33 T
-1 F
-(Pr) 152.1 463.33 T
-(oblem #15:) 162.46 463.33 T
-3 F
-(In entry widgets,) 211.88 463.33 T
-5 F
-(sel.last) 281.83 463.33 T
-3 F
-( now refers to the character just after the last) 329.8 463.33 T
-(selected one, rather than the last selected one. The second index for the) 152.1 451.33 T
-5 F
-(delete) 438.81 451.33 T
-3 F
-( widget) 474.79 451.33 T
-(command has changed in the same way) 152.1 439.33 T
-(.) 309.66 439.33 T
-2 F
-(Solution:) 170.1 427.33 T
-3 F
-(Add one to the values used in your scripts.) 209.25 427.33 T
-1 F
-(Pr) 152.1 412.33 T
-(oblem #16:) 162.46 412.33 T
-3 F
-(Because) 211.88 412.33 T
-5 F
-(Any) 247.68 412.33 T
-3 F
-( is implicit in all bindings, bindings trigger when extra modi-) 265.67 412.33 T
-(\336ers are present, whereas they didn\325) 152.1 400.33 T
-(t trigger in Tk 3.6.) 296.24 400.33 T
-2 F
-(Solution:) 170.1 388.33 T
-3 F
-(In most cases it\325) 209.25 388.33 T
-(s probably \336ne to ignore the extra modi\336ers. If you really) 273.93 388.33 T
--0.12 (don\325) 170.1 376.33 P
--0.12 (t want any actions to be taken when extra modi\336ers are present, create additional) 188.24 376.33 P
-(bindings for the cases with extra modi\336ers, and specify a single blank character \050or) 170.1 364.33 T
-(any script that does nothing\051 as the script for those bindings. Alternatively) 170.1 352.33 T
-(, you can) 465.93 352.33 T
-(use the) 170.1 340.33 T
-5 F
-(%s) 200.63 340.33 T
-3 F
-( substitution to extract the mouse and modi\336er state in the event binding,) 212.63 340.33 T
-(then you can test this value for modi\336ers you do or don\325) 170.1 328.33 T
-(t want.) 394.5 328.33 T
-1 F
-(Pr) 152.1 313.33 T
-(oblem #17:) 162.46 313.33 T
-3 F
-(In scrollbars there is no longer a) 211.88 313.33 T
-5 F
-(-foreground) 343.17 313.33 T
-3 F
-( or) 409.13 313.33 T
-5 F
-(-activefore-) 422.45 313.33 T
-(ground) 152.1 301.33 T
-3 F
-( option, and) 188.08 301.33 T
-5 F
-(-background) 238.05 301.33 T
-3 F
-( has a dif) 304.02 301.33 T
-(ferent meaning.) 340.2 301.33 T
-2 F
--0.4 (Solution:) 170.1 289.33 P
-3 F
--0.4 (Use) 208.85 289.33 P
-5 F
--0.96 (-troughcolor) 226.49 289.33 P
-3 F
--0.4 ( everywhere that you used) 298.45 289.33 P
-5 F
--0.96 (-background) 403.87 289.33 P
-3 F
--0.4 ( in Tk 3.6,) 469.83 289.33 P
-5 F
-(-background) 170.1 277.33 T
-3 F
-( everywhere you used to use) 236.06 277.33 T
-5 F
-(-foreground) 352.08 277.33 T
-3 F
-(, and) 418.04 277.33 T
-5 F
-(-activeback-) 439.97 277.33 T
-(ground) 170.1 265.33 T
-3 F
-( everywhere you used to use) 206.08 265.33 T
-5 F
-(-activeforeground) 322.1 265.33 T
-3 F
-(.) 424.04 265.33 T
-1 F
-(Pr) 152.1 250.33 T
-(oblem #18:) 162.46 250.33 T
-3 F
-(Options for colors seem to have changed in scale widgets.) 211.88 250.33 T
-2 F
-(Solution:) 170.1 238.33 T
-3 F
-(Use) 209.25 238.33 T
-5 F
-(-background) 227.29 238.33 T
-3 F
-( where you used to use) 293.25 238.33 T
-5 F
-(-sliderforeground) 387.07 238.33 T
-3 F
-(,) 489.02 238.33 T
-5 F
-(-) 170.1 226.33 T
-(troughcolor) 176.1 226.33 T
-3 F
-( where you used to use) 242.06 226.33 T
-5 F
-(-background) 335.88 226.33 T
-3 F
-(, and) 401.84 226.33 T
-5 F
-( -activeback-) 421.27 226.33 T
-(ground) 170.1 214.33 T
-3 F
-( everywhere you used to use) 206.08 214.33 T
-5 F
-(-activeforeground) 322.1 214.33 T
-3 F
-(.) 424.04 214.33 T
-1 F
-(Pr) 152.1 199.33 T
-(oblem #19:) 162.46 199.33 T
-3 F
-(Scale widgets no longer accept hexadecimal or octal numbers in the) 211.88 199.33 T
-5 F
-(set) 485.84 199.33 T
-3 F
-(command or the) 152.1 187.33 T
-5 F
-(-from) 219.55 187.33 T
-3 F
-( and) 249.54 187.33 T
-5 F
-(-to) 268.97 187.33 T
-3 F
-( options.) 286.96 187.33 T
-2 F
-(Solution:) 170.1 175.33 T
-3 F
-(Use) 209.25 175.33 T
-5 F
-(format) 227.29 175.33 T
-3 F
-( or) 263.27 175.33 T
-5 F
-(expr) 276.59 175.33 T
-3 F
-( to convert the values to decimal.) 300.58 175.33 T
-1 F
-(Pr) 152.1 160.33 T
-(oblem #20:) 162.46 160.33 T
-3 F
-(In checkbuttons, radiobuttons, and menu entries, the) 211.88 160.33 T
-5 F
-(-selector) 423.4 160.33 T
-3 F
-( option) 477.37 160.33 T
-(no longer exists.) 152.1 148.33 T
-FMENDPAGE
-%%EndPage: "18" 19
-%%Page: "19" 19
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(13 Summary of Incompatibilites) 98.1 668.33 T
-0 F
-(19) 500.99 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-2 F
-0 X
-(Solution:) 170.1 632.33 T
-3 F
-(Use) 209.25 632.33 T
-5 F
-(-selectcolor) 227.29 632.33 T
-3 F
-( instead of) 299.25 632.33 T
-5 F
-(-select) 343.39 632.33 T
-3 F
-(. T) 385.36 632.33 T
-(o specify that no indicator) 395.77 632.33 T
-(should be drawn at all, use the) 170.1 620.33 T
-5 F
-(-indicatoron) 293.9 620.33 T
-3 F
-( option instead of setting) 365.86 620.33 T
-5 F
-(-select) 467.2 620.33 T
-3 F
-(to an empty string.) 170.1 608.33 T
-1 F
--0.12 (Pr) 152.1 593.33 P
--0.12 (oblem #21:) 162.46 593.33 P
-3 F
--0.12 (The indices of menu entries have changed, and operations on menu entry 0) 211.64 593.33 P
-(no longer work.) 152.1 581.33 T
-2 F
-(Solution:) 170.1 569.33 T
-3 F
-(This is because menus now have a tearof) 209.25 569.33 T
-(f entry at the top by default, and) 372.55 569.33 T
-(this occupies entry 0, so your \336rst entry is now entry 1. Y) 170.1 557.33 T
-(ou can either set the) 398.95 557.33 T
-5 F
-(-) 170.1 545.33 T
-(tearoff) 176.1 545.33 T
-3 F
-( option to 0 to eliminate the tearof) 218.07 545.33 T
-(f entry or add 1 to all the indices you) 354.2 545.33 T
-(use in your scripts.) 170.1 533.33 T
-1 F
--0.22 (Pr) 152.1 518.33 P
--0.22 (oblem #22:) 162.46 518.33 P
-3 F
--0.22 (The) 211.44 518.33 P
-5 F
--0.53 (enable) 229.26 518.33 P
-3 F
--0.22 ( and) 265.24 518.33 P
-5 F
--0.53 (disable) 284.23 518.33 P
-3 F
--0.22 ( widget commands are no longer supported by) 326.21 518.33 P
-(menus.) 152.1 506.33 T
-2 F
-(Solution:) 170.1 494.33 T
-3 F
-(Use the) 209.25 494.33 T
-5 F
-(-state) 242 494.33 T
-3 F
-( con\336guration option instead.) 277.98 494.33 T
-1 F
-(Pr) 152.1 479.33 T
-(oblem #23:) 162.46 479.33 T
-3 F
-(The) 211.88 479.33 T
-5 F
-(activate) 229.92 479.33 T
-3 F
-( and) 277.89 479.33 T
-5 F
-(deactivate) 297.32 479.33 T
-3 F
-( widget commands are no longer sup-) 357.29 479.33 T
-(ported by buttons, checkbuttons, radiobuttons, and menus.) 152.1 467.33 T
-2 F
-(Solution:) 170.1 455.33 T
-3 F
-(Use the) 209.25 455.33 T
-5 F
-(-state) 242 455.33 T
-3 F
-( con\336guration option instead.) 277.98 455.33 T
-1 F
-(Pr) 152.1 440.33 T
-(oblem #24:) 162.46 440.33 T
-3 F
-(Canvas arc items no longer use the) 211.88 440.33 T
-5 F
-(-f) 353.72 440.33 T
-(ill) 365.71 440.33 T
-3 F
-( and) 383.7 440.33 T
-5 F
-(-stipple) 403.13 440.33 T
-3 F
-( options for) 451.11 440.33 T
-(drawing when the) 152.1 428.33 T
-5 F
-(-style) 226.21 428.33 T
-3 F
-( option is) 262.19 428.33 T
-5 F
-(arc) 301.9 428.33 T
-3 F
-(.) 319.89 428.33 T
-2 F
-(Solution:) 170.1 416.33 T
-3 F
-(Use the) 209.25 416.33 T
-5 F
-(-outline) 242 416.33 T
-3 F
-( and) 289.97 416.33 T
-5 F
-(-outlinestipple) 309.4 416.33 T
-3 F
-( options instead.) 399.35 416.33 T
-1 F
--0.29 (Pr) 152.1 401.33 P
--0.29 (oblem #25:) 162.46 401.33 P
-3 F
--0.29 (The variable) 211.29 401.33 P
-5 F
--0.7 (tkVersion) 263.43 401.33 P
-3 F
--0.29 ( no longer exists \050it has been obsolete for several) 317.4 401.33 P
-(releases\051.) 152.1 389.33 T
-2 F
-(Solution:) 170.1 377.33 T
-3 F
-(Use) 209.25 377.33 T
-5 F
-(tk_version) 227.29 377.33 T
-3 F
-( instead.) 287.26 377.33 T
-1 F
-(Pr) 152.1 362.33 T
-(oblem #26:) 162.46 362.33 T
-3 F
-(The syntax of the) 211.88 362.33 T
-5 F
-(scan) 284.05 362.33 T
-3 F
-( widget commands for texts has changed.) 308.03 362.33 T
-2 F
-(Solution:) 170.1 350.33 T
-3 F
-(Modify your code to use the new syntax.) 209.25 350.33 T
-1 F
-(Pr) 152.1 335.33 T
-(oblem #27:) 162.46 335.33 T
-5 F
-(wish) 211.88 335.33 T
-3 F
-( no longer recognizes the) 235.86 335.33 T
-5 F
-(-help) 338.84 335.33 T
-3 F
-( option.) 368.82 335.33 T
-2 F
-(Solution:) 170.1 323.33 T
-3 F
-(Implement this option yourself in your) 209.25 323.33 T
-5 F
-(wish) 366.38 323.33 T
-3 F
-( scripts.) 390.37 323.33 T
-1 F
-(Pr) 152.1 308.33 T
-(oblem #28:) 162.46 308.33 T
-3 F
-(Tk 4.0 always prints real numbers such as canvas coordinates with a deci-) 211.88 308.33 T
-(mal point. This can cause syntax errors if you later use them in situations where integers) 152.1 296.33 T
-(are expected.) 152.1 284.33 T
-2 F
-(Solution:) 170.1 272.33 T
-3 F
-(Change your code so that real numbers work OK, or use the) 209.25 272.33 T
-5 F
-(expr) 451.57 272.33 T
-3 F
-( com-) 475.55 272.33 T
-(mand \050with the) 170.1 260.33 T
-5 F
-(round) 233.12 260.33 T
-3 F
-( function\051 to convert the numbers to integers.) 263.1 260.33 T
-1 F
-(Pr) 152.1 245.33 T
-(oblem #29:) 162.46 245.33 T
-3 F
-(The) 211.88 245.33 T
-5 F
-(pack info) 229.92 245.33 T
-3 F
-( command returns dif) 283.89 245.33 T
-(ferent information, and) 369.48 245.33 T
-5 F
-(pack) 464.41 245.33 T
-(newinfo) 152.1 233.33 T
-3 F
-( no longer exists.) 194.08 233.33 T
-2 F
-(Solution:) 170.1 221.33 T
-3 F
-(Use) 209.25 221.33 T
-5 F
-(pack info) 227.29 221.33 T
-3 F
-( where you used to use) 281.26 221.33 T
-5 F
-(pack newinfo) 375.08 221.33 T
-3 F
-(.) 447.04 221.33 T
-5 F
-(Pack info) 452.04 221.33 T
-3 F
-(was obsolete, so it has been eliminated.) 170.1 209.33 T
-1 F
-(Pr) 152.1 194.33 T
-(oblem #30:) 162.46 194.33 T
-3 F
-(The) 211.88 194.33 T
-5 F
-(view) 229.92 194.33 T
-3 F
-( widget command for entries no longer exists, nor does the) 253.9 194.33 T
-5 F
-(-) 152.1 182.33 T
-(scrollcommand) 158.1 182.33 T
-3 F
-( option.) 236.05 182.33 T
-2 F
--0.29 (Solution:) 170.1 170.33 P
-3 F
--0.29 (Use) 208.96 170.33 P
-5 F
--0.69 (xview) 226.71 170.33 P
-3 F
--0.29 ( where you used to use) 256.7 170.33 P
-5 F
--0.69 (view) 348.8 170.33 P
-3 F
--0.29 (; use) 372.78 170.33 P
-5 F
--0.69 (-xscrollcommand) 393.31 170.33 P
-3 F
--0.29 ( where) 483.26 170.33 P
-(you used to use) 170.1 158.33 T
-5 F
-(-scrollcommand) 234.51 158.33 T
-3 F
-(.) 318.46 158.33 T
-FMENDPAGE
-%%EndPage: "19" 20
-%%Page: "20" 20
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(20) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-1 F
-0 X
-(Pr) 152.1 632.33 T
-(oblem #31:) 162.46 632.33 T
-3 F
-(The) 211.88 632.33 T
-5 F
-(-padx) 229.92 632.33 T
-3 F
-( and) 259.9 632.33 T
-5 F
-(-pady) 279.33 632.33 T
-3 F
-( options are ignored for the button family of wid-) 309.31 632.33 T
-(gets if a bitmap or image is being displayed: the padding is always 0.) 152.1 620.02 T
-2 F
--0.27 (Solution:) 170.1 608.02 P
-3 F
--0.27 (Pack the button inside a frame, with extra padding in the frame. Or) 208.98 608.02 P
--0.27 (, redo the) 472.94 608.02 P
-(image or bitmap to incorporate padding into it.) 170.1 595.71 T
-1 F
-(Pr) 152.1 580.71 T
-(oblem #32:) 162.46 580.71 T
-3 F
-(In radiobuttons, the) 211.88 580.71 T
-5 F
-(-value) 292.38 580.71 T
-3 F
-( option no longer defaults to the name of the) 328.36 580.71 T
-(widget; it defaults to an empty string.) 152.1 568.4 T
-2 F
-(Solution:) 170.1 556.4 T
-3 F
-(Specify the widget\325) 209.25 556.4 T
-(s name explicitly as the value of the option.) 286.98 556.4 T
-1 F
-(Pr) 152.1 541.4 T
-(oblem #33:) 162.46 541.4 T
-3 F
-(The) 211.88 541.4 T
-5 F
-(-menu) 229.92 541.4 T
-3 F
-( option for menubuttons and cascade menu entries may refer) 259.9 541.4 T
-(only to a child of the menubutton or menu.) 152.1 529.08 T
-2 F
-(Solution:) 170.1 517.08 T
-3 F
-(Rename menus to meet this requirement.) 209.25 517.08 T
-1 F
-(Pr) 152.1 502.08 T
-(oblem #34:) 162.46 502.08 T
-3 F
-(The interpretation of) 211.88 502.08 T
-5 F
-(@y) 297.09 502.08 T
-3 F
-( in menus has changed: it never returns) 309.08 502.08 T
-5 F
-(none) 467.86 502.08 T
-3 F
-(,) 491.84 502.08 T
-(even if the y-coordinate is outside the menu \050it returns the index of the closest entry\051.) 152.1 489.77 T
-2 F
-(Solution:) 170.1 477.77 T
-3 F
-(If you care about this distinction, check the y-coordinate explicitly to see if) 209.25 477.77 T
--0.17 (it is less than 0 or greater than or equal to the window\325) 170.1 465.46 P
--0.17 (s height \050use) 385.7 465.46 P
-5 F
--0.41 (winfo height) 438.21 465.46 P
-3 F
-(to get the height\051.) 170.1 453.15 T
-1 F
--0.13 (Pr) 152.1 438.15 P
--0.13 (oblem #35:) 162.46 438.15 P
-3 F
--0.13 (The) 211.62 438.15 P
-5 F
--0.3 (invoke) 229.54 438.15 P
-3 F
--0.13 ( and) 265.52 438.15 P
-5 F
--0.3 (activate) 284.7 438.15 P
-3 F
--0.13 ( widget commands for menus no longer post) 332.67 438.15 P
-(cascaded submenus.) 152.1 425.83 T
-2 F
-(Solution:) 170.1 413.83 T
-3 F
-(Use the) 209.25 413.83 T
-5 F
-(postcascade) 242 413.83 T
-3 F
-( widget command to post submenus.) 307.96 413.83 T
-1 F
-(Pr) 152.1 398.83 T
-(oblem #36:) 162.46 398.83 T
-3 F
-(The selection tar) 211.88 398.83 T
-(gets) 278.31 398.83 T
-5 F
-(APPLICATION) 296.91 398.83 T
-3 F
-( and) 362.87 398.83 T
-5 F
-(WINDOW_NAME) 382.3 398.83 T
-3 F
-( are no longer) 448.27 398.83 T
-(supported.) 152.1 386.52 T
-2 F
-(Solution:) 170.1 374.52 T
-3 F
-(Use tar) 209.25 374.52 T
-(gets) 237.65 374.52 T
-5 F
-(TK_APPLICATION) 256.25 374.52 T
-3 F
-( and) 340.21 374.52 T
-5 F
-(TK_WINDOW) 359.64 374.52 T
-3 F
-( instead.) 413.61 374.52 T
-1 F
-(Pr) 152.1 359.52 T
-(oblem #37:) 162.46 359.52 T
-3 F
-(There is no longer a default focus.) 211.88 359.52 T
-2 F
-(Solution:) 170.1 347.52 T
-3 F
-(None: modify your code not to depend on this feature.) 209.25 347.52 T
-1 F
-(Pr) 152.1 332.52 T
-(oblem #38:) 162.46 332.52 T
-3 F
-(The) 211.88 332.52 T
-5 F
-(focus) 229.92 332.52 T
-3 F
-( command now returns an empty string to indicate that the) 259.9 332.52 T
-(application doesn\325) 152.1 320.21 T
-(t have the input focus, instead of) 225.48 320.21 T
-5 F
-(none) 358.17 320.21 T
-3 F
-(.) 382.15 320.21 T
-2 F
-(Solution:) 170.1 308.21 T
-3 F
-(Modify your code to check for an empty string instead of) 209.25 308.21 T
-5 F
-(none) 440.47 308.21 T
-3 F
-(.) 464.46 308.21 T
-1 F
-(Pr) 152.1 293.21 T
-(oblem #39:) 162.46 293.21 T
-5 F
-(FocusIn) 211.88 293.21 T
-3 F
-( and) 253.85 293.21 T
-5 F
-(FocusOut) 273.28 293.21 T
-3 F
-( events are delivered to more windows than) 321.26 293.21 T
-(they used to be.) 152.1 280.9 T
-2 F
--0.02 (Solution:) 170.1 268.9 P
-3 F
--0.02 (Modify your code to use the new set of events. The old event set was some-) 209.23 268.9 P
-(what bizarre, and the new set matches more closely what happens elsewhere, such as) 170.1 256.58 T
-(with) 170.1 244.27 T
-5 F
-(Enter) 190.37 244.27 T
-3 F
-( and) 220.35 244.27 T
-5 F
-(Leave) 239.78 244.27 T
-3 F
-( events.) 269.77 244.27 T
-1 F
--0.28 (Pr) 152.1 229.27 P
--0.28 (oblem #40:) 162.46 229.27 P
-5 F
--0.67 (wm maxsize) 211.32 229.27 P
-3 F
--0.28 ( and) 270.62 229.27 P
-5 F
--0.67 (wm minsize) 289.49 229.27 P
-3 F
--0.28 ( no longer accept empty ar) 348.79 229.27 P
--0.28 (guments. This) 453.52 229.27 P
-(means that you cannot use these commands to make windows non-resizable.) 152.1 216.96 T
-2 F
-(Solution:) 170.1 204.96 T
-3 F
-(Use the) 209.25 204.96 T
-5 F
-(wm resizable) 242 204.96 T
-3 F
-( command to make windows resizable.) 313.96 204.96 T
-1 F
-(Pr) 152.1 189.96 T
-(oblem #41:) 162.46 189.96 T
-3 F
-(In the placer) 211.88 189.96 T
-(, if you specify both) 261.43 189.96 T
-5 F
-(-x) 344.15 189.96 T
-3 F
-( and) 356.15 189.96 T
-5 F
-(-relx) 375.58 189.96 T
-3 F
-( then they add, instead of) 405.56 189.96 T
-(the most recent speci\336cation replacing the earlier one. Ditto for) 152.1 177.65 T
-5 F
-(-y) 407.74 177.65 T
-3 F
-( and) 419.73 177.65 T
-5 F
-(-rely) 439.16 177.65 T
-3 F
-(,) 468.5 177.65 T
-5 F
-(-width) 473.49 177.65 T
-3 F
-(and) 152.1 165.33 T
-5 F
-(-relwidth) 169.03 165.33 T
-3 F
-(, and) 223 165.33 T
-5 F
-(-height) 244.93 165.33 T
-3 F
-( and) 286.91 165.33 T
-5 F
-(-relheight) 306.33 165.33 T
-3 F
-(.) 366.3 165.33 T
-2 F
-(Solution:) 170.1 153.33 T
-3 F
-(If you no longer want one of these options to be used, set it to 0 explicitly) 209.25 153.33 T
-(.) 503.14 153.33 T
-1 F
-(Pr) 152.1 138.33 T
-(oblem #42:) 162.46 138.33 T
-3 F
-(The command \322) 211.88 138.33 T
-5 F
-(focus none) 276.27 138.33 T
-3 F
-(\323 doesn\325) 336.24 138.33 T
-(t work in Tk 4.0.) 369.64 138.33 T
-FMENDPAGE
-%%EndPage: "20" 21
-%%Page: "21" 21
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(13 Summary of Incompatibilites) 98.1 668.33 T
-0 F
-(21) 500.99 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-2 F
-0 X
-(Solution:) 170.1 632.33 T
-3 F
-(Create a dummy widget that is never mapped and set the focus to that wid-) 209.25 632.33 T
-(get.) 170.1 620.33 T
-1 F
-(Pr) 152.1 605.33 T
-(oblem #43:) 162.46 605.33 T
-5 F
-(%D) 211.88 605.33 T
-3 F
-( substitutions are no longer supported in bindings, nor are the event) 223.87 605.33 T
-(types) 152.1 593.33 T
-5 F
-(CirculateRequest) 175.7 593.33 T
-3 F
-(,) 271.64 593.33 T
-5 F
-(Conf) 276.64 593.33 T
-(igureRequest) 300.63 593.33 T
-3 F
-(,) 372.59 593.33 T
-5 F
-(MapRequest) 377.59 593.33 T
-3 F
-(, and) 437.55 593.33 T
-5 F
-(Resiz-) 459.48 593.33 T
-(eRequest) 152.1 581.33 T
-3 F
-(.) 200.07 581.33 T
-2 F
--0.25 (Solution:) 170.1 569.33 P
-3 F
--0.25 (Use the name of the display instead of %D to identify a display; you can get) 209 569.33 P
-(the display name with the) 170.1 557.33 T
-5 F
-(winfo screen) 275.31 557.33 T
-3 F
-( command. The desupported event types) 347.27 557.33 T
-(never really worked anyway) 170.1 545.33 T
-(, so there should be no code that depends on them.) 282.96 545.33 T
-1 F
-(Pr) 152.1 530.33 T
-(oblem #44:) 162.46 530.33 T
-5 F
-(%) 211.88 530.33 T
-3 F
-( binding substitutions that return window identi\336ers, such as) 217.87 530.33 T
-5 F
-(%a) 461.63 530.33 T
-3 F
-( and) 473.62 530.33 T
-5 F
-(%S) 493.05 530.33 T
-3 F
-(,) 505.05 530.33 T
-(now produce hexadecimal results instead of decimal.) 152.1 518.33 T
-2 F
-(Solution:) 170.1 506.33 T
-3 F
-(Use the) 209.25 506.33 T
-5 F
-(format) 242 506.33 T
-3 F
-( command to turn them back to decimal.) 277.98 506.33 T
-1 F
-(Pr) 152.1 491.33 T
-(oblem #45:) 162.46 491.33 T
-5 F
-(Enter) 211.88 491.33 T
-3 F
-(,) 241.46 491.33 T
-5 F
-(Leave) 246.46 491.33 T
-3 F
-(,) 276.44 491.33 T
-5 F
-(FocusIn) 281.44 491.33 T
-3 F
-(, and) 323.42 491.33 T
-5 F
-(FocusOut) 345.34 491.33 T
-3 F
-( events with detail) 393.32 491.33 T
-5 F
-(Notify-) 468.83 491.33 T
-(Inferior) 152.1 479.33 T
-3 F
-( are now ignored by the binding mechanism, so they\325re not visible to T) 200.07 479.33 T
-(cl) 483.08 479.33 T
-(scripts.) 152.1 467.33 T
-2 F
--0.13 (Solution:) 170.1 455.33 P
-3 F
--0.13 (In most cases, T) 209.12 455.33 P
--0.13 (cl scripts work better if these bindings are ignored. Y) 273 455.33 P
--0.13 (ou can) 483.49 455.33 P
-(still use C code to access these events if you really need them. Or) 170.1 443.33 T
-(, create bindings on) 431.18 443.33 T
--0.33 (the inferior windows and use) 170.1 431.33 P
-5 F
--0.8 (NotifyAncestor) 286.96 431.33 P
-3 F
--0.33 ( bindings on the children instead of) 370.91 431.33 P
-5 F
-(NotifyInferior) 170.1 419.33 T
-3 F
-( bindings on the parent.) 254.05 419.33 T
-FMENDPAGE
-%%EndPage: "21" 22
-%%Page: "22" 22
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(22) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-FMENDPAGE
-%%EndPage: "22" 23
-%%Trailer
-%%BoundingBox: 0 0 612 792
-%%Pages: 22 1
-%%DocumentFonts: Helvetica-Bold
-%%+ Times-Bold
-%%+ Times-Italic
-%%+ Times-Roman
-%%+ Helvetica
-%%+ Courier
-%%+ Courier-Oblique

Index: doc/tk_mac.n
==================================================================
--- doc/tk_mac.n
+++ doc/tk_mac.n
@@ -216,15 +216,21 @@
 The Aqua/Mac OS X defines additional dialogs that applications should
 support.
 .TP
 \fB::tk::mac::standardAboutPanel\fR
 .
-Brings the standard Cocoa about panel to the front, with all its information
-filled in from your application bundle files (standard about panel with no
-options specified). See Apple Technote TN2179 and the AppKit documentation for
--[NSApplication orderFrontStandardAboutPanelWithOptions:] for details on the
-Info.plist keys and app bundle files used by the about panel.
+Brings the standard Cocoa about panel to the front with information filled in
+from the application bundle files. The panel displays the application icon and
+the values associated to the info.plist keys named CFBundleName,
+CFBundleShortVersionString, NSAboutPanelOptionVersion and
+NSHumanReadableCopyright.  If a file named \fICredits.html\fR or
+\fICredits.rtf\fR exists in the bundle's Resources directory then its contents
+will be displayed in a scrolling text box at the bottom of the dialog. See the
+documentation for -[NSApplication orderFrontStandardAboutPanelWithOptions:]
+for more details. A hook is also provided for a custom About dialog.  If a Tcl
+proc named tkAboutDialog is defined in the main interpreter then that
+procedure will be called instead of opening the standardAboutPanel.
 .SH "SYSTEM CONFIGURATION"
 .PP
 There are a number of additional global configuration options that control the
 details of how Tk renders by default.
 .TP

Index: doc/tkvars.n
==================================================================
--- doc/tkvars.n
+++ doc/tkvars.n
@@ -24,11 +24,11 @@
 file that is normally processed whenever a Tk application starts up,
 plus other files containing procedures that implement default behaviors
 for widgets.
 .RS
 .PP
-The initial value of \fBtcl_library\fR is set when Tk is added to
+The initial value of \fBtk_library\fR is set when Tk is added to
 an interpreter;  this is done by searching several different directories
 until one is found that contains an appropriate Tk startup script.
 If the \fBTK_LIBRARY\fR environment variable exists, then
 the directory it names is checked first.
 If \fBTK_LIBRARY\fR is not set or does not refer to an appropriate
@@ -48,11 +48,11 @@
 The patch level is incremented for each new release or patch, and
 it uniquely identifies an official version of Tk.
 .RS
 .PP
 This value is normally the same as the result of
-.QW "\fBpackage require\fR \fBTk\fR" .
+.QW "\fBpackage require\fR \fBtk\fR" .
 .RE
 .TP
 \fBtk_strictMotif\fR
 .
 This variable is set to zero by default.

Index: doc/toplevel.n
==================================================================
--- doc/toplevel.n
+++ doc/toplevel.n
@@ -38,11 +38,13 @@
 .VE "8.7, TIP262"
 .OP \-class class Class
 Specifies a class for the window.
 This class will be used when querying the option database for
 the window's other options, and it will also be used later for
-other purposes such as bindings.
+other purposes such as bindings. Some window managers display the
+class name for windows in their dock while some others display the
+window title.
 The \fB\-class\fR option may not be changed with the \fBconfigure\fR
 widget command.
 .OP \-colormap colormap Colormap
 Specifies a colormap to use for the window.
 The value may be either \fBnew\fR, in which case a new colormap is

Index: doc/ttk_button.n
==================================================================
--- doc/ttk_button.n
+++ doc/ttk_button.n
@@ -46,19 +46,28 @@
 .\" .OP \-anchor anchor Anchor
 .\" .OP \-relief relief Relief
 .SH "WIDGET COMMAND"
 .PP
 In addition to the standard
-\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR
-commands, buttons support the following additional widget commands:
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+commands (see \fBttk::widget\fR),
+button widgets support the following additional commands:
 .TP
 \fIpathName \fBinvoke\fR
 Invokes the command associated with the button.
 .SH "STANDARD STYLES"
 .PP
 \fBTtk::button\fR widgets support the \fBToolbutton\fR style in all standard
 themes, which is useful for creating widgets for toolbars.
+.PP
+In the Aqua theme there are several other styles which can be used to
+produce replicas of many of the different button types that are
+discussed in Apple's Human Interface Guidelines.  These include
+\fBDisclosureButton\fR, \fBDisclosureTriangle\fR, \fBHelpButton\fR,
+\fBImageButton\fR, \fBInlineButton\fR, \fBGradientButton\fR,
+\fBRoundedRectButton\fR, and \fBRecessedButton\fR.
 .SH "STYLING OPTIONS"
 .PP
 The class name for a \fBttk::button\fP is \fBTButton\fP.
 .PP
 Dynamic states: \fBactive\fP, \fBdisabled\fP, \fBpressed\fP, \fBreadonly\fP.

Index: doc/ttk_checkbutton.n
==================================================================
--- doc/ttk_checkbutton.n
+++ doc/ttk_checkbutton.n
@@ -35,13 +35,14 @@
 The name of a global variable whose value is linked to the widget.
 Defaults to the widget pathname if not specified.
 .SH "WIDGET COMMAND"
 .PP
 In addition to the standard
-\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR
-commands, checkbuttons support the following additional
-widget commands:
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+commands (see \fBttk::widget\fR),
+checkbutton widgets support the following additional commands:
 .TP
 \fIpathname\fB invoke\fR
 Toggles between the selected and deselected states
 and evaluates the associated \fB\-command\fR.
 If the widget is currently selected, sets the \fB\-variable\fR

Index: doc/ttk_combobox.n
==================================================================
--- doc/ttk_combobox.n
+++ doc/ttk_combobox.n
@@ -53,19 +53,15 @@
 .OP \-width width Width
 Specifies an integer value indicating the desired width of the entry window,
 in average-size characters of the widget's font.
 .SH "WIDGET COMMAND"
 .PP
-The following subcommands are possible for combobox widgets:
-'\".TP
-'\"\fIpathName \fBcget\fR \fIoption\fR
-'\"Returns the current value of the specified \fIoption\fR.
-'\"See \fIttk::widget(n)\fR.
-'\".TP
-'\"\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
-'\"Modify or query widget options.
-'\"See \fIttk::widget(n)\fR.
+In addition to the standard
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+commands (see \fBttk::widget\fR),
+combobox widgets support the following additional commands:
 .TP
 \fIpathName \fBcurrent\fR ?\fInewIndex\fR?
 If \fInewIndex\fR is supplied, sets the combobox value
 to the element at position \fInewIndex\fR in the list of \fB\-values\fR
 (in addition to integers, the \fBend\fR index is supported and indicates
@@ -73,41 +69,22 @@
 Otherwise, returns the index of the current value in the list of
 \fB\-values\fR or \fB\-1\fR if the current value does not appear in the list.
 .TP
 \fIpathName \fBget\fR
 Returns the current value of the combobox.
-'\".TP
-'\"\fIpathName \fBidentify \fIx y\fR
-'\"Returns the name of the element at position \fIx\fR, \fIy\fR.
-'\"See \fIttk::widget(n)\fR.
-'\".TP
-'\"\fIpathName \fBinstate \fIstateSpec\fR ?\fIscript\fR?
-'\"Test the widget state.
-'\"See \fIttk::widget(n)\fR.
 .TP
 \fIpathName \fBset\fR \fIvalue\fR
 Sets the value of the combobox to \fIvalue\fR.
-'\".TP
-'\"\fIpathName \fBstate\fR ?\fIstateSpec\fR?
-'\"Modify or query the widget state.
-'\"See \fIttk::widget(n)\fR.
 .PP
 The combobox widget also supports the following \fBttk::entry\fR
-widget subcommands (see \fIttk::entry(n)\fR for details):
+widget commands:
 .DS
 .ta 5.5c 11c
 \fBbbox\fR	\fBdelete\fR	\fBicursor\fR
 \fBindex\fR	\fBinsert\fR	\fBselection\fR
 \fBxview\fR
 .DE
-The combobox widget also supports the following generic \fBttk::widget\fR
-widget subcommands (see \fIttk::widget(n)\fR for details):
-.DS
-.ta 5.5c 11c
-\fBcget\fR	\fBconfigure\fR	\fBidentify\fR
-\fBinstate\fR	\fBstate\fR
-.DE
 .SH "VIRTUAL EVENTS"
 .PP
 The combobox widget generates a \fB<<ComboboxSelected>>\fR virtual event
 when the user selects an element from the list of values.
 If the selection action unposts the listbox,

Index: doc/ttk_entry.n
==================================================================
--- doc/ttk_entry.n
+++ doc/ttk_entry.n
@@ -137,11 +137,15 @@
 .QW \fBsel.l\fR .
 In general, out-of-range indices are automatically rounded to the
 nearest legal value.
 .SH "WIDGET COMMAND"
 .PP
-The following subcommands are possible for entry widgets:
+In addition to the standard
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR, \fBstyle\fR and \fBxview\fR
+commands (see \fBttk::widget\fR),
+entry widgets support the following additional commands:
 .TP
 \fIpathName \fBbbox \fIindex\fR
 Returns a list of four numbers describing the bounding box of the
 character given by \fIindex\fR.
 The first two elements of the list give the x and y coordinates of
@@ -148,18 +152,10 @@
 the upper-left corner of the screen area covered by the character
 (in pixels relative to the widget) and the last two elements give
 the width and height of the character, in pixels.
 The bounding box may refer to a region outside the visible area
 of the window.
-'\".TP
-'\"\fIpathName \fBcget\fR \fIoption\fR
-'\"Returns the current value of the specified \fIoption\fR.
-'\"See \fIttk::widget(n)\fR.
-'\".TP
-'\"\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
-'\"Modify or query widget options.
-'\"See \fIttk::widget(n)\fR.
 .TP
 \fIpathName \fBdelete \fIfirst \fR?\fIlast\fR?
 Delete one or more elements of the entry.
 \fIFirst\fR is the index of the first character to delete, and
 \fIlast\fR is the index of the character just after the last
@@ -172,25 +168,17 @@
 Returns the entry's string.
 .TP
 \fIpathName \fBicursor \fIindex\fR
 Arrange for the insert cursor to be displayed just before the character
 given by \fIindex\fR.  Returns the empty string.
-'\".TP
-'\"\fIpathName \fBidentify \fIx y\fR
-'\"Returns the name of the element at position \fIx\fR, \fIy\fR,
-'\"or the empty string if the coordinates are outside the window.
 .TP
 \fIpathName \fBindex\fI index\fR
 Returns the numerical index corresponding to \fIindex\fR.
 .TP
 \fIpathName \fBinsert \fIindex string\fR
 Insert \fIstring\fR just before the character
 indicated by \fIindex\fR.  Returns the empty string.
-'\".TP
-'\"\fIpathName \fBinstate \fIstatespec\fR ?\fIscript\fR?
-'\"Test the widget state.
-'\"See \fIttk::widget(n)\fR.
 .TP
 \fIpathName \fBselection \fIoption arg\fR
 This command is used to adjust the selection within an entry.  It
 has several forms, depending on \fIoption\fR:
 .RS
@@ -209,29 +197,17 @@
 the one indexed by \fIstart\fR and ending with the one just
 before \fIend\fR.
 If \fIend\fR refers to the same character as \fIstart\fR or an
 earlier one, then the entry's selection is cleared.
 .RE
-'\".TP
-'\"\fIpathName \fBstate\fR ?\fIstateSpec\fR?
-'\"Modify or query the widget state.
-'\"See \fIttk::widget(n)\fR.
 .TP
 \fIpathName \fBvalidate\fR
 Force revalidation, independent of the conditions specified
 by the \fB\-validate\fR option.
 Returns 0 if validation fails, 1 if it succeeds.
 Sets or clears the \fBinvalid\fR state accordingly.
 See \fBVALIDATION\fR below for more details.
-.PP
-The entry widget also supports the following generic \fBttk::widget\fR
-widget subcommands (see \fIttk::widget(n)\fR for details):
-.DS
-.ta 5.5c 11c
-\fBcget\fR	\fBconfigure\fR	\fBidentify\fR
-\fBinstate\fR	\fBstate\fR	\fBxview\fR
-.DE
 .SH VALIDATION
 .PP
 The \fB\-validate\fR, \fB\-validatecommand\fR, and \fB\-invalidcommand\fR
 options are used to enable entry widget validation.
 .SS "VALIDATION MODES"

Index: doc/ttk_frame.n
==================================================================
--- doc/ttk_frame.n
+++ doc/ttk_frame.n
@@ -33,13 +33,14 @@
 If specified, the widget's requested width in pixels.
 .OP \-height height Height
 If specified, the widget's requested height in pixels.
 .SH "WIDGET COMMAND"
 .PP
-Supports the standard widget commands
-\fBconfigure\fR, \fBcget\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR;
-see \fIttk::widget(n)\fR.
+Frame widgets support the standard commands
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+(see \fBttk::widget\fR).
 .SH "NOTES"
 .PP
 Note that if the \fBpack\fR, \fBgrid\fR, or other geometry managers
 are used to manage the children of the \fBframe\fR,
 by the GM's requested size will normally take precedence

Index: doc/ttk_image.n
==================================================================
--- doc/ttk_image.n
+++ doc/ttk_image.n
@@ -77,17 +77,20 @@
 based on the \fB\-border\fR option.
 The \fB\-border\fR divides the image into 9 regions:
 four fixed corners, top and left edges (which may be tiled horizontally),
 left and right edges (which may be tiled vertically),
 and the central area (which may be tiled in both directions).
+.PP
+An image element that is not meant to claim any space (for example when used
+as a background image) should use \fB\-width 0\fR and \fB\-height 0\fR.
 .SH "EXAMPLE"
 .PP
 .CS
 set img1 [image create photo \-file button.png]
 set img2 [image create photo \-file button-pressed.png]
 set img3 [image create photo \-file button-active.png]
-style element create Button.button image \e
+ttk::style element create Button.button image \e
     [list $img1  pressed $img2  active $img3] \e
     \-border {2 4} \-sticky we
 .CE
 .SH "SEE ALSO"
 ttk::intro(n), ttk::style(n), ttk_vsapi(n), image(n), photo(n)

Index: doc/ttk_label.n
==================================================================
--- doc/ttk_label.n
+++ doc/ttk_label.n
@@ -40,13 +40,14 @@
 then automatic wrapping is not performed; otherwise
 the text is split into lines such that no line is longer
 than the specified value.
 .SH "WIDGET COMMAND"
 .PP
-Supports the standard widget commands
-\fBconfigure\fR, \fBcget\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR;
-see \fIttk::widget(n)\fR.
+Label widgets support the standard commands
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+(see \fBttk::widget\fR).
 .SH "STYLING OPTIONS"
 .PP
 The class name for a \fBttk::label\fP is \fBTLabel\fP.
 .PP
 Dynamic states: \fBdisabled\fP, \fBreadonly\fP.

Index: doc/ttk_labelframe.n
==================================================================
--- doc/ttk_labelframe.n
+++ doc/ttk_labelframe.n
@@ -60,13 +60,14 @@
 sets the keyboard focus to the first child of the \fBttk::labelframe\fR widget.
 .OP \-width width Width
 If specified, the widget's requested width in pixels.
 .SH "WIDGET COMMAND"
 .PP
-Supports the standard widget commands
-\fBconfigure\fR, \fBcget\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR;
-see \fIttk::widget(n)\fR.
+Labelframe widgets support the standard commands
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+(see \fBttk::widget\fR).
 .SH "STYLING OPTIONS"
 .PP
 The class name for a \fBttk::labelframe\fP is \fBTLabelframe\fP.
 The text label
 has a class of \fBTLabelframe.Label\fP.

Index: doc/ttk_menubutton.n
==================================================================
--- doc/ttk_menubutton.n
+++ doc/ttk_menubutton.n
@@ -36,13 +36,14 @@
 .\" not documented: may go away:
 .\" .OP \-anchor anchor Anchor
 .\" .OP \-padding padding Pad
 .SH "WIDGET COMMAND"
 .PP
-Menubutton widgets support the standard
-\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR
-methods.  No other widget methods are used.
+Menubutton widgets support the standard commands
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+(see \fBttk::widget\fR).
 .SH "STANDARD STYLES"
 .PP
 \fBTtk::menubutton\fR widgets support the \fBToolbutton\fR style in all
 standard themes, which is useful for creating widgets for toolbars.
 .SH "STYLING OPTIONS"

Index: doc/ttk_notebook.n
==================================================================
--- doc/ttk_notebook.n
+++ doc/ttk_notebook.n
@@ -100,23 +100,23 @@
 .QW \fBend\fR ,
 which returns the number of tabs
 (only valid for
 .QW "\fIpathname \fBindex\fR" ).
 .SH "WIDGET COMMAND"
+.PP
+In addition to the standard
+\fBcget\fR, \fBconfigure\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+commands (see \fBttk::widget\fR),
+notebook widgets support the following additional commands:
 .TP
 \fIpathname \fBadd \fIwindow\fR ?\fIoptions...\fR?
 Adds a new tab to the notebook.
 See \fBTAB OPTIONS\fR for the list of available \fIoptions\fR.
 If \fIwindow\fR is currently managed by the notebook but hidden,
 it is restored to its previous position.
 .TP
-\fIpathname \fBconfigure\fR ?\fIoptions\fR?
-See \fIttk::widget(n)\fR.
-.TP
-\fIpathname \fBcget \fIoption\fR
-See \fIttk::widget(n)\fR.
-.TP
 \fIpathname \fBforget \fItabid\fR
 Removes the tab specified by \fItabid\fR,
 unmaps and unmanages the associated window.
 .TP
 \fIpathname \fBhide \fItabid\fR
@@ -149,23 +149,17 @@
 or the name of a managed subwindow.
 If \fIsubwindow\fR is already managed by the notebook,
 moves it to the specified position.
 See \fBTAB OPTIONS\fR for the list of available options.
 .TP
-\fIpathname \fBinstate \fIstatespec \fR?\fIscript...\fR?
-See \fIttk::widget(n)\fR.
-.TP
 \fIpathname \fBselect\fR ?\fItabid\fR?
 Selects the specified tab.
 The associated content window will be displayed,
 and the previously-selected window (if different) is unmapped.
 If \fItabid\fR is omitted, returns the widget name of the
 currently selected pane.
 .TP
-\fIpathname \fBstate\fR ?\fIstatespec\fR?
-See \fIttk::widget(n)\fR.
-.TP
 \fIpathname \fBtab \fItabid\fR ?\fI\-option \fR?\fIvalue ...\fR
 Query or modify the options of the specific tab.
 If no \fI\-option\fR is specified,
 returns a dictionary of the tab option values.
 If one \fI\-option\fR is specified,

Index: doc/ttk_panedwindow.n
==================================================================
--- doc/ttk_panedwindow.n
+++ doc/ttk_panedwindow.n
@@ -46,13 +46,16 @@
 .OP \-weight weight Weight
 An integer specifying the relative stretchability of the pane.
 When the paned window is resized, the extra space is added
 or subtracted to each pane proportionally to its \fB\-weight\fR.
 .SH "WIDGET COMMAND"
-Supports the standard \fBconfigure\fR, \fBcget\fR, \fBstate\fR,
-and \fBinstate\fR commands; see \fIttk::widget(n)\fR for details.
-Additional commands:
+.PP
+In addition to the standard
+\fBcget\fR, \fBconfigure\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+commands (see \fBttk::widget\fR),
+panedwindow widgets support the following additional commands:
 .TP
 \fIpathname \fBadd \fIsubwindow options...\fR
 Adds a new pane to the window.
 See \fBPANE OPTIONS\fR for the list of available options.
 .TP
@@ -104,18 +107,10 @@
 .\" Full story: "total size" is either the -height (resp -width),
 .\" or the actual window height (resp actual window width),
 .\" depending on which changed most recently.
 Returns the new position of sash number \fIindex\fR.
 .\" Full story: new position may be different than the requested position.
-.PP
-The panedwindow widget also supports the following generic \fBttk::widget\fR
-widget subcommands (see \fIttk::widget(n)\fR for details):
-.DS
-.ta 5.5c 11c
-\fBcget\fR	\fBconfigure\fR
-\fBinstate\fR	\fBstate\fR
-.DE
 .SH "VIRTUAL EVENTS"
 .PP
 The panedwindow widget generates an \fB<<EnteredChild>>\fR virtual event on
 LeaveNotify/NotifyInferior events, because Tk does not execute binding scripts
 for <Leave> events when the pointer crosses from a parent to a child. The

Index: doc/ttk_progressbar.n
==================================================================
--- doc/ttk_progressbar.n
+++ doc/ttk_progressbar.n
@@ -64,33 +64,22 @@
 If specified to an existing variable, the \fB\-value\fR of the progress bar is
 automatically set to the value of the variable whenever
 the latter is modified.
 .SH "WIDGET COMMAND"
 .PP
-.TP
-\fIpathName \fBcget \fIoption\fR
-Returns the current value of the specified \fIoption\fR; see \fIttk::widget(n)\fR.
-.TP
-\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
-Modify or query widget options; see \fIttk::widget(n)\fR.
-.TP
-\fIpathName \fBidentify \fIx y\fR
-Returns the name of the element at position \fIx\fR, \fIy\fR.
-See \fIttk::widget(n)\fR.
-.TP
-\fIpathName \fBinstate \fIstatespec\fR ?\fIscript\fR?
-Test the widget state; see \fIttk::widget(n)\fR.
+In addition to the standard
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+commands (see \fBttk::widget\fR),
+progressbar widgets support the following additional commands:
 .TP
 \fIpathName \fBstart\fR ?\fIinterval\fR?
 Begin autoincrement mode:
 schedules a recurring timer event that calls \fBstep\fR
 every \fIinterval\fR milliseconds.
 If omitted, \fIinterval\fR defaults to 50 milliseconds (20 steps/second).
 .TP
-\fIpathName \fBstate\fR ?\fIstateSpec\fR?
-Modify or query the widget state; see \fIttk::widget(n)\fR.
-.TP
 \fIpathName \fBstep\fR ?\fIamount\fR?
 Increments the \fB\-value\fR by \fIamount\fR.
 \fIamount\fR defaults to 1.0 if omitted.
 .TP
 \fIpathName \fBstop\fR

Index: doc/ttk_radiobutton.n
==================================================================
--- doc/ttk_radiobutton.n
+++ doc/ttk_radiobutton.n
@@ -35,13 +35,14 @@
 The name of a global variable whose value is linked to the widget.
 Default value is \fB::selectedButton\fR.
 .SH "WIDGET COMMAND"
 .PP
 In addition to the standard
-\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR
-commands, radiobuttons support the following additional
-widget commands:
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+commands (see \fBttk::widget\fR),
+radiobutton widgets support the following additional commands:
 .TP
 \fIpathname\fB invoke\fR
 Sets the \fB\-variable\fR to the \fB\-value\fR, selects the widget,
 and evaluates the associated \fB\-command\fR.
 Returns the result of the \fB\-command\fR, or the empty

Index: doc/ttk_scale.n
==================================================================
--- doc/ttk_scale.n
+++ doc/ttk_scale.n
@@ -49,59 +49,40 @@
 value of the variable changes, the scale will update to reflect this value.
 Whenever the scale is manipulated interactively, the variable will be modified
 to reflect the scale's new value.
 .SH "WIDGET COMMAND"
 .PP
-.TP
-\fIpathName \fBcget \fIoption\fR
-.
-Returns the current value of the specified \fIoption\fR; see
-\fIttk::widget(n)\fR.
-.TP
-\fIpathName \fBconfigure \fR?\fIoption\fR? ?\fIvalue option value ...\fR?
-.
-Modify or query widget options; see \fIttk::widget(n)\fR.
+In addition to the standard
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+commands (see \fBttk::widget\fR),
+scale widgets support the following additional commands:
 .TP
 \fIpathName \fBget \fR?\fIx y\fR?
-.
 Get the current value of the \fB\-value\fR option, or the value corresponding
 to the coordinates \fIx,y\fR if they are specified. \fIX\fR and \fIy\fR are
 pixel coordinates relative to the scale widget origin.
 .TP
-\fIpathName \fBidentify \fIx y\fR
-Returns the name of the element at position \fIx\fR, \fIy\fR.
-See \fIttk::widget(n)\fR.
-.TP
-\fIpathName \fBinstate \fIstatespec\fR ?\fIscript\fR?
-.
-Test the widget state; see \fIttk::widget(n)\fR.
-.TP
 \fIpathName \fBset \fIvalue\fR
-.
 Set the value of the widget (i.e. the \fB\-value\fR option) to \fIvalue\fR.
 The value will be clipped to the range given by the \fB\-from\fR and
 \fB\-to\fR options. Note that setting the linked variable (i.e. the variable
 named in the \fB\-variable\fR option) does not cause such clipping.
-.TP
-\fIpathName \fBstate\fR ?\fIstateSpec\fR?
-.
-Modify or query the widget state; see \fIttk::widget(n)\fR.
 .SH "INTERNAL COMMANDS"
 .PP
 .TP
 \fIpathName \fBcoords \fR?\fIvalue\fR?
-.
 Get the coordinates corresponding to \fIvalue\fR, or the coordinates
 corresponding to the current value of the \fB\-value\fR option if \fIvalue\fR
 is omitted.
 .SH "STYLING OPTIONS"
 .PP
 The class name for a \fBttk::scale\fP is \fBTScale\fP.
 .PP
 Dynamic states: \fBactive\fP.
 .PP
-\fBTProgressbar\fP styling options configurable with \fBttk::style\fP
+\fBTScale\fP styling options configurable with \fBttk::style\fP
 are:
 .PP
 \fB\-background\fP \fIcolor\fP
 .br
 \fB\-borderwidth\fP \fIamount\fP

Index: doc/ttk_scrollbar.n
==================================================================
--- doc/ttk_scrollbar.n
+++ doc/ttk_scrollbar.n
@@ -45,36 +45,25 @@
 .OP \-orient orient Orient
 One of \fBhorizontal\fR or \fBvertical\fR.
 Specifies the orientation of the scrollbar.
 .SH "WIDGET COMMAND"
 .PP
-.TP
-\fIpathName \fBcget \fIoption\fR
-Returns the current value of the specified \fIoption\fR; see \fIttk::widget(n)\fR.
-.TP
-\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
-Modify or query widget options; see \fIttk::widget(n)\fR.
+In addition to the standard
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+commands (see \fBttk::widget\fR),
+scrollbar widgets support the following additional commands:
 .TP
 \fIpathName \fBget\fR
 Returns the scrollbar settings in the form of a list whose
 elements are the arguments to the most recent \fBset\fR widget command.
 .TP
-\fIpathName \fBidentify \fIx y\fR
-Returns the name of the element at position \fIx\fR, \fIy\fR.
-See \fIttk::widget(n)\fR.
-.TP
-\fIpathName \fBinstate \fIstatespec\fR ?\fIscript\fR?
-Test the widget state; see \fIttk::widget(n)\fR.
-.TP
 \fIpathName \fBset \fIfirst last\fR
 This command is normally invoked by the scrollbar's associated widget
 from an \fB\-xscrollcommand\fR or \fB\-yscrollcommand\fR callback.
 Specifies the visible range to be displayed.
 \fIfirst\fR and \fIlast\fR are real fractions between 0 and 1.
-.TP
-\fIpathName \fBstate\fR ?\fIstateSpec\fR?
-Modify or query the widget state; see \fIttk::widget(n)\fR.
 .SH "INTERNAL COMMANDS"
 .PP
 The following widget commands are used internally
 by the \fBTScrollbar\fP widget class bindings.
 .TP

Index: doc/ttk_separator.n
==================================================================
--- doc/ttk_separator.n
+++ doc/ttk_separator.n
@@ -24,13 +24,14 @@
 .OP \-orient orient Orient
 One of \fBhorizontal\fR or \fBvertical\fR.
 Specifies the orientation of the separator.
 .SH "WIDGET COMMAND"
 .PP
-Separator widgets support the standard
-\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR
-methods.  No other widget methods are used.
+Separator widgets support the standard commands
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+(see \fBttk::widget\fR).
 .PP
 .SH "STYLING OPTIONS"
 .PP
 The class name for a \fBttk::separator\fP is \fBTSeparator\fP.
 .PP

Index: doc/ttk_sizegrip.n
==================================================================
--- doc/ttk_sizegrip.n
+++ doc/ttk_sizegrip.n
@@ -21,13 +21,14 @@
 \-class	\-cursor
 \-style	\-takefocus
 .SE
 .SH "WIDGET COMMAND"
 .PP
-Sizegrip widgets support the standard
-\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR
-methods.  No other widget methods are used.
+Sizegrip widgets support the standard commands
+\fBcget\fR, \fBconfigure\fR, \fBidentify element\fR, \fBinstate\fR,
+\fBstate\fR and \fBstyle\fR
+(see \fBttk::widget\fR).
 .SH "PLATFORM-SPECIFIC NOTES"
 .PP
 On Mac OSX, toplevel windows automatically include a built-in
 size grip by default.
 Adding a \fBttk::sizegrip\fR there is harmless, since

Index: doc/ttk_style.n
==================================================================
--- doc/ttk_style.n
+++ doc/ttk_style.n
@@ -13,11 +13,11 @@
 \fBttk::style\fR \fIoption\fR ?\fIargs\fR?
 .BE
 .SH NOTES
 .PP
 See also the Tcl'2004 conference presentation,
-available at https://tktable.sourceforge.net/tile/tile-tcl2004.pdf
+available at http://tktable.sourceforge.net/tile/tile-tcl2004.pdf
 .SH DEFINITIONS
 .PP
 Each widget is assigned a \fIstyle\fR,
 which specifies the set of elements making up the widget
 and how they are arranged, along with dynamic and default
@@ -25,16 +25,24 @@
 By default, the style name is the same as the widget's class;
 this may be overridden by the \fB\-style\fR option.
 .PP
 A \fItheme\fR is a collection of elements and styles
 which controls the overall look and feel of an application.
+The
+.QW .
+style is the theme root style on which derived styles are based.
 .SH DESCRIPTION
 .PP
 The \fBttk::style\fR command takes the following arguments:
 .TP
 \fBttk::style configure \fIstyle\fR ?\fI\-option\fR ?\fIvalue option value...\fR? ?
 Sets the default value of the specified option(s) in \fIstyle\fR.
+If \fIstyle\fR does not exist, it is created.
+If only \fIstyle\fR and \fI-option\fR are specified, get the default value
+for option \fI-option\fR of style \fIstyle\fR.
+If only \fIstyle\fR is specified, get the default value for all options
+of style \fIstyle\fR.
 .TP
 \fBttk::style element\fR \fIargs\fR
 .RS
 .TP
 \fBttk::style element create\fR \fIelementName\fR \fItype\fR ?\fIargs...\fR?
@@ -66,16 +74,22 @@
 .QW normal
 state).
 If the \fIdefault\fR argument is present, it is used as a fallback
 value in case no specification for \fI\-option\fR is found.
 .\" Otherwise -- signal error? return empty string? Leave unspecified for now.
+If \fIstyle\fR does not exist, it is created.
 .TP
 \fBttk::style map \fIstyle\fR ?\fI\-option\fB { \fIstatespec value...\fB }\fR?
-Sets dynamic values of the specified option(s) in \fIstyle\fR.
+Sets dynamic (state dependent) values of the specified option(s) in \fIstyle\fR.
 Each \fIstatespec / value\fR pair is examined in order;
 the value corresponding to the first matching \fIstatespec\fR
 is used.
+If \fIstyle\fR does not exist, it is created.
+If only \fIstyle\fR and \fI-option\fR are specified, get the dynamic values
+for option \fI-option\fR of style \fIstyle\fR.
+If only \fIstyle\fR is specified, get the dynamic values for all options
+of style \fIstyle\fR.
 .TP
 \fBttk::style theme\fR \fIargs\fR
 .RS
 .TP
 \fBttk::style theme create\fR \fIthemeName\fR ?\fB\-parent \fIbasedon\fR? ?\fB\-settings \fIscript...\fR ?
@@ -91,10 +105,14 @@
 \fBttk::style theme settings \fIthemeName\fR \fIscript\fR
 Temporarily sets the current theme to \fIthemeName\fR,
 evaluate \fIscript\fR, then restore the previous theme.
 Typically \fIscript\fR simply defines styles and elements,
 though arbitrary Tcl code may appear.
+.TP
+\fBttk::style theme styles\fR ?\fIthemeName\fR?
+Returns a list of all styles in \fIthemeName\fR. If \fIthemeName\fR
+is omitted, the current theme is used.
 .TP
 \fBttk::style theme use\fR ?\fIthemeName\fR?
 Without an argument the result is the name of the current theme.
 Otherwise this command sets the current theme to \fIthemeName\fR,
 and refreshes all widgets.

Index: doc/ttk_treeview.n
==================================================================
--- doc/ttk_treeview.n
+++ doc/ttk_treeview.n
@@ -74,38 +74,92 @@
 If \fBnone\fR, the selection will not be changed.
 .PP
 Note that application code and tag bindings can set the selection
 however they wish, regardless of the value of \fB\-selectmode\fR.
 .RE
+.OP \-selecttype selectType SelectType
+Controls how the built-in class bindings manage the selection.
+One of \fBitem\fR or \fBcell\fR.
 .OP \-show show Show
 A list containing zero or more of the following values, specifying
 which elements of the tree to display.
 .RS
 .IP \fBtree\fR
 Display tree labels in column #0.
 .IP \fBheadings\fR
 Display the heading row.
 .PP
-The default is \fBtree headings\fR, i.e., show all elements.
+The default is \fBtree headings\fR.
 .PP
 \fBNOTE:\fR Column #0 always refers to the tree column,
 even if \fB\-show tree\fR is not specified.
 .RE
+.OP \-striped striped Striped
+Boolean specifying zebra striped item coloring.
+Note:
+Striped items uses the \fB\-stripedbackground\fR option if set by the theme or a tag.
+If not supported by the current theme, it will not show.
+.OP \-titlecolumns titleColumns TitleColumns
+Number of display columns at the left that should not be scrolled. The tree column counts, even
+if \fB\-show tree\fR is not specified. Thus for value N of this option, column #N is
+the first one that is scrollable. Default is 0.
+.OP \-titleitems titleItems TitleItems
+Number of items at the top that should not be vertically scrolled. Default is 0.
 .SH "WIDGET COMMAND"
 .PP
+In addition to the standard
+\fBcget\fR, \fBconfigure\fR, \fBinstate\fR,
+\fBstate\fR, \fBstyle\fR, \fBxview\fR and \fByview\fR
+commands (see \fBttk::widget\fR),
+treeview widgets support the following additional commands:
 .TP
 \fIpathname \fBbbox \fIitem\fR ?\fIcolumn\fR?
 Returns the bounding box (relative to the treeview widget's window)
 of the specified \fIitem\fR
 in the form \fIx y width height\fR.
-If \fIcolumn\fR is specified, returns the bounding box of that cell.
 If the \fIitem\fR is not visible
-(i.e., if it is a descendant of a closed item or is scrolled offscreen),
+(i.e., if it is a descendant of a closed item or is vertically scrolled offscreen),
 returns the empty list.
+If \fIcolumn\fR is specified and is not hidden (by the \fB\-displaycolumns\fR option),
+returns the bounding box of that cell within \fIitem\fR (even if the cell
+is horizontally scrolled offscreen).
+.TP
+\fIpathname \fBcellselection\fR ?\fIselop arg ...\fR?
+Manages cell selection. Cell selection is independent from item selection
+handled by the \fBselection\fR command. A cell is given by a list of two
+elements, item and column.
+For the rectangle versions of commands, the cells must be in displayed columns.
+Any change to \fB\-columns\fR clears the cell selection.
+A \fIcellList\fR argument may be a single cell or a list of cells.
+If \fIselop\fR is not specified, returns the list of selected cells.
+Otherwise, \fIselop\fR is one of the following:
+.RS
+.TP
+\fIpathname \fBcellselection set \fIcellList\fR
+\fIcellList\fR becomes the new cell selection.
+.TP
+\fIpathname \fBcellselection set \fIfirstCell\fR \fIlastCell\fR
+The rectangle defined becomes the new cell selection.
+.TP
+\fIpathname \fBcellselection add \fIcellList\fR
+Add \fIcellList\fR to the cell selection
+.TP
+\fIpathname \fBcellselection add \fIfirstCell\fR \fIlastCell\fR
+The rectangle defined is added to the cell selection.
+.TP
+\fIpathname \fBcellselection remove \fIcellList\fR
+Remove \fIcellList\fR from the cell selection
+.TP
+\fIpathname \fBcellselection remove \fIfirstCell\fR \fIlastCell\fR
+The rectangle defined is removed from the cell selection.
+.TP
+\fIpathname \fBcellselection toggle \fIcellList\fR
+Toggle the cell selection state of each cell in \fIcellList\fR.
 .TP
-\fIpathname \fBcget \fIoption\fR
-Returns the current value of the specified \fIoption\fR; see \fIttk::widget(n)\fR.
+\fIpathname \fBcellselection toggle \fIfirstCell\fR \fIlastCell\fR
+Toggle the cell selection state of each cell in the rectangle defined.
+.RE
 .TP
 \fIpathname \fBchildren \fIitem\fR ?\fInewchildren\fR?
 If \fInewchildren\fR is not specified,
 returns the list of children belonging to \fIitem\fR.
 .RS
@@ -130,10 +184,11 @@
 .TP
 \fB\-id \fIname\fR
 The column name.  This is a read-only option.
 For example, [\fI$pathname \fBcolumn #\fIn \fB\-id\fR]
 returns the data column associated with display column #\fIn\fR.
+The tree column has -id \fB#0\fR.
 .TP
 \fB\-anchor \fIanchor\fR
 Specifies how the text in this column should be aligned
 with respect to the cell. \fIAnchor\fR is one of
 \fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR,
@@ -141,30 +196,31 @@
 .TP
 \fB\-minwidth \fIminwidth\fR
 The minimum width of the column in pixels.
 The treeview widget will not make the column any smaller than
 \fB\-minwidth\fR when the widget is resized or the user drags a
-column separator.  Default is 20 pixels.
+heading column separator.  Default is 20 pixels.
+.TP
+\fB\-separator \fIboolean\fR
+Specifies whether or not a column separator should be drawn to the right
+of the column.  Default is false.
 .TP
 \fB\-stretch \fIboolean\fR
 Specifies whether or not the column width should be adjusted
-when the widget is resized or the user drags a column separator.
+when the widget is resized or the user drags a heading column separator.
 \fIBoolean\fR may have any of the forms accepted by \fBTcl_GetBoolean\fR.
 By default columns are stretchable.
 .TP
 \fB\-width \fIwidth\fR
 The width of the column in pixels.  Default is 200 pixels. The specified
 column width may be changed by Tk in order to honor \fB\-stretch\fR
 and/or \fB\-minwidth\fR, or when the widget is resized or the user drags a
-column separator.
+heading column separator.
 .PP
 Use \fIpathname column #0\fR to configure the tree column.
 .RE
 .TP
-\fIpathname \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
-Modify or query widget options; see \fIttk::widget(n)\fR.
-.TP
 \fIpathname \fBdelete \fIitemList\fR
 Deletes each of the items in \fIitemList\fR and all of their descendants.
 The root item may not be deleted.
 See also: \fBdetach\fR.
 .TP
@@ -229,17 +285,22 @@
 .IP tree
 The tree area.
 .IP cell
 A data cell.
 .RE
+.TP
 \fIpathname \fBidentify item \fIx y\fR
 Returns the item ID of the item at position \fIy\fR.
 .TP
 \fIpathname \fBidentify column \fIx y\fR
 Returns the display column identifier of the cell at position \fIx\fR.
 The tree column has ID \fB#0\fR.
 .TP
+\fIpathname \fBidentify cell \fIx y\fR
+Returns the cell identifier of the cell at position \fIx y\fR.
+A cell identifier is a list of item ID and column ID.
+.TP
 \fIpathname \fBidentify element \fIx y\fR
 The element at position \fIx,y\fR.
 .TP
 \fIpathname \fBidentify row \fIx y\fR
 Obsolescent synonym for \fIpathname \fBidentify item\fR.
@@ -270,13 +331,10 @@
 \fIpathname \fBinsert\fR returns the item identifier of the
 newly created item.
 See \fBITEM OPTIONS\fR for the list of available options.
 .RE
 .TP
-\fIpathname \fBinstate \fIstatespec\fR ?\fIscript\fR?
-Test the widget state; see \fIttk::widget(n)\fR.
-.TP
 \fIpathname \fBitem \fIitem\fR ?\fI\-option \fR?\fIvalue \-option value...\fR?
 Query or modify the options for the specified \fIitem\fR.
 If no \fI\-option\fR is specified,
 returns a dictionary of option/value pairs.
 If a single \fI\-option\fR is specified,
@@ -311,10 +369,12 @@
 sets all of \fIitem\fR's ancestors to \fB\-open true\fR,
 and scrolls the widget if necessary so that \fIitem\fR is
 within the visible portion of the tree.
 .TP
 \fIpathname \fBselection\fR ?\fIselop itemList\fR?
+Manages item selection. Item selection is independent from cell selection
+handled by the \fBcellselection\fR command.
 If \fIselop\fR is not specified, returns the list of selected items.
 Otherwise, \fIselop\fR is one of the following:
 .RS
 .TP
 \fIpathname \fBselection set \fIitemList\fR
@@ -336,14 +396,17 @@
 With two arguments, returns the current value of the specified \fIcolumn\fR.
 With three arguments, sets the value of column \fIcolumn\fR
 in item \fIitem\fR to the specified \fIvalue\fR.
 See also \fBCOLUMN IDENTIFIERS\fR.
 .TP
-\fIpathname \fBstate\fR ?\fIstateSpec\fR?
-Modify or query the widget state; see \fIttk::widget(n)\fR.
-.TP
 \fIpathName \fBtag \fIargs...\fR
+Manages tags. Tags can be set on items as well as on cells.
+The set of tags is shared between items and cells. However item tagging is
+independent from cell tagging (for instance adding a tag on an item does
+not also add this tag on the cells in that item). Cell tags take precedence
+over item tags when drawing.
+The following subcommands are supported:
 .RS
 .TP
 \fIpathName \fBtag add \fItag items\fR
 Adds the specified \fItag\fR to each of the listed \fIitems\fR.
 If \fItag\fR is already present for a particular item,
@@ -352,10 +415,12 @@
 \fIpathName \fBtag bind \fItagName \fR?\fIsequence\fR? ?\fIscript\fR?
 Add a Tk binding script for the event sequence \fIsequence\fR
 to the tag \fItagName\fR.  When an X event is delivered to an item,
 binding scripts for each of the item's \fB\-tags\fR are evaluated
 in order as per \fIbindtags(n)\fR.
+If the event can be associated with a cell (i.e. mouse events) any
+bindings for the cell's \fB\-tags\fR are evaluated as well.
 .RS
 .PP
 \fB<Key>\fR, \fB<KeyRelease>\fR, and virtual events
 are sent to the focus item.
 \fB<Button>\fR, \fB<ButtonRelease>\fR, and \fB<Motion>\fR events
@@ -363,10 +428,31 @@
 No other event types are supported.
 .PP
 The binding \fIscript\fR undergoes \fB%\fR-substitutions before
 evaluation; see \fBbind(n)\fR for details.
 .RE
+.TP
+\fIpathName \fBtag cell \fIsubcmd...\fR
+Manages tags on individual cells.
+A \fIcellList\fR argument may be a single cell or a list of cells.
+.RS
+.TP
+\fIpathName \fBtag cell add \fItag cellList\fR
+Adds the specified \fItag\fR to each of the listed \fIcellList\fR.
+If \fItag\fR is already present for a particular cell,
+then the tag list for that cell is unchanged.
+.TP
+\fIpathName \fBtag cell has \fItagName\fR ?\fIcell\fR?
+If \fIcell\fR is specified, returns 1 or 0
+depending on whether the specified cell has the named tag.
+Otherwise, returns a list of all cells which have
+the specified tag.
+.TP
+\fIpathName \fBtag cell remove \fItag\fR ?\fIcellList\fR?
+Removes the specified \fItag\fR from each of the listed \fIcellList\fR.
+If \fIcellList\fR is omitted, removes \fItag\fR from each cell in the tree.
+.RE
 .TP
 \fIpathName \fBtag configure \fItagName\fR ?\fIoption\fR? ?\fIvalue option value...\fR?
 Query or modify the options for the specified \fItagName\fR.
 If one or more \fIoption/value\fR pairs are specified,
 sets the value of those options for the specified tag.
@@ -377,11 +463,11 @@
 returns a dictionary of the option settings for \fItagName\fR.
 See \fBTAG OPTIONS\fR for the list of available options.
 .TP
 \fIpathName \fBtag delete \fItagName\fR
 Deletes all tag information for the \fItagName\fR argument. The
-command removes the tag from all items in the widget and also deletes any
+command removes the tag from all items and cells in the widget and also deletes any
 other information associated with the tag, such as bindings and display
 information. The command returns an empty string.
 .TP
 \fIpathName \fBtag has \fItagName\fR ?\fIitem\fR?
 If \fIitem\fR is specified, returns 1 or 0
@@ -396,26 +482,24 @@
 Removes the specified \fItag\fR from each of the listed \fIitems\fR.
 If \fIitems\fR is omitted, removes \fItag\fR from each item in the tree.
 If \fItag\fR is not present for a particular item,
 then the \fB\-tags\fR for that item are unchanged.
 .RE
-.PP
-The treeview widget also supports the following generic \fBttk::widget\fR
-widget subcommands (see \fIttk::widget(n)\fR for details):
-.DS
-.ta 5.5c 11c
-\fBxview\fR	\fByview\fR
-.DE
 .SH "ITEM OPTIONS"
 .PP
 The following item options may be specified for items
 in the \fBinsert\fR and \fBitem\fR widget commands.
-.OP \-text text Text
-The textual label to display for the item.
-.OP \-image image Image
-A Tk image, displayed to the left of the label.
-.OP \-values values Values
+.IP \fB\-text\fR
+The textual label to display for the item in the tree column.
+.IP \fB\-height\fR
+The height for the item, in integer multiples of \fB\-rowheight\fP. Default is 1.
+.IP \fB\-image\fR
+A Tk image, displayed next to the label in the tree column, placed according to \fB-imageanchor\fR.
+.IP \fB\-imageanchor\fR
+Specifies how the \fB-image\fR is displayed relative to the text. Default is \fBw\fR.
+One of the standard Tk anchor values.
+.IP \fB\-values\fR
 The list of values associated with the item.
 .RS
 .PP
 Each item should have the same number of values as
 the \fB\-columns\fR widget option.
@@ -422,14 +506,18 @@
 If there are fewer values than columns,
 the remaining values are assumed empty.
 If there are more values than columns,
 the extra values are ignored.
 .RE
-.OP \-open open Open
+.IP \fB\-hidden\fR
+A boolean value indicating whether this item
+should be displayed (\fB\-hidden false\fR) or hidden (\fB\-hidden true\fR).
+If a parent is hidden, all its decendants are hidden too.
+.IP \fB\-open\fR
 A boolean value indicating whether the item's children
 should be displayed (\fB\-open true\fR) or hidden (\fB\-open false\fR).
-.OP \-tags tags Tags
+.IP \fB\-tags\fR
 A list of tags associated with this item.
 .SH "TAG OPTIONS"
 .PP
 The following options may be specified on tags:
 .IP \fB\-foreground\fR
@@ -436,20 +524,29 @@
 Specifies the text foreground color.
 .IP \fB\-background\fR
 Specifies the cell or item background color.
 .IP \fB\-font\fR
 Specifies the font to use when drawing text.
-.\" ??? Maybe: .IP \-anchor
-.\" ??? Maybe: .IP \-padding
-.\" ??? Maybe: .IP \-text
 .IP \fB\-image\fR
-Specifies the item image, in case the item's \fB\-image\fR option is empty.
+Specifies the cell or item image.
+.IP \fB\-imageanchor\fR
+Specifies the cell or item image anchor.
+.IP \fB\-padding\fR
+Specifies the cell padding. A data cell will have a default padding of {4 0}
+.IP \fB\-stripedbackground\fR
+Specifies the cell or item background color for alternate lines, if \fB\-striped\fR is true.
+.PP
 .\" .PP
 .\" \fI(@@@ TODO: sort out order of precedence for options)\fR
 .PP
-Tag priority is decided by the creation order: tags created first receive
-higher priority.
+Tags on cells have precedence over tags on items. Then, tag priority is
+decided by the creation order: tags created first receive higher priority.
+An item's options, like \fB\-image\fR and \fB\-imageanchor\fR, have priority over tags.
+.SH "IMAGES"
+The -image option on an item, and on an item tag, controls the image next to the label
+in the tree column.
+Other cells can have images through the cell tag -image option.
 .SH "COLUMN IDENTIFIERS"
 .PP
 Column identifiers take any of the following forms:
 .IP \(bu
 A symbolic name from the list of \fB\-columns\fR.
@@ -475,11 +572,14 @@
 Again, \fBcolumn #0 always refers to the tree column\fR.
 .SH "VIRTUAL EVENTS"
 .PP
 The treeview widget generates the following virtual events.
 .IP <<TreeviewSelect>>
-Generated whenever the selection changes.
+Generated whenever the selection or cellselection changes.
+It might also be generated when selection is affected but not actually changed.
+Further, multiple selection changes could happen before events can be processed
+leading to multiple events with the same visible selection.
 .IP <<TreeviewOpen>>
 Generated just before setting the focus item to \fB\-open true\fR.
 .IP <<TreeviewClose>>
 Generated just after setting the focus item to \fB\-open false\fR.
 .PP
@@ -506,26 +606,32 @@
 .br
 \fB\-font\fP \fIfont\fP
 .br
 \fB\-foreground\fP \fIcolor\fP
 .br
-\fB\-rowheight\fP \fIamount\fP
+\fB\-columnseparatorwidth\fP \fIpixels\fP
+.br
+\fB\-rowheight\fP \fIpixels\fP
 .RS
-The \fB\-rowheight\fP value is not corrected by the \fBtk scaling\fP
-value or by the configured font size and must always be set.  Also make
-sure that the \fB\-rowheight\fP is large enough to contain any images.
+This is the standard height for an item.
+If \fB\-rowheight\fP is not set by the style, it is set by measuring an
+item and a cell layout with the style's settings.
+This thus picks up the font and
+any focus ring or padding from the theme's layout.
+The \fB\-rowheight\fP may need to be set to make sure that a row
+is large enough to contain any images.
 .PP
-To adjust the \fB\-rowheight\fP for the Treeview style, use the following code
-after \fBtk scaling\fP has been applied.
-Note that even if you do not support or change \fBtk scaling\fP
-in your program, your users may have it set in their .wishrc.
+Example of how to set \fB\-rowheight\fP, adapting to a font in a similar
+way to how the default value is set:
 .RE
 .PP
 .CS
 ttk::style configure Treeview \\
      \-rowheight [expr {[font metrics \fIfont\fP \-linespace] + 2}]
 .CE
+.br
+\fB\-stripedbackground\fP \fIcolor\fP
 .PP
 \fBHeading\fP styling options configurable with \fBttk::style\fP
 are:
 .PP
 \fB\-background\fP \fIcolor\fP

Index: doc/ttk_widget.n
==================================================================
--- doc/ttk_widget.n
+++ doc/ttk_widget.n
@@ -81,11 +81,11 @@
 Specifies how to display the image relative to the text,
 in the case both \fB\-text\fR and \fB\-image\fR are present.
 If set to the empty string (the default), the rules described in the
 "Elements" section of \fIttk::intro(n)\fR explain which value is actually
 used.
-Valid values are:
+The other valid values are:
 .RS
 .IP text
 Display text only.
 .IP image
 Display image only.
@@ -172,16 +172,14 @@
 but the \fBstate\fR widget command
 does not affect the \fB\-state\fR option.
 .SH COMMANDS
 .TP
 \fIpathName \fBcget \fIoption\fR
-.
 Returns the current value of the configuration option given
 by \fIoption\fR.
 .TP
 \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
-.
 Query or modify the configuration options of the widget.
 If one or more \fIoption\-value\fR pairs are specified,
 then the command modifies the given widget option(s)
 to have the given value(s);
 in this case the command returns an empty string.
@@ -193,29 +191,27 @@
 .\" Note: Ttk widgets don't use TK_OPTION_SYNONYM.
 If no \fIoption\fR is specified, returns a list describing all of
 the available options for \fIpathName\fR.
 .TP
 \fIpathName \fBidentify element \fIx y\fR
-.
 Returns the name of the element under the point given
 by \fIx\fR and \fIy\fR, or an empty string if the point does
 not lie within any element.
 \fIx\fR and \fIy\fR are pixel coordinates relative to the widget.
-Some widgets accept other \fBidentify\fR subcommands.
+Some widgets accept other \fBidentify\fR subcommands described
+in these widgets documentation.
 .TP
 \fIpathName \fBinstate \fIstatespec\fR ?\fIscript\fR?
-.
 Test the widget's state.
 If \fIscript\fR is not specified, returns 1 if
 the widget state matches \fIstatespec\fR and 0 otherwise.
 If \fIscript\fR is specified, equivalent to
 .CS
 if {[\fIpathName\fR instate \fIstateSpec\fR]} \fIscript\fR
 .CE
 .TP
 \fIpathName \fBstate\fR ?\fIstateSpec\fR?
-.
 Modify or inquire widget state.
 If \fIstateSpec\fR is present, sets the widget state:
 for each flag in \fIstateSpec\fR, sets the corresponding flag
 or clears it if prefixed by an exclamation point.
 .RS
@@ -227,10 +223,13 @@
 will restore \fIpathName\fR to the original state.
 If \fIstateSpec\fR is not specified,
 returns a list of the currently-enabled state flags.
 .RE
 .TP
+\fIpathName \fBstyle\fR
+Return the style used by the widget.
+.TP
 \fIpathName \fBxview \fIargs\fR
 This command is used to query and change the horizontal position of the
 content in the widget's window.  It can take any of the following
 forms:
 .RS

Index: doc/wm.n
==================================================================
--- doc/wm.n
+++ doc/wm.n
@@ -118,11 +118,11 @@
 color with some alpha, e.g.
 .QW systemTransparent .
 .PP
 On X11, the following attributes may be set. These are not supported by all
 window managers, and will have no effect under older WMs.
-.\" See http://www.freedesktop.org/Standards/wm-spec
+.\" See https://www.freedesktop.org/wiki/Specifications/wm-spec/
 .TP
 \fB\-type\fR
 .VS 8.6
 Requests that the window should be interpreted by the window manager as being
 of the specified type(s). This may cause the window to be decorated in a
@@ -404,10 +404,41 @@
 leader is iconified.  \fIPathName\fR may be specified as an empty string to
 remove \fIwindow\fR from any group association.  If \fIpathName\fR is
 specified then the command returns an empty string;  otherwise it
 returns the path name of \fIwindow\fR's current group leader, or an empty
 string if \fIwindow\fR is not part of any group.
+.TP
+\fBwm iconbadge \fIwindow\fR \fIbadge\fR
+.
+Sets a badge for the icon of the \fIwindow\fR. The badge can be a positive
+integer number, for instance the number of new or unread messages, or
+an exclamation point denoting attention needed. If the badge is an empty
+string, the badge image is removed from the application icon. Managing
+these changes through bindings, such as <FocusIn>, is the responsibility
+of the developer.
+.RS
+.PP
+On X11, for this command to work,
+the variable \fB::tk::icons::base_icon($window)\fR must be set to the image that is
+being used for the window icon of $window. On Windows and X11, the iconphoto
+images work best at 32x32 or a similar dimension, as
+the badge images are provided by Tk and drawn to overlay the icon images
+using native (Windows) API's or Tk rendering. On macOS, the icon badge is
+rendered by a system API and is not provided by Tk. The icon image itself
+should be higher-resolution, preferably 512 pixels, to avoid being blurry.
+.PP
+The icon badge is intended for display in the Dock (macOS), taskbar
+(Windows) or app panel (X11). On macOS, the last badge called will be
+displayed in the Dock, regardless of how many different icon badges may be
+assigned to different windows. On Windows, the taskbar display depends on
+whether the taskbar buttons are combined or not (this is an OS setting
+available to the user): if combined the behavior is the same as on macOS,
+otherwise each button in the taskbar shows the badge it was assigned.
+Badge display on macOS is configured in the system preferences. App
+panel display behavior on X11 will depend on the window manager and/or
+desktop environment.
+.RE
 .TP
 \fBwm iconbitmap \fIwindow\fR ?\fIbitmap\fR?
 .
 If \fIbitmap\fR is specified, then it names a bitmap in the standard
 forms accepted by Tk (see the \fBTk_GetBitmap\fR manual entry for details).
@@ -479,16 +510,17 @@
 manager may scale provided icons to an appropriate size.
 .RS
 .PP
 On Windows, the images are packed into a Windows icon structure.
 This will override an ico specified to \fBwm iconbitmap\fR, and
-vice versa.
+vice versa. This command sets the taskbar icon for the window.
 .PP
 On X, the images are arranged into the _NET_WM_ICON X property, which
 most modern window managers support.  A \fBwm iconbitmap\fR may exist
 simultaneously.  It is recommended to use not more than 2 icons, placing
-the larger icon first.
+the larger icon first. This command also sets the panel icon for the
+application if the window manager or desktop environment supports it.
 .PP
 On Macintosh, the first image called is loaded into an OSX-native icon
 format, and becomes the application icon in dialogs, the Dock, and
 other contexts. At the
 script level the command will accept only the first image passed in the
@@ -605,40 +637,53 @@
 when a \fBwm geometry\fR command is invoked, unless the source has
 been set explicitly to \fBprogram\fR.
 .TP
 \fBwm protocol \fIwindow\fR ?\fIname\fR? ?\fIcommand\fR?
 .
-This command is used to manage window manager protocols such as
-\fBWM_DELETE_WINDOW\fR.
-\fIName\fR is the name of an atom corresponding to a window manager
-protocol, such as \fBWM_DELETE_WINDOW\fR or \fBWM_SAVE_YOURSELF\fR
-or \fBWM_TAKE_FOCUS\fR.
-If both \fIname\fR and \fIcommand\fR are specified, then \fIcommand\fR
-is associated with the protocol specified by \fIname\fR.
-\fIName\fR will be added to \fIwindow\fR's \fBWM_PROTOCOLS\fR
-property to tell the window manager that the application has a
-protocol handler for \fIname\fR, and \fIcommand\fR will
-be invoked in the future whenever the window manager sends a
-message to the client for that protocol.
-In this case the command returns an empty string.
-If \fIname\fR is specified but \fIcommand\fR is not, then the current
-command for \fIname\fR is returned, or an empty string if there
-is no handler defined for \fIname\fR.
-If \fIcommand\fR is specified as an empty string then the current
-handler for \fIname\fR is deleted and it is removed from the
-\fBWM_PROTOCOLS\fR property on \fIwindow\fR;  an empty string is
-returned.
-Lastly, if neither \fIname\fR nor \fIcommand\fR is specified, the
-command returns a list of all the protocols for which handlers
-are currently defined for \fIwindow\fR.
+This command is used to manage window manager protocols. The \fIname\fR
+argument in the \fBwm protocol\fR command is the name of an atom corresponding
+to a window manager protocol.  Examples include \fBWM_DELETE_WINDOW\fR or
+\fBWM_SAVE_YOURSELF\fR or \fBWM_TAKE_FOCUS\fR.
+.RS
+.PP
+A \fIwindow manager protocol\fR is a class of messages sent from a window
+manager to a Tk application outside of the normal event processing system. The
+main example is the \fBWM_DELETE_WINDOW\fR protocol; these messages are sent
+when the user clicks the close widget in the title bar of a window.  Handlers
+for window manager protocols are installed with the \fBwm protocol\fR
+command. As a rule, if no handler has been installed for a protocol by the
+\fBwm protocol\fR command then all messages of that protocol are ignored. The
+\fBWM_DELETE_WINDOW\fR protocol is an exception to this rule. At start-up Tk
+installs a handler for this protocol, which responds by destroying the
+window. The \fBwm protocol\fR command can be used to replace this default
+handler by one which responds differently.
+.RE
+.RS
+.PP
+The list of available window manager protocols depends on the window manager,
+but all window managers supported by Tk provide \fBWM_DELETE_WINDOW\fR. On the
+Windows platform, a \fBWM_SAVE_YOURSELF\fR message is sent on user logout
+or system restart.
+.RE
 .RS
 .PP
-Tk always defines a protocol handler for \fBWM_DELETE_WINDOW\fR, even if
-you have not asked for one with \fBwm protocol\fR.
-If a \fBWM_DELETE_WINDOW\fR message arrives when you have not defined
-a handler, then Tk handles the message by destroying the window for
-which it was received.
+If both \fIname\fR and \fIcommand\fR are specified, then \fIcommand\fR becomes
+the handler for the protocol specified by \fIname\fR. The atom for \fIname\fR
+will be added to \fIwindow\fR's \fBWM_PROTOCOLS\fR property to tell the window
+manager that the application has a handler for the protocol specified by
+\fIname\fR, and \fIcommand\fR will be invoked in the future whenever the
+window manager sends a message of that protocol to the Tk application.  In
+this case the \fBwm protocol\fR command returns an empty string.  If
+\fIname\fR is specified but \fIcommand\fR is not, then the current handler for
+\fIname\fR is returned, or an empty string if there is no handler defined for
+\fIname\fR (as a special case, the default handler for \fBWM_DELETE_WINDOW\fR
+is not returned).  If \fIcommand\fR is specified as an empty string then the
+atom for \fIname\fR is removed from the \fBWM_PROTOCOLS\fR property of
+\fIwindow\fR and the handler is destroyed; an empty string is returned.
+Lastly, if neither \fIname\fR nor \fIcommand\fR is specified, the
+\fBwm protocol\fR command returns a list of all of the protocols for which
+handlers are currently defined for \fIwindow\fR.
 .RE
 .TP
 \fBwm resizable \fIwindow\fR ?\fIwidth height\fR?
 .
 This command controls whether or not the user may interactively

Index: generic/ks_names.h
==================================================================
--- generic/ks_names.h
+++ generic/ks_names.h
@@ -18,16 +18,11 @@
 { "Return", 0xFF0D },
 { "Pause", 0xFF13 },
 { "Scroll_Lock", 0xFF14 },
 { "Sys_Req", 0xFF15 },
 { "Escape", 0xFF1B },
-{ "Delete", 0xFFFF },
 { "Multi_key", 0xFF20 },
-{ "Codeinput", 0xFF37 },
-{ "SingleCandidate", 0xFF3C },
-{ "MultipleCandidate", 0xFF3D },
-{ "PreviousCandidate", 0xFF3E },
 { "Kanji", 0xFF21 },
 { "Muhenkan", 0xFF22 },
 { "Henkan_Mode", 0xFF23 },
 { "Henkan", 0xFF23 },
 { "Romaji", 0xFF24 },
@@ -41,13 +36,25 @@
 { "Massyo", 0xFF2C },
 { "Kana_Lock", 0xFF2D },
 { "Kana_Shift", 0xFF2E },
 { "Eisu_Shift", 0xFF2F },
 { "Eisu_toggle", 0xFF30 },
-{ "Kanji_Bangou", 0xFF37 },
-{ "Zen_Koho", 0xFF3D },
-{ "Mae_Koho", 0xFF3E },
+{ "Hangul", 0xFF31 },
+{ "Hangul_Start", 0xFF32 },
+{ "Hangul_End", 0xFF33 },
+{ "Hangul_Hanja", 0xFF34 },
+{ "Hangul_Jamo", 0xFF35 },
+{ "Hangul_Romaja", 0xFF36 },
+{ "Codeinput", 0xFF37 },
+{ "Hangul_Jeonja", 0xFF38 },
+{ "Hangul_Banja", 0xFF39 },
+{ "Hangul_PreHanja", 0xFF3A },
+{ "Hangul_PostHanja", 0xFF3B },
+{ "SingleCandidate", 0xFF3C },
+{ "MultipleCandidate", 0xFF3D },
+{ "PreviousCandidate", 0xFF3E },
+{ "Hangul_Special", 0xFF3F },
 { "Home", 0xFF50 },
 { "Left", 0xFF51 },
 { "Up", 0xFF52 },
 { "Right", 0xFF53 },
 { "Down", 0xFF54 },
@@ -55,26 +62,32 @@
 { "Page_Up", 0xFF55 },
 { "Next", 0xFF56 },
 { "Page_Down", 0xFF56 },
 { "End", 0xFF57 },
 { "Begin", 0xFF58 },
-{ "Win_L", 0xFF5B },
-{ "Win_R", 0xFF5C },
-{ "App", 0xFF5D },
 { "Select", 0xFF60 },
 { "Print", 0xFF61 },
 { "Execute", 0xFF62 },
 { "Insert", 0xFF63 },
 { "Undo", 0xFF65 },
 { "Redo", 0xFF66 },
 { "Menu", 0xFF67 },
+#ifndef TK_NO_DEPRECATED
+{ "App", 0xFF67 },
+#endif
 { "Find", 0xFF68 },
 { "Cancel", 0xFF69 },
 { "Help", 0xFF6A },
 { "Break", 0xFF6B },
 { "Mode_switch", 0xFF7E },
+#ifndef TK_NO_DEPRECATED
 { "script_switch", 0xFF7E },
+{ "kana_switch", 0xFF7E },
+{ "Arabic_switch", 0xFF7E },
+{ "Greek_switch", 0xFF7E },
+{ "Hebrew_switch", 0xFF7E },
+#endif
 { "Num_Lock", 0xFF7F },
 { "KP_Space", 0xFF80 },
 { "KP_Tab", 0xFF89 },
 { "KP_Enter", 0xFF8D },
 { "KP_F1", 0xFF91 },
@@ -92,11 +105,10 @@
 { "KP_Page_Down", 0xFF9B },
 { "KP_End", 0xFF9C },
 { "KP_Begin", 0xFF9D },
 { "KP_Insert", 0xFF9E },
 { "KP_Delete", 0xFF9F },
-{ "KP_Equal", 0xFFBD },
 { "KP_Multiply", 0xFFAA },
 { "KP_Add", 0xFFAB },
 { "KP_Separator", 0xFFAC },
 { "KP_Subtract", 0xFFAD },
 { "KP_Decimal", 0xFFAE },
@@ -109,10 +121,11 @@
 { "KP_5", 0xFFB5 },
 { "KP_6", 0xFFB6 },
 { "KP_7", 0xFFB7 },
 { "KP_8", 0xFFB8 },
 { "KP_9", 0xFFB9 },
+{ "KP_Equal", 0xFFBD },
 { "F1", 0xFFBE },
 { "F2", 0xFFBF },
 { "F3", 0xFFC0 },
 { "F4", 0xFFC1 },
 { "F5", 0xFFC2 },
@@ -180,22 +193,35 @@
 { "Meta_L", 0xFFE7 },
 { "Meta_R", 0xFFE8 },
 { "Alt_L", 0xFFE9 },
 { "Alt_R", 0xFFEA },
 { "Super_L", 0xFFEB },
+#ifndef TK_NO_DEPRECATED
+{ "Win_L", 0xFFEB },
+#endif
 { "Super_R", 0xFFEC },
+#ifndef TK_NO_DEPRECATED
+{ "Win_R", 0xFFEC },
+#endif
 { "Hyper_L", 0xFFED },
 { "Hyper_R", 0xFFEE },
+{ "braille_dot_1", 0xFFF1 },
+{ "braille_dot_2", 0xFFF2 },
+{ "braille_dot_3", 0xFFF3 },
+{ "braille_dot_4", 0xFFF4 },
+{ "braille_dot_5", 0xFFF5 },
+{ "braille_dot_6", 0xFFF6 },
+{ "braille_dot_7", 0xFFF7 },
+{ "braille_dot_8", 0xFFF8 },
+{ "braille_dot_9", 0xFFF9 },
+{ "braille_dot_10", 0xFFFA },
+{ "Delete", 0xFFFF },
 { "ISO_Lock", 0xFE01 },
 { "ISO_Level2_Latch", 0xFE02 },
 { "ISO_Level3_Shift", 0xFE03 },
 { "ISO_Level3_Latch", 0xFE04 },
 { "ISO_Level3_Lock", 0xFE05 },
-{ "ISO_Level5_Shift", 0xFE11 },
-{ "ISO_Level5_Latch", 0xFE12 },
-{ "ISO_Level5_Lock", 0xFE13 },
-{ "ISO_Group_Shift", 0xFF7E },
 { "ISO_Group_Latch", 0xFE06 },
 { "ISO_Group_Lock", 0xFE07 },
 { "ISO_Next_Group", 0xFE08 },
 { "ISO_Next_Group_Lock", 0xFE09 },
 { "ISO_Prev_Group", 0xFE0A },
@@ -202,10 +228,13 @@
 { "ISO_Prev_Group_Lock", 0xFE0B },
 { "ISO_First_Group", 0xFE0C },
 { "ISO_First_Group_Lock", 0xFE0D },
 { "ISO_Last_Group", 0xFE0E },
 { "ISO_Last_Group_Lock", 0xFE0F },
+{ "ISO_Level5_Shift", 0xFE11 },
+{ "ISO_Level5_Latch", 0xFE12 },
+{ "ISO_Level5_Lock", 0xFE13 },
 { "ISO_Left_Tab", 0xFE20 },
 { "ISO_Move_Line_Up", 0xFE21 },
 { "ISO_Move_Line_Down", 0xFE22 },
 { "ISO_Partial_Line_Up", 0xFE23 },
 { "ISO_Partial_Line_Down", 0xFE24 },
@@ -258,14 +287,21 @@
 { "dead_belowbreve", 0xFE6B },
 { "dead_belowdiaeresis", 0xFE6C },
 { "dead_invertedbreve", 0xFE6D },
 { "dead_belowcomma", 0xFE6E },
 { "dead_currency", 0xFE6F },
-{ "dead_lowline", 0xFE90 },
-{ "dead_aboveverticalline", 0xFE91 },
-{ "dead_belowverticalline", 0xFE92 },
-{ "dead_longsolidusoverlay", 0xFE93 },
+{ "AccessX_Enable", 0xFE70 },
+{ "AccessX_Feedback_Enable", 0xFE71 },
+{ "RepeatKeys_Enable", 0xFE72 },
+{ "SlowKeys_Enable", 0xFE73 },
+{ "BounceKeys_Enable", 0xFE74 },
+{ "StickyKeys_Enable", 0xFE75 },
+{ "MouseKeys_Enable", 0xFE76 },
+{ "MouseKeys_Accel_Enable", 0xFE77 },
+{ "Overlay1_Enable", 0xFE78 },
+{ "Overlay2_Enable", 0xFE79 },
+{ "AudibleBell_Enable", 0xFE7A },
 { "dead_a", 0xFE80 },
 { "dead_A", 0xFE81 },
 { "dead_e", 0xFE82 },
 { "dead_E", 0xFE83 },
 { "dead_i", 0xFE84 },
@@ -275,26 +311,25 @@
 { "dead_u", 0xFE88 },
 { "dead_U", 0xFE89 },
 { "dead_small_schwa", 0xFE8A },
 { "dead_capital_schwa", 0xFE8B },
 { "dead_greek", 0xFE8C },
+{ "dead_lowline", 0xFE90 },
+{ "dead_aboveverticalline", 0xFE91 },
+{ "dead_belowverticalline", 0xFE92 },
+{ "dead_longsolidusoverlay", 0xFE93 },
+{ "ch", 0xFEA0 },
+{ "Ch", 0xFEA1 },
+{ "CH", 0xFEA2 },
+{ "c_h", 0xFEA3 },
+{ "C_h", 0xFEA4 },
+{ "C_H", 0xFEA5 },
 { "First_Virtual_Screen", 0xFED0 },
 { "Prev_Virtual_Screen", 0xFED1 },
 { "Next_Virtual_Screen", 0xFED2 },
 { "Last_Virtual_Screen", 0xFED4 },
 { "Terminate_Server", 0xFED5 },
-{ "AccessX_Enable", 0xFE70 },
-{ "AccessX_Feedback_Enable", 0xFE71 },
-{ "RepeatKeys_Enable", 0xFE72 },
-{ "SlowKeys_Enable", 0xFE73 },
-{ "BounceKeys_Enable", 0xFE74 },
-{ "StickyKeys_Enable", 0xFE75 },
-{ "MouseKeys_Enable", 0xFE76 },
-{ "MouseKeys_Accel_Enable", 0xFE77 },
-{ "Overlay1_Enable", 0xFE78 },
-{ "Overlay2_Enable", 0xFE79 },
-{ "AudibleBell_Enable", 0xFE7A },
 { "Pointer_Left", 0xFEE0 },
 { "Pointer_Right", 0xFEE1 },
 { "Pointer_Up", 0xFEE2 },
 { "Pointer_Down", 0xFEE3 },
 { "Pointer_UpLeft", 0xFEE4 },
@@ -316,66 +351,35 @@
 { "Pointer_Drag_Dflt", 0xFEF4 },
 { "Pointer_Drag1", 0xFEF5 },
 { "Pointer_Drag2", 0xFEF6 },
 { "Pointer_Drag3", 0xFEF7 },
 { "Pointer_Drag4", 0xFEF8 },
-{ "Pointer_Drag5", 0xFEFD },
 { "Pointer_EnableKeys", 0xFEF9 },
 { "Pointer_Accelerate", 0xFEFA },
 { "Pointer_DfltBtnNext", 0xFEFB },
 { "Pointer_DfltBtnPrev", 0xFEFC },
-{ "ch", 0xFEA0 },
-{ "Ch", 0xFEA1 },
-{ "CH", 0xFEA2 },
-{ "c_h", 0xFEA3 },
-{ "C_h", 0xFEA4 },
-{ "C_H", 0xFEA5 },
-{ "3270_Duplicate", 0xFD01 },
-{ "3270_FieldMark", 0xFD02 },
-{ "3270_Right2", 0xFD03 },
-{ "3270_Left2", 0xFD04 },
-{ "3270_BackTab", 0xFD05 },
-{ "3270_EraseEOF", 0xFD06 },
-{ "3270_EraseInput", 0xFD07 },
-{ "3270_Reset", 0xFD08 },
-{ "3270_Quit", 0xFD09 },
-{ "3270_PA1", 0xFD0A },
-{ "3270_PA2", 0xFD0B },
-{ "3270_PA3", 0xFD0C },
-{ "3270_Test", 0xFD0D },
-{ "3270_Attn", 0xFD0E },
-{ "3270_CursorBlink", 0xFD0F },
-{ "3270_AltCursor", 0xFD10 },
-{ "3270_KeyClick", 0xFD11 },
-{ "3270_Jump", 0xFD12 },
-{ "3270_Ident", 0xFD13 },
-{ "3270_Rule", 0xFD14 },
-{ "3270_Copy", 0xFD15 },
-{ "3270_Play", 0xFD16 },
-{ "3270_Setup", 0xFD17 },
-{ "3270_Record", 0xFD18 },
-{ "3270_ChangeScreen", 0xFD19 },
-{ "3270_DeleteWord", 0xFD1A },
-{ "3270_ExSelect", 0xFD1B },
-{ "3270_CursorSelect", 0xFD1C },
-{ "3270_PrintScreen", 0xFD1D },
-{ "3270_Enter", 0xFD1E },
+{ "Pointer_Drag5", 0xFEFD },
 { "space", 0x20 },
+#ifndef TK_NO_DEPRECATED
 { "exclam", 0x21 },
+#endif
 { "quotedbl", 0x22 },
 { "numbersign", 0x23 },
 { "dollar", 0x24 },
+#ifndef TK_NO_DEPRECATED
 { "percent", 0x25 },
 { "ampersand", 0x26 },
 { "apostrophe", 0x27 },
 { "quoteright", 0x27 },
 { "parenleft", 0x28 },
 { "parenright", 0x29 },
 { "asterisk", 0x2A },
 { "plus", 0x2B },
 { "comma", 0x2C },
+#endif
 { "minus", 0x2D },
+#ifndef TK_NO_DEPRECATED
 { "period", 0x2E },
 { "slash", 0x2F },
 { "0", 0x30 },
 { "1", 0x31 },
 { "2", 0x32 },
@@ -385,14 +389,18 @@
 { "6", 0x36 },
 { "7", 0x37 },
 { "8", 0x38 },
 { "9", 0x39 },
 { "colon", 0x3A },
+#endif
 { "semicolon", 0x3B },
 { "less", 0x3C },
+#ifndef TK_NO_DEPRECATED
 { "equal", 0x3D },
+#endif
 { "greater", 0x3E },
+#ifndef TK_NO_DEPRECATED
 { "question", 0x3F },
 { "at", 0x40 },
 { "A", 0x41 },
 { "B", 0x42 },
 { "C", 0x43 },
@@ -417,13 +425,15 @@
 { "V", 0x56 },
 { "W", 0x57 },
 { "X", 0x58 },
 { "Y", 0x59 },
 { "Z", 0x5A },
+#endif
 { "bracketleft", 0x5B },
 { "backslash", 0x5C },
 { "bracketright", 0x5D },
+#ifndef TK_NO_DEPRECATED
 { "asciicircum", 0x5E },
 { "underscore", 0x5F },
 { "grave", 0x60 },
 { "quoteleft", 0x60 },
 { "a", 0x61 },
@@ -450,15 +460,21 @@
 { "v", 0x76 },
 { "w", 0x77 },
 { "x", 0x78 },
 { "y", 0x79 },
 { "z", 0x7A },
+#endif
 { "braceleft", 0x7B },
+#ifndef TK_NO_DEPRECATED
 { "bar", 0x7C },
+#endif
 { "braceright", 0x7D },
+#ifndef TK_NO_DEPRECATED
 { "asciitilde", 0x7E },
+#endif
 { "nobreakspace", 0xA0 },
+#ifndef TK_NO_DEPRECATED
 { "exclamdown", 0xA1 },
 { "cent", 0xA2 },
 { "sterling", 0xA3 },
 { "currency", 0xA4 },
 { "yen", 0xA5 },
@@ -548,20 +564,18 @@
 { "ocircumflex", 0xF4 },
 { "otilde", 0xF5 },
 { "odiaeresis", 0xF6 },
 { "division", 0xF7 },
 { "oslash", 0xF8 },
-#ifndef TK_NO_DEPRECATED
-{ "ooblique", 0xF8 },
-#endif
 { "ugrave", 0xF9 },
 { "uacute", 0xFA },
 { "ucircumflex", 0xFB },
 { "udiaeresis", 0xFC },
 { "yacute", 0xFD },
 { "thorn", 0xFE },
 { "ydiaeresis", 0xFF },
+#endif /* TK_NO_DEPRECATED */
 { "Aogonek", 0x1A1 },
 { "breve", 0x1A2 },
 { "Lstroke", 0x1A3 },
 { "Lcaron", 0x1A5 },
 { "Sacute", 0x1A6 },
@@ -678,36 +692,10 @@
 { "omacron", 0x3F2 },
 { "kcedilla", 0x3F3 },
 { "uogonek", 0x3F9 },
 { "utilde", 0x3FD },
 { "umacron", 0x3FE },
-{ "Wcircumflex", 0x1000174 },
-{ "wcircumflex", 0x1000175 },
-{ "Ycircumflex", 0x1000176 },
-{ "ycircumflex", 0x1000177 },
-{ "Babovedot", 0x1001E02 },
-{ "babovedot", 0x1001E03 },
-{ "Dabovedot", 0x1001E0A },
-{ "dabovedot", 0x1001E0B },
-{ "Fabovedot", 0x1001E1E },
-{ "fabovedot", 0x1001E1F },
-{ "Mabovedot", 0x1001E40 },
-{ "mabovedot", 0x1001E41 },
-{ "Pabovedot", 0x1001E56 },
-{ "pabovedot", 0x1001E57 },
-{ "Sabovedot", 0x1001E60 },
-{ "sabovedot", 0x1001E61 },
-{ "Tabovedot", 0x1001E6A },
-{ "tabovedot", 0x1001E6B },
-{ "Wgrave", 0x1001E80 },
-{ "wgrave", 0x1001E81 },
-{ "Wacute", 0x1001E82 },
-{ "wacute", 0x1001E83 },
-{ "Wdiaeresis", 0x1001E84 },
-{ "wdiaeresis", 0x1001E85 },
-{ "Ygrave", 0x1001EF2 },
-{ "ygrave", 0x1001EF3 },
 { "OE", 0x13BC },
 { "oe", 0x13BD },
 { "Ydiaeresis", 0x13BE },
 { "overline", 0x47E },
 { "kana_fullstop", 0x4A1 },
@@ -786,40 +774,11 @@
 { "kana_RO", 0x4DB },
 { "kana_WA", 0x4DC },
 { "kana_N", 0x4DD },
 { "voicedsound", 0x4DE },
 { "semivoicedsound", 0x4DF },
-{ "kana_switch", 0xFF7E },
-{ "Farsi_0", 0x10006F0 },
-{ "Farsi_1", 0x10006F1 },
-{ "Farsi_2", 0x10006F2 },
-{ "Farsi_3", 0x10006F3 },
-{ "Farsi_4", 0x10006F4 },
-{ "Farsi_5", 0x10006F5 },
-{ "Farsi_6", 0x10006F6 },
-{ "Farsi_7", 0x10006F7 },
-{ "Farsi_8", 0x10006F8 },
-{ "Farsi_9", 0x10006F9 },
-{ "Arabic_percent", 0x100066A },
-{ "Arabic_superscript_alef", 0x1000670 },
-{ "Arabic_tteh", 0x1000679 },
-{ "Arabic_peh", 0x100067E },
-{ "Arabic_tcheh", 0x1000686 },
-{ "Arabic_ddal", 0x1000688 },
-{ "Arabic_rreh", 0x1000691 },
 { "Arabic_comma", 0x5AC },
-{ "Arabic_fullstop", 0x10006D4 },
-{ "Arabic_0", 0x1000660 },
-{ "Arabic_1", 0x1000661 },
-{ "Arabic_2", 0x1000662 },
-{ "Arabic_3", 0x1000663 },
-{ "Arabic_4", 0x1000664 },
-{ "Arabic_5", 0x1000665 },
-{ "Arabic_6", 0x1000666 },
-{ "Arabic_7", 0x1000667 },
-{ "Arabic_8", 0x1000668 },
-{ "Arabic_9", 0x1000669 },
 { "Arabic_semicolon", 0x5BB },
 { "Arabic_question_mark", 0x5BF },
 { "Arabic_hamza", 0x5C1 },
 { "Arabic_maddaonalef", 0x5C2 },
 { "Arabic_hamzaonalef", 0x5C3 },
@@ -866,54 +825,10 @@
 { "Arabic_fatha", 0x5EE },
 { "Arabic_damma", 0x5EF },
 { "Arabic_kasra", 0x5F0 },
 { "Arabic_shadda", 0x5F1 },
 { "Arabic_sukun", 0x5F2 },
-{ "Arabic_madda_above", 0x1000653 },
-{ "Arabic_hamza_above", 0x1000654 },
-{ "Arabic_hamza_below", 0x1000655 },
-{ "Arabic_jeh", 0x1000698 },
-{ "Arabic_veh", 0x10006A4 },
-{ "Arabic_keheh", 0x10006A9 },
-{ "Arabic_gaf", 0x10006AF },
-{ "Arabic_noon_ghunna", 0x10006BA },
-{ "Arabic_heh_doachashmee", 0x10006BE },
-{ "Farsi_yeh", 0x10006CC },
-{ "Arabic_farsi_yeh", 0x10006CC },
-{ "Arabic_yeh_baree", 0x10006D2 },
-{ "Arabic_heh_goal", 0x10006C1 },
-{ "Arabic_switch", 0xFF7E },
-{ "Cyrillic_GHE_bar", 0x1000492 },
-{ "Cyrillic_ghe_bar", 0x1000493 },
-{ "Cyrillic_ZHE_descender", 0x1000496 },
-{ "Cyrillic_zhe_descender", 0x1000497 },
-{ "Cyrillic_KA_descender", 0x100049A },
-{ "Cyrillic_ka_descender", 0x100049B },
-{ "Cyrillic_KA_vertstroke", 0x100049C },
-{ "Cyrillic_ka_vertstroke", 0x100049D },
-{ "Cyrillic_EN_descender", 0x10004A2 },
-{ "Cyrillic_en_descender", 0x10004A3 },
-{ "Cyrillic_U_straight", 0x10004AE },
-{ "Cyrillic_u_straight", 0x10004AF },
-{ "Cyrillic_U_straight_bar", 0x10004B0 },
-{ "Cyrillic_u_straight_bar", 0x10004B1 },
-{ "Cyrillic_HA_descender", 0x10004B2 },
-{ "Cyrillic_ha_descender", 0x10004B3 },
-{ "Cyrillic_CHE_descender", 0x10004B6 },
-{ "Cyrillic_che_descender", 0x10004B7 },
-{ "Cyrillic_CHE_vertstroke", 0x10004B8 },
-{ "Cyrillic_che_vertstroke", 0x10004B9 },
-{ "Cyrillic_SHHA", 0x10004BA },
-{ "Cyrillic_shha", 0x10004BB },
-{ "Cyrillic_SCHWA", 0x10004D8 },
-{ "Cyrillic_schwa", 0x10004D9 },
-{ "Cyrillic_I_macron", 0x10004E2 },
-{ "Cyrillic_i_macron", 0x10004E3 },
-{ "Cyrillic_O_bar", 0x10004E8 },
-{ "Cyrillic_o_bar", 0x10004E9 },
-{ "Cyrillic_U_macron", 0x10004EE },
-{ "Cyrillic_u_macron", 0x10004EF },
 { "Serbian_dje", 0x6A1 },
 { "Macedonia_gje", 0x6A2 },
 { "Cyrillic_io", 0x6A3 },
 { "Ukrainian_ie", 0x6A4 },
 #ifndef TK_NO_DEPRECATED
@@ -1052,11 +967,13 @@
 { "Greek_ALPHAaccent", 0x7A1 },
 { "Greek_EPSILONaccent", 0x7A2 },
 { "Greek_ETAaccent", 0x7A3 },
 { "Greek_IOTAaccent", 0x7A4 },
 { "Greek_IOTAdieresis", 0x7A5 },
+#ifndef TK_NO_DEPRECATED
 { "Greek_IOTAdiaeresis", 0x7A5 },
+#endif
 { "Greek_IOTAaccentdiaeresis", 0x7A6 },
 { "Greek_OMICRONaccent", 0x7A7 },
 { "Greek_UPSILONaccent", 0x7A8 },
 { "Greek_UPSILONdieresis", 0x7A9 },
 { "Greek_UPSILONaccentdieresis", 0x7AA },
@@ -1123,11 +1040,10 @@
 { "Greek_upsilon", 0x7F5 },
 { "Greek_phi", 0x7F6 },
 { "Greek_chi", 0x7F7 },
 { "Greek_psi", 0x7F8 },
 { "Greek_omega", 0x7F9 },
-{ "Greek_switch", 0xFF7E },
 { "leftradical", 0x8A1 },
 { "topleftradical", 0x8A2 },
 { "horizconnector", 0x8A3 },
 { "topintegral", 0x8A4 },
 { "botintegral", 0x8A5 },
@@ -1361,11 +1277,10 @@
 { "hebrew_shin", 0xCF9 },
 { "hebrew_taw", 0xCFA },
 #ifndef TK_NO_DEPRECATED
 { "hebrew_taf", 0xCFA },
 #endif
-{ "Hebrew_switch", 0xFF7E },
 { "Thai_kokai", 0xDA1 },
 { "Thai_khokhai", 0xDA2 },
 { "Thai_khokhuat", 0xDA3 },
 { "Thai_khokhwai", 0xDA4 },
 { "Thai_khokhon", 0xDA5 },
@@ -1446,26 +1361,10 @@
 { "Thai_lekha", 0xDF5 },
 { "Thai_lekhok", 0xDF6 },
 { "Thai_lekchet", 0xDF7 },
 { "Thai_lekpaet", 0xDF8 },
 { "Thai_lekkao", 0xDF9 },
-{ "Hangul", 0xFF31 },
-{ "Hangul_Start", 0xFF32 },
-{ "Hangul_End", 0xFF33 },
-{ "Hangul_Hanja", 0xFF34 },
-{ "Hangul_Jamo", 0xFF35 },
-{ "Hangul_Romaja", 0xFF36 },
-{ "Hangul_Codeinput", 0xFF37 },
-{ "Hangul_Jeonja", 0xFF38 },
-{ "Hangul_Banja", 0xFF39 },
-{ "Hangul_PreHanja", 0xFF3A },
-{ "Hangul_PostHanja", 0xFF3B },
-{ "Hangul_SingleCandidate", 0xFF3C },
-{ "Hangul_MultipleCandidate", 0xFF3D },
-{ "Hangul_PreviousCandidate", 0xFF3E },
-{ "Hangul_Special", 0xFF3F },
-{ "Hangul_switch", 0xFF7E },
 { "Hangul_Kiyeog", 0xEA1 },
 { "Hangul_SsangKiyeog", 0xEA2 },
 { "Hangul_KiyeogSios", 0xEA3 },
 { "Hangul_Nieun", 0xEA4 },
 { "Hangul_NieunJieuj", 0xEA5 },
@@ -1553,640 +1452,10 @@
 { "Hangul_AraeAE", 0xEF7 },
 { "Hangul_J_PanSios", 0xEF8 },
 { "Hangul_J_KkogjiDalrinIeung", 0xEF9 },
 { "Hangul_J_YeorinHieuh", 0xEFA },
 { "Korean_Won", 0xEFF },
-{ "Armenian_ligature_ew", 0x1000587 },
-{ "Armenian_full_stop", 0x1000589 },
-{ "Armenian_verjaket", 0x1000589 },
-{ "Armenian_separation_mark", 0x100055D },
-{ "Armenian_but", 0x100055D },
-{ "Armenian_hyphen", 0x100058A },
-{ "Armenian_yentamna", 0x100058A },
-{ "Armenian_exclam", 0x100055C },
-{ "Armenian_amanak", 0x100055C },
-{ "Armenian_accent", 0x100055B },
-{ "Armenian_shesht", 0x100055B },
-{ "Armenian_question", 0x100055E },
-{ "Armenian_paruyk", 0x100055E },
-{ "Armenian_AYB", 0x1000531 },
-{ "Armenian_ayb", 0x1000561 },
-{ "Armenian_BEN", 0x1000532 },
-{ "Armenian_ben", 0x1000562 },
-{ "Armenian_GIM", 0x1000533 },
-{ "Armenian_gim", 0x1000563 },
-{ "Armenian_DA", 0x1000534 },
-{ "Armenian_da", 0x1000564 },
-{ "Armenian_YECH", 0x1000535 },
-{ "Armenian_yech", 0x1000565 },
-{ "Armenian_ZA", 0x1000536 },
-{ "Armenian_za", 0x1000566 },
-{ "Armenian_E", 0x1000537 },
-{ "Armenian_e", 0x1000567 },
-{ "Armenian_AT", 0x1000538 },
-{ "Armenian_at", 0x1000568 },
-{ "Armenian_TO", 0x1000539 },
-{ "Armenian_to", 0x1000569 },
-{ "Armenian_ZHE", 0x100053A },
-{ "Armenian_zhe", 0x100056A },
-{ "Armenian_INI", 0x100053B },
-{ "Armenian_ini", 0x100056B },
-{ "Armenian_LYUN", 0x100053C },
-{ "Armenian_lyun", 0x100056C },
-{ "Armenian_KHE", 0x100053D },
-{ "Armenian_khe", 0x100056D },
-{ "Armenian_TSA", 0x100053E },
-{ "Armenian_tsa", 0x100056E },
-{ "Armenian_KEN", 0x100053F },
-{ "Armenian_ken", 0x100056F },
-{ "Armenian_HO", 0x1000540 },
-{ "Armenian_ho", 0x1000570 },
-{ "Armenian_DZA", 0x1000541 },
-{ "Armenian_dza", 0x1000571 },
-{ "Armenian_GHAT", 0x1000542 },
-{ "Armenian_ghat", 0x1000572 },
-{ "Armenian_TCHE", 0x1000543 },
-{ "Armenian_tche", 0x1000573 },
-{ "Armenian_MEN", 0x1000544 },
-{ "Armenian_men", 0x1000574 },
-{ "Armenian_HI", 0x1000545 },
-{ "Armenian_hi", 0x1000575 },
-{ "Armenian_NU", 0x1000546 },
-{ "Armenian_nu", 0x1000576 },
-{ "Armenian_SHA", 0x1000547 },
-{ "Armenian_sha", 0x1000577 },
-{ "Armenian_VO", 0x1000548 },
-{ "Armenian_vo", 0x1000578 },
-{ "Armenian_CHA", 0x1000549 },
-{ "Armenian_cha", 0x1000579 },
-{ "Armenian_PE", 0x100054A },
-{ "Armenian_pe", 0x100057A },
-{ "Armenian_JE", 0x100054B },
-{ "Armenian_je", 0x100057B },
-{ "Armenian_RA", 0x100054C },
-{ "Armenian_ra", 0x100057C },
-{ "Armenian_SE", 0x100054D },
-{ "Armenian_se", 0x100057D },
-{ "Armenian_VEV", 0x100054E },
-{ "Armenian_vev", 0x100057E },
-{ "Armenian_TYUN", 0x100054F },
-{ "Armenian_tyun", 0x100057F },
-{ "Armenian_RE", 0x1000550 },
-{ "Armenian_re", 0x1000580 },
-{ "Armenian_TSO", 0x1000551 },
-{ "Armenian_tso", 0x1000581 },
-{ "Armenian_VYUN", 0x1000552 },
-{ "Armenian_vyun", 0x1000582 },
-{ "Armenian_PYUR", 0x1000553 },
-{ "Armenian_pyur", 0x1000583 },
-{ "Armenian_KE", 0x1000554 },
-{ "Armenian_ke", 0x1000584 },
-{ "Armenian_O", 0x1000555 },
-{ "Armenian_o", 0x1000585 },
-{ "Armenian_FE", 0x1000556 },
-{ "Armenian_fe", 0x1000586 },
-{ "Armenian_apostrophe", 0x100055A },
-{ "Georgian_an", 0x10010D0 },
-{ "Georgian_ban", 0x10010D1 },
-{ "Georgian_gan", 0x10010D2 },
-{ "Georgian_don", 0x10010D3 },
-{ "Georgian_en", 0x10010D4 },
-{ "Georgian_vin", 0x10010D5 },
-{ "Georgian_zen", 0x10010D6 },
-{ "Georgian_tan", 0x10010D7 },
-{ "Georgian_in", 0x10010D8 },
-{ "Georgian_kan", 0x10010D9 },
-{ "Georgian_las", 0x10010DA },
-{ "Georgian_man", 0x10010DB },
-{ "Georgian_nar", 0x10010DC },
-{ "Georgian_on", 0x10010DD },
-{ "Georgian_par", 0x10010DE },
-{ "Georgian_zhar", 0x10010DF },
-{ "Georgian_rae", 0x10010E0 },
-{ "Georgian_san", 0x10010E1 },
-{ "Georgian_tar", 0x10010E2 },
-{ "Georgian_un", 0x10010E3 },
-{ "Georgian_phar", 0x10010E4 },
-{ "Georgian_khar", 0x10010E5 },
-{ "Georgian_ghan", 0x10010E6 },
-{ "Georgian_qar", 0x10010E7 },
-{ "Georgian_shin", 0x10010E8 },
-{ "Georgian_chin", 0x10010E9 },
-{ "Georgian_can", 0x10010EA },
-{ "Georgian_jil", 0x10010EB },
-{ "Georgian_cil", 0x10010EC },
-{ "Georgian_char", 0x10010ED },
-{ "Georgian_xan", 0x10010EE },
-{ "Georgian_jhan", 0x10010EF },
-{ "Georgian_hae", 0x10010F0 },
-{ "Georgian_he", 0x10010F1 },
-{ "Georgian_hie", 0x10010F2 },
-{ "Georgian_we", 0x10010F3 },
-{ "Georgian_har", 0x10010F4 },
-{ "Georgian_hoe", 0x10010F5 },
-{ "Georgian_fi", 0x10010F6 },
-{ "Xabovedot", 0x1001E8A },
-{ "Ibreve", 0x100012C },
-{ "Zstroke", 0x10001B5 },
-{ "Gcaron", 0x10001E6 },
-{ "Ocaron", 0x10001D1 },
-{ "Obarred", 0x100019F },
-{ "xabovedot", 0x1001E8B },
-{ "ibreve", 0x100012D },
-{ "zstroke", 0x10001B6 },
-{ "gcaron", 0x10001E7 },
-{ "ocaron", 0x10001D2 },
-{ "obarred", 0x1000275 },
-{ "SCHWA", 0x100018F },
-{ "schwa", 0x1000259 },
-{ "EZH", 0x10001B7 },
-{ "ezh", 0x1000292 },
-{ "Lbelowdot", 0x1001E36 },
-{ "lbelowdot", 0x1001E37 },
-{ "Abelowdot", 0x1001EA0 },
-{ "abelowdot", 0x1001EA1 },
-{ "Ahook", 0x1001EA2 },
-{ "ahook", 0x1001EA3 },
-{ "Acircumflexacute", 0x1001EA4 },
-{ "acircumflexacute", 0x1001EA5 },
-{ "Acircumflexgrave", 0x1001EA6 },
-{ "acircumflexgrave", 0x1001EA7 },
-{ "Acircumflexhook", 0x1001EA8 },
-{ "acircumflexhook", 0x1001EA9 },
-{ "Acircumflextilde", 0x1001EAA },
-{ "acircumflextilde", 0x1001EAB },
-{ "Acircumflexbelowdot", 0x1001EAC },
-{ "acircumflexbelowdot", 0x1001EAD },
-{ "Abreveacute", 0x1001EAE },
-{ "abreveacute", 0x1001EAF },
-{ "Abrevegrave", 0x1001EB0 },
-{ "abrevegrave", 0x1001EB1 },
-{ "Abrevehook", 0x1001EB2 },
-{ "abrevehook", 0x1001EB3 },
-{ "Abrevetilde", 0x1001EB4 },
-{ "abrevetilde", 0x1001EB5 },
-{ "Abrevebelowdot", 0x1001EB6 },
-{ "abrevebelowdot", 0x1001EB7 },
-{ "Ebelowdot", 0x1001EB8 },
-{ "ebelowdot", 0x1001EB9 },
-{ "Ehook", 0x1001EBA },
-{ "ehook", 0x1001EBB },
-{ "Etilde", 0x1001EBC },
-{ "etilde", 0x1001EBD },
-{ "Ecircumflexacute", 0x1001EBE },
-{ "ecircumflexacute", 0x1001EBF },
-{ "Ecircumflexgrave", 0x1001EC0 },
-{ "ecircumflexgrave", 0x1001EC1 },
-{ "Ecircumflexhook", 0x1001EC2 },
-{ "ecircumflexhook", 0x1001EC3 },
-{ "Ecircumflextilde", 0x1001EC4 },
-{ "ecircumflextilde", 0x1001EC5 },
-{ "Ecircumflexbelowdot", 0x1001EC6 },
-{ "ecircumflexbelowdot", 0x1001EC7 },
-{ "Ihook", 0x1001EC8 },
-{ "ihook", 0x1001EC9 },
-{ "Ibelowdot", 0x1001ECA },
-{ "ibelowdot", 0x1001ECB },
-{ "Obelowdot", 0x1001ECC },
-{ "obelowdot", 0x1001ECD },
-{ "Ohook", 0x1001ECE },
-{ "ohook", 0x1001ECF },
-{ "Ocircumflexacute", 0x1001ED0 },
-{ "ocircumflexacute", 0x1001ED1 },
-{ "Ocircumflexgrave", 0x1001ED2 },
-{ "ocircumflexgrave", 0x1001ED3 },
-{ "Ocircumflexhook", 0x1001ED4 },
-{ "ocircumflexhook", 0x1001ED5 },
-{ "Ocircumflextilde", 0x1001ED6 },
-{ "ocircumflextilde", 0x1001ED7 },
-{ "Ocircumflexbelowdot", 0x1001ED8 },
-{ "ocircumflexbelowdot", 0x1001ED9 },
-{ "Ohornacute", 0x1001EDA },
-{ "ohornacute", 0x1001EDB },
-{ "Ohorngrave", 0x1001EDC },
-{ "ohorngrave", 0x1001EDD },
-{ "Ohornhook", 0x1001EDE },
-{ "ohornhook", 0x1001EDF },
-{ "Ohorntilde", 0x1001EE0 },
-{ "ohorntilde", 0x1001EE1 },
-{ "Ohornbelowdot", 0x1001EE2 },
-{ "ohornbelowdot", 0x1001EE3 },
-{ "Ubelowdot", 0x1001EE4 },
-{ "ubelowdot", 0x1001EE5 },
-{ "Uhook", 0x1001EE6 },
-{ "uhook", 0x1001EE7 },
-{ "Uhornacute", 0x1001EE8 },
-{ "uhornacute", 0x1001EE9 },
-{ "Uhorngrave", 0x1001EEA },
-{ "uhorngrave", 0x1001EEB },
-{ "Uhornhook", 0x1001EEC },
-{ "uhornhook", 0x1001EED },
-{ "Uhorntilde", 0x1001EEE },
-{ "uhorntilde", 0x1001EEF },
-{ "Uhornbelowdot", 0x1001EF0 },
-{ "uhornbelowdot", 0x1001EF1 },
-{ "Ybelowdot", 0x1001EF4 },
-{ "ybelowdot", 0x1001EF5 },
-{ "Yhook", 0x1001EF6 },
-{ "yhook", 0x1001EF7 },
-{ "Ytilde", 0x1001EF8 },
-{ "ytilde", 0x1001EF9 },
-{ "Ohorn", 0x10001A0 },
-{ "ohorn", 0x10001A1 },
-{ "Uhorn", 0x10001AF },
-{ "uhorn", 0x10001B0 },
-{ "EcuSign", 0x10020A0 },
-{ "ColonSign", 0x10020A1 },
-{ "CruzeiroSign", 0x10020A2 },
-{ "FFrancSign", 0x10020A3 },
-{ "LiraSign", 0x10020A4 },
-{ "MillSign", 0x10020A5 },
-{ "NairaSign", 0x10020A6 },
-{ "PesetaSign", 0x10020A7 },
-{ "RupeeSign", 0x10020A8 },
-{ "WonSign", 0x10020A9 },
-{ "NewSheqelSign", 0x10020AA },
-{ "DongSign", 0x10020AB },
-{ "EuroSign", 0x20AC },
-{ "zerosuperior", 0x1002070 },
-{ "foursuperior", 0x1002074 },
-{ "fivesuperior", 0x1002075 },
-{ "sixsuperior", 0x1002076 },
-{ "sevensuperior", 0x1002077 },
-{ "eightsuperior", 0x1002078 },
-{ "ninesuperior", 0x1002079 },
-{ "zerosubscript", 0x1002080 },
-{ "onesubscript", 0x1002081 },
-{ "twosubscript", 0x1002082 },
-{ "threesubscript", 0x1002083 },
-{ "foursubscript", 0x1002084 },
-{ "fivesubscript", 0x1002085 },
-{ "sixsubscript", 0x1002086 },
-{ "sevensubscript", 0x1002087 },
-{ "eightsubscript", 0x1002088 },
-{ "ninesubscript", 0x1002089 },
-{ "partdifferential", 0x1002202 },
-{ "emptyset", 0x1002205 },
-{ "elementof", 0x1002208 },
-{ "notelementof", 0x1002209 },
-{ "containsas", 0x100220B },
-{ "squareroot", 0x100221A },
-{ "cuberoot", 0x100221B },
-{ "fourthroot", 0x100221C },
-{ "dintegral", 0x100222C },
-{ "tintegral", 0x100222D },
-{ "because", 0x1002235 },
-{ "approxeq", 0x1002248 },
-{ "notapproxeq", 0x1002247 },
-{ "notidentical", 0x1002262 },
-{ "stricteq", 0x1002263 },
-{ "braille_dot_1", 0xFFF1 },
-{ "braille_dot_2", 0xFFF2 },
-{ "braille_dot_3", 0xFFF3 },
-{ "braille_dot_4", 0xFFF4 },
-{ "braille_dot_5", 0xFFF5 },
-{ "braille_dot_6", 0xFFF6 },
-{ "braille_dot_7", 0xFFF7 },
-{ "braille_dot_8", 0xFFF8 },
-{ "braille_dot_9", 0xFFF9 },
-{ "braille_dot_10", 0xFFFA },
-{ "braille_blank", 0x1002800 },
-{ "braille_dots_1", 0x1002801 },
-{ "braille_dots_2", 0x1002802 },
-{ "braille_dots_12", 0x1002803 },
-{ "braille_dots_3", 0x1002804 },
-{ "braille_dots_13", 0x1002805 },
-{ "braille_dots_23", 0x1002806 },
-{ "braille_dots_123", 0x1002807 },
-{ "braille_dots_4", 0x1002808 },
-{ "braille_dots_14", 0x1002809 },
-{ "braille_dots_24", 0x100280A },
-{ "braille_dots_124", 0x100280B },
-{ "braille_dots_34", 0x100280C },
-{ "braille_dots_134", 0x100280D },
-{ "braille_dots_234", 0x100280E },
-{ "braille_dots_1234", 0x100280F },
-{ "braille_dots_5", 0x1002810 },
-{ "braille_dots_15", 0x1002811 },
-{ "braille_dots_25", 0x1002812 },
-{ "braille_dots_125", 0x1002813 },
-{ "braille_dots_35", 0x1002814 },
-{ "braille_dots_135", 0x1002815 },
-{ "braille_dots_235", 0x1002816 },
-{ "braille_dots_1235", 0x1002817 },
-{ "braille_dots_45", 0x1002818 },
-{ "braille_dots_145", 0x1002819 },
-{ "braille_dots_245", 0x100281A },
-{ "braille_dots_1245", 0x100281B },
-{ "braille_dots_345", 0x100281C },
-{ "braille_dots_1345", 0x100281D },
-{ "braille_dots_2345", 0x100281E },
-{ "braille_dots_12345", 0x100281F },
-{ "braille_dots_6", 0x1002820 },
-{ "braille_dots_16", 0x1002821 },
-{ "braille_dots_26", 0x1002822 },
-{ "braille_dots_126", 0x1002823 },
-{ "braille_dots_36", 0x1002824 },
-{ "braille_dots_136", 0x1002825 },
-{ "braille_dots_236", 0x1002826 },
-{ "braille_dots_1236", 0x1002827 },
-{ "braille_dots_46", 0x1002828 },
-{ "braille_dots_146", 0x1002829 },
-{ "braille_dots_246", 0x100282A },
-{ "braille_dots_1246", 0x100282B },
-{ "braille_dots_346", 0x100282C },
-{ "braille_dots_1346", 0x100282D },
-{ "braille_dots_2346", 0x100282E },
-{ "braille_dots_12346", 0x100282F },
-{ "braille_dots_56", 0x1002830 },
-{ "braille_dots_156", 0x1002831 },
-{ "braille_dots_256", 0x1002832 },
-{ "braille_dots_1256", 0x1002833 },
-{ "braille_dots_356", 0x1002834 },
-{ "braille_dots_1356", 0x1002835 },
-{ "braille_dots_2356", 0x1002836 },
-{ "braille_dots_12356", 0x1002837 },
-{ "braille_dots_456", 0x1002838 },
-{ "braille_dots_1456", 0x1002839 },
-{ "braille_dots_2456", 0x100283A },
-{ "braille_dots_12456", 0x100283B },
-{ "braille_dots_3456", 0x100283C },
-{ "braille_dots_13456", 0x100283D },
-{ "braille_dots_23456", 0x100283E },
-{ "braille_dots_123456", 0x100283F },
-{ "braille_dots_7", 0x1002840 },
-{ "braille_dots_17", 0x1002841 },
-{ "braille_dots_27", 0x1002842 },
-{ "braille_dots_127", 0x1002843 },
-{ "braille_dots_37", 0x1002844 },
-{ "braille_dots_137", 0x1002845 },
-{ "braille_dots_237", 0x1002846 },
-{ "braille_dots_1237", 0x1002847 },
-{ "braille_dots_47", 0x1002848 },
-{ "braille_dots_147", 0x1002849 },
-{ "braille_dots_247", 0x100284A },
-{ "braille_dots_1247", 0x100284B },
-{ "braille_dots_347", 0x100284C },
-{ "braille_dots_1347", 0x100284D },
-{ "braille_dots_2347", 0x100284E },
-{ "braille_dots_12347", 0x100284F },
-{ "braille_dots_57", 0x1002850 },
-{ "braille_dots_157", 0x1002851 },
-{ "braille_dots_257", 0x1002852 },
-{ "braille_dots_1257", 0x1002853 },
-{ "braille_dots_357", 0x1002854 },
-{ "braille_dots_1357", 0x1002855 },
-{ "braille_dots_2357", 0x1002856 },
-{ "braille_dots_12357", 0x1002857 },
-{ "braille_dots_457", 0x1002858 },
-{ "braille_dots_1457", 0x1002859 },
-{ "braille_dots_2457", 0x100285A },
-{ "braille_dots_12457", 0x100285B },
-{ "braille_dots_3457", 0x100285C },
-{ "braille_dots_13457", 0x100285D },
-{ "braille_dots_23457", 0x100285E },
-{ "braille_dots_123457", 0x100285F },
-{ "braille_dots_67", 0x1002860 },
-{ "braille_dots_167", 0x1002861 },
-{ "braille_dots_267", 0x1002862 },
-{ "braille_dots_1267", 0x1002863 },
-{ "braille_dots_367", 0x1002864 },
-{ "braille_dots_1367", 0x1002865 },
-{ "braille_dots_2367", 0x1002866 },
-{ "braille_dots_12367", 0x1002867 },
-{ "braille_dots_467", 0x1002868 },
-{ "braille_dots_1467", 0x1002869 },
-{ "braille_dots_2467", 0x100286A },
-{ "braille_dots_12467", 0x100286B },
-{ "braille_dots_3467", 0x100286C },
-{ "braille_dots_13467", 0x100286D },
-{ "braille_dots_23467", 0x100286E },
-{ "braille_dots_123467", 0x100286F },
-{ "braille_dots_567", 0x1002870 },
-{ "braille_dots_1567", 0x1002871 },
-{ "braille_dots_2567", 0x1002872 },
-{ "braille_dots_12567", 0x1002873 },
-{ "braille_dots_3567", 0x1002874 },
-{ "braille_dots_13567", 0x1002875 },
-{ "braille_dots_23567", 0x1002876 },
-{ "braille_dots_123567", 0x1002877 },
-{ "braille_dots_4567", 0x1002878 },
-{ "braille_dots_14567", 0x1002879 },
-{ "braille_dots_24567", 0x100287A },
-{ "braille_dots_124567", 0x100287B },
-{ "braille_dots_34567", 0x100287C },
-{ "braille_dots_134567", 0x100287D },
-{ "braille_dots_234567", 0x100287E },
-{ "braille_dots_1234567", 0x100287F },
-{ "braille_dots_8", 0x1002880 },
-{ "braille_dots_18", 0x1002881 },
-{ "braille_dots_28", 0x1002882 },
-{ "braille_dots_128", 0x1002883 },
-{ "braille_dots_38", 0x1002884 },
-{ "braille_dots_138", 0x1002885 },
-{ "braille_dots_238", 0x1002886 },
-{ "braille_dots_1238", 0x1002887 },
-{ "braille_dots_48", 0x1002888 },
-{ "braille_dots_148", 0x1002889 },
-{ "braille_dots_248", 0x100288A },
-{ "braille_dots_1248", 0x100288B },
-{ "braille_dots_348", 0x100288C },
-{ "braille_dots_1348", 0x100288D },
-{ "braille_dots_2348", 0x100288E },
-{ "braille_dots_12348", 0x100288F },
-{ "braille_dots_58", 0x1002890 },
-{ "braille_dots_158", 0x1002891 },
-{ "braille_dots_258", 0x1002892 },
-{ "braille_dots_1258", 0x1002893 },
-{ "braille_dots_358", 0x1002894 },
-{ "braille_dots_1358", 0x1002895 },
-{ "braille_dots_2358", 0x1002896 },
-{ "braille_dots_12358", 0x1002897 },
-{ "braille_dots_458", 0x1002898 },
-{ "braille_dots_1458", 0x1002899 },
-{ "braille_dots_2458", 0x100289A },
-{ "braille_dots_12458", 0x100289B },
-{ "braille_dots_3458", 0x100289C },
-{ "braille_dots_13458", 0x100289D },
-{ "braille_dots_23458", 0x100289E },
-{ "braille_dots_123458", 0x100289F },
-{ "braille_dots_68", 0x10028A0 },
-{ "braille_dots_168", 0x10028A1 },
-{ "braille_dots_268", 0x10028A2 },
-{ "braille_dots_1268", 0x10028A3 },
-{ "braille_dots_368", 0x10028A4 },
-{ "braille_dots_1368", 0x10028A5 },
-{ "braille_dots_2368", 0x10028A6 },
-{ "braille_dots_12368", 0x10028A7 },
-{ "braille_dots_468", 0x10028A8 },
-{ "braille_dots_1468", 0x10028A9 },
-{ "braille_dots_2468", 0x10028AA },
-{ "braille_dots_12468", 0x10028AB },
-{ "braille_dots_3468", 0x10028AC },
-{ "braille_dots_13468", 0x10028AD },
-{ "braille_dots_23468", 0x10028AE },
-{ "braille_dots_123468", 0x10028AF },
-{ "braille_dots_568", 0x10028B0 },
-{ "braille_dots_1568", 0x10028B1 },
-{ "braille_dots_2568", 0x10028B2 },
-{ "braille_dots_12568", 0x10028B3 },
-{ "braille_dots_3568", 0x10028B4 },
-{ "braille_dots_13568", 0x10028B5 },
-{ "braille_dots_23568", 0x10028B6 },
-{ "braille_dots_123568", 0x10028B7 },
-{ "braille_dots_4568", 0x10028B8 },
-{ "braille_dots_14568", 0x10028B9 },
-{ "braille_dots_24568", 0x10028BA },
-{ "braille_dots_124568", 0x10028BB },
-{ "braille_dots_34568", 0x10028BC },
-{ "braille_dots_134568", 0x10028BD },
-{ "braille_dots_234568", 0x10028BE },
-{ "braille_dots_1234568", 0x10028BF },
-{ "braille_dots_78", 0x10028C0 },
-{ "braille_dots_178", 0x10028C1 },
-{ "braille_dots_278", 0x10028C2 },
-{ "braille_dots_1278", 0x10028C3 },
-{ "braille_dots_378", 0x10028C4 },
-{ "braille_dots_1378", 0x10028C5 },
-{ "braille_dots_2378", 0x10028C6 },
-{ "braille_dots_12378", 0x10028C7 },
-{ "braille_dots_478", 0x10028C8 },
-{ "braille_dots_1478", 0x10028C9 },
-{ "braille_dots_2478", 0x10028CA },
-{ "braille_dots_12478", 0x10028CB },
-{ "braille_dots_3478", 0x10028CC },
-{ "braille_dots_13478", 0x10028CD },
-{ "braille_dots_23478", 0x10028CE },
-{ "braille_dots_123478", 0x10028CF },
-{ "braille_dots_578", 0x10028D0 },
-{ "braille_dots_1578", 0x10028D1 },
-{ "braille_dots_2578", 0x10028D2 },
-{ "braille_dots_12578", 0x10028D3 },
-{ "braille_dots_3578", 0x10028D4 },
-{ "braille_dots_13578", 0x10028D5 },
-{ "braille_dots_23578", 0x10028D6 },
-{ "braille_dots_123578", 0x10028D7 },
-{ "braille_dots_4578", 0x10028D8 },
-{ "braille_dots_14578", 0x10028D9 },
-{ "braille_dots_24578", 0x10028DA },
-{ "braille_dots_124578", 0x10028DB },
-{ "braille_dots_34578", 0x10028DC },
-{ "braille_dots_134578", 0x10028DD },
-{ "braille_dots_234578", 0x10028DE },
-{ "braille_dots_1234578", 0x10028DF },
-{ "braille_dots_678", 0x10028E0 },
-{ "braille_dots_1678", 0x10028E1 },
-{ "braille_dots_2678", 0x10028E2 },
-{ "braille_dots_12678", 0x10028E3 },
-{ "braille_dots_3678", 0x10028E4 },
-{ "braille_dots_13678", 0x10028E5 },
-{ "braille_dots_23678", 0x10028E6 },
-{ "braille_dots_123678", 0x10028E7 },
-{ "braille_dots_4678", 0x10028E8 },
-{ "braille_dots_14678", 0x10028E9 },
-{ "braille_dots_24678", 0x10028EA },
-{ "braille_dots_124678", 0x10028EB },
-{ "braille_dots_34678", 0x10028EC },
-{ "braille_dots_134678", 0x10028ED },
-{ "braille_dots_234678", 0x10028EE },
-{ "braille_dots_1234678", 0x10028EF },
-{ "braille_dots_5678", 0x10028F0 },
-{ "braille_dots_15678", 0x10028F1 },
-{ "braille_dots_25678", 0x10028F2 },
-{ "braille_dots_125678", 0x10028F3 },
-{ "braille_dots_35678", 0x10028F4 },
-{ "braille_dots_135678", 0x10028F5 },
-{ "braille_dots_235678", 0x10028F6 },
-{ "braille_dots_1235678", 0x10028F7 },
-{ "braille_dots_45678", 0x10028F8 },
-{ "braille_dots_145678", 0x10028F9 },
-{ "braille_dots_245678", 0x10028FA },
-{ "braille_dots_1245678", 0x10028FB },
-{ "braille_dots_345678", 0x10028FC },
-{ "braille_dots_1345678", 0x10028FD },
-{ "braille_dots_2345678", 0x10028FE },
-{ "braille_dots_12345678", 0x10028FF },
-{ "Sinh_ng", 0x1000D82 },
-{ "Sinh_h2", 0x1000D83 },
-{ "Sinh_a", 0x1000D85 },
-{ "Sinh_aa", 0x1000D86 },
-{ "Sinh_ae", 0x1000D87 },
-{ "Sinh_aee", 0x1000D88 },
-{ "Sinh_i", 0x1000D89 },
-{ "Sinh_ii", 0x1000D8A },
-{ "Sinh_u", 0x1000D8B },
-{ "Sinh_uu", 0x1000D8C },
-{ "Sinh_ri", 0x1000D8D },
-{ "Sinh_rii", 0x1000D8E },
-{ "Sinh_lu", 0x1000D8F },
-{ "Sinh_luu", 0x1000D90 },
-{ "Sinh_e", 0x1000D91 },
-{ "Sinh_ee", 0x1000D92 },
-{ "Sinh_ai", 0x1000D93 },
-{ "Sinh_o", 0x1000D94 },
-{ "Sinh_oo", 0x1000D95 },
-{ "Sinh_au", 0x1000D96 },
-{ "Sinh_ka", 0x1000D9A },
-{ "Sinh_kha", 0x1000D9B },
-{ "Sinh_ga", 0x1000D9C },
-{ "Sinh_gha", 0x1000D9D },
-{ "Sinh_ng2", 0x1000D9E },
-{ "Sinh_nga", 0x1000D9F },
-{ "Sinh_ca", 0x1000DA0 },
-{ "Sinh_cha", 0x1000DA1 },
-{ "Sinh_ja", 0x1000DA2 },
-{ "Sinh_jha", 0x1000DA3 },
-{ "Sinh_nya", 0x1000DA4 },
-{ "Sinh_jnya", 0x1000DA5 },
-{ "Sinh_nja", 0x1000DA6 },
-{ "Sinh_tta", 0x1000DA7 },
-{ "Sinh_ttha", 0x1000DA8 },
-{ "Sinh_dda", 0x1000DA9 },
-{ "Sinh_ddha", 0x1000DAA },
-{ "Sinh_nna", 0x1000DAB },
-{ "Sinh_ndda", 0x1000DAC },
-{ "Sinh_tha", 0x1000DAD },
-{ "Sinh_thha", 0x1000DAE },
-{ "Sinh_dha", 0x1000DAF },
-{ "Sinh_dhha", 0x1000DB0 },
-{ "Sinh_na", 0x1000DB1 },
-{ "Sinh_ndha", 0x1000DB3 },
-{ "Sinh_pa", 0x1000DB4 },
-{ "Sinh_pha", 0x1000DB5 },
-{ "Sinh_ba", 0x1000DB6 },
-{ "Sinh_bha", 0x1000DB7 },
-{ "Sinh_ma", 0x1000DB8 },
-{ "Sinh_mba", 0x1000DB9 },
-{ "Sinh_ya", 0x1000DBA },
-{ "Sinh_ra", 0x1000DBB },
-{ "Sinh_la", 0x1000DBD },
-{ "Sinh_va", 0x1000DC0 },
-{ "Sinh_sha", 0x1000DC1 },
-{ "Sinh_ssha", 0x1000DC2 },
-{ "Sinh_sa", 0x1000DC3 },
-{ "Sinh_ha", 0x1000DC4 },
-{ "Sinh_lla", 0x1000DC5 },
-{ "Sinh_fa", 0x1000DC6 },
-{ "Sinh_al", 0x1000DCA },
-{ "Sinh_aa2", 0x1000DCF },
-{ "Sinh_ae2", 0x1000DD0 },
-{ "Sinh_aee2", 0x1000DD1 },
-{ "Sinh_i2", 0x1000DD2 },
-{ "Sinh_ii2", 0x1000DD3 },
-{ "Sinh_u2", 0x1000DD4 },
-{ "Sinh_uu2", 0x1000DD6 },
-{ "Sinh_ru2", 0x1000DD8 },
-{ "Sinh_e2", 0x1000DD9 },
-{ "Sinh_ee2", 0x1000DDA },
-{ "Sinh_ai2", 0x1000DDB },
-{ "Sinh_o2", 0x1000DDC },
-{ "Sinh_oo2", 0x1000DDD },
-{ "Sinh_au2", 0x1000DDE },
-{ "Sinh_lu2", 0x1000DDF },
-{ "Sinh_ruu2", 0x1000DF2 },
-{ "Sinh_luu2", 0x1000DF3 },
-{ "Sinh_kunddaliya", 0x1000DF4 },
 { "XF86ModeLock", 0x1008FF01 },
 { "XF86MonBrightnessUp", 0x1008FF02 },
 { "XF86MonBrightnessDown", 0x1008FF03 },
 { "XF86KbdLightOnOff", 0x1008FF04 },
 { "XF86KbdBrightnessUp", 0x1008FF05 },
@@ -2348,10 +1617,11 @@
 { "XF86Keyboard", 0x1008FFB3 },
 { "XF86WWAN", 0x1008FFB4 },
 { "XF86RFKill", 0x1008FFB5 },
 { "XF86AudioPreset", 0x1008FFB6 },
 { "XF86RotationLockToggle", 0x1008FFB7 },
+{ "XF86FullScreen", 0x1008FFB8 },
 { "XF86Switch_VT_1", 0x1008FE01 },
 { "XF86Switch_VT_2", 0x1008FE02 },
 { "XF86Switch_VT_3", 0x1008FE03 },
 { "XF86Switch_VT_4", 0x1008FE04 },
 { "XF86Switch_VT_5", 0x1008FE05 },
@@ -2366,10 +1636,149 @@
 { "XF86ClearGrab", 0x1008FE21 },
 { "XF86Next_VMode", 0x1008FE22 },
 { "XF86Prev_VMode", 0x1008FE23 },
 { "XF86LogWindowTree", 0x1008FE24 },
 { "XF86LogGrabInfo", 0x1008FE25 },
+{ "XF86BrightnessAuto", 0x100810F4 },
+{ "XF86DisplayOff", 0x100810F5 },
+{ "XF86Info", 0x10081166 },
+{ "XF86AspectRatio", 0x10081177 },
+{ "XF86DVD", 0x10081185 },
+{ "XF86Audio", 0x10081188 },
+{ "XF86ChannelUp", 0x10081192 },
+{ "XF86ChannelDown", 0x10081193 },
+{ "XF86Break", 0x1008119B },
+{ "XF86VideoPhone", 0x100811A0 },
+{ "XF86ZoomReset", 0x100811A4 },
+{ "XF86Editor", 0x100811A6 },
+{ "XF86GraphicsEditor", 0x100811A8 },
+{ "XF86Presentation", 0x100811A9 },
+{ "XF86Database", 0x100811AA },
+{ "XF86Voicemail", 0x100811AC },
+{ "XF86Addressbook", 0x100811AD },
+{ "XF86DisplayToggle", 0x100811AF },
+{ "XF86SpellCheck", 0x100811B0 },
+{ "XF86ContextMenu", 0x100811B6 },
+{ "XF86MediaRepeat", 0x100811B7 },
+{ "XF8610ChannelsUp", 0x100811B8 },
+{ "XF8610ChannelsDown", 0x100811B9 },
+{ "XF86Images", 0x100811BA },
+{ "XF86NotificationCenter", 0x100811BC },
+{ "XF86PickupPhone", 0x100811BD },
+{ "XF86HangupPhone", 0x100811BE },
+{ "XF86Fn", 0x100811D0 },
+{ "XF86Fn_Esc", 0x100811D1 },
+{ "XF86FnRightShift", 0x100811E5 },
+{ "XF86Numeric0", 0x10081200 },
+{ "XF86Numeric1", 0x10081201 },
+{ "XF86Numeric2", 0x10081202 },
+{ "XF86Numeric3", 0x10081203 },
+{ "XF86Numeric4", 0x10081204 },
+{ "XF86Numeric5", 0x10081205 },
+{ "XF86Numeric6", 0x10081206 },
+{ "XF86Numeric7", 0x10081207 },
+{ "XF86Numeric8", 0x10081208 },
+{ "XF86Numeric9", 0x10081209 },
+{ "XF86NumericStar", 0x1008120A },
+{ "XF86NumericPound", 0x1008120B },
+{ "XF86NumericA", 0x1008120C },
+{ "XF86NumericB", 0x1008120D },
+{ "XF86NumericC", 0x1008120E },
+{ "XF86NumericD", 0x1008120F },
+{ "XF86CameraFocus", 0x10081210 },
+{ "XF86WPSButton", 0x10081211 },
+{ "XF86CameraZoomIn", 0x10081215 },
+{ "XF86CameraZoomOut", 0x10081216 },
+{ "XF86CameraUp", 0x10081217 },
+{ "XF86CameraDown", 0x10081218 },
+{ "XF86CameraLeft", 0x10081219 },
+{ "XF86CameraRight", 0x1008121A },
+{ "XF86AttendantOn", 0x1008121B },
+{ "XF86AttendantOff", 0x1008121C },
+{ "XF86AttendantToggle", 0x1008121D },
+{ "XF86LightsToggle", 0x1008121E },
+{ "XF86ALSToggle", 0x10081230 },
+{ "XF86Buttonconfig", 0x10081240 },
+{ "XF86Taskmanager", 0x10081241 },
+{ "XF86Journal", 0x10081242 },
+{ "XF86ControlPanel", 0x10081243 },
+{ "XF86AppSelect", 0x10081244 },
+{ "XF86Screensaver", 0x10081245 },
+{ "XF86VoiceCommand", 0x10081246 },
+{ "XF86Assistant", 0x10081247 },
+{ "XF86EmojiPicker", 0x10081249 },
+{ "XF86Dictate", 0x1008124A },
+{ "XF86BrightnessMin", 0x10081250 },
+{ "XF86BrightnessMax", 0x10081251 },
+{ "XF86KbdInputAssistPrev", 0x10081260 },
+{ "XF86KbdInputAssistNext", 0x10081261 },
+{ "XF86KbdInputAssistPrevgroup", 0x10081262 },
+{ "XF86KbdInputAssistNextgroup", 0x10081263 },
+{ "XF86KbdInputAssistAccept", 0x10081264 },
+{ "XF86KbdInputAssistCancel", 0x10081265 },
+{ "XF86RightUp", 0x10081266 },
+{ "XF86RightDown", 0x10081267 },
+{ "XF86LeftUp", 0x10081268 },
+{ "XF86LeftDown", 0x10081269 },
+{ "XF86RootMenu", 0x1008126A },
+{ "XF86MediaTopMenu", 0x1008126B },
+{ "XF86Numeric11", 0x1008126C },
+{ "XF86Numeric12", 0x1008126D },
+{ "XF86AudioDesc", 0x1008126E },
+{ "XF863DMode", 0x1008126F },
+{ "XF86NextFavorite", 0x10081270 },
+{ "XF86StopRecord", 0x10081271 },
+{ "XF86PauseRecord", 0x10081272 },
+{ "XF86VOD", 0x10081273 },
+{ "XF86Unmute", 0x10081274 },
+{ "XF86FastReverse", 0x10081275 },
+{ "XF86SlowReverse", 0x10081276 },
+{ "XF86Data", 0x10081277 },
+{ "XF86OnScreenKeyboard", 0x10081278 },
+{ "XF86PrivacyScreenToggle", 0x10081279 },
+{ "XF86SelectiveScreenshot", 0x1008127A },
+{ "XF86Macro1", 0x10081290 },
+{ "XF86Macro2", 0x10081291 },
+{ "XF86Macro3", 0x10081292 },
+{ "XF86Macro4", 0x10081293 },
+{ "XF86Macro5", 0x10081294 },
+{ "XF86Macro6", 0x10081295 },
+{ "XF86Macro7", 0x10081296 },
+{ "XF86Macro8", 0x10081297 },
+{ "XF86Macro9", 0x10081298 },
+{ "XF86Macro10", 0x10081299 },
+{ "XF86Macro11", 0x1008129A },
+{ "XF86Macro12", 0x1008129B },
+{ "XF86Macro13", 0x1008129C },
+{ "XF86Macro14", 0x1008129D },
+{ "XF86Macro15", 0x1008129E },
+{ "XF86Macro16", 0x1008129F },
+{ "XF86Macro17", 0x100812A0 },
+{ "XF86Macro18", 0x100812A1 },
+{ "XF86Macro19", 0x100812A2 },
+{ "XF86Macro20", 0x100812A3 },
+{ "XF86Macro21", 0x100812A4 },
+{ "XF86Macro22", 0x100812A5 },
+{ "XF86Macro23", 0x100812A6 },
+{ "XF86Macro24", 0x100812A7 },
+{ "XF86Macro25", 0x100812A8 },
+{ "XF86Macro26", 0x100812A9 },
+{ "XF86Macro27", 0x100812AA },
+{ "XF86Macro28", 0x100812AB },
+{ "XF86Macro29", 0x100812AC },
+{ "XF86Macro30", 0x100812AD },
+{ "XF86MacroRecordStart", 0x100812B0 },
+{ "XF86MacroRecordStop", 0x100812B1 },
+{ "XF86MacroPresetCycle", 0x100812B2 },
+{ "XF86MacroPreset1", 0x100812B3 },
+{ "XF86MacroPreset2", 0x100812B4 },
+{ "XF86MacroPreset3", 0x100812B5 },
+{ "XF86KbdLcdMenu1", 0x100812B8 },
+{ "XF86KbdLcdMenu2", 0x100812B9 },
+{ "XF86KbdLcdMenu3", 0x100812BA },
+{ "XF86KbdLcdMenu4", 0x100812BB },
+{ "XF86KbdLcdMenu5", 0x100812BC },
 { "SunFA_Grave", 0x1005FF00 },
 { "SunFA_Circum", 0x1005FF01 },
 { "SunFA_Tilde", 0x1005FF02 },
 { "SunFA_Acute", 0x1005FF03 },
 { "SunFA_Diaeresis", 0x1005FF04 },

Index: generic/nanosvg.h
==================================================================
--- generic/nanosvg.h
+++ generic/nanosvg.h
@@ -31,26 +31,27 @@
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-// NanoSVG is a simple stupid single-header-file SVG parse. The output of the parser is a list of cubic bezier shapes.
-//
-// The library suits well for anything from rendering scalable icons in your editor application to prototyping a game.
-//
-// NanoSVG supports a wide range of SVG features, but something may be missing, feel free to create a pull request!
-//
-// The shapes in the SVG images are transformed by the viewBox and converted to specified units.
-// That is, you should get the same looking data as your designed in your favorite app.
-//
-// NanoSVG can return the paths in few different units. For example if you want to render an image, you may choose
-// to get the paths in pixels, or if you are feeding the data into a CNC-cutter, you may want to use millimeters.
-//
-// The units passed to NanoSVG should be one of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'.
-// DPI (dots-per-inch) controls how the unit conversion is done.
-//
-// If you don't know or care about the units stuff, "px" and 96 should get you going.
+/* NanoSVG is a simple stupid single-header-file SVG parse. The output of the parser is a list of cubic bezier shapes.
+ *
+ * The library suits well for anything from rendering scalable icons in your editor application to prototyping a game.
+ *
+ * NanoSVG supports a wide range of SVG features, but something may be missing, feel free to create a pull request!
+ *
+ * The shapes in the SVG images are transformed by the viewBox and converted to specified units.
+ * That is, you should get the same looking data as your designed in your favorite app.
+ *
+ * NanoSVG can return the paths in few different units. For example if you want to render an image, you may choose
+ * to get the paths in pixels, or if you are feeding the data into a CNC-cutter, you may want to use millimeters.
+ *
+ * The units passed to NanoSVG should be one of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'.
+ * DPI (dots-per-inch) controls how the unit conversion is done.
+ *
+ * If you don't know or care about the units stuff, "px" and 96 should get you going.
+ */
 
 
 /* Example Usage:
 	// Load SVG
 	NSVGimage* image;
@@ -83,11 +84,11 @@
 
 #ifndef NANOSVG_free
 #define NANOSVG_free free
 #endif
 
-// float emulation for MS VC6++ compiler
+/* float emulation for MS VC6++ compiler */
 #if defined(_MSC_VER) && (_MSC_VER == 1200)
 #define tanf(a) (float)tan(a)
 #define cosf(a) (float)cos(a)
 #define sinf(a) (float)sin(a)
 #define sqrtf(a) (float)sqrt(a)
@@ -96,11 +97,11 @@
 #define atan2f(a,b) (float)atan2(a,b)
 #define ceilf(a) (float)ceil(a)
 #define fmodf(a,b) (float)fmod(a,b)
 #define floorf(a) (float)floor(a)
 #endif
-// float emulation for MS VC8++ compiler
+/* float emulation for MS VC8++ compiler */
 #if defined(_MSC_VER) && (_MSC_VER == 1400)
 #define fabsf(a) (float)fabs(a)
 #endif
 
 enum NSVGpaintType {
@@ -158,68 +159,67 @@
 	};
 } NSVGpaint;
 
 typedef struct NSVGpath
 {
-	float* pts;					// Cubic bezier points: x0,y0, [cpx1,cpx1,cpx2,cpy2,x1,y1], ...
-	int npts;					// Total number of bezier points.
-	char closed;				// Flag indicating if shapes should be treated as closed.
-	float bounds[4];			// Tight bounding box of the shape [minx,miny,maxx,maxy].
-	struct NSVGpath* next;		// Pointer to next path, or NULL if last element.
+	float* pts;					/* Cubic bezier points: x0,y0, [cpx1,cpx1,cpx2,cpy2,x1,y1], ... */
+	int npts;					/* Total number of bezier points. */
+	char closed;				/* Flag indicating if shapes should be treated as closed. */
+	float bounds[4];			/* Tight bounding box of the shape [minx,miny,maxx,maxy]. */
+	struct NSVGpath* next;		/* Pointer to next path, or NULL if last element. */
 } NSVGpath;
 
 typedef struct NSVGshape
 {
-	char id[64];				// Optional 'id' attr of the shape or its group
-	NSVGpaint fill;				// Fill paint
-	NSVGpaint stroke;			// Stroke paint
-	float opacity;				// Opacity of the shape.
-	float strokeWidth;			// Stroke width (scaled).
-	float strokeDashOffset;		// Stroke dash offset (scaled).
-	float strokeDashArray[8];			// Stroke dash array (scaled).
-	char strokeDashCount;				// Number of dash values in dash array.
-	char strokeLineJoin;		// Stroke join type.
-	char strokeLineCap;			// Stroke cap type.
-	float miterLimit;			// Miter limit
-	char fillRule;				// Fill rule, see NSVGfillRule.
-	unsigned char flags;		// Logical or of NSVG_FLAGS_* flags
-	float bounds[4];			// Tight bounding box of the shape [minx,miny,maxx,maxy].
-	NSVGpath* paths;			// Linked list of paths in the image.
-	struct NSVGshape* next;		// Pointer to next shape, or NULL if last element.
+	char id[64];				/* Optional 'id' attr of the shape or its group */
+	NSVGpaint fill;				/* Fill paint */
+	NSVGpaint stroke;			/* Stroke paint */
+	float opacity;				/* Opacity of the shape. */
+	float strokeWidth;			/* Stroke width (scaled). */
+	float strokeDashOffset;		/* Stroke dash offset (scaled). */
+	float strokeDashArray[8];			/* Stroke dash array (scaled). */
+	char strokeDashCount;				/* Number of dash values in dash array. */
+	char strokeLineJoin;		/* Stroke join type. */
+	char strokeLineCap;			/* Stroke cap type. */
+	float miterLimit;			/* Miter limit */
+	char fillRule;				/* Fill rule, see NSVGfillRule. */
+	unsigned char flags;		/* Logical or of NSVG_FLAGS_* flags */
+	float bounds[4];			/* Tight bounding box of the shape [minx,miny,maxx,maxy]. */
+	NSVGpath* paths;			/* Linked list of paths in the image. */
+	struct NSVGshape* next;		/* Pointer to next shape, or NULL if last element. */
 } NSVGshape;
 
 typedef struct NSVGimage
 {
-	float width;				// Width of the image.
-	float height;				// Height of the image.
-	NSVGshape* shapes;			// Linked list of shapes in the image.
+	float width;				/* Width of the image. */
+	float height;				/* Height of the image. */
+	NSVGshape* shapes;			/* Linked list of shapes in the image. */
 } NSVGimage;
 
-// Parses SVG file from a file, returns SVG image as paths.
+/* Parses SVG file from a file, returns SVG image as paths. */
 NANOSVG_SCOPE NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi);
 
-// Parses SVG file from a null terminated string, returns SVG image as paths.
-// Important note: changes the string.
+/* Parses SVG file from a null terminated string, returns SVG image as paths. */
+/* Important note: changes the string. */
 NANOSVG_SCOPE NSVGimage* nsvgParse(char* input, const char* units, float dpi);
 
-// Deletes list of paths.
+/* Deletes list of paths. */
 NANOSVG_SCOPE void nsvgDelete(NSVGimage* image);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif // NANOSVG_H
-
 #ifdef NANOSVG_IMPLEMENTATION
 
 #include <string.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <math.h>
 
 #define NSVG_PI (3.14159265358979323846264338327f)
-#define NSVG_KAPPA90 (0.5522847493f)	// Length proportional to radius of a cubic bezier handle for 90deg arcs.
+#define NSVG_KAPPA90 (0.5522847493f)	/* Length proportional to radius of a cubic bezier handle for 90deg arcs. */
 
 #define NSVG_ALIGN_MIN 0
 #define NSVG_ALIGN_MID 1
 #define NSVG_ALIGN_MAX 2
 #define NSVG_ALIGN_NONE 0
@@ -228,18 +228,18 @@
 
 #define NSVG_NOTUSED(v) do { (void)(1 ? (void)0 : ( (void)(v) ) ); } while(0)
 #define NSVG_RGB(r, g, b) (((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16))
 
 #ifdef _MSC_VER
-	#pragma warning (disable: 4996) // Switch off security warnings
-	#pragma warning (disable: 4100) // Switch off unreferenced formal parameter warnings
+	#pragma warning (disable: 4996) /* Switch off security warnings */
+	#pragma warning (disable: 4100) /* Switch off unreferenced formal parameter warnings */
 	#ifdef __cplusplus
 	#define NSVG_INLINE inline
 	#else
 	#define NSVG_INLINE
 	#endif
-	#if !defined(strtoll)           // old MSVC versions do not have strtoll()
+	#if !defined(strtoll)           /* old MSVC versions do not have strtoll() */
 		#define strtoll _strtoi64
 	#endif
 #else
 	#define NSVG_INLINE inline
 #endif
@@ -257,21 +257,21 @@
 
 static NSVG_INLINE float nsvg__minf(float a, float b) { return a < b ? a : b; }
 static NSVG_INLINE float nsvg__maxf(float a, float b) { return a > b ? a : b; }
 
 
-// Simple XML parser
+/* Simple XML parser */
 
 #define NSVG_XML_TAG 1
 #define NSVG_XML_CONTENT 2
 #define NSVG_XML_MAX_ATTRIBS 256
 
 static void nsvg__parseContent(char* s,
 							   void (*contentCb)(void* ud, const char* s),
 							   void* ud)
 {
-	// Trim start white spaces
+	/* Trim start white spaces */
 	while (*s && nsvg__isspace(*s)) s++;
 	if (!*s) return;
 
 	if (contentCb)
 		(*contentCb)(ud, s);
@@ -287,68 +287,68 @@
 	char* cbname;
 	int start = 0;
 	int end = 0;
 	char quote;
 
-	// Skip white space after the '<'
+	/* Skip white space after the '<' */
 	while (*s && nsvg__isspace(*s)) s++;
 
-	// Check if the tag is end tag
+	/* Check if the tag is end tag */
 	if (*s == '/') {
 		s++;
 		end = 1;
 	} else {
 		start = 1;
 	}
 
-	// Skip comments, data and preprocessor stuff.
+	/* Skip comments, data and preprocessor stuff. */
 	if (!*s || *s == '?' || *s == '!')
 		return;
 
-	// Get tag name
+	/* Get tag name */
 	cbname = s;
 	while (*s && !nsvg__isspace(*s)) s++;
 	if (*s) { *s++ = '\0'; }
 
-	// Get attribs
+	/* Get attribs */
 	while (!end && *s && nattr < NSVG_XML_MAX_ATTRIBS-3) {
 		char* name = NULL;
 		char* value = NULL;
 
-		// Skip white space before the attrib name
+		/* Skip white space before the attrib name */
 		while (*s && nsvg__isspace(*s)) s++;
 		if (!*s) break;
 		if (*s == '/') {
 			end = 1;
 			break;
 		}
 		name = s;
-		// Find end of the attrib name.
+		/* Find end of the attrib name. */
 		while (*s && !nsvg__isspace(*s) && *s != '=') s++;
 		if (*s) { *s++ = '\0'; }
-		// Skip until the beginning of the value.
+		/* Skip until the beginning of the value. */
 		while (*s && *s != '\"' && *s != '\'') s++;
 		if (!*s) break;
 		quote = *s;
 		s++;
-		// Store value and find the end of it.
+		/* Store value and find the end of it. */
 		value = s;
 		while (*s && *s != quote) s++;
 		if (*s) { *s++ = '\0'; }
 
-		// Store only well formed attributes
+		/* Store only well formed attributes */
 		if (name && value) {
 			attr[nattr++] = name;
 			attr[nattr++] = value;
 		}
 	}
 
-	// List terminator
+	/* List terminator */
 	attr[nattr++] = 0;
 	attr[nattr++] = 0;
 
-	// Call callbacks.
+	/* Call callbacks. */
 	if (start && startelCb)
 		(*startelCb)(ud, cbname, attr);
 	if (end && endelCb)
 		(*endelCb)(ud, cbname);
 }
@@ -363,17 +363,17 @@
 	char* s = input;
 	char* mark = s;
 	int state = NSVG_XML_CONTENT;
 	while (*s) {
 		if (*s == '<' && state == NSVG_XML_CONTENT) {
-			// Start of a tag
+			/* Start of a tag */
 			*s++ = '\0';
 			nsvg__parseContent(mark, contentCb, ud);
 			mark = s;
 			state = NSVG_XML_TAG;
 		} else if (*s == '>' && state == NSVG_XML_TAG) {
-			// Start of a content or new tag.
+			/* Start of a content or new tag. */
 			*s++ = '\0';
 			nsvg__parseContent(mark, contentCb, ud);
 			nsvg__parseElement(mark, startelCb, endelCb, ud);
 			mark = s;
 			state = NSVG_XML_CONTENT;
@@ -613,22 +613,22 @@
 	float* v0 = &curve[0];
 	float* v1 = &curve[2];
 	float* v2 = &curve[4];
 	float* v3 = &curve[6];
 
-	// Start the bounding box by end points
+	/* Start the bounding box by end points */
 	bounds[0] = nsvg__minf(v0[0], v3[0]);
 	bounds[1] = nsvg__minf(v0[1], v3[1]);
 	bounds[2] = nsvg__maxf(v0[0], v3[0]);
 	bounds[3] = nsvg__maxf(v0[1], v3[1]);
 
-	// Bezier curve fits inside the convex hull of it's control points.
-	// If control points are inside the bounds, we're done.
+	/* Bezier curve fits inside the convex hull of it's control points. */
+	/* If control points are inside the bounds, we're done. */
 	if (nsvg__ptInBounds(v1, bounds) && nsvg__ptInBounds(v2, bounds))
 		return;
 
-	// Add bezier curve inflection points in X and Y.
+	/* Add bezier curve inflection points in X and Y. */
 	for (i = 0; i < 2; i++) {
 		a = -3.0 * v0[i] + 9.0 * v1[i] - 9.0 * v2[i] + 3.0 * v3[i];
 		b = 6.0 * v0[i] - 12.0 * v1[i] + 6.0 * v2[i];
 		c = 3.0 * v1[i] - 3.0 * v0[i];
 		count = 0;
@@ -666,11 +666,11 @@
 
 	p->image = (NSVGimage*)NANOSVG_malloc(sizeof(NSVGimage));
 	if (p->image == NULL) goto error;
 	memset(p->image, 0, sizeof(NSVGimage));
 
-	// Init style
+	/* Init style */
 	nsvg__xformIdentity(p->attr[0].xform);
 	memset(p->attr[0].id, 0, sizeof p->attr[0].id);
 	p->attr[0].fillColor = NSVG_RGB(0,0,0);
 	p->attr[0].strokeColor = NSVG_RGB(0,0,0);
 	p->attr[0].opacity = 1;
@@ -852,11 +852,11 @@
 		case NSVG_UNITS_PC:			return c.value / 6.0f * p->dpi;
 		case NSVG_UNITS_MM:			return c.value / 25.4f * p->dpi;
 		case NSVG_UNITS_CM:			return c.value / 2.54f * p->dpi;
 		case NSVG_UNITS_IN:			return c.value * p->dpi;
 		case NSVG_UNITS_EM:			return c.value * attr->fontSize;
-		case NSVG_UNITS_EX:			return c.value * attr->fontSize * 0.52f; // x-height of Helvetica.
+		case NSVG_UNITS_EX:			return c.value * attr->fontSize * 0.52f; /* x-height of Helvetica. */
 		case NSVG_UNITS_PERCENT:	return orig + c.value / 100.0f * length;
 		default:					return c.value;
 	}
 	return c.value;
 }
@@ -886,11 +886,11 @@
 	int refIter;
 
 	data = nsvg__findGradientData(p, id);
 	if (data == NULL) return NULL;
 
-	// TODO: use ref to fill in all unset values too.
+	/* TODO: use ref to fill in all unset values too. */
 	ref = data;
 	refIter = 0;
 	while (ref != NULL) {
 		NSVGgradientData* nextRef = NULL;
 		if (stops == NULL && ref->stops != NULL) {
@@ -897,21 +897,21 @@
 			stops = ref->stops;
 			nstops = ref->nstops;
 			break;
 		}
 		nextRef = nsvg__findGradientData(p, ref->ref);
-		if (nextRef == ref) break; // prevent infite loops on malformed data
+		if (nextRef == ref) break; /* prevent infite loops on malformed data */
 		ref = nextRef;
 		refIter++;
-		if (refIter > 32) break; // prevent infite loops on malformed data
+		if (refIter > 32) break; /* prevent infite loops on malformed data */
 	}
 	if (stops == NULL) return NULL;
 
 	grad = (NSVGgradient*)NANOSVG_malloc(sizeof(NSVGgradient) + sizeof(NSVGgradientStop)*(nstops-1));
 	if (grad == NULL) return NULL;
 
-	// The shape width and height.
+	/* The shape width and height. */
 	if (data->units == NSVG_OBJECT_SPACE) {
 		ox = localBounds[0];
 		oy = localBounds[1];
 		sw = localBounds[2] - localBounds[0];
 		sh = localBounds[3] - localBounds[1];
@@ -927,11 +927,11 @@
 		float x1, y1, x2, y2, dx, dy;
 		x1 = nsvg__convertToPixels(p, data->linear.x1, ox, sw);
 		y1 = nsvg__convertToPixels(p, data->linear.y1, oy, sh);
 		x2 = nsvg__convertToPixels(p, data->linear.x2, ox, sw);
 		y2 = nsvg__convertToPixels(p, data->linear.y2, oy, sh);
-		// Calculate transform aligned to the line
+		/* Calculate transform aligned to the line */
 		dx = x2 - x1;
 		dy = y2 - y1;
 		grad->xform[0] = dy; grad->xform[1] = -dx;
 		grad->xform[2] = dx; grad->xform[3] = dy;
 		grad->xform[4] = x1; grad->xform[5] = y1;
@@ -940,11 +940,11 @@
 		cx = nsvg__convertToPixels(p, data->radial.cx, ox, sw);
 		cy = nsvg__convertToPixels(p, data->radial.cy, oy, sh);
 		fx = nsvg__convertToPixels(p, data->radial.fx, ox, sw);
 		fy = nsvg__convertToPixels(p, data->radial.fy, oy, sh);
 		r = nsvg__convertToPixels(p, data->radial.r, 0, sl);
-		// Calculate transform aligned to the circle
+		/* Calculate transform aligned to the circle */
 		grad->xform[0] = r; grad->xform[1] = 0;
 		grad->xform[2] = 0; grad->xform[3] = r;
 		grad->xform[4] = cx; grad->xform[5] = cy;
 		grad->fx = fx / r;
 		grad->fy = fy / r;
@@ -1028,11 +1028,11 @@
 	shape->opacity = attr->opacity;
 
 	shape->paths = p->plist;
 	p->plist = NULL;
 
-	// Calculate shape bounds
+	/* Calculate shape bounds */
 	shape->bounds[0] = shape->paths->bounds[0];
 	shape->bounds[1] = shape->paths->bounds[1];
 	shape->bounds[2] = shape->paths->bounds[2];
 	shape->bounds[3] = shape->paths->bounds[3];
 	for (path = shape->paths->next; path != NULL; path = path->next) {
@@ -1040,11 +1040,11 @@
 		shape->bounds[1] = nsvg__minf(shape->bounds[1], path->bounds[1]);
 		shape->bounds[2] = nsvg__maxf(shape->bounds[2], path->bounds[2]);
 		shape->bounds[3] = nsvg__maxf(shape->bounds[3], path->bounds[3]);
 	}
 
-	// Set fill
+	/* Set fill */
 	if (attr->hasFill == 0) {
 		shape->fill.type = NSVG_PAINT_NONE;
 	} else if (attr->hasFill == 1) {
 		shape->fill.type = NSVG_PAINT_COLOR;
 		shape->fill.color = attr->fillColor;
@@ -1057,11 +1057,11 @@
 		if (shape->fill.gradient == NULL) {
 			shape->fill.type = NSVG_PAINT_NONE;
 		}
 	}
 
-	// Set stroke
+	/* Set stroke */
 	if (attr->hasStroke == 0) {
 		shape->stroke.type = NSVG_PAINT_NONE;
 	} else if (attr->hasStroke == 1) {
 		shape->stroke.type = NSVG_PAINT_COLOR;
 		shape->stroke.color = attr->strokeColor;
@@ -1073,14 +1073,14 @@
 		shape->stroke.gradient = nsvg__createGradient(p, attr->strokeGradient, localBounds, &shape->stroke.type);
 		if (shape->stroke.gradient == NULL)
 			shape->stroke.type = NSVG_PAINT_NONE;
 	}
 
-	// Set flags
+	/* Set flags */
 	shape->flags = ((attr->visible & NSVG_VIS_DISPLAY) && (attr->visible & NSVG_VIS_VISIBLE) ? NSVG_FLAGS_VISIBLE : 0x00);
 
-	// Add to tail
+	/* Add to tail */
 	if (p->image->shapes == NULL)
 		p->image->shapes = shape;
 	else
 		p->shapesTail->next = shape;
 	p->shapesTail = shape;
@@ -1103,11 +1103,11 @@
 		return;
 
 	if (closed)
 		nsvg__lineTo(p, p->pts[0], p->pts[1]);
 
-	// Expect 1 + N*3 points (N = number of cubic bezier segments).
+	/* Expect 1 + N*3 points (N = number of cubic bezier segments). */
 	if ((p->npts % 3) != 1)
 		return;
 
 	path = (NSVGpath*)NANOSVG_malloc(sizeof(NSVGpath));
 	if (path == NULL) goto error;
@@ -1116,15 +1116,15 @@
 	path->pts = (float*)NANOSVG_malloc(p->npts*2*sizeof(float));
 	if (path->pts == NULL) goto error;
 	path->closed = closed;
 	path->npts = p->npts;
 
-	// Transform path.
+	/* Transform path. */
 	for (i = 0; i < p->npts; ++i)
 		nsvg__xformPoint(&path->pts[i*2], &path->pts[i*2+1], p->pts[i*2], p->pts[i*2+1], attr->xform);
 
-	// Find bounds
+	/* Find bounds */
 	for (i = 0; i < path->npts-1; i += 3) {
 		curve = &path->pts[i*2];
 		nsvg__curveBounds(bounds, curve);
 		if (i == 0) {
 			path->bounds[0] = bounds[0];
@@ -1149,11 +1149,11 @@
 		if (path->pts != NULL) NANOSVG_free(path->pts);
 		NANOSVG_free(path);
 	}
 }
 
-// We roll our own string to float because the std library one uses locale and messes things up.
+/* We roll our own string to float because the std library one uses locale and messes things up. */
 static double nsvg__atof(const char* s)
 {
 	char* cur = (char*)s;
 	char* end = NULL;
 	double res = 0.0, sign = 1.0;
@@ -1162,21 +1162,21 @@
 #else
 	long long intPart = 0, fracPart = 0;
 #endif
 	char hasIntPart = 0, hasFracPart = 0;
 
-	// Parse optional sign
+	/* Parse optional sign */
 	if (*cur == '+') {
 		cur++;
 	} else if (*cur == '-') {
 		sign = -1;
 		cur++;
 	}
 
-	// Parse integer part
+	/* Parse integer part */
 	if (nsvg__isdigit(*cur)) {
-		// Parse digit sequence
+		/* Parse digit sequence */
 #if defined(_MSC_VER) && (_MSC_VER == 1200)
 		intPart = strtol(cur, &end, 10);
 #else
 		intPart = strtoll(cur, &end, 10);
 #endif
@@ -1185,15 +1185,15 @@
 			hasIntPart = 1;
 			cur = end;
 		}
 	}
 
-	// Parse fractional part.
+	/* Parse fractional part. */
 	if (*cur == '.') {
-		cur++; // Skip '.'
+		cur++; /* Skip '.' */
 		if (nsvg__isdigit(*cur)) {
-			// Parse digit sequence
+			/* Parse digit sequence */
 #if defined(_MSC_VER) && (_MSC_VER == 1200)
 			fracPart = strtol(cur, &end, 10);
 #else
 			fracPart = strtoll(cur, &end, 10);
 #endif
@@ -1203,19 +1203,19 @@
 				cur = end;
 			}
 		}
 	}
 
-	// A valid number should have integer or fractional part.
+	/* A valid number should have integer or fractional part. */
 	if (!hasIntPart && !hasFracPart)
 		return 0.0;
 
-	// Parse optional exponent
+	/* Parse optional exponent */
 	if (*cur == 'e' || *cur == 'E') {
 		int expPart = 0;
-		cur++; // skip 'E'
-		expPart = strtol(cur, &end, 10); // Parse digit sequence with sign
+		cur++; /* skip 'E' */
+		expPart = strtol(cur, &end, 10); /* Parse digit sequence with sign */
 		if (cur != end) {
 			res *= pow(10.0, (double)expPart);
 		}
 	}
 
@@ -1226,31 +1226,31 @@
 static const char* nsvg__parseNumber(const char* s, char* it, const int size)
 {
 	const int last = size-1;
 	int i = 0;
 
-	// sign
+	/* sign */
 	if (*s == '-' || *s == '+') {
 		if (i < last) it[i++] = *s;
 		s++;
 	}
-	// integer part
+	/* integer part */
 	while (*s && nsvg__isdigit(*s)) {
 		if (i < last) it[i++] = *s;
 		s++;
 	}
 	if (*s == '.') {
-		// decimal point
+		/* decimal point */
 		if (i < last) it[i++] = *s;
 		s++;
-		// fraction part
+		/* fraction part */
 		while (*s && nsvg__isdigit(*s)) {
 			if (i < last) it[i++] = *s;
 			s++;
 		}
 	}
-	// exponent
+	/* exponent */
 	if (*s == 'e' || *s == 'E') {
 		if (i < last) it[i++] = *s;
 		s++;
 		if (*s == '-' || *s == '+') {
 			if (i < last) it[i++] = *s;
@@ -1267,17 +1267,17 @@
 }
 
 static const char* nsvg__getNextPathItem(const char* s, char* it)
 {
 	it[0] = '\0';
-	// Skip white spaces and commas
+	/* Skip white spaces and commas */
 	while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
 	if (!*s) return s;
 	if (*s == '-' || *s == '+' || *s == '.' || nsvg__isdigit(*s)) {
 		s = nsvg__parseNumber(s, it, 64);
 	} else {
-		// Parse command
+		/* Parse command */
 		it[0] = *s++;
 		it[1] = '\0';
 		return s;
 	}
 
@@ -1284,39 +1284,74 @@
 	return s;
 }
 
 static unsigned int nsvg__parseColorHex(const char* str)
 {
-	unsigned int c = 0, r = 0, g = 0, b = 0;
-	int n = 0;
-	str++; // skip #
-	// Calculate number of characters.
-	while(str[n] && !nsvg__isspace(str[n]))
-		n++;
-	if (n == 6) {
-		sscanf(str, "%x", &c);
-	} else if (n == 3) {
-		sscanf(str, "%x", &c);
-		c = (c&0xf) | ((c&0xf0) << 4) | ((c&0xf00) << 8);
-		c |= c<<4;
-	}
-	r = (c >> 16) & 0xff;
-	g = (c >> 8) & 0xff;
-	b = c & 0xff;
-	return NSVG_RGB(r,g,b);
-}
+	unsigned int r=0, g=0, b=0;
+	if (sscanf(str, "#%2x%2x%2x", &r, &g, &b) == 3 )		/* 2 digit hex */
+		return NSVG_RGB(r, g, b);
+	if (sscanf(str, "#%1x%1x%1x", &r, &g, &b) == 3 )		/* 1 digit hex, e.g. #abc -> 0xccbbaa */
+		return NSVG_RGB(r*17, g*17, b*17);			/* same effect as (r<<4|r), (g<<4|g), .. */
+	return NSVG_RGB(128, 128, 128);
+}
+
+/*
+ * Parse rgb color. The pointer 'str' must point at "rgb(" (4+ characters).
+ * This function returns gray (rgb(128, 128, 128) == '#808080') on parse errors
+ * for backwards compatibility. Note: other image viewers return black instead.
+ */
 
 static unsigned int nsvg__parseColorRGB(const char* str)
 {
-	int r = -1, g = -1, b = -1;
-	char s1[32]="", s2[32]="";
-	sscanf(str + 4, "%d%[%%, \t]%d%[%%, \t]%d", &r, s1, &g, s2, &b);
-	if (strchr(s1, '%')) {
-		return NSVG_RGB((r*255)/100,(g*255)/100,(b*255)/100);
-	} else {
-		return NSVG_RGB(r,g,b);
-	}
+	int i;
+	unsigned int rgbi[3];
+	float rgbf[3];
+	/* try decimal integers first */
+	if (sscanf(str, "rgb(%u, %u, %u)", &rgbi[0], &rgbi[1], &rgbi[2]) != 3) {
+		/* integers failed, try percent values (float, locale independent) */
+		const char delimiter[3] = {',', ',', ')'};
+		str += 4; /* skip "rgb(" */
+		for (i = 0; i < 3; i++) {
+			while (*str && (nsvg__isspace(*str))) str++; 	/* skip leading spaces */
+			if (*str == '+') str++;				/* skip '+' (don't allow '-') */
+			if (!*str) break;
+			rgbf[i] = nsvg__atof(str);
+
+			/*
+			 * Note 1: it would be great if nsvg__atof() returned how many
+			 * bytes it consumed but it doesn't. We need to skip the number,
+			 * the '%' character, spaces, and the delimiter ',' or ')'.
+			 *
+			 * Note 2: The following code does not allow values like "33.%",
+			 * i.e. a decimal point w/o fractional part, but this is consistent
+			 * with other image viewers, e.g. firefox, chrome, eog, gimp.
+			 */
+
+			while (*str && nsvg__isdigit(*str)) str++;		/* skip integer part */
+			if (*str == '.') {
+				str++;
+				if (!nsvg__isdigit(*str)) break;		/* error: no digit after '.' */
+				while (*str && nsvg__isdigit(*str)) str++;	/* skip fractional part */
+			}
+			if (*str == '%') str++; else break;
+			while (nsvg__isspace(*str)) str++;
+			if (*str == delimiter[i]) str++;
+			else break;
+		}
+		if (i == 3) {
+			rgbi[0] = roundf(rgbf[0] * 2.55f);
+			rgbi[1] = roundf(rgbf[1] * 2.55f);
+			rgbi[2] = roundf(rgbf[2] * 2.55f);
+		} else {
+			rgbi[0] = rgbi[1] = rgbi[2] = 128;
+		}
+	}
+	/* clip values as the CSS spec requires */
+	for (i = 0; i < 3; i++) {
+		if (rgbi[i] > 255) rgbi[i] = 255;
+	}
+	return NSVG_RGB(rgbi[0], rgbi[1], rgbi[2]);
 }
 
 typedef struct NSVGNamedColor {
 	const char* name;
 	unsigned int color;
@@ -1541,15 +1576,15 @@
 	return NSVG_UNITS_USER;
 }
 
 static int nsvg__isCoordinate(const char* s)
 {
-	// optional sign
+	/* optional sign */
 	if (*s == '-' || *s == '+')
 		s++;
-	// must have at least one digit
-	return nsvg__isdigit(*s);
+	/* must have at least one digit, or start by a dot */
+	return (nsvg__isdigit(*s) || *s == '.');
 }
 
 static NSVGcoordinate nsvg__parseCoordinateRaw(const char* str)
 {
 	NSVGcoordinate coord = {0, NSVG_UNITS_USER};
@@ -1721,14 +1756,14 @@
 }
 
 static void nsvg__parseUrl(char* id, const char* str)
 {
 	int i = 0;
-	str += 4; // "url(";
-	if (*str == '#')
+	str += 4; /* "url("; */
+	if (*str && *str == '#')
 		str++;
-	while (i < 63 && *str != ')') {
+	while (i < 63 && *str && *str != ')') {
 		id[i] = *str++;
 		i++;
 	}
 	id[i] = '\0';
 }
@@ -1739,11 +1774,11 @@
 		return NSVG_CAP_BUTT;
 	else if (strcmp(str, "round") == 0)
 		return NSVG_CAP_ROUND;
 	else if (strcmp(str, "square") == 0)
 		return NSVG_CAP_SQUARE;
-	// TODO: handle inherit.
+	/* TODO: handle inherit. */
 	return NSVG_CAP_BUTT;
 }
 
 static char nsvg__parseLineJoin(const char* str)
 {
@@ -1751,31 +1786,31 @@
 		return NSVG_JOIN_MITER;
 	else if (strcmp(str, "round") == 0)
 		return NSVG_JOIN_ROUND;
 	else if (strcmp(str, "bevel") == 0)
 		return NSVG_JOIN_BEVEL;
-	// TODO: handle inherit.
+	/* TODO: handle inherit. */
 	return NSVG_JOIN_MITER;
 }
 
 static char nsvg__parseFillRule(const char* str)
 {
 	if (strcmp(str, "nonzero") == 0)
 		return NSVG_FILLRULE_NONZERO;
 	else if (strcmp(str, "evenodd") == 0)
 		return NSVG_FILLRULE_EVENODD;
-	// TODO: handle inherit.
+	/* TODO: handle inherit. */
 	return NSVG_FILLRULE_NONZERO;
 }
 
 static const char* nsvg__getNextDashItem(const char* s, char* it)
 {
 	int n = 0;
 	it[0] = '\0';
-	// Skip white spaces and commas
+	/* Skip white spaces and commas */
 	while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
-	// Advance until whitespace, comma or end.
+	/* Advance until whitespace, comma or end. */
 	while (*s && (!nsvg__isspace(*s) && *s != ',')) {
 		if (n < 63)
 			it[n++] = *s;
 		s++;
 	}
@@ -1787,15 +1822,15 @@
 {
 	char item[64];
 	int count = 0, i;
 	float sum = 0.0f;
 
-	// Handle "none"
+	/* Handle "none" */
 	if (str[0] == 'n')
 		return 0;
 
-	// Parse dashes
+	/* Parse dashes */
 	while (*str) {
 		str = nsvg__getNextDashItem(str, item);
 		if (!*item) break;
 		if (count < NSVG_MAX_DASHES)
 			strokeDashArray[count++] = fabsf(nsvg__parseCoordinate(p, item, 0.0f, nsvg__actualLength(p)));
@@ -1820,11 +1855,11 @@
 	if (strcmp(name, "style") == 0) {
 		nsvg__parseStyle(p, value);
 	} else if (strcmp(name, "display") == 0) {
 		if (strcmp(value, "none") == 0)
 			attr->visible &= ~NSVG_VIS_DISPLAY;
-		// Don't reset ->visible on display:inline, one display:none hides the whole subtree
+		/* Don't reset ->visible on display:inline, one display:none hides the whole subtree */
 
 	} else if (strcmp(name, "visibility") == 0) {
 		if (strcmp(value, "hidden") == 0) {
 			attr->visible &= ~NSVG_VIS_VISIBLE;
 		} else if (strcmp(value, "visible") == 0) {
@@ -1912,11 +1947,11 @@
 	str = start;
 	while (str < end && *str != ':') ++str;
 
 	val = str;
 
-	// Right Trim
+	/* Right Trim */
 	while (str > start &&  (*str == ':' || nsvg__isspace(*str))) --str;
 	++str;
 
 	n = (int)(str - start);
 	if (n > 511) n = 511;
@@ -1937,17 +1972,17 @@
 {
 	const char* start;
 	const char* end;
 
 	while (*str) {
-		// Left Trim
+		/* Left Trim */
 		while(*str && nsvg__isspace(*str)) ++str;
 		start = str;
 		while(*str && *str != ';') ++str;
 		end = str;
 
-		// Right Trim
+		/* Right Trim */
 		while (end > start &&  (*end == ';' || nsvg__isspace(*end))) --end;
 		++end;
 
 		nsvg__parseNameValue(p, start, end);
 		if (*str) ++str;
@@ -2118,11 +2153,11 @@
 		cy = args[1];
 		x2 = args[2];
 		y2 = args[3];
 	}
 
-	// Convert to cubic bezier
+	/* Convert to cubic bezier */
 	cx1 = x1 + 2.0f/3.0f*(cx - x1);
 	cy1 = y1 + 2.0f/3.0f*(cy - y1);
 	cx2 = x2 + 2.0f/3.0f*(cx - x2);
 	cy2 = y2 + 2.0f/3.0f*(cy - y2);
 
@@ -2151,11 +2186,11 @@
 	}
 
 	cx = 2*x1 - *cpx2;
 	cy = 2*y1 - *cpy2;
 
-	// Convert to cubix bezier
+	/* Convert to cubix bezier */
 	cx1 = x1 + 2.0f/3.0f*(cx - x1);
 	cy1 = y1 + 2.0f/3.0f*(cy - y1);
 	cx2 = x2 + 2.0f/3.0f*(cx - x2);
 	cy2 = y2 + 2.0f/3.0f*(cy - y2);
 
@@ -2183,11 +2218,11 @@
 	return ((ux*vy < uy*vx) ? -1.0f : 1.0f) * acosf(r);
 }
 
 static void nsvg__pathArcTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
 {
-	// Ported from canvg (https://code.google.com/p/canvg/)
+	/* Ported from canvg (https://code.google.com/p/canvg/) */
 	float rx, ry, rotx;
 	float x1, y1, x2, y2, cx, cy, dx, dy, d;
 	float x1p, y1p, cxp, cyp, s, sa, sb;
 	float ux, uy, vx, vy, a1, da;
 	float x, y, tanx, tany, a, px = 0, py = 0, ptanx = 0, ptany = 0, t[6];
@@ -2194,18 +2229,18 @@
 	float sinrx, cosrx;
 	int fa, fs;
 	int i, ndivs;
 	float hda, kappa;
 
-	rx = fabsf(args[0]);				// y radius
-	ry = fabsf(args[1]);				// x radius
-	rotx = args[2] / 180.0f * NSVG_PI;		// x rotation angle
-	fa = fabsf(args[3]) > 1e-6 ? 1 : 0;	// Large arc
-	fs = fabsf(args[4]) > 1e-6 ? 1 : 0;	// Sweep direction
-	x1 = *cpx;							// start point
+	rx = fabsf(args[0]);				/* y radius */
+	ry = fabsf(args[1]);				/* x radius */
+	rotx = args[2] / 180.0f * NSVG_PI;		/* x rotation angle */
+	fa = fabsf(args[3]) > 1e-6 ? 1 : 0;	/* Large arc */
+	fs = fabsf(args[4]) > 1e-6 ? 1 : 0;	/* Sweep direction */
+	x1 = *cpx;							/* start point */
 	y1 = *cpy;
-	if (rel) {							// end point
+	if (rel) {							/* end point */
 		x2 = *cpx + args[5];
 		y2 = *cpy + args[6];
 	} else {
 		x2 = args[5];
 		y2 = args[6];
@@ -2213,32 +2248,32 @@
 
 	dx = x1 - x2;
 	dy = y1 - y2;
 	d = sqrtf(dx*dx + dy*dy);
 	if (d < 1e-6f || rx < 1e-6f || ry < 1e-6f) {
-		// The arc degenerates to a line
+		/* The arc degenerates to a line */
 		nsvg__lineTo(p, x2, y2);
 		*cpx = x2;
 		*cpy = y2;
 		return;
 	}
 
 	sinrx = sinf(rotx);
 	cosrx = cosf(rotx);
 
-	// Convert to center point parameterization.
-	// http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
-	// 1) Compute x1', y1'
+	/* Convert to center point parameterization. */
+	/* http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes */
+	/* 1) Compute x1', y1' */
 	x1p = cosrx * dx / 2.0f + sinrx * dy / 2.0f;
 	y1p = -sinrx * dx / 2.0f + cosrx * dy / 2.0f;
 	d = nsvg__sqr(x1p)/nsvg__sqr(rx) + nsvg__sqr(y1p)/nsvg__sqr(ry);
 	if (d > 1) {
 		d = sqrtf(d);
 		rx *= d;
 		ry *= d;
 	}
-	// 2) Compute cx', cy'
+	/* 2) Compute cx', cy' */
 	s = 0.0f;
 	sa = nsvg__sqr(rx)*nsvg__sqr(ry) - nsvg__sqr(rx)*nsvg__sqr(y1p) - nsvg__sqr(ry)*nsvg__sqr(x1p);
 	sb = nsvg__sqr(rx)*nsvg__sqr(y1p) + nsvg__sqr(ry)*nsvg__sqr(x1p);
 	if (sa < 0.0f) sa = 0.0f;
 	if (sb > 0.0f)
@@ -2246,49 +2281,54 @@
 	if (fa == fs)
 		s = -s;
 	cxp = s * rx * y1p / ry;
 	cyp = s * -ry * x1p / rx;
 
-	// 3) Compute cx,cy from cx',cy'
+	/* 3) Compute cx,cy from cx',cy' */
 	cx = (x1 + x2)/2.0f + cosrx*cxp - sinrx*cyp;
 	cy = (y1 + y2)/2.0f + sinrx*cxp + cosrx*cyp;
 
-	// 4) Calculate theta1, and delta theta.
+	/* 4) Calculate theta1, and delta theta. */
 	ux = (x1p - cxp) / rx;
 	uy = (y1p - cyp) / ry;
 	vx = (-x1p - cxp) / rx;
 	vy = (-y1p - cyp) / ry;
-	a1 = nsvg__vecang(1.0f,0.0f, ux,uy);	// Initial angle
-	da = nsvg__vecang(ux,uy, vx,vy);		// Delta angle
+	a1 = nsvg__vecang(1.0f,0.0f, ux,uy);	/* Initial angle */
+	da = nsvg__vecang(ux,uy, vx,vy);		/* Delta angle */
 
-//	if (vecrat(ux,uy,vx,vy) <= -1.0f) da = NSVG_PI;
-//	if (vecrat(ux,uy,vx,vy) >= 1.0f) da = 0;
+/*	if (vecrat(ux,uy,vx,vy) <= -1.0f) da = NSVG_PI; */
+/*	if (vecrat(ux,uy,vx,vy) >= 1.0f) da = 0; */
 
 	if (fs == 0 && da > 0)
 		da -= 2 * NSVG_PI;
 	else if (fs == 1 && da < 0)
 		da += 2 * NSVG_PI;
 
-	// Approximate the arc using cubic spline segments.
+	/* Approximate the arc using cubic spline segments. */
 	t[0] = cosrx; t[1] = sinrx;
 	t[2] = -sinrx; t[3] = cosrx;
 	t[4] = cx; t[5] = cy;
 
-	// Split arc into max 90 degree segments.
-	// The loop assumes an iteration per end point (including start and end), this +1.
+	/* Split arc into max 90 degree segments. */
+	/* The loop assumes an iteration per end point (including start and end), this +1. */
 	ndivs = (int)(fabsf(da) / (NSVG_PI*0.5f) + 1.0f);
 	hda = (da / (float)ndivs) / 2.0f;
-	kappa = fabsf(4.0f / 3.0f * (1.0f - cosf(hda)) / sinf(hda));
+	/* Fix for ticket #179: division by 0: avoid cotangens around 0 (infinite) */
+	if ((hda < 1e-3f) && (hda > -1e-3f))
+		hda *= 0.5f;
+	else
+		hda = (1.0f - cosf(hda)) / sinf(hda);
+	kappa = fabsf(4.0f / 3.0f * hda);
 	if (da < 0.0f)
 		kappa = -kappa;
 
 	for (i = 0; i <= ndivs; i++) {
 		a = a1 + da * ((float)i/(float)ndivs);
 		dx = cosf(a);
 		dy = sinf(a);
-		nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); // position
-		nsvg__xformVec(&tanx, &tany, -dy*rx * kappa, dx*ry * kappa, t); // tangent
+		nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); /* position */
+		nsvg__xformVec(&tanx, &tany, -dy*rx * kappa, dx*ry * kappa, t); /* tangent */
 		if (i > 0)
 			nsvg__cubicBezTo(p, px+ptanx,py+ptany, x-tanx, y-tany, x, y);
 		px = x;
 		py = y;
 		ptanx = tanx;
@@ -2342,12 +2382,12 @@
 				if (nargs >= rargs) {
 					switch (cmd) {
 						case 'm':
 						case 'M':
 							nsvg__pathMoveTo(p, &cpx, &cpy, args, cmd == 'm' ? 1 : 0);
-							// Moveto can be followed by multiple coordinate pairs,
-							// which should be treated as linetos.
+							/* Moveto can be followed by multiple coordinate pairs, */
+							/* which should be treated as linetos. */
 							cmd = (cmd == 'm') ? 'l' : 'L';
 							rargs = nsvg__getArgsPerElement(cmd);
 							cpx2 = cpx; cpy2 = cpy;
 							initPoint = 1;
 							break;
@@ -2398,46 +2438,46 @@
 					nargs = 0;
 				}
 			} else {
 				cmd = item[0];
 				if (cmd == 'M' || cmd == 'm') {
-					// Commit path.
+					/* Commit path. */
 					if (p->npts > 0)
 						nsvg__addPath(p, closedFlag);
-					// Start new subpath.
+					/* Start new subpath. */
 					nsvg__resetPath(p);
 					closedFlag = 0;
 					nargs = 0;
 				} else if (initPoint == 0) {
-					// Do not allow other commands until initial point has been set (moveTo called once).
+					/* Do not allow other commands until initial point has been set (moveTo called once). */
 					cmd = '\0';
 				}
 				if (cmd == 'Z' || cmd == 'z') {
 					closedFlag = 1;
-					// Commit path.
+					/* Commit path. */
 					if (p->npts > 0) {
-						// Move current point to first point
+						/* Move current point to first point */
 						cpx = p->pts[0];
 						cpy = p->pts[1];
 						cpx2 = cpx; cpy2 = cpy;
 						nsvg__addPath(p, closedFlag);
 					}
-					// Start new subpath.
+					/* Start new subpath. */
 					nsvg__resetPath(p);
 					nsvg__moveTo(p, cpx, cpy);
 					closedFlag = 0;
 					nargs = 0;
 				}
 				rargs = nsvg__getArgsPerElement(cmd);
 				if (rargs == -1) {
-					// Command not recognized
+					/* Command not recognized */
 					cmd = '\0';
 					rargs = 0;
 				}
 			}
 		}
-		// Commit path.
+		/* Commit path. */
 		if (p->npts)
 			nsvg__addPath(p, closedFlag);
 	}
 
 	nsvg__addShape(p);
@@ -2447,11 +2487,11 @@
 {
 	float x = 0.0f;
 	float y = 0.0f;
 	float w = 0.0f;
 	float h = 0.0f;
-	float rx = -1.0f; // marks not set
+	float rx = -1.0f; /* marks not set */
 	float ry = -1.0f;
 	int i;
 
 	for (i = 0; attr[i]; i += 2) {
 		if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
@@ -2478,11 +2518,11 @@
 			nsvg__moveTo(p, x, y);
 			nsvg__lineTo(p, x+w, y);
 			nsvg__lineTo(p, x+w, y+h);
 			nsvg__lineTo(p, x, y+h);
 		} else {
-			// Rounded rectangle
+			/* Rounded rectangle */
 			nsvg__moveTo(p, x+rx, y);
 			nsvg__lineTo(p, x+w-rx, y);
 			nsvg__cubicBezTo(p, x+w-rx*(1-NSVG_KAPPA90), y, x+w, y+ry*(1-NSVG_KAPPA90), x+w, y+ry);
 			nsvg__lineTo(p, x+w, y+h-ry);
 			nsvg__cubicBezTo(p, x+w, y+h-ry*(1-NSVG_KAPPA90), x+w-rx*(1-NSVG_KAPPA90), y+h, x+w-rx, y+h);
@@ -2635,28 +2675,28 @@
 				p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f);
 			} else if (strcmp(attr[i], "viewBox") == 0) {
 				sscanf(attr[i + 1], "%f%*[%%, \t]%f%*[%%, \t]%f%*[%%, \t]%f", &p->viewMinx, &p->viewMiny, &p->viewWidth, &p->viewHeight);
 			} else if (strcmp(attr[i], "preserveAspectRatio") == 0) {
 				if (strstr(attr[i + 1], "none") != 0) {
-					// No uniform scaling
+					/* No uniform scaling */
 					p->alignType = NSVG_ALIGN_NONE;
 				} else {
-					// Parse X align
+					/* Parse X align */
 					if (strstr(attr[i + 1], "xMin") != 0)
 						p->alignX = NSVG_ALIGN_MIN;
 					else if (strstr(attr[i + 1], "xMid") != 0)
 						p->alignX = NSVG_ALIGN_MID;
 					else if (strstr(attr[i + 1], "xMax") != 0)
 						p->alignX = NSVG_ALIGN_MAX;
-					// Parse X align
+					/* Parse X align */
 					if (strstr(attr[i + 1], "yMin") != 0)
 						p->alignY = NSVG_ALIGN_MIN;
 					else if (strstr(attr[i + 1], "yMid") != 0)
 						p->alignY = NSVG_ALIGN_MID;
 					else if (strstr(attr[i + 1], "yMax") != 0)
 						p->alignY = NSVG_ALIGN_MAX;
-					// Parse meet/slice
+					/* Parse meet/slice */
 					p->alignType = NSVG_ALIGN_MEET;
 					if (strstr(attr[i + 1], "slice") != 0)
 						p->alignType = NSVG_ALIGN_SLICE;
 				}
 			}
@@ -2747,19 +2787,19 @@
 
 	for (i = 0; attr[i]; i += 2) {
 		nsvg__parseAttr(p, attr[i], attr[i + 1]);
 	}
 
-	// Add stop to the last gradient.
+	/* Add stop to the last gradient. */
 	grad = p->gradients;
 	if (grad == NULL) return;
 
 	grad->nstops++;
 	grad->stops = (NSVGgradientStop*)NANOSVG_realloc(grad->stops, sizeof(NSVGgradientStop)*grad->nstops);
 	if (grad->stops == NULL) return;
 
-	// Insert
+	/* Insert */
 	idx = grad->nstops-1;
 	for (i = 0; i < grad->nstops-1; i++) {
 		if (curAttr->stopOffset < grad->stops[i].offset) {
 			idx = i;
 			break;
@@ -2779,11 +2819,11 @@
 static void nsvg__startElement(void* ud, const char* el, const char** attr)
 {
 	NSVGparser* p = (NSVGparser*)ud;
 
 	if (p->defsFlag) {
-		// Skip everything but gradients in defs
+		/* Skip everything but gradients in defs */
 		if (strcmp(el, "linearGradient") == 0) {
 			nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT);
 		} else if (strcmp(el, "radialGradient") == 0) {
 			nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT);
 		} else if (strcmp(el, "stop") == 0) {
@@ -2794,11 +2834,11 @@
 
 	if (strcmp(el, "g") == 0) {
 		nsvg__pushAttr(p);
 		nsvg__parseAttribs(p, attr);
 	} else if (strcmp(el, "path") == 0) {
-		if (p->pathFlag)	// Do not allow nested paths.
+		if (p->pathFlag)	/* Do not allow nested paths. */
 			return;
 		nsvg__pushAttr(p);
 		nsvg__parsePath(p, attr);
 		nsvg__popAttr(p);
 	} else if (strcmp(el, "rect") == 0) {
@@ -2947,11 +2987,11 @@
 {
 	if (type == NSVG_ALIGN_MIN)
 		return 0;
 	else if (type == NSVG_ALIGN_MAX)
 		return container - content;
-	// mid
+	/* mid */
 	return (container - content) * 0.5f;
 }
 
 static void nsvg__scaleGradient(NSVGgradient* grad, float tx, float ty, float sx, float sy)
 {
@@ -2969,11 +3009,11 @@
 	NSVGpath* path;
 	float tx, ty, sx, sy, us, bounds[4], t[6], avgs;
 	int i;
 	float* pt;
 
-	// Guess image size if not set completely.
+	/* Guess image size if not set completely. */
 	nsvg__imageBounds(p, bounds);
 
 	if (p->viewWidth == 0) {
 		if (p->image->width > 0) {
 			p->viewWidth = p->image->width;
@@ -2997,27 +3037,27 @@
 
 	tx = -p->viewMinx;
 	ty = -p->viewMiny;
 	sx = p->viewWidth > 0 ? p->image->width / p->viewWidth : 0;
 	sy = p->viewHeight > 0 ? p->image->height / p->viewHeight : 0;
-	// Unit scaling
+	/* Unit scaling */
 	us = 1.0f / nsvg__convertToPixels(p, nsvg__coord(1.0f, nsvg__parseUnits(units)), 0.0f, 1.0f);
 
-	// Fix aspect ratio
+	/* Fix aspect ratio */
 	if (p->alignType == NSVG_ALIGN_MEET) {
-		// fit whole image into viewbox
+		/* fit whole image into viewbox */
 		sx = sy = nsvg__minf(sx, sy);
 		tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
 		ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
 	} else if (p->alignType == NSVG_ALIGN_SLICE) {
-		// fill whole viewbox with image
+		/* fill whole viewbox with image */
 		sx = sy = nsvg__maxf(sx, sy);
 		tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
 		ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
 	}
 
-	// Transform
+	/* Transform */
 	sx *= us;
 	sy *= us;
 	avgs = (sx+sy) / 2.0f;
 	for (shape = p->image->shapes; shape != NULL; shape = shape->next) {
 		shape->bounds[0] = (shape->bounds[0] + tx) * sx;
@@ -3066,11 +3106,11 @@
 	}
 	p->dpi = dpi;
 
 	nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p);
 
-	// Scale to viewBox
+	/* Scale to viewBox */
 	nsvg__scaleToViewbox(p, units);
 
 	ret = p->image;
 	p->image = NULL;
 
@@ -3093,11 +3133,11 @@
 	size = ftell(fp);
 	fseek(fp, 0, SEEK_SET);
 	data = (char*)NANOSVG_malloc(size+1);
 	if (data == NULL) goto error;
 	if (fread(data, 1, size, fp) != size) goto error;
-	data[size] = '\0';	// Must be null terminated.
+	data[size] = '\0';	/* Must be null terminated. */
 	fclose(fp);
 	image = nsvgParse(data, units, dpi);
 	NANOSVG_free(data);
 
 	return image;
@@ -3125,5 +3165,7 @@
 	}
 	NANOSVG_free(image);
 }
 
 #endif
+
+#endif /* NANOSVG_H */

Index: generic/nanosvgrast.h
==================================================================
--- generic/nanosvgrast.h
+++ generic/nanosvgrast.h
@@ -23,10 +23,12 @@
  */
 
 #ifndef NANOSVGRAST_H
 #define NANOSVGRAST_H
 
+#include "nanosvg.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 #ifndef NANOSVG_SCOPE
@@ -57,39 +59,40 @@
 	unsigned char* img = malloc(w*h*4);
 	// Rasterize
 	nsvgRasterize(rast, image, 0,0,1, img, w, h, w*4);
 */
 
-// Allocated rasterizer context.
+/* Allocated rasterizer context. */
 NANOSVG_SCOPE NSVGrasterizer* nsvgCreateRasterizer(void);
 
-// Rasterizes SVG image, returns RGBA image (non-premultiplied alpha)
-//   r - pointer to rasterizer context
-//   image - pointer to image to rasterize
-//   tx,ty - image offset (applied after scaling)
-//   scale - image scale
-//   dst - pointer to destination image data, 4 bytes per pixel (RGBA)
-//   w - width of the image to render
-//   h - height of the image to render
-//   stride - number of bytes per scaleline in the destination buffer
+/* Rasterizes SVG image, returns RGBA image (non-premultiplied alpha)
+ *   r - pointer to rasterizer context
+ *   image - pointer to image to rasterize
+ *   tx,ty - image offset (applied after scaling)
+ *   scale - image scale
+ *   dst - pointer to destination image data, 4 bytes per pixel (RGBA)
+ *   w - width of the image to render
+ *   h - height of the image to render
+ *   stride - number of bytes per scaleline in the destination buffer
 NANOSVG_SCOPE void nsvgRasterize(NSVGrasterizer* r,
 				   NSVGimage* image, float tx, float ty, float scale,
 				   unsigned char* dst, int w, int h, int stride);
+ */
 
-// Deletes rasterizer context.
+/* Deletes rasterizer context. */
 NANOSVG_SCOPE void nsvgDeleteRasterizer(NSVGrasterizer*);
 
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif // NANOSVGRAST_H
-
 #ifdef NANOSVGRAST_IMPLEMENTATION
 
 #include <math.h>
+#include <stdlib.h>
+#include <string.h>
 
 #define NSVG__SUBSAMPLES	5
 #define NSVG__FIXSHIFT		10
 #define NSVG__FIX			(1 << NSVG__FIXSHIFT)
 #define NSVG__FIXMASK		(NSVG__FIX-1)
@@ -200,21 +203,21 @@
 
 static NSVGmemPage* nsvg__nextPage(NSVGrasterizer* r, NSVGmemPage* cur)
 {
 	NSVGmemPage *newp;
 
-	// If using existing chain, return the next page in chain
+	/* If using existing chain, return the next page in chain */
 	if (cur != NULL && cur->next != NULL) {
 		return cur->next;
 	}
 
-	// Alloc new page
+	/* Alloc new page */
 	newp = (NSVGmemPage*)NANOSVG_malloc(sizeof(NSVGmemPage));
 	if (newp == NULL) return NULL;
 	memset(newp, 0, sizeof(NSVGmemPage));
 
-	// Add to linked list
+	/* Add to linked list */
 	if (cur != NULL)
 		cur->next = newp;
 	else
 		r->pages = newp;
 
@@ -300,11 +303,11 @@
 
 static void nsvg__addEdge(NSVGrasterizer* r, float x0, float y0, float x1, float y1)
 {
 	NSVGedge* e;
 
-	// Skip horizontal edges
+	/* Skip horizontal edges */
 	if (y0 == y1)
 		return;
 
 	if (r->nedges+1 > r->cedges) {
 		r->cedges = r->cedges > 0 ? r->cedges * 2 : 64;
@@ -386,19 +389,19 @@
 	int i, j;
 	NSVGpath* path;
 
 	for (path = shape->paths; path != NULL; path = path->next) {
 		r->npoints = 0;
-		// Flatten path
+		/* Flatten path */
 		nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
 		for (i = 0; i < path->npts-1; i += 3) {
 			float* p = &path->pts[i*2];
 			nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, 0);
 		}
-		// Close path
+		/* Close path */
 		nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
-		// Build edges
+		/* Build edges */
 		for (i = 0, j = r->npoints-1; i < r->npoints; j = i++)
 			nsvg__addEdge(r, r->points[j].x, r->points[j].y, r->points[i].x, r->points[i].y);
 	}
 }
 
@@ -617,24 +620,24 @@
 	return divs;
 }
 
 static void nsvg__expandStroke(NSVGrasterizer* r, NSVGpoint* points, int npoints, int closed, int lineJoin, int lineCap, float lineWidth)
 {
-	int ncap = nsvg__curveDivs(lineWidth*0.5f, NSVG_PI, r->tessTol);	// Calculate divisions per half circle.
+	int ncap = nsvg__curveDivs(lineWidth*0.5f, NSVG_PI, r->tessTol);	/* Calculate divisions per half circle. */
 	NSVGpoint left = {0,0,0,0,0,0,0,0}, right = {0,0,0,0,0,0,0,0}, firstLeft = {0,0,0,0,0,0,0,0}, firstRight = {0,0,0,0,0,0,0,0};
 	NSVGpoint* p0, *p1;
 	int j, s, e;
 
-	// Build stroke edges
+	/* Build stroke edges */
 	if (closed) {
-		// Looping
+		/* Looping */
 		p0 = &points[npoints-1];
 		p1 = &points[0];
 		s = 0;
 		e = npoints;
 	} else {
-		// Add cap
+		/* Add cap */
 		p0 = &points[0];
 		p1 = &points[1];
 		s = 1;
 		e = npoints-1;
 	}
@@ -642,11 +645,11 @@
 	if (closed) {
 		nsvg__initClosed(&left, &right, p0, p1, lineWidth);
 		firstLeft = left;
 		firstRight = right;
 	} else {
-		// Add cap
+		/* Add cap */
 		float dx = p1->x - p0->x;
 		float dy = p1->y - p0->y;
 		nsvg__normalize(&dx, &dy);
 		if (lineCap == NSVG_CAP_BUTT)
 			nsvg__buttCap(r, &left, &right, p0, dx, dy, lineWidth, 0);
@@ -669,15 +672,15 @@
 		}
 		p0 = p1++;
 	}
 
 	if (closed) {
-		// Loop it
+		/* Loop it */
 		nsvg__addEdge(r, firstLeft.x, firstLeft.y, left.x, left.y);
 		nsvg__addEdge(r, right.x, right.y, firstRight.x, firstRight.y);
 	} else {
-		// Add cap
+		/* Add cap */
 		float dx = p1->x - p0->x;
 		float dy = p1->y - p0->y;
 		nsvg__normalize(&dx, &dy);
 		if (lineCap == NSVG_CAP_BUTT)
 			nsvg__buttCap(r, &right, &left, p1, -dx, -dy, lineWidth, 1);
@@ -694,28 +697,28 @@
 	NSVGpoint* p0, *p1;
 
 	p0 = &r->points[r->npoints-1];
 	p1 = &r->points[0];
 	for (i = 0; i < r->npoints; i++) {
-		// Calculate segment direction and length
+		/* Calculate segment direction and length */
 		p0->dx = p1->x - p0->x;
 		p0->dy = p1->y - p0->y;
 		p0->len = nsvg__normalize(&p0->dx, &p0->dy);
-		// Advance
+		/* Advance */
 		p0 = p1++;
 	}
 
-	// calculate joins
+	/* calculate joins */
 	p0 = &r->points[r->npoints-1];
 	p1 = &r->points[0];
 	for (j = 0; j < r->npoints; j++) {
 		float dlx0, dly0, dlx1, dly1, dmr2, cross;
 		dlx0 = p0->dy;
 		dly0 = -p0->dx;
 		dlx1 = p1->dy;
 		dly1 = -p1->dx;
-		// Calculate extrusions
+		/* Calculate extrusions */
 		p1->dmx = (dlx0 + dlx1) * 0.5f;
 		p1->dmy = (dly0 + dly1) * 0.5f;
 		dmr2 = p1->dmx*p1->dmx + p1->dmy*p1->dmy;
 		if (dmr2 > 0.000001f) {
 			float s2 = 1.0f / dmr2;
@@ -724,19 +727,19 @@
 			}
 			p1->dmx *= s2;
 			p1->dmy *= s2;
 		}
 
-		// Clear flags, but keep the corner.
+		/* Clear flags, but keep the corner. */
 		p1->flags = (p1->flags & NSVG_PT_CORNER) ? NSVG_PT_CORNER : 0;
 
-		// Keep track of left turns.
+		/* Keep track of left turns. */
 		cross = p1->dx * p0->dy - p0->dx * p1->dy;
 		if (cross > 0.0f)
 			p1->flags |= NSVG_PT_LEFT;
 
-		// Check to see if the corner needs to be beveled.
+		/* Check to see if the corner needs to be beveled. */
 		if (p1->flags & NSVG_PT_CORNER) {
 			if ((dmr2 * miterLimit*miterLimit) < 1.0f || lineJoin == NSVG_JOIN_BEVEL || lineJoin == NSVG_JOIN_ROUND) {
 				p1->flags |= NSVG_PT_BEVEL;
 			}
 		}
@@ -754,11 +757,11 @@
 	int lineJoin = shape->strokeLineJoin;
 	int lineCap = shape->strokeLineCap;
 	float lineWidth = shape->strokeWidth * scale;
 
 	for (path = shape->paths; path != NULL; path = path->next) {
-		// Flatten path
+		/* Flatten path */
 		r->npoints = 0;
 		nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, NSVG_PT_CORNER);
 		for (i = 0; i < path->npts-1; i += 3) {
 			float* p = &path->pts[i*2];
 			nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, NSVG_PT_CORNER);
@@ -766,11 +769,11 @@
 		if (r->npoints < 2)
 			continue;
 
 		closed = path->closed;
 
-		// If the first and last points are the same, remove the last, mark as closed path.
+		/* If the first and last points are the same, remove the last, mark as closed path. */
 		p0 = &r->points[r->npoints-1];
 		p1 = &r->points[0];
 		if (nsvg__ptEquals(p0->x,p0->y, p1->x,p1->y, r->distTol)) {
 			r->npoints--;
 			p0 = &r->points[r->npoints-1];
@@ -783,24 +786,24 @@
 			NSVGpoint cur;
 
 			if (closed)
 				nsvg__appendPathPoint(r, r->points[0]);
 
-			// Duplicate points -> points2.
+			/* Duplicate points -> points2. */
 			nsvg__duplicatePoints(r);
 
 			r->npoints = 0;
  			cur = r->points2[0];
 			nsvg__appendPathPoint(r, cur);
 
-			// Figure out dash offset.
+			/* Figure out dash offset. */
 			allDashLen = 0;
 			for (j = 0; j < shape->strokeDashCount; j++)
 				allDashLen += shape->strokeDashArray[j];
 			if (shape->strokeDashCount & 1)
 				allDashLen *= 2.0f;
-			// Find location inside pattern
+			/* Find location inside pattern */
 			dashOffset = fmodf(shape->strokeDashOffset, allDashLen);
 			if (dashOffset < 0.0f)
 				dashOffset += allDashLen;
 
 			while (dashOffset > shape->strokeDashArray[idash]) {
@@ -813,26 +816,26 @@
 				float dx = r->points2[j].x - cur.x;
 				float dy = r->points2[j].y - cur.y;
 				float dist = sqrtf(dx*dx + dy*dy);
 
 				if ((totalDist + dist) > dashLen) {
-					// Calculate intermediate point
+					/* Calculate intermediate point */
 					float d = (dashLen - totalDist) / dist;
 					float x = cur.x + dx * d;
 					float y = cur.y + dy * d;
 					nsvg__addPathPoint(r, x, y, NSVG_PT_CORNER);
 
-					// Stroke
+					/* Stroke */
 					if (r->npoints > 1 && dashState) {
 						nsvg__prepareStroke(r, miterLimit, lineJoin);
 						nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth);
 					}
-					// Advance dash pattern
+					/* Advance dash pattern */
 					dashState = !dashState;
 					idash = (idash+1) % shape->strokeDashCount;
 					dashLen = shape->strokeDashArray[idash] * scale;
-					// Restart
+					/* Restart */
 					cur.x = x;
 					cur.y = y;
 					cur.flags = NSVG_PT_CORNER;
 					totalDist = 0.0f;
 					r->npoints = 0;
@@ -842,11 +845,11 @@
 					cur = r->points2[j];
 					nsvg__appendPathPoint(r, cur);
 					j++;
 				}
 			}
-			// Stroke any leftover path
+			/* Stroke any leftover path */
 			if (r->npoints > 1 && dashState)
 				nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth);
 		} else {
 			nsvg__prepareStroke(r, miterLimit, lineJoin);
 			nsvg__expandStroke(r, r->points, r->npoints, closed, lineJoin, lineCap, lineWidth);
@@ -869,28 +872,28 @@
 {
 	 NSVGactiveEdge* z;
 	float dxdy;
 
 	if (r->freelist != NULL) {
-		// Restore from freelist.
+		/* Restore from freelist. */
 		z = r->freelist;
 		r->freelist = z->next;
 	} else {
-		// Alloc new edge.
+		/* Alloc new edge. */
 		z = (NSVGactiveEdge*)nsvg__alloc(r, sizeof(NSVGactiveEdge));
 		if (z == NULL) return NULL;
 	}
 
 	dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
-//	STBTT_assert(e->y0 <= start_point);
-	// round dx down to avoid going too far
+/*	STBTT_assert(e->y0 <= start_point); */
+	/* round dx down to avoid going too far */
 	if (dxdy < 0)
 		z->dx = (int)(-floorf(NSVG__FIX * -dxdy));
 	else
 		z->dx = (int)floorf(NSVG__FIX * dxdy);
 	z->x = (int)floorf(NSVG__FIX * (e->x0 + dxdy * (startPoint - e->y0)));
-//	z->x -= off_x * FIX;
+/*	z->x -= off_x * FIX; */
 	z->ey = e->y1;
 	z->next = 0;
 	z->dir = e->dir;
 
 	return z;
@@ -908,56 +911,57 @@
 	int j = x1 >> NSVG__FIXSHIFT;
 	if (i < *xmin) *xmin = i;
 	if (j > *xmax) *xmax = j;
 	if (i < len && j >= 0) {
 		if (i == j) {
-			// x0,x1 are the same pixel, so compute combined coverage
+			/* x0,x1 are the same pixel, so compute combined coverage */
 			scanline[i] = (unsigned char)(scanline[i] + ((x1 - x0) * maxWeight >> NSVG__FIXSHIFT));
 		} else {
-			if (i >= 0) // add antialiasing for x0
+			if (i >= 0) /* add antialiasing for x0 */
 				scanline[i] = (unsigned char)(scanline[i] + (((NSVG__FIX - (x0 & NSVG__FIXMASK)) * maxWeight) >> NSVG__FIXSHIFT));
 			else
-				i = -1; // clip
+				i = -1; /* clip */
 
-			if (j < len) // add antialiasing for x1
+			if (j < len) /* add antialiasing for x1 */
 				scanline[j] = (unsigned char)(scanline[j] + (((x1 & NSVG__FIXMASK) * maxWeight) >> NSVG__FIXSHIFT));
 			else
-				j = len; // clip
+				j = len; /* clip */
 
-			for (++i; i < j; ++i) // fill pixels between x0 and x1
+			for (++i; i < j; ++i) /* fill pixels between x0 and x1 */
 				scanline[i] = (unsigned char)(scanline[i] + maxWeight);
 		}
 	}
 }
 
-// note: this routine clips fills that extend off the edges... ideally this
-// wouldn't happen, but it could happen if the truetype glyph bounding boxes
-// are wrong, or if the user supplies a too-small bitmap
+/* note: this routine clips fills that extend off the edges... ideally this
+ * wouldn't happen, but it could happen if the truetype glyph bounding boxes
+ * are wrong, or if the user supplies a too-small bitmap
+ */
 static void nsvg__fillActiveEdges(unsigned char* scanline, int len, NSVGactiveEdge* e, int maxWeight, int* xmin, int* xmax, char fillRule)
 {
-	// non-zero winding fill
+	/* non-zero winding fill */
 	int x0 = 0, w = 0;
 
 	if (fillRule == NSVG_FILLRULE_NONZERO) {
-		// Non-zero
+		/* Non-zero */
 		while (e != NULL) {
 			if (w == 0) {
-				// if we're currently at zero, we need to record the edge start point
+				/* if we're currently at zero, we need to record the edge start point */
 				x0 = e->x; w += e->dir;
 			} else {
 				int x1 = e->x; w += e->dir;
-				// if we went to zero, we need to draw
+				/* if we went to zero, we need to draw */
 				if (w == 0)
 					nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax);
 			}
 			e = e->next;
 		}
 	} else if (fillRule == NSVG_FILLRULE_EVENODD) {
-		// Even-odd
+		/* Even-odd */
 		while (e != NULL) {
 			if (w == 0) {
-				// if we're currently at zero, we need to record the edge start point
+				/* if we're currently at zero, we need to record the edge start point */
 				x0 = e->x; w = 1;
 			} else {
 				int x1 = e->x; w = 0;
 				nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax);
 			}
@@ -968,11 +972,11 @@
 
 static float nsvg__clampf(float a, float mn, float mx) { return a < mn ? mn : (a > mx ? mx : a); }
 
 static unsigned int nsvg__RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
 {
-	return (r) | (g << 8) | (b << 16) | (a << 24);
+	return ((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16) | ((unsigned int)a << 24);
 }
 
 static unsigned int nsvg__lerpRGBA(unsigned int c0, unsigned int c1, float u)
 {
 	int iu = (int)(nsvg__clampf(u, 0.0f, 1.0f) * 256.0f);
@@ -1011,16 +1015,16 @@
 
 		for (i = 0; i < count; i++) {
 			int r,g,b;
 			int a = nsvg__div255((int)cover[0] * ca);
 			int ia = 255 - a;
-			// Premultiply
+			/* Premultiply */
 			r = nsvg__div255(cr * a);
 			g = nsvg__div255(cg * a);
 			b = nsvg__div255(cb * a);
 
-			// Blend over
+			/* Blend over */
 			r += nsvg__div255(ia * (int)dst[0]);
 			g += nsvg__div255(ia * (int)dst[1]);
 			b += nsvg__div255(ia * (int)dst[2]);
 			a += nsvg__div255(ia * (int)dst[3]);
 
@@ -1031,12 +1035,12 @@
 
 			cover++;
 			dst += 4;
 		}
 	} else if (cache->type == NSVG_PAINT_LINEAR_GRADIENT) {
-		// TODO: spread modes.
-		// TODO: plenty of opportunities to optimize.
+		/* TODO: spread modes. */
+		/* TODO: plenty of opportunities to optimize. */
 		float fx, fy, dx, gy;
 		float* t = cache->xform;
 		int i, cr, cg, cb, ca;
 		unsigned int c;
 
@@ -1054,16 +1058,16 @@
 			ca = (c >> 24) & 0xff;
 
 			a = nsvg__div255((int)cover[0] * ca);
 			ia = 255 - a;
 
-			// Premultiply
+			/* Premultiply */
 			r = nsvg__div255(cr * a);
 			g = nsvg__div255(cg * a);
 			b = nsvg__div255(cb * a);
 
-			// Blend over
+			/* Blend over */
 			r += nsvg__div255(ia * (int)dst[0]);
 			g += nsvg__div255(ia * (int)dst[1]);
 			b += nsvg__div255(ia * (int)dst[2]);
 			a += nsvg__div255(ia * (int)dst[3]);
 
@@ -1075,13 +1079,13 @@
 			cover++;
 			dst += 4;
 			fx += dx;
 		}
 	} else if (cache->type == NSVG_PAINT_RADIAL_GRADIENT) {
-		// TODO: spread modes.
-		// TODO: plenty of opportunities to optimize.
-		// TODO: focus (fx,fy)
+		/* TODO: spread modes. */
+		/* TODO: plenty of opportunities to optimize. */
+		/* TODO: focus (fx,fy) */
 		float fx, fy, dx, gx, gy, gd;
 		float* t = cache->xform;
 		int i, cr, cg, cb, ca;
 		unsigned int c;
 
@@ -1101,16 +1105,16 @@
 			ca = (c >> 24) & 0xff;
 
 			a = nsvg__div255((int)cover[0] * ca);
 			ia = 255 - a;
 
-			// Premultiply
+			/* Premultiply */
 			r = nsvg__div255(cr * a);
 			g = nsvg__div255(cg * a);
 			b = nsvg__div255(cb * a);
 
-			// Blend over
+			/* Blend over */
 			r += nsvg__div255(ia * (int)dst[0]);
 			g += nsvg__div255(ia * (int)dst[1]);
 			b += nsvg__div255(ia * (int)dst[2]);
 			a += nsvg__div255(ia * (int)dst[3]);
 
@@ -1129,37 +1133,37 @@
 static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float scale, NSVGcachedPaint* cache, char fillRule)
 {
 	NSVGactiveEdge *active = NULL;
 	int y, s;
 	int e = 0;
-	int maxWeight = (255 / NSVG__SUBSAMPLES);  // weight per vertical scanline
+	int maxWeight = (255 / NSVG__SUBSAMPLES);  /* weight per vertical scanline */
 	int xmin, xmax;
 
 	for (y = 0; y < r->height; y++) {
 		memset(r->scanline, 0, r->width);
 		xmin = r->width;
 		xmax = 0;
 		for (s = 0; s < NSVG__SUBSAMPLES; ++s) {
-			// find center of pixel for this scanline
+			/* find center of pixel for this scanline */
 			float scany = (float)(y*NSVG__SUBSAMPLES + s) + 0.5f;
 			NSVGactiveEdge **step = &active;
 
-			// update all active edges;
-			// remove all active edges that terminate before the center of this scanline
+			/* update all active edges; */
+			/* remove all active edges that terminate before the center of this scanline */
 			while (*step) {
 				NSVGactiveEdge *z = *step;
 				if (z->ey <= scany) {
-					*step = z->next; // delete from list
-//					NSVG__assert(z->valid);
+					*step = z->next; /* delete from list */
+/*					NSVG__assert(z->valid); */
 					nsvg__freeActive(r, z);
 				} else {
-					z->x += z->dx; // advance to position for current scanline
-					step = &((*step)->next); // advance through list
+					z->x += z->dx; /* advance to position for current scanline */
+					step = &((*step)->next); /* advance through list */
 				}
 			}
 
-			// resort the list if needed
+			/* resort the list if needed */
 			for (;;) {
 				int changed = 0;
 				step = &active;
 				while (*step && (*step)->next) {
 					if ((*step)->x > (*step)->next->x) {
@@ -1173,40 +1177,40 @@
 					step = &(*step)->next;
 				}
 				if (!changed) break;
 			}
 
-			// insert all edges that start before the center of this scanline -- omit ones that also end on this scanline
+			/* insert all edges that start before the center of this scanline -- omit ones that also end on this scanline */
 			while (e < r->nedges && r->edges[e].y0 <= scany) {
 				if (r->edges[e].y1 > scany) {
 					NSVGactiveEdge* z = nsvg__addActive(r, &r->edges[e], scany);
 					if (z == NULL) break;
-					// find insertion point
+					/* find insertion point */
 					if (active == NULL) {
 						active = z;
 					} else if (z->x < active->x) {
-						// insert at front
+						/* insert at front */
 						z->next = active;
 						active = z;
 					} else {
-						// find thing to insert AFTER
+						/* find thing to insert AFTER */
 						NSVGactiveEdge* p = active;
 						while (p->next && p->next->x < z->x)
 							p = p->next;
-						// at this point, p->next->x is NOT < z->x
+						/* at this point, p->next->x is NOT < z->x */
 						z->next = p->next;
 						p->next = z;
 					}
 				}
 				e++;
 			}
 
-			// now process all active edges in non-zero fashion
+			/* now process all active edges in non-zero fashion */
 			if (active != NULL)
 				nsvg__fillActiveEdges(r->scanline, r->width, active, maxWeight, &xmin, &xmax, fillRule);
 		}
-		// Blit
+		/* Blit */
 		if (xmin < 0) xmin = 0;
 		if (xmax > r->width-1) xmax = r->width-1;
 		if (xmin <= xmax) {
 			nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, scale, cache);
 		}
@@ -1216,11 +1220,11 @@
 
 static void nsvg__unpremultiplyAlpha(unsigned char* image, int w, int h, int stride)
 {
 	int x,y;
 
-	// Unpremultiply
+	/* Unpremultiply */
 	for (y = 0; y < h; y++) {
 		unsigned char *row = &image[y*stride];
 		for (x = 0; x < w; x++) {
 			int r = row[0], g = row[1], b = row[2], a = row[3];
 			if (a != 0) {
@@ -1230,11 +1234,11 @@
 			}
 			row += 4;
 		}
 	}
 
-	// Defringe
+	/* Defringe */
 	for (y = 0; y < h; y++) {
 		unsigned char *row = &image[y*stride];
 		for (x = 0; x < w; x++) {
 			int r = 0, g = 0, b = 0, a = row[3], n = 0;
 			if (a == 0) {
@@ -1409,23 +1413,24 @@
 			r->freelist = NULL;
 			r->nedges = 0;
 
 			nsvg__flattenShape(r, shape, scale);
 
-			// Scale and translate edges
+			/* Scale and translate edges */
 			for (i = 0; i < r->nedges; i++) {
 				e = &r->edges[i];
 				e->x0 = tx + e->x0;
 				e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES;
 				e->x1 = tx + e->x1;
 				e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES;
 			}
 
-			// Rasterize edges
-			qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
+			/* Rasterize edges */
+			if (r->nedges != 0)
+				qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
 
-			// now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
+			/* now, traverse the scanlines and find the intersections on each scanline, use non-zero rule */
 			nsvg__initPaint(&cache, &shape->fill, shape->opacity);
 
 			nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, shape->fillRule);
 		}
 		if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * scale) > 0.01f) {
@@ -1433,25 +1438,26 @@
 			r->freelist = NULL;
 			r->nedges = 0;
 
 			nsvg__flattenShapeStroke(r, shape, scale);
 
-//			dumpEdges(r, "edge.svg");
+/*			dumpEdges(r, "edge.svg"); */
 
-			// Scale and translate edges
+			/* Scale and translate edges */
 			for (i = 0; i < r->nedges; i++) {
 				e = &r->edges[i];
 				e->x0 = tx + e->x0;
 				e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES;
 				e->x1 = tx + e->x1;
 				e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES;
 			}
 
-			// Rasterize edges
-			qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
+			/* Rasterize edges */
+			if (r->nedges != 0)
+				qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
 
-			// now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
+			/* now, traverse the scanlines and find the intersections on each scanline, use non-zero rule */
 			nsvg__initPaint(&cache, &shape->stroke, shape->opacity);
 
 			nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, NSVG_FILLRULE_NONZERO);
 		}
 	}
@@ -1463,5 +1469,7 @@
 	r->height = 0;
 	r->stride = 0;
 }
 
 #endif
+
+#endif /* NANOSVGRAST_H */

Index: generic/tk.decls
==================================================================
--- generic/tk.decls
+++ generic/tk.decls
@@ -3,12 +3,12 @@
 #	This file contains the declarations for all supported public
 #	functions that are exported by the Tk library via the stubs table.
 #	This file is used to generate the tkDecls.h, tkPlatDecls.h,
 #	tkStub.c, and tkPlatStub.c files.
 #
-# Copyright (c) 1998-2000 Ajuba Solutions.
-# Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
+# Copyright © 1998-2000 Ajuba Solutions.
+# Copyright © 2007 Daniel A. Steffen <das@users.sourceforge.net>
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
 library tk
@@ -1088,10 +1088,54 @@
 	    Tcl_Obj *detail)
 }
 declare 279 {
     Tcl_Obj *Tk_FontGetDescription(Tk_Font tkfont)
 }
+
+# TIP#529
+declare 280 {
+    void Tk_CreatePhotoImageFormatVersion3(
+	    const Tk_PhotoImageFormatVersion3 *formatPtr)
+}
+
+# TIP#606
+declare 281 {
+    void Tk_DrawHighlightBorder(Tk_Window tkwin, GC fgGC, GC bgGC,
+	    int highlightWidth, Drawable drawable)
+}
+declare 282 {
+    void Tk_SetMainMenubar(Tcl_Interp *interp, Tk_Window tkwin, const char *menuName)
+}
+declare 283 {
+    void Tk_SetWindowMenubar(Tcl_Interp *interp, Tk_Window tkwin,
+	    const char *oldMenuName, const char *menuName)
+}
+declare 284 {
+    void Tk_ClipDrawableToRect(Display *display, Drawable d, int x,
+	    int y, int width, int height)
+}
+declare 285 {
+    Tcl_Obj *Tk_GetSystemDefault(Tk_Window tkwin,
+	    const char *dbName, const char *className)
+}
+declare 286 {
+    int Tk_UseWindow(Tcl_Interp *interp, Tk_Window tkwin, const char *string)
+}
+declare 287 {
+    void Tk_MakeContainer(Tk_Window tkwin)
+}
+declare 288 {
+    Tk_Window Tk_GetOtherWindow(Tk_Window tkwin)
+}
+declare 289 {
+    void Tk_Get3DBorderColors(Tk_3DBorder border, XColor *bgColorPtr, XColor *darkColorPtr,
+	    XColor *lightColorPtr)
+}
+declare 290 {
+    Window Tk_MakeWindow(Tk_Window tkwin, Window parent)
+}
+
 
 # Define the platform specific public Tk interface.  These functions are
 # only available on the designated platform.
 
 interface tkPlat

Index: generic/tk.h
==================================================================
--- generic/tk.h
+++ generic/tk.h
@@ -66,14 +66,14 @@
  */
 
 #define TK_MAJOR_VERSION	8
 #define TK_MINOR_VERSION	7
 #define TK_RELEASE_LEVEL	TCL_ALPHA_RELEASE
-#define TK_RELEASE_SERIAL	4
+#define TK_RELEASE_SERIAL	6
 
 #define TK_VERSION		"8.7"
-#define TK_PATCH_LEVEL		"8.7a4"
+#define TK_PATCH_LEVEL		"8.7a6"
 
 /*
  * A special definition used to allow this header file to be included from
  * windows or mac resource files so that they can obtain version information.
  * RC_INVOKED is defined by default by the windows RC tool and manually set
@@ -92,14 +92,11 @@
 #   include <X11/Xlib.h>
 #   ifdef MAC_OSX_TK
 #	include <X11/X.h>
 #   endif
 #endif
-#if defined(STDC_HEADERS) || defined(__STDC__) || defined(__C99__FUNC__) \
-     || defined(__cplusplus) || defined(_MSC_VER) || defined(__ICC)
-#   include <stddef.h>
-#endif
+#include <stddef.h>
 
 #ifdef BUILD_tk
 #undef TCL_STORAGE_CLASS
 #define TCL_STORAGE_CLASS	DLLEXPORT
 #else
@@ -169,11 +166,12 @@
     TK_OPTION_SYNONYM,
     TK_OPTION_PIXELS,
     TK_OPTION_WINDOW,
     TK_OPTION_END,
     TK_OPTION_CUSTOM,
-    TK_OPTION_STYLE
+    TK_OPTION_STYLE,
+    TK_OPTION_INDEX
 } Tk_OptionType;
 
 /*
  * Structures of the following type are used by widgets to specify their
  * configuration options. Typically each widget has a static array of these
@@ -547,10 +545,11 @@
 /*
  * Enumerated type for describing a point by which to anchor something:
  */
 
 typedef enum {
+    TK_ANCHOR_NULL = -1,
     TK_ANCHOR_N, TK_ANCHOR_NE, TK_ANCHOR_E, TK_ANCHOR_SE,
     TK_ANCHOR_S, TK_ANCHOR_SW, TK_ANCHOR_W, TK_ANCHOR_NW,
     TK_ANCHOR_CENTER
 } Tk_Anchor;
 
@@ -557,10 +556,11 @@
 /*
  * Enumerated type for describing a style of justification:
  */
 
 typedef enum {
+    TK_JUSTIFY_NULL = -1,
     TK_JUSTIFY_LEFT, TK_JUSTIFY_RIGHT, TK_JUSTIFY_CENTER
 } Tk_Justify;
 
 /*
  * The following structure is used by Tk_GetFontMetrics() to return
@@ -835,12 +835,17 @@
     char *dummy8;		/* handlerList */
 #if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8)
     XIC dummy9;			/* inputContext */
 #endif /* TK_USE_INPUT_METHODS */
     ClientData *dummy10;	/* tagPtr */
-    int dummy11;		/* numTags */
-    int dummy12;		/* optionLevel */
+#if TCL_MAJOR_VERSION > 8
+    size_t dummy11;		/* numTags */
+    size_t dummy12;		/* optionLevel */
+#else
+    int dummy11;
+    int dummy12;
+#endif
     char *dummy13;		/* selHandlerList */
     char *dummy14;		/* geomMgrPtr */
     ClientData dummy15;		/* geomData */
     int reqWidth, reqHeight;
     int internalBorderLeft;
@@ -1060,16 +1065,16 @@
 		    int beforeThis, char *string);
 typedef int	(Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
 		    Tk_Item *itemPtr, char *indexString, int *indexPtr);
 #else
 typedef int	(Tk_ItemCreateProc)(Tcl_Interp *interp, Tk_Canvas canvas,
-		    Tk_Item *itemPtr, int argc, Tcl_Obj *const objv[]);
+		    Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]);
 typedef int	(Tk_ItemConfigureProc)(Tcl_Interp *interp, Tk_Canvas canvas,
-		    Tk_Item *itemPtr, int argc, Tcl_Obj *const objv[],
+		    Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[],
 		    int flags);
 typedef int	(Tk_ItemCoordProc)(Tcl_Interp *interp, Tk_Canvas canvas,
-		    Tk_Item *itemPtr, int argc, Tcl_Obj *const argv[]);
+		    Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]);
 #if TCL_MAJOR_VERSION > 8
 typedef void	(Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
 		    size_t beforeThis, Tcl_Obj *string);
 typedef int	(Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
 		    Tk_Item *itemPtr, Tcl_Obj *indexString, size_t *indexPtr);
@@ -1435,10 +1440,40 @@
 typedef int (Tk_ImageFileWriteProc) (Tcl_Interp *interp, const char *fileName,
 	Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr);
 typedef int (Tk_ImageStringWriteProc) (Tcl_Interp *interp, Tcl_Obj *format,
 	Tk_PhotoImageBlock *blockPtr);
 #endif /* USE_OLD_IMAGE */
+
+/*
+ * The following alternate definitions are used with the Tk8.7 file format
+ * supporting a metadata dict, internal dstring and close file flag
+ */
+
+typedef struct Tk_PhotoImageFormatVersion3 Tk_PhotoImageFormatVersion3;
+typedef int (Tk_ImageFileMatchProcVersion3) (Tcl_Interp *interp,
+	Tcl_Channel chan, const char *fileName, Tcl_Obj *format,
+	Tcl_Obj *metadataIn, int *widthPtr, int *heightPtr,
+	Tcl_Obj *metadataOut);
+typedef int (Tk_ImageStringMatchProcVersion3) (Tcl_Interp *interp,
+	Tcl_Obj *dataObj, Tcl_Obj *format, Tcl_Obj *metadataIn, int *widthPtr,
+	int *heightPtr, Tcl_Obj *metadataOut);
+typedef int (Tk_ImageFileReadProcVersion3) (Tcl_Interp *interp,
+	Tcl_Channel chan,
+	const char *fileName, Tcl_Obj *format, Tcl_Obj *metadataIn,
+	Tk_PhotoHandle imageHandle,
+	int destX, int destY, int width, int height, int srcX, int srcY,
+	Tcl_Obj *metadataOut);
+typedef int (Tk_ImageStringReadProcVersion3) (Tcl_Interp *interp,
+	Tcl_Obj *dataObj, Tcl_Obj *format, Tcl_Obj *metadataIn,
+	Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height,
+	int srcX, int srcY, Tcl_Obj *metadataOut);
+typedef int (Tk_ImageFileWriteProcVersion3) (Tcl_Interp *interp,
+	const char *fileName, Tcl_Obj *format, Tcl_Obj *metadataIn,
+	Tk_PhotoImageBlock *blockPtr);
+typedef int (Tk_ImageStringWriteProcVersion3) (Tcl_Interp *interp,
+	Tcl_Obj *format, Tcl_Obj *metadataIn, Tk_PhotoImageBlock *blockPtr);
+
 
 /*
  * The following structure represents a particular file format for storing
  * images (e.g., PPM, GIF, JPEG, etc.). It provides information to allow image
  * files of that format to be recognized and read into a photo image.
@@ -1468,10 +1503,42 @@
     struct Tk_PhotoImageFormat *nextPtr;
 				/* Next in list of all photo image formats
 				 * currently known. Filled in by Tk, not by
 				 * image format handler. */
 };
+
+/*
+ * The following structure is the same plus added support for the metadata
+ * structure.
+ */
+
+struct Tk_PhotoImageFormatVersion3 {
+    const char *name;		/* Name of image file format */
+    Tk_ImageFileMatchProcVersion3 *fileMatchProc;
+				/* Procedure to call to determine whether an
+				 * image file matches this format. */
+    Tk_ImageStringMatchProcVersion3 *stringMatchProc;
+				/* Procedure to call to determine whether the
+				 * data in a string matches this format. */
+    Tk_ImageFileReadProcVersion3 *fileReadProc;
+				/* Procedure to call to read data from an
+				 * image file into a photo image. */
+    Tk_ImageStringReadProcVersion3 *stringReadProc;
+				/* Procedure to call to read data from a
+				 * string into a photo image. */
+    Tk_ImageFileWriteProcVersion3 *fileWriteProc;
+				/* Procedure to call to write data from a
+				 * photo image to a file. */
+    Tk_ImageStringWriteProcVersion3 *stringWriteProc;
+				/* Procedure to call to obtain a string
+				 * representation of the data in a photo
+				 * image.*/
+    struct Tk_PhotoImageFormatVersion3 *nextPtr;
+				/* Next in list of all photo image formats
+				 * currently known. Filled in by Tk, not by
+				 * image format handler. */
+};
 
 /*
  *----------------------------------------------------------------------
  *
  * Procedure prototypes and structures used for managing styles:

Index: generic/tk3d.c
==================================================================
--- generic/tk3d.c
+++ generic/tk3d.c
@@ -2,12 +2,12 @@
  * tk3d.c --
  *
  *	This module provides procedures to draw borders in the
  *	three-dimensional Motif style.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -17,11 +17,11 @@
 /*
  * The following table defines the string values for reliefs, which are used
  * by Tk_GetReliefFromObj.
  */
 
-static const char *const reliefStrings[] = {
+const char *const tkReliefStrings[] = {
     "flat", "groove", "raised", "ridge", "solid", "sunken", NULL
 };
 
 /*
  * Forward declarations for functions defined in this file:
@@ -621,11 +621,11 @@
     Tcl_Interp *interp,		/* Used for error reporting. */
     Tcl_Obj *objPtr,		/* The object we are trying to get the value
 				 * from. */
     int *resultPtr)		/* Where to place the answer. */
 {
-    return Tcl_GetIndexFromObjStruct(interp, objPtr, reliefStrings,
+    return Tcl_GetIndexFromObjStruct(interp, objPtr, tkReliefStrings,
 	    sizeof(char *), "relief", 0, resultPtr);
 }
 
 /*
  *----------------------------------------------------------------------
@@ -1385,13 +1385,47 @@
 	    Tcl_ListObjAppendElement(NULL, resultPtr, objPtr);
 	}
     }
     return resultPtr;
 }
+
+/*
+ *--------------------------------------------------------------
+ *
+ * Tk_Get3BorderColors --
+ *
+ *	Given a Tk_3DBorder determine its 3 colors.
+ *
+ * Results:
+ *	None.
+ *
+ * Side effects:
+ *	None.
+ *
+ *--------------------------------------------------------------
+ */
+
+void
+Tk_Get3DBorderColors(
+    Tk_3DBorder border,
+    XColor *bgColorPtr,
+    XColor *darkColorPtr,
+    XColor *lightColorPtr)
+{
+    if (bgColorPtr) {
+	*bgColorPtr = *((TkBorder *)border)->bgColorPtr;
+    }
+    if (darkColorPtr) {
+	*darkColorPtr = *((TkBorder *) border)->darkColorPtr;
+    }
+    if (lightColorPtr) {
+	*lightColorPtr = *((TkBorder *) border)->lightColorPtr;
+    }
+}
 
 /*
  * Local Variables:
  * mode: c
  * c-basic-offset: 4
  * fill-column: 78
  * End:
  */

Index: generic/tk3d.h
==================================================================
--- generic/tk3d.h
+++ generic/tk3d.h
@@ -1,11 +1,11 @@
 /*
  * tk3d.h --
  *
  *	Declarations of types and functions shared by the 3d border module.
  *
- * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkArgv.c
==================================================================
--- generic/tkArgv.c
+++ generic/tkArgv.c
@@ -2,12 +2,12 @@
  * tkArgv.c --
  *
  *	This file contains a function that handles table-based argv-argc
  *	parsing.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkArray.h
==================================================================
--- generic/tkArray.h
+++ generic/tkArray.h
@@ -3,11 +3,11 @@
  *
  * An array is a sequence of items, stored in a contiguous memory region.
  * Random access to any item is very fast. New items can be either appended
  * or prepended. An array may be traversed in the forward or backward direction.
  *
- * Copyright (c) 2018-2019 by Gregor Cramer.
+ * Copyright © 2018-2019 Gregor Cramer.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkAtom.c
==================================================================
--- generic/tkAtom.c
+++ generic/tkAtom.c
@@ -4,12 +4,12 @@
  *	This file manages a cache of X Atoms in order to avoid interactions
  *	with the X server. It's much like the Xmu routines, except it has a
  *	cleaner interface (caller doesn't have to provide permanent storage
  *	for atom names, for example).
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkBind.c
==================================================================
--- generic/tkBind.c
+++ generic/tkBind.c
@@ -2,14 +2,14 @@
  * tkBind.c --
  *
  *	This file provides functions that associate Tcl commands with X events
  *	or sequences of X events.
  *
- * Copyright (c) 1989-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998 by Scriptics Corporation.
- * Copyright (c) 2018-2019 by Gregor Cramer.
+ * Copyright © 1989-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998 Scriptics Corporation.
+ * Copyright © 2018-2019 Gregor Cramer.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -330,11 +330,11 @@
  */
 #define PATSEQ_MEMSIZE(numPats) (sizeof(PatSeq) + (numPats - 1)*sizeof(TkPattern))
 
 /*
  * Constants that define how close together two events must be in milliseconds
- * or pixels to meet the PAT_NEARBY constraint:
+ * or pixels to be considered close in space or time.
  */
 
 #define NEARBY_PIXELS	5
 #define NEARBY_MS	500
 
@@ -430,11 +430,13 @@
 static const ModInfo modArray[] = {
     {"Control",		ControlMask,	0},
     {"Shift",		ShiftMask,	0},
     {"Lock",		LockMask,	0},
     {"Meta",		META_MASK,	0},
+#ifndef TK_NO_DEPRECATED
     {"M",		META_MASK,	0},
+#endif
     {"Alt",		ALT_MASK,	0},
     {"Extended",	EXTENDED_MASK,	0},
     {"B1",		Button1Mask,	0},
     {"Button1",		Button1Mask,	0},
     {"B2",		Button2Mask,	0},
@@ -453,17 +455,29 @@
     {"Button8",		Button8Mask,	0},
     {"B9",		Button9Mask,	0},
     {"Button9",		Button9Mask,	0},
     {"Mod1",		Mod1Mask,	0},
     {"M1",		Mod1Mask,	0},
+#ifdef MAC_OSX_TK
     {"Command",		Mod1Mask,	0},
+#elif defined (_WIN32)
+    {"Command",		ControlMask,	0},
+#else
+    {"Command",		META_MASK,	0},
+#endif
     {"Mod2",		Mod2Mask,	0},
     {"M2",		Mod2Mask,	0},
+#ifdef MAC_OSX_TK
     {"Option",		Mod2Mask,	0},
+#else
+    {"Option",		ALT_MASK,	0},
+#endif
     {"Mod3",		Mod3Mask,	0},
     {"M3",		Mod3Mask,	0},
+    {"Num",		Mod3Mask,	0},
     {"Mod4",		Mod4Mask,	0},
+    {"Fn",		Mod4Mask,	0},
     {"M4",		Mod4Mask,	0},
     {"Mod5",		Mod5Mask,	0},
     {"M5",		Mod5Mask,	0},
     {"Double",		0,		DOUBLE},
     {"Triple",		0,		TRIPLE},
@@ -492,14 +506,18 @@
  * unless you've asked about button events.
  */
 
 static const EventInfo eventArray[] = {
     {"Key",		KeyPress,		KeyPressMask},
+#ifndef TK_NO_DEPRECATED
     {"KeyPress",	KeyPress,		KeyPressMask},
+#endif
     {"KeyRelease",	KeyRelease,		KeyPressMask|KeyReleaseMask},
     {"Button",		ButtonPress,		ButtonPressMask},
+#ifndef TK_NO_DEPRECATED
     {"ButtonPress",	ButtonPress,		ButtonPressMask},
+#endif
     {"ButtonRelease",	ButtonRelease,		ButtonPressMask|ButtonReleaseMask},
     {"Motion",		MotionNotify,		ButtonPressMask|PointerMotionMask},
     {"Enter",		EnterNotify,		EnterWindowMask},
     {"Leave",		LeaveNotify,		LeaveWindowMask},
     {"FocusIn",		FocusIn,		FocusChangeMask},
@@ -800,10 +818,11 @@
 
 static Time
 CurrentTimeInMilliSecs(void)
 {
     Tcl_Time now;
+
     Tcl_GetTime(&now);
     return ((Time) now.sec)*1000 + ((Time) now.usec)/1000;
 }
 
 static Info
@@ -2992,12 +3011,12 @@
     }
 
     while (1) {
 	char numStorage[TCL_INTEGER_SPACE];
 	const char *string;
-	Tcl_WideInt number;     /* signed */
-	Tcl_WideUInt unumber;   /* unsigned */
+	long long number;     /* signed */
+	unsigned long long unumber;   /* unsigned */
 
 	/*
 	 * Find everything up to the next % character and append it to the
 	 * result string.
 	 */
@@ -5238,18 +5257,52 @@
 KeySym
 TkStringToKeysym(
     const char *name)		/* Name of a keysym. */
 {
 #ifdef REDO_KEYSYM_LOOKUP
-    Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&keySymTable, name);
+    Tcl_HashEntry *hPtr;
+#endif /* REDO_KEYSYM_LOOKUP */
+    int keysym;
 
+    size_t len = TkUtfToUniChar(name, &keysym);
+    if (name[len] == '\0') {
+        if (!Tcl_UniCharIsPrint(keysym)) {
+    	/* This form not supported */
+        } else if ((unsigned)(keysym - 0x21) <= 0x5D) {
+		return keysym;
+	    } else if ((unsigned)(keysym - 0xA1) <= 0x5E) {
+		return keysym;
+	    } else if (keysym == 0x20AC) {
+		return 0x20AC;
+	    } else {
+		return keysym + 0x1000000;
+	    }
+    }
+#ifdef REDO_KEYSYM_LOOKUP
+    if ((name[0] == 'U') && ((unsigned)(name[1] - '0') <= 9)) {
+	char *p = (char *)name + 1;
+	keysym = strtol(p, &p, 16);
+	if ((p >= name + 5) && (p <= name + 9) && !*p && (keysym >= 0x20)
+		&& ((unsigned)(keysym - 0x7F) > 0x20)) {
+	    if ((unsigned)(keysym - 0x21) <= 0x5D) {
+		return keysym;
+	    } else if ((unsigned)(keysym - 0xA1) <= 0x5E) {
+		return keysym;
+	    } else if (keysym == 0x20AC) {
+		return keysym;
+	    }
+	    return keysym + 0x1000000;
+	}
+    }
+#endif
+#ifdef REDO_KEYSYM_LOOKUP
+    hPtr = Tcl_FindHashEntry(&keySymTable, name);
     if (hPtr) {
 	return (KeySym) Tcl_GetHashValue(hPtr);
     }
-    assert(name);
-    if (strlen(name) == 1u) {
-	KeySym keysym = (KeySym) (unsigned char) name[0];
+    if (((unsigned)(name[0]-1) < 0x7F) && !name[1]) {
+	keysym = (unsigned char) name[0];
 
 	if (TkKeysymToString(keysym)) {
 	    return keysym;
 	}
     }
@@ -5278,20 +5331,41 @@
 const char *
 TkKeysymToString(
     KeySym keysym)
 {
 #ifdef REDO_KEYSYM_LOOKUP
-    Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&nameTable, (char *)keysym);
+    Tcl_HashEntry *hPtr;
+#endif
+
+    if ((unsigned)(keysym - 0x21) <= 0x5D) {
+	keysym += 0x1000000;
+    } else if ((unsigned)(keysym - 0xA1) <= 0x5E) {
+	keysym += 0x1000000;
+    } else if (keysym == 0x20AC) {
+	keysym += 0x1000000;
+    }
+    if ((keysym >= 0x1000020) && (keysym <= 0x110FFFF)
+	    && ((unsigned)(keysym - 0x100007F) > 0x20)) {
+	char buf[10];
+	if (Tcl_UniCharIsPrint(keysym-0x1000000)) {
+	    buf[TkUniCharToUtf(keysym - 0x1000000, buf)] = '\0';
+	} else if (keysym >= 0x1010000) {
+	    sprintf(buf, "U%08X", (int)(keysym - 0x1000000));
+	} else {
+	    sprintf(buf, "U%04X", (int)(keysym - 0x1000000));
+	}
+	return Tk_GetUid(buf);
+    }
+
+#ifdef REDO_KEYSYM_LOOKUP
+    hPtr = Tcl_FindHashEntry(&nameTable, INT2PTR(keysym));
 
     if (hPtr) {
 	return (const char *)Tcl_GetHashValue(hPtr);
     }
 #endif /* REDO_KEYSYM_LOOKUP */
 
-    if (keysym > (KeySym)0x1008FFFF) {
-	return NULL;
-    }
     return XKeysymToString(keysym);
 }
 
 /*
  *----------------------------------------------------------------------

Index: generic/tkBitmap.c
==================================================================
--- generic/tkBitmap.c
+++ generic/tkBitmap.c
@@ -3,12 +3,12 @@
  *
  *	This file maintains a database of read-only bitmaps for the Tk
  *	toolkit. This allows bitmaps to be shared between widgets and also
  *	avoids interactions with the X server.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1998 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1998 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -1012,11 +1012,11 @@
     Tcl_Interp *dummy;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
 
     /*
-     * First initialize the data in the ThreadSpecificData strucuture, if
+     * First initialize the data in the ThreadSpecificData structure, if
      * needed.
      */
 
     if (!tsdPtr->initialized) {
 	tsdPtr->initialized = 1;
@@ -1167,11 +1167,11 @@
 /*
  *----------------------------------------------------------------------
  *
  * TkGetBitmapPredefTable --
  *
- *	This function is used by tkMacBitmap.c to access the thread-specific
+ *	This function is used by tkMacOSXBitmap.c to access the thread-specific
  *	predefBitmap table that maps from the names of the predefined bitmaps
  *	to data associated with those bitmaps. It is required because the
  *	table is allocated in thread-local storage and is not visible outside
  *	this file.
 

Index: generic/tkButton.c
==================================================================
--- generic/tkButton.c
+++ generic/tkButton.c
@@ -3,12 +3,12 @@
  *
  *	This module implements a collection of button-like widgets for the Tk
  *	toolkit. The widgets implemented include buttons, checkbuttons,
  *	radiobuttons, and labels.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1998 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1998 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -27,33 +27,24 @@
  */
 
 static const char *const classNames[] = {"Label", "Button", "Checkbutton", "Radiobutton"};
 
 /*
- * The following table defines the legal values for the -default option. It is
- * used together with the "enum defaultValue" declaration in tkButton.h.
+ * The following table defines the legal values for the -default/-state options.
+ * It is used together with the "enum defaultValue/state" declarations in tkButton.h.
  */
 
-static const char *const defaultStrings[] = {
-    "active", "disabled", "normal", NULL
-};
-
-/*
- * The following table defines the legal values for the -state option.
- * It is used together with the "enum state" declaration in tkButton.h.
- */
-
-static const char *const stateStrings[] = {
+const char *const tkStateStrings[] = {
     "active", "disabled", "normal", NULL
 };
 
 /*
  * The following table defines the legal values for the -compound option.
  * It is used with the "enum compound" declaration in tkButton.h
  */
 
-static const char *const compoundStrings[] = {
+const char *const tkCompoundStrings[] = {
     "bottom", "center", "left", "none", "right", "top", NULL
 };
 
 char tkDefButtonHighlightWidth[TCL_INTEGER_SPACE] = DEF_BUTTON_HIGHLIGHT_WIDTH;
 char tkDefButtonPadx[TCL_INTEGER_SPACE] = DEF_BUTTON_PADX;
@@ -89,31 +80,31 @@
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
 	tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr),
 	offsetof(TkButton, borderWidth), 0, 0, 0},
     {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
-	 DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0,
-	 compoundStrings, 0},
+	DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound),
+	0, tkCompoundStrings, 0},
     {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
 	DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
 	"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
 	TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
-	(ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0},
+	DEF_BUTTON_DISABLED_FG_MONO, 0},
     {TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
 	NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
     {TK_OPTION_FONT, "-font", "font", "Font",
 	DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
     {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
-	DEF_BUTTON_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
+	DEF_LABEL_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
     {TK_OPTION_STRING, "-height", "height", "Height",
 	DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
     {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
 	"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
 	TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
-	(ClientData) DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
+	DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
     {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
 	DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
 	0, 0, 0},
     {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
 	"HighlightThickness", tkDefLabelHighlightWidth,
@@ -132,21 +123,21 @@
 	offsetof(TkButton, padY), 0, 0, 0},
     {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
 	DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0},
     {TK_OPTION_STRING_TABLE, "-state", "state", "State",
 	DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
-	0, stateStrings, 0},
+	TK_OPTION_ENUM_VAR, tkStateStrings, 0},
     {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
 	DEF_LABEL_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING, "-text", "text", "Text",
 	DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
     {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
 	DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
-    {TK_OPTION_INT, "-underline", "underline", "Underline",
-	DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 0, 0},
+    {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+	TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0},
     {TK_OPTION_STRING, "-width", "width", "Width",
 	DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
     {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
 	DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
 	offsetof(TkButton, wrapLength), 0, 0, 0},
@@ -177,22 +168,22 @@
 	offsetof(TkButton, borderWidth), 0, 0, 0},
     {TK_OPTION_STRING, "-command", "command", "Command",
 	DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
-	 DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0,
-	 compoundStrings, 0},
+	DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound),
+	0, tkCompoundStrings, 0},
     {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
 	DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING_TABLE, "-default", "default", "Default",
-        DEF_BUTTON_DEFAULT, TCL_INDEX_NONE, offsetof(TkButton, defaultState),
-	0, defaultStrings, 0},
+	DEF_BUTTON_DEFAULT, TCL_INDEX_NONE, offsetof(TkButton, defaultState),
+	TK_OPTION_ENUM_VAR, tkStateStrings, 0},
     {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
 	"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
 	TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
-	(ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0},
+	DEF_BUTTON_DISABLED_FG_MONO, 0},
     {TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
 	NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
     {TK_OPTION_FONT, "-font", "font", "Font",
 	DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
     {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
@@ -200,11 +191,11 @@
     {TK_OPTION_STRING, "-height", "height", "Height",
 	DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
     {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
 	"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
 	TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
-	(ClientData) DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
+	DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
     {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
 	DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
 	0, 0, 0},
     {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
 	"HighlightThickness", tkDefButtonHighlightWidth,
@@ -233,21 +224,21 @@
     {TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
 	 DEF_BUTTON_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(TkButton, repeatInterval),
 	 0, 0, 0},
     {TK_OPTION_STRING_TABLE, "-state", "state", "State",
 	DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
-	0, stateStrings, 0},
+	TK_OPTION_ENUM_VAR, tkStateStrings, 0},
     {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
 	DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING, "-text", "text", "Text",
 	DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
     {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
 	DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
-    {TK_OPTION_INT, "-underline", "underline", "Underline",
-	DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 0, 0},
+    {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+	TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0},
     {TK_OPTION_STRING, "-width", "width", "Width",
 	DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
     {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
 	DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
 	offsetof(TkButton, wrapLength), 0, 0, 0},
@@ -278,19 +269,19 @@
 	offsetof(TkButton, borderWidth), 0, 0, 0},
     {TK_OPTION_STRING, "-command", "command", "Command",
 	DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
-	 DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0,
-	 compoundStrings, 0},
+	DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound),
+	0, tkCompoundStrings, 0},
     {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
 	DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
 	"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
 	TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
-	(ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0},
+	DEF_BUTTON_DISABLED_FG_MONO, 0},
     {TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
 	NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
     {TK_OPTION_FONT, "-font", "font", "Font",
 	DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
     {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
@@ -298,11 +289,11 @@
     {TK_OPTION_STRING, "-height", "height", "Height",
 	DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
     {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
 	"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
 	TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
-	(ClientData) DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
+	DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
     {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
 	DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
 	0, 0, 0},
     {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
 	"HighlightThickness", tkDefButtonHighlightWidth,
@@ -314,18 +305,18 @@
     {TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
 	DEF_BUTTON_INDICATOR, TCL_INDEX_NONE, offsetof(TkButton, indicatorOn), 0, 0, 0},
     {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
 	DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), 0, 0, 0},
     {TK_OPTION_RELIEF, "-offrelief", "offRelief", "OffRelief",
-	 DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, offRelief), 0, 0, 0},
+	DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, offRelief), 0, 0, 0},
     {TK_OPTION_STRING, "-offvalue", "offValue", "Value",
 	DEF_BUTTON_OFF_VALUE, offsetof(TkButton, offValuePtr), TCL_INDEX_NONE, 0, 0, 0},
     {TK_OPTION_STRING, "-onvalue", "onValue", "Value",
 	DEF_BUTTON_ON_VALUE, offsetof(TkButton, onValuePtr), TCL_INDEX_NONE, 0, 0, 0},
     {TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief",
-	 DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief),
-	 TK_OPTION_NULL_OK, 0, 0},
+	DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief),
+	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_PIXELS, "-padx", "padX", "Pad",
 	tkDefLabelPadx, offsetof(TkButton, padXPtr),
 	offsetof(TkButton, padX), 0, 0, 0},
     {TK_OPTION_PIXELS, "-pady", "padY", "Pad",
 	tkDefLabelPady, offsetof(TkButton, padYPtr),
@@ -338,11 +329,11 @@
     {TK_OPTION_STRING, "-selectimage", "selectImage", "SelectImage",
 	DEF_BUTTON_SELECT_IMAGE, offsetof(TkButton, selectImagePtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING_TABLE, "-state", "state", "State",
 	DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
-	0, stateStrings, 0},
+	TK_OPTION_ENUM_VAR, tkStateStrings, 0},
     {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
 	DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING, "-text", "text", "Text",
 	DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
@@ -352,12 +343,12 @@
     {TK_OPTION_STRING, "-tristateimage", "tristateImage", "TristateImage",
 	DEF_BUTTON_IMAGE, offsetof(TkButton, tristateImagePtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING, "-tristatevalue", "tristateValue", "TristateValue",
 	DEF_BUTTON_TRISTATE_VALUE, offsetof(TkButton, tristateValuePtr), TCL_INDEX_NONE, 0, 0, 0},
-    {TK_OPTION_INT, "-underline", "underline", "Underline",
-	DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 0, 0},
+    {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+	TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0},
     {TK_OPTION_STRING, "-variable", "variable", "Variable",
 	DEF_CHECKBUTTON_VARIABLE, offsetof(TkButton, selVarNamePtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING, "-width", "width", "Width",
 	DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
@@ -391,19 +382,19 @@
 	offsetof(TkButton, borderWidth), 0, 0, 0},
     {TK_OPTION_STRING, "-command", "command", "Command",
 	DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
-	 DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0,
-	 compoundStrings, 0},
+	DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound),
+	0, tkCompoundStrings, 0},
     {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
 	DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
 	"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
 	TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
-	(ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0},
+	DEF_BUTTON_DISABLED_FG_MONO, 0},
     {TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
 	NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
     {TK_OPTION_FONT, "-font", "font", "Font",
 	DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
     {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
@@ -411,11 +402,11 @@
     {TK_OPTION_STRING, "-height", "height", "Height",
 	DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
     {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
 	"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
 	TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
-	(ClientData) DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
+	DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
     {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
 	DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
 	0, 0, 0},
     {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
 	"HighlightThickness", tkDefButtonHighlightWidth,
@@ -448,11 +439,11 @@
     {TK_OPTION_STRING, "-selectimage", "selectImage", "SelectImage",
 	DEF_BUTTON_SELECT_IMAGE, offsetof(TkButton, selectImagePtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING_TABLE, "-state", "state", "State",
 	DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
-	0, stateStrings, 0},
+	TK_OPTION_ENUM_VAR, tkStateStrings, 0},
     {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
 	DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING, "-text", "text", "Text",
 	DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
@@ -462,12 +453,12 @@
     {TK_OPTION_STRING, "-tristateimage", "tristateImage", "TristateImage",
 	DEF_BUTTON_IMAGE, offsetof(TkButton, tristateImagePtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING, "-tristatevalue", "tristateValue", "TristateValue",
 	DEF_BUTTON_TRISTATE_VALUE, offsetof(TkButton, tristateValuePtr), TCL_INDEX_NONE, 0, 0, 0},
-    {TK_OPTION_INT, "-underline", "underline", "Underline",
-	DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 0, 0},
+    {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+	TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0},
     {TK_OPTION_STRING, "-value", "value", "Value",
 	DEF_BUTTON_VALUE, offsetof(TkButton, onValuePtr), TCL_INDEX_NONE, 0, 0, 0},
     {TK_OPTION_STRING, "-variable", "variable", "Variable",
 	DEF_RADIOBUTTON_VARIABLE, offsetof(TkButton, selVarNamePtr), TCL_INDEX_NONE,
 	0, 0, 0},
@@ -685,11 +676,11 @@
     butPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(tkwin),
 	    ButtonWidgetObjCmd, butPtr, ButtonCmdDeletedProc);
     butPtr->type = type;
     butPtr->optionTable = optionTable;
     butPtr->textPtr = NULL;
-    butPtr->underline = -1;
+    butPtr->underline = INT_MIN;
     butPtr->textVarNamePtr = NULL;
     butPtr->bitmap = None;
     butPtr->imagePtr = NULL;
     butPtr->image = NULL;
     butPtr->selectImagePtr = NULL;
@@ -1624,18 +1615,18 @@
      */
 
     if (flags & TCL_TRACE_UNSETS) {
 	butPtr->flags &= ~(SELECTED | TRISTATED);
 	if (!Tcl_InterpDeleted(interp)) {
-	    ClientData probe = NULL;
+	    void *probe = NULL;
 
 	    do {
 		probe = Tcl_VarTraceInfo(interp,
 			Tcl_GetString(butPtr->selVarNamePtr),
 			TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
 			ButtonVarProc, probe);
-		if (probe == (ClientData)butPtr) {
+		if (probe == (void *)butPtr) {
 		    break;
 		}
 	    } while (probe);
 	    if (probe) {
 		/*
@@ -1743,18 +1734,18 @@
 	    /*
 	     * An unset trace on some variable brought us here, but is it
 	     * the variable we have stored in butPtr->textVarNamePtr ?
 	     */
 
-	    ClientData probe = NULL;
+	    void *probe = NULL;
 
 	    do {
 		probe = Tcl_VarTraceInfo(interp,
 			Tcl_GetString(butPtr->textVarNamePtr),
 			TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
 			ButtonTextVarProc, probe);
-		if (probe == (ClientData)butPtr) {
+		if (probe == (void *)butPtr) {
 		    break;
 		}
 	    } while (probe);
 	    if (probe) {
 		/*

Index: generic/tkButton.h
==================================================================
--- generic/tkButton.h
+++ generic/tkButton.h
@@ -2,11 +2,11 @@
  * tkButton.h --
  *
  *	Declarations of types and functions used to implement button-like
  *	widgets.
  *
- * Copyright (c) 1996-1998 by Sun Microsystems, Inc.
+ * Copyright © 1996-1998 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -65,11 +65,11 @@
      */
 
     Tcl_Obj *textPtr;		/* Value of -text option: specifies text to
 				 * display in button. */
     int underline;		/* Value of -underline option: specifies index
-				 * of character to underline. < 0 means don't
+				 * of character to underline. INT_MIN means don't
 				 * underline anything. */
     Tcl_Obj *textVarNamePtr;	/* Value of -textvariable option: specifies
 				 * name of variable or NULL. If non-NULL,
 				 * button displays the contents of this
 				 * variable. */

Index: generic/tkCanvArc.c
==================================================================
--- generic/tkCanvArc.c
+++ generic/tkCanvArc.c
@@ -1,12 +1,12 @@
 /*
  * tkCanvArc.c --
  *
  *	This file implements arc items for canvas widgets.
  *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkCanvBmap.c
==================================================================
--- generic/tkCanvBmap.c
+++ generic/tkCanvBmap.c
@@ -1,12 +1,12 @@
 /*
  * tkCanvBmap.c --
  *
  *	This file implements bitmap items for canvas widgets.
  *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -538,11 +538,11 @@
     case TK_ANCHOR_W:
 	y -= height/2;
 	break;
     case TK_ANCHOR_NW:
 	break;
-    case TK_ANCHOR_CENTER:
+    default:
 	x -= width/2;
 	y -= height/2;
 	break;
     }
 
@@ -943,11 +943,11 @@
     case TK_ANCHOR_E:	   x -= width;	   y -= height/2.0;	break;
     case TK_ANCHOR_SE:	   x -= width;				break;
     case TK_ANCHOR_S:	   x -= width/2.0;			break;
     case TK_ANCHOR_SW:						break;
     case TK_ANCHOR_W:			   y -= height/2.0;	break;
-    case TK_ANCHOR_CENTER: x -= width/2.0; y -= height/2.0;	break;
+    default: x -= width/2.0; y -= height/2.0;	break;
     }
 
     /*
      * Make our working space.
      */

Index: generic/tkCanvImg.c
==================================================================
--- generic/tkCanvImg.c
+++ generic/tkCanvImg.c
@@ -1,12 +1,12 @@
 /*
  * tkCanvImg.c --
  *
  *	This file implements image items for canvas widgets.
  *
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -72,25 +72,25 @@
 
 static void		ImageChangedProc(ClientData clientData,
 			    int x, int y, int width, int height, int imgWidth,
 			    int imgHeight);
 static int		ImageCoords(Tcl_Interp *interp,
-			    Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
-			    Tcl_Obj *const argv[]);
+			    Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+			    Tcl_Obj *const objv[]);
 static int		ImageToArea(Tk_Canvas canvas,
 			    Tk_Item *itemPtr, double *rectPtr);
 static double		ImageToPoint(Tk_Canvas canvas,
 			    Tk_Item *itemPtr, double *coordPtr);
 static int		ImageToPostscript(Tcl_Interp *interp,
 			    Tk_Canvas canvas, Tk_Item *itemPtr, int prepass);
 static void		ComputeImageBbox(Tk_Canvas canvas, ImageItem *imgPtr);
 static int		ConfigureImage(Tcl_Interp *interp,
-			    Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
-			    Tcl_Obj *const argv[], int flags);
+			    Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+			    Tcl_Obj *const objv[], int flags);
 static int		CreateImage(Tcl_Interp *interp,
 			    Tk_Canvas canvas, struct Tk_Item *itemPtr,
-			    int argc, Tcl_Obj *const argv[]);
+			    int objc, Tcl_Obj *const objv[]);
 static void		DeleteImage(Tk_Canvas canvas,
 			    Tk_Item *itemPtr, Display *display);
 static void		DisplayImage(Tk_Canvas canvas,
 			    Tk_Item *itemPtr, Display *display, Drawable dst,
 			    int x, int y, int width, int height);
@@ -489,11 +489,11 @@
     case TK_ANCHOR_W:
 	y -= height/2;
 	break;
     case TK_ANCHOR_NW:
 	break;
-    case TK_ANCHOR_CENTER:
+    default:
 	x -= width/2;
 	y -= height/2;
 	break;
     }
 
@@ -745,11 +745,11 @@
     case TK_ANCHOR_E:	   x -= width;	   y -= height/2.0;	break;
     case TK_ANCHOR_SE:	   x -= width;				break;
     case TK_ANCHOR_S:	   x -= width/2.0;			break;
     case TK_ANCHOR_SW:						break;
     case TK_ANCHOR_W:			   y -= height/2.0;	break;
-    case TK_ANCHOR_CENTER: x -= width/2.0; y -= height/2.0;	break;
+    default: x -= width/2.0; y -= height/2.0;	break;
     }
 
     if (!prepass) {
 	Tcl_Obj *psObj = Tcl_GetObjResult(interp);
 

Index: generic/tkCanvLine.c
==================================================================
--- generic/tkCanvLine.c
+++ generic/tkCanvLine.c
@@ -1,13 +1,13 @@
 /*
  * tkCanvLine.c --
  *
  *	This file implements line items for canvas widgets.
  *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-1999 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -958,11 +958,11 @@
     TkSizeT beforeThis,		/* Index before which new coordinates are to
 				 * be inserted. */
     Tcl_Obj *obj)		/* New coordinates to be inserted. */
 {
     LineItem *linePtr = (LineItem *) itemPtr;
-    int length, objc, i;
+    int length, oriNumPoints, objc, nbInsPoints, i;
     double *newCoordPtr, *coordPtr;
     Tk_State state = itemPtr->state;
     Tcl_Obj **objv;
 
     if (state == TK_STATE_NULL) {
@@ -971,17 +971,25 @@
 
     if (!obj || (Tcl_ListObjGetElements(NULL, obj, &objc, &objv) != TCL_OK)
 	    || !objc || objc&1) {
 	return;
     }
+    oriNumPoints = linePtr->numPoints;
     length = 2*linePtr->numPoints;
+    nbInsPoints = objc / 2;
     if (beforeThis == TCL_INDEX_NONE) {
 	beforeThis = 0;
     }
     if (beforeThis + 1 > (TkSizeT)length + 1) {
 	beforeThis = length;
     }
+
+    /*
+     * With arrows, the end points of the line are adjusted so that a thick
+     * line doesn't stick out past the arrowheads (see ConfigureArrows).
+     */
+
     if (linePtr->firstArrowPtr != NULL) {
 	linePtr->coordPtr[0] = linePtr->firstArrowPtr[0];
 	linePtr->coordPtr[1] = linePtr->firstArrowPtr[1];
     }
     if (linePtr->lastArrowPtr != NULL) {
@@ -999,11 +1007,11 @@
 	    ckfree(newCoordPtr);
 	    return;
 	}
     }
 
-    for (i=beforeThis; i<length; i++) {
+    for (i=(int)beforeThis; i<length; i++) {
 	newCoordPtr[i+objc] = linePtr->coordPtr[i];
     }
     if (linePtr->coordPtr) {
         ckfree(linePtr->coordPtr);
     }
@@ -1012,63 +1020,116 @@
     linePtr->numPoints = length / 2;
 
     if ((length > 3) && (state != TK_STATE_HIDDEN)) {
 	/*
 	 * This is some optimizing code that will result that only the part of
-	 * the polygon that changed (and the objects that are overlapping with
+	 * the line that changed (and the objects that are overlapping with
 	 * that part) need to be redrawn. A special flag is set that instructs
 	 * the general canvas code not to redraw the whole object. If this
 	 * flag is not set, the canvas will do the redrawing, otherwise I have
 	 * to do it here.
+	 * Rationale for the optimization code can be found in Tk ticket
+	 * [5fb8145997].
 	 */
 
 	itemPtr->redraw_flags |= TK_ITEM_DONT_REDRAW;
 
-	if ((int)beforeThis > 0) {
-	    beforeThis -= 2;
-	    objc += 2;
-	}
-	if ((int)beforeThis+objc < length) {
-	    objc += 2;
-	}
+	/*
+	 * Include one point at left of the left insert position, and one
+	 * point at right of the right insert position.
+	 */
+
+	beforeThis -= 2;
+	objc += 4;
+
 	if (linePtr->smooth) {
-	    if ((int)beforeThis > 0) {
+	    if (!strcmp(linePtr->smooth->name, "true")) {
+		/*
+		 * Quadratic Bezier splines. A second point must be included at
+		 * each side of the insert position.
+		 */
+
 		beforeThis -= 2;
-		objc += 2;
-	    }
-	    if ((int)beforeThis+objc+2 < length) {
-		objc += 2;
-	    }
-	}
-	itemPtr->x1 = itemPtr->x2 = (int) linePtr->coordPtr[beforeThis];
-	itemPtr->y1 = itemPtr->y2 = (int) linePtr->coordPtr[beforeThis+1];
-	if ((linePtr->firstArrowPtr != NULL) && ((int)beforeThis < 1)) {
-	    /*
-	     * Include old first arrow.
-	     */
-
-	    for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW;
-		    i++, coordPtr += 2) {
-		TkIncludePoint(itemPtr, coordPtr);
-	    }
-	}
-	if ((linePtr->lastArrowPtr != NULL) && ((int)beforeThis+objc >= length)) {
-	    /*
-	     * Include old last arrow.
-	     */
-
-	    for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW;
-		    i++, coordPtr += 2) {
-		TkIncludePoint(itemPtr, coordPtr);
-	    }
-	}
-	coordPtr = linePtr->coordPtr + beforeThis + 2;
-	for (i=2; i<objc; i+=2) {
-	    TkIncludePoint(itemPtr, coordPtr);
-	    coordPtr += 2;
-	}
-    }
+		objc += 4;
+
+		/*
+		 * Moreover, if the insert position is the first or last point
+		 * of the line, include a third point.
+		 */
+
+		if ((int)beforeThis == -4) {
+		    objc += 2;
+		}
+		if ((int)beforeThis + 4 == length - (objc - 8)) {
+		    beforeThis -= 2;
+		    objc += 2;
+		}
+
+	    } else if (!strcmp(linePtr->smooth->name, "raw")) {
+		/*
+		 * Cubic Bezier splines. See details in ticket [5fb8145997].
+		 */
+
+		if (((oriNumPoints - 1) % 3) || (nbInsPoints % 3)) {
+		    /*
+		     * No optimization for "degenerate" lines or when inserting
+		     * something else than a multiple of 3 points.
+		     */
+
+		    itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW;
+		} else {
+		    beforeThis -= (int)beforeThis % 6;
+		    objc += 4;
+		}
+
+	    } else {
+		/*
+		 * Custom smoothing method. No optimization is possible.
+		 */
+
+		itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW;
+	    }
+	}
+
+	if (itemPtr->redraw_flags & TK_ITEM_DONT_REDRAW) {
+	    if ((int)beforeThis < 0) {
+		beforeThis = 0;
+	    }
+	    if ((int)beforeThis + objc > length) {
+		objc = length - (int)beforeThis;
+	    }
+
+	    itemPtr->x1 = itemPtr->x2 = (int) linePtr->coordPtr[beforeThis];
+	    itemPtr->y1 = itemPtr->y2 = (int) linePtr->coordPtr[beforeThis+1];
+	    if ((linePtr->firstArrowPtr != NULL) && ((int)beforeThis < 2)) {
+		/*
+		 * Include old first arrow.
+		 */
+
+		for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW;
+			i++, coordPtr += 2) {
+		    TkIncludePoint(itemPtr, coordPtr);
+		}
+	    }
+	    if ((linePtr->lastArrowPtr != NULL) && ((int)beforeThis+objc >= length)) {
+		/*
+		 * Include old last arrow.
+		 */
+
+		for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW;
+			i++, coordPtr += 2) {
+		    TkIncludePoint(itemPtr, coordPtr);
+		}
+	    }
+	    coordPtr = linePtr->coordPtr + beforeThis;
+	    for (i=0; i<objc; i+=2) {
+		TkIncludePoint(itemPtr, coordPtr);
+		coordPtr += 2;
+	    }
+	}
+    }
+
     if (linePtr->firstArrowPtr != NULL) {
 	ckfree(linePtr->firstArrowPtr);
 	linePtr->firstArrowPtr = NULL;
     }
     if (linePtr->lastArrowPtr != NULL) {
@@ -1081,23 +1142,23 @@
 
     if (itemPtr->redraw_flags & TK_ITEM_DONT_REDRAW) {
 	double width;
 	int intWidth;
 
-	if ((linePtr->firstArrowPtr != NULL) && ((int)beforeThis > 2)) {
+	if ((linePtr->firstArrowPtr != NULL) && ((int)beforeThis < 2)) {
 	    /*
 	     * Include new first arrow.
 	     */
 
 	    for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW;
 		    i++, coordPtr += 2) {
 		TkIncludePoint(itemPtr, coordPtr);
 	    }
 	}
-	if ((linePtr->lastArrowPtr != NULL) && ((int)beforeThis+objc < length-2)) {
+	if ((linePtr->lastArrowPtr != NULL) && ((int)beforeThis+objc >= length)) {
 	    /*
-	     * Include new right arrow.
+	     * Include new last arrow.
 	     */
 
 	    for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW;
 		    i++, coordPtr += 2) {
 		TkIncludePoint(itemPtr, coordPtr);
@@ -1151,31 +1212,39 @@
     Tk_Item *itemPtr,		/* Item in which to delete characters. */
     TkSizeT first,			/* Index of first character to delete. */
     TkSizeT last)			/* Index of last character to delete. */
 {
     LineItem *linePtr = (LineItem *) itemPtr;
-    int count, i, first1, last1;
+    int count, i, first1, last1, nbDelPoints;
+    int oriNumPoints = linePtr->numPoints;
+    int canOptimize = 1;
     int length = 2*linePtr->numPoints;
     double *coordPtr;
     Tk_State state = itemPtr->state;
 
     if (state == TK_STATE_NULL) {
 	state = Canvas(canvas)->canvas_state;
     }
 
-    first &= -2;
+    first &= -2;	/* If odd, make it even. */
     last &= -2;
 
     if ((int)first < 0) {
 	first = 0;
     }
     if ((int)last >= length) {
-	last = length-2;
+	last = length - 2;
     }
     if ((int)first > (int)last) {
 	return;
     }
+
+    /*
+     * With arrows, the end points of the line are adjusted so that a thick
+     * line doesn't stick out past the arrowheads (see ConfigureArrows).
+     */
+
     if (linePtr->firstArrowPtr != NULL) {
 	linePtr->coordPtr[0] = linePtr->firstArrowPtr[0];
 	linePtr->coordPtr[1] = linePtr->firstArrowPtr[1];
     }
     if (linePtr->lastArrowPtr != NULL) {
@@ -1182,33 +1251,87 @@
 	linePtr->coordPtr[length-2] = linePtr->lastArrowPtr[0];
 	linePtr->coordPtr[length-1] = linePtr->lastArrowPtr[1];
     }
     first1 = first;
     last1 = last;
-    if (first1 > 0) {
-	first1 -= 2;
-    }
-    if (last1 < length-2) {
-	last1 += 2;
-    }
+    nbDelPoints = (last - first) / 2 + 1;
+
+    /*
+     * Include one point at left of the left delete position, and one
+     * point at right of the right delete position.
+     */
+
+    first1 -= 2;
+    last1 += 2;
+
     if (linePtr->smooth) {
-	if (first1 > 0) {
+
+	if (!strcmp(linePtr->smooth->name, "true")) {
+	    /*
+	     * Quadratic Bezier splines. A second point must be included at
+	     * each side of the delete position.
+	     */
+
 	    first1 -= 2;
-	}
-	if (last1 < length-2) {
 	    last1 += 2;
+
+	    /*
+	     * If the delete position is the first or last point of the line,
+	     * include a third point.
+	     */
+
+	    if (first1 == -4) {
+		last1 += 2;
+	    }
+	    if (last1 - 4 == length - 2) {
+		first1 -= 2;
+	    }
+
+	} else if (!strcmp(linePtr->smooth->name, "raw")) {
+	    /*
+	     * Cubic Bezier splines. See details in ticket [5fb8145997].
+	     */
+
+	    if (((oriNumPoints - 1) % 3) || (nbDelPoints % 3)) {
+		/*
+		 * No optimization for "degenerate" lines or when deleting
+		 * something else than a multiple of 3 points.
+		 */
+
+		canOptimize = 0;
+	    }
+	    else {
+		first1 -= first1 % 6;
+		last1 = last + 6 - last % 6;
+	    }
+
+	} else {
+	    /*
+	     * Custom smoothing method. No optimization is possible.
+	     */
+
+	    canOptimize = 0;
 	}
     }
 
-    if ((first1 >= 2) || (last1 < length-2)) {
+    if (first1 < 0) {
+	first1 = 0;
+    }
+    if (last1 >= length) {
+	last1 = length - 2;
+    }
+
+    if (canOptimize && ((first1 >= 2) || (last1 < length-2))) {
 	/*
 	 * This is some optimizing code that will result that only the part of
 	 * the line that changed (and the objects that are overlapping with
 	 * that part) need to be redrawn. A special flag is set that instructs
 	 * the general canvas code not to redraw the whole object. If this
 	 * flag is set, the redrawing has to be done here, otherwise the
 	 * general Canvas code will take care of it.
+	 * Rationale for the optimization code can be found in Tk ticket
+	 * [5fb8145997].
 	 */
 
 	itemPtr->redraw_flags |= TK_ITEM_DONT_REDRAW;
 	itemPtr->x1 = itemPtr->x2 = (int) linePtr->coordPtr[first1];
 	itemPtr->y1 = itemPtr->y2 = (int) linePtr->coordPtr[first1+1];
@@ -1220,11 +1343,11 @@
 	    for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW;
 		    i++, coordPtr += 2) {
 		TkIncludePoint(itemPtr, coordPtr);
 	    }
 	}
-	if ((linePtr->lastArrowPtr != NULL) && (last1 >= length-2)) {
+	if ((linePtr->lastArrowPtr != NULL) && (last1 >= length - 2)) {
 	    /*
 	     * Include old last arrow.
 	     */
 
 	    for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW;
@@ -1257,23 +1380,23 @@
     }
     if (itemPtr->redraw_flags & TK_ITEM_DONT_REDRAW) {
 	double width;
 	int intWidth;
 
-	if ((linePtr->firstArrowPtr != NULL) && (first1 < 4)) {
+	if ((linePtr->firstArrowPtr != NULL) && (first1 < 2)) {
 	    /*
 	     * Include new first arrow.
 	     */
 
 	    for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW;
 		    i++, coordPtr += 2) {
 		TkIncludePoint(itemPtr, coordPtr);
 	    }
 	}
-	if ((linePtr->lastArrowPtr != NULL) && (last1 > length-4)) {
+	if ((linePtr->lastArrowPtr != NULL) && (last1 >= length - 2)) {
 	    /*
-	     * Include new right arrow.
+	     * Include new last arrow.
 	     */
 
 	    for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW;
 		    i++, coordPtr += 2) {
 		TkIncludePoint(itemPtr, coordPtr);
@@ -1746,11 +1869,11 @@
     TkSizeT idx, length;
     LineItem *linePtr = (LineItem *) itemPtr;
     const char *string;
     (void)canvas;
 
-    if (TCL_OK == TkGetIntForIndex(obj, 2*linePtr->numPoints - 1, 0, &idx)) {
+    if (TCL_OK == TkGetIntForIndex(obj, 2*linePtr->numPoints - 1, 1, &idx)) {
 	if (idx == TCL_INDEX_NONE) {
 	    idx = 0;
 	} else if (idx > (2*(TkSizeT)linePtr->numPoints)) {
 	    idx = 2*linePtr->numPoints;
 	} else {
@@ -1758,11 +1881,11 @@
 	}
 	*indexPtr = idx;
 	return TCL_OK;
     }
 
-    string = TkGetStringFromObj(obj, &length);
+    string = Tcl_GetStringFromObj(obj, &length);
 
     if (string[0] == '@') {
 	int i;
 	double x, y, bestDist, dist, *coordPtr;
 	char *end;
@@ -1934,11 +2057,11 @@
     TkSizeT offset)			/* Offset of shape information in widget
 				 * record. */
 {
     LineItem *linePtr = (LineItem *) recordPtr;
     double a, b, c;
-    int argc;
+    TkSizeT argc;
     const char **argv = NULL;
 
     if ((size_t)offset != offsetof(LineItem, arrowShapeA)) {
 	Tcl_Panic("ParseArrowShape received bogus offset");
     }

Index: generic/tkCanvPoly.c
==================================================================
--- generic/tkCanvPoly.c
+++ generic/tkCanvPoly.c
@@ -1,13 +1,13 @@
 /*
  * tkCanvPoly.c --
  *
  *	This file implements polygon items for canvas widgets.
  *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-2000 Ajuba Solutions.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Ajuba Solutions.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -1019,11 +1019,11 @@
     TkSizeT beforeThis,		/* Index before which new coordinates are to
 				 * be inserted. */
     Tcl_Obj *obj)		/* New coordinates to be inserted. */
 {
     PolygonItem *polyPtr = (PolygonItem *) itemPtr;
-    int length, objc, i;
+    int length, oriNumPoints, objc, nbInsPoints, i;
     Tcl_Obj **objv;
     double *newCoordPtr;
     Tk_State state = itemPtr->state;
 
     if (state == TK_STATE_NULL) {
@@ -1032,11 +1032,13 @@
 
     if (!obj || (Tcl_ListObjGetElements(NULL, obj, &objc, &objv) != TCL_OK)
 	    || !objc || objc&1) {
 	return;
     }
+    oriNumPoints = polyPtr->numPoints - polyPtr->autoClosed;
     length = 2*(polyPtr->numPoints - polyPtr->autoClosed);
+    nbInsPoints = objc / 2;
     while ((int)beforeThis > length) {
 	beforeThis -= length;
     }
     while ((int)beforeThis < 0) {
 	beforeThis += length;
@@ -1090,10 +1092,12 @@
 	 * the polygon that changed (and the objects that are overlapping with
 	 * that part) need to be redrawn. A special flag is set that instructs
 	 * the general canvas code not to redraw the whole object. If this
 	 * flag is not set, the canvas will do the redrawing, otherwise I have
 	 * to do it here.
+	 * Rationale for the optimization code can be found in Tk ticket
+	 * [5fb8145997].
 	 */
 
     	double width;
 	int j;
 
@@ -1106,46 +1110,80 @@
 	 * bounding box has to be re-calculated anyway.
 	 */
 
 	itemPtr->x1 = itemPtr->x2 = (int) polyPtr->coordPtr[beforeThis];
 	itemPtr->y1 = itemPtr->y2 = (int) polyPtr->coordPtr[beforeThis+1];
-	beforeThis -= 2;
-	objc += 4;
-	if (polyPtr->smooth) {
-	    beforeThis -= 2;
-	    objc += 4;
-	}
-
-	/*
-	 * Be careful; beforeThis could now be negative
-	 */
-
-	for (i=beforeThis; i<(int)beforeThis+objc; i+=2) {
-	    j = i;
-	    if (j < 0) {
-		j += length;
-	    } else if (j >= length) {
-		j -= length;
-	    }
-	    TkIncludePoint(itemPtr, polyPtr->coordPtr+j);
-	}
-	width = polyPtr->outline.width;
-	if (Canvas(canvas)->currentItemPtr == itemPtr) {
-	    if (polyPtr->outline.activeWidth > width) {
-		width = polyPtr->outline.activeWidth;
-	    }
-	} else if (state == TK_STATE_DISABLED) {
-	    if (polyPtr->outline.disabledWidth > 0.0) {
-		width = polyPtr->outline.disabledWidth;
-	    }
-	}
-	itemPtr->x1 -= (int) width;
-	itemPtr->y1 -= (int) width;
-	itemPtr->x2 += (int) width;
-	itemPtr->y2 += (int) width;
-	Tk_CanvasEventuallyRedraw(canvas,
-		itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
+
+	beforeThis -= 2;
+	objc += 4;
+
+	if (polyPtr->smooth) {
+	    if (!strcmp(polyPtr->smooth->name, "true")) {
+		/*
+		 * Quadratic Bezier splines.
+		 */
+
+		beforeThis -= 2;
+		objc += 4;
+
+	    } else if (!strcmp(polyPtr->smooth->name, "raw")) {
+		/*
+		 * Cubic Bezier splines.
+		 */
+
+		if ((oriNumPoints % 3) || (nbInsPoints % 3)) {
+		    /*
+		     * No optimization for "degenerate" polygons or when inserting
+		     * something else than a multiple of 3 points.
+		     */
+
+		    itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW;
+		} else {
+		    beforeThis -= abs((int)beforeThis) % 6;
+		    objc += 4;
+		}
+
+	    } else {
+		/*
+		 * Custom smoothing method. No optimization is possible.
+		 */
+
+		itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW;
+	    }
+	}
+
+	if (itemPtr->redraw_flags & TK_ITEM_DONT_REDRAW) {
+	    /*
+	     * Be careful; beforeThis could now be negative
+	     */
+
+	    for (i=(int)beforeThis; i<(int)beforeThis+objc; i+=2) {
+		j = i;
+		if (j < 0) {
+		    j += length;
+		} else if (j >= length) {
+		    j -= length;
+		}
+		TkIncludePoint(itemPtr, polyPtr->coordPtr+j);
+	    }
+	    width = polyPtr->outline.width;
+	    if (Canvas(canvas)->currentItemPtr == itemPtr) {
+		if (polyPtr->outline.activeWidth > width) {
+		    width = polyPtr->outline.activeWidth;
+		}
+	    } else if (state == TK_STATE_DISABLED) {
+		if (polyPtr->outline.disabledWidth > 0.0) {
+		    width = polyPtr->outline.disabledWidth;
+		}
+	    }
+	    itemPtr->x1 -= (int) width;
+	    itemPtr->y1 -= (int) width;
+	    itemPtr->x2 += (int) width;
+	    itemPtr->y2 += (int) width;
+	    Tk_CanvasEventuallyRedraw(canvas,
+		    itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
+	}
     }
 
     ComputePolygonBbox(canvas, polyPtr);
 }
 
@@ -1681,18 +1719,20 @@
     TkSizeT count = 2*(polyPtr->numPoints - polyPtr->autoClosed);
 
     if (TCL_OK == TkGetIntForIndex(obj,  (INT_MAX - 1) - ((INT_MAX) % count), 1, &idx)) {
 	if (idx == TCL_INDEX_NONE) {
 	    idx = 0;
+	} else if (idx >= INT_MAX - ((INT_MAX) % count)) {
+	    idx = count;
 	} else {
 	    idx = (idx & (TkSizeT)-2) % count;
 	}
 	*indexPtr = idx;
 	return TCL_OK;
     }
 
-    string = TkGetStringFromObj(obj, &length);
+    string = Tcl_GetStringFromObj(obj, &length);
 
     if (string[0] == '@') {
 	int i;
 	double x, y, bestDist, dist, *coordPtr;
 	char *end;

Index: generic/tkCanvPs.c
==================================================================
--- generic/tkCanvPs.c
+++ generic/tkCanvPs.c
@@ -3,12 +3,12 @@
  *
  *	This module provides Postscript output support for canvases, including
  *	the "postscript" widget command plus a few utility functions used for
  *	generating Postscript.
  *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -283,37 +283,33 @@
     case TK_ANCHOR_NW:
     case TK_ANCHOR_W:
     case TK_ANCHOR_SW:
 	deltaX = 0;
 	break;
-    case TK_ANCHOR_N:
-    case TK_ANCHOR_CENTER:
-    case TK_ANCHOR_S:
-	deltaX = -psInfo.width/2;
-	break;
     case TK_ANCHOR_NE:
     case TK_ANCHOR_E:
     case TK_ANCHOR_SE:
 	deltaX = -psInfo.width;
 	break;
+    default:
+	deltaX = -psInfo.width/2;
+	break;
     }
     switch (psInfo.pageAnchor) {
     case TK_ANCHOR_NW:
     case TK_ANCHOR_N:
     case TK_ANCHOR_NE:
 	deltaY = - psInfo.height;
 	break;
-    case TK_ANCHOR_W:
-    case TK_ANCHOR_CENTER:
-    case TK_ANCHOR_E:
-	deltaY = -psInfo.height/2;
-	break;
     case TK_ANCHOR_SW:
     case TK_ANCHOR_S:
     case TK_ANCHOR_SE:
 	deltaY = 0;
 	break;
+    default:
+	deltaY = -psInfo.height/2;
+	break;
     }
 
     if (psInfo.colorMode == NULL) {
 	psInfo.colorLevel = 2;
     } else {
@@ -901,10 +897,22 @@
 	    (int *) &dummyX, (int *) &dummyY, (unsigned int *) &totalWidth,
 	    (unsigned int *) &totalHeight, &dummyBorderwidth, &dummyDepth);
     imagePtr = XGetImage(Tk_Display(tkwin), bitmap, 0, 0,
 	    totalWidth, totalHeight, 1, XYPixmap);
 
+
+    if (!imagePtr) {
+	/*
+	 * The XGetImage() function is apparently not implemented on this
+	 * system. Just skip the pixels, the Postscript will still be
+	 * syntactically correct.
+	 */
+
+        Tcl_AppendToObj(psObj, "<>", -1);
+	return;
+    }
+
     Tcl_AppendToObj(psObj, "<", -1);
     mask = 0x80;
     value = 0;
     charsInLine = 0;
     lastX = startX + width - 1;

Index: generic/tkCanvText.c
==================================================================
--- generic/tkCanvText.c
+++ generic/tkCanvText.c
@@ -1,12 +1,12 @@
 /*
  * tkCanvText.c --
  *
  *	This file implements text items for canvas widgets.
  *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -51,11 +51,11 @@
     Pixmap disabledStipple;	/* Stipple bitmap for text, or None. */
     char *text;			/* Text for item (malloc-ed). */
     int width;			/* Width of lines for word-wrap, pixels. Zero
 				 * means no word-wrap. */
     int underline;		/* Index of character to put underline beneath
-				 * or -1 for no underlining. */
+				 * or INT_MIN for no underlining. */
     double angle;		/* What angle, in degrees, to draw the text
 				 * at. */
 
     /*
      * Fields whose values are derived from the current values of the
@@ -90,10 +90,99 @@
     TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
 };
 static const Tk_CustomOption offsetOption = {
     TkOffsetParseProc, TkOffsetPrintProc, INT2PTR(TK_OFFSET_RELATIVE)
 };
+
+static int
+UnderlineParseProc(
+    ClientData dummy,	/* Not used.*/
+    Tcl_Interp *interp,		/* Used for reporting errors. */
+    Tk_Window tkwin,		/* Window containing canvas widget. */
+    const char *value,		/* Value of option. */
+    char *widgRec,		/* Pointer to record for item. */
+    TkSizeT offset)			/* Offset into item (ignored). */
+{
+    int *underlinePtr = (int *) (widgRec + offset);
+    Tcl_Obj obj;
+    int code;
+    TkSizeT underline;
+    (void)dummy;
+    (void)tkwin;
+
+    if (value == NULL || *value == 0) {
+	*underlinePtr = INT_MIN; /* No underline */
+	return TCL_OK;
+    }
+
+    obj.refCount = 1;
+    obj.bytes = (char *)value;
+    obj.length = strlen(value);
+    obj.typePtr = NULL;
+    code = TkGetIntForIndex(&obj, TCL_INDEX_END, 0, &underline);
+    if (code == TCL_OK) {
+	if (underline == TCL_INDEX_NONE) {
+	    underline = INT_MIN;
+	} else if ((size_t)underline > (size_t)TCL_INDEX_END>>1) {
+		underline++;
+	} else if (underline >= INT_MAX) {
+	    underline = INT_MAX;
+	}
+	*underlinePtr = underline;
+
+    } else {
+	Tcl_AppendResult(interp, "bad index \"", value,
+		"\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"", NULL);
+    }
+	return code;
+}
+
+const char *
+UnderlinePrintProc(
+    ClientData dummy,	/* Ignored. */
+    Tk_Window tkwin,		/* Window containing canvas widget. */
+    char *widgRec,		/* Pointer to record for item. */
+    TkSizeT offset,			/* Pointer to record for item. */
+    Tcl_FreeProc **freeProcPtr)	/* Pointer to variable to fill in with
+				 * information about how to reclaim storage
+				 * for return string. */
+{
+    int underline = *(int *)(widgRec + offset);
+    char *p;
+    (void)dummy;
+    (void)tkwin;
+
+    if (underline == INT_MIN) {
+#if !defined(TK_NO_DEPRECATED) && TK_MAJOR_VERSION < 9
+	p = (char *)"-1";
+#else
+	p = (char *)"";
+#endif
+	*freeProcPtr = TCL_STATIC;
+	return p;
+    } else if (underline == INT_MAX) {
+	p = (char *)"end+1";
+	*freeProcPtr = TCL_STATIC;
+	return p;
+    } else if (underline == -1) {
+	p = (char *)"end";
+	*freeProcPtr = TCL_STATIC;
+	return p;
+    }
+    p = (char *)ckalloc(32);
+    if (underline < 0) {
+	sprintf(p, "end%d", underline);
+    } else {
+	sprintf(p, "%d", underline);
+    }
+    *freeProcPtr = TCL_DYNAMIC;
+    return p;
+}
+
+static const Tk_CustomOption underlineOption = {
+    UnderlineParseProc, UnderlinePrintProc, NULL
+};
 
 static const Tk_ConfigSpec configSpecs[] = {
     {TK_CONFIG_COLOR, "-activefill", NULL, NULL,
 	NULL, offsetof(TextItem, activeColor), TK_CONFIG_NULL_OK, NULL},
     {TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
@@ -121,12 +210,12 @@
 	NULL, offsetof(TextItem, stipple), TK_CONFIG_NULL_OK, NULL},
     {TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
 	NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
     {TK_CONFIG_STRING, "-text", NULL, NULL,
 	"", offsetof(TextItem, text), 0, NULL},
-    {TK_CONFIG_INT, "-underline", NULL, NULL,
-	"-1", offsetof(TextItem, underline), 0, NULL},
+    {TK_CONFIG_CUSTOM, "-underline", NULL, NULL, NULL,
+	offsetof(TextItem, underline), TK_CONFIG_NULL_OK, &underlineOption},
     {TK_CONFIG_PIXELS, "-width", NULL, NULL,
 	"0", offsetof(TextItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL},
     {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
 };
 
@@ -138,11 +227,11 @@
 static int		ConfigureText(Tcl_Interp *interp,
 			    Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
 			    Tcl_Obj *const objv[], int flags);
 static int		CreateText(Tcl_Interp *interp,
 			    Tk_Canvas canvas, struct Tk_Item *itemPtr,
-			    int argc, Tcl_Obj *const objv[]);
+			    int objc, Tcl_Obj *const objv[]);
 static void		DeleteText(Tk_Canvas canvas,
 			    Tk_Item *itemPtr, Display *display);
 static void		DisplayCanvText(Tk_Canvas canvas,
 			    Tk_Item *itemPtr, Display *display, Drawable dst,
 			    int x, int y, int width, int height);
@@ -157,11 +246,11 @@
 			    double scaleX, double scaleY);
 static void		SetTextCursor(Tk_Canvas canvas,
 			    Tk_Item *itemPtr, TkSizeT index);
 static int		TextCoords(Tcl_Interp *interp,
 			    Tk_Canvas canvas, Tk_Item *itemPtr,
-			    int argc, Tcl_Obj *const objv[]);
+			    int objc, Tcl_Obj *const objv[]);
 static void		TextDeleteChars(Tk_Canvas canvas,
 			    Tk_Item *itemPtr, TkSizeT first, TkSizeT last);
 static void		TextInsert(Tk_Canvas canvas,
 			    Tk_Item *itemPtr, TkSizeT beforeThis, Tcl_Obj *obj);
 static int		TextToArea(Tk_Canvas canvas,
@@ -262,11 +351,11 @@
     textPtr->stipple	= None;
     textPtr->activeStipple = None;
     textPtr->disabledStipple = None;
     textPtr->text	= NULL;
     textPtr->width	= 0;
-    textPtr->underline	= -1;
+    textPtr->underline	= INT_MIN;
     textPtr->angle	= 0.0;
 
     textPtr->numChars	= 0;
     textPtr->numBytes	= 0;
     textPtr->textLayout = NULL;
@@ -563,16 +652,15 @@
  *--------------------------------------------------------------
  */
 
 static void
 DeleteText(
-    Tk_Canvas canvas,		/* Info about overall canvas widget. */
+    TCL_UNUSED(Tk_Canvas),	/* Info about overall canvas widget. */
     Tk_Item *itemPtr,		/* Item that is being deleted. */
     Display *display)		/* Display containing window for canvas. */
 {
     TextItem *textPtr = (TextItem *) itemPtr;
-    (void)canvas;
 
     if (textPtr->color != NULL) {
 	Tk_FreeColor(textPtr->color);
     }
     if (textPtr->activeColor != NULL) {
@@ -631,11 +719,11 @@
 ComputeTextBbox(
     Tk_Canvas canvas,		/* Canvas that contains item. */
     TextItem *textPtr)		/* Item whose bbox is to be recomputed. */
 {
     Tk_CanvasTextInfo *textInfoPtr;
-    int leftX, topY, width, height, fudge, i;
+    int width, height, fudge, i;
     Tk_State state = textPtr->header.state;
     double x[4], y[4], dx[4], dy[4], sinA, cosA, tmp;
 
     if (state == TK_STATE_NULL) {
 	state = Canvas(canvas)->canvas_state;
@@ -653,60 +741,50 @@
     /*
      * Use overall geometry information to compute the top-left corner of the
      * bounding box for the text item.
      */
 
-    leftX = ROUND(textPtr->x);
-    topY = ROUND(textPtr->y);
     for (i=0 ; i<4 ; i++) {
 	dx[i] = dy[i] = 0.0;
     }
     switch (textPtr->anchor) {
     case TK_ANCHOR_NW:
     case TK_ANCHOR_N:
     case TK_ANCHOR_NE:
 	break;
 
-    case TK_ANCHOR_W:
-    case TK_ANCHOR_CENTER:
-    case TK_ANCHOR_E:
-	topY -= height / 2;
+    case TK_ANCHOR_SW:
+    case TK_ANCHOR_S:
+    case TK_ANCHOR_SE:
 	for (i=0 ; i<4 ; i++) {
-	    dy[i] = -height / 2;
+	    dy[i] = -height;
 	}
 	break;
 
-    case TK_ANCHOR_SW:
-    case TK_ANCHOR_S:
-    case TK_ANCHOR_SE:
-	topY -= height;
+    default:
 	for (i=0 ; i<4 ; i++) {
-	    dy[i] = -height;
+	    dy[i] = -height / 2;
 	}
 	break;
     }
     switch (textPtr->anchor) {
     case TK_ANCHOR_NW:
     case TK_ANCHOR_W:
     case TK_ANCHOR_SW:
 	break;
 
-    case TK_ANCHOR_N:
-    case TK_ANCHOR_CENTER:
-    case TK_ANCHOR_S:
-	leftX -= width / 2;
+    case TK_ANCHOR_NE:
+    case TK_ANCHOR_E:
+    case TK_ANCHOR_SE:
 	for (i=0 ; i<4 ; i++) {
-	    dx[i] = -width / 2;
+	    dx[i] = -width;
 	}
 	break;
 
-    case TK_ANCHOR_NE:
-    case TK_ANCHOR_E:
-    case TK_ANCHOR_SE:
-	leftX -= width;
+    default:
 	for (i=0 ; i<4 ; i++) {
-	    dx[i] = -width;
+	    dx[i] = -width / 2;
 	}
 	break;
     }
 
     textPtr->actualWidth = width;
@@ -1018,11 +1096,11 @@
     TkSizeT byteCount;
     char *newStr, *text;
     const char *string;
     Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
 
-    string = TkGetStringFromObj(obj, &byteCount);
+    string = Tcl_GetStringFromObj(obj, &byteCount);
 
     text = textPtr->text;
 
     if (index == TCL_INDEX_NONE) {
 	index = 0;
@@ -1397,11 +1475,11 @@
 	}
 	*indexPtr = idx;
 	return TCL_OK;
     }
 
-    string = TkGetStringFromObj(obj, &length);
+    string = Tcl_GetStringFromObj(obj, &length);
     c = string[0];
 
     if ((c == 'i')
 	    && (strncmp(string, "insert", length) == 0)) {
 	*indexPtr = textPtr->insertPos;
@@ -1643,26 +1721,25 @@
 	Tk_CanvasPsStipple(interp, canvas, stipple);
 	Tcl_AppendPrintfToObj(psObj, "/StippleText {\n    %s} bind def\n",
 		Tcl_GetString(Tcl_GetObjResult(interp)));
     }
 
-    x = 0;  y = 0;  justify = NULL;
     switch (textPtr->anchor) {
     case TK_ANCHOR_NW:	   x = 0; y = 0; break;
     case TK_ANCHOR_N:	   x = 1; y = 0; break;
     case TK_ANCHOR_NE:	   x = 2; y = 0; break;
     case TK_ANCHOR_E:	   x = 2; y = 1; break;
     case TK_ANCHOR_SE:	   x = 2; y = 2; break;
     case TK_ANCHOR_S:	   x = 1; y = 2; break;
     case TK_ANCHOR_SW:	   x = 0; y = 2; break;
     case TK_ANCHOR_W:	   x = 0; y = 1; break;
-    case TK_ANCHOR_CENTER: x = 1; y = 1; break;
+    default: x = 1; y = 1; break;
     }
     switch (textPtr->justify) {
-    case TK_JUSTIFY_LEFT:   justify = "0";   break;
     case TK_JUSTIFY_CENTER: justify = "0.5"; break;
     case TK_JUSTIFY_RIGHT:  justify = "1";   break;
+    default:                justify = "0";   break;
     }
 
     Tk_GetFontMetrics(textPtr->tkfont, &fm);
 
     Tcl_AppendPrintfToObj(psObj, "%.15g %.15g %.15g [\n",

Index: generic/tkCanvUtil.c
==================================================================
--- generic/tkCanvUtil.c
+++ generic/tkCanvUtil.c
@@ -2,11 +2,11 @@
  * tkCanvUtil.c --
  *
  *	This file contains a collection of utility functions used by the
  *	implementations of various canvas item types.
  *
- * Copyright (c) 1994 Sun Microsystems, Inc.
+ * Copyright © 1994 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -409,11 +409,11 @@
     const char *value,		/* Value of option (list of tag names). */
     char *widgRec,		/* Pointer to record for item. */
     TkSizeT offset)			/* Offset into item (ignored). */
 {
     Tk_Item *itemPtr = (Tk_Item *) widgRec;
-    int argc, i;
+    TkSizeT argc, i;
     const char **argv;
     Tk_Uid *newPtr;
     (void)dummy;
     (void)tkwin;
     (void)offset;
@@ -428,13 +428,13 @@
 
     /*
      * Make sure that there's enough space in the item to hold the tag names.
      */
 
-    if ((int)itemPtr->tagSpace < argc) {
+    if (itemPtr->tagSpace < argc) {
 	newPtr = (Tk_Uid *)ckalloc(argc * sizeof(Tk_Uid));
-	for (i = (int)itemPtr->numTags - 1; i >= 0; i--) {
+	for (i = itemPtr->numTags - 1; i != TCL_INDEX_NONE; i--) {
 	    newPtr[i] = itemPtr->tagPtr[i];
 	}
 	if (itemPtr->tagPtr != itemPtr->staticTagSpace) {
 	    ckfree(itemPtr->tagPtr);
 	}
@@ -772,11 +772,11 @@
     if (methods == NULL) {
 	methods = InitSmoothMethods(interp);
     }
 
     /*
-     * Backward compatability hack.
+     * Backward compatibility hack.
      */
 
     if (strncmp(value, "bezier", length) == 0) {
 	smooth = &tkBezierSmoothMethod;
     }

Index: generic/tkCanvWind.c
==================================================================
--- generic/tkCanvWind.c
+++ generic/tkCanvWind.c
@@ -1,12 +1,12 @@
 /*
  * tkCanvWind.c --
  *
  *	This file implements window items for canvas widgets.
  *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -516,11 +516,11 @@
     case TK_ANCHOR_W:
 	y -= height/2;
 	break;
     case TK_ANCHOR_NW:
 	break;
-    case TK_ANCHOR_CENTER:
+    default:
 	x -= width/2;
 	y -= height/2;
 	break;
     }
 
@@ -578,10 +578,13 @@
     (void)regionHeight;
 
     if (winItemPtr->tkwin == NULL) {
 	return;
     }
+
+    Tcl_Preserve(canvas);
+
     if (state == TK_STATE_NULL) {
 	state = Canvas(canvas)->canvas_state;
     }
 
     /*
@@ -592,10 +595,11 @@
 	if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) {
 	    Tk_UnmapWindow(winItemPtr->tkwin);
 	} else {
 	    Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin);
 	}
+	Tcl_Release(canvas);
 	return;
     }
     Tk_CanvasWindowCoords(canvas, (double) winItemPtr->header.x1,
 	    (double) winItemPtr->header.y1, &x, &y);
     width = winItemPtr->header.x2 - winItemPtr->header.x1;
@@ -613,10 +617,11 @@
 	if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) {
 	    Tk_UnmapWindow(winItemPtr->tkwin);
 	} else {
 	    Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin);
 	}
+	Tcl_Release(canvas);
 	return;
     }
 
     /*
      * Reposition and map the window (but in different ways depending on
@@ -627,15 +632,20 @@
 	if ((x != Tk_X(winItemPtr->tkwin)) || (y != Tk_Y(winItemPtr->tkwin))
 		|| (width != Tk_Width(winItemPtr->tkwin))
 		|| (height != Tk_Height(winItemPtr->tkwin))) {
 	    Tk_MoveResizeWindow(winItemPtr->tkwin, x, y, width, height);
 	}
-	Tk_MapWindow(winItemPtr->tkwin);
+
+	if (winItemPtr->tkwin) {
+	    Tk_MapWindow(winItemPtr->tkwin);
+	}
+
     } else {
 	Tk_MaintainGeometry(winItemPtr->tkwin, canvasTkwin, x, y,
 		width, height);
     }
+    Tcl_Release(canvas);
 }
 
 /*
  *--------------------------------------------------------------
  *
@@ -824,11 +834,11 @@
     case TK_ANCHOR_E:	    x -= width;	    y -= height/2.0;	    break;
     case TK_ANCHOR_SE:	    x -= width;				    break;
     case TK_ANCHOR_S:	    x -= width/2.0;			    break;
     case TK_ANCHOR_SW:						    break;
     case TK_ANCHOR_W:			    y -= height/2.0;	    break;
-    case TK_ANCHOR_CENTER:  x -= width/2.0; y -= height/2.0;	    break;
+    default:  x -= width/2.0; y -= height/2.0;	    break;
     }
 
     return CanvasPsWindow(interp, tkwin, canvas, x, y, width, height);
 }
 

Index: generic/tkCanvas.c
==================================================================
--- generic/tkCanvas.c
+++ generic/tkCanvas.c
@@ -3,26 +3,25 @@
  *
  *	This module implements canvas widgets for the Tk toolkit. A canvas
  *	displays a background and a collection of graphical objects such as
  *	rectangles, lines, and texts.
  *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-1999 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
 #include "tkInt.h"
 #include "tkCanvas.h"
 #include "default.h"
-#ifdef TK_NO_DOUBLE_BUFFERING
+#include "tkPort.h"
 #ifdef MAC_OSX_TK
 #include "tkMacOSXInt.h"
 #endif
-#endif /* TK_NO_DOUBLE_BUFFERING */
 
 /*
  * See tkCanvas.h for key data structures used to implement canvases.
  */
 
@@ -214,53 +213,53 @@
 
 /*
  * Prototypes for functions defined later in this file:
  */
 
-static void		CanvasBindProc(ClientData clientData,
+static void		CanvasBindProc(void *clientData,
 			    XEvent *eventPtr);
-static void		CanvasBlinkProc(ClientData clientData);
-static void		CanvasCmdDeletedProc(ClientData clientData);
+static void		CanvasBlinkProc(void *clientData);
+static void		CanvasCmdDeletedProc(void *clientData);
 static void		CanvasDoEvent(TkCanvas *canvasPtr, XEvent *eventPtr);
-static void		CanvasEventProc(ClientData clientData,
+static void		CanvasEventProc(void *clientData,
 			    XEvent *eventPtr);
-static TkSizeT	CanvasFetchSelection(ClientData clientData, TkSizeT offset,
+static TkSizeT	CanvasFetchSelection(void *clientData, TkSizeT offset,
 			    char *buffer, TkSizeT maxBytes);
 static Tk_Item *	CanvasFindClosest(TkCanvas *canvasPtr,
 			    double coords[2]);
 static void		CanvasFocusProc(TkCanvas *canvasPtr, int gotFocus);
-static void		CanvasLostSelection(ClientData clientData);
+static void		CanvasLostSelection(void *clientData);
 static void		CanvasSelectTo(TkCanvas *canvasPtr,
 			    Tk_Item *itemPtr, TkSizeT index);
 static void		CanvasSetOrigin(TkCanvas *canvasPtr,
 			    int xOrigin, int yOrigin);
 static void		CanvasUpdateScrollbars(TkCanvas *canvasPtr);
-static int		CanvasWidgetCmd(ClientData clientData,
-			    Tcl_Interp *interp, int argc,
-			    Tcl_Obj *const *argv);
-static void		CanvasWorldChanged(ClientData instanceData);
+static int		CanvasWidgetCmd(void *clientData,
+			    Tcl_Interp *interp, int objc,
+			    Tcl_Obj *const *objv);
+static void		CanvasWorldChanged(void *instanceData);
 static int		ConfigureCanvas(Tcl_Interp *interp,
-			    TkCanvas *canvasPtr, int argc,
-			    Tcl_Obj *const *argv, int flags);
+			    TkCanvas *canvasPtr, int objc,
+			    Tcl_Obj *const *objv, int flags);
 static void		DefaultRotateImplementation(TkCanvas *canvasPtr,
 			    Tk_Item *itemPtr, double x, double y,
 			    double angleRadians);
 static void		DestroyCanvas(void *memPtr);
-static int		DrawCanvas(Tcl_Interp *interp, ClientData clientData, Tk_PhotoHandle photohandle, int subsample, int zoom);
-static void		DisplayCanvas(ClientData clientData);
+static int		DrawCanvas(Tcl_Interp *interp, void *clientData, Tk_PhotoHandle photohandle, int subsample, int zoom);
+static void		DisplayCanvas(void *clientData);
 static void		DoItem(Tcl_Obj *accumObj,
 			    Tk_Item *itemPtr, Tk_Uid tag);
 static void		EventuallyRedrawItem(TkCanvas *canvasPtr,
 			    Tk_Item *itemPtr);
 static int		FindItems(Tcl_Interp *interp, TkCanvas *canvasPtr,
-			    int argc, Tcl_Obj *const *argv,
+			    int objc, Tcl_Obj *const *objv,
 			    Tcl_Obj *newTagObj, int first,
 			    TagSearch **searchPtrPtr);
 static int		FindArea(Tcl_Interp *interp, TkCanvas *canvasPtr,
-			    Tcl_Obj *const *argv, Tk_Uid uid, int enclosed);
+			    Tcl_Obj *const *objv, Tk_Uid uid, int enclosed);
 static double		GridAlign(double coord, double spacing);
-static const char**	TkGetStringsFromObjs(int argc, Tcl_Obj *const *objv);
+static const char**	TkGetStringsFromObjs(int objc, Tcl_Obj *const *objv);
 static void		InitCanvas(void);
 static void		PickCurrentItem(TkCanvas *canvasPtr, XEvent *eventPtr);
 static Tcl_Obj *	ScrollFractions(int screen1,
 			    int screen2, int object1, int object2);
 static int		RelinkItems(TkCanvas *canvasPtr, Tcl_Obj *tag,
@@ -597,11 +596,12 @@
     Tk_Item *itemPtr,
     double x,
     double y,
     double angleRadians)
 {
-    int objc, i, ok = 1;
+    TkSizeT i, objc;
+    int ok = 1;
     Tcl_Obj **objv, **newObjv;
     double *coordv;
     double s = sin(angleRadians);
     double c = cos(angleRadians);
     Tcl_Interp *interp = canvasPtr->interp;
@@ -677,29 +677,29 @@
  *--------------------------------------------------------------
  */
 
 int
 Tk_CanvasObjCmd(
-    ClientData clientData,	/* Main window associated with interpreter. */
+    void *clientData,	/* Main window associated with interpreter. */
     Tcl_Interp *interp,		/* Current interpreter. */
-    int argc,			/* Number of arguments. */
-    Tcl_Obj *const argv[])	/* Argument objects. */
+    int objc,			/* Number of arguments. */
+    Tcl_Obj *const objv[])	/* Argument objects. */
 {
     Tk_Window tkwin = (Tk_Window)clientData;
     TkCanvas *canvasPtr;
     Tk_Window newWin;
 
     if (typeList == NULL) {
 	InitCanvas();
     }
 
-    if (argc < 2) {
-	Tcl_WrongNumArgs(interp, 1, argv, "pathName ?-option value ...?");
+    if (objc < 2) {
+	Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
 	return TCL_ERROR;
     }
 
-    newWin = Tk_CreateWindowFromPath(interp,tkwin,Tcl_GetString(argv[1]),NULL);
+    newWin = Tk_CreateWindowFromPath(interp,tkwin,Tcl_GetString(objv[1]),NULL);
     if (newWin == NULL) {
 	return TCL_ERROR;
     }
 
     /*
@@ -793,11 +793,11 @@
 	    |ButtonPressMask|ButtonReleaseMask|EnterWindowMask
 	    |LeaveWindowMask|PointerMotionMask|VirtualEventMask,
 	    CanvasBindProc, canvasPtr);
     Tk_CreateSelHandler(canvasPtr->tkwin, XA_PRIMARY, XA_STRING,
 	    CanvasFetchSelection, canvasPtr, XA_STRING);
-    if (ConfigureCanvas(interp, canvasPtr, argc-2, argv+2, 0) != TCL_OK) {
+    if (ConfigureCanvas(interp, canvasPtr, objc-2, objv+2, 0) != TCL_OK) {
 	goto error;
     }
 
     Tcl_SetObjResult(interp, Tk_NewWindowObj(canvasPtr->tkwin));
     return TCL_OK;
@@ -825,11 +825,11 @@
  *--------------------------------------------------------------
  */
 
 static int
 CanvasWidgetCmd(
-    ClientData clientData,	/* Information about canvas widget. */
+    void *clientData,	/* Information about canvas widget. */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     TkCanvas *canvasPtr = (TkCanvas *)clientData;
@@ -1255,11 +1255,11 @@
 	if (objc < 3) {
 	    Tcl_WrongNumArgs(interp, 2, objv, "type coords ?arg ...?");
 	    result = TCL_ERROR;
 	    goto done;
 	}
-	arg = TkGetStringFromObj(objv[2], &length);
+	arg = Tcl_GetStringFromObj(objv[2], &length);
 	c = arg[0];
 
 	/*
 	 * Lock because the list of types is a global resource that could be
 	 * updated by another thread. That's fairly unlikely, but not
@@ -1440,11 +1440,11 @@
 	}
 	break;
     }
     case CANV_DTAG: {
 	Tk_Uid tag;
-	int i;
+	TkSizeT i;
 
 	if ((objc != 3) && (objc != 4)) {
 	    Tcl_WrongNumArgs(interp, 2, objv, "tagOrId ?tagToDelete?");
 	    result = TCL_ERROR;
 	    goto done;
@@ -1453,11 +1453,11 @@
 	    tag = Tk_GetUid(Tcl_GetString(objv[3]));
 	} else {
 	    tag = Tk_GetUid(Tcl_GetString(objv[2]));
 	}
 	FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done) {
-	    for (i = (int)itemPtr->numTags-1; i >= 0; i--) {
+	    for (i = itemPtr->numTags-1; i != TCL_INDEX_NONE; i--) {
 		if (itemPtr->tagPtr[i] == tag) {
 
                     /*
                      * Don't shuffle the tags sequence: memmove the tags.
                      */
@@ -1916,29 +1916,29 @@
 	break;
     }
     case CANV_SCAN: {
 	int x, y, gain = 10;
 	static const char *const optionStrings[] = {
-	    "mark", "dragto", NULL
+	    "dragto", "mark", NULL
 	};
 
 	if (objc < 5) {
 	    Tcl_WrongNumArgs(interp, 2, objv, "mark|dragto x y ?dragGain?");
 	    result = TCL_ERROR;
 	} else if (Tcl_GetIndexFromObj(interp, objv[2], optionStrings,
 		"scan option", 0, &idx) != TCL_OK) {
 	    result = TCL_ERROR;
-	} else if ((objc != 5) && (objc != 5+idx)) {
-	    Tcl_WrongNumArgs(interp, 3, objv, idx?"x y ?gain?":"x y");
+	} else if ((objc != 5) && (objc + idx != 6)) {
+	    Tcl_WrongNumArgs(interp, 3, objv, idx?"x y":"x y ?gain?");
 	    result = TCL_ERROR;
 	} else if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK)
 		|| (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)){
 	    result = TCL_ERROR;
 	} else if ((objc == 6) &&
 		(Tcl_GetIntFromObj(interp, objv[5], &gain) != TCL_OK)) {
 	    result = TCL_ERROR;
-	} else if (!idx) {
+	} else if (idx) {
 	    canvasPtr->scanX = x;
 	    canvasPtr->scanXOrigin = canvasPtr->xOrigin;
 	    canvasPtr->scanY = y;
 	    canvasPtr->scanYOrigin = canvasPtr->yOrigin;
 	} else {
@@ -2381,11 +2381,11 @@
     canvasPtr->scrollX1 = 0;
     canvasPtr->scrollY1 = 0;
     canvasPtr->scrollX2 = 0;
     canvasPtr->scrollY2 = 0;
     if (canvasPtr->regionString != NULL) {
-	int argc2;
+	TkSizeT argc2;
 	const char **argv2;
 
 	if (Tcl_SplitList(canvasPtr->interp, canvasPtr->regionString,
 		&argc2, &argv2) != TCL_OK) {
 	    return TCL_ERROR;
@@ -2463,11 +2463,11 @@
  *----------------------------------------------------------------------
  */
 
 static void
 CanvasWorldChanged(
-    ClientData instanceData)	/* Information about widget. */
+    void *instanceData)	/* Information about widget. */
 {
     TkCanvas *canvasPtr = (TkCanvas *)instanceData;
     Tk_Item *itemPtr;
 
     itemPtr = canvasPtr->firstItemPtr;
@@ -2573,11 +2573,11 @@
 #define BYTE_SWAP32(n) (((n>>24)&0x000000FF) | ((n<<8)&0x00FF0000) | ((n>>8)&0x0000FF00) | ((n<<24)&0xFF000000))
 
 static int
 DrawCanvas(
     Tcl_Interp *interp,           /* As passed to the widget command, and we will leave errors here */
-    ClientData clientData,
+    void *clientData,
     Tk_PhotoHandle photohandle,   /* The photo we are rendering into */
     int subsample,                /* If either subsample or zoom are not 1 then we call Tk_PhotoPutZoomedBlock() */
     int zoom)
 {
     TkCanvas *canvasPtr = (TkCanvas *)clientData;
@@ -2806,14 +2806,23 @@
 
     blockPtr.width = cWidth;
     blockPtr.height = cHeight;
     blockPtr.pixelSize = 4;
     blockPtr.pitch = blockPtr.pixelSize * blockPtr.width;
+
+#ifdef TK_XGETIMAGE_USES_ABGR32
+    blockPtr.offset[0] = 1;
+    blockPtr.offset[1] = 2;
+    blockPtr.offset[2] = 3;
+    blockPtr.offset[3] = 0;
+#else
     blockPtr.offset[0] = 0;
     blockPtr.offset[1] = 1;
     blockPtr.offset[2] = 2;
     blockPtr.offset[3] = 3;
+#endif
+
     blockPtr.pixelPtr = (unsigned char *)ckalloc(blockPtr.pixelSize * blockPtr.height * blockPtr.width);
 
     /*
      * Now convert the image data pixel by pixel from XImage to 32bit RGBA
      * format suitable for Tk_PhotoPutBlock().
@@ -2846,11 +2855,11 @@
         Tcl_AppendResult(interp, " {", NULL);
 #endif
 
         for(x = 0; x < blockPtr.width; ++x) {
             unsigned int pixel = 0;
-
+	    int pixel_offset = blockPtr.pitch * y + blockPtr.pixelSize * x;
             switch (ximagePtr->bits_per_pixel) {
 
                 /*
                  * Get an 8 bit pixel from the XImage.
                  */
@@ -2899,25 +2908,49 @@
              * If the visual mask was correct there would be no need to
              * swap anything here.
              */
 
 #ifdef _WIN32
-#define   R_OFFSET 2
-#define   B_OFFSET 0
+#define   R_OFFSET blockPtr.offset[2]
+#define   G_OFFSET blockPtr.offset[1]
+#define   B_OFFSET blockPtr.offset[0]
+#define   A_OFFSET blockPtr.offset[3]
+#else
+#define   R_OFFSET blockPtr.offset[0]
+#define   G_OFFSET blockPtr.offset[1]
+#define   B_OFFSET blockPtr.offset[2]
+#define   A_OFFSET blockPtr.offset[3]
+#endif
+#ifdef TK_XGETIMAGE_USES_ABGR32
+#define COPY_PIXEL (ximagePtr->bits_per_pixel == 32)
 #else
-#define   R_OFFSET 0
-#define   B_OFFSET 2
+#define COPY_PIXEL 0
 #endif
-            blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x + R_OFFSET] =
+
+	    if (COPY_PIXEL) {
+		/*
+		 * This platform packs pixels in RGBA byte order, as expected
+		 * by Tk_PhotoPutBlock() so we can just copy the pixel as an int.
+		 */
+		*((unsigned int *) (blockPtr.pixelPtr + pixel_offset)) = pixel;
+	    } else {
+		blockPtr.pixelPtr[pixel_offset + R_OFFSET] =
                     (unsigned char)((pixel & visualPtr->red_mask) >> rshift);
-            blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x +1] =
+		blockPtr.pixelPtr[pixel_offset + G_OFFSET] =
                     (unsigned char)((pixel & visualPtr->green_mask) >> gshift);
-            blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x + B_OFFSET] =
+		blockPtr.pixelPtr[pixel_offset + B_OFFSET] =
                     (unsigned char)((pixel & visualPtr->blue_mask) >> bshift);
-            blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x +3] = 0xFF;
+		blockPtr.pixelPtr[pixel_offset + A_OFFSET] = 0xFF;
+	    }
 
 #ifdef DEBUG_DRAWCANVAS
+	    fprintf(stderr, "Converted pixel %x to %hhx %hhx %hhx %hhx \n",
+		    pixel,
+		    blockPtr.pixelPtr[pixel_offset + 0],
+		    blockPtr.pixelPtr[pixel_offset + 1],
+		    blockPtr.pixelPtr[pixel_offset + 2],
+		    blockPtr.pixelPtr[pixel_offset + 3]);
             {
 		int ix;
                 if (x > 0)
                     Tcl_AppendResult(interp, "-", NULL);
 	        for (ix = 0; ix < 4; ++ix) {
@@ -2995,17 +3028,21 @@
  *----------------------------------------------------------------------
  */
 
 static void
 DisplayCanvas(
-    ClientData clientData)	/* Information about widget. */
+    void *clientData)	/* Information about widget. */
 {
     TkCanvas *canvasPtr = (TkCanvas *)clientData;
     Tk_Window tkwin = canvasPtr->tkwin;
     Tk_Item *itemPtr;
     Pixmap pixmap;
     int screenX1, screenX2, screenY1, screenY2, width, height;
+#ifdef MAC_OSX_TK
+    TkWindow *winPtr;
+    MacDrawable *macWin;
+#endif
 
     if (canvasPtr->tkwin == NULL) {
 	return;
     }
 
@@ -3016,12 +3053,12 @@
 #ifdef MAC_OSX_TK
     /*
      * If drawing is disabled, all we need to do is
      * clear the REDRAW_PENDING flag.
      */
-    TkWindow *winPtr = (TkWindow *)(canvasPtr->tkwin);
-    MacDrawable *macWin = winPtr->privatePtr;
+    winPtr = (TkWindow *)(canvasPtr->tkwin);
+    macWin = winPtr->privatePtr;
     if (macWin && (macWin->flags & TK_DO_NOT_DRAW)){
 	canvasPtr->flags &= ~REDRAW_PENDING;
 	return;
     }
 #endif
@@ -3124,11 +3161,11 @@
 	    Tk_Depth(tkwin));
 #else
 	canvasPtr->drawableXOrigin = canvasPtr->xOrigin;
 	canvasPtr->drawableYOrigin = canvasPtr->yOrigin;
 	pixmap = Tk_WindowId(tkwin);
-	TkpClipDrawableToRect(Tk_Display(tkwin), pixmap,
+	Tk_ClipDrawableToRect(Tk_Display(tkwin), pixmap,
 		screenX1 - canvasPtr->xOrigin, screenY1 - canvasPtr->yOrigin,
 		width, height);
 #endif /* TK_NO_DOUBLE_BUFFERING */
 
 	/*
@@ -3183,11 +3220,11 @@
 		screenY1 - canvasPtr->drawableYOrigin,
 		(unsigned int) width, (unsigned int) height,
 		screenX1 - canvasPtr->xOrigin, screenY1 - canvasPtr->yOrigin);
 	Tk_FreePixmap(Tk_Display(tkwin), pixmap);
 #else
-	TkpClipDrawableToRect(Tk_Display(tkwin), pixmap, 0, 0, -1, -1);
+	Tk_ClipDrawableToRect(Tk_Display(tkwin), pixmap, 0, 0, -1, -1);
 #endif /* TK_NO_DOUBLE_BUFFERING */
     }
 
     /*
      * Draw the window borders, if needed.
@@ -3210,14 +3247,14 @@
 	    bgGC = Tk_GCForColor(canvasPtr->highlightBgColorPtr,
 		    Tk_WindowId(tkwin));
 	    if (canvasPtr->textInfo.gotFocus) {
 		fgGC = Tk_GCForColor(canvasPtr->highlightColorPtr,
 			Tk_WindowId(tkwin));
-	    	TkpDrawHighlightBorder(tkwin, fgGC, bgGC,
+	    	Tk_DrawHighlightBorder(tkwin, fgGC, bgGC,
 			canvasPtr->highlightWidth, Tk_WindowId(tkwin));
 	    } else {
-	    	TkpDrawHighlightBorder(tkwin, bgGC, bgGC,
+	    	Tk_DrawHighlightBorder(tkwin, bgGC, bgGC,
 			canvasPtr->highlightWidth, Tk_WindowId(tkwin));
 	    }
 	}
     }
 
@@ -3248,11 +3285,11 @@
  *----------------------------------------------------------------------
  */
 
 static void
 CanvasEventProc(
-    ClientData clientData,	/* Information about window. */
+    void *clientData,	/* Information about window. */
     XEvent *eventPtr)		/* Information about event. */
 {
     TkCanvas *canvasPtr = (TkCanvas *)clientData;
 
     if (eventPtr->type == Expose) {
@@ -3339,11 +3376,11 @@
  *----------------------------------------------------------------------
  */
 
 static void
 CanvasCmdDeletedProc(
-    ClientData clientData)	/* Pointer to widget record for widget. */
+    void *clientData)	/* Pointer to widget record for widget. */
 {
     TkCanvas *canvasPtr = (TkCanvas *)clientData;
     Tk_Window tkwin = canvasPtr->tkwin;
 
     /*
@@ -4593,11 +4630,11 @@
     if (itemPtr->tagSpace == itemPtr->numTags) {
 	Tk_Uid *newTagPtr;
 
 	itemPtr->tagSpace += 5;
 	newTagPtr = (Tk_Uid *)ckalloc(itemPtr->tagSpace * sizeof(Tk_Uid));
-	memcpy((void *) newTagPtr, itemPtr->tagPtr,
+	memcpy(newTagPtr, itemPtr->tagPtr,
 		itemPtr->numTags * sizeof(Tk_Uid));
 	if (itemPtr->tagPtr != itemPtr->staticTagSpace) {
 	    ckfree(itemPtr->tagPtr);
 	}
 	itemPtr->tagPtr = newTagPtr;
@@ -5074,11 +5111,11 @@
  *--------------------------------------------------------------
  */
 
 static void
 CanvasBindProc(
-    ClientData clientData,	/* Pointer to canvas structure. */
+    void *clientData,	/* Pointer to canvas structure. */
     XEvent *eventPtr)		/* Pointer to X event that just happened. */
 {
     TkCanvas *canvasPtr = (TkCanvas *)clientData;
     unsigned mask;
 
@@ -5275,11 +5312,11 @@
     if ((canvasPtr->newCurrentPtr != canvasPtr->currentItemPtr)
 	    && (canvasPtr->currentItemPtr != NULL)
 	    && !(canvasPtr->flags & LEFT_GRABBED_ITEM)) {
 	XEvent event;
 	Tk_Item *itemPtr = canvasPtr->currentItemPtr;
-	int i;
+	TkSizeT i;
 
 	event = canvasPtr->pickEvent;
 	event.type = LeaveNotify;
 
 	/*
@@ -5297,11 +5334,11 @@
 	 * The check below is needed because there could be an event handler
 	 * for <LeaveNotify> that deletes the current item.
 	 */
 
 	if ((itemPtr == canvasPtr->currentItemPtr) && !buttonDown) {
-	    for (i = (int)itemPtr->numTags-1; i >= 0; i--) {
+	    for (i = itemPtr->numTags-1; i != TCL_INDEX_NONE; i--) {
 		if (itemPtr->tagPtr[i] == searchUids->currentUid)
 		    /* then */ {
                     memmove((void *)(itemPtr->tagPtr + i),
                             itemPtr->tagPtr + i + 1,
                             (itemPtr->numTags - (i+1)) * sizeof(Tk_Uid));
@@ -5433,11 +5470,11 @@
 				 * processed. */
 {
 #define NUM_STATIC 3
     void *staticObjects[NUM_STATIC];
     void **objectPtr;
-    int numObjects, i;
+    TkSizeT numObjects, i;
     Tk_Item *itemPtr;
     TagSearchExpr *expr;
     int numExprs;
     SearchUids *searchUids = GetStaticUids();
 
@@ -5485,11 +5522,11 @@
 	objectPtr = staticObjects;
     } else {
 	objectPtr = (void **)ckalloc(numObjects * sizeof(void *));
     }
     objectPtr[0] = (char *)searchUids->allUid;
-    for (i = (int)itemPtr->numTags - 1; i >= 0; i--) {
+    for (i = itemPtr->numTags - 1; i != TCL_INDEX_NONE; i--) {
 	objectPtr[i+1] = (char *)itemPtr->tagPtr[i];
     }
     objectPtr[itemPtr->numTags + 1] = itemPtr;
 
     /*
@@ -5537,11 +5574,11 @@
  *----------------------------------------------------------------------
  */
 
 static void
 CanvasBlinkProc(
-    ClientData clientData)	/* Pointer to record describing entry. */
+    void *clientData)	/* Pointer to record describing entry. */
 {
     TkCanvas *canvasPtr = (TkCanvas *)clientData;
 
     if (!canvasPtr->textInfo.gotFocus || (canvasPtr->insertOffTime == 0)) {
 	return;
@@ -5687,11 +5724,11 @@
  *--------------------------------------------------------------
  */
 
 static TkSizeT
 CanvasFetchSelection(
-    ClientData clientData,	/* Information about canvas widget. */
+    void *clientData,	/* Information about canvas widget. */
     TkSizeT offset,			/* Offset within selection of first character
 				 * to be returned. */
     char *buffer,		/* Location in which to place selection. */
     TkSizeT maxBytes)		/* Maximum number of bytes to place at buffer,
 				 * not including terminating NULL
@@ -5721,11 +5758,11 @@
  *----------------------------------------------------------------------
  */
 
 static void
 CanvasLostSelection(
-    ClientData clientData)	/* Information about entry widget. */
+    void *clientData)	/* Information about entry widget. */
 {
     TkCanvas *canvasPtr = (TkCanvas *)clientData;
 
     EventuallyRedrawItem(canvasPtr, canvasPtr->textInfo.selItemPtr);
     canvasPtr->textInfo.selItemPtr = NULL;

Index: generic/tkCanvas.h
==================================================================
--- generic/tkCanvas.h
+++ generic/tkCanvas.h
@@ -1,13 +1,13 @@
 /*
  * tkCanvas.h --
  *
  *	Declarations shared among all the files that implement canvas widgets.
  *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 Sun Microsystems, Inc.
- * Copyright (c) 1998 by Scriptics Corporation.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 1994-1995 Sun Microsystems, Inc.
+ * Copyright © 1998 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkClipboard.c
==================================================================
--- generic/tkClipboard.c
+++ generic/tkClipboard.c
@@ -3,12 +3,12 @@
  *
  * 	This file manages the clipboard for the Tk toolkit, maintaining a
  * 	collection of data buffers that will be supplied on demand to
  * 	requesting applications.
  *
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -452,11 +452,11 @@
 	enum appendOptions { APPEND_DISPLAYOF, APPEND_FORMAT, APPEND_TYPE };
 	int subIndex;
 	TkSizeT length;
 
 	for (i = 2; i < objc - 1; i++) {
-	    string = TkGetStringFromObj(objv[i], &length);
+	    string = Tcl_GetStringFromObj(objv[i], &length);
 	    if (string[0] != '-') {
 		break;
 	    }
 
 	    /*
@@ -707,11 +707,17 @@
 				 * selection. */
     TCL_UNUSED(Tcl_Interp *),		/* Interpreter used for error reporting (not
 				 * used). */
     const char *portion)	/* New information to be appended. */
 {
-    Tcl_DStringAppend((Tcl_DString *)clientData, portion, -1);
+    Tcl_Encoding utf8 = Tcl_GetEncoding(NULL, "utf-8");
+    Tcl_DString ds;
+
+    (void)Tcl_ExternalToUtfDStringEx(utf8, portion, -1, TCL_ENCODING_NOCOMPLAIN, &ds);
+    Tcl_DStringAppend((Tcl_DString *) clientData, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
+    Tcl_DStringFree(&ds);
+    Tcl_FreeEncoding(utf8);
     return TCL_OK;
 }
 
 /*
  * Local Variables:

Index: generic/tkCmds.c
==================================================================
--- generic/tkCmds.c
+++ generic/tkCmds.c
@@ -2,13 +2,13 @@
  * tkCmds.c --
  *
  *	This file contains a collection of Tk-related Tcl commands that didn't
  *	fit in any particular file of the toolkit.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 2000 Scriptics Corporation.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2000 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -58,18 +58,18 @@
 /*
  * Table of tk subcommand names and implementations.
  */
 
 static const TkEnsemble tkCmdMap[] = {
+    {"fontchooser",	NULL, tkFontchooserEnsemble},
     {"appname",		AppnameCmd, NULL },
     {"busy",		Tk_BusyObjCmd, NULL },
     {"caret",		CaretCmd, NULL },
     {"inactive",	InactiveCmd, NULL },
     {"scaling",		ScalingCmd, NULL },
     {"useinputmethods",	UseinputmethodsCmd, NULL },
     {"windowingsystem",	WindowingsystemCmd, NULL },
-    {"fontchooser",	NULL, tkFontchooserEnsemble},
     {NULL, NULL, NULL}
 };
 
 /*
  *----------------------------------------------------------------------
@@ -183,14 +183,14 @@
     if (string[0] == '.') {
 	winPtr = (TkWindow *) Tk_NameToWindow(interp, string, tkwin);
 	if (winPtr == NULL) {
 	    return TCL_ERROR;
 	}
-	object = (ClientData) winPtr->pathName;
+	object = winPtr->pathName;
     } else {
 	winPtr = (TkWindow *)clientData;
-	object = (ClientData) Tk_GetUid(string);
+	object = (void *) Tk_GetUid(string);
     }
 
     /*
      * If there are four arguments, the command is modifying a binding. If
      * there are three arguments, the command is querying a binding. If there
@@ -265,14 +265,14 @@
 TkBindEventProc(
     TkWindow *winPtr,		/* Pointer to info about window. */
     XEvent *eventPtr)		/* Information about event. */
 {
 #define MAX_OBJS 20
-    ClientData objects[MAX_OBJS], *objPtr;
+    void *objects[MAX_OBJS], **objPtr;
     TkWindow *topLevPtr;
-    int i, count;
-    const char *p;
+    TkSizeT i, count;
+    char *p;
     Tcl_HashEntry *hPtr;
 
     if ((winPtr->mainPtr == NULL) || (winPtr->mainPtr->bindingTable == NULL)) {
 	return;
     }
@@ -286,37 +286,37 @@
 
 	if (winPtr->numTags > MAX_OBJS) {
 	    objPtr = (void **)ckalloc(winPtr->numTags * sizeof(void *));
 	}
 	for (i = 0; i < winPtr->numTags; i++) {
-	    p = (const char *)winPtr->tagPtr[i];
+	    p = (char *)winPtr->tagPtr[i];
 	    if (*p == '.') {
 		hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->nameTable, p);
 		if (hPtr != NULL) {
 		    p = ((TkWindow *) Tcl_GetHashValue(hPtr))->pathName;
 		} else {
 		    p = NULL;
 		}
 	    }
-	    objPtr[i] = (ClientData) p;
+	    objPtr[i] = p;
 	}
 	count = winPtr->numTags;
     } else {
-	objPtr[0] = (ClientData) winPtr->pathName;
-	objPtr[1] = (ClientData) winPtr->classUid;
+	objPtr[0] = winPtr->pathName;
+	objPtr[1] = (void *)winPtr->classUid;
 	for (topLevPtr = winPtr;
 		(topLevPtr != NULL) && !(topLevPtr->flags & TK_TOP_HIERARCHY);
 		topLevPtr = topLevPtr->parentPtr) {
 	    /* Empty loop body. */
 	}
 	if ((winPtr != topLevPtr) && (topLevPtr != NULL)) {
 	    count = 4;
-	    objPtr[2] = (ClientData) topLevPtr->pathName;
+	    objPtr[2] = topLevPtr->pathName;
 	} else {
 	    count = 3;
 	}
-	objPtr[count-1] = (ClientData) Tk_GetUid("all");
+	objPtr[count-1] = (void *) Tk_GetUid("all");
     }
     Tk_BindEvent(winPtr->mainPtr->bindingTable, eventPtr, (Tk_Window) winPtr,
 	    count, objPtr);
     if (objPtr != objects) {
 	ckfree(objPtr);
@@ -347,11 +347,11 @@
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     Tk_Window tkwin = (Tk_Window)clientData;
     TkWindow *winPtr, *winPtr2;
-    int i, length;
+    TkSizeT i, length;
     const char *p;
     Tcl_Obj *listPtr, **tags;
 
     if ((objc < 2) || (objc > 3)) {
 	Tcl_WrongNumArgs(interp, 1, objv, "window ?taglist?");
@@ -398,11 +398,11 @@
 	return TCL_OK;
     }
 
     winPtr->numTags = length;
     winPtr->tagPtr = (void **)ckalloc(length * sizeof(void *));
-    for (i = 0; i < length; i++) {
+    for (i = 0; i < (TkSizeT)length; i++) {
 	p = Tcl_GetString(tags[i]);
 	if (p[0] == '.') {
 	    char *copy;
 
 	    /*
@@ -412,13 +412,13 @@
 	     * is one.
 	     */
 
 	    copy = (char *)ckalloc(strlen(p) + 1);
 	    strcpy(copy, p);
-	    winPtr->tagPtr[i] = (ClientData) copy;
+	    winPtr->tagPtr[i] = copy;
 	} else {
-	    winPtr->tagPtr[i] = (ClientData) Tk_GetUid(p);
+	    winPtr->tagPtr[i] = (void *)Tk_GetUid(p);
 	}
     }
     return TCL_OK;
 }
 
@@ -442,11 +442,11 @@
 
 void
 TkFreeBindingTags(
     TkWindow *winPtr)		/* Window whose tags are to be released. */
 {
-    int i;
+    TkSizeT i;
     const char *p;
 
     for (i = 0; i < winPtr->numTags; i++) {
 	p = (const char *)winPtr->tagPtr[i];
 	if (*p == '.') {
@@ -647,13 +647,17 @@
 int
 TkInitTkCmd(
     Tcl_Interp *interp,
     ClientData clientData)
 {
-    TkMakeEnsemble(interp, "::", "tk", clientData, tkCmdMap);
+    /* If the interp is safe, leave out "fontchooser" */
+    int isSafe = Tcl_IsSafe(interp);
+    TkMakeEnsemble(interp, "::", "tk", clientData, tkCmdMap + isSafe);
 #if defined(_WIN32) || defined(MAC_OSX_TK)
-    TkInitFontchooser(interp, clientData);
+    if (!isSafe) {
+	TkInitFontchooser(interp, clientData);
+    }
 #endif
     return TCL_OK;
 }
 
 /*
@@ -1111,18 +1115,20 @@
 }
 
 static char *
 WaitVariableProc(
     ClientData clientData,	/* Pointer to integer to set to 1. */
-    TCL_UNUSED(Tcl_Interp *),		/* Interpreter containing variable. */
-    TCL_UNUSED(const char *),		/* Name of variable. */
+    Tcl_Interp *interp,		/* Interpreter containing variable. */
+    const char *name1,		/* Name of variable. */
     TCL_UNUSED(const char *),		/* Second part of variable name. */
     TCL_UNUSED(int))			/* Information about what happened. */
 {
     int *donePtr = (int *)clientData;
 
     *donePtr = 1;
+    Tcl_UntraceVar(interp, name1, TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+	    WaitVariableProc, clientData);
     return NULL;
 }
 
 static void
 WaitVisibilityProc(
@@ -1860,11 +1866,11 @@
     TkSizeT length;
 
     if (objc < 1) {
 	return 0;
     }
-    string = TkGetStringFromObj(objv[0], &length);
+    string = Tcl_GetStringFromObj(objv[0], &length);
     if ((length >= 2) &&
 	    (strncmp(string, "-displayof", length) == 0)) {
         if (objc < 2) {
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
 		    "value for \"-displayof\" missing", -1));

Index: generic/tkColor.c
==================================================================
--- generic/tkColor.c
+++ generic/tkColor.c
@@ -3,12 +3,12 @@
  *
  *	This file maintains a database of color values for the Tk toolkit, in
  *	order to avoid round-trips to the server to map color names to pixel
  *	values.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkColor.h
==================================================================
--- generic/tkColor.h
+++ generic/tkColor.h
@@ -1,11 +1,11 @@
 /*
  * tkColor.h --
  *
  *	Declarations of data types and functions used by the Tk color module.
  *
- * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkConfig.c
==================================================================
--- generic/tkConfig.c
+++ generic/tkConfig.c
@@ -2,11 +2,11 @@
  * tkConfig.c --
  *
  *	This file contains functions that manage configuration options for
  *	widgets and other things.
  *
- * Copyright (c) 1997-1998 Sun Microsystems, Inc.
+ * Copyright © 1997-1998 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -24,10 +24,20 @@
 #endif
 
 #include "tkInt.h"
 #include "tkFont.h"
 
+/*
+ * The following encoding is used in TYPE_FLAGS:
+ *
+ * if sizeof(type) == sizeof(int)     =>    TYPE_FLAGS(type) = 0
+ * if sizeof(type) == 1               =>    TYPE_FLAGS(type) = 64
+ * if sizeof(type) == 2               =>    TYPE_FLAGS(type) = 128
+ */
+#define TYPE_FLAGS(type) (((int)(sizeof(type)&(sizeof(int)-1))<<6))
+#define TYPE_MASK        (((((int)sizeof(int)-1))|3)<<6)
+
 /*
  * The following definition keeps track of all of
  * the option tables that have been created for a thread.
  */
 
@@ -453,11 +463,11 @@
 	 * Second, check for a system-specific default value.
 	 */
 
 	if ((valuePtr == NULL)
 		&& (optionPtr->dbNameUID != NULL)) {
-	    valuePtr = TkpGetSystemDefault(tkwin, optionPtr->dbNameUID,
+	    valuePtr = Tk_GetSystemDefault(tkwin, optionPtr->dbNameUID,
 		    optionPtr->dbClassUID);
 	    if (valuePtr != NULL) {
 		source = SYSTEM_DEFAULT;
 	    }
 	}
@@ -607,16 +617,23 @@
 	savedOptionPtr->valuePtr = oldPtr;
 	oldInternalPtr = (char *) &savedOptionPtr->internalForm;
     } else {
 	oldInternalPtr = (char *) &internal.internalForm;
     }
-    nullOK = (optionPtr->specPtr->flags & TK_OPTION_NULL_OK);
+    nullOK = (optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_INDEX_NULL_OK));
     switch (optionPtr->specPtr->type) {
     case TK_OPTION_BOOLEAN: {
 	int newBool;
 
-	if (Tcl_GetBooleanFromObj(interp, valuePtr, &newBool) != TCL_OK) {
+	if (nullOK && ObjectIsEmpty(valuePtr)) {
+	    valuePtr = NULL;
+	    newBool = -1;
+	} else if (Tcl_GetBooleanFromObj(nullOK ? NULL : interp, valuePtr, &newBool) != TCL_OK) {
+	    if (nullOK && interp) {
+		Tcl_AppendResult(interp, "expected boolean value or \"\" but got \"",
+			Tcl_GetString(valuePtr), "\"", NULL);
+	    }
 	    return TCL_ERROR;
 	}
 	if (internalPtr != NULL) {
 	    *((int *) oldInternalPtr) = *((int *) internalPtr);
 	    *((int *) internalPtr) = newBool;
@@ -624,27 +641,71 @@
 	break;
     }
     case TK_OPTION_INT: {
 	int newInt;
 
-	if (Tcl_GetIntFromObj(interp, valuePtr, &newInt) != TCL_OK) {
+	if (nullOK && ObjectIsEmpty(valuePtr)) {
+	    valuePtr = NULL;
+	    newInt = INT_MIN;
+	} else if (Tcl_GetIntFromObj(nullOK ? NULL : interp, valuePtr, &newInt) != TCL_OK) {
+		if (nullOK && interp) {
+		    Tcl_Obj *msg = Tcl_NewStringObj("expected integer or \"\" but got \"", -1);
+
+		    Tcl_AppendLimitedToObj(msg, Tcl_GetString(valuePtr), -1, 50, "");
+		    Tcl_AppendToObj(msg, "\"", -1);
+		    Tcl_SetObjResult(interp, msg);
+		    Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", NULL);
+		}
 	    return TCL_ERROR;
 	}
 	if (internalPtr != NULL) {
 	    *((int *) oldInternalPtr) = *((int *) internalPtr);
 	    *((int *) internalPtr) = newInt;
 	}
+	break;
+    }
+    case TK_OPTION_INDEX: {
+	TkSizeT newIndex;
+
+	if (TkGetIntForIndex(valuePtr, TCL_INDEX_END, 0, &newIndex) != TCL_OK) {
+	    if (interp) {
+		Tcl_AppendResult(interp, "bad index \"", Tcl_GetString(valuePtr),
+			"\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"", NULL);
+	    }
+	    return TCL_ERROR;
+	}
+    if (newIndex == TCL_INDEX_NONE) {
+	newIndex = (TkSizeT)INT_MIN;
+    } else if ((size_t)newIndex > (size_t)TCL_INDEX_END>>1) {
+	newIndex++;
+    }
+	if (internalPtr != NULL) {
+	    *((int *) oldInternalPtr) = *((int *) internalPtr);
+	    *((int *) internalPtr) = (int)newIndex;
+	}
 	break;
     }
     case TK_OPTION_DOUBLE: {
 	double newDbl;
 
 	if (nullOK && ObjectIsEmpty(valuePtr)) {
 	    valuePtr = NULL;
-	    newDbl = 0;
+#if defined(NAN)
+	    newDbl = NAN;
+#else
+	    newDbl = 0.0;
+#endif
 	} else {
-	    if (Tcl_GetDoubleFromObj(interp, valuePtr, &newDbl) != TCL_OK) {
+	    if (Tcl_GetDoubleFromObj(nullOK ? NULL : interp, valuePtr, &newDbl) != TCL_OK) {
+		if (nullOK && interp) {
+		    Tcl_Obj *msg = Tcl_NewStringObj("expected floating-point number or \"\" but got \"", -1);
+
+		    Tcl_AppendLimitedToObj(msg, Tcl_GetString(valuePtr), -1, 50, "");
+		    Tcl_AppendToObj(msg, "\"", -1);
+		    Tcl_SetObjResult(interp, msg);
+		    Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", NULL);
+		}
 		return TCL_ERROR;
 	    }
 	}
 
 	if (internalPtr != NULL) {
@@ -661,11 +722,11 @@
 	if (nullOK && ObjectIsEmpty(valuePtr)) {
 	    valuePtr = NULL;
 	}
 	if (internalPtr != NULL) {
 	    if (valuePtr != NULL) {
-		value = TkGetStringFromObj(valuePtr, &length);
+		value = Tcl_GetStringFromObj(valuePtr, &length);
 		newStr = (char *)ckalloc(length + 1);
 		strcpy(newStr, value);
 	    } else {
 		newStr = NULL;
 	    }
@@ -677,21 +738,33 @@
     case TK_OPTION_STRING_TABLE: {
 	int newValue;
 
 	if (nullOK && ObjectIsEmpty(valuePtr)) {
 	    valuePtr = NULL;
-            newValue = -1;
-        } else {
+	    newValue = -1;
+	} else {
 	    if (Tcl_GetIndexFromObjStruct(interp, valuePtr,
 		    optionPtr->specPtr->clientData, sizeof(char *),
-		    optionPtr->specPtr->optionName+1, 0, &newValue) != TCL_OK) {
-	        return TCL_ERROR;
+		    optionPtr->specPtr->optionName+1, (nullOK ? TCL_INDEX_NULL_OK : 0), &newValue) != TCL_OK) {
+		return TCL_ERROR;
 	    }
-        }
+	}
 	if (internalPtr != NULL) {
-	    *((int *) oldInternalPtr) = *((int *) internalPtr);
-	    *((int *) internalPtr) = newValue;
+	    if (optionPtr->specPtr->flags & TYPE_MASK) {
+		if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(char)) {
+		    *((char *) oldInternalPtr) = *((char *) internalPtr);
+		    *((char *) internalPtr) = newValue;
+		} else if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(short)) {
+		    *((short *) oldInternalPtr) = *((short *) internalPtr);
+		    *((short *) internalPtr) = newValue;
+		} else {
+		    Tcl_Panic("Invalid flags for %s", "TK_OPTION_STRING_TABLE");
+		}
+	    } else {
+		*((int *) oldInternalPtr) = *((int *) internalPtr);
+		*((int *) internalPtr) = newValue;
+	    }
 	}
 	break;
     }
     case TK_OPTION_COLOR: {
 	XColor *newPtr;
@@ -787,14 +860,13 @@
 	int newRelief;
 
 	if (nullOK && ObjectIsEmpty(valuePtr)) {
 	    valuePtr = NULL;
 	    newRelief = TK_RELIEF_NULL;
-	} else {
-	    if (Tk_GetReliefFromObj(interp, valuePtr, &newRelief) != TCL_OK) {
-		return TCL_ERROR;
-	    }
+	} else if (Tcl_GetIndexFromObj(interp, valuePtr, tkReliefStrings,
+		"relief", (nullOK ? TCL_INDEX_NULL_OK : 0), &newRelief) != TCL_OK) {
+	    return TCL_ERROR;
 	}
 	if (internalPtr != NULL) {
 	    *((int *) oldInternalPtr) = *((int *) internalPtr);
 	    *((int *) internalPtr) = newRelief;
 	}
@@ -818,44 +890,50 @@
 	}
 	Tk_DefineCursor(tkwin, newCursor);
 	break;
     }
     case TK_OPTION_JUSTIFY: {
-	Tk_Justify newJustify;
+	int newJustify;
 
-	if (Tk_GetJustifyFromObj(interp, valuePtr, &newJustify) != TCL_OK) {
+	if (nullOK && ObjectIsEmpty(valuePtr)) {
+	    valuePtr = NULL;
+	    newJustify = -1;
+	} else if (Tcl_GetIndexFromObj(interp, valuePtr, tkJustifyStrings,
+		"justification", (nullOK ? TCL_INDEX_NULL_OK : 0), &newJustify) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 	if (internalPtr != NULL) {
 	    *((Tk_Justify *) oldInternalPtr) = *((Tk_Justify *) internalPtr);
-	    *((Tk_Justify *) internalPtr) = newJustify;
+	    *((Tk_Justify *) internalPtr) = (Tk_Justify)newJustify;
 	}
 	break;
     }
     case TK_OPTION_ANCHOR: {
-	Tk_Anchor newAnchor;
+	int newAnchor;
 
-	if (Tk_GetAnchorFromObj(interp, valuePtr, &newAnchor) != TCL_OK) {
+	if (nullOK && ObjectIsEmpty(valuePtr)) {
+	    valuePtr = NULL;
+	    newAnchor = -1;
+	} else if (Tcl_GetIndexFromObj(interp, valuePtr, tkAnchorStrings,
+		"anchor", (nullOK ? TCL_INDEX_NULL_OK : 0), &newAnchor) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 	if (internalPtr != NULL) {
 	    *((Tk_Anchor *) oldInternalPtr) = *((Tk_Anchor *) internalPtr);
-	    *((Tk_Anchor *) internalPtr) = newAnchor;
+	    *((Tk_Anchor *) internalPtr) = (Tk_Anchor)newAnchor;
 	}
 	break;
     }
     case TK_OPTION_PIXELS: {
 	int newPixels;
 
 	if (nullOK && ObjectIsEmpty(valuePtr)) {
 	    valuePtr = NULL;
-	    newPixels = 0;
-	} else {
-	    if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr,
-		    &newPixels) != TCL_OK) {
-		return TCL_ERROR;
-	    }
+	    newPixels = INT_MIN;
+	} else if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr,
+		&newPixels) != TCL_OK) {
+	    return TCL_ERROR;
 	}
 	if (internalPtr != NULL) {
 	    *((int *) oldInternalPtr) = *((int *) internalPtr);
 	    *((int *) internalPtr) = newPixels;
 	}
@@ -865,15 +943,13 @@
 	Tk_Window newWin;
 
 	if (nullOK && ObjectIsEmpty(valuePtr)) {
 	    valuePtr = NULL;
 	    newWin = NULL;
-	} else {
-	    if (TkGetWindowFromObj(interp, tkwin, valuePtr,
-		    &newWin) != TCL_OK) {
-		return TCL_ERROR;
-	    }
+	} else if (TkGetWindowFromObj(interp, tkwin, valuePtr,
+		&newWin) != TCL_OK) {
+	    return TCL_ERROR;
 	}
 	if (internalPtr != NULL) {
 	    *((Tk_Window *) oldInternalPtr) = *((Tk_Window *) internalPtr);
 	    *((Tk_Window *) internalPtr) = newWin;
 	}
@@ -1404,20 +1480,31 @@
 
 	    CLANG_ASSERT(internalPtr);
 	    switch (specPtr->type) {
 	    case TK_OPTION_BOOLEAN:
 	    case TK_OPTION_INT:
+	    case TK_OPTION_INDEX:
 		*((int *) internalPtr) = *((int *) ptr);
 		break;
 	    case TK_OPTION_DOUBLE:
 		*((double *) internalPtr) = *((double *) ptr);
 		break;
 	    case TK_OPTION_STRING:
 		*((char **) internalPtr) = *((char **) ptr);
 		break;
 	    case TK_OPTION_STRING_TABLE:
-		*((int *) internalPtr) = *((int *) ptr);
+		if (optionPtr->specPtr->flags & TYPE_MASK) {
+		    if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(char)) {
+			*((char *) internalPtr) = *((char *) ptr);
+		    } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(short)) {
+			*((short *) internalPtr) = *((short *) ptr);
+		    } else {
+			Tcl_Panic("Invalid flags for %s", "TK_OPTION_STRING_TABLE");
+		    }
+		} else {
+		    *((int *) internalPtr) = *((int *) ptr);
+		}
 		break;
 	    case TK_OPTION_COLOR:
 		*((XColor **) internalPtr) = *((XColor **) ptr);
 		break;
 	    case TK_OPTION_FONT:
@@ -1865,32 +1952,68 @@
     Option *optionPtr,		/* Pointer to information describing an option
 				 * whose internal value is stored in
 				 * *recordPtr. */
     Tk_Window tkwin)		/* Window corresponding to recordPtr. */
 {
-    Tcl_Obj *objPtr;
-    void *internalPtr;		/* Points to internal value of option in
-				 * record. */
+    Tcl_Obj *objPtr = NULL;
+    void *internalPtr;		/* Points to internal value of option in record. */
 
-    objPtr = NULL;
     if (optionPtr->specPtr->internalOffset != TCL_INDEX_NONE) {
 	internalPtr = (char *)recordPtr + optionPtr->specPtr->internalOffset;
 	switch (optionPtr->specPtr->type) {
 	case TK_OPTION_BOOLEAN:
+	    if (*((int *) internalPtr) != -1) {
+		objPtr = Tcl_NewBooleanObj(*((int *)internalPtr));
+	    }
+	    break;
 	case TK_OPTION_INT:
-	    objPtr = Tcl_NewWideIntObj(*((int *)internalPtr));
+	    if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_INDEX_NULL_OK)) || *((int *) internalPtr) != INT_MIN) {
+		objPtr = Tcl_NewWideIntObj(*((int *)internalPtr));
+	    }
+	    break;
+	case TK_OPTION_INDEX:
+	    if (*((int *) internalPtr) == INT_MIN) {
+		objPtr = TkNewIndexObj(TCL_INDEX_NONE);
+	    } else if (*((int *) internalPtr) == INT_MAX) {
+		objPtr = Tcl_NewStringObj("end+1", -1);
+	    } else if (*((int *) internalPtr) == -1) {
+		objPtr = Tcl_NewStringObj("end", -1);
+	    } else if (*((int *) internalPtr) < 0) {
+		char buf[32];
+		sprintf(buf, "end%d", *((int *) internalPtr));
+		objPtr = Tcl_NewStringObj(buf, -1);
+	    } else {
+		objPtr = Tcl_NewWideIntObj(*((int *) internalPtr));
+	    }
 	    break;
 	case TK_OPTION_DOUBLE:
-	    objPtr = Tcl_NewDoubleObj(*((double *) internalPtr));
+	    if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_INDEX_NULL_OK)) || !isnan(*((double *) internalPtr))) {
+		objPtr = Tcl_NewDoubleObj(*((double *) internalPtr));
+	    }
 	    break;
 	case TK_OPTION_STRING:
 	    objPtr = Tcl_NewStringObj(*((char **)internalPtr), -1);
 	    break;
-	case TK_OPTION_STRING_TABLE:
-	    objPtr = Tcl_NewStringObj(((char **) optionPtr->specPtr->clientData)[
-		    *((int *) internalPtr)], -1);
+	case TK_OPTION_STRING_TABLE: {
+	    int value;
+	    if (optionPtr->specPtr->flags & TYPE_MASK) {
+		if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(char)) {
+		    value = *((signed char *)internalPtr);
+		} else if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(short)) {
+		    value = *((short *)internalPtr);
+		} else {
+		    Tcl_Panic("Invalid flags for %s", "TK_OPTION_STRING_TABLE");
+		}
+	    } else {
+		value = *((int *)internalPtr);
+	    }
+	    if (value >= 0) {
+		objPtr = Tcl_NewStringObj(((char **) optionPtr->specPtr->clientData)[
+			value], -1);
+	    }
 	    break;
+	}
 	case TK_OPTION_COLOR: {
 	    XColor *colorPtr = *((XColor **)internalPtr);
 
 	    if (colorPtr != NULL) {
 		objPtr = Tcl_NewStringObj(Tk_NameOfColor(colorPtr), -1);
@@ -1949,11 +2072,13 @@
 	case TK_OPTION_ANCHOR:
 	    objPtr = Tcl_NewStringObj(Tk_NameOfAnchor(
 		    *((Tk_Anchor *)internalPtr)), -1);
 	    break;
 	case TK_OPTION_PIXELS:
-	    objPtr = Tcl_NewWideIntObj(*((int *)internalPtr));
+	    if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_INDEX_NULL_OK)) || *((int *) internalPtr) != INT_MIN) {
+		objPtr = Tcl_NewWideIntObj(*((int *)internalPtr));
+	    }
 	    break;
 	case TK_OPTION_WINDOW: {
 	    tkwin = *((Tk_Window *) internalPtr);
 
 	    if (tkwin != NULL) {

Index: generic/tkConsole.c
==================================================================
--- generic/tkConsole.c
+++ generic/tkConsole.c
@@ -3,11 +3,11 @@
  *
  *	This file implements a Tcl console for systems that may not otherwise
  *	have access to a console. It uses the Text widget and provides special
  *	access via a console command.
  *
- * Copyright (c) 1995-1996 Sun Microsystems, Inc.
+ * Copyright © 1995-1996 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -515,12 +515,12 @@
 	     * Not checking for utf8 == NULL.  Did not check for TCL_ERROR
 	     * from Tcl_SetChannelOption() in Tk_InitConsoleChannels() either.
 	     * Assumption is utf-8 Tcl_Encoding is reliably present.
 	     */
 
-	    const char *bytes
-		    = Tcl_ExternalToUtfDString(utf8, buf, toWrite, &ds);
+	    (void)Tcl_ExternalToUtfDStringEx(utf8, buf, toWrite, TCL_ENCODING_NOCOMPLAIN, &ds);
+	    const char *bytes = Tcl_DStringValue(&ds);
 	    int numBytes = Tcl_DStringLength(&ds);
 	    Tcl_Obj *cmd = Tcl_NewStringObj("tk::ConsoleOutput", -1);
 
 	    Tcl_FreeEncoding(utf8);
 

Index: generic/tkCursor.c
==================================================================
--- generic/tkCursor.c
+++ generic/tkCursor.c
@@ -3,12 +3,12 @@
  *
  *	This file maintains a database of read-only cursors for the Tk
  *	toolkit. This allows cursors to be shared between widgets and also
  *	avoids round-trips to the X server.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkDList.h
==================================================================
--- generic/tkDList.h
+++ generic/tkDList.h
@@ -5,11 +5,11 @@
  * are doubly linked so that an arbitrary element can be removed without
  * a need to traverse the list. New elements can be added to the list
  * before or after an existing element or at the head/tail of the list.
  * A list may be traversed in the forward or backward direction.
  *
- * Copyright (c) 2018 by Gregor Cramer.
+ * Copyright © 2018 Gregor Cramer.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkDecls.h
==================================================================
--- generic/tkDecls.h
+++ generic/tkDecls.h
@@ -1,11 +1,11 @@
 /*
  * tkDecls.h --
  *
  *	Declarations of functions in the platform independent public Tcl API.
  *
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright (c) 1998-1999 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -891,10 +891,43 @@
 /* 278 */
 EXTERN void		Tk_SendVirtualEvent(Tk_Window tkwin,
 				const char *eventName, Tcl_Obj *detail);
 /* 279 */
 EXTERN Tcl_Obj *	Tk_FontGetDescription(Tk_Font tkfont);
+/* 280 */
+EXTERN void		Tk_CreatePhotoImageFormatVersion3(
+				const Tk_PhotoImageFormatVersion3 *formatPtr);
+/* 281 */
+EXTERN void		Tk_DrawHighlightBorder(Tk_Window tkwin, GC fgGC,
+				GC bgGC, int highlightWidth,
+				Drawable drawable);
+/* 282 */
+EXTERN void		Tk_SetMainMenubar(Tcl_Interp *interp,
+				Tk_Window tkwin, const char *menuName);
+/* 283 */
+EXTERN void		Tk_SetWindowMenubar(Tcl_Interp *interp,
+				Tk_Window tkwin, const char *oldMenuName,
+				const char *menuName);
+/* 284 */
+EXTERN void		Tk_ClipDrawableToRect(Display *display, Drawable d,
+				int x, int y, int width, int height);
+/* 285 */
+EXTERN Tcl_Obj *	Tk_GetSystemDefault(Tk_Window tkwin,
+				const char *dbName, const char *className);
+/* 286 */
+EXTERN int		Tk_UseWindow(Tcl_Interp *interp, Tk_Window tkwin,
+				const char *string);
+/* 287 */
+EXTERN void		Tk_MakeContainer(Tk_Window tkwin);
+/* 288 */
+EXTERN Tk_Window	Tk_GetOtherWindow(Tk_Window tkwin);
+/* 289 */
+EXTERN void		Tk_Get3DBorderColors(Tk_3DBorder border,
+				XColor *bgColorPtr, XColor *darkColorPtr,
+				XColor *lightColorPtr);
+/* 290 */
+EXTERN Window		Tk_MakeWindow(Tk_Window tkwin, Window parent);
 
 typedef struct {
     const struct TkPlatStubs *tkPlatStubs;
     const struct TkIntStubs *tkIntStubs;
     const struct TkIntPlatStubs *tkIntPlatStubs;
@@ -1183,10 +1216,21 @@
     unsigned (*tk_GetButtonMask) (unsigned button); /* 275 */
     int (*tk_GetDoublePixelsFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, double *doublePtr); /* 276 */
     Tcl_Obj * (*tk_NewWindowObj) (Tk_Window tkwin); /* 277 */
     void (*tk_SendVirtualEvent) (Tk_Window tkwin, const char *eventName, Tcl_Obj *detail); /* 278 */
     Tcl_Obj * (*tk_FontGetDescription) (Tk_Font tkfont); /* 279 */
+    void (*tk_CreatePhotoImageFormatVersion3) (const Tk_PhotoImageFormatVersion3 *formatPtr); /* 280 */
+    void (*tk_DrawHighlightBorder) (Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable); /* 281 */
+    void (*tk_SetMainMenubar) (Tcl_Interp *interp, Tk_Window tkwin, const char *menuName); /* 282 */
+    void (*tk_SetWindowMenubar) (Tcl_Interp *interp, Tk_Window tkwin, const char *oldMenuName, const char *menuName); /* 283 */
+    void (*tk_ClipDrawableToRect) (Display *display, Drawable d, int x, int y, int width, int height); /* 284 */
+    Tcl_Obj * (*tk_GetSystemDefault) (Tk_Window tkwin, const char *dbName, const char *className); /* 285 */
+    int (*tk_UseWindow) (Tcl_Interp *interp, Tk_Window tkwin, const char *string); /* 286 */
+    void (*tk_MakeContainer) (Tk_Window tkwin); /* 287 */
+    Tk_Window (*tk_GetOtherWindow) (Tk_Window tkwin); /* 288 */
+    void (*tk_Get3DBorderColors) (Tk_3DBorder border, XColor *bgColorPtr, XColor *darkColorPtr, XColor *lightColorPtr); /* 289 */
+    Window (*tk_MakeWindow) (Tk_Window tkwin, Window parent); /* 290 */
 } TkStubs;
 
 extern const TkStubs *tkStubsPtr;
 
 #ifdef __cplusplus
@@ -1755,10 +1799,32 @@
 	(tkStubsPtr->tk_NewWindowObj) /* 277 */
 #define Tk_SendVirtualEvent \
 	(tkStubsPtr->tk_SendVirtualEvent) /* 278 */
 #define Tk_FontGetDescription \
 	(tkStubsPtr->tk_FontGetDescription) /* 279 */
+#define Tk_CreatePhotoImageFormatVersion3 \
+	(tkStubsPtr->tk_CreatePhotoImageFormatVersion3) /* 280 */
+#define Tk_DrawHighlightBorder \
+	(tkStubsPtr->tk_DrawHighlightBorder) /* 281 */
+#define Tk_SetMainMenubar \
+	(tkStubsPtr->tk_SetMainMenubar) /* 282 */
+#define Tk_SetWindowMenubar \
+	(tkStubsPtr->tk_SetWindowMenubar) /* 283 */
+#define Tk_ClipDrawableToRect \
+	(tkStubsPtr->tk_ClipDrawableToRect) /* 284 */
+#define Tk_GetSystemDefault \
+	(tkStubsPtr->tk_GetSystemDefault) /* 285 */
+#define Tk_UseWindow \
+	(tkStubsPtr->tk_UseWindow) /* 286 */
+#define Tk_MakeContainer \
+	(tkStubsPtr->tk_MakeContainer) /* 287 */
+#define Tk_GetOtherWindow \
+	(tkStubsPtr->tk_GetOtherWindow) /* 288 */
+#define Tk_Get3DBorderColors \
+	(tkStubsPtr->tk_Get3DBorderColors) /* 289 */
+#define Tk_MakeWindow \
+	(tkStubsPtr->tk_MakeWindow) /* 290 */
 
 #endif /* defined(USE_TK_STUBS) */
 
 /* !END!: Do not edit above this line. */
 
@@ -1773,10 +1839,14 @@
 #undef Tk_GetStyleFromObj
 #undef Tk_FreeStyleFromObj
 #define Tk_GetStyleFromObj(obj) Tk_AllocStyleFromObj(NULL, obj)
 #define Tk_FreeStyleFromObj(obj) /* no-op */
 #define Tk_GetImageMasterData Tk_GetImageModelData
+
+#ifndef MAC_OSX_TK
+#   undef Tk_ClipDrawableToRect
+#endif
 
 #if defined(_WIN32) && defined(UNICODE)
 #   define Tk_MainEx Tk_MainExW
     EXTERN void Tk_MainExW(int argc, wchar_t **argv,
 	    Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
@@ -1793,7 +1863,9 @@
 #undef Tk_CreateOldPhotoImageFormat
 #endif /* TK_NO_DEPRECATED */
 
 #undef TCL_STORAGE_CLASS
 #define TCL_STORAGE_CLASS DLLIMPORT
+
+#undef TkUnusedStubEntry
 
 #endif /* _TKDECLS */

Index: generic/tkEntry.c
==================================================================
--- generic/tkEntry.c
+++ generic/tkEntry.c
@@ -4,14 +4,14 @@
  *	This module implements entry and spinbox widgets for the Tk toolkit.
  *	An entry displays a string and allows the string to be edited. A
  *	spinbox expands on the entry by adding up/down buttons that control
  *	the value of the entry widget.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 2000 Ajuba Solutions.
- * Copyright (c) 2002 ActiveState Corporation.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2000 Ajuba Solutions.
+ * Copyright © 2002 ActiveState Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -75,11 +75,11 @@
 	DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_BORDER, "-disabledbackground", "disabledBackground",
 	"DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, TCL_INDEX_NONE,
 	offsetof(Entry, disabledBorder), TK_OPTION_NULL_OK,
-	(ClientData) DEF_ENTRY_DISABLED_BG_MONO, 0},
+	DEF_ENTRY_DISABLED_BG_MONO, 0},
     {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
 	"DisabledForeground", DEF_ENTRY_DISABLED_FG, TCL_INDEX_NONE,
 	offsetof(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
 	"ExportSelection", DEF_ENTRY_EXPORT_SELECTION, TCL_INDEX_NONE,
@@ -101,11 +101,11 @@
     {TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
 	DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0},
     {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth",
 	"BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE,
 	offsetof(Entry, insertBorderWidth), 0,
-	(ClientData) DEF_ENTRY_INSERT_BD_MONO, 0},
+	DEF_ENTRY_INSERT_BD_MONO, 0},
     {TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime",
 	DEF_ENTRY_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOffTime),
 	0, 0, 0},
     {TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime",
 	DEF_ENTRY_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOnTime), 0, 0, 0},
@@ -120,16 +120,16 @@
 	DEF_ENTRY_JUSTIFY, TCL_INDEX_NONE, offsetof(Entry, justify), 0, 0, 0},
     {TK_OPTION_STRING, "-placeholder", "placeHolder", "PlaceHolder",
 	DEF_ENTRY_PLACEHOLDER, TCL_INDEX_NONE, offsetof(Entry, placeholderString),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_COLOR, "-placeholderforeground", "placeholderForeground",
-        "PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, TCL_INDEX_NONE,
-        offsetof(Entry, placeholderColorPtr), 0, 0, 0},
+	"PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, TCL_INDEX_NONE,
+	offsetof(Entry, placeholderColorPtr), 0, 0, 0},
     {TK_OPTION_BORDER, "-readonlybackground", "readonlyBackground",
 	"ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, TCL_INDEX_NONE,
 	offsetof(Entry, readonlyBorder), TK_OPTION_NULL_OK,
-	(ClientData) DEF_ENTRY_READONLY_BG_MONO, 0},
+	DEF_ENTRY_READONLY_BG_MONO, 0},
     {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
 	DEF_ENTRY_RELIEF, TCL_INDEX_NONE, offsetof(Entry, relief), 0, 0, 0},
     {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
 	DEF_ENTRY_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Entry, selBorder),
 	0, DEF_ENTRY_SELECT_MONO, 0},
@@ -214,11 +214,11 @@
 	DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_BORDER, "-disabledbackground", "disabledBackground",
 	"DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, TCL_INDEX_NONE,
 	offsetof(Entry, disabledBorder), TK_OPTION_NULL_OK,
-	(ClientData) DEF_ENTRY_DISABLED_BG_MONO, 0},
+	DEF_ENTRY_DISABLED_BG_MONO, 0},
     {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
 	"DisabledForeground", DEF_ENTRY_DISABLED_FG, TCL_INDEX_NONE,
 	offsetof(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
 	"ExportSelection", DEF_ENTRY_EXPORT_SELECTION, TCL_INDEX_NONE,
@@ -247,11 +247,11 @@
     {TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
 	DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0},
     {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth",
 	"BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE,
 	offsetof(Entry, insertBorderWidth), 0,
-	(ClientData) DEF_ENTRY_INSERT_BD_MONO, 0},
+	DEF_ENTRY_INSERT_BD_MONO, 0},
     {TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime",
 	DEF_ENTRY_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOffTime),
 	0, 0, 0},
     {TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime",
 	DEF_ENTRY_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOnTime), 0, 0, 0},
@@ -273,11 +273,11 @@
     {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
 	DEF_ENTRY_RELIEF, TCL_INDEX_NONE, offsetof(Entry, relief), 0, 0, 0},
     {TK_OPTION_BORDER, "-readonlybackground", "readonlyBackground",
 	"ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, TCL_INDEX_NONE,
 	offsetof(Entry, readonlyBorder), TK_OPTION_NULL_OK,
-	(ClientData) DEF_ENTRY_READONLY_BG_MONO, 0},
+	DEF_ENTRY_READONLY_BG_MONO, 0},
     {TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
 	DEF_SPINBOX_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(Spinbox, repeatDelay),
 	0, 0, 0},
     {TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
 	DEF_SPINBOX_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(Spinbox, repeatInterval),
@@ -385,11 +385,11 @@
  * This is the string array corresponding to the enum in selelement. If you
  * modify them, you must modify the strings here.
  */
 
 static const char *const selElementNames[] = {
-    "none", "buttondown", "buttonup", NULL, "entry"
+    "buttondown", "buttonup", "none", NULL, "entry"
 };
 
 /*
  * Flags for GetEntryIndex function:
  */
@@ -709,11 +709,11 @@
     case COMMAND_GET:
 	if (objc != 2) {
 	    Tcl_WrongNumArgs(interp, 2, objv, NULL);
 	    goto error;
 	}
-	Tcl_SetObjResult(interp, Tcl_NewStringObj(entryPtr->string, TCL_INDEX_NONE));
+	Tcl_SetObjResult(interp, Tcl_NewStringObj(entryPtr->string, -1));
 	break;
 
     case COMMAND_ICURSOR:
 	if (objc != 3) {
 	    Tcl_WrongNumArgs(interp, 2, objv, "pos");
@@ -782,11 +782,11 @@
 	} else if ((minorCmd[0] == 'd')
 		&& (strncmp(minorCmd, "dragto", strlen(minorCmd)) == 0)) {
 	    EntryScanTo(entryPtr, x);
 	} else {
 	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
-		    "bad scan option \"%s\": must be mark or dragto",
+		    "bad scan option \"%s\": must be dragto or mark",
 		    minorCmd));
 	    Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "scan option",
 		    minorCmd, NULL);
 	    goto error;
 	}
@@ -1259,13 +1259,13 @@
 		    Tcl_DecrRefCount(sbPtr->listObj);
 		}
 		sbPtr->listObj = NULL;
 		if (sbPtr->valueStr != NULL) {
 		    Tcl_Obj *newObjPtr;
-		    int nelems;
+		    TkSizeT nelems;
 
-		    newObjPtr = Tcl_NewStringObj(sbPtr->valueStr, TCL_INDEX_NONE);
+		    newObjPtr = Tcl_NewStringObj(sbPtr->valueStr, -1);
 		    if (Tcl_ListObjLength(interp, newObjPtr, &nelems)
 			    != TCL_OK) {
 			valuesChanged = -1;
 			continue;
 		    }
@@ -1925,13 +1925,13 @@
 	    GC fgGC, bgGC;
 
 	    bgGC = Tk_GCForColor(entryPtr->highlightBgColorPtr, pixmap);
 	    if (entryPtr->flags & GOT_FOCUS) {
 		fgGC = Tk_GCForColor(entryPtr->highlightColorPtr, pixmap);
-		TkpDrawHighlightBorder(tkwin, fgGC, bgGC, xBound, pixmap);
+		Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, xBound, pixmap);
 	    } else {
-		TkpDrawHighlightBorder(tkwin, bgGC, bgGC, xBound, pixmap);
+		Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, xBound, pixmap);
 	    }
 	}
     }
 
 #ifndef TK_NO_DOUBLE_BUFFERING
@@ -2688,11 +2688,11 @@
 	}
 	*indexPtr = idx;
 	return TCL_OK;
     }
 
-    string = TkGetStringFromObj(indexObj, &length);
+    string = Tcl_GetStringFromObj(indexObj, &length);
 
     switch (string[0]) {
     case 'a':
 	if (strncmp(string, "anchor", length) != 0) {
 	    goto badIndex;
@@ -3265,18 +3265,18 @@
      * interpreter is going away.
      */
 
     if (flags & TCL_TRACE_UNSETS) {
         if (!Tcl_InterpDeleted(interp) && entryPtr->textVarName) {
-            ClientData probe = NULL;
+            void *probe = NULL;
 
             do {
                 probe = Tcl_VarTraceInfo(interp,
                         entryPtr->textVarName,
                         TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
                         EntryTextVarProc, probe);
-                if (probe == (ClientData)entryPtr) {
+                if (probe == (void *)entryPtr) {
                     break;
                 }
             } while (probe);
             if (probe) {
                 /*
@@ -4057,11 +4057,11 @@
 	} else if ((minorCmd[0] == 'd')
 		&& (strncmp(minorCmd, "dragto", strlen(minorCmd)) == 0)) {
 	    EntryScanTo(entryPtr, x);
 	} else {
 	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
-		    "bad scan option \"%s\": must be mark or dragto",
+		    "bad scan option \"%s\": must be dragto or mark",
 		    minorCmd));
 	    Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "scan option",
 		    minorCmd, NULL);
 	    goto error;
 	}
@@ -4424,18 +4424,18 @@
 		 * Somehow the string changed from what we expected, so let's
 		 * do a search on the list to see if the current value is
 		 * there. If not, move to the first element of the list.
 		 */
 
-		int i, listc;
+		TkSizeT i, listc;
 		TkSizeT elemLen, length = entryPtr->numChars;
 		const char *bytes;
 		Tcl_Obj **listv;
 
 		Tcl_ListObjGetElements(interp, sbPtr->listObj, &listc, &listv);
 		for (i = 0; i < listc; i++) {
-		    bytes = TkGetStringFromObj(listv[i], &elemLen);
+		    bytes = Tcl_GetStringFromObj(listv[i], &elemLen);
 		    if ((length == elemLen) &&
 			    (memcmp(bytes, entryPtr->string,
 				    length) == 0)) {
 			sbPtr->eIndex = i;
 			break;

Index: generic/tkEntry.h
==================================================================
--- generic/tkEntry.h
+++ generic/tkEntry.h
@@ -4,11 +4,11 @@
  * This module defined the structures for the Entry & SpinBox widgets.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
- * Copyright (c) 2002 Apple Inc.
+ * Copyright © 2002 Apple Inc.
  */
 
 #ifndef _TKENTRY
 #define _TKENTRY
 
@@ -294,11 +294,11 @@
  * This is the element index corresponding to the strings in selElementNames.
  * If you modify them, you must modify the numbers here.
  */
 
 enum selelement {
-    SEL_NONE, SEL_BUTTONDOWN, SEL_BUTTONUP, SEL_NULL, SEL_ENTRY
+    SEL_BUTTONDOWN, SEL_BUTTONUP, SEL_NONE, SEL_NULL, SEL_ENTRY
 };
 
 /*
  * Declaration of functions used in the implementation of the native side of
  * the Entry widget.

Index: generic/tkError.c
==================================================================
--- generic/tkError.c
+++ generic/tkError.c
@@ -4,12 +4,12 @@
  *	This file provides a high-performance mechanism for selectively
  *	dealing with errors that occur in talking to the X server. This is
  *	useful, for example, when communicating with a window that may not
  *	exist.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1995 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkEvent.c
==================================================================
--- generic/tkEvent.c
+++ generic/tkEvent.c
@@ -2,14 +2,14 @@
  * tkEvent.c --
  *
  *	This file provides basic low-level facilities for managing X events in
  *	Tk.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 Sun Microsystems, Inc.
- * Copyright (c) 1998-2000 Ajuba Solutions.
- * Copyright (c) 2004 George Peter Staplin
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1995 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Ajuba Solutions.
+ * Copyright © 2004 George Peter Staplin
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -1149,11 +1149,11 @@
 	    int but = eventPtr->xbutton.button;
 	    eventPtr->type = MouseWheelEvent;
 	    eventPtr->xany.send_event = -1;
 	    eventPtr->xkey.keycode = (but & 1) ? -120 : 120;
 	    if (but > Button5) {
-		eventPtr->xkey.state ^= ShiftMask;
+		eventPtr->xkey.state |= ShiftMask;
 	    }
 	}
     }
 #endif
 
@@ -1840,11 +1840,11 @@
  */
 
 void
 TkCreateExitHandler(
     Tcl_ExitProc *proc,		/* Function to invoke. */
-    ClientData clientData)	/* Arbitrary value to pass to proc. */
+    void *clientData)	/* Arbitrary value to pass to proc. */
 {
     ExitHandler *exitPtr;
 
     exitPtr = (ExitHandler *)ckalloc(sizeof(ExitHandler));
     exitPtr->proc = proc;
@@ -2005,11 +2005,11 @@
  *----------------------------------------------------------------------
  *
  * TkFinalize --
  *
  *	Runs our private exit handlers and removes itself from Tcl. This is
- *	benificial should we want to protect from dangling pointers should the
+ *	beneficial should we want to protect from dangling pointers should the
  *	Tk shared library be unloaded prior to Tcl which can happen on windows
  *	should the process be forcefully exiting from an exception handler.
  *
  * Results:
  *	None.

Index: generic/tkFileFilter.c
==================================================================
--- generic/tkFileFilter.c
+++ generic/tkFileFilter.c
@@ -2,11 +2,11 @@
  * tkFileFilter.c --
  *
  *	Process the -filetypes option for the file dialogs on Windows and the
  *	Mac.
  *
- * Copyright (c) 1996 Sun Microsystems, Inc.
+ * Copyright © 1996 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -261,11 +261,11 @@
 	 * require further code refactoring.
 	 */
 
 	for (i=0; i<ostypeCount; i++) {
 	    TkSizeT len;
-	    const char *strType = TkGetStringFromObj(ostypeList[i], &len);
+	    const char *strType = Tcl_GetStringFromObj(ostypeList[i], &len);
 
 	    /*
 	     * If len is < 4, it is definitely an error. If equal or longer,
 	     * we need to use the macRoman encoding to determine the correct
 	     * length (assuming there may be non-ascii characters, e.g.,
@@ -284,11 +284,11 @@
 		/*
 		 * Convert utf to macRoman, since MacOS types are defined to
 		 * be 4 macRoman characters long
 		 */
 
-		Tcl_UtfToExternalDString(macRoman, strType, len, &osTypeDS);
+		(void)Tcl_UtfToExternalDStringEx(macRoman, strType, len, TCL_ENCODING_NOCOMPLAIN, &osTypeDS);
 		len = Tcl_DStringLength(&osTypeDS);
 		Tcl_DStringFree(&osTypeDS);
 	    }
 	    if (len != 4) {
 		Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -321,11 +321,11 @@
 
     if (globCount > 0 && globList != NULL) {
 	for (i=0; i<globCount; i++) {
 	    GlobPattern *globPtr = (GlobPattern *)ckalloc(sizeof(GlobPattern));
 	    TkSizeT len;
-	    const char *str = TkGetStringFromObj(globList[i], &len);
+	    const char *str = Tcl_GetStringFromObj(globList[i], &len);
 
 	    len = (len + 1) * sizeof(char);
 	    if (str[0] && str[0] != '*') {
 		/*
 		 * Prepend a "*" to patterns that do not have a leading "*"
@@ -375,19 +375,19 @@
 	}
 	for (i=0; i<ostypeCount; i++) {
 	    Tcl_DString osTypeDS;
 	    TkSizeT len;
 	    MacFileType *mfPtr = (MacFileType *)ckalloc(sizeof(MacFileType));
-	    const char *strType = TkGetStringFromObj(ostypeList[i], &len);
+	    const char *strType = Tcl_GetStringFromObj(ostypeList[i], &len);
 	    char *string;
 
 	    /*
 	     * Convert utf to macRoman, since MacOS types are defined to be 4
 	     * macRoman characters long
 	     */
 
-	    Tcl_UtfToExternalDString(macRoman, strType, len, &osTypeDS);
+	    (void)Tcl_UtfToExternalDStringEx(macRoman, strType, len, TCL_ENCODING_NOCOMPLAIN, &osTypeDS);
 	    string = Tcl_DStringValue(&osTypeDS);
 	    mfPtr->type = (OSType) string[0] << 24 | (OSType) string[1] << 16 |
 		    (OSType) string[2] <<  8 | (OSType) string[3];
 	    Tcl_DStringFree(&osTypeDS);
 

Index: generic/tkFileFilter.h
==================================================================
--- generic/tkFileFilter.h
+++ generic/tkFileFilter.h
@@ -2,11 +2,11 @@
  * tkFileFilter.h --
  *
  *	Declarations for the file filter processing routines needed by the
  *	file selection dialogs.
  *
- * Copyright (c) 1996 Sun Microsystems, Inc.
+ * Copyright © 1996 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkFocus.c
==================================================================
--- generic/tkFocus.c
+++ generic/tkFocus.c
@@ -1,12 +1,12 @@
 /*
  * tkFocus.c --
  *
  *	This file contains functions that manage the input focus for Tk.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -313,11 +313,11 @@
 	 *	windows in between the origin and destination of the focus
 	 *	change. For FocusIn we may see this when focus goes into an
 	 *	embedded child. We don't care about this, although we may end
 	 *	up getting a NotifyPointer later.
 	 * NotifyInferior - focus is coming to us from an embedded child. When
-	 *	focus is on an embeded focus, we still think we have the
+	 *	focus is on an embedded focus, we still think we have the
 	 *	focus, too, so this message doesn't change our state.
 	 * NotifyPointerRoot - should never happen because this is sent to the
 	 *	root window.
 	 *
 	 * Interesting FocusIn events are
@@ -367,11 +367,11 @@
 	    return retValue;
 	}
     }
 
     /*
-     * If winPtr isn't a top-level window than just ignore the event.
+     * If winPtr isn't a top-level window then just ignore the event.
      */
 
     winPtr = TkWmFocusToplevel(winPtr);
     if (winPtr == NULL) {
 	return retValue;
@@ -634,11 +634,11 @@
 
 	/*
 	 * We are assigning focus to an embedded toplevel.  The platform
 	 * specific function TkpClaimFocus needs to handle the job of
 	 * assigning focus to the container, since we have no way to find the
-	 * contaiuner.
+	 * container.
 	 */
 
 	TkpClaimFocus(topLevelPtr, force);
     } else if ((displayFocusPtr->focusWinPtr != NULL) || force) {
 
@@ -811,10 +811,11 @@
 				 * deleted. */
 {
     ToplevelFocusInfo *tlFocusPtr, *prevPtr;
     DisplayFocusInfo *displayFocusPtr;
     TkDisplay *dispPtr = winPtr->dispPtr;
+    int noMatch = 1;
 
     /*
      * Certain special windows like those used for send and clipboard have no
      * mainPtr.
      */
@@ -854,10 +855,11 @@
 		winPtr->mainPtr->tlFocusPtr = tlFocusPtr->nextPtr;
 	    } else {
 		prevPtr->nextPtr = tlFocusPtr->nextPtr;
 	    }
 	    ckfree(tlFocusPtr);
+	    noMatch = 0;
 	    break;
 	} else if (winPtr == tlFocusPtr->focusWinPtr) {
 	    /*
 	     * The deleted window had the focus for its top-level: move the
 	     * focus to the top-level itself.
@@ -871,10 +873,11 @@
 		GenerateFocusEvents(displayFocusPtr->focusWinPtr,
 			tlFocusPtr->topLevelPtr);
 		displayFocusPtr->focusWinPtr = tlFocusPtr->topLevelPtr;
 		dispPtr->focusPtr = tlFocusPtr->topLevelPtr;
 	    }
+	    noMatch = 0;
 	    break;
 	}
     }
 
     /*
@@ -888,10 +891,19 @@
     }
 
     if (displayFocusPtr->focusOnMapPtr == winPtr) {
 	displayFocusPtr->focusOnMapPtr = NULL;
     }
+
+    /*
+     * It may happen that the search above for focus records that refer
+     * to this window did not find any match. In such a case, when the
+     * dead window had the focus, release it.
+     */
+    if (noMatch && (dispPtr->focusPtr == winPtr)) {
+	dispPtr->focusPtr = NULL;
+    }
 }
 
 /*
  *----------------------------------------------------------------------
  *
@@ -1165,11 +1177,11 @@
 /*
  *----------------------------------------------------------------------
  *
  * TkFocusJoin --
  *
- *	Remove the focus record for this window that is nolonger managed
+ *	Remove the focus record for this window that is no longer managed
  *
  * Results:
  *	None.
  *
  * Side effects:

Index: generic/tkFont.c
==================================================================
--- generic/tkFont.c
+++ generic/tkFont.c
@@ -2,12 +2,12 @@
  * tkFont.c --
  *
  *	This file maintains a database of fonts for the Tk toolkit. It also
  *	provides several utility functions for measuring and displaying text.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1998 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1998 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -731,11 +731,11 @@
 	}
 	tkfont = Tk_AllocFontFromObj(interp, tkwin, objv[2]);
 	if (tkfont == NULL) {
 	    return TCL_ERROR;
 	}
-	string = TkGetStringFromObj(objv[3 + skip], &length);
+	string = Tcl_GetStringFromObj(objv[3 + skip], &length);
 	Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
 		Tk_TextWidth(tkfont, string, length)));
 	Tk_FreeFont(tkfont);
 	break;
     }
@@ -742,11 +742,11 @@
     case FONT_METRICS: {
 	Tk_Font tkfont;
 	int skip, i;
 	const TkFontMetrics *fmPtr;
 	static const char *const switches[] = {
-	    "-ascent", "-descent", "-linespace", "-fixed", NULL
+	    "-ascent", "-descent", "-fixed", "-linespace", NULL
 	};
 
 	skip = TkGetDisplayOf(interp, objc - 3, objv + 3, &tkwin);
 	if (skip < 0) {
 	    return TCL_ERROR;
@@ -776,12 +776,12 @@
 	    }
 	    i = 0;		/* Needed only to prevent compiler warning. */
 	    switch (index) {
 	    case 0: i = fmPtr->ascent;			break;
 	    case 1: i = fmPtr->descent;			break;
-	    case 2: i = fmPtr->ascent + fmPtr->descent;	break;
-	    case 3: i = fmPtr->fixed;			break;
+	    case 2: i = fmPtr->fixed;			break;
+	    case 3: i = fmPtr->ascent + fmPtr->descent;	break;
 	    }
 	    Tcl_SetObjResult(interp, Tcl_NewWideIntObj(i));
 	}
 	Tk_FreeFont(tkfont);
 	break;
@@ -896,10 +896,11 @@
 RecomputeWidgets(
     TkWindow *winPtr)		/* Window to which command is sent. */
 {
     Tk_ClassWorldChangedProc *proc =
 	    Tk_GetClassProc(winPtr->classProcsPtr, worldChangedProc);
+    TkWindow *tkwinPtr;
 
     if (proc != NULL) {
 	proc(winPtr->instanceData);
     }
 
@@ -911,22 +912,29 @@
      * option will be leaf nodes in the widget heirarchy (buttons, labels,
      * etc.), so the recursion depth will be shallow.
      *
      * However, the additional overhead of the recursive calls may become a
      * performance problem if typical usage alters such that -font'ed widgets
-     * appear high in the heirarchy, causing deep recursion. This could happen
-     * with text widgets, or more likely with the (not yet existant) labeled
-     * frame widget. With these widgets it is possible, even likely, that a
-     * -font'ed widget (text or labeled frame) will not be a leaf node, but
+     * appear high in the hierarchy, causing deep recursion. This could happen
+     * with text widgets, or more likely with the labelframe
+     * widget. With these widgets it is possible, even likely, that a
+     * -font'ed widget (text or labelframe) will not be a leaf node, but
      * will instead have many descendants. If this is ever found to cause a
      * performance problem, it may be worth investigating an iterative version
      * of the code below.
      */
 
-    for (winPtr=winPtr->childList ; winPtr!=NULL ; winPtr=winPtr->nextPtr) {
-	RecomputeWidgets(winPtr);
+    for (tkwinPtr=winPtr->childList ; tkwinPtr!=NULL ; tkwinPtr=tkwinPtr->nextPtr) {
+	RecomputeWidgets(tkwinPtr);
     }
+
+    /*
+     * Broadcast font change virtually for mega-widget layout managers.
+     * Do this after the font change has been propagated to core widgets.
+    */
+    Tk_SendVirtualEvent((Tk_Window)winPtr, "TkWorldChanged",
+			Tcl_NewStringObj("FontChanged",-1));
 }
 
 /*
  *---------------------------------------------------------------------------
  *
@@ -2469,11 +2477,11 @@
     Tk_TextLayout layout,	/* Layout information, from a previous call to
 				 * Tk_ComputeTextLayout(). */
     int x, int y,		/* Upper-left hand corner of rectangle in
 				 * which to draw (pixels). */
     int underline)		/* Index of the single character to underline,
-				 * or -1 for no underline. */
+				 * or INT_MIN for no underline. */
 {
     int xx, yy, width, height;
 
     if ((Tk_CharBbox(layout, underline, &xx, &yy, &width, &height) != 0)
 	    && (width != 0)) {
@@ -2496,11 +2504,11 @@
 				 * Tk_ComputeTextLayout(). */
     int x, int y,		/* Upper-left hand corner of rectangle in
 				 * which to draw (pixels). */
     double angle,
     int underline)		/* Index of the single character to underline,
-				 * or -1 for no underline. */
+				 * or INT_MIN for no underline. */
 {
     int xx, yy, width, height;
 
     if (angle == 0.0) {
 	Tk_UnderlineTextLayout(display, drawable, gc, layout, x,y, underline);
@@ -2724,11 +2732,11 @@
 int
 Tk_CharBbox(
     Tk_TextLayout layout,	/* Layout information, from a previous call to
 				 * Tk_ComputeTextLayout(). */
     int index,			/* The index of the character whose bbox is
-				 * desired. */
+				 * desired. Negative means count backwards. */
     int *xPtr, int *yPtr,	/* Filled with the upper-left hand corner, in
 				 * pixels, of the bounding box for the
 				 * character specified by index, if
 				 * non-NULL. */
     int *widthPtr, int *heightPtr)
@@ -2742,11 +2750,16 @@
     Tk_Font tkfont;
     TkFont *fontPtr;
     const char *end;
 
     if (index < 0) {
-	return 0;
+	for (i = 0; i < layoutPtr->numChunks; i++) {
+	    index += (chunkPtr + i)->numChars;
+	}
+	if (index < 0) {
+	    return 0;
+	}
     }
 
     tkfont = layoutPtr->tkfont;
     fontPtr = (TkFont *) tkfont;
 
@@ -3342,11 +3355,11 @@
 		goto noMapping;
 	    }
 	    sprintf(uindex, "%04X", ch);		/* endianness? */
 	    glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0);
 	    if (glyphname) {
-		ps = TkGetStringFromObj(psObj, &len);
+		ps = Tcl_GetStringFromObj(psObj, &len);
 		if (ps[len-1] == '(') {
 		    /*
 		     * In-place edit. Ewww!
 		     */
 
@@ -3656,11 +3669,12 @@
 				 * name. Any attributes that were not
 				 * specified in font name are filled with
 				 * default values. */
 {
     const char *dash;
-    int objc, result, i, n;
+    int result, n;
+    TkSizeT objc, i;
     Tcl_Obj **objv;
     const char *string;
 
     TkInitFontAttributes(faPtr);
 

Index: generic/tkFont.h
==================================================================
--- generic/tkFont.h
+++ generic/tkFont.h
@@ -3,11 +3,11 @@
  *
  *	Declarations for interfaces between the generic and platform-specific
  *	parts of the font package. This information is not visible outside of
  *	the font package.
  *
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkFrame.c
==================================================================
--- generic/tkFrame.c
+++ generic/tkFrame.c
@@ -3,12 +3,12 @@
  *
  *	This module implements "frame", "labelframe" and "toplevel" widgets
  *	for the Tk toolkit. Frames are windows with a background color and
  *	possibly a 3-D effect, but not much else in the way of attributes.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -328,11 +328,11 @@
 
 static void		ComputeFrameGeometry(Frame *framePtr);
 static int		ConfigureFrame(Tcl_Interp *interp, Frame *framePtr,
 			    int objc, Tcl_Obj *const objv[]);
 static int		CreateFrame(ClientData clientData, Tcl_Interp *interp,
-			    int objc, Tcl_Obj *const argv[],
+			    int objc, Tcl_Obj *const objv[],
 			    enum FrameType type, const char *appName);
 static void		DestroyFrame(void *memPtr);
 static void		DestroyFramePartly(Frame *framePtr);
 static void		DisplayFrame(ClientData clientData);
 static void		DrawFrameBackground(Tk_Window tkwin, Pixmap pixmap,
@@ -487,11 +487,11 @@
     Tcl_Obj *nameObj)		/* Should only be non-NULL if there is no main
 				 * window associated with the interpreter.
 				 * Gives the base name to use for the new
 				 * application. */
 {
-    int objc;
+    TkSizeT objc;
     Tcl_Obj **objv;
 
     if (TCL_OK != Tcl_ListObjGetElements(interp, listObj, &objc, &objv)) {
 	return TCL_ERROR;
     }
@@ -545,11 +545,11 @@
      */
 
     className = colormapName = screenName = visualName = useOption = NULL;
     colormap = None;
     for (i = 2; i < objc; i += 2) {
-	arg = TkGetStringFromObj(objv[i], &length);
+	arg = Tcl_GetStringFromObj(objv[i], &length);
 	if (length < 2) {
 	    continue;
 	}
 	if ((arg[1] == 'c') && (length >= 3)
 		&& (strncmp(arg, "-class", length) == 0)) {
@@ -577,12 +577,12 @@
      * 1. Must set the window's class before calling ConfigureFrame, so that
      *	  unspecified options are looked up in the option database using the
      *	  correct class.
      * 2. Must set visual information before calling ConfigureFrame so that
      *	  colors are allocated in a proper colormap.
-     * 3. Must call TkpUseWindow before setting non-default visual
-     *	  information, since TkpUseWindow changes the defaults.
+     * 3. Must call Tk_UseWindow before setting non-default visual
+     *	  information, since Tk_UseWindow changes the defaults.
      */
 
     if (screenName == NULL) {
 	screenName = (type == TYPE_TOPLEVEL) ? "" : NULL;
     }
@@ -632,11 +632,11 @@
     Tk_SetClass(newWin, className);
     if (useOption == NULL) {
 	useOption = Tk_GetOption(newWin, "use", "Use");
     }
     if ((useOption != NULL) && (*useOption != 0)
-	    && (TkpUseWindow(interp, newWin, useOption) != TCL_OK)) {
+	    && (Tk_UseWindow(interp, newWin, useOption) != TCL_OK)) {
 	goto error;
     }
     if (visualName == NULL) {
 	visualName = Tk_GetOption(newWin, "visual", "Visual");
     }
@@ -725,11 +725,11 @@
 		    "windows cannot have both the -use and the -container"
 		    " option set", -1));
 	    Tcl_SetErrorCode(interp, "TK", "FRAME", "CONTAINMENT", NULL);
 	    goto error;
 	}
-	TkpMakeContainer(framePtr->tkwin);
+	Tk_MakeContainer(framePtr->tkwin);
     }
     if (type == TYPE_TOPLEVEL) {
 	Tcl_DoWhenIdle(MapFrame, framePtr);
     }
     Tcl_SetObjResult(interp, Tk_NewWindowObj(newWin));
@@ -818,11 +818,11 @@
 	     * Don't allow the options -class, -colormap, -container, -screen,
 	     * -use, or -visual to be changed.
 	     */
 
 	    for (i = 2; i < objc; i++) {
-		const char *arg = TkGetStringFromObj(objv[i], &length);
+		const char *arg = Tcl_GetStringFromObj(objv[i], &length);
 
 		if (length < 2) {
 		    continue;
 		}
 		c = arg[1];
@@ -837,15 +837,15 @@
 		    || ((c == 'u') && (framePtr->type == TYPE_TOPLEVEL)
 			&& (strncmp(arg, "-use", length) == 0))
 		    || ((c == 'v')
 			&& (strncmp(arg, "-visual", length) == 0))) {
 
-#ifdef SUPPORT_CONFIG_EMBEDDED
+#ifdef _WIN32
 		    if (c == 'u') {
 			const char *string = Tcl_GetString(objv[i+1]);
 
-			if (TkpUseWindow(interp, framePtr->tkwin,
+			if (Tk_UseWindow(interp, framePtr->tkwin,
 				string) != TCL_OK) {
 			    result = TCL_ERROR;
 			    goto done;
 			}
 			continue;
@@ -1033,11 +1033,11 @@
     if ((((oldMenuName == NULL) && (framePtr->menuName != NULL))
 	    || ((oldMenuName != NULL) && (framePtr->menuName == NULL))
 	    || ((oldMenuName != NULL) && (framePtr->menuName != NULL)
 	    && strcmp(oldMenuName, framePtr->menuName) != 0))
 	    && framePtr->type == TYPE_TOPLEVEL) {
-	TkSetWindowMenuBar(interp, framePtr->tkwin, oldMenuName,
+	Tk_SetWindowMenubar(interp, framePtr->tkwin, oldMenuName,
 		framePtr->menuName);
     }
 
     if (oldMenuName != NULL) {
     	ckfree(oldMenuName);
@@ -1500,14 +1500,14 @@
 	bgGC = Tk_GCForColor(framePtr->highlightBgColorPtr,
 		Tk_WindowId(tkwin));
 	if (framePtr->flags & GOT_FOCUS) {
 	    fgGC = Tk_GCForColor(framePtr->highlightColorPtr,
 		    Tk_WindowId(tkwin));
-	    TkpDrawHighlightBorder(tkwin, fgGC, bgGC, hlWidth,
+	    Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, hlWidth,
 		    Tk_WindowId(tkwin));
 	} else {
-	    TkpDrawHighlightBorder(tkwin, bgGC, bgGC, hlWidth,
+	    Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, hlWidth,
 		    Tk_WindowId(tkwin));
 	}
     }
 
     /*
@@ -1745,11 +1745,11 @@
     } else if (eventPtr->type == ConfigureNotify) {
 	ComputeFrameGeometry(framePtr);
 	goto redraw;
     } else if (eventPtr->type == DestroyNotify) {
 	if (framePtr->menuName != NULL) {
-	    TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin,
+	    Tk_SetWindowMenubar(framePtr->interp, framePtr->tkwin,
 		    framePtr->menuName, NULL);
 	    ckfree(framePtr->menuName);
 	    framePtr->menuName = NULL;
 	}
 	if (framePtr->tkwin != NULL) {
@@ -1794,11 +1794,11 @@
 	    if (framePtr->highlightWidth > 0) {
 		goto redraw;
 	    }
 	}
     } else if (eventPtr->type == ActivateNotify) {
-    	TkpSetMainMenubar(framePtr->interp, framePtr->tkwin,
+    	Tk_SetMainMenubar(framePtr->interp, framePtr->tkwin,
     		framePtr->menuName);
     }
     return;
 
   redraw:
@@ -1832,11 +1832,11 @@
 {
     Frame *framePtr = (Frame *)clientData;
     Tk_Window tkwin = framePtr->tkwin;
 
     if (framePtr->menuName != NULL) {
-	TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin,
+	Tk_SetWindowMenubar(framePtr->interp, framePtr->tkwin,
 		framePtr->menuName, NULL);
 	ckfree(framePtr->menuName);
 	framePtr->menuName = NULL;
     }
 
@@ -2066,11 +2066,11 @@
 
     if (Tk_IsTopLevel(tkwin) && framePtr->type == TYPE_FRAME) {
 	framePtr->type = TYPE_TOPLEVEL;
 	Tcl_DoWhenIdle(MapFrame, framePtr);
 	if (framePtr->menuName != NULL) {
-	    TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin, NULL,
+	    Tk_SetWindowMenubar(framePtr->interp, framePtr->tkwin, NULL,
 		    framePtr->menuName);
 	}
     } else if (!Tk_IsTopLevel(tkwin) && framePtr->type == TYPE_TOPLEVEL) {
 	framePtr->type = TYPE_FRAME;
     } else {

Index: generic/tkGC.c
==================================================================
--- generic/tkGC.c
+++ generic/tkGC.c
@@ -2,12 +2,12 @@
  * tkGC.c --
  *
  *	This file maintains a database of read-only graphics contexts for the
  *	Tk toolkit, in order to allow GC's to be shared.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkGeometry.c
==================================================================
--- generic/tkGeometry.c
+++ generic/tkGeometry.c
@@ -2,12 +2,12 @@
  * tkGeometry.c --
  *
  *	This file contains generic Tk code for geometry management (stuff
  *	that's used by all geometry managers).
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1995 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -559,11 +559,11 @@
  *----------------------------------------------------------------------
  */
 
 void
 Tk_UnmaintainGeometry(
-    Tk_Window window,		/* WIndow for geometry management. */
+    Tk_Window window,		/* Window for geometry management. */
     Tk_Window container)		/* Container for window; must be a descendant of
 				 * window's parent. */
 {
     Tcl_HashEntry *hPtr;
     MaintainContainer *containerPtr;

Index: generic/tkGet.c
==================================================================
--- generic/tkGet.c
+++ generic/tkGet.c
@@ -4,12 +4,12 @@
  *	This file contains a number of "Tk_GetXXX" procedures, which parse
  *	text strings into useful forms for Tk. This file has the simpler
  *	functions, like Tk_GetDirection and Tk_GetUid. The more complex
  *	functions like Tk_GetColor are in separate files.
  *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -33,14 +33,14 @@
 /*
  * The following tables defines the string values for reliefs, which are
  * used by Tk_GetAnchorFromObj and Tk_GetJustifyFromObj.
  */
 
-static const char *const anchorStrings[] = {
+const char *const tkAnchorStrings[] = {
     "n", "ne", "e", "se", "s", "sw", "w", "nw", "center", NULL
 };
-static const char *const justifyStrings[] = {
+const char *const tkJustifyStrings[] = {
     "left", "right", "center", NULL
 };
 
 /*
  *----------------------------------------------------------------------
@@ -69,11 +69,11 @@
 				 * corresponds to the string value of
 				 * objPtr. */
 {
     int index, code;
 
-    code = Tcl_GetIndexFromObj(interp, objPtr, anchorStrings, "anchor", 0,
+    code = Tcl_GetIndexFromObj(interp, objPtr, tkAnchorStrings, "anchor", 0,
 	    &index);
     if (code == TCL_OK) {
 	*anchorPtr = (Tk_Anchor) index;
     }
     return code;
@@ -188,10 +188,11 @@
     case TK_ANCHOR_S: return "s";
     case TK_ANCHOR_SW: return "sw";
     case TK_ANCHOR_W: return "w";
     case TK_ANCHOR_NW: return "nw";
     case TK_ANCHOR_CENTER: return "center";
+    case TK_ANCHOR_NULL: return "";
     }
     return "unknown anchor position";
 }
 
 /*
@@ -383,11 +384,11 @@
 				 * corresponds to the string value of
 				 * objPtr. */
 {
     int index, code;
 
-    code = Tcl_GetIndexFromObj(interp, objPtr, justifyStrings,
+    code = Tcl_GetIndexFromObj(interp, objPtr, tkJustifyStrings,
 	    "justification", 0, &index);
     if (code == TCL_OK) {
 	*justifyPtr = (Tk_Justify) index;
     }
     return code;
@@ -469,10 +470,11 @@
 {
     switch (justify) {
     case TK_JUSTIFY_LEFT: return "left";
     case TK_JUSTIFY_RIGHT: return "right";
     case TK_JUSTIFY_CENTER: return "center";
+    case TK_JUSTIFY_NULL: return "";
     }
     return "unknown justification style";
 }
 
 /*
@@ -692,10 +694,15 @@
     double *doublePtr)		/* Place to store converted result. */
 {
     char *end;
     double d;
 
+    if (!tkwin) {
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad screen"));
+	Tcl_SetErrorCode(interp, "TK", "VALUE", "FRACTIONAL_PIXELS", NULL);
+	return TCL_ERROR;
+    }
     d = strtod((char *) string, &end);
     if (end == string) {
 	goto error;
     }
     while ((*end != '\0') && isspace(UCHAR(*end))) {

Index: generic/tkGrab.c
==================================================================
--- generic/tkGrab.c
+++ generic/tkGrab.c
@@ -1,12 +1,12 @@
 /*
  * tkGrab.c --
  *
  *	This file provides functions that implement grabs for Tk.
  *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -14,10 +14,12 @@
 
 #ifdef _WIN32
 #include "tkWinInt.h"
 #elif !defined(MAC_OSX_TK)
 #include "tkUnixInt.h"
+#else
+#include "tkMacOSXInt.h"
 #endif
 
 /*
  * The grab state machine has four states: ungrabbed, button pressed, grabbed,
  * and button pressed while grabbed. In addition, there are three pieces of
@@ -213,11 +215,11 @@
 
     /*
      * First check for a window name or "-global" as the first argument.
      */
 
-    arg = TkGetStringFromObj(objv[1], &len);
+    arg = Tcl_GetStringFromObj(objv[1], &len);
     if (arg[0] == '.') {
 	/* [grab window] */
 	if (objc != 2) {
 	    Tcl_WrongNumArgs(interp, 1, objv, "?-global? window");
 	    return TCL_ERROR;

Index: generic/tkGrid.c
==================================================================
--- generic/tkGrid.c
+++ generic/tkGrid.c
@@ -1,11 +1,11 @@
 /*
  * tkGrid.c --
  *
  *	Grid based geometry manager.
  *
- * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -981,14 +981,15 @@
     Gridder *containerPtr, *contentPtr;
     SlotInfo *slotPtr = NULL;
     int slot;			/* the column or row number */
     int slotType;		/* COLUMN or ROW */
     int size;			/* the configuration value */
-    int lObjc;			/* Number of items in index list */
+    TkSizeT lObjc;		/* Number of items in index list */
     Tcl_Obj **lObjv;		/* array of indices */
     int ok;			/* temporary TCL result code */
-    int i, j, first, last;
+    int i, first, last;
+    TkSizeT j;
     const char *string;
     static const char *const optionStrings[] = {
 	"-minsize", "-pad", "-uniform", "-weight", NULL
     };
     enum options {
@@ -2826,10 +2827,13 @@
 DestroyGrid(
     void *memPtr)		/* Info about window that is now dead. */
 {
     Gridder *gridPtr = (Gridder *)memPtr;
 
+    if (gridPtr->flags & REQUESTED_RELAYOUT) {
+	Tcl_CancelIdleCall(ArrangeGrid, gridPtr);
+    }
     if (gridPtr->containerDataPtr != NULL) {
 	if (gridPtr->containerDataPtr->rowPtr != NULL) {
 	    ckfree(gridPtr->containerDataPtr -> rowPtr);
 	}
 	if (gridPtr->containerDataPtr->columnPtr != NULL) {
@@ -2984,11 +2988,11 @@
     firstChar = 0;
     for (numWindows=0, i=0; i < objc; i++) {
 	TkSizeT length;
 	char prevChar = firstChar;
 
-	string = TkGetStringFromObj(objv[i], &length);
+	string = Tcl_GetStringFromObj(objv[i], &length);
     	firstChar = string[0];
 
 	if (firstChar == '.') {
 	    /*
 	     * Check that windows are valid, and locate the first content's

ADDED   generic/tkIcu.c
Index: generic/tkIcu.c
==================================================================
--- /dev/null
+++ generic/tkIcu.c
@@ -0,0 +1,313 @@
+/*
+ * tkIcu.c --
+ *
+ * 	tkIcu.c implements various Tk commands which can find
+ * 	grapheme cluster and workchar bounderies in Unicode strings.
+ *
+ * Copyright © 2021 Jan Nijtmans
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+#include "tkInt.h"
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+/*
+ * Runtime linking of libicu.
+ */
+typedef enum UBreakIteratorTypex {
+	  UBRK_CHARACTERX = 0,
+	  UBRK_WORDX = 1
+} UBreakIteratorTypex;
+
+typedef enum UErrorCodex {
+    U_ZERO_ERRORZ              =  0     /**< No error, no warning. */
+} UErrorCodex;
+
+typedef void *(*fn_icu_open)(UBreakIteratorTypex, const char *,
+	const uint16_t *, int32_t, UErrorCodex *);
+typedef void	(*fn_icu_close)(void *);
+typedef int32_t	(*fn_icu_preceding)(void *, int32_t);
+typedef int32_t	(*fn_icu_following)(void *, int32_t);
+typedef int32_t	(*fn_icu_previous)(void *);
+typedef int32_t	(*fn_icu_next)(void *);
+typedef void	(*fn_icu_setText)(void *, const void *, int32_t, UErrorCodex *);
+
+static struct {
+    size_t				nopen;
+    Tcl_LoadHandle		lib;
+    fn_icu_open			open;
+    fn_icu_close		close;
+    fn_icu_preceding	preceding;
+    fn_icu_following	following;
+    fn_icu_previous	previous;
+    fn_icu_next	next;
+    fn_icu_setText	setText;
+} icu_fns = {
+    0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+};
+
+#define FLAG_WORD 1
+#define FLAG_FOLLOWING 4
+#define FLAG_SPACE 8
+
+#define icu_open			icu_fns.open
+#define icu_close			icu_fns.close
+#define icu_preceding		icu_fns.preceding
+#define icu_following		icu_fns.following
+#define icu_previous		icu_fns.previous
+#define icu_next		icu_fns.next
+#define icu_setText		icu_fns.setText
+
+TCL_DECLARE_MUTEX(icu_mutex);
+
+static int
+startEndOfCmd(
+    ClientData clientData,
+    Tcl_Interp *interp,
+    int objc,
+    Tcl_Obj *const objv[])
+{
+    Tcl_DString ds;
+    TkSizeT len;
+    const char *str;
+    UErrorCodex errorCode = U_ZERO_ERRORZ;
+    void *it;
+    TkSizeT idx;
+    int flags = PTR2INT(clientData);
+    const uint16_t *ustr;
+    const char *locale = NULL;
+
+    if ((unsigned)(objc - 3) > 1) {
+	Tcl_WrongNumArgs(interp, 1 , objv, "str start ?locale?");
+	return TCL_ERROR;
+    }
+    if (objc > 3) {
+	locale = Tcl_GetString(objv[3]);
+	if (!*locale) {
+	    locale = NULL;
+	}
+    }
+    Tcl_DStringInit(&ds);
+    str = Tcl_GetStringFromObj(objv[1], &len);
+    Tcl_UtfToChar16DString(str, len, &ds);
+    len = Tcl_DStringLength(&ds)/2;
+    if (TkGetIntForIndex(objv[2], len-1, 0, &idx) != TCL_OK) {
+	Tcl_DStringFree(&ds);
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"", Tcl_GetString(objv[2])));
+	Tcl_SetErrorCode(interp, "TK", "ICU", "INDEX", NULL);
+	return TCL_ERROR;
+    }
+
+    it = icu_open((UBreakIteratorTypex)(flags&3), locale,
+    		NULL, -1, &errorCode);
+    if (it != NULL) {
+	errorCode = U_ZERO_ERRORZ;
+	ustr = (const uint16_t *)Tcl_DStringValue(&ds);
+	icu_setText(it, ustr, len, &errorCode);
+    }
+    if (it == NULL || errorCode != U_ZERO_ERRORZ) {
+    	Tcl_DStringFree(&ds);
+    	Tcl_SetObjResult(interp, Tcl_ObjPrintf("cannot open ICU iterator, errorcode: %d", (int)errorCode));
+    	Tcl_SetErrorCode(interp, "TK", "ICU", "CANNOTOPEN", NULL);
+    	return TCL_ERROR;
+    }
+    if (flags & FLAG_FOLLOWING) {
+	if ((idx == TCL_INDEX_NONE) && (flags & FLAG_WORD)) {
+	    idx = 0;
+	}
+	idx = icu_following(it, idx);
+	if ((flags & FLAG_WORD) && idx >= len) {
+	    idx = -1;
+	}
+    } else if (idx > 0) {
+	if (!(flags & FLAG_WORD)) {
+		idx += 1 + (((ustr[idx]&0xFFC0) == 0xD800) && ((ustr[idx+1]&0xFFC0) == 0xDC00));
+	}
+	idx = icu_preceding(it, idx);
+	if (idx == 0 && (flags & FLAG_WORD)) {
+	    flags &= ~FLAG_WORD; /* If 0 is reached here, don't do a further search */
+	}
+    }
+    if ((flags & FLAG_WORD) && (idx != TCL_INDEX_NONE)) {
+	if (!(flags & FLAG_SPACE) == ((idx >= len) || Tcl_UniCharIsSpace(ustr[idx]))) {
+	    if (flags & FLAG_FOLLOWING) {
+		idx = icu_next(it);
+		if (idx >= len) {
+		    idx = TCL_INDEX_NONE;
+		}
+	    } else {
+		idx = icu_previous(it);
+	    }
+	} else if (idx == 0 && !(flags & FLAG_FOLLOWING)) {
+	    idx = TCL_INDEX_NONE;
+	}
+    }
+    icu_close(it);
+    Tcl_DStringFree(&ds);
+    if (idx != TCL_INDEX_NONE) {
+	Tcl_SetObjResult(interp, TkNewIndexObj(idx));
+    }
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SysNotifyDeleteCmd --
+ *
+ *      Delete notification and clean up.
+ *
+ * Results:
+ *	Window destroyed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+icuCleanup(
+    TCL_UNUSED(void *))
+{
+    Tcl_MutexLock(&icu_mutex);
+    if (icu_fns.nopen-- <= 1) {
+	if (icu_fns.lib != NULL) {
+	    Tcl_FSUnloadFile(NULL, icu_fns.lib);
+	}
+	memset(&icu_fns, 0, sizeof(icu_fns));
+    }
+    Tcl_MutexUnlock(&icu_mutex);
+}
+
+void
+Icu_Init(
+    Tcl_Interp *interp)
+{
+    Tcl_MutexLock(&icu_mutex);
+    char symbol[24];
+    char icuversion[4] = "_75"; /* Highest ICU version + 1 */
+
+    if (icu_fns.nopen == 0) {
+	int i = 0;
+	Tcl_Obj *nameobj;
+	static const char *iculibs[] = {
+#if defined(_WIN32)
+	    "icuuc??.dll", /* When running under Windows, user-provided */
+	    NULL,
+	    "cygicuuc??.dll", /* When running under Cygwin */
+#elif defined(__CYGWIN__)
+	    "cygicuuc??.dll",
+#elif defined(MAC_OSX_TCL)
+	    "libicuuc.??.dylib",
+#else
+	    "libicuuc.so.??",
+#endif
+	    NULL
+	};
+
+	/* Going back down to ICU version 50 */
+	while ((icu_fns.lib == NULL) && (icuversion[1] >= '5')) {
+	    if (icuversion[2]-- < '0') {
+		icuversion[1]--; icuversion[2] = '9';
+	    }
+#if defined(_WIN32) && !defined(STATIC_BUILD)
+	    if (tclStubsPtr->tcl_CreateFileHandler) {
+		/* Running on Cygwin, so try to load the cygwin icu dll */
+		i = 2;
+	    } else
+#endif
+	    i = 0;
+	    while (iculibs[i] != NULL) {
+		Tcl_ResetResult(interp);
+		nameobj = Tcl_NewStringObj(iculibs[i], -1);
+		char *nameStr = Tcl_GetString(nameobj);
+		char *p = strchr(nameStr, '?');
+		if (p != NULL) {
+		    memcpy(p, icuversion+1, 2);
+		}
+		Tcl_IncrRefCount(nameobj);
+		if (Tcl_LoadFile(interp, nameobj, NULL, 0, NULL, &icu_fns.lib)
+			== TCL_OK) {
+		    if (p == NULL) {
+			icuversion[0] = '\0';
+		    }
+		    Tcl_DecrRefCount(nameobj);
+		    break;
+		}
+		Tcl_DecrRefCount(nameobj);
+		++i;
+	    }
+	}
+#if defined(_WIN32)
+	if (icu_fns.lib == NULL) {
+	    Tcl_ResetResult(interp);
+		nameobj = Tcl_NewStringObj("icu.dll", -1);
+		Tcl_IncrRefCount(nameobj);
+		if (Tcl_LoadFile(interp, nameobj, NULL, 0, NULL, &icu_fns.lib)
+			== TCL_OK) {
+		    icuversion[0] = '\0';
+		}
+		Tcl_DecrRefCount(nameobj);
+	}
+	if (icu_fns.lib == NULL) {
+	    Tcl_ResetResult(interp);
+		nameobj = Tcl_NewStringObj("icuuc.dll", -1);
+		Tcl_IncrRefCount(nameobj);
+		if (Tcl_LoadFile(interp, nameobj, NULL, 0, NULL, &icu_fns.lib)
+			== TCL_OK) {
+		    icuversion[0] = '\0';
+		}
+		Tcl_DecrRefCount(nameobj);
+	}
+#endif
+	if (icu_fns.lib != NULL) {
+#define ICU_SYM(name)							\
+	    strcpy(symbol, "ubrk_" #name ); \
+	    strcat(symbol, icuversion); \
+	    icu_fns.name = (fn_icu_ ## name)				\
+		Tcl_FindSymbol(NULL, icu_fns.lib, symbol)
+	    ICU_SYM(open);
+	    ICU_SYM(close);
+	    ICU_SYM(preceding);
+	    ICU_SYM(following);
+	    ICU_SYM(previous);
+	    ICU_SYM(next);
+	    ICU_SYM(setText);
+#undef ICU_SYM
+	}
+    }
+    Tcl_MutexUnlock(&icu_mutex);
+
+    if (icu_fns.lib != NULL) {
+	Tcl_CreateObjCommand(interp, "::tk::startOfCluster", startEndOfCmd,
+		INT2PTR(0), icuCleanup);
+	Tcl_CreateObjCommand(interp, "::tk::startOfNextWord", startEndOfCmd,
+		INT2PTR(FLAG_WORD|FLAG_FOLLOWING), icuCleanup);
+	Tcl_CreateObjCommand(interp, "::tk::startOfPreviousWord", startEndOfCmd,
+		INT2PTR(FLAG_WORD), icuCleanup);
+	Tcl_CreateObjCommand(interp, "::tk::endOfCluster", startEndOfCmd,
+		INT2PTR(FLAG_FOLLOWING), icuCleanup);
+	Tcl_CreateObjCommand(interp, "::tk::endOfWord", startEndOfCmd,
+		INT2PTR(FLAG_WORD|FLAG_FOLLOWING|FLAG_SPACE), icuCleanup);
+    icu_fns.nopen += 5;
+    }
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * coding: utf-8
+ * End:
+ */
+

Index: generic/tkImage.c
==================================================================
--- generic/tkImage.c
+++ generic/tkImage.c
@@ -2,12 +2,12 @@
  * tkImage.c --
  *
  *	This module implements the image protocol, which allows lots of
  *	different kinds of images to be used in lots of different widgets.
  *
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkImgBmap.c
==================================================================
--- generic/tkImgBmap.c
+++ generic/tkImgBmap.c
@@ -1,13 +1,13 @@
 /*
  * tkImgBmap.c --
  *
  *	This procedure implements images of type "bitmap" for Tk.
  *
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1999 by Scriptics Corporation.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1999 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -73,11 +73,11 @@
  * The type record for bitmap images:
  */
 
 static int		GetByte(Tcl_Channel chan);
 static int		ImgBmapCreate(Tcl_Interp *interp,
-			    const char *name, int argc, Tcl_Obj *const objv[],
+			    const char *name, int objc, Tcl_Obj *const objv[],
 			    const Tk_ImageType *typePtr, Tk_ImageModel model,
 			    ClientData *clientDataPtr);
 static ClientData	ImgBmapGet(Tk_Window tkwin, ClientData clientData);
 static void		ImgBmapDisplay(ClientData clientData,
 			    Display *display, Drawable drawable,
@@ -144,15 +144,15 @@
 /*
  * Prototypes for procedures used only locally in this file:
  */
 
 static int		ImgBmapCmd(ClientData clientData, Tcl_Interp *interp,
-			    int argc, Tcl_Obj *const objv[]);
+			    int objc, Tcl_Obj *const objv[]);
 static void		ImgBmapCmdDeletedProc(ClientData clientData);
 static void		ImgBmapConfigureInstance(BitmapInstance *instancePtr);
 static int		ImgBmapConfigureModel(BitmapModel *modelPtr,
-			    int argc, Tcl_Obj *const objv[], int flags);
+			    int objc, Tcl_Obj *const objv[], int flags);
 static int		NextBitmapWord(ParseInfo *parseInfoPtr);
 
 /*
  *----------------------------------------------------------------------
  *
@@ -172,12 +172,12 @@
 static int
 ImgBmapCreate(
     Tcl_Interp *interp,		/* Interpreter for application containing
 				 * image. */
     const char *name,			/* Name to use for image. */
-    int argc,			/* Number of arguments. */
-    Tcl_Obj *const argv[],	/* Argument objects for options (doesn't
+    int objc,			/* Number of arguments. */
+    Tcl_Obj *const objv[],	/* Argument objects for options (doesn't
 				 * include image name or type). */
     const Tk_ImageType *typePtr,/* Pointer to our type record (not used). */
     Tk_ImageModel model,	/* Token for image, to be used by us in later
 				 * callbacks. */
     ClientData *clientDataPtr)	/* Store manager's token for image here; it
@@ -198,11 +198,11 @@
     modelPtr->fileString = NULL;
     modelPtr->dataString = NULL;
     modelPtr->maskFileString = NULL;
     modelPtr->maskDataString = NULL;
     modelPtr->instancePtr = NULL;
-    if (ImgBmapConfigureModel(modelPtr, argc, argv, 0) != TCL_OK) {
+    if (ImgBmapConfigureModel(modelPtr, objc, objv, 0) != TCL_OK) {
 	ImgBmapDelete(modelPtr);
 	return TCL_ERROR;
     }
     *clientDataPtr = modelPtr;
     return TCL_OK;
@@ -498,17 +498,19 @@
 		    "can't get bitmap data from a file in a safe interpreter",
 		    -1));
 	    Tcl_SetErrorCode(interp, "TK", "SAFE", "BITMAP_FILE", NULL);
 	    return NULL;
 	}
-	expandedFileName = Tcl_TranslateFileName(interp, fileName, &buffer);
+	expandedFileName = Tcl_TranslateFileName(NULL, fileName, &buffer);
 	if (expandedFileName == NULL) {
-	    return NULL;
+	    Tcl_SetErrno(ENOENT);
+	    goto cannotRead;
 	}
 	pi.chan = Tcl_OpenFileChannel(interp, expandedFileName, "r", 0);
 	Tcl_DStringFree(&buffer);
 	if (pi.chan == NULL) {
+	cannotRead:
 	    if (interp != NULL) {
 		Tcl_ResetResult(interp);
 		Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 			"couldn't read bitmap file \"%s\": %s",
 			fileName, Tcl_PosixError(interp)));

Index: generic/tkImgGIF.c
==================================================================
--- generic/tkImgGIF.c
+++ generic/tkImgGIF.c
@@ -6,14 +6,14 @@
  *	read using the -data option of the photo image. The data may be given
  *	as a binary string in a Tcl_Obj or by representing the data as BASE64
  *	encoded ascii. Derived from the giftoppm code found in the pbmplus
  *	package and tkImgFmtPPM.c in the tk4.0b2 distribution.
  *
- * Copyright (c) Reed Wade (wade@cs.utk.edu), University of Tennessee
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright (c) 1997 Australian National University
- * Copyright (c) 2005-2010 Donal K. Fellows
+ * Copyright © Reed Wade (wade@cs.utk.edu), University of Tennessee
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 1997 Australian National University
+ * Copyright © 2005-2010 Donal K. Fellows
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
  * This file also contains code from the giftoppm program, which is
@@ -116,32 +116,41 @@
 
 /*
  * The format record for the GIF file format:
  */
 
-static int		FileMatchGIF(Tcl_Channel chan, const char *fileName,
-			    Tcl_Obj *format, int *widthPtr, int *heightPtr,
-			    Tcl_Interp *interp);
+static int		FileMatchGIF(Tcl_Interp *interp, Tcl_Channel chan,
+			    const char *fileName, Tcl_Obj *format,
+			    Tcl_Obj *metadataInObj, int *widthPtr,
+			    int *heightPtr, Tcl_Obj *metadataOutObj);
 static int		FileReadGIF(Tcl_Interp *interp, Tcl_Channel chan,
 			    const char *fileName, Tcl_Obj *format,
-			    Tk_PhotoHandle imageHandle, int destX, int destY,
-			    int width, int height, int srcX, int srcY);
-static int		StringMatchGIF(Tcl_Obj *dataObj, Tcl_Obj *format,
-			    int *widthPtr, int *heightPtr, Tcl_Interp *interp);
-static int		StringReadGIF(Tcl_Interp *interp, Tcl_Obj *dataObj,
-			    Tcl_Obj *format, Tk_PhotoHandle imageHandle,
-			    int destX, int destY, int width, int height,
-			    int srcX, int srcY);
-static int		FileWriteGIF(Tcl_Interp *interp, const char *filename,
-			    Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr);
-static int		StringWriteGIF(Tcl_Interp *interp, Tcl_Obj *format,
-			    Tk_PhotoImageBlock *blockPtr);
-static int		CommonWriteGIF(Tcl_Interp *interp, ClientData clientData,
-			    WriteBytesFunc *writeProc, Tcl_Obj *format,
-			    Tk_PhotoImageBlock *blockPtr);
-
-Tk_PhotoImageFormat tkImgFmtGIF = {
+			    Tcl_Obj *metadataInObj, Tk_PhotoHandle imageHandle,
+			    int destX, int destY, int width, int height,
+			    int srcX, int srcY, Tcl_Obj *metadataOutObj);
+static int		StringMatchGIF(Tcl_Interp *interp, Tcl_Obj *dataObj,
+			    Tcl_Obj *format, Tcl_Obj *metadataInObj,
+			    int *widthPtr, int *heightPtr,
+			    Tcl_Obj *metadataOutObj);
+static int		StringReadGIF(Tcl_Interp *interp, Tcl_Obj *dataObj,
+			    Tcl_Obj *format, Tcl_Obj *metadataInObj,
+			    Tk_PhotoHandle imageHandle,
+			    int destX, int destY, int width, int height,
+			    int srcX, int srcY, Tcl_Obj *metadataOutObj);
+static int		FileWriteGIF(Tcl_Interp *interp, const char *filename,
+			    Tcl_Obj *format, Tcl_Obj *metadataInObj,
+			    Tk_PhotoImageBlock *blockPtr);
+static int		StringWriteGIF(Tcl_Interp *interp, Tcl_Obj *format,
+			    Tcl_Obj *metadataInObj,
+			    Tk_PhotoImageBlock *blockPtr);
+static int		CommonWriteGIF(Tcl_Interp *interp,
+			    ClientData clientData,
+			    WriteBytesFunc *writeProc, Tcl_Obj *format,
+			    Tcl_Obj *metadataInObj,
+			    Tk_PhotoImageBlock *blockPtr);
+
+Tk_PhotoImageFormatVersion3 tkImgFmtGIF = {
     "gif",		/* name */
     FileMatchGIF,	/* fileMatchProc */
     StringMatchGIF,	/* stringMatchProc */
     FileReadGIF,	/* fileReadProc */
     StringReadGIF,	/* stringReadProc */
@@ -163,13 +172,15 @@
 
 /*
  * Prototypes for local functions defined in this file:
  */
 
+static int		ReadOneByte(Tcl_Interp *interp,
+			    GIFImageConfig *gifConfPtr, Tcl_Channel chan);
 static int		DoExtension(GIFImageConfig *gifConfPtr,
 			    Tcl_Channel chan, int label, unsigned char *buffer,
-			    int *transparent);
+			    int *transparent, Tcl_Obj *metadataOutObj);
 static int		GetCode(Tcl_Channel chan, int code_size, int flag,
 			    GIFImageConfig *gifConfPtr);
 static int		GetDataBlock(GIFImageConfig *gifConfPtr,
 			    Tcl_Channel chan, unsigned char *buf);
 static int		ReadColorMap(GIFImageConfig *gifConfPtr,
@@ -343,22 +354,21 @@
  *----------------------------------------------------------------------
  */
 
 static int
 FileMatchGIF(
+    TCL_UNUSED(Tcl_Interp *),	/* not used */
     Tcl_Channel chan,		/* The image file, open for reading. */
-    const char *fileName,	/* The name of the image file. */
-    Tcl_Obj *format,		/* User-specified format object, or NULL. */
+    TCL_UNUSED(const char *),	/* The name of the image file. */
+    TCL_UNUSED(Tcl_Obj *),	/* User-specified format object, or NULL. */
+    TCL_UNUSED(Tcl_Obj *),	/* metadata input, may be NULL */
     int *widthPtr, int *heightPtr,
 				/* The dimensions of the image are returned
 				 * here if the file is a valid raw GIF file. */
-    Tcl_Interp *dummy)		/* not used */
+    TCL_UNUSED(Tcl_Obj *))	/* metadata return dict, may be NULL */
 {
     GIFImageConfig gifConf;
-    (void)fileName;
-    (void)format;
-    (void)dummy;
 
     memset(&gifConf, 0, sizeof(GIFImageConfig));
     return ReadGIFHeader(&gifConf, chan, widthPtr, heightPtr);
 }
 
@@ -385,25 +395,28 @@
 FileReadGIF(
     Tcl_Interp *interp,		/* Interpreter to use for reporting errors. */
     Tcl_Channel chan,		/* The image file, open for reading. */
     const char *fileName,	/* The name of the image file. */
     Tcl_Obj *format,		/* User-specified format object, or NULL. */
+    TCL_UNUSED(Tcl_Obj *),	/* metadata input, may be NULL */
     Tk_PhotoHandle imageHandle,	/* The photo image to write into. */
     int destX, int destY,	/* Coordinates of top-left pixel in photo
 				 * image to be written to. */
     int width, int height,	/* Dimensions of block of photo image to be
 				 * written to. */
-    int srcX, int srcY)		/* Coordinates of top-left pixel to be used in
+    int srcX, int srcY,		/* Coordinates of top-left pixel to be used in
 				 * image being read. */
+    Tcl_Obj *metadataOutObj)	/* metadata return dict, may be NULL */
 {
     int fileWidth, fileHeight, imageWidth, imageHeight;
     unsigned int nBytes;
     int index = 0, argc = 0, i, result = TCL_ERROR;
     Tcl_Obj **objv;
     unsigned char buf[100];
     unsigned char *trashBuffer = NULL;
     int bitPixel;
+    int gifLabel;
     unsigned char colorMap[MAXCOLORMAPSIZE][4];
     int transparent = -1;
     static const char *const optionStrings[] = {
 	"-index", NULL
     };
@@ -501,28 +514,26 @@
     if (Tk_PhotoExpand(interp, imageHandle,
 	    destX + width, destY + height) != TCL_OK) {
 	return TCL_ERROR;
     }
 
+    /*
+     * -------------------------------------------------------------------------
+     * From here on, go to error to not leave memory leaks
+     * -------------------------------------------------------------------------
+     */
+
     /*
      * Search for the frame from the GIF to display.
      */
 
     while (1) {
-	if (Fread(gifConfPtr, buf, 1, 1, chan) != 1) {
-	    /*
-	     * Premature end of image.
-	     */
-
-	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
-		    "premature end of image data for this index", -1));
-	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "PREMATURE_END",
-		    NULL);
+	if (-1 == (gifLabel = ReadOneByte( interp, gifConfPtr, chan ) ) ) {
 	    goto error;
 	}
 
-	switch (buf[0]) {
+	switch (gifLabel) {
 	case GIF_TERMINATOR:
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
 		    "no image data for this index", -1));
 	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "NO_DATA", NULL);
 	    goto error;
@@ -530,20 +541,16 @@
 	case GIF_EXTENSION:
 	    /*
 	     * This is a GIF extension.
 	     */
 
-	    if (Fread(gifConfPtr, buf, 1, 1, chan) != 1) {
-		Tcl_SetObjResult(interp, Tcl_NewStringObj(
-			"error reading extension function code in GIF image",
-			-1));
-		Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BAD_EXT",
-			NULL);
+	    if (-1 == (gifLabel = ReadOneByte( interp, gifConfPtr, chan ) ) ) {
 		goto error;
 	    }
-	    if (DoExtension(gifConfPtr, chan, buf[0],
-		    gifConfPtr->workingBuffer, &transparent) < 0) {
+	    if (DoExtension(gifConfPtr, chan, gifLabel,
+		    gifConfPtr->workingBuffer, &transparent, metadataOutObj)
+		    < 0) {
 		Tcl_SetObjResult(interp, Tcl_NewStringObj(
 			"error reading extension in GIF image", -1));
 		Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BAD_EXT",
 			NULL);
 		goto error;
@@ -625,10 +632,17 @@
 
 	    if (ReadImage(gifConfPtr, interp, trashBuffer, chan, imageWidth,
 		    imageHeight, colorMap, 0, 0, 0, -1) != TCL_OK) {
 		goto error;
 	    }
+
+	    /*
+	     * This extension starts a new scope, so Graphic control Extension
+	     * data should be cleared
+	     */
+	    transparent = -1;
+
 	    continue;
 	}
 	break;
     }
 
@@ -716,15 +730,57 @@
 
     /*
      * We've successfully read the GIF frame (or there was nothing to read,
      * which suits as well). We're done.
      */
+
+    while (1) {
+	if (-1 == (gifLabel = ReadOneByte( interp, gifConfPtr, chan ) ) ) {
+	    goto error;
+	}
+	switch (gifLabel) {
+	case GIF_TERMINATOR:
+	    break;
+
+	case GIF_EXTENSION:
+	    /*
+	     * This is a GIF extension.
+	     */
+
+	    if (-1 == (gifLabel = ReadOneByte( interp, gifConfPtr, chan ) ) ) {
+		goto error;
+	    }
+	    if (DoExtension(gifConfPtr, chan, gifLabel,
+		    gifConfPtr->workingBuffer, &transparent, metadataOutObj)
+		    < 0) {
+		Tcl_SetObjResult(interp, Tcl_NewStringObj(
+			"error reading extension in GIF image", -1));
+		Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BAD_EXT",
+			NULL);
+		goto error;
+	    }
+	    continue;
+	case GIF_START:
+	    /*
+	     * There should not be a second image block - bail out without error
+	     */
+	    break;
+	default:
+	    /*
+	     * Not a valid start character; ignore it.
+	     */
+
+	    continue;
+	}
+	break;
+    }
 
     Tcl_SetObjResult(interp, Tcl_NewStringObj(tkImgFmtGIF.name, -1));
     result = TCL_OK;
 
-  error:
+error:
+
     /*
      * If a trash buffer has been allocated, free it now.
      */
 
     if (trashBuffer != NULL) {
@@ -731,10 +787,49 @@
 	ckfree(trashBuffer);
     }
     return result;
 }
 
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Read one Byte --
+ *
+ *	Read one byte (label byte) from the image stream.
+ *
+ * Results:
+ *	The return value is 1 if the first characters in the data are like GIF
+ *	data, and 0 otherwise.
+ *
+ * Side effects:
+ *	The access position in the source is incremented.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+ReadOneByte(
+    Tcl_Interp *interp,		/* Interpreter to use for reporting errors. */
+    GIFImageConfig *gifConfPtr,
+    Tcl_Channel chan		/* The image file, open for reading. */
+    )
+{
+    unsigned char buf[2];
+    if (Fread(gifConfPtr, buf, 1, 1, chan) != 1) {
+        /*
+         * Premature end of image.
+         */
+
+        Tcl_SetObjResult(interp, Tcl_NewStringObj(
+		"premature end of image data", -1));
+	Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "PREMATURE_END", NULL);
+	return -1;
+    }
+    return buf[0];
+}
+
 /*
  *----------------------------------------------------------------------
  *
  * StringMatchGIF --
  *
@@ -748,26 +843,27 @@
  * Side effects:
  *	The size of the image is placed in widthPtr and heightPtr.
  *
  *----------------------------------------------------------------------
  */
+
 
 static int
 StringMatchGIF(
+    TCL_UNUSED(Tcl_Interp *),		/* not used */
     Tcl_Obj *dataObj,		/* the object containing the image data */
-    Tcl_Obj *format,		/* the image format object, or NULL */
+    TCL_UNUSED(Tcl_Obj *),		/* the image format object, or NULL */
+    TCL_UNUSED(Tcl_Obj *),	/* metadata input, may be NULL */
     int *widthPtr,		/* where to put the string width */
     int *heightPtr,		/* where to put the string height */
-    Tcl_Interp *dummy)		/* not used */
+    TCL_UNUSED(Tcl_Obj *))	/* metadata return dict, may be NULL */
 {
     unsigned char *data, header[10];
     TkSizeT got, length;
     MFile handle;
-    (void)format;
-    (void)dummy;
 
-    data = TkGetByteArrayFromObj(dataObj, &length);
+    data = Tcl_GetByteArrayFromObj(dataObj, &length);
 
     /*
      * Header is a minimum of 10 bytes.
      */
 
@@ -823,19 +919,21 @@
 static int
 StringReadGIF(
     Tcl_Interp *interp,		/* interpreter for reporting errors in */
     Tcl_Obj *dataObj,		/* object containing the image */
     Tcl_Obj *format,		/* format object, or NULL */
+    Tcl_Obj *metadataInObj,	/* metadata input, may be NULL */
     Tk_PhotoHandle imageHandle,	/* the image to write this data into */
     int destX, int destY,	/* The rectangular region of the */
     int width, int height,	/* image to copy */
-    int srcX, int srcY)
+    int srcX, int srcY,
+    Tcl_Obj *metadataOutObj)	/* metadata return dict, may be NULL */
 {
     MFile handle, *hdlPtr = &handle;
     TkSizeT length;
     const char *xferFormat;
-    unsigned char *data = TkGetByteArrayFromObj(dataObj, &length);
+    unsigned char *data = Tcl_GetByteArrayFromObj(dataObj, &length);
 
     mInit(data, hdlPtr, length);
 
     /*
      * Check whether the data is Base64 encoded by doing a character-by-
@@ -855,11 +953,12 @@
      * Fall through to the file reader now that we have a correctly-configured
      * pseudo-channel to pull the data from.
      */
 
     return FileReadGIF(interp, (Tcl_Channel) hdlPtr, xferFormat, format,
-	    imageHandle, destX, destY, width, height, srcX, srcY);
+	    metadataInObj, imageHandle, destX, destY, width, height, srcX, srcY,
+	    metadataOutObj);
 }
 
 /*
  *----------------------------------------------------------------------
  *
@@ -934,52 +1033,112 @@
 	}
     }
     return 1;
 }
 
+/*
+*----------------------------------------------------------------------
+*
+* DoExtension --
+*
+*	Process a GIF extension block
+*
+* Results:
+*	-1 to trigger an extension read error
+*       >= 0 ok
+*
+* Side effects:
+*	The transparent color is set if present in current extensions
+*       The data of the following extensions are saved to the metadata dict:
+*       - Application extension
+*         - Comment extension in key "comment"
+*       Plain text extensions are currently ignored.
+*
+*----------------------------------------------------------------------
+*/
+
 static int
 DoExtension(
     GIFImageConfig *gifConfPtr,
     Tcl_Channel chan,
     int label,
-    unsigned char *buf,
-    int *transparent)
+    unsigned char *buf, /* defined as 280 byte working buffer */
+    int *transparent,
+    Tcl_Obj *metadataOutObj)
 {
     int count;
+    /* Prepare extension name
+     * Maximum string size: "comment" + Code(3) + trailing zero
+     */
+    char extensionStreamName[8];
+    extensionStreamName[0] = '\0';
 
     switch (label) {
     case 0x01:			/* Plain Text Extension */
-	break;
-
-    case 0xff:			/* Application Extension */
-	break;
-
-    case 0xfe:			/* Comment Extension */
-	do {
-	    count = GetDataBlock(gifConfPtr, chan, buf);
-	} while (count > 0);
-	return count;
-
+	/*
+	 * This extension starts a new scope, so Graphic control Extension
+	 * data should be cleared
+	 */
+	*transparent = -1;
+	/* this extension is ignored, skip below */
+	break;
     case 0xf9:			/* Graphic Control Extension */
 	count = GetDataBlock(gifConfPtr, chan, buf);
 	if (count < 0) {
-	    return 1;
+	    return -1;
 	}
 	if ((buf[0] & 0x1) != 0) {
 	    *transparent = buf[3];
 	}
-
-	do {
+	break;
+    case 0xfe:			/* Comment Extension */
+	strcpy(extensionStreamName,"comment");
+        /* copy the extension data below */
+	break;
+    }
+    /* Add extension to dict */
+    if (NULL != metadataOutObj
+	    && extensionStreamName[0] != '\0' ) {
+	Tcl_Obj *ValueObj = NULL;
+	int length = 0;
+	for (;;) {
 	    count = GetDataBlock(gifConfPtr, chan, buf);
-	} while (count > 0);
-	return count;
+	    switch (count) {
+	    case -1: /* error */
+		return -1;
+	    case 0: /* end of data */
+		if (length > 0) {
+		    if ( TCL_OK != Tcl_DictObjPut(NULL, metadataOutObj,
+			    Tcl_NewByteArrayObj(
+				(unsigned char *)extensionStreamName,
+			    strlen(extensionStreamName)), ValueObj)) {
+			return -1;
+		    }
+		}
+		/* return success */
+		return 0;
+	    default: /* block received */
+		if (length == 0) {
+		    /* first block */
+		    ValueObj = Tcl_NewByteArrayObj(buf, count);
+		    length = count;
+		} else {
+		    /* consecutive block */
+		    unsigned char *bytePtr;
+		    bytePtr = Tcl_SetByteArrayLength(ValueObj, length+count);
+		    memcpy(bytePtr+length,buf,count);
+		    length += count;
+		}
+		break;
+	    }
+	} /* for */
     }
-
+    /* skip eventual remaining data block bytes */
     do {
 	count = GetDataBlock(gifConfPtr, chan, buf);
     } while (count > 0);
-    return count;
+    return count; /* this may be -1 for error or 0 */
 }
 
 static int
 GetDataBlock(
     GIFImageConfig *gifConfPtr,
@@ -1032,11 +1191,12 @@
     Tcl_Interp *interp,
     unsigned char *imagePtr,
     Tcl_Channel chan,
     int len, int rows,
     unsigned char cmap[MAXCOLORMAPSIZE][4],
-    int srcX, int srcY,
+    TCL_UNUSED(int),
+    TCL_UNUSED(int),
     int interlace,
     int transparent)
 {
     unsigned char initialCodeSize;
     int xpos = 0, ypos = 0, pass = 0, i, count;
@@ -1047,12 +1207,10 @@
     unsigned char append[(1 << MAX_LWZ_BITS)];
     unsigned char stack[(1 << MAX_LWZ_BITS)*2];
     unsigned char *top;
     int codeSize, clearCode, inCode, endCode, oldCode, maxCode;
     int code, firstCode, v;
-    (void)srcX;
-    (void)srcY;
 
     /*
      * Initialize the decoder
      */
 
@@ -1635,10 +1793,11 @@
 static int
 FileWriteGIF(
     Tcl_Interp *interp,		/* Interpreter to use for reporting errors. */
     const char *filename,
     Tcl_Obj *format,
+    Tcl_Obj *metadataInObj,
     Tk_PhotoImageBlock *blockPtr)
 {
     Tcl_Channel chan = NULL;
     int result;
 
@@ -1650,11 +1809,12 @@
 	    "binary") != TCL_OK) {
 	Tcl_Close(NULL, chan);
 	return TCL_ERROR;
     }
 
-    result = CommonWriteGIF(interp, chan, WriteToChannel, format, blockPtr);
+    result = CommonWriteGIF(interp, chan, WriteToChannel, format, metadataInObj,
+	    blockPtr);
 
     if (Tcl_Close(interp, chan) == TCL_ERROR) {
 	return TCL_ERROR;
     }
     return result;
@@ -1663,18 +1823,19 @@
 static int
 StringWriteGIF(
     Tcl_Interp *interp,		/* Interpreter to use for reporting errors and
 				 * returning the GIF data. */
     Tcl_Obj *format,
+    Tcl_Obj *metadataInObj,
     Tk_PhotoImageBlock *blockPtr)
 {
     int result;
     Tcl_Obj *objPtr = Tcl_NewObj();
 
     Tcl_IncrRefCount(objPtr);
     result = CommonWriteGIF(interp, objPtr, WriteToByteArray, format,
-	    blockPtr);
+	    metadataInObj, blockPtr);
     if (result == TCL_OK) {
 	Tcl_SetObjResult(interp, objPtr);
     }
     Tcl_DecrRefCount(objPtr);
     return result;
@@ -1709,19 +1870,19 @@
 static int
 CommonWriteGIF(
     Tcl_Interp *interp,
     ClientData handle,
     WriteBytesFunc *writeProc,
-    Tcl_Obj *format,
+    TCL_UNUSED(Tcl_Obj *),
+    Tcl_Obj *metadataInObj,
     Tk_PhotoImageBlock *blockPtr)
 {
     GifWriterState state;
     int resolution;
     long width, height, x;
     unsigned char c;
     unsigned int top, left;
-    (void)format;
 
     top = 0;
     left = 0;
 
     memset(&state, 0, sizeof(state));
@@ -1840,10 +2001,54 @@
     state.csize = blockPtr->height;
     Compress(resolution+1, handle, writeProc, ReadValue, &state);
 
     c = 0;
     writeProc(handle, (char *) &c, 1);
+    /*
+     * Check for metadata keys to add to file
+     */
+    if (NULL != metadataInObj) {
+	Tcl_Obj *itemData;
+
+	/*
+	 * Check and code comment block
+	 */
+
+	if (TCL_ERROR == Tcl_DictObjGet(interp, metadataInObj,
+		Tcl_NewStringObj("comment",-1),
+		&itemData)) {
+	    return TCL_ERROR;
+	}
+	if (itemData != NULL) {
+	    int length;
+	    unsigned char *comment;
+	    comment = Tcl_GetByteArrayFromObj(itemData, &length);
+	    if (length > 0) {
+		/* write comment header */
+		writeProc(handle, (char *) "\x21\xfe", 2);
+		/* write comment blocks */
+		for (;length > 0;) {
+		    int blockLength;
+		    unsigned char blockLengthChar;
+		    if (length > 255) {
+			length -=255;
+			blockLength = 255;
+		    } else {
+			blockLength = length;
+			length = 0;
+		    }
+		    blockLengthChar = (unsigned char) blockLength;
+		    writeProc(handle, (char *) &blockLengthChar, 1);
+		    writeProc(handle, (char *) comment, blockLength);
+		    comment += blockLength;
+		}
+		/* Block terminator */
+		c = 0;
+		writeProc(handle, (char *) &c, 1);
+	    }
+	}
+    }
     c = GIF_TERMINATOR;
     writeProc(handle, (char *) &c, 1);
 
     return TCL_OK;
 }

Index: generic/tkImgListFormat.c
==================================================================
--- generic/tkImgListFormat.c
+++ generic/tkImgListFormat.c
@@ -10,14 +10,14 @@
  *
  *      This image format cannot read/write files, it is meant for string
  *      data only.
  *
  *
- * Copyright (c) 1994 The Australian National University.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 2002-2003 Donal K. Fellows
- * Copyright (c) 2003 ActiveState Corporation.
+ * Copyright © 1994 The Australian National University.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2002-2003 Donal K. Fellows
+ * Copyright © 2003 ActiveState Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
  * Authors:
@@ -42,11 +42,11 @@
 /*
  * Color name length limit: do not attempt to parse as color strings that are
  * longer than this limit
  */
 
-#define TK_PHOTO_MAX_COLOR_CHARS 99
+#define TK_PHOTO_MAX_COLOR_LENGTH 99
 
 /*
  * Symbols for the different formats of a color string.
  */
 
@@ -194,12 +194,11 @@
                                        * index where parsing ended */
     struct FormatOptions *optPtr)     /* Parsed option values are written to
                                        * this struct */
 
 {
-    int index, optIndex, first;
-    enum ColorFormatType typeIndex;
+    int index, optIndex, first, typeIndex;
     const char *option;
 
     first = 1;
 
     /*
@@ -256,11 +255,11 @@
                 Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
                         "MISSING_VALUE", NULL);
                 return TCL_ERROR;
             }
             if (Tcl_GetIndexFromObj(NULL, objv[index], colorFormatNames, "",
-                    TCL_EXACT, (int *)&typeIndex) != TCL_OK
+                    TCL_EXACT, &typeIndex) != TCL_OK
                     || (typeIndex != COLORFORMAT_LIST
                     && typeIndex != COLORFORMAT_RGB2
                     && typeIndex != COLORFORMAT_RGBA2) ) {
                 Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad color format "
                         "\"%s\": must be rgb, rgba, or list",
@@ -267,11 +266,11 @@
                         Tcl_GetString(objv[index])));
                 Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
                         "BAD_COLOR_FORMAT", NULL);
                 return TCL_ERROR;
             }
-            optPtr->colorFormat = typeIndex;
+            optPtr->colorFormat = (enum ColorFormatType)typeIndex;
             break;
         default:
             Tcl_Panic("ParseFormatOptions: unexpected switch fallthrough");
         }
 
@@ -411,11 +410,12 @@
      * pixel for validity.
      */
     if (Tcl_ListObjIndex(interp, rowListPtr[0], 0, &pixelData) != TCL_OK) {
         return 0;
     }
-    if (Tcl_GetCharLength(pixelData) > TK_PHOTO_MAX_COLOR_CHARS) {
+    (void)Tcl_GetString(pixelData);
+    if (pixelData->length > TK_PHOTO_MAX_COLOR_LENGTH) {
         return 0;
     }
     if (ParseColor(interp, pixelData, Tk_Display(Tk_MainWindow(interp)),
             Tk_Colormap(Tk_MainWindow(interp)), &dummy, &dummy, &dummy, &dummy)
             != TCL_OK) {
@@ -773,34 +773,34 @@
     unsigned char *greenPtr,
     unsigned char *bluePtr,
     unsigned char *alphaPtr)
 {
     const char *specString;
-    TkSizeT charCount;
+    TkSizeT length;
 
     /*
      * Find out which color format we have
      */
 
-    specString = TkGetStringFromObj(specObj, &charCount);
+    specString = Tcl_GetStringFromObj(specObj, &length);
 
-    if (charCount == 0) {
+    if (length == 0) {
         /* Empty string */
         *redPtr = *greenPtr = *bluePtr = *alphaPtr = 0;
         return TCL_OK;
     }
-    if (charCount > TK_PHOTO_MAX_COLOR_CHARS) {
+    if (length > TK_PHOTO_MAX_COLOR_LENGTH) {
         Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid color"));
         Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
                 "INVALID_COLOR", NULL);
         return TCL_ERROR;
     }
     if (specString[0] == '#') {
-        return ParseColorAsHex(interp, specString, charCount, display,
+        return ParseColorAsHex(interp, specString, length, display,
                 colormap, redPtr, greenPtr, bluePtr, alphaPtr);
     }
-    if (ParseColorAsList(interp, specString, charCount,
+    if (ParseColorAsList(interp, specString, length,
             redPtr, greenPtr, bluePtr, alphaPtr) == TCL_OK) {
         return TCL_OK;
     }
 
     /*
@@ -807,11 +807,11 @@
      * Parsing the color as standard Tk color always is the last option tried
      * because TkParseColor() is very slow with values it cannot parse.
      */
 
     Tcl_ResetResult(interp);
-    return ParseColorAsStandard(interp, specString, charCount, display,
+    return ParseColorAsStandard(interp, specString, length, display,
             colormap, redPtr, greenPtr, bluePtr, alphaPtr);
 
 }
 
 /*
@@ -1003,11 +1003,11 @@
     unsigned char *bluePtr,
     unsigned char *alphaPtr)
 {
     XColor parsedColor;
     const char *suffixString, *colorString;
-    char colorBuffer[TK_PHOTO_MAX_COLOR_CHARS + 1];
+    char colorBuffer[TK_PHOTO_MAX_COLOR_LENGTH + 1];
     char *tmpString;
     double fracAlpha;
     unsigned int suffixAlpha;
     int i;
 

Index: generic/tkImgPNG.c
==================================================================
--- generic/tkImgPNG.c
+++ generic/tkImgPNG.c
@@ -1,21 +1,21 @@
 /*
  * tkImgPNG.c --
  *
  *	A Tk photo image file handler for PNG files.
  *
- * Copyright (c) 2006-2008 Muonics, Inc.
- * Copyright (c) 2008 Donal K. Fellows
+ * Copyright © 2006-2008 Muonics, Inc.
+ * Copyright © 2008 Donal K. Fellows
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
 #include "tkInt.h"
 
-#define	PNG_INT32(a,b,c,d)	\
-	(((long)(a) << 24) | ((long)(b) << 16) | ((long)(c) << 8) | (long)(d))
+#define	PNG_UINT32(a,b,c,d)	\
+	(((unsigned long)(a) << 24) | ((unsigned long)(b) << 16) | ((unsigned long)(c) << 8) | (unsigned long)(d))
 #define	PNG_BLOCK_SZ	1024		/* Process up to 1k at a time. */
 #define PNG_MIN(a, b) (((a) < (b)) ? (a) : (b))
 
 /*
  * Every PNG image starts with the following 8-byte signature.
@@ -43,39 +43,39 @@
  * Chunk types, not all of which have support implemented. Note that there are
  * others in the official extension set which we will never support (as they
  * are officially deprecated).
  */
 
-#define CHUNK_IDAT	PNG_INT32('I','D','A','T')	/* Pixel data. */
-#define CHUNK_IEND	PNG_INT32('I','E','N','D')	/* End of Image. */
-#define CHUNK_IHDR	PNG_INT32('I','H','D','R')	/* Header. */
-#define CHUNK_PLTE	PNG_INT32('P','L','T','E')	/* Palette. */
-
-#define CHUNK_bKGD	PNG_INT32('b','K','G','D')	/* Background Color */
-#define CHUNK_cHRM	PNG_INT32('c','H','R','M')	/* Chroma values. */
-#define CHUNK_gAMA	PNG_INT32('g','A','M','A')	/* Gamma. */
-#define CHUNK_hIST	PNG_INT32('h','I','S','T')	/* Histogram. */
-#define CHUNK_iCCP	PNG_INT32('i','C','C','P')	/* Color profile. */
-#define CHUNK_iTXt	PNG_INT32('i','T','X','t')	/* Internationalized
+#define CHUNK_IDAT	PNG_UINT32('I','D','A','T')	/* Pixel data. */
+#define CHUNK_IEND	PNG_UINT32('I','E','N','D')	/* End of Image. */
+#define CHUNK_IHDR	PNG_UINT32('I','H','D','R')	/* Header. */
+#define CHUNK_PLTE	PNG_UINT32('P','L','T','E')	/* Palette. */
+
+#define CHUNK_bKGD	PNG_UINT32('b','K','G','D')	/* Background Color */
+#define CHUNK_cHRM	PNG_UINT32('c','H','R','M')	/* Chroma values. */
+#define CHUNK_gAMA	PNG_UINT32('g','A','M','A')	/* Gamma. */
+#define CHUNK_hIST	PNG_UINT32('h','I','S','T')	/* Histogram. */
+#define CHUNK_iCCP	PNG_UINT32('i','C','C','P')	/* Color profile. */
+#define CHUNK_iTXt	PNG_UINT32('i','T','X','t')	/* Internationalized
 							 * text (comments,
 							 * etc.) */
-#define CHUNK_oFFs	PNG_INT32('o','F','F','s')	/* Image offset. */
-#define CHUNK_pCAL	PNG_INT32('p','C','A','L')	/* Pixel calibration
+#define CHUNK_oFFs	PNG_UINT32('o','F','F','s')	/* Image offset. */
+#define CHUNK_pCAL	PNG_UINT32('p','C','A','L')	/* Pixel calibration
 							 * data. */
-#define CHUNK_pHYs	PNG_INT32('p','H','Y','s')	/* Physical pixel
+#define CHUNK_pHYs	PNG_UINT32('p','H','Y','s')	/* Physical pixel
 							 * dimensions. */
-#define CHUNK_sBIT	PNG_INT32('s','B','I','T')	/* Significant bits */
-#define CHUNK_sCAL	PNG_INT32('s','C','A','L')	/* Physical scale. */
-#define CHUNK_sPLT	PNG_INT32('s','P','L','T')	/* Suggested
+#define CHUNK_sBIT	PNG_UINT32('s','B','I','T')	/* Significant bits */
+#define CHUNK_sCAL	PNG_UINT32('s','C','A','L')	/* Physical scale. */
+#define CHUNK_sPLT	PNG_UINT32('s','P','L','T')	/* Suggested
 							 * palette. */
-#define CHUNK_sRGB	PNG_INT32('s','R','G','B')	/* Standard RGB space
+#define CHUNK_sRGB	PNG_UINT32('s','R','G','B')	/* Standard RGB space
 							 * declaration. */
-#define CHUNK_tEXt	PNG_INT32('t','E','X','t')	/* Plain Latin-1
+#define CHUNK_tEXt	PNG_UINT32('t','E','X','t')	/* Plain Latin-1
 							 * text. */
-#define CHUNK_tIME	PNG_INT32('t','I','M','E')	/* Time stamp. */
-#define CHUNK_tRNS	PNG_INT32('t','R','N','S')	/* Transparency. */
-#define CHUNK_zTXt	PNG_INT32('z','T','X','t')	/* Compressed Latin-1
+#define CHUNK_tIME	PNG_UINT32('t','I','M','E')	/* Time stamp. */
+#define CHUNK_tRNS	PNG_UINT32('t','R','N','S')	/* Transparency. */
+#define CHUNK_zTXt	PNG_UINT32('z','T','X','t')	/* Compressed Latin-1
 							 * text. */
 
 /*
  * Color flags.
  */
@@ -173,10 +173,19 @@
 				 * not bound to a Tcl command. */
     Tcl_Obj *lastLineObj;	/* Last line of pixels, for unfiltering. */
     Tcl_Obj *thisLineObj;	/* Current line of pixels to process. */
     int lineSize;		/* Number of bytes in a PNG line. */
     int phaseSize;		/* Number of bytes/line in current phase. */
+
+
+    /*
+     * Physical size: pHYS chunks.
+     */
+
+    double DPI;
+    double aspect;
+
 } PNGImage;
 
 /*
  * Maximum size of various chunks.
  */
@@ -196,20 +205,24 @@
 static int		DecodeLine(Tcl_Interp *interp, PNGImage *pngPtr);
 static int		DecodePNG(Tcl_Interp *interp, PNGImage *pngPtr,
 			    Tcl_Obj *fmtObj, Tk_PhotoHandle imageHandle,
 			    int destX, int destY);
 static int		EncodePNG(Tcl_Interp *interp,
-			    Tk_PhotoImageBlock *blockPtr, PNGImage *pngPtr);
-static int		FileMatchPNG(Tcl_Channel chan, const char *fileName,
-			    Tcl_Obj *fmtObj, int *widthPtr, int *heightPtr,
-			    Tcl_Interp *interp);
+			    Tk_PhotoImageBlock *blockPtr, PNGImage *pngPtr,
+			    Tcl_Obj *metadataInObj);
+static int		FileMatchPNG(Tcl_Interp *interp, Tcl_Channel chan,
+			    const char *fileName, Tcl_Obj *fmtObj,
+			    Tcl_Obj *metadataInObj, int *widthPtr,
+			    int *heightPtr, Tcl_Obj *metadataOut);
 static int		FileReadPNG(Tcl_Interp *interp, Tcl_Channel chan,
 			    const char *fileName, Tcl_Obj *fmtObj,
-			    Tk_PhotoHandle imageHandle, int destX, int destY,
-			    int width, int height, int srcX, int srcY);
+			    Tcl_Obj *metadataInObj, Tk_PhotoHandle imageHandle,
+			    int destX, int destY, int width, int height,
+			    int srcX, int srcY, Tcl_Obj *metadataOutPtr);
 static int		FileWritePNG(Tcl_Interp *interp, const char *filename,
-			    Tcl_Obj *fmtObj, Tk_PhotoImageBlock *blockPtr);
+			    Tcl_Obj *fmtObj, Tcl_Obj *metadataInObj,
+			    Tk_PhotoImageBlock *blockPtr);
 static int		InitPNGImage(Tcl_Interp *interp, PNGImage *pngPtr,
 			    Tcl_Channel chan, Tcl_Obj *objPtr, int dir);
 static inline unsigned char Paeth(int a, int b, int c);
 static int		ParseFormat(Tcl_Interp *interp, Tcl_Obj *fmtObj,
 			    PNGImage *pngPtr);
@@ -234,18 +247,22 @@
 			    int chunkSz, unsigned long crc);
 static int		ReadTRNS(Tcl_Interp *interp, PNGImage *pngPtr,
 			    int chunkSz, unsigned long crc);
 static int		SkipChunk(Tcl_Interp *interp, PNGImage *pngPtr,
 			    int chunkSz, unsigned long crc);
-static int		StringMatchPNG(Tcl_Obj *dataObj, Tcl_Obj *fmtObj,
+static int		StringMatchPNG(Tcl_Interp *interp, Tcl_Obj *pObjData,
+			    Tcl_Obj *fmtObj, Tcl_Obj *metadataInObj,
 			    int *widthPtr, int *heightPtr,
-			    Tcl_Interp *interp);
-static int		StringReadPNG(Tcl_Interp *interp, Tcl_Obj *dataObj,
-			    Tcl_Obj *fmtObj, Tk_PhotoHandle imageHandle,
+			    Tcl_Obj *metadataOutObj);
+static int		StringReadPNG(Tcl_Interp *interp, Tcl_Obj *pObjData,
+			    Tcl_Obj *fmtObj, Tcl_Obj *metadataInObj,
+			    Tk_PhotoHandle imageHandle,
 			    int destX, int destY, int width, int height,
-			    int srcX, int srcY);
+			    int srcX, int srcY, Tcl_Obj *metadataOutObj);
+
 static int		StringWritePNG(Tcl_Interp *interp, Tcl_Obj *fmtObj,
+			    Tcl_Obj *metadataInObj,
 			    Tk_PhotoImageBlock *blockPtr);
 static int		UnfilterLine(Tcl_Interp *interp, PNGImage *pngPtr);
 static inline int	WriteByte(Tcl_Interp *interp, PNGImage *pngPtr,
 			    unsigned char c, unsigned long *crcPtr);
 static inline int	WriteChunk(Tcl_Interp *interp, PNGImage *pngPtr,
@@ -253,11 +270,11 @@
 			    const unsigned char *dataPtr, size_t dataSize);
 static int		WriteData(Tcl_Interp *interp, PNGImage *pngPtr,
 			    const unsigned char *srcPtr, size_t srcSz,
 			    unsigned long *crcPtr);
 static int		WriteExtraChunks(Tcl_Interp *interp,
-			    PNGImage *pngPtr);
+			    PNGImage *pngPtr, Tcl_Obj *metadataInObj);
 static int		WriteIHDR(Tcl_Interp *interp, PNGImage *pngPtr,
 			    Tk_PhotoImageBlock *blockPtr);
 static int		WriteIDAT(Tcl_Interp *interp, PNGImage *pngPtr,
 			    Tk_PhotoImageBlock *blockPtr);
 static inline int	WriteInt32(Tcl_Interp *interp, PNGImage *pngPtr,
@@ -265,11 +282,11 @@
 
 /*
  * The format record for the PNG file format:
  */
 
-Tk_PhotoImageFormat tkImgFmtPNG = {
+Tk_PhotoImageFormatVersion3 tkImgFmtPNG = {
     "png",			/* name */
     FileMatchPNG,		/* fileMatchProc */
     StringMatchPNG,		/* stringMatchProc */
     FileReadPNG,		/* fileReadProc */
     StringReadPNG,		/* stringReadProc */
@@ -317,11 +334,11 @@
 
     if (objPtr) {
 	Tcl_IncrRefCount(objPtr);
 	pngPtr->objDataPtr = objPtr;
 	pngPtr->strDataBuf =
-		TkGetByteArrayFromObj(objPtr, &pngPtr->strDataLen);
+		Tcl_GetByteArrayFromObj(objPtr, &pngPtr->strDataLen);
     }
 
     /*
      * Initialize the palette transparency table to fully opaque.
      */
@@ -343,10 +360,17 @@
 	    Tcl_DecrRefCount(objPtr);
 	}
 	return TCL_ERROR;
     }
 
+    /*
+     * Initialize physical size pHYS values
+     */
+
+    pngPtr->DPI = -1;
+    pngPtr->aspect = -1;
+
     return TCL_OK;
 }
 
 /*
  *----------------------------------------------------------------------
@@ -692,11 +716,11 @@
 
     if (ReadData(interp, pngPtr, p, 4, crcPtr) == TCL_ERROR) {
 	return TCL_ERROR;
     }
 
-    *resultPtr = PNG_INT32(p[0], p[1], p[2], p[3]);
+    *resultPtr = PNG_UINT32(p[0], p[1], p[2], p[3]);
 
     return TCL_OK;
 }
 
 /*
@@ -884,11 +908,11 @@
 
 	if (ReadData(interp, pngPtr, pc, 4, NULL) == TCL_ERROR) {
 	    return TCL_ERROR;
 	}
 
-	temp = PNG_INT32(pc[0], pc[1], pc[2], pc[3]);
+	temp = PNG_UINT32(pc[0], pc[1], pc[2], pc[3]);
 
 	if (temp > INT_MAX) {
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
 		    "chunk size is out of supported range on this architecture",
 		    -1));
@@ -909,11 +933,11 @@
 
 	/*
 	 * Convert it to a host-order integer for simple comparison.
 	 */
 
-	chunkType = PNG_INT32(pc[0], pc[1], pc[2], pc[3]);
+	chunkType = PNG_UINT32(pc[0], pc[1], pc[2], pc[3]);
 
 	/*
 	 * Check to see if this is a known/supported chunk type. Note that the
 	 * PNG specs require non-critical (i.e., ancillary) chunk types that
 	 * are not recognized to be ignored, rather than be treated as an
@@ -931,10 +955,11 @@
 	     */
 
 	case CHUNK_IDAT:
 	case CHUNK_IEND:
 	case CHUNK_IHDR:
+	case CHUNK_pHYs:
 	case CHUNK_PLTE:
 	case CHUNK_tRNS:
 	    break;
 
 	    /*
@@ -949,11 +974,10 @@
 	case CHUNK_hIST:
 	case CHUNK_iCCP:
 	case CHUNK_iTXt:
 	case CHUNK_oFFs:
 	case CHUNK_pCAL:
-	case CHUNK_pHYs:
 	case CHUNK_sBIT:
 	case CHUNK_sCAL:
 	case CHUNK_sPLT:
 	case CHUNK_sRGB:
 	case CHUNK_tEXt:
@@ -974,11 +998,11 @@
 	    /*
 	     * Unknown chunk type. If it's critical, we can't continue.
 	     */
 
 	    if (!(chunkType & PNG_CF_ANCILLARY)) {
-		if (chunkType & PNG_INT32(128,128,128,128)) {
+		if (chunkType & PNG_UINT32(128,128,128,128)) {
 		    /*
 		     * No nice ASCII conversion; shouldn't happen either, but
 		     * we'll be doubly careful.
 		     */
 
@@ -1261,11 +1285,11 @@
     /*
      * If reading from string, reset position and try base64 decode.
      */
 
     if (mismatch && pngPtr->strDataBuf) {
-	pngPtr->strDataBuf = TkGetByteArrayFromObj(pngPtr->objDataPtr,
+	pngPtr->strDataBuf = Tcl_GetByteArrayFromObj(pngPtr->objDataPtr,
 		&pngPtr->strDataLen);
 	pngPtr->base64Data = pngPtr->strDataBuf;
 
 	if (ReadData(interp, pngPtr, sigBuf, PNG_SIG_SZ, NULL) == TCL_ERROR) {
 	    return TCL_ERROR;
@@ -1641,10 +1665,88 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
+ * ReadPHYS --
+ *
+ *	This function reads the PHYS (physical size) chunk data from
+ *	the PNG file and populates the fields in the PNGImage
+ *	structure.
+ *
+ * Results:
+ *	TCL_OK, or TCL_ERROR if an I/O error occurs or the PHYS chunk is
+ *	invalid.
+ *
+ * Side effects:
+ *	The access position in f advances.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+ReadPHYS(
+    Tcl_Interp *interp,
+    PNGImage *pngPtr,
+    int chunkSz,
+    unsigned long crc)
+{
+    unsigned long PPUx, PPUy;
+    char unitSpecifier;
+
+    /*
+     * Check chunk size equal 9 bytes
+     */
+
+    if (chunkSz != 9) {
+	Tcl_SetObjResult(interp, Tcl_NewStringObj(
+		"invalid physical chunk size", -1));
+	Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_PHYS", NULL);
+	return TCL_ERROR;
+    }
+
+    /*
+     * Read the chunk data
+     * 4 bytes: Pixels per unit, x axis
+     * 4 bytes: Pixels per unit, y axis
+     * 1 byte: unit specifier
+     */
+
+    if (ReadInt32(interp, pngPtr, &PPUx, &crc) == TCL_ERROR) {
+	return TCL_ERROR;
+    }
+    if (ReadInt32(interp, pngPtr, &PPUy, &crc) == TCL_ERROR) {
+	return TCL_ERROR;
+    }
+    if (ReadData(interp, pngPtr, (unsigned char *)&unitSpecifier, 1, &crc) == TCL_ERROR) {
+	return TCL_ERROR;
+    }
+
+    if (CheckCRC(interp, pngPtr, crc) == TCL_ERROR) {
+	return TCL_ERROR;
+    }
+
+    if ( PPUx > 2147483647 || PPUy > 2147483647
+	    || unitSpecifier > 1 ) {
+	Tcl_SetObjResult(interp, Tcl_NewStringObj(
+		"invalid physical size value", -1));
+	Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_PHYS", NULL);
+	return TCL_ERROR;
+    }
+
+    if (PPUx > 0) {
+	pngPtr->aspect = ((double) PPUy) / ((double) PPUx);
+    }
+    if (1 == unitSpecifier) {
+	pngPtr->DPI = ((double) PPUx) * 0.0254;
+    }
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
  * Paeth --
  *
  *	Utility function for applying the Paeth filter to a pixel. The Paeth
  *	filter is a linear function of the pixel to be filtered and the pixels
  *	to the left, above, and above-left of the pixel to be unfiltered.
@@ -1706,13 +1808,13 @@
 UnfilterLine(
     Tcl_Interp *interp,
     PNGImage *pngPtr)
 {
     unsigned char *thisLine =
-	    Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, NULL);
+	    Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, (int *)NULL);
     unsigned char *lastLine =
-	    Tcl_GetByteArrayFromObj(pngPtr->lastLineObj, NULL);
+	    Tcl_GetByteArrayFromObj(pngPtr->lastLineObj, (int *)NULL);
 
 #define	PNG_FILTER_NONE		0
 #define	PNG_FILTER_SUB		1
 #define	PNG_FILTER_UP		2
 #define	PNG_FILTER_AVG		3
@@ -1838,11 +1940,11 @@
     int shifts = 0;		/* Number of channels extracted from byte */
     int offset = 0;		/* Current offset into pixelPtr */
     int colStep = 1;		/* Column increment each pass */
     int pixStep = 0;		/* extra pixelPtr increment each pass */
     unsigned char lastPixel[6];
-    unsigned char *p = Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, NULL);
+    unsigned char *p = Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, (int *)NULL);
 
     p++;
     if (UnfilterLine(interp, pngPtr) == TCL_ERROR) {
 	return TCL_ERROR;
     }
@@ -2144,16 +2246,16 @@
 	 * Inflate, processing each output buffer's worth as a line of pixels,
 	 * until we cannot fill the buffer any more.
 	 */
 
     getNextLine:
-	TkGetByteArrayFromObj(pngPtr->thisLineObj, &len1);
+	Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, &len1);
 	if (Tcl_ZlibStreamGet(pngPtr->stream, pngPtr->thisLineObj,
 		pngPtr->phaseSize - len1) == TCL_ERROR) {
 	    return TCL_ERROR;
 	}
-	TkGetByteArrayFromObj(pngPtr->thisLineObj, &len2);
+	Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, &len2);
 
 	if (len2 == (TkSizeT)pngPtr->phaseSize) {
 	    if (pngPtr->phase > 7) {
 		Tcl_SetObjResult(interp, Tcl_NewStringObj(
 			"extra data after final scan line of final phase",
@@ -2412,10 +2514,33 @@
 
     if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType,
 	    &crc) == TCL_ERROR) {
 	return TCL_ERROR;
     }
+
+    /*
+     * Physical header may be present here so try to parse it
+     */
+
+    if (CHUNK_pHYs == chunkType) {
+	/*
+	 * Finish parsing the PHYS chunk.
+	 */
+
+	if (ReadPHYS(interp, pngPtr, chunkSz, crc) == TCL_ERROR) {
+	    return TCL_ERROR;
+	}
+
+	/*
+	 * Begin the next chunk.
+	 */
+
+	if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType,
+		&crc) == TCL_ERROR) {
+	    return TCL_ERROR;
+	}
+    }
 
     if (CHUNK_PLTE == chunkType) {
 	/*
 	 * Finish parsing the PLTE chunk.
 	 */
@@ -2452,10 +2577,33 @@
 	 */
 
 	if (ReadTRNS(interp, pngPtr, chunkSz, crc) == TCL_ERROR) {
 	    return TCL_ERROR;
 	}
+
+	/*
+	 * Begin the next chunk.
+	 */
+
+	if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType,
+		&crc) == TCL_ERROR) {
+	    return TCL_ERROR;
+	}
+    }
+
+    /*
+     * Physical header may be present here so try to parse it
+     */
+
+    if (CHUNK_pHYs == chunkType) {
+	/*
+	 * Finish parsing the PHYS chunk.
+	 */
+
+	if (ReadPHYS(interp, pngPtr, chunkSz, crc) == TCL_ERROR) {
+	    return TCL_ERROR;
+	}
 
 	/*
 	 * Begin the next chunk.
 	 */
 
@@ -2665,21 +2813,22 @@
  *----------------------------------------------------------------------
  */
 
 static int
 FileMatchPNG(
-    Tcl_Channel chan,
-    const char *fileName,
-    Tcl_Obj *fmtObj,
-    int *widthPtr,
-    int *heightPtr,
-    Tcl_Interp *interp)
+    Tcl_Interp *interp,		/* Interpreter to use for reporting errors. */
+    Tcl_Channel chan,		/* The image file, open for reading. */
+    TCL_UNUSED(const char *),	/* The name of the image file. */
+    TCL_UNUSED(Tcl_Obj *),	/* User-specified format object, or NULL. */
+    TCL_UNUSED(Tcl_Obj *),	/* metadata input, may be NULL */
+    int *widthPtr, int *heightPtr,
+				/* The dimensions of the image are returned
+				 * here if the file is a valid raw GIF file. */
+    TCL_UNUSED(Tcl_Obj *))	/* metadata return dict, may be NULL */
 {
     PNGImage png;
     int match = 0;
-    (void)fileName;
-    (void)fmtObj;
 
     InitPNGImage(NULL, &png, chan, NULL, TCL_ZLIB_STREAM_INFLATE);
 
     if (ReadIHDR(interp, &png) == TCL_OK) {
 	*widthPtr = png.block.width;
@@ -2711,35 +2860,46 @@
  *----------------------------------------------------------------------
  */
 
 static int
 FileReadPNG(
-    Tcl_Interp *interp,
-    Tcl_Channel chan,
-    const char *fileName,
-    Tcl_Obj *fmtObj,
-    Tk_PhotoHandle imageHandle,
-    int destX,
-    int destY,
-    int width,
-    int height,
-    int srcX,
-    int srcY)
+    Tcl_Interp *interp,		/* Interpreter to use for reporting errors. */
+    Tcl_Channel chan,		/* The image file, open for reading. */
+    TCL_UNUSED(const char *),	/* The name of the image file. */
+    Tcl_Obj *fmtObj,		/* User-specified format object, or NULL. */
+    TCL_UNUSED(Tcl_Obj *),	/* metadata input, may be NULL */
+    Tk_PhotoHandle imageHandle,	/* The photo image to write into. */
+    int destX, int destY,	/* Coordinates of top-left pixel in photo
+				 * image to be written to. */
+    TCL_UNUSED(int),		/* Dimensions of block of photo image to be
+				 * written to. */
+    TCL_UNUSED(int),
+    TCL_UNUSED(int),		/* Coordinates of top-left pixel to be used in
+				 * image being read. */
+    TCL_UNUSED(int),
+    Tcl_Obj *metadataOutObj)	/* metadata return dict, may be NULL */
 {
     PNGImage png;
     int result = TCL_ERROR;
-    (void)fileName;
-    (void)width;
-    (void)height;
-    (void)srcX;
-    (void)srcY;
 
     result = InitPNGImage(interp, &png, chan, NULL, TCL_ZLIB_STREAM_INFLATE);
 
     if (TCL_OK == result) {
 	result = DecodePNG(interp, &png, fmtObj, imageHandle, destX, destY);
     }
+
+    if (TCL_OK == result && metadataOutObj != NULL && png.DPI != -1) {
+	result = Tcl_DictObjPut(NULL, metadataOutObj,
+		Tcl_NewStringObj("DPI",-1),
+		Tcl_NewDoubleObj(png.DPI));
+    }
+
+    if (TCL_OK == result && metadataOutObj != NULL && png.aspect != -1) {
+	result = Tcl_DictObjPut(NULL, metadataOutObj,
+		Tcl_NewStringObj("aspect",-1),
+		Tcl_NewDoubleObj(png.aspect));
+    }
 
     CleanupPNGImage(&png);
     return result;
 }
 
@@ -2761,23 +2921,24 @@
  *----------------------------------------------------------------------
  */
 
 static int
 StringMatchPNG(
-    Tcl_Obj *pObjData,
-    Tcl_Obj *fmtObj,
-    int *widthPtr,
-    int *heightPtr,
-    Tcl_Interp *interp)
+    Tcl_Interp *interp,		/* Interpreter to use for reporting errors. */
+    Tcl_Obj *pObjData,		/* the object containing the image data */
+    TCL_UNUSED(Tcl_Obj *),	/* the image format object, or NULL */
+    TCL_UNUSED(Tcl_Obj *),	/* metadata input, may be NULL */
+    int *widthPtr,		/* where to put the string width */
+    int *heightPtr,		/* where to put the string height */
+    TCL_UNUSED(Tcl_Obj *))	/* metadata return dict, may be NULL */
 {
     PNGImage png;
     int match = 0;
-    (void)fmtObj;
 
     InitPNGImage(NULL, &png, NULL, pObjData, TCL_ZLIB_STREAM_INFLATE);
 
-    png.strDataBuf = TkGetByteArrayFromObj(pObjData, &png.strDataLen);
+    png.strDataBuf = Tcl_GetByteArrayFromObj(pObjData, &png.strDataLen);
 
     if (ReadIHDR(interp, &png) == TCL_OK) {
 	*widthPtr = png.block.width;
 	*heightPtr = png.block.height;
 	match = 1;
@@ -2805,34 +2966,43 @@
  *----------------------------------------------------------------------
  */
 
 static int
 StringReadPNG(
-    Tcl_Interp *interp,
-    Tcl_Obj *pObjData,
-    Tcl_Obj *fmtObj,
-    Tk_PhotoHandle imageHandle,
-    int destX,
-    int destY,
-    int width,
-    int height,
-    int srcX,
-    int srcY)
+    Tcl_Interp *interp,		/* interpreter for reporting errors in */
+    Tcl_Obj *pObjData,		/* object containing the image */
+    Tcl_Obj *fmtObj,		/* format object, or NULL */
+    TCL_UNUSED(Tcl_Obj *),	/* metadata input, may be NULL */
+    Tk_PhotoHandle imageHandle,	/* the image to write this data into */
+    int destX, int destY,	/* The rectangular region of the */
+    TCL_UNUSED(int),		/* image to copy */
+    TCL_UNUSED(int),
+    TCL_UNUSED(int),
+    TCL_UNUSED(int),
+    Tcl_Obj *metadataOutObj)	/* metadata return dict, may be NULL */
 {
     PNGImage png;
     int result = TCL_ERROR;
-    (void)width;
-    (void)height;
-    (void)srcX;
-    (void)srcY;
 
     result = InitPNGImage(interp, &png, NULL, pObjData,
 	    TCL_ZLIB_STREAM_INFLATE);
 
     if (TCL_OK == result) {
 	result = DecodePNG(interp, &png, fmtObj, imageHandle, destX, destY);
     }
+
+    if (TCL_OK == result && metadataOutObj != NULL && png.DPI != -1) {
+	result = Tcl_DictObjPut(NULL, metadataOutObj,
+		Tcl_NewStringObj("DPI",-1),
+		Tcl_NewDoubleObj(png.DPI));
+    }
+
+    if (TCL_OK == result && metadataOutObj != NULL && png.aspect != -1) {
+	result = Tcl_DictObjPut(NULL, metadataOutObj,
+		Tcl_NewStringObj("aspect",-1),
+		Tcl_NewDoubleObj(png.aspect));
+    }
 
     CleanupPNGImage(&png);
     return result;
 }
 
@@ -2875,11 +3045,11 @@
 
     if (pngPtr->objDataPtr) {
 	TkSizeT objSz;
 	unsigned char *destPtr;
 
-	TkGetByteArrayFromObj(pngPtr->objDataPtr, &objSz);
+	Tcl_GetByteArrayFromObj(pngPtr->objDataPtr, &objSz);
 
 	if (objSz + srcSz > INT_MAX) {
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
 		    "image too large to store completely in byte array", -1));
 	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "TOO_LARGE", NULL);
@@ -2916,10 +3086,38 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
+ * LongToInt32 --
+ *
+ *	This function transforms to a 32-bit integer value as
+ *	four bytes in network byte order.
+ *
+ * Results:
+ *	None
+ *
+ * Side effects:
+ *	Buffer will be modified.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static inline void
+LongToInt32(
+    unsigned long l,
+    unsigned char *pc)
+{
+    pc[0] = (unsigned char) ((l & 0xff000000) >> 24);
+    pc[1] = (unsigned char) ((l & 0x00ff0000) >> 16);
+    pc[2] = (unsigned char) ((l & 0x0000ff00) >> 8);
+    pc[3] = (unsigned char) ((l & 0x000000ff) >> 0);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
  * WriteInt32 --
  *
  *	This function writes a 32-bit integer value out to the PNG image as
  *	four bytes in network byte order.
  *
@@ -2938,16 +3136,11 @@
     PNGImage *pngPtr,
     unsigned long l,
     unsigned long *crcPtr)
 {
     unsigned char pc[4];
-
-    pc[0] = (unsigned char) ((l & 0xff000000) >> 24);
-    pc[1] = (unsigned char) ((l & 0x00ff0000) >> 16);
-    pc[2] = (unsigned char) ((l & 0x0000ff00) >> 8);
-    pc[3] = (unsigned char) ((l & 0x000000ff) >> 0);
-
+    LongToInt32(l,pc);
     return WriteData(interp, pngPtr, pc, 4, crcPtr);
 }
 
 /*
  *----------------------------------------------------------------------
@@ -3236,11 +3429,11 @@
      * Now get the compressed data and write it as one big IDAT chunk.
      */
 
     outputObj = Tcl_NewObj();
     (void) Tcl_ZlibStreamGet(pngPtr->stream, outputObj, -1);
-    outputBytes = TkGetByteArrayFromObj(outputObj, &outputSize);
+    outputBytes = Tcl_GetByteArrayFromObj(outputObj, &outputSize);
     result = WriteChunk(interp, pngPtr, CHUNK_IDAT, outputBytes, outputSize);
     Tcl_DecrRefCount(outputObj);
     return result;
 }
 
@@ -3262,11 +3455,12 @@
  */
 
 static int
 WriteExtraChunks(
     Tcl_Interp *interp,
-    PNGImage *pngPtr)
+    PNGImage *pngPtr,
+    Tcl_Obj *metadataInObj)
 {
     static const unsigned char sBIT_contents[] = {
 	8, 8, 8, 8
     };
     int sBIT_length = 4;
@@ -3314,10 +3508,83 @@
 	Tcl_DStringFree(&buf);
 	return TCL_ERROR;
     }
     Tcl_DStringFree(&buf);
 
+    /*
+     * Add a pHYs chunk if there is metadata for DPI and/or aspect
+     * aspect = PPUy / PPUx
+     * DPI = PPUx * 0.0254
+     * The physical chunk consists of:
+     * - Points per meter in x direction (32 bit)
+     * - Points per meter in x direction (32 bit)
+     * - Unit specifier: 0: no unit (only aspect), 1: Points per meter
+     */
+
+    if (metadataInObj != NULL) {
+
+	Tcl_Obj *aspectObj, *DPIObj;
+	double aspectValue=-1, DPIValue=-1;
+	unsigned long PPUx = 65536, PPUy = 65536;
+	char unitSpecifier;
+
+	if (TCL_ERROR == Tcl_DictObjGet(interp, metadataInObj,
+		Tcl_NewStringObj("aspect",-1),
+		&aspectObj) ||
+	    TCL_ERROR == Tcl_DictObjGet(interp, metadataInObj,
+		Tcl_NewStringObj("DPI",-1),
+		&DPIObj) ) {
+	    return TCL_ERROR;
+	}
+	if (DPIObj != NULL) {
+	    if (TCL_ERROR == Tcl_GetDoubleFromObj(interp, DPIObj, &DPIValue))
+	    {
+		return TCL_ERROR;
+	    }
+	    PPUx = (unsigned long)floor(DPIValue / 0.0254+0.5);
+	    if (aspectObj == NULL) {
+		PPUy = PPUx;
+	    }
+	    unitSpecifier = 1;
+	}
+	if (aspectObj != NULL) {
+	    if (TCL_ERROR == Tcl_GetDoubleFromObj(interp, aspectObj,
+		    &aspectValue)) {
+		return TCL_ERROR;
+	    }
+
+	    /*
+	     * aspect = PPUy / PPUx
+	     */
+
+	    if (DPIObj == NULL) {
+		unitSpecifier = 0;
+		PPUx = 65536;
+		PPUy = (unsigned long)floor(65536.0 * aspectValue+0.5);
+	    } else {
+		PPUy = (unsigned long)floor(DPIValue * aspectValue / 0.0254+0.5);
+	    }
+	}
+	if (DPIObj != NULL || aspectObj != NULL) {
+	    unsigned char buffer[9];
+
+	    if ( PPUx > 2147483647 || PPUy > 2147483647 ) {
+		Tcl_SetObjResult(interp, Tcl_NewStringObj(
+			"DPI or aspect out of range", -1));
+		Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "PHYS", NULL);
+		return TCL_ERROR;
+	    }
+
+	    LongToInt32(PPUx, buffer);
+	    LongToInt32(PPUy, buffer+4);
+	    buffer[8] = unitSpecifier;
+	    if (WriteChunk(interp, pngPtr, CHUNK_pHYs, buffer, 9)
+		    != TCL_OK) {
+		return TCL_ERROR;
+	    }
+	}
+    }
     return TCL_OK;
 }
 
 /*
  *----------------------------------------------------------------------
@@ -3339,11 +3606,12 @@
 
 static int
 EncodePNG(
     Tcl_Interp *interp,
     Tk_PhotoImageBlock *blockPtr,
-    PNGImage *pngPtr)
+    PNGImage *pngPtr,
+    Tcl_Obj *metadataInObj)
 {
     int greenOffset, blueOffset, alphaOffset;
 
     /*
      * Determine appropriate color type based on color usage (e.g., only red
@@ -3422,11 +3690,11 @@
     /*
      * Write out the extra chunks containing metadata that is of interest to
      * other programs more than us.
      */
 
-    if (WriteExtraChunks(interp, pngPtr) == TCL_ERROR) {
+    if (WriteExtraChunks(interp, pngPtr, metadataInObj) == TCL_ERROR) {
 	return TCL_ERROR;
     }
 
     /*
      * Write out the image pixels in the IDAT (data) chunk.
@@ -3463,17 +3731,17 @@
 
 static int
 FileWritePNG(
     Tcl_Interp *interp,
     const char *filename,
-    Tcl_Obj *fmtObj,
+    TCL_UNUSED(Tcl_Obj *),
+    Tcl_Obj *metadataInObj,
     Tk_PhotoImageBlock *blockPtr)
 {
     Tcl_Channel chan;
     PNGImage png;
     int result = TCL_ERROR;
-    (void)fmtObj;
 
     /*
      * Open a Tcl file channel where the image data will be stored. Tk ought
      * to take care of this, and just provide a channel, but it doesn't.
      */
@@ -3505,11 +3773,11 @@
 
     /*
      * Write the raw PNG data out to the file.
      */
 
-    result = EncodePNG(interp, blockPtr, &png);
+    result = EncodePNG(interp, blockPtr, &png, metadataInObj);
 
   cleanup:
     Tcl_Close(interp, chan);
     CleanupPNGImage(&png);
     return result;
@@ -3534,17 +3802,17 @@
  */
 
 static int
 StringWritePNG(
     Tcl_Interp *interp,
-    Tcl_Obj *fmtObj,
+    TCL_UNUSED(Tcl_Obj *),
+    Tcl_Obj *metadataInObj,
     Tk_PhotoImageBlock *blockPtr)
 {
     Tcl_Obj *resultObj = Tcl_NewObj();
     PNGImage png;
     int result = TCL_ERROR;
-    (void)fmtObj;
 
     /*
      * Initalize PNGImage instance for encoding.
      */
 
@@ -3556,11 +3824,11 @@
     /*
      * Write the raw PNG data into the prepared Tcl_Obj buffer. Set the result
      * back to the interpreter if successful.
      */
 
-    result = EncodePNG(interp, blockPtr, &png);
+    result = EncodePNG(interp, blockPtr, &png, metadataInObj);
 
     if (TCL_OK == result) {
 	Tcl_SetObjResult(interp, png.objDataPtr);
     }
 

Index: generic/tkImgPPM.c
==================================================================
--- generic/tkImgPPM.c
+++ generic/tkImgPPM.c
@@ -1,12 +1,12 @@
 /*
  * tkImgPPM.c --
  *
  *	A photo image file handler for PPM (Portable PixMap) files.
  *
- * Copyright (c) 1994 The Australian National University.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Australian National University.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
  * Author: Paul Mackerras (paulus@cs.anu.edu.au),
@@ -199,11 +199,11 @@
 	    destX + width, destY + height) != TCL_OK) {
 	return TCL_ERROR;
     }
 
     if (srcY > 0) {
-	Tcl_Seek(chan, (Tcl_WideInt)(srcY * block.pitch), SEEK_CUR);
+	Tcl_Seek(chan, (long long)srcY * block.pitch, SEEK_CUR);
     }
 
     nLines = (MAX_MEMORY + block.pitch - 1) / block.pitch;
     if (nLines > height) {
 	nLines = height;
@@ -239,11 +239,11 @@
 	    }
 	} else if (maxIntensity > 0x00ff) {
 	    unsigned char *p;
 	    unsigned int value;
 
-	    for (p = pixelPtr; count > 0; count--, p += 2) {
+	    for (p = pixelPtr; count > 0; count -= 2, p += 2) {
 		value = ((unsigned int) p[0]) * 256 + ((unsigned int) p[1]);
 		value = value * 255 / maxIntensity;
 		p[0] = p[1] = (unsigned char) value;
 	    }
 	}
@@ -602,12 +602,12 @@
 		*p = (((int) *dataBuffer) * 255)/maxIntensity;
 	    }
 	} else {
 	    unsigned int value;
 
-	    for (p = pixelPtr,count=nBytes; count > 1; count-=2, p += 2) {
-		value = ((unsigned int) p[0]) * 256 + ((unsigned int) p[1]);
+	    for (p = pixelPtr,count=nBytes; count > 1; count-=2, p += 2, dataBuffer += 2) {
+		value = ((unsigned int)dataBuffer[0]) * 256 + ((unsigned int)dataBuffer[1]);
 		value = value * 255 / maxIntensity;
 		p[0] = p[1] = (unsigned char) value;
 	    }
 	}
 	dataSize -= nBytes;
@@ -765,11 +765,11 @@
     char buffer[BUFFER_SIZE], c;
     int i, numFields, type = 0;
     TkSizeT dataSize;
     unsigned char *dataBuffer;
 
-    dataBuffer = TkGetByteArrayFromObj(dataPtr, &dataSize);
+    dataBuffer = Tcl_GetByteArrayFromObj(dataPtr, &dataSize);
 
     /*
      * Read 4 space-separated fields from the string, ignoring comments (any
      * line that starts with "#").
      */

Index: generic/tkImgPhInstance.c
==================================================================
--- generic/tkImgPhInstance.c
+++ generic/tkImgPhInstance.c
@@ -3,14 +3,14 @@
  *
  *	Implements the rendering of images of type "photo" for Tk. Photo
  *	images are stored in full color (32 bits per pixel including alpha
  *	channel) and displayed using dithering if necessary.
  *
- * Copyright (c) 1994 The Australian National University.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 2002-2008 Donal K. Fellows
- * Copyright (c) 2003 ActiveState Corporation.
+ * Copyright © 1994 The Australian National University.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2002-2008 Donal K. Fellows
+ * Copyright © 2003 ActiveState Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
  * Author: Paul Mackerras (paulus@cs.anu.edu.au),
@@ -36,11 +36,11 @@
 
 /*
  * Forward declarations
  */
 
-#ifndef TKPUTIMAGE_CAN_BLEND
+#ifndef TK_CAN_RENDER_RGBA
 static void		BlendComplexAlpha(XImage *bgImg, PhotoInstance *iPtr,
 			    int xOffset, int yOffset, int width, int height);
 #endif
 static int		IsValidPalette(PhotoInstance *instancePtr,
 			    const char *palette);
@@ -414,11 +414,11 @@
  *
  *	Note that Win32 pre-defines those operations that we really need.
  *
  *----------------------------------------------------------------------
  */
-#ifndef TKPUTIMAGE_CAN_BLEND
+#ifndef TK_CAN_RENDER_RGBA
 #ifndef _WIN32
 #define GetRValue(rgb)	(UCHAR(((rgb) & red_mask) >> red_shift))
 #define GetGValue(rgb)	(UCHAR(((rgb) & green_mask) >> green_shift))
 #define GetBValue(rgb)	(UCHAR(((rgb) & blue_mask) >> blue_shift))
 #define RGB(r, g, b)	((unsigned)( \
@@ -580,11 +580,11 @@
 	    }
 	}
     }
 #undef ALPHA_BLEND
 }
-#endif /* TKPUTIMAGE_CAN_BLEND */
+#endif /* TK_CAN_RENDER_RGBA */
 
 /*
  *----------------------------------------------------------------------
  *
  * TkImgPhotoDisplay --
@@ -612,11 +612,11 @@
 				 * draw. */
     int drawableX,int drawableY)/* Coordinates within drawable that correspond
 				 * to imageX and imageY. */
 {
     PhotoInstance *instancePtr = (PhotoInstance *)clientData;
-#ifndef TKPUTIMAGE_CAN_BLEND
+#ifndef TK_CAN_RENDER_RGBA
     XVisualInfo visInfo = instancePtr->visualInfo;
 #endif
 
     /*
      * If there's no pixmap, it means that an error occurred while creating
@@ -625,26 +625,28 @@
 
     if (instancePtr->pixels == None) {
 	return;
     }
 
-#ifdef TKPUTIMAGE_CAN_BLEND
+#ifdef TK_CAN_RENDER_RGBA
+
     /*
-     * If TkPutImage can handle RGBA Ximages directly there is
+     * We can use TkpPutRGBAImage to render RGBA Ximages directly so there is
      * no need to call XGetImage or to do the Porter-Duff compositing by hand.
      */
 
     unsigned char *rgbaPixels = instancePtr->modelPtr->pix32;
     XImage *photo = XCreateImage(display, NULL, 32, ZPixmap, 0, (char*)rgbaPixels,
 				 (unsigned int)instancePtr->width,
 				 (unsigned int)instancePtr->height,
 				 0, (unsigned int)(4 * instancePtr->width));
-    TkPutImage(NULL, 0, display, drawable, instancePtr->gc,
+    TkpPutRGBAImage(display, drawable, instancePtr->gc,
 	       photo, imageX, imageY, drawableX, drawableY,
 	       (unsigned int) width, (unsigned int) height);
     photo->data = NULL;
     XDestroyImage(photo);
+
 #else
 
     if ((instancePtr->modelPtr->flags & COMPLEX_ALPHA)
 	    && visInfo.depth >= 15
 	    && (visInfo.c_class == DirectColor || visInfo.c_class == TrueColor)) {

Index: generic/tkImgPhoto.c
==================================================================
--- generic/tkImgPhoto.c
+++ generic/tkImgPhoto.c
@@ -3,14 +3,14 @@
  *
  *	Implements images of type "photo" for Tk. Photo images are stored in
  *	full color (32 bits per pixel including alpha channel) and displayed
  *	using dithering if necessary.
  *
- * Copyright (c) 1994 The Australian National University.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 2002-2003 Donal K. Fellows
- * Copyright (c) 2003 ActiveState Corporation.
+ * Copyright © 1994 The Australian National University.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2002-2003 Donal K. Fellows
+ * Copyright © 2003 ActiveState Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
  * Author: Paul Mackerras (paulus@cs.anu.edu.au),
@@ -37,10 +37,11 @@
     int subsampleX, subsampleY;	/* Values specified for -subsample option. */
     Tcl_Obj *format;		/* Value specified for -format option. */
     XColor *background;		/* Value specified for -background option. */
     int compositingRule;	/* Value specified for -compositingrule
 				 * option. */
+    Tcl_Obj *metadata;		/* Value specified for -metadata option. */
 };
 
 /*
  * Bit definitions for use with ParseSubcommandOptions: each bit is set in the
  * allowedOptions parameter on a call to ParseSubcommandOptions if that option
@@ -52,10 +53,11 @@
  * OPT_BACKGROUND:		Set if -format option allowed/specified.
  * OPT_COMPOSITE:		Set if -compositingrule option allowed/spec'd.
  * OPT_FORMAT:			Set if -format option allowed/specified.
  * OPT_FROM:			Set if -from option allowed/specified.
  * OPT_GRAYSCALE:		Set if -grayscale option allowed/specified.
+ * OPT_METADATA:		Set if -metadata option allowed/specified.
  * OPT_SHRINK:			Set if -shrink option allowed/specified.
  * OPT_SUBSAMPLE:		Set if -subsample option allowed/spec'd.
  * OPT_TO:			Set if -to option allowed/specified.
  * OPT_WITHALPHA:		Set if -withalpha option allowed/specified.
  * OPT_ZOOM:			Set if -zoom option allowed/specified.
@@ -65,15 +67,16 @@
 #define OPT_BACKGROUND	2
 #define OPT_COMPOSITE	4
 #define OPT_FORMAT	8
 #define OPT_FROM	0x10
 #define OPT_GRAYSCALE	0x20
-#define OPT_SHRINK	0x40
-#define OPT_SUBSAMPLE	0x80
-#define OPT_TO		0x100
-#define OPT_WITHALPHA	0x200
-#define OPT_ZOOM	0x400
+#define OPT_METADATA	0x40
+#define OPT_SHRINK	0x80
+#define OPT_SUBSAMPLE	0x100
+#define OPT_TO		0x200
+#define OPT_WITHALPHA	0x400
+#define OPT_ZOOM	0x800
 
 /*
  * List of option names. The order here must match the order of declarations
  * of the OPT_* constants above.
  */
@@ -83,10 +86,11 @@
     "-background",
     "-compositingrule",
     "-format",
     "-from",
     "-grayscale",
+    "-metadata",
     "-shrink",
     "-subsample",
     "-to",
     "-withalpha",
     "-zoom",
@@ -138,10 +142,13 @@
 #if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
     Tk_PhotoImageFormat *oldFormatList;
 				/* Pointer to the first in the list of known
 				 * photo image formats.*/
 #endif
+    Tk_PhotoImageFormatVersion3 *formatListVersion3;
+				/* Pointer to the first in the list of known
+				 * photo image formats in Version3 format.*/
     int initialized;		/* Set to 1 if we've initialized the
 				 * structure. */
 } ThreadSpecificData;
 static Tcl_ThreadDataKey dataKey;
 
@@ -193,15 +200,21 @@
 static char *		ImgGetPhoto(PhotoModel *modelPtr,
 			    Tk_PhotoImageBlock *blockPtr,
 			    struct SubcommandOptions *optPtr);
 static int		MatchFileFormat(Tcl_Interp *interp, Tcl_Channel chan,
 			    const char *fileName, Tcl_Obj *formatString,
+			    Tcl_Obj *metadataInObj,
+			    Tcl_Obj *metadataOutObj,
 			    Tk_PhotoImageFormat **imageFormatPtr,
+			    Tk_PhotoImageFormatVersion3 **imageFormatVersion3Ptr,
 			    int *widthPtr, int *heightPtr, int *oldformat);
 static int		MatchStringFormat(Tcl_Interp *interp, Tcl_Obj *data,
 			    Tcl_Obj *formatString,
+			    Tcl_Obj *metadataInObj,
+			    Tcl_Obj *metadataOutObj,
 			    Tk_PhotoImageFormat **imageFormatPtr,
+			    Tk_PhotoImageFormatVersion3 **imageFormatVersion3Ptr,
 			    int *widthPtr, int *heightPtr, int *oldformat);
 static const char *	GetExtension(const char *path);
 
 /*
  *----------------------------------------------------------------------
@@ -222,10 +235,11 @@
 static void
 PhotoFormatThreadExitProc(
     TCL_UNUSED(void *))	/* not used */
 {
     Tk_PhotoImageFormat *freePtr;
+    Tk_PhotoImageFormatVersion3 *freePtrVersion3;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
 
 #if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
     while (tsdPtr->oldFormatList != NULL) {
@@ -238,16 +252,23 @@
 	freePtr = tsdPtr->formatList;
 	tsdPtr->formatList = tsdPtr->formatList->nextPtr;
 	ckfree((char *)freePtr->name);
 	ckfree(freePtr);
     }
+    while (tsdPtr->formatListVersion3 != NULL) {
+	freePtrVersion3 = tsdPtr->formatListVersion3;
+	tsdPtr->formatListVersion3 = tsdPtr->formatListVersion3->nextPtr;
+	ckfree((char *)freePtrVersion3->name);
+	ckfree(freePtrVersion3);
+    }
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * Tk_CreateOldPhotoImageFormat, Tk_CreatePhotoImageFormat --
+ * Tk_CreateOldPhotoImageFormat, Tk_CreatePhotoImageFormat,
+ * Tk_CreatePhotoImageFormatVersion3 --
  *
  *	This function is invoked by an image file handler to register a new
  *	photo image format and the functions that handle the new format. The
  *	function is typically invoked during Tcl_AppInit.
  *
@@ -314,10 +335,36 @@
 	copyPtr->name = name;
 	copyPtr->nextPtr = tsdPtr->formatList;
 	tsdPtr->formatList = copyPtr;
     }
 }
+void
+Tk_CreatePhotoImageFormatVersion3(
+    const Tk_PhotoImageFormatVersion3 *formatPtr)
+				/* Structure describing the format. All of the
+				 * fields except "nextPtr" must be filled in
+				 * by caller. */
+{
+    Tk_PhotoImageFormatVersion3 *copyPtr;
+    char *name;
+    ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+
+    if (!tsdPtr->initialized) {
+	tsdPtr->initialized = 1;
+	Tcl_CreateThreadExitHandler(PhotoFormatThreadExitProc, NULL);
+    }
+    copyPtr = (Tk_PhotoImageFormatVersion3 *)
+	    ckalloc(sizeof(Tk_PhotoImageFormatVersion3));
+    *copyPtr = *formatPtr;
+    /* for compatibility with aMSN: make a copy of formatPtr->name */
+    name = (char *)ckalloc(strlen(formatPtr->name) + 1);
+    strcpy(name, formatPtr->name);
+    copyPtr->name = name;
+    copyPtr->nextPtr = tsdPtr->formatListVersion3;
+    tsdPtr->formatListVersion3 = copyPtr;
+}
 
 /*
  *----------------------------------------------------------------------
  *
  * ImgPhotoCreate --
@@ -417,10 +464,11 @@
     int result, index, x, y, width, height;
     struct SubcommandOptions options;
     unsigned char *pixelPtr;
     Tk_PhotoImageBlock block;
     Tk_PhotoImageFormat *imageFormat;
+    Tk_PhotoImageFormatVersion3 *imageFormatVersion3;
     TkSizeT length;
     int imageWidth, imageHeight, matched, oldformat = 0;
     Tcl_Channel chan;
     Tk_PhotoHandle srcHandle;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
@@ -455,18 +503,22 @@
 
 	if (objc != 3) {
 	    Tcl_WrongNumArgs(interp, 2, objv, "option");
 	    return TCL_ERROR;
 	}
-	arg = TkGetStringFromObj(objv[2], &length);
+	arg = Tcl_GetStringFromObj(objv[2], &length);
 	if (strncmp(arg,"-data", length) == 0) {
 	    if (modelPtr->dataString) {
 		Tcl_SetObjResult(interp, modelPtr->dataString);
 	    }
 	} else if (strncmp(arg,"-format", length) == 0) {
 	    if (modelPtr->format) {
 		Tcl_SetObjResult(interp, modelPtr->format);
+	    }
+	} else if (strncmp(arg, "-metadata", length) == 0) {
+	    if (modelPtr->metadata) {
+		Tcl_SetObjResult(interp, modelPtr->metadata);
 	    }
 	} else {
 	    Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs,
 		    (char *) modelPtr, Tcl_GetString(objv[2]), 0);
 	}
@@ -497,18 +549,25 @@
 	    subobj = Tcl_NewStringObj("-format {} {} {}", 16);
 	    if (modelPtr->format) {
 		Tcl_ListObjAppendElement(NULL, subobj, modelPtr->format);
 	    } else {
 		Tcl_AppendStringsToObj(subobj, " {}", NULL);
+	    }
+	    Tcl_ListObjAppendElement(interp, obj, subobj);
+	    subobj = Tcl_NewStringObj("-metadata {} {} {}", 16);
+	    if (modelPtr->metadata) {
+		Tcl_ListObjAppendElement(NULL, subobj, modelPtr->metadata);
+	    } else {
+		Tcl_AppendStringsToObj(subobj, " {}", NULL);
 	    }
 	    Tcl_ListObjAppendElement(interp, obj, subobj);
 	    Tcl_ListObjAppendList(interp, obj, Tcl_GetObjResult(interp));
 	    Tcl_SetObjResult(interp, obj);
 	    return TCL_OK;
 
 	} else if (objc == 3) {
-	    const char *arg = TkGetStringFromObj(objv[2], &length);
+	    const char *arg = Tcl_GetStringFromObj(objv[2], &length);
 
 	    if (length > 1 && !strncmp(arg, "-data", length)) {
 		Tcl_AppendResult(interp, "-data {} {} {}", NULL);
 		if (modelPtr->dataString) {
 		    /*
@@ -529,10 +588,24 @@
 		     * TODO: Modifying result is bad!
 		     */
 
 		    Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp),
 			    modelPtr->format);
+		} else {
+		    Tcl_AppendResult(interp, " {}", NULL);
+		}
+		return TCL_OK;
+	    } else if (length > 1 &&
+		!strncmp(arg, "-metadata", length)) {
+		Tcl_AppendResult(interp, "-metadata {} {} {}", NULL);
+		if (modelPtr->metadata) {
+		    /*
+		     * TODO: Modifying result is bad!
+		     */
+
+		    Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp),
+			modelPtr->metadata);
 		} else {
 		    Tcl_AppendResult(interp, " {}", NULL);
 		}
 		return TCL_OK;
 	    } else {
@@ -582,13 +655,10 @@
 	}
 	Tk_PhotoGetImage(srcHandle, &block);
 	if ((options.fromX2 > block.width) || (options.fromY2 > block.height)
 		|| (options.fromX2 > block.width)
 		|| (options.fromY2 > block.height)) {
-	    if (options.background) {
-		Tk_FreeColor(options.background);
-	    }
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
 		    "coordinates for -from option extend outside source image",
 		    -1));
 	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);
 	    return TCL_ERROR;
@@ -637,19 +707,23 @@
 
 	/*
 	 * Copy the image data over using Tk_PhotoPutZoomedBlock.
 	 */
 
-	block.pixelPtr += options.fromX * block.pixelSize
-		+ options.fromY * block.pitch;
-	block.width = options.fromX2 - options.fromX;
-	block.height = options.fromY2 - options.fromY;
-	result = Tk_PhotoPutZoomedBlock(interp, (Tk_PhotoHandle) modelPtr,
-		&block, options.toX, options.toY, options.toX2 - options.toX,
-		options.toY2 - options.toY, options.zoomX, options.zoomY,
-		options.subsampleX, options.subsampleY,
-		options.compositingRule);
+	if (block.pixelPtr) {
+	    block.pixelPtr += options.fromX * block.pixelSize
+		    + options.fromY * block.pitch;
+	    block.width = options.fromX2 - options.fromX;
+	    block.height = options.fromY2 - options.fromY;
+	    result = Tk_PhotoPutZoomedBlock(interp, (Tk_PhotoHandle) modelPtr,
+		    &block, options.toX, options.toY, options.toX2 - options.toX,
+		    options.toY2 - options.toY, options.zoomX, options.zoomY,
+		    options.subsampleX, options.subsampleY,
+		    options.compositingRule);
+	} else {
+	    result = TCL_OK;
+	}
 
 	/*
 	 * Set the destination image size if the -shrink option was specified.
 	 * This has to be done _after_ copying the data. Otherwise, if source
 	 * and destination are the same image, block.pixelPtr would point to
@@ -657,58 +731,64 @@
 	 */
 
 	if (options.options & OPT_SHRINK) {
 	    if (ImgPhotoSetSize(modelPtr, options.toX2,
 		    options.toY2) != TCL_OK) {
-		if (options.background) {
-		    Tk_FreeColor(options.background);
-		}
 		Tcl_SetObjResult(interp, Tcl_NewStringObj(
 			TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
 		Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
 		return TCL_ERROR;
 	    }
 	}
-	Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0,
-		modelPtr->width, modelPtr->height);
-	if (options.background) {
-	    Tk_FreeColor(options.background);
+	if (block.pixelPtr || (options.options & OPT_SHRINK)) {
+	    Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0,
+		    modelPtr->width, modelPtr->height);
 	}
 	return result;
 
     case PHOTO_DATA: {
         char *data = NULL;
         Tcl_Obj *freeObj = NULL;
+	Tcl_Obj *metadataIn;
 
 	/*
 	 * photo data command - first parse and check any options given.
 	 */
 
 	Tk_ImageStringWriteProc *stringWriteProc = NULL;
+	Tk_ImageStringWriteProcVersion3 *stringWriteProcVersion3 = NULL;
 
 	index = 1;
 	memset(&options, 0, sizeof(options));
 	options.name = NULL;
 	options.format = NULL;
+	options.metadata = NULL;
 	options.fromX = 0;
 	options.fromY = 0;
 	if (ParseSubcommandOptions(&options, interp,
-		OPT_FORMAT | OPT_FROM | OPT_GRAYSCALE | OPT_BACKGROUND,
+		OPT_FORMAT | OPT_FROM | OPT_GRAYSCALE | OPT_BACKGROUND
+		| OPT_METADATA,
 		&index, objc, objv) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 	if ((options.name == NULL) || (index < objc)) {
 	    Tcl_WrongNumArgs(interp, 2, objv, "?-option value ...?");
+	    if (options.background) {
+		Tk_FreeColor(options.background);
+	    }
 	    return TCL_ERROR;
 	}
 	if ((options.fromX > modelPtr->width)
 		|| (options.fromY > modelPtr->height)
 		|| (options.fromX2 > modelPtr->width)
 		|| (options.fromY2 > modelPtr->height)) {
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
 		    "coordinates for -from option extend outside image", -1));
 	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);
+	    if (options.background) {
+		Tk_FreeColor(options.background);
+	    }
 	    return TCL_ERROR;
 	}
 
 	/*
 	 * Fill in default values for unspecified parameters.
@@ -720,10 +800,20 @@
 	}
 	if (!(options.options & OPT_FORMAT)) {
             options.format = Tcl_NewStringObj("default", -1);
             freeObj = options.format;
 	}
+
+	/*
+	 * Use argument metadata if specified, otherwise the master metadata
+	 */
+
+	if (NULL != options.metadata) {
+	    metadataIn = options.metadata;
+	} else {
+	    metadataIn = modelPtr->metadata;
+	}
 
 	/*
 	 * Search for an appropriate image string format handler.
 	 */
 
@@ -755,26 +845,46 @@
                 }
 	    }
 	}
 #endif
 	if (stringWriteProc == NULL) {
+	    oldformat = 0;
+	    for (imageFormatVersion3 = tsdPtr->formatListVersion3;
+		    imageFormatVersion3 != NULL;
+		    imageFormatVersion3 = imageFormatVersion3->nextPtr) {
+		if ((strncasecmp(Tcl_GetString(options.format),
+			imageFormatVersion3->name,
+			strlen(imageFormatVersion3->name)) == 0)) {
+		    matched = 1;
+		    if (imageFormatVersion3->stringWriteProc != NULL) {
+			stringWriteProcVersion3 =
+				imageFormatVersion3->stringWriteProc;
+			break;
+		    }
+		}
+	    }
+	}
+	if (stringWriteProc == NULL && stringWriteProcVersion3 == NULL) {
 	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
-                    "image string format \"%s\" is %s",
-                    Tcl_GetString(options.format),
-                    (matched ? "not supported" : "unknown")));
+		    "image string format \"%s\" is %s",
+		    Tcl_GetString(options.format),
+		    (matched ? "not supported" : "unknown")));
 	    Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT",
-                    Tcl_GetString(options.format), NULL);
+		    Tcl_GetString(options.format), NULL);
 	    goto dataErrorExit;
 	}
 
 	/*
 	 * Call the handler's string write function to write out the image.
 	 */
 
 	data = ImgGetPhoto(modelPtr, &block, &options);
 
-	if (oldformat) {
+	if (stringWriteProc == NULL) {
+	    result = (stringWriteProcVersion3)(interp,
+		    options.format, metadataIn, &block);
+	} else if (oldformat) {
 	    Tcl_DString buffer;
 	    typedef int (*OldStringWriteProc)(Tcl_Interp *interp,
 		    Tcl_DString *dataPtr, const char *formatString,
 		    Tk_PhotoImageBlock *blockPtr);
 
@@ -798,25 +908,25 @@
 	    Tk_FreeColor(options.background);
 	}
 	if (data) {
 	    ckfree(data);
 	}
-        if (freeObj != NULL) {
-            Tcl_DecrRefCount(freeObj);
-        }
+	if (freeObj != NULL) {
+	    Tcl_DecrRefCount(freeObj);
+	}
 	return result;
 
       dataErrorExit:
-        if (options.background) {
+	if (options.background) {
 	    Tk_FreeColor(options.background);
 	}
 	if (data) {
 	    ckfree(data);
 	}
-        if (freeObj != NULL) {
-            Tcl_DecrRefCount(freeObj);
-        }
+	if (freeObj != NULL) {
+	    Tcl_DecrRefCount(freeObj);
+	}
 	return TCL_ERROR;
     }
 
     case PHOTO_GET: {
 	/*
@@ -877,11 +987,13 @@
 
 	index = 2;
 	memset(&options, 0, sizeof(options));
 	options.name = NULL;
 	options.format = NULL;
-	if (ParseSubcommandOptions(&options, interp, OPT_TO|OPT_FORMAT,
+	options.metadata = NULL;
+	if (ParseSubcommandOptions(&options, interp,
+		OPT_TO|OPT_FORMAT|OPT_METADATA,
 		&index, objc, objv) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 	if ((options.name == NULL) || (index < objc)) {
 	    Tcl_WrongNumArgs(interp, 2, objv, "data ?-option value ...?");
@@ -890,12 +1002,14 @@
 
 	/*
 	 * See if there's a format that can read the data
 	 */
 
-	if (MatchStringFormat(interp, objv[2], options.format, &imageFormat,
-		&imageWidth, &imageHeight, &oldformat) != TCL_OK) {
+	if (MatchStringFormat(interp, objv[2], options.format,
+		options.metadata, NULL, &imageFormat,
+		&imageFormatVersion3, &imageWidth, &imageHeight, &oldformat)
+		!= TCL_OK) {
 	    return TCL_ERROR;
 	}
 
 	if (!(options.options & OPT_TO) || (options.toX2 < 0)) {
 	    options.toX2 = options.toX + imageWidth;
@@ -914,16 +1028,29 @@
 		format = (Tcl_Obj *) Tcl_GetString(format);
 	    }
 	    data = (Tcl_Obj *) Tcl_GetString(data);
 	}
 
-	if (imageFormat->stringReadProc(interp, data, format,
-		(Tk_PhotoHandle) modelPtr, options.toX, options.toY,
-		options.toX2 - options.toX,
-		options.toY2 - options.toY, 0, 0) != TCL_OK) {
-	    return TCL_ERROR;
+	if (imageFormat != NULL) {
+	    if (imageFormat->stringReadProc(interp, data, format,
+		    (Tk_PhotoHandle) modelPtr, options.toX, options.toY,
+		    options.toX2 - options.toX,
+		    options.toY2 - options.toY, 0, 0) != TCL_OK) {
+		return TCL_ERROR;
+	    }
+	} else {
+	    if (imageFormatVersion3->stringReadProc(interp, data, format,
+		    options.metadata,
+		    (Tk_PhotoHandle) modelPtr, options.toX, options.toY,
+		    options.toX2 - options.toX,
+		    options.toY2 - options.toY, 0, 0,
+		    NULL)
+		    != TCL_OK) {
+		return TCL_ERROR;
+	    }
 	}
+
 	/*
 	 * SB: is the next line really needed? The stringReadProc
 	 * writes image data with Tk_PhotoPutBlock(), which in turn
 	 * takes care to notify the changed image and to set/unset the
 	 * IMAGE_CHANGED bit.
@@ -941,12 +1068,13 @@
 
 	index = 2;
 	memset(&options, 0, sizeof(options));
 	options.name = NULL;
 	options.format = NULL;
+	options.metadata = NULL;
 	if (ParseSubcommandOptions(&options, interp,
-		OPT_FORMAT | OPT_FROM | OPT_TO | OPT_SHRINK,
+		OPT_FORMAT | OPT_FROM | OPT_TO | OPT_SHRINK | OPT_METADATA,
 		&index, objc, objv) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 	if ((options.name == NULL) || (index < objc)) {
 	    Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?");
@@ -983,14 +1111,16 @@
 	    Tcl_Close(NULL, chan);
 	    return TCL_ERROR;
 	}
 
 	if (MatchFileFormat(interp, chan,
-		Tcl_GetString(options.name), options.format, &imageFormat,
-		&imageWidth, &imageHeight, &oldformat) != TCL_OK) {
-	    Tcl_Close(NULL, chan);
-	    return TCL_ERROR;
+		Tcl_GetString(options.name), options.format,
+		options.metadata, NULL, &imageFormat,
+		&imageFormatVersion3, &imageWidth, &imageHeight, &oldformat)
+		!= TCL_OK) {
+	    result = TCL_ERROR;
+	    goto readCleanup;
 	}
 
 	/*
 	 * Check the values given for the -from option.
 	 */
@@ -1000,12 +1130,12 @@
 		|| (options.fromY2 > imageHeight)) {
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
 		    "coordinates for -from option extend outside source image",
 		    -1));
 	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);
-	    Tcl_Close(NULL, chan);
-	    return TCL_ERROR;
+	    result = TCL_ERROR;
+	    goto readCleanup;
 	}
 	if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) {
 	    width = imageWidth - options.fromX;
 	    height = imageHeight - options.fromY;
 	} else {
@@ -1022,12 +1152,12 @@
 		    options.toY + height) != TCL_OK) {
 		Tcl_ResetResult(interp);
 		Tcl_SetObjResult(interp, Tcl_NewStringObj(
 			TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
 		Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
-		Tcl_Close(NULL, chan);
-		return TCL_ERROR;
+		result = TCL_ERROR;
+		goto readCleanup;
 	    }
 	}
 
 	/*
 	 * Call the handler's file read function to read the data into the
@@ -1036,14 +1166,23 @@
 
 	format = options.format;
 	if (oldformat && format) {
 	    format = (Tcl_Obj *) Tcl_GetString(format);
 	}
-	result = imageFormat->fileReadProc(interp, chan,
-		Tcl_GetString(options.name),
-		format, (Tk_PhotoHandle) modelPtr, options.toX,
-		options.toY, width, height, options.fromX, options.fromY);
+	if (imageFormat != NULL) {
+	    result = imageFormat->fileReadProc(interp, chan,
+		    Tcl_GetString(options.name),
+		    format, (Tk_PhotoHandle) modelPtr, options.toX,
+		    options.toY, width, height, options.fromX, options.fromY);
+	} else {
+	    result = imageFormatVersion3->fileReadProc(interp, chan,
+		    Tcl_GetString(options.name),
+		    format, options.metadata, (Tk_PhotoHandle) modelPtr,
+		    options.toX, options.toY, width, height, options.fromX,
+		    options.fromY, NULL);
+	}
+readCleanup:
 	if (chan != NULL) {
 	    Tcl_Close(NULL, chan);
 	}
 	return result;
     }
@@ -1269,11 +1408,11 @@
     }
 
     case PHOTO_WRITE: {
 	char *data;
 	const char *fmtString;
-	Tcl_Obj *format;
+	Tcl_Obj *format, *metadataIn;
 	int usedExt;
 
 	/*
 	 * Prevent file system access in safe interpreters.
 	 */
@@ -1291,26 +1430,34 @@
 
 	index = 2;
 	memset(&options, 0, sizeof(options));
 	options.name = NULL;
 	options.format = NULL;
+	options.metadata = NULL;
 	if (ParseSubcommandOptions(&options, interp,
-		OPT_FORMAT | OPT_FROM | OPT_GRAYSCALE | OPT_BACKGROUND,
+		OPT_FORMAT | OPT_FROM | OPT_GRAYSCALE | OPT_BACKGROUND
+		| OPT_METADATA,
 		&index, objc, objv) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 	if ((options.name == NULL) || (index < objc)) {
 	    Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?");
+	    if (options.background) {
+		Tk_FreeColor(options.background);
+	    }
 	    return TCL_ERROR;
 	}
 	if ((options.fromX > modelPtr->width)
 		|| (options.fromY > modelPtr->height)
 		|| (options.fromX2 > modelPtr->width)
 		|| (options.fromY2 > modelPtr->height)) {
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
 		    "coordinates for -from option extend outside image", -1));
 	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);
+	    if (options.background) {
+		Tk_FreeColor(options.background);
+	    }
 	    return TCL_ERROR;
 	}
 
 	/*
 	 * Fill in default values for unspecified parameters. Note that a
@@ -1328,17 +1475,29 @@
 	} else {
 	    fmtString = Tcl_GetString(options.format);
 	    usedExt = 0;
 	}
 
+
+	/*
+	 * Use argument metadata if specified, otherwise the master metadata
+	 */
+
+	if (NULL != options.metadata) {
+	    metadataIn = options.metadata;
+	} else {
+	    metadataIn = modelPtr->metadata;
+	}
+
 	/*
 	 * Search for an appropriate image file format handler, and give an
 	 * error if none is found.
 	 */
 
 	matched = 0;
     redoFormatLookup:
+	imageFormatVersion3 = NULL;
 	for (imageFormat = tsdPtr->formatList; imageFormat != NULL;
 		imageFormat = imageFormat->nextPtr) {
 	    if ((fmtString == NULL)
 		    || (strncasecmp(fmtString, imageFormat->name,
 			    strlen(imageFormat->name)) == 0)) {
@@ -1362,10 +1521,25 @@
 		    }
 		}
 	    }
 	}
 #endif
+	if (imageFormat == NULL) {
+	    oldformat = 0;
+	    for (imageFormatVersion3 = tsdPtr->formatListVersion3;
+		    imageFormatVersion3 != NULL;
+		    imageFormatVersion3 = imageFormatVersion3->nextPtr) {
+		if ((fmtString == NULL)
+			|| (strncasecmp(fmtString, imageFormatVersion3->name,
+				strlen(imageFormatVersion3->name)) == 0)) {
+		    matched = 1;
+		    if (imageFormatVersion3->fileWriteProc != NULL) {
+			break;
+		    }
+		}
+	    }
+	}
 	if (usedExt && !matched) {
 	    /*
 	     * If we didn't find one and we're using file extensions as the
 	     * basis for the guessing, go back and look again without
 	     * prejudice. Supports old broken code.
@@ -1373,11 +1547,11 @@
 
 	    usedExt = 0;
 	    fmtString = NULL;
 	    goto redoFormatLookup;
 	}
-	if (imageFormat == NULL) {
+	if (imageFormat == NULL && imageFormatVersion3 == NULL) {
 	    if (fmtString == NULL) {
 		Tcl_SetObjResult(interp, Tcl_NewStringObj(
 			"no available image file format has file writing"
 			" capability", -1));
 	    } else if (!matched) {
@@ -1388,10 +1562,13 @@
 			"image file format \"%s\" has no file writing capability",
 			fmtString));
 	    }
 	    Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT",
 		    fmtString, NULL);
+	    if (options.background) {
+		Tk_FreeColor(options.background);
+	    }
 	    return TCL_ERROR;
 	}
 
 	/*
 	 * Call the handler's file write function to write out the image.
@@ -1400,12 +1577,18 @@
 	data = ImgGetPhoto(modelPtr, &block, &options);
 	format = options.format;
 	if (oldformat && format) {
 	    format = (Tcl_Obj *) Tcl_GetString(options.format);
 	}
-	result = imageFormat->fileWriteProc(interp,
-		Tcl_GetString(options.name), format, &block);
+	if (imageFormat != NULL) {
+	    result = imageFormat->fileWriteProc(interp,
+		    Tcl_GetString(options.name), format, &block);
+	} else {
+	    result = imageFormatVersion3->fileWriteProc(interp,
+		    Tcl_GetString(options.name), format, metadataIn,
+		    &block);
+	}
 	if (options.background) {
 	    Tk_FreeColor(options.background);
 	}
 	if (data) {
 	    ckfree(data);
@@ -1453,12 +1636,12 @@
  *
  * ParseSubcommandOptions --
  *
  *	This function is invoked to process one of the options which may be
  *	specified for the photo image subcommands, namely, -from, -to, -zoom,
- *	-subsample, -format, -shrink, -compositingrule, -alpha, -boolean and
- *	-withalpha.
+ *	-subsample, -format, -shrink, -compositingrule, -alpha, -boolean,
+ *	-withalpha and -metadata.
  *	Parsing starts at the index in *optIndexPtr and stops at the end of
  *	objv[] or at the first value that does not belong to an option.
  *
  * Results:
  *	A standard Tcl result.
@@ -1501,11 +1684,11 @@
 	/*
 	 * We can have one value specified without an option; it goes into
 	 * optPtr->name.
 	 */
 
-	expandedOption = option = TkGetStringFromObj(objv[index], &length);
+	expandedOption = option = Tcl_GetStringFromObj(objv[index], &length);
 	if (option[0] != '-') {
 	    if (optPtr->name == NULL) {
 		optPtr->name = objv[index];
 		continue;
 	    }
@@ -1572,10 +1755,21 @@
 	    if (index + 1 >= objc) {
 		goto oneValueRequired;
 	    }
 	    *optIndexPtr = ++index;
 	    optPtr->format = objv[index];
+	} else if (bit == OPT_METADATA) {
+	    /*
+	    * The -metadata option takes a single dict value. Note that
+	    * parsing this is outside the scope of this function.
+	    */
+
+	    if (index + 1 >= objc) {
+		goto oneValueRequired;
+	    }
+	    *optIndexPtr = ++index;
+	    optPtr->metadata = objv[index];
 	} else if (bit == OPT_COMPOSITE) {
 	    /*
 	     * The -compositingrule option takes a single value from a
 	     * well-known set.
 	     */
@@ -1768,22 +1962,24 @@
     int flags)			/* Flags to pass to Tk_ConfigureWidget, such
 				 * as TK_CONFIG_ARGV_ONLY. */
 {
     PhotoInstance *instancePtr;
     const char *oldFileString, *oldPaletteString;
-    Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL;
+    Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL,
+	    *metadataInObj = NULL, *metadataOutObj = NULL;
     Tcl_Obj *tempdata, *tempformat;
     TkSizeT length;
     int i, j, result, imageWidth, imageHeight, oldformat;
     double oldGamma;
     Tcl_Channel chan;
     Tk_PhotoImageFormat *imageFormat;
+    Tk_PhotoImageFormatVersion3 *imageFormatVersion3;
     const char **args;
 
     args = (const char **)ckalloc((objc + 1) * sizeof(char *));
     for (i = 0, j = 0; i < objc; i++,j++) {
-	args[j] = TkGetStringFromObj(objv[i], &length);
+	args[j] = Tcl_GetStringFromObj(objv[i], &length);
 	if ((length > 1) && (args[j][0] == '-')) {
 	    if ((args[j][1] == 'd') &&
 		    !strncmp(args[j], "-data", length)) {
 		if (++i < objc) {
 		    data = objv[i];
@@ -1806,10 +2002,23 @@
 		    Tcl_SetObjResult(interp, Tcl_NewStringObj(
 			    "value for \"-format\" missing", -1));
 		    Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
 			    "MISSING_VALUE", NULL);
 		    return TCL_ERROR;
+		}
+	    } else if ((args[j][1] == 'm') &&
+		!strncmp(args[j], "-metadata", length)) {
+		if (++i < objc) {
+		    metadataInObj = objv[i];
+		    j--;
+		} else {
+		    ckfree(args);
+		    Tcl_SetObjResult(interp, Tcl_NewStringObj(
+			"value for \"-metadata\" missing", -1));
+		    Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+			"MISSING_VALUE", NULL);
+		    return TCL_ERROR;
 		}
 	    }
 	}
     }
 
@@ -1846,11 +2055,11 @@
 	goto errorExit;
     }
     ckfree(args);
 
     /*
-     * Regard the empty string for -file, -data or -format as the null value.
+     * Regard the empty string for -file, -data, -format or -metadata as the null value.
      */
 
     if ((modelPtr->fileString != NULL) && (modelPtr->fileString[0] == 0)) {
 	ckfree(modelPtr->fileString);
 	modelPtr->fileString = NULL;
@@ -1860,11 +2069,11 @@
 	 * Force into ByteArray format, which most (all) image handlers will
 	 * use anyway. Empty length means ignore the -data option.
 	 */
 	TkSizeT bytesize;
 
-	(void) TkGetByteArrayFromObj(data, &bytesize);
+	(void) Tcl_GetByteArrayFromObj(data, &bytesize);
 	if (bytesize) {
 	    Tcl_IncrRefCount(data);
 	} else {
 	    data = NULL;
 	}
@@ -1888,10 +2097,36 @@
 	if (modelPtr->format) {
 	    Tcl_DecrRefCount(modelPtr->format);
 	}
 	modelPtr->format = format;
     }
+    if (metadataInObj) {
+	/*
+	 * Make -metadata a dict.
+	 * Take also empty metadatas as this may be a sign to replace
+	 * existing metadata.
+	 */
+	int dictSize;
+
+	if (TCL_OK != Tcl_DictObjSize(interp,metadataInObj, &dictSize)) {
+	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
+		    "value for \"-metadata\" not a dict", -1));
+	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+		    "UNRECOGNIZED_DATA", NULL);
+	    return TCL_ERROR;
+	}
+
+	if (dictSize > 0) {
+	    Tcl_IncrRefCount(metadataInObj);
+	} else {
+	    metadataInObj = NULL;
+	}
+	if (modelPtr->metadata) {
+	    Tcl_DecrRefCount(modelPtr->metadata);
+	}
+	modelPtr->metadata = metadataInObj;
+    }
     /*
      * Set the image to the user-requested size, if any, and make sure storage
      * is correctly allocated for this image.
      */
 
@@ -1927,19 +2162,27 @@
 	chan = Tcl_OpenFileChannel(interp, modelPtr->fileString, "r", 0);
 	if (chan == NULL) {
 	    goto errorExit;
 	}
 
+	/*
+	 * Flag that we want the metadata result dict
+	 */
+
+	metadataOutObj = Tcl_NewDictObj();
+	Tcl_IncrRefCount(metadataOutObj);
+
 	/*
 	 * -translation binary also sets -encoding binary
 	 */
 
 	if ((Tcl_SetChannelOption(interp, chan,
 		"-translation", "binary") != TCL_OK) ||
 		(MatchFileFormat(interp, chan, modelPtr->fileString,
-			modelPtr->format, &imageFormat, &imageWidth,
-			&imageHeight, &oldformat) != TCL_OK)) {
+			modelPtr->format, modelPtr->metadata, metadataOutObj,
+			&imageFormat, &imageFormatVersion3,
+			&imageWidth, &imageHeight, &oldformat) != TCL_OK)) {
 	    Tcl_Close(NULL, chan);
 	    goto errorExit;
 	}
 	result = ImgPhotoSetSize(modelPtr, imageWidth, imageHeight);
 	if (result != TCL_OK) {
@@ -1951,13 +2194,23 @@
 	}
 	tempformat = modelPtr->format;
 	if (oldformat && tempformat) {
 	    tempformat = (Tcl_Obj *) Tcl_GetString(tempformat);
 	}
-	result = imageFormat->fileReadProc(interp, chan,
-		modelPtr->fileString, tempformat, (Tk_PhotoHandle) modelPtr,
-		0, 0, imageWidth, imageHeight, 0, 0);
+	if (imageFormat != NULL) {
+	    result = imageFormat->fileReadProc(interp, chan,
+		    modelPtr->fileString, tempformat,
+		    (Tk_PhotoHandle) modelPtr,
+		    0, 0, imageWidth, imageHeight, 0, 0);
+	} else {
+	    result = imageFormatVersion3->fileReadProc(interp, chan,
+		    modelPtr->fileString, tempformat, modelPtr->metadata,
+		    (Tk_PhotoHandle) modelPtr,
+		    0, 0, imageWidth, imageHeight, 0, 0,
+		    metadataOutObj);
+	}
+
 	Tcl_Close(NULL, chan);
 	if (result != TCL_OK) {
 	    goto errorExit;
 	}
 
@@ -1967,12 +2220,20 @@
 
     if ((modelPtr->fileString == NULL) && (modelPtr->dataString != NULL)
 	    && ((modelPtr->dataString != oldData)
 		    || (modelPtr->format != oldFormat))) {
 
+	/*
+	 * Flag that we want the metadata result dict
+	 */
+
+	metadataOutObj = Tcl_NewDictObj();
+	Tcl_IncrRefCount(metadataOutObj);
+
 	if (MatchStringFormat(interp, modelPtr->dataString,
-		modelPtr->format, &imageFormat, &imageWidth,
+		modelPtr->format, modelPtr->metadata, metadataOutObj,
+		&imageFormat, &imageFormatVersion3, &imageWidth,
 		&imageHeight, &oldformat) != TCL_OK) {
 	    goto errorExit;
 	}
 	if (ImgPhotoSetSize(modelPtr, imageWidth, imageHeight) != TCL_OK) {
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
@@ -1986,19 +2247,70 @@
 	    if (tempformat) {
 		tempformat = (Tcl_Obj *) Tcl_GetString(tempformat);
 	    }
 	    tempdata = (Tcl_Obj *) Tcl_GetString(tempdata);
 	}
-	if (imageFormat->stringReadProc(interp, tempdata, tempformat,
-		(Tk_PhotoHandle) modelPtr, 0, 0, imageWidth, imageHeight,
-		0, 0) != TCL_OK) {
-	    goto errorExit;
+	if (imageFormat != NULL) {
+	    if (imageFormat->stringReadProc(interp, tempdata, tempformat,
+		    (Tk_PhotoHandle) modelPtr, 0, 0, imageWidth, imageHeight,
+		    0, 0) != TCL_OK) {
+		goto errorExit;
+	    }
+	} else {
+	    if (imageFormatVersion3->stringReadProc(interp, tempdata, tempformat,
+		    modelPtr->metadata, (Tk_PhotoHandle) modelPtr, 0, 0,
+		    imageWidth, imageHeight, 0, 0, metadataOutObj) != TCL_OK) {
+		goto errorExit;
+	    }
 	}
 
 	Tcl_ResetResult(interp);
 	modelPtr->flags |= IMAGE_CHANGED;
     }
+
+    /*
+     * Merge driver returned metadata and master metadata
+     */
+    if (metadataOutObj != NULL) {
+	int dictSize;
+	if (TCL_OK != Tcl_DictObjSize(interp,metadataOutObj, &dictSize)) {
+	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
+		    "driver metadata not a dict", -1));
+	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+		    "UNRECOGNIZED_DATA", NULL);
+	    goto errorExit;
+	}
+	if (dictSize > 0) {
+
+	    /*
+	     * We have driver return metadata
+	     */
+
+	    if (modelPtr->metadata == NULL) {
+		modelPtr->metadata = metadataOutObj;
+		metadataOutObj = NULL;
+	    } else {
+		Tcl_DictSearch search;
+		Tcl_Obj *key, *value;
+		int done;
+
+		if (Tcl_IsShared(modelPtr->metadata)) {
+		    Tcl_DecrRefCount(modelPtr->metadata);
+		    modelPtr->metadata = Tcl_DuplicateObj(modelPtr->metadata);
+		    Tcl_IncrRefCount(modelPtr->metadata);
+		}
+
+		if (Tcl_DictObjFirst(interp, metadataOutObj, &search, &key,
+			&value, &done) != TCL_OK) {
+		    goto errorExit;
+		}
+		for (; !done ; Tcl_DictObjNext(&search, &key, &value, &done)) {
+		    Tcl_DictObjPut(interp, modelPtr->metadata, key, value);
+		}
+	    }
+	}
+    }
 
     /*
      * Enforce a reasonable value for gamma.
      */
 
@@ -2034,10 +2346,13 @@
 	Tcl_DecrRefCount(oldData);
     }
     if (oldFormat != NULL) {
 	Tcl_DecrRefCount(oldFormat);
     }
+    if (metadataOutObj != NULL) {
+	Tcl_DecrRefCount(metadataOutObj);
+    }
 
     ToggleComplexAlphaIfNeeded(modelPtr);
 
     return TCL_OK;
 
@@ -2046,10 +2361,13 @@
 	Tcl_DecrRefCount(oldData);
     }
     if (oldFormat != NULL) {
 	Tcl_DecrRefCount(oldFormat);
     }
+    if (metadataOutObj != NULL) {
+	Tcl_DecrRefCount(metadataOutObj);
+    }
     return TCL_ERROR;
 }
 
 /*
  *----------------------------------------------------------------------
@@ -2074,11 +2392,11 @@
     PhotoModel *mPtr)
 {
     size_t len = (size_t)MAX(mPtr->userWidth, mPtr->width) *
 	    (size_t)MAX(mPtr->userHeight, mPtr->height) * 4;
     unsigned char *c = mPtr->pix32;
-    unsigned char *end = c + len;
+    unsigned char *end;
 
     /*
      * Set the COMPLEX_ALPHA flag if we have an image with partially
      * transparent bits.
      */
@@ -2085,10 +2403,11 @@
 
     mPtr->flags &= ~COMPLEX_ALPHA;
     if (c == NULL) {
 	return 0;
     }
+    end = c + len;
     c += 3;			/* Start at first alpha byte. */
     for (; c < end; c += 4) {
 	if (*c && *c != 255) {
      	    mPtr->flags |= COMPLEX_ALPHA;
 	    break;
@@ -2143,10 +2462,13 @@
 	Tcl_DecrRefCount(modelPtr->dataString);
     }
     if (modelPtr->format != NULL) {
 	Tcl_DecrRefCount(modelPtr->format);
     }
+    if (modelPtr->metadata != NULL) {
+	Tcl_DecrRefCount(modelPtr->metadata);
+    }
     Tk_FreeOptions(configSpecs, (char *) modelPtr, NULL, 0);
     ckfree(modelPtr);
 }
 
 /*
@@ -2379,13 +2701,13 @@
  *	format string is provided, only handlers whose names match a prefix of
  *	the format string are tried.
  *
  * Results:
  *	A standard TCL return value. If the return value is TCL_OK, a pointer
- *	to the image format record is returned in *imageFormatPtr, and the
- *	width and height of the image are returned in *widthPtr and
- *	*heightPtr.
+ *	to the image format record is returned in *imageFormatPtr or
+ *	*imageFormatVersion3Ptr, and the width and height of the image are
+ *	returned in *widthPtr and *heightPtr.
  *
  * Side effects:
  *	None.
  *
  *----------------------------------------------------------------------
@@ -2395,21 +2717,29 @@
 MatchFileFormat(
     Tcl_Interp *interp,		/* Interpreter to use for reporting errors. */
     Tcl_Channel chan,		/* The image file, open for reading. */
     const char *fileName,	/* The name of the image file. */
     Tcl_Obj *formatObj,		/* User-specified format string, or NULL. */
+    Tcl_Obj *metadataInObj,	/* User-specified metadata, may be NULL */
+    Tcl_Obj *metadataOutObj,	/* metadata to return, may be NULL */
     Tk_PhotoImageFormat **imageFormatPtr,
 				/* A pointer to the photo image format record
-				 * is returned here. */
+				 * is returned here. For formatVersion3, this is
+				 * set to NULL */
+    Tk_PhotoImageFormatVersion3 **imageFormatVersion3Ptr,
+				/* A pointer to the photo image formatVersion3
+				 * record is returned here. For non
+				 * formatVersion3, this is set to NULL*/
     int *widthPtr, int *heightPtr,
 				/* The dimensions of the image are returned
 				 * here. */
     int *oldformat)		/* Returns 1 if the old image API is used. */
 {
     int matched = 0;
     int useoldformat = 0;
     Tk_PhotoImageFormat *formatPtr;
+    Tk_PhotoImageFormatVersion3 *formatVersion3Ptr;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
     const char *formatString = NULL;
 
     if (formatObj) {
@@ -2488,31 +2818,101 @@
 	    }
 	}
     }
 #endif
 
-    if (formatPtr == NULL) {
-	if ((formatObj != NULL) && !matched) {
-	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
-		    "image file format \"%s\" is not supported",
-		    formatString));
-	    Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT",
-		    formatString, NULL);
-	} else {
-	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
-		    "couldn't recognize data in image file \"%s\"",
-		    fileName));
-	    Tcl_SetErrorCode(interp, "TK", "PHOTO", "IMAGE",
-		    "UNRECOGNIZED_DATA", NULL);
-	}
-	return TCL_ERROR;
-    }
-
-    *imageFormatPtr = formatPtr;
-    *oldformat = useoldformat;
-    (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET);
-    return TCL_OK;
+    /*
+     * For old and not version 3 format, exit now with success
+     */
+
+    if (formatPtr != NULL) {
+	*imageFormatPtr = formatPtr;
+	*imageFormatVersion3Ptr = NULL;
+	*oldformat = useoldformat;
+	(void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET);
+	return TCL_OK;
+    }
+
+    /*
+     * Scan through the table of file format version 3 handlers to find one
+     * which can handle the image.
+     */
+
+    for (formatVersion3Ptr = tsdPtr->formatListVersion3;
+	    formatVersion3Ptr != NULL;
+	    formatVersion3Ptr = formatVersion3Ptr->nextPtr) {
+	if (formatObj != NULL) {
+	    if (strncasecmp(formatString,
+		    formatVersion3Ptr->name, strlen(formatVersion3Ptr->name))
+		    != 0) {
+		continue;
+	    }
+	    matched = 1;
+	    if (formatVersion3Ptr->fileMatchProc == NULL) {
+		Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+			"-file option isn't supported for %s images",
+			formatString));
+		Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+			"NOT_FILE_FORMAT", NULL);
+		return TCL_ERROR;
+	    }
+	}
+	if (formatVersion3Ptr->fileMatchProc != NULL) {
+	    (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET);
+
+	    if (formatVersion3Ptr->fileMatchProc(interp, chan, fileName,
+		    formatObj, metadataInObj, widthPtr, heightPtr,
+		    metadataOutObj)) {
+		if (*widthPtr < 1) {
+		    *widthPtr = 1;
+		}
+		if (*heightPtr < 1) {
+		    *heightPtr = 1;
+		}
+		*imageFormatVersion3Ptr = formatVersion3Ptr;
+		*imageFormatPtr = NULL;
+		*oldformat = 0;
+		(void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET);
+		return TCL_OK;
+	    }
+
+	    /*
+	     * Check if driver has shared or changed the metadata Tcl object.
+	     * In this case, release and recreate it.
+	     */
+
+	    if (metadataOutObj != NULL) {
+		int dictSize;
+		if (Tcl_IsShared(metadataOutObj)
+			|| TCL_OK != Tcl_DictObjSize(interp,metadataOutObj, &dictSize)
+			|| dictSize > 0) {
+		    Tcl_DecrRefCount(metadataOutObj);
+		    metadataOutObj = Tcl_NewDictObj();
+		    Tcl_IncrRefCount(metadataOutObj);
+		}
+	    }
+	}
+    }
+
+    /*
+     * No matching format found
+     */
+
+    if ((formatObj != NULL) && !matched) {
+        Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"image file format \"%s\" is not supported",
+		formatString));
+	Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT",
+		formatString, NULL);
+    } else {
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"couldn't recognize data in image file \"%s\"",
+		fileName));
+	Tcl_SetErrorCode(interp, "TK", "PHOTO", "IMAGE",
+		"UNRECOGNIZED_DATA", NULL);
+    }
+    return TCL_ERROR;
 }
 
 /*
  *----------------------------------------------------------------------
  *
@@ -2523,13 +2923,13 @@
  *	user-specified format string is provided, only handlers whose names
  *	match a prefix of the format string are tried.
  *
  * Results:
  *	A standard TCL return value. If the return value is TCL_OK, a pointer
- *	to the image format record is returned in *imageFormatPtr, and the
- *	width and height of the image are returned in *widthPtr and
- *	*heightPtr.
+ *	to the image format record is returned in *imageFormatPtr or
+ *	*imageFormatVersion3Ptr, and the width and height of the image are
+ *	returned in *widthPtr and *heightPtr.
  *
  * Side effects:
  *	None.
  *
  *----------------------------------------------------------------------
@@ -2538,20 +2938,28 @@
 static int
 MatchStringFormat(
     Tcl_Interp *interp,		/* Interpreter to use for reporting errors. */
     Tcl_Obj *data,		/* Object containing the image data. */
     Tcl_Obj *formatObj,		/* User-specified format string, or NULL. */
+    Tcl_Obj *metadataInObj,	/* User-specified metadata, may be NULL */
+    Tcl_Obj *metadataOutObj,	/* metadata output dict, may be NULL */
     Tk_PhotoImageFormat **imageFormatPtr,
 				/* A pointer to the photo image format record
-				 * is returned here. */
+				 * is returned here. For formatVersion3, this is
+				 * set to NULL*/
+    Tk_PhotoImageFormatVersion3 **imageFormatVersion3Ptr,
+				/* A pointer to the photo image formatVersion3
+				 * record is returned here. For non
+				 * formatVersion3, this is set to NULL*/
     int *widthPtr, int *heightPtr,
 				/* The dimensions of the image are returned
 				 * here. */
     int *oldformat)		/* Returns 1 if the old image API is used. */
 {
     int matched = 0, useoldformat = 0;
     Tk_PhotoImageFormat *formatPtr, *defaultFormatPtr = NULL;
+    Tk_PhotoImageFormatVersion3 *formatVersion3Ptr = NULL;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
     const char *formatString = NULL;
 
     if (formatObj) {
@@ -2639,10 +3047,57 @@
 	}
     }
 #endif
 
     if (formatPtr == NULL) {
+	useoldformat = 0;
+	for (formatVersion3Ptr = tsdPtr->formatListVersion3;
+		formatVersion3Ptr != NULL;
+		formatVersion3Ptr = formatVersion3Ptr->nextPtr) {
+	    if (formatObj != NULL) {
+		if (strncasecmp(formatString,
+			formatVersion3Ptr->name, strlen(formatVersion3Ptr->name)
+			) != 0) {
+		    continue;
+		}
+		matched = 1;
+		if (formatVersion3Ptr->stringMatchProc == NULL) {
+		    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+			    "-data option isn't supported for %s images",
+			    formatString));
+		    Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+			    "NOT_DATA_FORMAT", NULL);
+		    return TCL_ERROR;
+		}
+	    }
+	    if ((formatVersion3Ptr->stringMatchProc != NULL)
+		    && (formatVersion3Ptr->stringReadProc != NULL)
+		    && formatVersion3Ptr->stringMatchProc(interp, data,
+			    formatObj, metadataInObj, widthPtr, heightPtr,
+			    metadataOutObj)) {
+		break;
+	    }
+
+	    /*
+	     * Check if driver has shared or changed the metadata tcl object.
+	     * In this case, release and recreate it.
+	     */
+
+	    if (metadataOutObj != NULL) {
+		int dictSize;
+		if (Tcl_IsShared(metadataOutObj)
+			|| TCL_OK != Tcl_DictObjSize(interp,metadataOutObj, &dictSize)
+			|| dictSize > 0) {
+		    Tcl_DecrRefCount(metadataOutObj);
+		    metadataOutObj = Tcl_NewDictObj();
+		    Tcl_IncrRefCount(metadataOutObj);
+		}
+	    }
+	}
+    }
+
+    if (formatPtr == NULL && formatVersion3Ptr == NULL) {
 	/*
 	 * Try the default format as last resort (only if no -format option
 	 * was passed).
 	 */
 
@@ -2679,10 +3134,11 @@
 	    return TCL_ERROR;
 	}
     }
 
     *imageFormatPtr = formatPtr;
+    *imageFormatVersion3Ptr = formatVersion3Ptr;
     *oldformat = useoldformat;
 
     /*
      * Some stringMatchProc might have left error messages and error codes in
      * interp.	Clear them before return.
@@ -2805,13 +3261,13 @@
      * different values and still point to the same block of memory. (e.g.
      * if the -from option was passed to [imageName copy])
      */
     sourceBlock = *blockPtr;
     memToFree = NULL;
-    if (sourceBlock.pixelPtr >= modelPtr->pix32
-	    && sourceBlock.pixelPtr <= modelPtr->pix32 + modelPtr->width
-	    * modelPtr->height * 4) {
+    if (modelPtr->pix32 && (sourceBlock.pixelPtr >= modelPtr->pix32)
+	    && (sourceBlock.pixelPtr < modelPtr->pix32 + modelPtr->width
+	    * modelPtr->height * 4)) {
 	/*
 	 * Fix 5c51be6411: avoid reading
 	 *
 	 *	(sourceBlock.pitch - sourceBlock.width * sourceBlock.pixelSize)
 	 *
@@ -3045,11 +3501,11 @@
      */
 
     if (alphaOffset) {
 	/*
 	 * This block is grossly inefficient. For each row in the image, it
-	 * finds each continguous string of nontransparent pixels, then marks
+	 * finds each contiguous string of nontransparent pixels, then marks
 	 * those areas as valid in the validRegion mask. This makes drawing
 	 * very efficient, because of the way we use X: we just say, here's
 	 * your mask, and here's your data. We need not worry about the
 	 * current background color, etc. But this costs us a lot on the image
 	 * setup. Still, image setup only happens once, whereas the drawing
@@ -3251,13 +3707,13 @@
      * different values and still point to the same block of memory. (e.g.
      * if the -from option was passed to [imageName copy])
      */
     sourceBlock = *blockPtr;
     memToFree = NULL;
-    if (sourceBlock.pixelPtr >= modelPtr->pix32
-	    && sourceBlock.pixelPtr <= modelPtr->pix32 + modelPtr->width
-	    * modelPtr->height * 4) {
+    if (modelPtr->pix32 && (sourceBlock.pixelPtr >= modelPtr->pix32)
+	    && (sourceBlock.pixelPtr < modelPtr->pix32 + modelPtr->width
+	    * modelPtr->height * 4)) {
 	/*
 	 * Fix 5c51be6411: avoid reading
 	 *
 	 *	(sourceBlock.pitch - sourceBlock.width * sourceBlock.pixelSize)
 	 *
@@ -3636,12 +4092,14 @@
     /*
      * Clear out the 32-bit pixel storage array. Clear out the dithering error
      * arrays for each instance.
      */
 
-    memset(modelPtr->pix32, 0,
-	    ((size_t)modelPtr->width * modelPtr->height * 4));
+    if (modelPtr->pix32) {
+	memset(modelPtr->pix32, 0,
+		((size_t)modelPtr->width * modelPtr->height * 4));
+    }
     for (instancePtr = modelPtr->instancePtr; instancePtr != NULL;
 	    instancePtr = instancePtr->nextPtr) {
 	TkImgResetDither(instancePtr);
     }
 
@@ -4080,11 +4538,11 @@
 /*
  *----------------------------------------------------------------------
  *
  * Tk_PhotoPutBlock_NoComposite, Tk_PhotoPutZoomedBlock_NoComposite --
  *
- * These backward-compatability functions just exist to fill slots in stubs
+ * These backward-compatibility functions just exist to fill slots in stubs
  * table. For the behaviour of *_NoComposite, refer to the corresponding
  * function without the extra suffix, except that the compositing rule is
  * always "overlay" and the function always panics on memory-allocation
  * failure.
  *
@@ -4121,11 +4579,11 @@
  *----------------------------------------------------------------------
  *
  * Tk_PhotoExpand_Panic, Tk_PhotoPutBlock_Panic,
  * Tk_PhotoPutZoomedBlock_Panic, Tk_PhotoSetSize_Panic
  *
- * Backward compatability functions for preserving the old behaviour (i.e.
+ * Backward compatibility functions for preserving the old behaviour (i.e.
  * panic on memory allocation failure) so that extensions do not need to be
  * significantly updated to take account of TIP #116. These call the new
  * interface (i.e. the interface without the extra suffix), but panic if an
  * error condition is returned.
  *

Index: generic/tkImgPhoto.h
==================================================================
--- generic/tkImgPhoto.h
+++ generic/tkImgPhoto.h
@@ -1,14 +1,14 @@
 /*
  * tkImgPhoto.h --
  *
  *	Declarations for images of type "photo" for Tk.
  *
- * Copyright (c) 1994 The Australian National University.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 2002-2008 Donal K. Fellows
- * Copyright (c) 2003 ActiveState Corporation.
+ * Copyright © 1994 The Australian National University.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2002-2008 Donal K. Fellows
+ * Copyright © 2003 ActiveState Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
  * Author: Paul Mackerras (paulus@cs.anu.edu.au),
@@ -157,10 +157,12 @@
     double gamma;		/* Display gamma value to correct for. */
     char *fileString;		/* Name of file to read into image. */
     Tcl_Obj *dataString;	/* Object to use as contents of image. */
     Tcl_Obj *format;		/* User-specified format of data in image file
 				 * or string value. */
+    Tcl_Obj *metadata;		/* User-specified metadata dict or read from
+				 * image file */
     unsigned char *pix32;	/* Local storage for 32-bit image. */
     int ditherX, ditherY;	/* Location of first incorrectly dithered
 				 * pixel in image. */
     TkRegion validRegion;	/* Tk region indicating which parts of the
 				 * image have valid image data. */

Index: generic/tkImgSVGnano.c
==================================================================
--- generic/tkImgSVGnano.c
+++ generic/tkImgSVGnano.c
@@ -1,14 +1,14 @@
 /*
  * tkImgSVGnano.c
  *
  *	A photo file handler for SVG files.
  *
- * Copyright (c) 2013-14 Mikko Mononen memon@inside.org
- * Copyright (c) 2018 Christian Gollwitzer auriocus@gmx.de
- * Copyright (c) 2018 Christian Werner https://www.androwish.org/
- * Copyright (c) 2018 Rene Zaumseil r.zaumseil@freenet.de
+ * Copyright © 2013-14 Mikko Mononen memon@inside.org
+ * Copyright © 2018 Christian Gollwitzer auriocus@gmx.de
+ * Copyright © 2018 Christian Werner https://www.androwish.org/
+ * Copyright © 2018 Rene Zaumseil r.zaumseil@freenet.de
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
  * This handler is build using the original nanosvg library files from
@@ -50,10 +50,12 @@
     Tcl_DString formatString;
     NSVGimage *nsvgImage;
     RastOpts ropts;
 } NSVGcache;
 
+static const void *	MemMem(const void *haystack, size_t haysize,
+			       const void *needle, size_t needlen);
 static int		FileMatchSVG(Tcl_Channel chan, const char *fileName,
 			    Tcl_Obj *format, int *widthPtr, int *heightPtr,
 			    Tcl_Interp *interp);
 static int		FileReadSVG(Tcl_Interp *interp, Tcl_Channel chan,
 			    const char *fileName, Tcl_Obj *format,
@@ -99,10 +101,50 @@
 };
 
 /*
  *----------------------------------------------------------------------
  *
+ * MemMem --
+ *
+ *	Like strstr() but operating on memory buffers with sizes.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static const void *
+MemMem(const void *haystack, size_t haylen,
+       const void *needle, size_t needlen)
+{
+    const void *hayend, *second, *p;
+    unsigned char first;
+
+    if ((needlen <= 0) || (haylen < needlen)) {
+	return NULL;
+    }
+    hayend = (const void *) ((char *) haystack + haylen - needlen);
+    first = ((char *) needle)[0];
+    second = (const void *) ((char *) needle + 1);
+    needlen -= 1;
+    while (haystack < hayend) {
+	p = memchr(haystack, first, (char *) hayend - (char *) haystack);
+	if (p == NULL) {
+	    break;
+	}
+	if (needlen == 0) {
+	    return p;
+	}
+	haystack = (const void *) ((char *) p + 1);
+	if (memcmp(second, haystack, needlen) == 0) {
+	    return p;
+	}
+    }
+    return NULL;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
  * FileMatchSVG --
  *
  *	This function is invoked by the photo image type to see if a file
  *	contains image data in SVG format.
  *
@@ -130,16 +172,28 @@
     RastOpts ropts;
     NSVGimage *nsvgImage;
     (void)fileName;
 
     CleanCache(interp);
-    if (Tcl_ReadChars(chan, dataObj, -1, 0) == TCL_IO_FAILURE) {
+    if (Tcl_ReadChars(chan, dataObj, 4096, 0) == TCL_IO_FAILURE) {
+	/* in case of an error reading the file */
+	Tcl_DecrRefCount(dataObj);
+	return 0;
+    }
+    data = Tcl_GetStringFromObj(dataObj, &length);
+    /* should have a '<svg' and a '>' in the first 4k */
+    if ((memchr(data, '>', length) == NULL) ||
+	(MemMem(data, length, "<svg", 4) == NULL)) {
+	Tcl_DecrRefCount(dataObj);
+	return 0;
+    }
+    if (!Tcl_Eof(chan) && (Tcl_ReadChars(chan, dataObj, -1, 1) == TCL_IO_FAILURE)) {
 	/* in case of an error reading the file */
 	Tcl_DecrRefCount(dataObj);
 	return 0;
     }
-    data = TkGetStringFromObj(dataObj, &length);
+    data = Tcl_GetStringFromObj(dataObj, &length);
     nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts);
     Tcl_DecrRefCount(dataObj);
     if (nsvgImage != NULL) {
         GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr);
         if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) {
@@ -198,11 +252,11 @@
 	    Tcl_DecrRefCount(dataObj);
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj("read error", -1));
 	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "READ_ERROR", NULL);
 	    return TCL_ERROR;
 	}
-	data = TkGetStringFromObj(dataObj, &length);
+	data = Tcl_GetStringFromObj(dataObj, &length);
 	nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj,
 			    &ropts);
 	Tcl_DecrRefCount(dataObj);
 	if (nsvgImage == NULL) {
 	    return TCL_ERROR;
@@ -235,17 +289,23 @@
     Tcl_Obj *dataObj,
     Tcl_Obj *formatObj,
     int *widthPtr, int *heightPtr,
     Tcl_Interp *interp)
 {
-    TkSizeT length;
+    TkSizeT length, testLength;
     const char *data;
     RastOpts ropts;
     NSVGimage *nsvgImage;
 
     CleanCache(interp);
-    data = TkGetStringFromObj(dataObj, &length);
+    data = Tcl_GetStringFromObj(dataObj, &length);
+    /* should have a '<svg' and a '>' in the first 4k */
+    testLength = (length > 4096) ? 4096 : length;
+    if ((memchr(data, '>', testLength) == NULL) ||
+	(MemMem(data, testLength, "<svg", 4) == NULL)) {
+	return 0;
+    }
     nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts);
     if (nsvgImage != NULL) {
         GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr);
         if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) {
 	    nsvgDelete(nsvgImage);
@@ -291,11 +351,11 @@
     const char *data;
     RastOpts ropts;
     NSVGimage *nsvgImage = GetCachedSVG(interp, dataObj, formatObj, &ropts);
 
     if (nsvgImage == NULL) {
-        data = TkGetStringFromObj(dataObj, &length);
+	data = Tcl_GetStringFromObj(dataObj, &length);
 	nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj,
 			    &ropts);
     }
     if (nsvgImage == NULL) {
 	return TCL_ERROR;
@@ -517,10 +577,11 @@
     int w, h, c;
     NSVGrasterizer *rast;
     unsigned char *imgData;
     Tk_PhotoImageBlock svgblock;
     double scale;
+    Tcl_WideUInt wh;
     (void)srcX;
     (void)srcY;
 
     scale = GetScaleFromParameters(nsvgImage, ropts, &w, &h);
 
@@ -529,11 +590,20 @@
 	Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot initialize rasterizer", -1));
 	Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "RASTERIZER_ERROR",
 		NULL);
 	goto cleanAST;
     }
-    imgData = (unsigned char *)attemptckalloc(w * h *4);
+
+    /* Tk Ticket [822330269b] Check potential int overflow in following ckalloc */
+    wh = (Tcl_WideUInt)w * (Tcl_WideUInt)h;
+    if ( w < 0 || h < 0 || wh > INT_MAX / 4) {
+	Tcl_SetObjResult(interp, Tcl_NewStringObj("image size overflow", -1));
+	Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "IMAGE_SIZE_OVERFLOW", NULL);
+	goto cleanRAST;
+    }
+
+    imgData = (unsigned char *)attemptckalloc(wh * 4);
     if (imgData == NULL) {
 	Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot alloc image buffer", -1));
 	Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "OUT_OF_MEMORY", NULL);
 	goto cleanRAST;
     }
@@ -692,11 +762,11 @@
     NSVGcache *cachePtr = GetCachePtr(interp);
 
     if (cachePtr != NULL) {
         cachePtr->dataOrChan = dataOrChan;
 	if (formatObj != NULL) {
-	    data = TkGetStringFromObj(formatObj, &length);
+	    data = Tcl_GetStringFromObj(formatObj, &length);
 	    Tcl_DStringAppend(&cachePtr->formatString, data, length);
 	}
 	cachePtr->nsvgImage = nsvgImage;
 	cachePtr->ropts = *ropts;
 	return 1;
@@ -733,11 +803,11 @@
     NSVGimage *nsvgImage = NULL;
 
     if ((cachePtr != NULL) && (cachePtr->nsvgImage != NULL) &&
 	(cachePtr->dataOrChan == dataOrChan)) {
         if (formatObj != NULL) {
-	    data = TkGetStringFromObj(formatObj, &length);
+	    data = Tcl_GetStringFromObj(formatObj, &length);
 	    if (strcmp(data, Tcl_DStringValue(&cachePtr->formatString)) == 0) {
 	        nsvgImage = cachePtr->nsvgImage;
 		*ropts = cachePtr->ropts;
 		cachePtr->nsvgImage = NULL;
 	    }

Index: generic/tkImgUtil.c
==================================================================
--- generic/tkImgUtil.c
+++ generic/tkImgUtil.c
@@ -1,11 +1,11 @@
 /*
  * tkImgUtil.c --
  *
  *	This file contains image related utility functions.
  *
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright © 1995 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkInt.decls
==================================================================
--- generic/tkInt.decls
+++ generic/tkInt.decls
@@ -2,12 +2,12 @@
 #
 #	This file contains the declarations for all unsupported functions that
 #	are exported by the Tk library. This file is used to generate the
 #	tkIntDecls.h, tkIntPlatDecls.h, tkIntStub.c, and tkPlatStub.c files.
 #
-# Copyright (c) 1998-1999 by Scriptics Corporation.
-# Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
+# Copyright © 1998-1999 Scriptics Corporation.
+# Copyright © 2007 Daniel A. Steffen <das@users.sourceforge.net>
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
 library tk
@@ -224,11 +224,11 @@
     void TkpDisplayWarning(const char *msg, const char *title)
 }
 declare 59 {
     void TkpGetAppName(Tcl_Interp *interp, Tcl_DString *name)
 }
-declare 60 {
+declare 60 {deprecated {renamed to Tk_GetOtherWindow}} {
     TkWindow *TkpGetOtherWindow(TkWindow *winPtr)
 }
 declare 61 {
     TkWindow *TkpGetWrapperWindow(TkWindow *winPtr)
 }
@@ -237,17 +237,17 @@
 }
 declare 63 {
     void TkpInitializeMenuBindings(Tcl_Interp *interp,
 	    Tk_BindingTable bindingTable)
 }
-declare 64 {
+declare 64 {deprecated {renamed to Tk_MakeContainer}} {
     void TkpMakeContainer(Tk_Window tkwin)
 }
 declare 65 {
     void TkpMakeMenuWindow(Tk_Window tkwin, int transient)
 }
-declare 66 {
+declare 66 {deprecated {renamed to Tk_MakeWindow}} {
     Window TkpMakeWindow(TkWindow *winPtr, Window parent)
 }
 declare 67 {
     void TkpMenuNotifyToplevelCreate(Tcl_Interp *interp, const char *menuName)
 }
@@ -267,14 +267,14 @@
     int TkPositionInTree(TkWindow *winPtr, TkWindow *treePtr)
 }
 declare 73 {
     void TkpRedirectKeyEvent(TkWindow *winPtr, XEvent *eventPtr)
 }
-declare 74 {
+declare 74 {deprecated {renamed to Tk_SetMainMenubar}} {
     void TkpSetMainMenubar(Tcl_Interp *interp, Tk_Window tkwin, const char *menuName)
 }
-declare 75 {
+declare 75 {deprecated {renamed to Tk_UseWindow}} {
     int TkpUseWindow(Tcl_Interp *interp, Tk_Window tkwin, const char *string)
 }
 #
 # Slot 76 unused (WAS: TkpWindowWasRecentlyDeleted)
 #
@@ -306,11 +306,11 @@
 # Exported publically as Tk_SetClassProcs in 8.4a2
 #declare 84 {
 #    void TkSetClassProcs(Tk_Window tkwin,
 #	    TkClassProcs *procs, ClientData instanceData)
 #}
-declare 85 {
+declare 85 {deprecated {renamed to Tk_SetWindowMenubar}} {
     void TkSetWindowMenuBar(Tcl_Interp *interp, Tk_Window tkwin,
 	    const char *oldMenuName, const char *menuName)
 }
 declare 86 {
     KeySym TkStringToKeysym(const char *name)
@@ -392,11 +392,11 @@
     const char *TkpGetString(TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr)
 }
 declare 110 {
     void TkpGetSubFonts(Tcl_Interp *interp, Tk_Font tkfont)
 }
-declare 111 {
+declare 111 {deprecated {renamed to Tk_GetSystemDefault}} {
     Tcl_Obj *TkpGetSystemDefault(Tk_Window tkwin,
 	    const char *dbName, const char *className)
 }
 declare 112 {
     void TkpMenuThreadInit(void)
@@ -432,11 +432,11 @@
 }
 declare 124 aqua {
     Pixmap TkpGetNativeAppBitmap(Display *display,
 	    const char *name, int *width, int *height)
 }
-declare 135 {
+declare 135 {deprecated {renamed to Tk_DrawHighlightBorder}} {
     void TkpDrawHighlightBorder(Tk_Window tkwin, GC fgGC, GC bgGC,
         int highlightWidth, Drawable drawable)
 }
 declare 136 {
     void TkSetFocusWin(TkWindow *winPtr, int force)
@@ -634,14 +634,14 @@
 	    Tk_Font tkfont, const char *source, int numBytes, double x,
 	    double y, double angle)
 }
 
 # Support for aqua's inability to draw outside [NSView drawRect:]
-declare 185 macosx {
+declare 185 {
     void TkpRedrawWidget(Tk_Window tkwin)
 }
-declare 186 macosx {
+declare 186 {
     int TkpWillDrawWidget(Tk_Window tkwin)
 }
 
 # Debugging / testing functions for photo images
 declare 187 {

Index: generic/tkInt.h
==================================================================
--- generic/tkInt.h
+++ generic/tkInt.h
@@ -4,11 +4,11 @@
  *	Declarations for things used internally by the Tk functions but not
  *	exported outside the module.
  *
  * Copyright (c) 1990-1994 The Regents of the University of California.
  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998 by Scriptics Corporation.
+ * Copyright (c) 1998 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -16,10 +16,12 @@
 #define _TKINT
 
 #ifndef _TKPORT
 #include "tkPort.h"
 #endif
+
+#define TK_OPTION_ENUM_VAR		((int)(sizeof(Tk_OptionType)&(sizeof(int)-1))<<6)
 
 /*
  * Ensure WORDS_BIGENDIAN is defined correctly:
  * Needs to happen here in addition to configure to work with fat compiles on
  * Darwin (where configure runs only once for multiple architectures).
@@ -92,37 +94,52 @@
 #   define TKFLEXARRAY 0
 #else
 #   define TKFLEXARRAY 1
 #endif
 
-#if !defined(Tcl_GetParent) && (TCL_MAJOR_VERSION < 9) && (TCL_MINOR_VERSION < 7)
-#   define Tcl_GetParent Tcl_GetMaster
+#if TCL_MAJOR_VERSION < 9
+#   undef Tcl_ExternalToUtfDStringEx
+#   undef Tcl_UtfToExternalDStringEx
+    /* just assume 'flags' is TCL_ENCODING_NOCOMPLAIN, and return value not used. */
+#   define Tcl_ExternalToUtfDStringEx(encoding, data, length, flags, ds) \
+	(Tcl_ExternalToUtfDString(encoding, data, length, ds), TCL_INDEX_NONE)
+#   define Tcl_UtfToExternalDStringEx(encoding, data, length, flags, ds) \
+	(Tcl_UtfToExternalDString(encoding, data, length, ds), TCL_INDEX_NONE)
+#   if !defined(Tcl_GetParent) && (TCL_MINOR_VERSION < 7)
+#	define Tcl_GetParent Tcl_GetMaster
+#   endif
 #endif
 
 /*
  * Macros used to cast between pointers and integers (e.g. when storing an int
  * in ClientData), on 64-bit architectures they avoid gcc warning about "cast
  * to/from pointer from/to integer of different size".
  */
 
-#if !defined(INT2PTR) && !defined(PTR2INT)
-#   if defined(HAVE_INTPTR_T) || defined(intptr_t)
-#	define INT2PTR(p) ((void*)(intptr_t)(p))
-#	define PTR2INT(p) ((intptr_t)(p))
-#   else
-#	define INT2PTR(p) ((void*)(p))
-#	define PTR2INT(p) ((long)(p))
-#   endif
+#if !defined(INT2PTR)
+#   define INT2PTR(p) ((void *)(ptrdiff_t)(p))
+#endif
+#if !defined(PTR2INT)
+#   define PTR2INT(p) ((ptrdiff_t)(p))
+#endif
+#if !defined(UINT2PTR)
+#   define UINT2PTR(p) ((void *)(size_t)(p))
+#endif
+#if !defined(PTR2UINT)
+#   define PTR2UINT(p) ((size_t)(p))
+#endif
+
+/*
+ * Fallback in case Tk is linked against a Tcl version not having TIP #585
+ * (TCL_INDEX_TEMP_TABLE) or TIP #613 (TCL_INDEX_NULL_OK)
+ */
+
+#ifndef TCL_INDEX_NULL_OK
+#   define TCL_INDEX_NULL_OK 32
 #endif
-#if !defined(UINT2PTR) && !defined(PTR2UINT)
-#   if defined(HAVE_UINTPTR_T) || defined(uintptr_t)
-#	define UINT2PTR(p) ((void*)(uintptr_t)(p))
-#	define PTR2UINT(p) ((uintptr_t)(p))
-#   else
-#	define UINT2PTR(p) ((void*)(p))
-#	define PTR2UINT(p) ((unsigned long)(p))
-#   endif
+#if !defined(TCL_INDEX_TEMP_TABLE)
+#   define TCL_INDEX_TEMP_TABLE 64
 #endif
 
 #ifndef TCL_Z_MODIFIER
 #   if defined(_WIN64)
 #	define TCL_Z_MODIFIER	"I"
@@ -130,10 +147,22 @@
 #	define TCL_Z_MODIFIER	"z"
 #   else
 #	define TCL_Z_MODIFIER	""
 #   endif
 #endif /* !TCL_Z_MODIFIER */
+#undef TCL_LL_MODIFIER
+#if defined(_WIN32) && (!defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO)
+#   define TCL_LL_MODIFIER	"I64"
+#else
+#   define TCL_LL_MODIFIER	"ll"
+#endif
+
+#if TCL_MAJOR_VERSION > 8
+#   define TKSIZET_MODIFIER TCL_Z_MODIFIER
+#else
+#   define TKSIZET_MODIFIER ""
+#endif
 
 /*
  * Opaque type declarations:
  */
 
@@ -372,12 +401,18 @@
 				/* Hash table that maps from a container's
 				 * Tk_Window token to a list of windows managed
 				 * by that container. */
     int geomInit;
 
-#define TkGetContainer(tkwin) (((TkWindow *)tkwin)->maintainerPtr != NULL ? \
-    ((TkWindow *)tkwin)->maintainerPtr : ((TkWindow *)tkwin)->parentPtr)
+    /*
+     * Information used by tkGrid.c, tkPack.c, tkPlace.c, tkPointer.c,
+     * and ttkMacOSXTheme.c:
+     */
+
+#define TkGetContainer(tkwin) (Tk_TopWinHierarchy((TkWindow *)tkwin) ? NULL : \
+	(((TkWindow *)tkwin)->maintainerPtr != NULL ? \
+	 ((TkWindow *)tkwin)->maintainerPtr : ((TkWindow *)tkwin)->parentPtr))
 
     /*
      * Information used by tkGet.c only:
      */
 
@@ -693,10 +728,21 @@
     int alwaysShowSelection;	/* This is linked to the
 				 * ::tk::AlwaysShowSelection variable. */
     struct TkMainInfo *nextPtr;	/* Next in list of all main windows managed by
 				 * this process. */
     Tcl_HashTable busyTable;	/* Information used by [tk busy] command. */
+    Tcl_ObjCmdProc *tclUpdateObjProc;
+				/* Saved Tcl [update] command, used to restore
+				 * Tcl's version of [update] after Tk is shut
+				 * down */
+#if TCL_MAJOR_VERSION > 8
+    Tcl_ObjCmdProc2 *tclUpdateObjProc2;
+				/* Saved Tcl [update] command, used to restore
+				 * Tcl's version of [update] after Tk is shut
+				 * down, in case it's a Tcl_ObjCmdProc2 */
+#endif
+
 } TkMainInfo;
 
 /*
  * Tk keeps the following data structure for each of it's builtin bitmaps.
  * This structure is only used by tkBitmap.c and other platform specific
@@ -805,17 +851,17 @@
      */
 
     ClientData *tagPtr;		/* Points to array of tags used for bindings
 				 * on this window. Each tag is a Tk_Uid.
 				 * Malloc'ed. NULL means no tags. */
-    int numTags;		/* Number of tags at *tagPtr. */
+    TkSizeT numTags;		/* Number of tags at *tagPtr. */
 
     /*
      * Information used by tkOption.c to manage options for the window.
      */
 
-    int optionLevel;		/* -1 means no option information is currently
+    TkSizeT optionLevel;		/* TCL_INDEX_NONE means no option information is currently
 				 * cached for this window. Otherwise this
 				 * gives the level in the option stack at
 				 * which info is cached. */
     /*
      * Information used by tkSelect.c to manage the selection.
@@ -888,22 +934,35 @@
     XIC inputContext;		/* XIM input context. */
     int ximGeneration;          /* Used to invalidate XIC */
 #endif /* TK_USE_INPUT_METHODS */
 } TkWindow;
 
+/*
+ * String tables:
+ */
+
+MODULE_SCOPE const char *const tkStateStrings[];
+MODULE_SCOPE const char *const tkCompoundStrings[];
+MODULE_SCOPE const char *const tkAnchorStrings[];
+MODULE_SCOPE const char *const tkReliefStrings[];
+MODULE_SCOPE const char *const tkJustifyStrings[];
+
 /*
  * Real definition of some events. Note that these events come from outside
  * but have internally generated pieces added to them.
  */
 
 typedef struct {
     XKeyEvent keyEvent;		/* The real event from X11. */
 #ifdef _WIN32
+#   ifndef XMaxTransChars
+#	define XMaxTransChars 7
+#   endif
     char trans_chars[XMaxTransChars];
                             /* translated characters */
     unsigned char nbytes;
-#elif !defined(MAC_OSC_TK)
+#elif !defined(MAC_OSX_TK)
     char *charValuePtr;		/* A pointer to a string that holds the key's
 				 * %A substitution text (before backslash
 				 * adding), or NULL if that has not been
 				 * computed yet. If non-NULL, this string was
 				 * allocated with ckalloc(). */
@@ -928,10 +987,13 @@
 #endif
 /* See TIP #537 */
 #ifndef TCL_INDEX_NONE
 #   define TCL_INDEX_NONE (-1)
 #endif
+#ifndef TCL_INDEX_END
+#   define TCL_INDEX_END ((TkSizeT)-2)
+#endif
 
 /*
  * The following structure is used with TkMakeEnsemble to create ensemble
  * commands and optionally to create sub-ensembles.
  */
@@ -1064,14 +1126,14 @@
  * outside world:
  */
 
 MODULE_SCOPE const Tk_SmoothMethod tkBezierSmoothMethod;
 MODULE_SCOPE Tk_ImageType	tkBitmapImageType;
-MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtGIF;
+MODULE_SCOPE Tk_PhotoImageFormatVersion3 tkImgFmtGIF;
 MODULE_SCOPE void		(*tkHandleEventProc) (XEvent* eventPtr);
 MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtDefault;
-MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtPNG;
+MODULE_SCOPE Tk_PhotoImageFormatVersion3 tkImgFmtPNG;
 MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtPPM;
 MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtSVGnano;
 MODULE_SCOPE TkMainInfo		*tkMainWindowList;
 MODULE_SCOPE Tk_ImageType	tkPhotoImageType;
 MODULE_SCOPE Tcl_HashTable	tkPredefBitmapTable;
@@ -1090,11 +1152,11 @@
 #define PI	3.14159265358979323846
 #endif
 #endif
 
 /*
- * Support for Clang Static Analyzer <http://clang-analyzer.llvm.org>
+ * Support for Clang Static Analyzer <https://clang-analyzer.llvm.org/>
  */
 
 #if defined(PURIFY) && defined(__clang__)
 #if __has_feature(attribute_analyzer_noreturn) && \
 	!defined(Tcl_Panic) && defined(Tcl_Panic_TCL_DECLARED)
@@ -1251,13 +1313,10 @@
 			    Tcl_Interp *interp, int objc,
 			    Tcl_Obj *const objv[]);
 MODULE_SCOPE int	Tk_SendObjCmd(ClientData clientData,
 			    Tcl_Interp *interp,int objc,
 			    Tcl_Obj *const objv[]);
-MODULE_SCOPE int	Tk_SendObjCmd(ClientData clientData,
-			    Tcl_Interp *interp, int objc,
-			    Tcl_Obj *const objv[]);
 MODULE_SCOPE int	Tk_SpinboxObjCmd(ClientData clientData,
 			    Tcl_Interp *interp, int objc,
 			    Tcl_Obj *const objv[]);
 MODULE_SCOPE int	Tk_TextObjCmd(ClientData clientData,
 			    Tcl_Interp *interp, int objc,
@@ -1283,11 +1342,11 @@
 			    const char *name);
 
 MODULE_SCOPE void	TkEventInit(void);
 MODULE_SCOPE void	TkRegisterObjTypes(void);
 MODULE_SCOPE int	TkDeadAppObjCmd(ClientData clientData,
-			    Tcl_Interp *interp, int objc, Tcl_Obj *const argv[]);
+			    Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
 MODULE_SCOPE int	TkCanvasGetCoordObj(Tcl_Interp *interp,
 			    Tk_Canvas canvas, Tcl_Obj *obj,
 			    double *doublePtr);
 MODULE_SCOPE int	TkGetDoublePixels(Tcl_Interp *interp, Tk_Window tkwin,
 			    const char *string, double *doublePtr);
@@ -1304,11 +1363,11 @@
 #define TkCanvasTagsPrintProc Tk_CanvasTagsPrintProc
 #endif
 MODULE_SCOPE void       TkMapTopFrame(Tk_Window tkwin);
 MODULE_SCOPE XEvent *	TkpGetBindingXEvent(Tcl_Interp *interp);
 MODULE_SCOPE void	TkCreateExitHandler(Tcl_ExitProc *proc,
-			    ClientData clientData);
+			    void *clientData);
 MODULE_SCOPE void	TkDeleteExitHandler(Tcl_ExitProc *proc,
 			    ClientData clientData);
 MODULE_SCOPE Tcl_ExitProc	TkFinalize;
 MODULE_SCOPE Tcl_ExitProc	TkFinalizeThread;
 MODULE_SCOPE void	TkpBuildRegionFromAlphaData(Region region,
@@ -1369,11 +1428,18 @@
 MODULE_SCOPE void	TkRotatePoint(double originX, double originY,
 			    double sine, double cosine, double *xPtr,
 			    double *yPtr);
 MODULE_SCOPE int TkGetIntForIndex(Tcl_Obj *, TkSizeT, int lastOK, TkSizeT*);
 
-#define TkNewIndexObj(value) Tcl_NewWideIntObj((Tcl_WideInt)(value + 1) - 1)
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
+#   define TkNewIndexObj(value) Tcl_NewWideIntObj((Tcl_WideInt)(value + 1) - 1)
+#   define TK_OPTION_UNDERLINE_DEF(type, field) "-1", TCL_INDEX_NONE, offsetof(type, field), 0, NULL
+#else
+#   define TkNewIndexObj(value) (((TkSizeT)(value) == TCL_INDEX_NONE) ? Tcl_NewObj() : Tcl_NewWideIntObj(value))
+#   define TK_OPTION_UNDERLINE_DEF(type, field) NULL, TCL_INDEX_NONE, offsetof(type, field), TK_OPTION_NULL_OK, NULL
+#endif
+
 
 #ifdef _WIN32
 #define TkParseColor XParseColor
 #else
 MODULE_SCOPE Status TkParseColor (Display * display,
@@ -1408,30 +1474,24 @@
 
 #if !defined(__cplusplus) && !defined(c_plusplus)
 # define c_class class
 #endif
 
-#if TCL_UTF_MAX > 4
+/* Tcl 8.6 has a different definition of Tcl_UniChar than other Tcl versions for TCL_UTF_MAX > 3 */
+#if TCL_UTF_MAX > (3 + (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 6))
 #   define TkUtfToUniChar(src, ch) (size_t)(((int (*)(const char *, int *))Tcl_UtfToUniChar)(src, ch))
 #   define TkUniCharToUtf(ch, src) (size_t)(((int (*)(int, char *))Tcl_UniCharToUtf)(ch, src))
-#   define TkUtfPrev Tcl_UtfPrev
 #else
     MODULE_SCOPE size_t TkUtfToUniChar(const char *, int *);
     MODULE_SCOPE size_t TkUniCharToUtf(int, char *);
-    MODULE_SCOPE const char *TkUtfPrev(const char *, const char *);
+#endif
+
+#if defined(_WIN32) && !defined(STATIC_BUILD) && TCL_MAJOR_VERSION < 9
+#   define tcl_CreateFileHandler reserved9
 #endif
 
-#if TCL_MAJOR_VERSION > 8
-#define TkGetStringFromObj(objPtr, lenPtr) \
-	(((objPtr)->bytes ? 0 : Tcl_GetString(objPtr)), \
-	*(lenPtr) = (objPtr)->length, (objPtr)->bytes)
-MODULE_SCOPE unsigned char *TkGetByteArrayFromObj(Tcl_Obj *objPtr,
-	size_t *lengthPtr);
-#else
-#define TkGetStringFromObj Tcl_GetStringFromObj
-#define TkGetByteArrayFromObj Tcl_GetByteArrayFromObj
-#endif
+MODULE_SCOPE  void       Icu_Init(Tcl_Interp* interp);
 
 /*
  * Unsupported commands.
  */
 

Index: generic/tkIntDecls.h
==================================================================
--- generic/tkIntDecls.h
+++ generic/tkIntDecls.h
@@ -4,11 +4,11 @@
  *	This file contains the declarations for all unsupported
  *	functions that are exported by the Tk library.  These
  *	interfaces are not guaranteed to remain the same between
  *	versions.  Use at your own risk.
  *
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright (c) 1998-1999 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -202,24 +202,27 @@
 /* 58 */
 EXTERN void		TkpDisplayWarning(const char *msg, const char *title);
 /* 59 */
 EXTERN void		TkpGetAppName(Tcl_Interp *interp, Tcl_DString *name);
 /* 60 */
-EXTERN TkWindow *	TkpGetOtherWindow(TkWindow *winPtr);
+TK_DEPRECATED("renamed to Tk_GetOtherWindow")
+TkWindow *		TkpGetOtherWindow(TkWindow *winPtr);
 /* 61 */
 EXTERN TkWindow *	TkpGetWrapperWindow(TkWindow *winPtr);
 /* 62 */
 EXTERN int		TkpInit(Tcl_Interp *interp);
 /* 63 */
 EXTERN void		TkpInitializeMenuBindings(Tcl_Interp *interp,
 				Tk_BindingTable bindingTable);
 /* 64 */
-EXTERN void		TkpMakeContainer(Tk_Window tkwin);
+TK_DEPRECATED("renamed to Tk_MakeContainer")
+void			TkpMakeContainer(Tk_Window tkwin);
 /* 65 */
 EXTERN void		TkpMakeMenuWindow(Tk_Window tkwin, int transient);
 /* 66 */
-EXTERN Window		TkpMakeWindow(TkWindow *winPtr, Window parent);
+TK_DEPRECATED("renamed to Tk_MakeWindow")
+Window			TkpMakeWindow(TkWindow *winPtr, Window parent);
 /* 67 */
 EXTERN void		TkpMenuNotifyToplevelCreate(Tcl_Interp *interp,
 				const char *menuName);
 /* 68 */
 EXTERN TkDisplay *	TkpOpenDisplay(const char *display_name);
@@ -235,14 +238,16 @@
 EXTERN int		TkPositionInTree(TkWindow *winPtr, TkWindow *treePtr);
 /* 73 */
 EXTERN void		TkpRedirectKeyEvent(TkWindow *winPtr,
 				XEvent *eventPtr);
 /* 74 */
-EXTERN void		TkpSetMainMenubar(Tcl_Interp *interp,
+TK_DEPRECATED("renamed to Tk_SetMainMenubar")
+void			TkpSetMainMenubar(Tcl_Interp *interp,
 				Tk_Window tkwin, const char *menuName);
 /* 75 */
-EXTERN int		TkpUseWindow(Tcl_Interp *interp, Tk_Window tkwin,
+TK_DEPRECATED("renamed to Tk_UseWindow")
+int			TkpUseWindow(Tcl_Interp *interp, Tk_Window tkwin,
 				const char *string);
 /* Slot 76 is reserved */
 /* 77 */
 EXTERN void		TkQueueEventForAllChildren(TkWindow *winPtr,
 				XEvent *eventPtr);
@@ -265,11 +270,12 @@
 EXTERN void		TkSelInit(Tk_Window tkwin);
 /* 83 */
 EXTERN void		TkSelPropProc(XEvent *eventPtr);
 /* Slot 84 is reserved */
 /* 85 */
-EXTERN void		TkSetWindowMenuBar(Tcl_Interp *interp,
+TK_DEPRECATED("renamed to Tk_SetWindowMenubar")
+void			TkSetWindowMenuBar(Tcl_Interp *interp,
 				Tk_Window tkwin, const char *oldMenuName,
 				const char *menuName);
 /* 86 */
 EXTERN KeySym		TkStringToKeysym(const char *name);
 /* 87 */
@@ -329,11 +335,12 @@
 EXTERN const char *	TkpGetString(TkWindow *winPtr, XEvent *eventPtr,
 				Tcl_DString *dsPtr);
 /* 110 */
 EXTERN void		TkpGetSubFonts(Tcl_Interp *interp, Tk_Font tkfont);
 /* 111 */
-EXTERN Tcl_Obj *	TkpGetSystemDefault(Tk_Window tkwin,
+TK_DEPRECATED("renamed to Tk_GetSystemDefault")
+Tcl_Obj *		TkpGetSystemDefault(Tk_Window tkwin,
 				const char *dbName, const char *className);
 /* 112 */
 EXTERN void		TkpMenuThreadInit(void);
 /* 113 */
 EXTERN int		XClipBox(Region rgn, XRectangle *rect_return);
@@ -377,11 +384,12 @@
 /* Slot 131 is reserved */
 /* Slot 132 is reserved */
 /* Slot 133 is reserved */
 /* Slot 134 is reserved */
 /* 135 */
-EXTERN void		TkpDrawHighlightBorder(Tk_Window tkwin, GC fgGC,
+TK_DEPRECATED("renamed to Tk_DrawHighlightBorder")
+void			TkpDrawHighlightBorder(Tk_Window tkwin, GC fgGC,
 				GC bgGC, int highlightWidth,
 				Drawable drawable);
 /* 136 */
 EXTERN void		TkSetFocusWin(TkWindow *winPtr, int force);
 /* 137 */
@@ -556,18 +564,14 @@
 /* 184 */
 EXTERN void		TkDrawAngledChars(Display *display,
 				Drawable drawable, GC gc, Tk_Font tkfont,
 				const char *source, int numBytes, double x,
 				double y, double angle);
-#ifdef MAC_OSX_TCL /* MACOSX */
 /* 185 */
 EXTERN void		TkpRedrawWidget(Tk_Window tkwin);
-#endif /* MACOSX */
-#ifdef MAC_OSX_TCL /* MACOSX */
 /* 186 */
 EXTERN int		TkpWillDrawWidget(Tk_Window tkwin);
-#endif /* MACOSX */
 /* 187 */
 EXTERN int		TkDebugPhotoStringMatchDef(Tcl_Interp *inter,
 				Tcl_Obj *data, Tcl_Obj *formatString,
 				int *widthPtr, int *heightPtr);
 
@@ -633,36 +637,36 @@
     int (*tkpChangeFocus) (TkWindow *winPtr, int force); /* 55 */
     void (*tkpCloseDisplay) (TkDisplay *dispPtr); /* 56 */
     void (*tkpClaimFocus) (TkWindow *topLevelPtr, int force); /* 57 */
     void (*tkpDisplayWarning) (const char *msg, const char *title); /* 58 */
     void (*tkpGetAppName) (Tcl_Interp *interp, Tcl_DString *name); /* 59 */
-    TkWindow * (*tkpGetOtherWindow) (TkWindow *winPtr); /* 60 */
+    TCL_DEPRECATED_API("renamed to Tk_GetOtherWindow") TkWindow * (*tkpGetOtherWindow) (TkWindow *winPtr); /* 60 */
     TkWindow * (*tkpGetWrapperWindow) (TkWindow *winPtr); /* 61 */
     int (*tkpInit) (Tcl_Interp *interp); /* 62 */
     void (*tkpInitializeMenuBindings) (Tcl_Interp *interp, Tk_BindingTable bindingTable); /* 63 */
-    void (*tkpMakeContainer) (Tk_Window tkwin); /* 64 */
+    TCL_DEPRECATED_API("renamed to Tk_MakeContainer") void (*tkpMakeContainer) (Tk_Window tkwin); /* 64 */
     void (*tkpMakeMenuWindow) (Tk_Window tkwin, int transient); /* 65 */
-    Window (*tkpMakeWindow) (TkWindow *winPtr, Window parent); /* 66 */
+    TCL_DEPRECATED_API("renamed to Tk_MakeWindow") Window (*tkpMakeWindow) (TkWindow *winPtr, Window parent); /* 66 */
     void (*tkpMenuNotifyToplevelCreate) (Tcl_Interp *interp, const char *menuName); /* 67 */
     TkDisplay * (*tkpOpenDisplay) (const char *display_name); /* 68 */
     int (*tkPointerEvent) (XEvent *eventPtr, TkWindow *winPtr); /* 69 */
     int (*tkPolygonToArea) (double *polyPtr, int numPoints, double *rectPtr); /* 70 */
     double (*tkPolygonToPoint) (double *polyPtr, int numPoints, double *pointPtr); /* 71 */
     int (*tkPositionInTree) (TkWindow *winPtr, TkWindow *treePtr); /* 72 */
     void (*tkpRedirectKeyEvent) (TkWindow *winPtr, XEvent *eventPtr); /* 73 */
-    void (*tkpSetMainMenubar) (Tcl_Interp *interp, Tk_Window tkwin, const char *menuName); /* 74 */
-    int (*tkpUseWindow) (Tcl_Interp *interp, Tk_Window tkwin, const char *string); /* 75 */
+    TCL_DEPRECATED_API("renamed to Tk_SetMainMenubar") void (*tkpSetMainMenubar) (Tcl_Interp *interp, Tk_Window tkwin, const char *menuName); /* 74 */
+    TCL_DEPRECATED_API("renamed to Tk_UseWindow") int (*tkpUseWindow) (Tcl_Interp *interp, Tk_Window tkwin, const char *string); /* 75 */
     void (*reserved76)(void);
     void (*tkQueueEventForAllChildren) (TkWindow *winPtr, XEvent *eventPtr); /* 77 */
     int (*tkReadBitmapFile) (Display *display, Drawable d, const char *filename, unsigned int *width_return, unsigned int *height_return, Pixmap *bitmap_return, int *x_hot_return, int *y_hot_return); /* 78 */
     int (*tkScrollWindow) (Tk_Window tkwin, GC gc, int x, int y, int width, int height, int dx, int dy, Region damageRgn); /* 79 */
     void (*tkSelDeadWindow) (TkWindow *winPtr); /* 80 */
     void (*tkSelEventProc) (Tk_Window tkwin, XEvent *eventPtr); /* 81 */
     void (*tkSelInit) (Tk_Window tkwin); /* 82 */
     void (*tkSelPropProc) (XEvent *eventPtr); /* 83 */
     void (*reserved84)(void);
-    void (*tkSetWindowMenuBar) (Tcl_Interp *interp, Tk_Window tkwin, const char *oldMenuName, const char *menuName); /* 85 */
+    TCL_DEPRECATED_API("renamed to Tk_SetWindowMenubar") void (*tkSetWindowMenuBar) (Tcl_Interp *interp, Tk_Window tkwin, const char *oldMenuName, const char *menuName); /* 85 */
     KeySym (*tkStringToKeysym) (const char *name); /* 86 */
     int (*tkThickPolyLineToArea) (double *coordPtr, int numPoints, double width, int capStyle, int joinStyle, double *rectPtr); /* 87 */
     void (*tkWmAddToColormapWindows) (TkWindow *winPtr); /* 88 */
     void (*tkWmDeadWindow) (TkWindow *winPtr); /* 89 */
     TkWindow * (*tkWmFocusToplevel) (TkWindow *winPtr); /* 90 */
@@ -684,11 +688,11 @@
     TkDisplay * (*tkGetDisplayList) (void); /* 106 */
     TkMainInfo * (*tkGetMainInfoList) (void); /* 107 */
     int (*tkGetWindowFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, Tk_Window *windowPtr); /* 108 */
     const char * (*tkpGetString) (TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr); /* 109 */
     void (*tkpGetSubFonts) (Tcl_Interp *interp, Tk_Font tkfont); /* 110 */
-    Tcl_Obj * (*tkpGetSystemDefault) (Tk_Window tkwin, const char *dbName, const char *className); /* 111 */
+    TCL_DEPRECATED_API("renamed to Tk_GetSystemDefault") Tcl_Obj * (*tkpGetSystemDefault) (Tk_Window tkwin, const char *dbName, const char *className); /* 111 */
     void (*tkpMenuThreadInit) (void); /* 112 */
     int (*xClipBox) (Region rgn, XRectangle *rect_return); /* 113 */
     Region (*xCreateRegion) (void); /* 114 */
     int (*xDestroyRegion) (Region rgn); /* 115 */
     int (*xIntersectRegion) (Region sra, Region srcb, Region dr_return); /* 116 */
@@ -735,11 +739,11 @@
     void (*reserved130)(void);
     void (*reserved131)(void);
     void (*reserved132)(void);
     void (*reserved133)(void);
     void (*reserved134)(void);
-    void (*tkpDrawHighlightBorder) (Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable); /* 135 */
+    TCL_DEPRECATED_API("renamed to Tk_DrawHighlightBorder") void (*tkpDrawHighlightBorder) (Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable); /* 135 */
     void (*tkSetFocusWin) (TkWindow *winPtr, int force); /* 136 */
     void (*tkpSetKeycodeAndState) (Tk_Window tkwin, KeySym keySym, XEvent *eventPtr); /* 137 */
     KeySym (*tkpGetKeySym) (TkDisplay *dispPtr, XEvent *eventPtr); /* 138 */
     void (*tkpInitKeymapInfo) (TkDisplay *dispPtr); /* 139 */
     Region (*tkPhotoGetValidRegion) (Tk_PhotoHandle handle); /* 140 */
@@ -785,28 +789,12 @@
     const char * (*tkSmoothPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 180 */
     void (*tkDrawAngledTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, double angle, int firstChar, int lastChar); /* 181 */
     void (*tkUnderlineAngledTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, double angle, int underline); /* 182 */
     int (*tkIntersectAngledTextLayout) (Tk_TextLayout layout, int x, int y, int width, int height, double angle); /* 183 */
     void (*tkDrawAngledChars) (Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, double x, double y, double angle); /* 184 */
-#if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */
-    void (*reserved185)(void);
-#endif /* UNIX */
-#if defined(_WIN32) /* WIN */
-    void (*reserved185)(void);
-#endif /* WIN */
-#ifdef MAC_OSX_TCL /* MACOSX */
     void (*tkpRedrawWidget) (Tk_Window tkwin); /* 185 */
-#endif /* MACOSX */
-#if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */
-    void (*reserved186)(void);
-#endif /* UNIX */
-#if defined(_WIN32) /* WIN */
-    void (*reserved186)(void);
-#endif /* WIN */
-#ifdef MAC_OSX_TCL /* MACOSX */
     int (*tkpWillDrawWidget) (Tk_Window tkwin); /* 186 */
-#endif /* MACOSX */
     int (*tkDebugPhotoStringMatchDef) (Tcl_Interp *inter, Tcl_Obj *data, Tcl_Obj *formatString, int *widthPtr, int *heightPtr); /* 187 */
 } TkIntStubs;
 
 extern const TkIntStubs *tkIntStubsPtr;
 
@@ -1176,18 +1164,14 @@
 	(tkIntStubsPtr->tkUnderlineAngledTextLayout) /* 182 */
 #define TkIntersectAngledTextLayout \
 	(tkIntStubsPtr->tkIntersectAngledTextLayout) /* 183 */
 #define TkDrawAngledChars \
 	(tkIntStubsPtr->tkDrawAngledChars) /* 184 */
-#ifdef MAC_OSX_TCL /* MACOSX */
 #define TkpRedrawWidget \
 	(tkIntStubsPtr->tkpRedrawWidget) /* 185 */
-#endif /* MACOSX */
-#ifdef MAC_OSX_TCL /* MACOSX */
 #define TkpWillDrawWidget \
 	(tkIntStubsPtr->tkpWillDrawWidget) /* 186 */
-#endif /* MACOSX */
 #define TkDebugPhotoStringMatchDef \
 	(tkIntStubsPtr->tkDebugPhotoStringMatchDef) /* 187 */
 
 #endif /* defined(USE_TK_STUBS) */
 
@@ -1202,14 +1186,33 @@
 #undef TkUnixDoOneXEvent_
 #undef TkUnixSetMenubar_
 #undef TkWmCleanup_
 #undef TkSendCleanup_
 #undef TkpTestsendCmd_
+#undef TkSetWindowMenuBar
+#undef TkpDrawHighlightBorder
+#undef TkpUseWindow
+#undef TkpSetMainMenubar
+#undef TkpGetOtherWindow
+#undef TkpGetSystemDefault
+#undef TkpMakeContainer
+#undef TkpMakeWindow
+
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION == 8)
+#   define TkSetWindowMenuBar Tk_SetWindowMenubar
+#   define TkpDrawHighlightBorder Tk_DrawHighlightBorder
+#   define TkpUseWindow Tk_UseWindow
+#   define TkpSetMainMenubar Tk_SetMainMenubar
+#   define TkpGetOtherWindow ((TkWindow *(*)(TkWindow *))(void *)Tk_GetOtherWindow)
+#   define TkpGetSystemDefault Tk_GetSystemDefault
+#   define TkpMakeContainer Tk_MakeContainer
+#   define TkpMakeWindow ((Window (*)(TkWindow *, Window))(void *)Tk_MakeWindow)
+#endif
 
-#if !defined(MAC_OSX_TK)
+#if !defined(MAC_OSX_TK) && !defined(USE_TK_STUBS)
 #   undef TkpWillDrawWidget
 #   undef TkpRedrawWidget
 #   define TkpWillDrawWidget(w) 0
 #   define TkpRedrawWidget(w)
 #endif
 
 #endif /* _TKINTDECLS */

Index: generic/tkIntPlatDecls.h
==================================================================
--- generic/tkIntPlatDecls.h
+++ generic/tkIntPlatDecls.h
@@ -4,11 +4,11 @@
  *	This file contains the declarations for all platform dependent
  *	unsupported functions that are exported by the Tk library.  These
  *	interfaces are not guaranteed to remain the same between
  *	versions.  Use at your own risk.
  *
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright (c) 1998-1999 Scriptics Corporation.
  * All rights reserved.
  */
 
 #ifndef _TKINTPLATDECLS
 #define _TKINTPLATDECLS

Index: generic/tkIntXlibDecls.h
==================================================================
--- generic/tkIntXlibDecls.h
+++ generic/tkIntXlibDecls.h
@@ -4,11 +4,11 @@
  *	This file contains the declarations for all platform dependent
  *	unsupported functions that are exported by the Tk library.  These
  *	interfaces are not guaranteed to remain the same between
  *	versions.  Use at your own risk.
  *
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright (c) 1998-1999 Scriptics Corporation.
  * All rights reserved.
  */
 
 #ifndef _TKINTXLIBDECLS
 #define _TKINTXLIBDECLS

Index: generic/tkListbox.c
==================================================================
--- generic/tkListbox.c
+++ generic/tkListbox.c
@@ -3,12 +3,12 @@
  *
  *	This module implements listbox widgets for the Tk toolkit. A listbox
  *	displays a collection of strings, one per line, and provides scrolling
  *	and selection.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -218,14 +218,10 @@
 
 enum state {
     STATE_DISABLED, STATE_NORMAL
 };
 
-static const char *const stateStrings[] = {
-    "disabled", "normal", NULL
-};
-
 enum activeStyle {
     ACTIVE_STYLE_DOTBOX, ACTIVE_STYLE_NONE, ACTIVE_STYLE_UNDERLINE
 };
 
 static const char *const activeStyleStrings[] = {
@@ -295,11 +291,11 @@
 	 TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid",
 	 DEF_LISTBOX_SET_GRID, TCL_INDEX_NONE, offsetof(Listbox, setGrid), 0, 0, 0},
     {TK_OPTION_STRING_TABLE, "-state", "state", "State",
 	DEF_LISTBOX_STATE, TCL_INDEX_NONE, offsetof(Listbox, state),
-	0, stateStrings, 0},
+	0, &tkStateStrings[1], 0},
     {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
 	 DEF_LISTBOX_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Listbox, takeFocus),
 	 TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_INT, "-width", "width", "Width",
 	 DEF_LISTBOX_WIDTH, TCL_INDEX_NONE, offsetof(Listbox, width), 0, 0, 0},
@@ -321,26 +317,26 @@
  */
 
 static const Tk_OptionSpec itemAttrOptionSpecs[] = {
     {TK_OPTION_BORDER, "-background", "background", "Background",
      NULL, TCL_INDEX_NONE, offsetof(ItemAttr, border),
-     TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT,
+     TK_OPTION_NULL_OK,
      DEF_LISTBOX_BG_MONO, 0},
     {TK_OPTION_SYNONYM, "-bg", NULL, NULL,
      NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
     {TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
      NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
     {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
      NULL, TCL_INDEX_NONE, offsetof(ItemAttr, fgColor),
-     TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0},
+     TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
      NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selBorder),
-     TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT,
+     TK_OPTION_NULL_OK,
      DEF_LISTBOX_SELECT_MONO, 0},
     {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
      NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selFgColor),
-     TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT,
+     TK_OPTION_NULL_OK,
      DEF_LISTBOX_SELECT_FG_MONO, 0},
     {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
 };
 
 /*
@@ -368,14 +364,14 @@
 enum selcommand {
     SELECTION_ANCHOR, SELECTION_CLEAR, SELECTION_INCLUDES, SELECTION_SET
 };
 
 static const char *const scanCommandNames[] = {
-    "mark", "dragto", NULL
+    "dragto", "mark", NULL
 };
 enum scancommand {
-    SCAN_MARK, SCAN_DRAGTO
+    SCAN_DRAGTO, SCAN_MARK
 };
 
 static const char *const indexNames[] = {
     "active", "anchor", NULL
 };
@@ -1114,11 +1110,11 @@
 	result = Tcl_ListObjIndex(interp, listPtr->listObj, index, &el);
 	if (result != TCL_OK) {
 	    return result;
 	}
 
-	stringRep = TkGetStringFromObj(el, &stringLen);
+	stringRep = Tcl_GetStringFromObj(el, &stringLen);
 	Tk_GetFontMetrics(listPtr->tkfont, &fm);
 	pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen);
 
         if (listPtr->justify == TK_JUSTIFY_LEFT) {
             x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset;
@@ -2077,11 +2073,11 @@
 	/*
 	 * Draw the actual text of this item.
 	 */
 
         Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement);
-        stringRep = TkGetStringFromObj(curElement, &stringLen);
+        stringRep = Tcl_GetStringFromObj(curElement, &stringLen);
         textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen);
 
 	Tk_GetFontMetrics(listPtr->tkfont, &fm);
 	y += fm.ascent + listPtr->selBorderWidth;
 
@@ -2190,14 +2186,14 @@
 	GC fgGC, bgGC;
 
 	bgGC = Tk_GCForColor(listPtr->highlightBgColorPtr, pixmap);
 	if (listPtr->flags & GOT_FOCUS) {
 	    fgGC = Tk_GCForColor(listPtr->highlightColorPtr, pixmap);
-	    TkpDrawHighlightBorder(tkwin, fgGC, bgGC,
+	    Tk_DrawHighlightBorder(tkwin, fgGC, bgGC,
 		    listPtr->highlightWidth, pixmap);
 	} else {
-	    TkpDrawHighlightBorder(tkwin, bgGC, bgGC,
+	    Tk_DrawHighlightBorder(tkwin, bgGC, bgGC,
 		    listPtr->highlightWidth, pixmap);
 	}
     }
 #ifndef TK_NO_DOUBLE_BUFFERING
     XCopyArea(listPtr->display, pixmap, Tk_WindowId(tkwin),
@@ -2261,11 +2257,11 @@
 	    result = Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i,
 		    &element);
 	    if (result != TCL_OK) {
 		continue;
 	    }
-	    text = TkGetStringFromObj(element, &textLength);
+	    text = Tcl_GetStringFromObj(element, &textLength);
 	    Tk_GetFontMetrics(listPtr->tkfont, &fm);
 	    pixelWidth = Tk_TextWidth(listPtr->tkfont, text, textLength);
 	    if (pixelWidth > listPtr->maxWidth) {
 		listPtr->maxWidth = pixelWidth;
 	    }
@@ -2339,11 +2335,11 @@
 	/*
 	 * Check if any of the new elements are wider than the current widest;
 	 * if so, update our notion of "widest."
 	 */
 
-	stringRep = TkGetStringFromObj(objv[i], &length);
+	stringRep = Tcl_GetStringFromObj(objv[i], &length);
 	pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, length);
 	if (pixelWidth > listPtr->maxWidth) {
 	    listPtr->maxWidth = pixelWidth;
 	}
     }
@@ -2498,11 +2494,11 @@
 	 * element to disappear for us to have to recompute the width.
 	 */
 
 	if (widthChanged == 0) {
 	    Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &element);
-	    stringRep = TkGetStringFromObj(element, &length);
+	    stringRep = Tcl_GetStringFromObj(element, &length);
 	    pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, length);
 	    if (pixelWidth == listPtr->maxWidth) {
 		widthChanged = 1;
 	    }
 	}
@@ -2802,11 +2798,11 @@
      */
 
   badIndex:
     Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 	    "bad listbox index \"%s\": must be active, anchor, end, @x,y,"
-	    " or a number", Tcl_GetString(indexObj)));
+	    " or an index", Tcl_GetString(indexObj)));
     Tcl_SetErrorCode(interp, "TK", "VALUE", "LISTBOX_INDEX", NULL);
     return TCL_ERROR;
 }
 
 /*
@@ -3146,11 +3142,11 @@
 	    if (needNewline) {
 		Tcl_DStringAppend(&selection, "\n", 1);
 	    }
 	    Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i,
 		    &curElement);
-	    stringRep = TkGetStringFromObj(curElement, &stringLen);
+	    stringRep = Tcl_GetStringFromObj(curElement, &stringLen);
 	    Tcl_DStringAppend(&selection, stringRep, stringLen);
 	    needNewline = 1;
 	}
     }
 
@@ -3453,18 +3449,18 @@
      */
 
     if (flags & TCL_TRACE_UNSETS) {
 
         if (!Tcl_InterpDeleted(interp) && listPtr->listVarName) {
-            ClientData probe = NULL;
+            void *probe = NULL;
 
             do {
                 probe = Tcl_VarTraceInfo(interp,
                         listPtr->listVarName,
                         TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
                         ListboxListVarProc, probe);
-                if (probe == (ClientData)listPtr) {
+                if (probe == (void *)listPtr) {
                     break;
                 }
             } while (probe);
             if (probe) {
                 /*

Index: generic/tkMacWinMenu.c
==================================================================
--- generic/tkMacWinMenu.c
+++ generic/tkMacWinMenu.c
@@ -2,11 +2,11 @@
  * tkMacWinMenu.c --
  *
  *	This module implements the common elements of the Mac and Windows
  *	specific features of menus. This file is not used for UNIX.
  *
- * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkMain.c
==================================================================
--- generic/tkMain.c
+++ generic/tkMain.c
@@ -23,15 +23,14 @@
  */
 
 static const char DEFAULT_PRIMARY_PROMPT[] = "% ";
 
 /*
- * This file can be compiled on Windows in UNICODE mode, as well as
- * on all other platforms using the native encoding. This is done
- * by using the normal Windows functions like _tcscmp, but on
- * platforms which don't have <tchar.h> we have to translate that
- * to strcmp here.
+ * This file can be compiled on Windows in UNICODE mode, as well as on all
+ * other platforms using the native encoding. This is done by using the normal
+ * Windows functions like _tcscmp, but on platforms which don't have <tchar.h>
+ * we have to translate that to strcmp here.
  */
 #ifdef _WIN32
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -66,24 +65,24 @@
     TCHAR *string)
 {
     Tcl_Obj *obj;
     Tcl_DString ds;
 
-#ifdef UNICODE
+#if defined(_WIN32) && defined(UNICODE)
     Tcl_DStringInit(&ds);
     Tcl_WCharToUtfDString(string, wcslen(string), &ds);
 #else
-    Tcl_ExternalToUtfDString(NULL, (char *) string, -1, &ds);
+    (void)Tcl_ExternalToUtfDStringEx(NULL, (char *)string, -1, TCL_ENCODING_NOCOMPLAIN, &ds);
 #endif
     obj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
     Tcl_DStringFree(&ds);
     return obj;
 }
 
 /*
  * Declarations for various library functions and variables (don't want to
- * include tkInt.h or tkPort.h here, because people might copy this file out
+ * include tclInt.h or tclPort.h here, because people might copy this file out
  * of the Tk source directory to make their own modified versions). Note: do
  * not declare "exit" here even though a declaration is really needed, because
  * it will conflict with a declaration elsewhere on some systems.
  */
 
@@ -98,11 +97,11 @@
      * always claim to be running on a tty. This probably isn't the right way
      * to do it.
      */
 
 #if !defined(STATIC_BUILD)
-	if (tclStubsPtr->reserved9 && tclIntPlatStubsPtr->tclpIsAtty) {
+	if (tclStubsPtr->tcl_CreateFileHandler && tclIntPlatStubsPtr->tclpIsAtty) {
 	    /* We are running on Cygwin */
 	    return tclIntPlatStubsPtr->tclpIsAtty(fd);
 	}
 #endif
     handle = GetStdHandle(STD_INPUT_HANDLE + fd);
@@ -116,11 +115,11 @@
 }
 #else
 extern int		isatty(int fd);
 #endif
 
-typedef struct InteractiveState {
+typedef struct {
     Tcl_Channel input;		/* The standard input channel from which lines
 				 * are read. */
     int tty;			/* Non-zero means standard input is a
 				 * terminal-like device. Zero means it's a
 				 * file. */
@@ -167,15 +166,21 @@
 				/* Application-specific initialization
 				 * function to call after most initialization
 				 * but before starting to execute commands. */
     Tcl_Interp *interp)
 {
+    int i=0;			/* argv[i] index */
     Tcl_Obj *path, *argvPtr, *appName;
     const char *encodingName;
     int code, nullStdin = 0;
     Tcl_Channel chan;
     InteractiveState is;
+
+    if (0 < argc) {
+	--argc;			/* "consume" argv[0] */
+	++i;
+    }
 
     /*
      * Ensure that we are getting a compatible version of Tcl.
      */
 
@@ -187,11 +192,11 @@
 	}
     }
 
 #if defined(_WIN32) && !defined(UNICODE) && !defined(STATIC_BUILD)
 
-    if (tclStubsPtr->reserved9) {
+    if (tclStubsPtr->tcl_CreateFileHandler) {
 	/* We are running win32 Tk under Cygwin, so let's check
 	 * whether the env("DISPLAY") variable or the -display
 	 * argument is set. If so, we really want to run the
 	 * Tk_MainEx function of libtk8.?.dll, not this one. */
 	if (Tcl_GetVar2(interp, "env", "DISPLAY", TCL_GLOBAL_ONLY)) {
@@ -199,14 +204,14 @@
 	    if (TkCygwinMainEx(argc, argv, appInitProc, interp)) {
 		/* Should never reach here. */
 		return;
 	    }
 	} else {
-	    int i;
+	    int j;
 
-	    for (i = 1; i < argc; ++i) {
-		if (!_tcscmp(argv[i], TEXT("-display"))) {
+	    for (j = 1; j < argc; ++j) {
+		if (!strcmp(argv[j], "-display")) {
 		    goto loadCygwinTk;
 		}
 	    }
 	}
     }
@@ -219,11 +224,11 @@
     Tcl_Preserve(interp);
 
 #if defined(_WIN32)
 #if !defined(STATIC_BUILD)
     /* If compiled for Win32 but running on Cygwin, don't use console */
-    if (!tclStubsPtr->reserved9)
+    if (!tclStubsPtr->tcl_CreateFileHandler)
 #endif
     Tk_InitConsoleChannels(interp);
 #endif
 
 #ifdef MAC_OSX_TK
@@ -237,38 +242,44 @@
      * first few command line arguments to determine the script path and
      * encoding.
      */
 
     if (NULL == Tcl_GetStartupScript(NULL)) {
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
 	size_t length;
+#endif
 
 	/*
 	 * Check whether first 3 args (argv[1] - argv[3]) look like
 	 *  -encoding ENCODING FILENAME
 	 * or like
 	 *  FILENAME
 	 * or like
-	 *  -file FILENAME		(ancient history support only)
+	 *  -file FILENAME (ancient history support only, removed with Tcl 9.0)
 	 */
 
-	if ((argc > 3) && (0 == _tcscmp(TEXT("-encoding"), argv[1]))
-		&& (TEXT('-') != argv[3][0])) {
+	/* mind argc is being adjusted as we proceed */
+	if ((argc >= 3) && (0 == _tcscmp(TEXT("-encoding"), argv[1]))
+		&& ('-' != argv[3][0])) {
 	    Tcl_Obj *value = NewNativeObj(argv[2]);
-	    Tcl_SetStartupScript(NewNativeObj(argv[3]), Tcl_GetString(value));
+	    Tcl_SetStartupScript(NewNativeObj(argv[3]),
+		    Tcl_GetString(value));
 	    Tcl_DecrRefCount(value);
 	    argc -= 3;
-	    argv += 3;
-	} else if ((argc > 1) && (TEXT('-') != argv[1][0])) {
+	    i += 3;
+	} else if ((argc >= 1) && ('-' != argv[1][0])) {
 	    Tcl_SetStartupScript(NewNativeObj(argv[1]), NULL);
 	    argc--;
-	    argv++;
-	} else if ((argc > 2) && (length = _tcslen(argv[1]))
+	    i++;
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
+	} else if ((argc >= 2) && (length = _tcslen(argv[1]))
 		&& (length > 1) && (0 == _tcsncmp(TEXT("-file"), argv[1], length))
-		&& (TEXT('-') != argv[2][0])) {
+		&& ('-' != argv[2][0])) {
 	    Tcl_SetStartupScript(NewNativeObj(argv[2]), NULL);
 	    argc -= 2;
-	    argv += 2;
+	    i += 2;
+#endif
 	}
     }
 
     path = Tcl_GetStartupScript(&encodingName);
     if (path == NULL) {
@@ -275,18 +286,16 @@
 	appName = NewNativeObj(argv[0]);
     } else {
 	appName = path;
     }
     Tcl_SetVar2Ex(interp, "argv0", NULL, appName, TCL_GLOBAL_ONLY);
-    argc--;
-    argv++;
 
     Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewWideIntObj(argc), TCL_GLOBAL_ONLY);
 
     argvPtr = Tcl_NewListObj(0, NULL);
     while (argc--) {
-	Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(*argv++));
+	Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(argv[i++]));
     }
     Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
 
     /*
      * Set the "tcl_interactive" variable.
@@ -401,27 +410,32 @@
  */
 
 static void
 StdinProc(
     ClientData clientData,	/* The state of interactive cmd line */
-    TCL_UNUSED(int))
+    TCL_UNUSED(int) /*mask*/)
 {
     char *cmd;
     int code;
-    TkSizeT count;
+    int length;
     InteractiveState *isPtr = (InteractiveState *)clientData;
     Tcl_Channel chan = isPtr->input;
     Tcl_Interp *interp = isPtr->interp;
 
-    count = Tcl_Gets(chan, &isPtr->line);
+    length = Tcl_Gets(chan, &isPtr->line);
 
-    if ((count == TCL_IO_FAILURE) && !isPtr->gotPartial) {
+    if ((length < 0) && !isPtr->gotPartial) {
 	if (isPtr->tty) {
+	    /*
+	     * Would be better to find a way to exit the mainLoop? Or perhaps
+	     * evaluate [exit]? Leaving as is for now due to compatibility
+	     * concerns.
+	     */
+
 	    Tcl_Exit(0);
-	} else {
-	    Tcl_DeleteChannelHandler(chan, StdinProc, isPtr);
 	}
+	Tcl_DeleteChannelHandler(chan, StdinProc, isPtr);
 	return;
     }
 
     Tcl_DStringAppend(&isPtr->command, Tcl_DStringValue(&isPtr->line), -1);
     cmd = Tcl_DStringAppend(&isPtr->command, "\n", -1);
@@ -439,24 +453,33 @@
      * things, this will trash the text of the command being evaluated.
      */
 
     Tcl_CreateChannelHandler(chan, 0, StdinProc, isPtr);
     code = Tcl_RecordAndEval(interp, cmd, TCL_EVAL_GLOBAL);
-
-    isPtr->input = Tcl_GetStdChannel(TCL_STDIN);
-    if (isPtr->input) {
-	Tcl_CreateChannelHandler(isPtr->input, TCL_READABLE, StdinProc, isPtr);
+    isPtr->input = chan = Tcl_GetStdChannel(TCL_STDIN);
+    if (chan != NULL) {
+	Tcl_CreateChannelHandler(chan, TCL_READABLE, StdinProc, isPtr);
     }
     Tcl_DStringFree(&isPtr->command);
-    if (Tcl_GetString(Tcl_GetObjResult(interp))[0] != '\0') {
-	if ((code != TCL_OK) || (isPtr->tty)) {
-	    chan = Tcl_GetStdChannel((code != TCL_OK) ? TCL_STDERR : TCL_STDOUT);
-	    if (chan) {
-		Tcl_WriteObj(chan, Tcl_GetObjResult(interp));
-		Tcl_WriteChars(chan, "\n", 1);
-	    }
-	}
+    if (code != TCL_OK) {
+	chan = Tcl_GetStdChannel(TCL_STDERR);
+
+	if (chan != NULL) {
+	    Tcl_WriteObj(chan, Tcl_GetObjResult(interp));
+	    Tcl_WriteChars(chan, "\n", 1);
+	}
+    } else if (isPtr->tty) {
+	Tcl_Obj *resultPtr = Tcl_GetObjResult(interp);
+	chan = Tcl_GetStdChannel(TCL_STDOUT);
+
+	Tcl_IncrRefCount(resultPtr);
+	(void)Tcl_GetStringFromObj(resultPtr, &length);
+	if ((length > 0) && (chan != NULL)) {
+	    Tcl_WriteObj(chan, resultPtr);
+	    Tcl_WriteChars(chan, "\n", 1);
+	}
+	Tcl_DecrRefCount(resultPtr);
     }
 
     /*
      * If a tty stdin is still around, output a prompt.
      */
@@ -508,16 +531,14 @@
     } else {
 	code = Tcl_EvalObjEx(interp, promptCmdPtr, TCL_EVAL_GLOBAL);
 	if (code != TCL_OK) {
 	    Tcl_AddErrorInfo(interp,
 		    "\n    (script that generates prompt)");
-	    if (Tcl_GetString(Tcl_GetObjResult(interp))[0] != '\0') {
-		chan = Tcl_GetStdChannel(TCL_STDERR);
-		if (chan != NULL) {
-		    Tcl_WriteObj(chan, Tcl_GetObjResult(interp));
-		    Tcl_WriteChars(chan, "\n", 1);
-		}
+	    chan = Tcl_GetStdChannel(TCL_STDERR);
+	    if (chan != NULL) {
+		Tcl_WriteObj(chan, Tcl_GetObjResult(interp));
+		Tcl_WriteChars(chan, "\n", 1);
 	    }
 	    goto defaultPrompt;
 	}
     }
 

Index: generic/tkMenu.c
==================================================================
--- generic/tkMenu.c
+++ generic/tkMenu.c
@@ -4,12 +4,12 @@
  * This file contains most of the code for implementing menus in Tk. It takes
  * care of all of the generic (platform-independent) parts of menus, and is
  * supplemented by platform-specific files. The geometry calculation and
  * drawing code for menus is in the file tkMenuDraw.c
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1998 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1998 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -99,25 +99,14 @@
 /*
  * Configuration specs for individual menu entries. If this changes, be sure
  * to update code in TkpMenuInit that changes the font string entry.
  */
 
-static const char *const menuStateStrings[] = {"active", "normal", "disabled", NULL};
-
 static const char *const menuEntryTypeStrings[] = {
     "cascade", "checkbutton", "command", "radiobutton", "separator", NULL
 };
 
-/*
- * The following table defines the legal values for the -compound option. It
- * is used with the "enum compound" declaration in tkMenu.h
- */
-
-static const char *const compoundStrings[] = {
-    "bottom", "center", "left", "none", "right", "top", NULL
-};
-
 static const Tk_OptionSpec tkBasicMenuEntryConfigSpecs[] = {
     {TK_OPTION_BORDER, "-activebackground", NULL, NULL,
 	DEF_MENU_ENTRY_ACTIVE_BG, offsetof(TkMenuEntry, activeBorderPtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, NULL, 0},
     {TK_OPTION_COLOR, "-activeforeground", NULL, NULL,
@@ -138,11 +127,11 @@
     {TK_OPTION_STRING, "-command", NULL, NULL,
 	DEF_MENU_ENTRY_COMMAND,
 	offsetof(TkMenuEntry, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
     {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
 	DEF_MENU_ENTRY_COMPOUND, TCL_INDEX_NONE, offsetof(TkMenuEntry, compound), 0,
-	(ClientData) compoundStrings, 0},
+	tkCompoundStrings, 0},
     {TK_OPTION_FONT, "-font", NULL, NULL,
 	DEF_MENU_ENTRY_FONT,
 	offsetof(TkMenuEntry, fontPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
     {TK_OPTION_COLOR, "-foreground", NULL, NULL,
 	DEF_MENU_ENTRY_FG,
@@ -156,14 +145,14 @@
     {TK_OPTION_STRING, "-label", NULL, NULL,
 	DEF_MENU_ENTRY_LABEL,
 	offsetof(TkMenuEntry, labelPtr), TCL_INDEX_NONE, 0, NULL, 0},
     {TK_OPTION_STRING_TABLE, "-state", NULL, NULL,
 	DEF_MENU_ENTRY_STATE,
-	TCL_INDEX_NONE, offsetof(TkMenuEntry, state), 0,
-	(ClientData) menuStateStrings, 0},
-    {TK_OPTION_INT, "-underline", NULL, NULL,
-	DEF_MENU_ENTRY_UNDERLINE, TCL_INDEX_NONE, offsetof(TkMenuEntry, underline), 0, NULL, 0},
+	TCL_INDEX_NONE, offsetof(TkMenuEntry, state),
+	0, tkStateStrings, 0},
+    {TK_OPTION_INDEX, "-underline", NULL, NULL,
+	TK_OPTION_UNDERLINE_DEF(TkMenuEntry, underline), 0},
     {TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
 };
 
 static const Tk_OptionSpec tkSeparatorEntryConfigSpecs[] = {
     {TK_OPTION_BORDER, "-background", NULL, NULL,
@@ -226,12 +215,12 @@
 static const Tk_OptionSpec tkTearoffEntryConfigSpecs[] = {
     {TK_OPTION_BORDER, "-background", NULL, NULL,
 	DEF_MENU_ENTRY_BG,
 	offsetof(TkMenuEntry, borderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
     {TK_OPTION_STRING_TABLE, "-state", NULL, NULL,
-	DEF_MENU_ENTRY_STATE, TCL_INDEX_NONE, offsetof(TkMenuEntry, state), 0,
-	(ClientData) menuStateStrings, 0},
+	DEF_MENU_ENTRY_STATE, TCL_INDEX_NONE, offsetof(TkMenuEntry, state),
+	0, tkStateStrings, 0},
     {TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
 };
 
 static const Tk_OptionSpec *specsArray[] = {
     tkCascadeEntryConfigSpecs, tkCheckButtonEntryConfigSpecs,
@@ -242,31 +231,31 @@
 /*
  * Menu type strings for use with Tcl_GetIndexFromObj.
  */
 
 static const char *const menuTypeStrings[] = {
-    "normal", "tearoff", "menubar", NULL
+    "menubar", "normal", "tearoff", NULL
 };
 
 static const Tk_OptionSpec tkMenuConfigSpecs[] = {
     {TK_OPTION_BORDER, "-activebackground", "activeBackground",
 	"Foreground", DEF_MENU_ACTIVE_BG_COLOR,
 	offsetof(TkMenu, activeBorderPtr), TCL_INDEX_NONE, 0,
-	(ClientData) DEF_MENU_ACTIVE_BG_MONO, 0},
+	DEF_MENU_ACTIVE_BG_MONO, 0},
     {TK_OPTION_PIXELS, "-activeborderwidth", "activeBorderWidth",
 	"BorderWidth", DEF_MENU_ACTIVE_BORDER_WIDTH,
 	offsetof(TkMenu, activeBorderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0},
     {TK_OPTION_COLOR, "-activeforeground", "activeForeground",
 	"Background", DEF_MENU_ACTIVE_FG_COLOR,
 	offsetof(TkMenu, activeFgPtr), TCL_INDEX_NONE, 0,
-	(ClientData) DEF_MENU_ACTIVE_FG_MONO, 0},
+	DEF_MENU_ACTIVE_FG_MONO, 0},
     {TK_OPTION_RELIEF, "-activerelief", "activeRelief", "Relief",
 	DEF_MENU_ACTIVE_RELIEF, offsetof(TkMenu, activeReliefPtr),
 	TCL_INDEX_NONE, 0, NULL, 0},
     {TK_OPTION_BORDER, "-background", "background", "Background",
 	DEF_MENU_BG_COLOR, offsetof(TkMenu, borderPtr), TCL_INDEX_NONE, 0,
-	(ClientData) DEF_MENU_BG_MONO, 0},
+	DEF_MENU_BG_MONO, 0},
     {TK_OPTION_SYNONYM, "-bd", NULL, NULL,
 	NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
     {TK_OPTION_SYNONYM, "-bg", NULL, NULL,
 	NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
     {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
@@ -276,11 +265,11 @@
 	DEF_MENU_CURSOR,
 	offsetof(TkMenu, cursorPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
     {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
 	"DisabledForeground", DEF_MENU_DISABLED_FG_COLOR,
 	offsetof(TkMenu, disabledFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK,
-	(ClientData) DEF_MENU_DISABLED_FG_MONO, 0},
+	DEF_MENU_DISABLED_FG_MONO, 0},
     {TK_OPTION_SYNONYM, "-fg", NULL, NULL,
 	NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
     {TK_OPTION_FONT, "-font", "font", "Font",
 	DEF_MENU_FONT, offsetof(TkMenu, fontPtr), TCL_INDEX_NONE, 0, NULL, 0},
     {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
@@ -290,11 +279,11 @@
 	offsetof(TkMenu, postCommandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
     {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
 	DEF_MENU_RELIEF, offsetof(TkMenu, reliefPtr), TCL_INDEX_NONE, 0, NULL, 0},
     {TK_OPTION_COLOR, "-selectcolor", "selectColor", "Background",
 	DEF_MENU_SELECT_COLOR, offsetof(TkMenu, indicatorFgPtr), TCL_INDEX_NONE, 0,
-	(ClientData) DEF_MENU_SELECT_MONO, 0},
+	DEF_MENU_SELECT_MONO, 0},
     {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
 	DEF_MENU_TAKE_FOCUS,
 	offsetof(TkMenu, takeFocusPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
     {TK_OPTION_BOOLEAN, "-tearoff", "tearOff", "TearOff",
 	DEF_MENU_TEAROFF, TCL_INDEX_NONE, offsetof(TkMenu, tearoff), 0, NULL, 0},
@@ -303,12 +292,12 @@
 	offsetof(TkMenu, tearoffCommandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
     {TK_OPTION_STRING, "-title", "title", "Title",
 	DEF_MENU_TITLE,	 offsetof(TkMenu, titlePtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, NULL, 0},
     {TK_OPTION_STRING_TABLE, "-type", "type", "Type",
-	DEF_MENU_TYPE, offsetof(TkMenu, menuTypePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK,
-	(ClientData) menuTypeStrings, 0},
+	DEF_MENU_TYPE, offsetof(TkMenu, menuTypePtr), TCL_INDEX_NONE,
+	0, menuTypeStrings, 0},
     {TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
 };
 
 /*
  * Command line options. Put here because MenuCmd has to look at them along
@@ -578,18 +567,18 @@
     	TkMenuTopLevelList *nextPtr;
     	Tk_Window listtkwin;
 
 	while (topLevelListPtr != NULL) {
     	    /*
-    	     * Need to get the next pointer first. TkSetWindowMenuBar changes
+    	     * Need to get the next pointer first. Tk_SetWindowMenubar changes
     	     * the list, so that the next pointer is different after calling
     	     * it.
     	     */
 
     	    nextPtr = topLevelListPtr->nextPtr;
     	    listtkwin = topLevelListPtr->tkwin;
-    	    TkSetWindowMenuBar(menuPtr->interp, listtkwin,
+    	    Tk_SetWindowMenubar(menuPtr->interp, listtkwin,
     	    	    Tk_PathName(menuPtr->tkwin), Tk_PathName(menuPtr->tkwin));
     	    topLevelListPtr = nextPtr;
     	}
     }
 
@@ -841,13 +830,15 @@
 	    goto error;
 	}
 	if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
 	    goto error;
 	}
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
 	if (index == TCL_INDEX_NONE) {
-	    Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1));
+	    Tcl_SetObjResult(interp, Tcl_NewObj());
 	} else
+#endif
 	Tcl_SetObjResult(interp, TkNewIndexObj(index));
 	break;
     }
     case MENU_INSERT:
 	if (objc < 4) {
@@ -1195,10 +1186,11 @@
 	DestroyMenuEntry(menuPtr->entries[i]);
 	menuPtr->numEntries = i;
     }
     if (menuPtr->entries != NULL) {
 	ckfree(menuPtr->entries);
+	menuPtr->entries = NULL;
     }
     TkMenuFreeDrawOptions(menuPtr);
     Tk_FreeConfigOptions((char *) menuPtr,
 	    tsdPtr->menuOptionTable, menuPtr->tkwin);
     if (menuPtr->tkwin != NULL) {
@@ -1708,16 +1700,16 @@
      */
 
     if (mePtr->labelPtr == NULL) {
 	mePtr->labelLength = 0;
     } else {
-	(void)TkGetStringFromObj(mePtr->labelPtr, &mePtr->labelLength);
+	(void)Tcl_GetStringFromObj(mePtr->labelPtr, &mePtr->labelLength);
     }
     if (mePtr->accelPtr == NULL) {
 	mePtr->accelLength = 0;
     } else {
-	(void)TkGetStringFromObj(mePtr->accelPtr, &mePtr->accelLength);
+	(void)Tcl_GetStringFromObj(mePtr->accelPtr, &mePtr->accelLength);
     }
 
     /*
      * If this is a cascade entry, the platform-specific data of the child
      * menu has to be updated. Also, the links that point to parents and
@@ -2126,11 +2118,11 @@
     const char *string;
 
     if (TkGetIntForIndex(objPtr, menuPtr->numEntries - 1, lastOK, indexPtr) == TCL_OK) {
 	/* TCL_INDEX_NONE is only accepted if it does not result from a negative number */
 	if (*indexPtr != TCL_INDEX_NONE || Tcl_GetString(objPtr)[0] != '-') {
-	    if (*indexPtr >= menuPtr->numEntries) {
+	    if (*indexPtr + 1 >= menuPtr->numEntries + 1) {
 		*indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1);
 	    }
 	    return TCL_OK;
 	}
     }
@@ -2145,14 +2137,20 @@
     if ((string[0] == 'l') && (strcmp(string, "last") == 0)) {
 	*indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1);
 	goto success;
     }
 
+    if (string[0] == 0) {
+	*indexPtr = TCL_INDEX_NONE;
+	goto success;
+    }
+#if !defined(TK_NO_DEPRECATED) && TK_MAJOR_VERSION < 9
     if ((string[0] == 'n') && (strcmp(string, "none") == 0)) {
 	*indexPtr = TCL_INDEX_NONE;
 	goto success;
     }
+#endif
 
     if (string[0] == '@') {
 	if (GetIndexFromCoords(NULL, menuPtr, string, indexPtr)
 		== TCL_OK) {
 	    goto success;
@@ -2274,11 +2272,11 @@
     mePtr->type = type;
     mePtr->optionTable = tsdPtr->entryOptionTables[type];
     mePtr->menuPtr = menuPtr;
     mePtr->labelPtr = NULL;
     mePtr->labelLength = 0;
-    mePtr->underline = -1;
+    mePtr->underline = INT_MIN;
     mePtr->bitmapPtr = NULL;
     mePtr->imagePtr = NULL;
     mePtr->image = NULL;
     mePtr->selectImagePtr = NULL;
     mePtr->selectImage = NULL;
@@ -2512,18 +2510,18 @@
     /*
      * If the variable is being unset, then re-establish the trace.
      */
 
     if (flags & TCL_TRACE_UNSETS) {
-        ClientData probe = NULL;
+        void *probe = NULL;
 	mePtr->entryFlags &= ~ENTRY_SELECTED;
 
         do {
                 probe = Tcl_VarTraceInfo(interp, name,
                         TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
                         MenuVarProc, probe);
-                if (probe == (ClientData)mePtr) {
+                if (probe == (void *)mePtr) {
                     break;
                 }
         } while (probe);
         if (probe) {
                 /*
@@ -2691,11 +2689,12 @@
     Tcl_Obj *newMenuNamePtr,	/* The name to give the new menu. */
     Tcl_Obj *newMenuTypePtr)	/* What kind of menu is this, a normal menu a
     				 * menubar, or a tearoff? */
 {
     int returnResult;
-    int menuType, i;
+    int menuType;
+    TkSizeT i;
     TkMenuReferences *menuRefPtr;
     Tcl_Obj *menuDupCommandArray[4];
 
     if (newMenuTypePtr == NULL) {
 	menuType = MAIN_MENU;
@@ -2731,11 +2730,11 @@
 	    ((menuRefPtr = TkFindMenuReferencesObj(menuPtr->interp,
 	    newMenuNamePtr)) != NULL)
 	    && (menuPtr->numEntries == menuRefPtr->menuPtr->numEntries)) {
 	TkMenu *newMenuPtr = menuRefPtr->menuPtr;
 	Tcl_Obj *newObjv[3];
-	int numElements;
+	TkSizeT numElements;
 
 	/*
 	 * Now put this newly created menu into the parent menu's instance
 	 * chain.
 	 */
@@ -2802,11 +2801,11 @@
 
 	/*
 	 * Clone all of the cascade menus that this menu points to.
 	 */
 
-	for (i = 0; i < (int)menuPtr->numEntries; i++) {
+	for (i = 0; i < menuPtr->numEntries; i++) {
 	    TkMenuReferences *cascadeRefPtr;
 	    TkMenu *oldCascadePtr;
 
 	    if ((menuPtr->entries[i]->type == CASCADE_ENTRY)
 		&& (menuPtr->entries[i]->namePtr != NULL)) {
@@ -3129,11 +3128,11 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkSetWindowMenuBar --
+ * Tk_SetWindowMenubar --
  *
  *	Associates a menu with a window. Called by ConfigureFrame in in
  *	response to a "-menu .foo" configuration option for a top level.
  *
  * Results:
@@ -3145,11 +3144,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 void
-TkSetWindowMenuBar(
+Tk_SetWindowMenubar(
     Tcl_Interp *interp,		/* The interpreter the toplevel lives in. */
     Tk_Window tkwin,		/* The toplevel window. */
     const char *oldMenuName, /* The name of the menubar previously set in
     				 * this toplevel. NULL means no menu was set
     				 * previously. */
@@ -3287,11 +3286,11 @@
 	topLevelListPtr->nextPtr = menuRefPtr->topLevelListPtr;
 	menuRefPtr->topLevelListPtr = topLevelListPtr;
     } else {
 	TkpSetWindowMenuBar(tkwin, NULL);
     }
-    TkpSetMainMenubar(interp, tkwin, menuName);
+    Tk_SetMainMenubar(interp, tkwin, menuName);
 }
 
 /*
  *----------------------------------------------------------------------
  *

Index: generic/tkMenu.h
==================================================================
--- generic/tkMenu.h
+++ generic/tkMenu.h
@@ -2,11 +2,11 @@
  * tkMenu.h --
  *
  *	Declarations shared among all of the files that implement menu
  *	widgets.
  *
- * Copyright (c) 1996-1998 by Sun Microsystems, Inc.
+ * Copyright © 1996-1998 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -242,12 +242,12 @@
 /*
  * Menu states
  */
 
 #define ENTRY_ACTIVE 0
-#define ENTRY_NORMAL 1
-#define ENTRY_DISABLED 2
+#define ENTRY_DISABLED 1
+#define ENTRY_NORMAL 2
 
 /*
  * A data structure of the following type is kept for each menu widget:
  */
 
@@ -459,13 +459,13 @@
  * are deleted. If one of the other instances is deleted, only that instance
  * is deleted.
  */
 
 #define UNKNOWN_TYPE		-1
-#define MAIN_MENU 		0
-#define TEAROFF_MENU 		1
-#define MENUBAR 		2
+#define MENUBAR 		0
+#define MAIN_MENU 		1
+#define TEAROFF_MENU 		2
 
 /*
  * Various geometry definitions:
  */
 
@@ -513,11 +513,11 @@
 			    Tcl_Obj *parentNamePtr, TkMenu *menuPtr);
 MODULE_SCOPE int	TkPostCommand(TkMenu *menuPtr);
 MODULE_SCOPE int	TkPostSubmenu(Tcl_Interp *interp, TkMenu *menuPtr,
 			    TkMenuEntry *mePtr);
 MODULE_SCOPE int	TkPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr,
-					   int x, int y);
+			    int x, int y);
 MODULE_SCOPE int	TkPreprocessMenu(TkMenu *menuPtr);
 MODULE_SCOPE void	TkRecomputeMenu(TkMenu *menuPtr);
 
 /*
  * These routines are the platform-dependent routines called by the common
@@ -538,9 +538,9 @@
 MODULE_SCOPE int	TkpMenuNewEntry(TkMenuEntry *mePtr);
 MODULE_SCOPE int	TkpNewMenu(TkMenu *menuPtr);
 MODULE_SCOPE int	TkpPostMenu(Tcl_Interp *interp, TkMenu *menuPtr,
 			    int x, int y, int index);
 MODULE_SCOPE int	TkpPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr,
-					   int x, int y, int index);
+			    int x, int y, int index);
 MODULE_SCOPE void	TkpSetWindowMenuBar(Tk_Window tkwin, TkMenu *menuPtr);
 
 #endif /* _TKMENU */

Index: generic/tkMenuDraw.c
==================================================================
--- generic/tkMenuDraw.c
+++ generic/tkMenuDraw.c
@@ -2,11 +2,11 @@
  * tkMenuDraw.c --
  *
  *	This module implements the platform-independent drawing and geometry
  *	calculations of menu widgets.
  *
- * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -773,11 +773,11 @@
     } else if (eventPtr->type == ConfigureNotify) {
 	TkEventuallyRecomputeMenu(menuPtr);
 	TkEventuallyRedrawMenu(menuPtr, NULL);
     } else if (eventPtr->type == ActivateNotify) {
 	if (menuPtr->menuType == TEAROFF_MENU) {
-	    TkpSetMainMenubar(menuPtr->interp, menuPtr->tkwin, NULL);
+	    Tk_SetMainMenubar(menuPtr->interp, menuPtr->tkwin, NULL);
 	}
     } else if (eventPtr->type == DestroyNotify) {
 	if (menuPtr->tkwin != NULL) {
 	    if (!(menuPtr->menuFlags & MENU_DELETION_PENDING)) {
 		TkDestroyMenu(menuPtr);

Index: generic/tkMenubutton.c
==================================================================
--- generic/tkMenubutton.c
+++ generic/tkMenubutton.c
@@ -2,12 +2,12 @@
  * tkMenubutton.c --
  *
  *	This module implements button-like widgets that are used to invoke
  *	pull-down menus.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -33,51 +33,33 @@
 
 static const char *const directionStrings[] = {
     "above", "below", "flush", "left", "right", NULL
 };
 
-/*
- * The following table defines the legal values for the -state option. It is
- * used together with the "enum state" declaration in tkMenubutton.h.
- */
-
-static const char *const stateStrings[] = {
-    "active", "disabled", "normal", NULL
-};
-
-/*
- * The following table defines the legal values for the -compound option. It
- * is used with the "enum compound" declaration in tkMenuButton.h
- */
-
-static const char *const compoundStrings[] = {
-    "bottom", "center", "left", "none", "right", "top", NULL
-};
-
 /*
  * Information used for parsing configuration specs:
  */
 
 static const Tk_OptionSpec optionSpecs[] = {
     {TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
 	DEF_MENUBUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE,
 	offsetof(TkMenuButton, activeBorder), 0,
-	(ClientData) DEF_MENUBUTTON_ACTIVE_BG_MONO, 0},
+	DEF_MENUBUTTON_ACTIVE_BG_MONO, 0},
     {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
 	DEF_MENUBUTTON_ACTIVE_FG_COLOR, TCL_INDEX_NONE,
-	 offsetof(TkMenuButton, activeFg),
-	 0, DEF_MENUBUTTON_ACTIVE_FG_MONO, 0},
+	offsetof(TkMenuButton, activeFg),
+	0, DEF_MENUBUTTON_ACTIVE_FG_MONO, 0},
     {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
 	DEF_MENUBUTTON_ANCHOR, TCL_INDEX_NONE,
 	offsetof(TkMenuButton, anchor), 0, 0, 0},
     {TK_OPTION_BORDER, "-background", "background", "Background",
 	DEF_MENUBUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkMenuButton, normalBorder),
 	0, DEF_MENUBUTTON_BG_MONO, 0},
-    {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
-	(ClientData) "-borderwidth", 0},
-    {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
-	(ClientData) "-background", 0},
+    {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE,
+	0, "-borderwidth", 0},
+    {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE,
+	0, "-background", 0},
     {TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
 	DEF_MENUBUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkMenuButton, bitmap),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
 	DEF_MENUBUTTON_BORDER_WIDTH, TCL_INDEX_NONE,
@@ -85,17 +67,17 @@
     {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
 	DEF_MENUBUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkMenuButton, cursor),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction",
 	DEF_MENUBUTTON_DIRECTION, TCL_INDEX_NONE, offsetof(TkMenuButton, direction),
-	0, directionStrings, 0},
+	TK_OPTION_ENUM_VAR, directionStrings, 0},
     {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
 	"DisabledForeground", DEF_MENUBUTTON_DISABLED_FG_COLOR,
 	TCL_INDEX_NONE, offsetof(TkMenuButton, disabledFg), TK_OPTION_NULL_OK,
-	(ClientData) DEF_MENUBUTTON_DISABLED_FG_MONO, 0},
-    {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE, 0,
-	(ClientData) "-foreground", 0},
+	DEF_MENUBUTTON_DISABLED_FG_MONO, 0},
+    {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE,
+	0, "-foreground", 0},
     {TK_OPTION_FONT, "-font", "font", "Font",
 	DEF_MENUBUTTON_FONT, TCL_INDEX_NONE, offsetof(TkMenuButton, tkfont), 0, 0, 0},
     {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
 	DEF_MENUBUTTON_FG, TCL_INDEX_NONE, offsetof(TkMenuButton, normalFg), 0, 0, 0},
     {TK_OPTION_STRING, "-height", "height", "Height",
@@ -129,26 +111,25 @@
 	0, 0, 0},
     {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
 	DEF_MENUBUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkMenuButton, relief),
 	0, 0, 0},
     {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
-	 DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkMenuButton, compound), 0,
-	 compoundStrings, 0},
+	DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkMenuButton, compound),
+	0, tkCompoundStrings, 0},
     {TK_OPTION_STRING_TABLE, "-state", "state", "State",
 	DEF_MENUBUTTON_STATE, TCL_INDEX_NONE, offsetof(TkMenuButton, state),
-	0, stateStrings, 0},
+	TK_OPTION_ENUM_VAR, tkStateStrings, 0},
     {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
 	DEF_MENUBUTTON_TAKE_FOCUS, TCL_INDEX_NONE,
 	offsetof(TkMenuButton, takeFocus), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING, "-text", "text", "Text",
 	DEF_MENUBUTTON_TEXT, TCL_INDEX_NONE, offsetof(TkMenuButton, text), 0, 0, 0},
     {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
 	DEF_MENUBUTTON_TEXT_VARIABLE, TCL_INDEX_NONE,
 	offsetof(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0},
-    {TK_OPTION_INT, "-underline", "underline", "Underline",
-	DEF_MENUBUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkMenuButton, underline),
-	 0, 0, 0},
+    {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+	TK_OPTION_UNDERLINE_DEF(TkMenuButton, underline), 0},
     {TK_OPTION_STRING, "-width", "width", "Width",
 	DEF_MENUBUTTON_WIDTH, TCL_INDEX_NONE, offsetof(TkMenuButton, widthString),
 	0, 0, 0},
     {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
 	DEF_MENUBUTTON_WRAP_LENGTH, TCL_INDEX_NONE, offsetof(TkMenuButton, wrapLength),
@@ -259,11 +240,11 @@
 	    Tk_PathName(mbPtr->tkwin), MenuButtonWidgetObjCmd, mbPtr,
 	    MenuButtonCmdDeletedProc);
     mbPtr->optionTable = optionTable;
     mbPtr->menuName = NULL;
     mbPtr->text = NULL;
-    mbPtr->underline = -1;
+    mbPtr->underline = INT_MIN;
     mbPtr->textVarName = NULL;
     mbPtr->bitmap = None;
     mbPtr->imageString = NULL;
     mbPtr->image = NULL;
     mbPtr->state = STATE_NORMAL;
@@ -887,18 +868,18 @@
      * interpreter is going away.
      */
 
     if (flags & TCL_TRACE_UNSETS) {
         if (!Tcl_InterpDeleted(interp) && mbPtr->textVarName) {
-            ClientData probe = NULL;
+            void *probe = NULL;
 
             do {
                 probe = Tcl_VarTraceInfo(interp,
                         mbPtr->textVarName,
                         TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
                         MenuButtonTextVarProc, probe);
-                if (probe == (ClientData)mbPtr) {
+                if (probe == (void *)mbPtr) {
                     break;
                 }
             } while (probe);
             if (probe) {
                 /*

Index: generic/tkMenubutton.h
==================================================================
--- generic/tkMenubutton.h
+++ generic/tkMenubutton.h
@@ -2,11 +2,11 @@
  * tkMenubutton.h --
  *
  *	Declarations of types and functions used to implement the menubutton
  *	widget.
  *
- * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -62,11 +62,11 @@
      * Information about what's displayed in the menu button:
      */
 
     char *text;			/* Text to display in button (malloc'ed) or
 				 * NULL. */
-    int underline;		/* Index of character to underline. */
+    int underline;		/* Index of character to underline. INT_MIN means no underline */
     char *textVarName;		/* Name of variable (malloc'ed) or NULL. If
 				 * non-NULL, button displays the contents of
 				 * this variable. */
     Pixmap bitmap;		/* Bitmap to display or None. If not None then
 				 * text and textVar and underline are

Index: generic/tkMessage.c
==================================================================
--- generic/tkMessage.c
+++ generic/tkMessage.c
@@ -3,13 +3,13 @@
  *
  *	This module implements a message widgets for the Tk toolkit. A message
  *	widget displays a multi-line string in a window according to a
  *	particular aspect ratio.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-2000 by Ajuba Solutions.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Ajuba Solutions.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -710,14 +710,14 @@
 	GC fgGC, bgGC;
 
 	bgGC = Tk_GCForColor(msgPtr->highlightBgColorPtr, Tk_WindowId(tkwin));
 	if (msgPtr->flags & GOT_FOCUS) {
 	    fgGC = Tk_GCForColor(msgPtr->highlightColorPtr,Tk_WindowId(tkwin));
-	    TkpDrawHighlightBorder(tkwin, fgGC, bgGC, msgPtr->highlightWidth,
+	    Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, msgPtr->highlightWidth,
 		    Tk_WindowId(tkwin));
 	} else {
-	    TkpDrawHighlightBorder(tkwin, bgGC, bgGC, msgPtr->highlightWidth,
+	    Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, msgPtr->highlightWidth,
 		    Tk_WindowId(tkwin));
 	}
     }
 }
 
@@ -846,18 +846,18 @@
      * interpreter is going away.
      */
 
     if (flags & TCL_TRACE_UNSETS) {
         if (!Tcl_InterpDeleted(interp) && msgPtr->textVarName) {
-            ClientData probe = NULL;
+            void *probe = NULL;
 
             do {
                 probe = Tcl_VarTraceInfo(interp,
                         msgPtr->textVarName,
                         TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
                         MessageTextVarProc, probe);
-                if (probe == (ClientData)msgPtr) {
+                if (probe == (void *)msgPtr) {
                     break;
                 }
             } while (probe);
             if (probe) {
                 /*

Index: generic/tkObj.c
==================================================================
--- generic/tkObj.c
+++ generic/tkObj.c
@@ -1,11 +1,11 @@
 /*
  * tkObj.c --
  *
  *	This file contains functions that implement the common Tk object types
  *
- * Copyright (c) 1997 Sun Microsystems, Inc.
+ * Copyright © 1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -48,11 +48,10 @@
  */
 
 typedef struct {
     const Tcl_ObjType *doubleTypePtr;
     const Tcl_ObjType *intTypePtr;
-    const Tcl_ObjType *endTypePtr;
 } ThreadSpecificData;
 static Tcl_ThreadDataKey dataKey;
 
 /*
  * The following structure is the internal representation for mm objects.
@@ -97,10 +96,13 @@
 static int		SetMMFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
 static int		SetPixelFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
 static int		SetWindowFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
 
 #if TCL_MAJOR_VERSION < 9
+#ifdef __cplusplus
+extern "C" {
+#endif
 #if defined(USE_TCL_STUBS)
 /*  Little hack to eliminate the need for "tclInt.h" here:
     Just copy a small portion of TclIntStubs, just
     enough to make it work */
 typedef struct TclIntStubs {
@@ -107,19 +109,22 @@
     int magic;
     void *hooks;
     void (*dummy[34]) (void); /* dummy entries 0-33, not used */
     int (*tclGetIntForIndex) (Tcl_Interp *interp, Tcl_Obj *objPtr, int endValue, int *indexPtr); /* 34 */
 } TclIntStubs;
-extern const struct TclIntStubs *tclIntStubsPtr;
+extern const TclIntStubs *tclIntStubsPtr;
 
 # undef Tcl_GetIntForIndex
 # define Tcl_GetIntForIndex(interp, obj, max, ptr) ((tclIntStubsPtr->tclGetIntForIndex == NULL)? \
     ((int (*)(Tcl_Interp*,  Tcl_Obj *, int, int*))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[645]))((interp), (obj), (max), (ptr)): \
 	tclIntStubsPtr->tclGetIntForIndex((interp), (obj), (max), (ptr)))
 #elif TCL_MINOR_VERSION < 7
 extern int TclGetIntForIndex(Tcl_Interp*,  Tcl_Obj *, int, int*);
 # define Tcl_GetIntForIndex(interp, obj, max, ptr) TclGetIntForIndex(interp, obj, max, ptr)
+#endif
+#ifdef __cplusplus
+}
 #endif
 #endif
 
 /*
  * The following structure defines the implementation of the "pixel" Tcl
@@ -182,15 +187,10 @@
 
     if (tsdPtr->doubleTypePtr == NULL) {
 	/* Smart initialization of doubleTypePtr/intTypePtr without
 	 * hash-table lookup or creating complete Tcl_Obj's */
 	Tcl_Obj obj;
-	obj.bytes = (char *)"end";
-	obj.length = 3;
-	obj.typePtr = NULL;
-	Tcl_GetIntForIndex(NULL, &obj, TCL_INDEX_NONE, (TkSizeT *)&obj.internalRep.doubleValue);
-	tsdPtr->endTypePtr = obj.typePtr;
 	obj.bytes = (char *)"0.0";
 	obj.length = 3;
 	obj.typePtr = NULL;
 	Tcl_GetDoubleFromObj(NULL, &obj, &obj.internalRep.doubleValue);
 	tsdPtr->doubleTypePtr = obj.typePtr;
@@ -206,13 +206,12 @@
 /*
  *----------------------------------------------------------------------
  *
  * TkGetIntForIndex --
  *
- *	Almost the same as Tcl_GetIntForIndex, but it return an int, and it is
- *	more restricted. For example it only accepts "end", not "end-1", and
- *	only "2", not "1+1"
+ *	Almost the same as Tcl_GetIntForIndex, but it return an int. Accepts
+ *	"" (empty string) as well.
  *
  * Results:
  *	The return value is a standard Tcl object result.
  *
  * Side effects:
@@ -226,28 +225,26 @@
     Tcl_Obj *indexObj,
     TkSizeT end,
     int lastOK,
     TkSizeT *indexPtr)
 {
-    ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
-	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
-
+    if (indexObj == NULL) {
+	*indexPtr = TCL_INDEX_NONE;
+	return TCL_OK;
+    }
     if (Tcl_GetIntForIndex(NULL, indexObj, end + lastOK, indexPtr) != TCL_OK) {
-	return TCL_ERROR;
-    }
-    if (indexObj->typePtr == tsdPtr->endTypePtr) {
-	/* check for "end", but not "end-??" or "end+??" */
-	return (*indexPtr == (end + lastOK)) ? TCL_OK :  TCL_ERROR;
-    }
-    if (indexObj->typePtr != tsdPtr->intTypePtr) {
-	/* Neither do we accept "??-??" or "??+??" */
+	const char *value = Tcl_GetString(indexObj);
+	if (!*value) {
+	    *indexPtr = TCL_INDEX_NONE;
+	    return TCL_OK;
+	}
 	return TCL_ERROR;
     }
 #if TCL_MAJOR_VERSION < 9
-    if ((*indexPtr < -1) || (end < -1)) {
-	return TCL_ERROR;
-    }
+    if (*indexPtr < -1) {
+	*indexPtr = TCL_INDEX_NONE;
+    } else if (end >= -1)
 #endif
     if ((*indexPtr + 1) > (end + 1)) {
 	*indexPtr = end + 1;
     }
     return TCL_OK;
@@ -1056,12 +1053,12 @@
 /*
  *----------------------------------------------------------------------
  *
  * Tk_NewWindowObj --
  *
- *	This function allocates a new Tcl_Obj that refers to a particular to a
- *	particular Tk window.
+ *	This function allocates a new Tcl_Obj that refers to a particular
+ *	Tk window.
  *
  * Results:
  *	A standard Tcl object reference, with refcount 0.
  *
  * Side effects:
@@ -1117,11 +1114,11 @@
 				 * or "-ipady". The thing to be parsed. */
     int *halfPtr,		/* Write the left/top part of padding here */
     int *allPtr)		/* Write the total padding here */
 {
     int firstInt, secondInt;    /* The two components of the padding */
-    int objc;			/* The length of the list (should be 1 or 2) */
+    TkSizeT objc;			/* The length of the list (should be 1 or 2) */
     Tcl_Obj **objv;		/* The objects in the list */
 
     /*
      * Check for a common case where a single object would otherwise be
      * shimmered between a list and a pixel spec.

Index: generic/tkOldConfig.c
==================================================================
--- generic/tkOldConfig.c
+++ generic/tkOldConfig.c
@@ -3,12 +3,12 @@
  *
  *	This file contains the Tk_ConfigureWidget function. THIS FILE IS HERE
  *	FOR BACKWARD COMPATIBILITY; THE NEW CONFIGURATION PACKAGE SHOULD BE
  *	USED FOR NEW PROJECTS.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -16,17 +16,12 @@
 
 /*
  * Values for "flags" field of Tk_ConfigSpec structures. Be sure to coordinate
  * these values with those defined in tk.h (TK_CONFIG_COLOR_ONLY, etc.) There
  * must not be overlap!
- *
- * INIT -		Non-zero means (char *) things have been converted to
- *			Tk_Uid's.
  */
 
-#define INIT		0x20
-
 #ifndef TK_CONFIG_OPTION_SPECIFIED
 #  define TK_CONFIG_OPTION_SPECIFIED      (1 << 4)
 #endif
 
 /*
@@ -350,11 +345,11 @@
     void *ptr;
     Tk_Uid uid;
     int nullValue;
 
     nullValue = 0;
-    if ((*value == 0) && (specPtr->specFlags & TK_CONFIG_NULL_OK)) {
+    if ((*value == 0) && (specPtr->specFlags & (TK_CONFIG_NULL_OK|TCL_INDEX_NULL_OK))) {
 	nullValue = 1;
     }
 
     do {
 	ptr = (char *)widgRec + specPtr->offset;

Index: generic/tkOldTest.c
==================================================================
--- generic/tkOldTest.c
+++ generic/tkOldTest.c
@@ -4,13 +4,13 @@
  *	This file contains C command functions for additional Tcl
  *	commands that are used to test Tk's support for legacy
  *	interfaces.  These commands are not normally included in Tcl/Tk
  *	applications; they're only used for testing.
  *
- * Copyright (c) 1993-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright © 1993-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-1999 Scriptics Corporation.
  * Contributions by Don Porter, NIST, 2007.  (not subject to US copyright)
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */

Index: generic/tkOption.c
==================================================================
--- generic/tkOption.c
+++ generic/tkOption.c
@@ -3,12 +3,12 @@
  *
  *	This module contains functions to manage the option database, which
  *	allows various strings to be associated with windows either by name or
  *	by class or both.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -749,15 +749,15 @@
      * XXX: OptionThreadExitProc will be invoked before DeleteWindowsExitProc
      * XXX: if it is thread-specific (which it should be), invalidating the
      * XXX: tsd. Tk shutdown needs to be verified to handle this correctly.
      */
 
-    if (tsdPtr->initialized && (winPtr->optionLevel != -1)) {
+    if (tsdPtr->initialized && (winPtr->optionLevel != TCL_INDEX_NONE)) {
 	int i;
 
 	for (i = 1; i <= tsdPtr->curLevel; i++) {
-	    tsdPtr->levels[i].winPtr->optionLevel = -1;
+	    tsdPtr->levels[i].winPtr->optionLevel = TCL_INDEX_NONE;
 	}
 	tsdPtr->curLevel = -1;
 	tsdPtr->cachedWindow = NULL;
     }
 
@@ -797,11 +797,11 @@
     int i, j, *basePtr;
     ElArray *arrayPtr;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
 
-    if (winPtr->optionLevel == -1) {
+    if (winPtr->optionLevel == TCL_INDEX_NONE) {
 	return;
     }
 
     /*
      * Find the lowest stack level that refers to this window, then flush all
@@ -809,11 +809,11 @@
      */
 
     for (i = 1; i <= tsdPtr->curLevel; i++) {
 	if (tsdPtr->levels[i].winPtr == winPtr) {
 	    for (j = i; j <= tsdPtr->curLevel; j++) {
-		tsdPtr->levels[j].winPtr->optionLevel = -1;
+		tsdPtr->levels[j].winPtr->optionLevel = TCL_INDEX_NONE;
 	    }
 	    tsdPtr->curLevel = i-1;
 	    basePtr = tsdPtr->levels[i].bases;
 	    for (j = 0; j < NUM_STACKS; j++) {
 		arrayPtr = tsdPtr->stacks[j];
@@ -1267,11 +1267,11 @@
      * windows as no longer having cached information.
      */
 
     if (tsdPtr->curLevel >= level) {
 	while (tsdPtr->curLevel >= level) {
-	    tsdPtr->levels[tsdPtr->curLevel].winPtr->optionLevel = -1;
+	    tsdPtr->levels[tsdPtr->curLevel].winPtr->optionLevel = TCL_INDEX_NONE;
 	    tsdPtr->curLevel--;
 	}
 	levelPtr = &tsdPtr->levels[level];
 	for (i = 0; i < NUM_STACKS; i++) {
 	    arrayPtr = tsdPtr->stacks[i];

Index: generic/tkPack.c
==================================================================
--- generic/tkPack.c
+++ generic/tkPack.c
@@ -2,22 +2,22 @@
  * tkPack.c --
  *
  *	This file contains code to implement the "packer" geometry manager for
  *	Tk.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
 #include "tkInt.h"
 
-typedef enum {TOP, BOTTOM, LEFT, RIGHT} Side;
+typedef enum {BOTTOM, LEFT, RIGHT, TOP} Side;
 static const char *const sideNames[] = {
-    "top", "bottom", "left", "right", NULL
+    "bottom", "left", "right", "top", NULL
 };
 
 /*
  * For each window that the packer cares about (either because the window is
  * managed by the packer or because the window has content that are managed by
@@ -222,20 +222,20 @@
     if (objc < 3) {
 	Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?");
 	return TCL_ERROR;
     }
 
-    if (Tcl_GetIndexFromObjStruct(NULL, objv[1], optionStrings,
-	    sizeof(char *), "option", 0, &index) != TCL_OK) {
+    if (Tcl_GetIndexFromObj(NULL, objv[1], optionStrings,
+	    "option", 0, &index) != TCL_OK) {
 	/*
 	 * Call it again without the deprecated ones to get a proper error
 	 * message. This works well since there can't be any ambiguity between
 	 * deprecated and new options.
 	 */
 
-	Tcl_GetIndexFromObjStruct(interp, objv[1], optionStringsNoDep,
-		sizeof(char *), "option", 0, &index);
+	Tcl_GetIndexFromObj(interp, objv[1], optionStringsNoDep,
+		"option", 0, &index);
 	return TCL_ERROR;
     }
 
     argv2 = Tcl_GetString(objv[2]);
     switch ((enum options) index) {
@@ -824,16 +824,14 @@
 	    break;
 	case TK_ANCHOR_NW:
 	    x = frameX + borderLeft;
 	    y = frameY + borderTop;
 	    break;
-	case TK_ANCHOR_CENTER:
+	default:
 	    x = frameX + (borderLeft + frameWidth - width - borderRight)/2;
 	    y = frameY + (borderTop + frameHeight - height - borderBtm)/2;
 	    break;
-	default:
-	    Tcl_Panic("bad frame factor in ArrangePacking");
 	}
 	width -= contentPtr->doubleBw;
 	height -= contentPtr->doubleBw;
 
 	/*
@@ -1111,11 +1109,12 @@
 				 * pack. */
 {
     Packer *packPtr;
     Tk_Window tkwin, ancestor, parent;
     Tcl_Obj **options;
-    int index, optionCount, c;
+    int c;
+    TkSizeT index, optionCount;
 
     /*
      * Iterate over all of the window specifiers, each consisting of two
      * arguments. The first argument contains the window name and the
      * additional arguments contain options such as "top" or "padx 20".
@@ -1179,11 +1178,11 @@
 	packPtr->flags &= ~(FILLX|FILLY|EXPAND);
 	packPtr->flags |= OLD_STYLE;
 	for (index = 0 ; index < optionCount; index++) {
 	    Tcl_Obj *curOptPtr = options[index];
 	    TkSizeT length;
-	    const char *curOpt = TkGetStringFromObj(curOptPtr, &length);
+	    const char *curOpt = Tcl_GetStringFromObj(curOptPtr, &length);
 
 	    c = curOpt[0];
 
 	    if ((c == 't')
 		    && (strncmp(curOpt, "top", length)) == 0) {
@@ -1206,11 +1205,11 @@
 	    } else if ((length == 5) && (strcmp(curOpt, "fillx")) == 0) {
 		packPtr->flags |= FILLX;
 	    } else if ((length == 5) && (strcmp(curOpt, "filly")) == 0) {
 		packPtr->flags |= FILLY;
 	    } else if ((c == 'p') && (strcmp(curOpt, "padx")) == 0) {
-		if (optionCount < (index+2)) {
+		if (optionCount <= (index+1)) {
 		missingPad:
 		    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 			    "wrong # args: \"%s\" option must be"
 			    " followed by screen distance", curOpt));
 		    Tcl_SetErrorCode(interp, "TK", "OLDPACK", "BAD_PARAMETER",
@@ -1224,11 +1223,11 @@
 		packPtr->padX /= 2;
 		packPtr->padLeft /= 2;
 		packPtr->iPadX = 0;
 		index++;
 	    } else if ((c == 'p') && (strcmp(curOpt, "pady")) == 0) {
-		if (optionCount < (index+2)) {
+		if (optionCount <= (index+1)) {
 		    goto missingPad;
 		}
 		if (TkParsePadAmount(interp, tkwin, options[index+1],
 			&packPtr->padTop, &packPtr->padY) != TCL_OK) {
 		    return TCL_ERROR;
@@ -1237,11 +1236,11 @@
 		packPtr->padTop /= 2;
 		packPtr->iPadY = 0;
 		index++;
 	    } else if ((c == 'f') && (length > 1)
 		    && (strncmp(curOpt, "frame", length) == 0)) {
-		if (optionCount < (index+2)) {
+		if (optionCount <= (index+1)) {
 		    Tcl_SetObjResult(interp, Tcl_NewStringObj(
 			    "wrong # args: \"frame\""
 			    " option must be followed by anchor point", -1));
 		    Tcl_SetErrorCode(interp, "TK", "OLDPACK", "BAD_PARAMETER",
 			    NULL);
@@ -1408,10 +1407,13 @@
     void *memPtr)		/* Info about packed window that is now
 				 * dead. */
 {
     Packer *packPtr = (Packer *)memPtr;
 
+    if (packPtr->flags & REQUESTED_REPACK) {
+	Tcl_CancelIdleCall(ArrangePacking, packPtr);
+    }
     ckfree(packPtr);
 }
 
 /*
  *----------------------------------------------------------------------
@@ -1608,12 +1610,12 @@
 			"extra option \"%s\" (option with no value?)",
 			Tcl_GetString(objv[i])));
 		Tcl_SetErrorCode(interp, "TK", "PACK", "BAD_PARAMETER", NULL);
 		return TCL_ERROR;
 	    }
-	    if (Tcl_GetIndexFromObjStruct(interp, objv[i], optionStrings,
-		    sizeof(char *), "option", 0, &index) != TCL_OK) {
+	    if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings,
+		    "option", 0, &index) != TCL_OK) {
 		return TCL_ERROR;
 	    }
 
 	    switch ((enum options) index) {
 	    case CONF_AFTER:
@@ -1740,12 +1742,12 @@
 			&contentPtr->padTop, &contentPtr->padY) != TCL_OK) {
 		    return TCL_ERROR;
 		}
 		break;
 	    case CONF_SIDE:
-		if (Tcl_GetIndexFromObjStruct(interp, objv[i+1], sideNames,
-			sizeof(char *), "side", TCL_EXACT, &side) != TCL_OK) {
+		if (Tcl_GetIndexFromObj(interp, objv[i+1], sideNames,
+			"side", TCL_EXACT, &side) != TCL_OK) {
 		    return TCL_ERROR;
 		}
 		contentPtr->side = (Side) side;
 		break;
 	    }

Index: generic/tkPanedWindow.c
==================================================================
--- generic/tkPanedWindow.c
+++ generic/tkPanedWindow.c
@@ -4,12 +4,12 @@
  *	This module implements "paned window" widgets that are object based. A
  *	"paned window" is a widget that manages the geometry for some number
  *	of other widgets, placing a movable "sash" between them, which can be
  *	used to alter the relative sizes of adjacent widgets.
  *
- * Copyright (c) 1997 Sun Microsystems, Inc.
- * Copyright (c) 2000 Ajuba Solutions.
+ * Copyright © 1997 Sun Microsystems, Inc.
+ * Copyright © 2000 Ajuba Solutions.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -181,37 +181,37 @@
 
 /*
  * Forward declarations for functions defined later in this file:
  */
 
-int			Tk_PanedWindowObjCmd(ClientData clientData,
+int			Tk_PanedWindowObjCmd(void *clientData,
 			    Tcl_Interp *interp, int objc,
 			    Tcl_Obj *const objv[]);
-static void		PanedWindowCmdDeletedProc(ClientData clientData);
+static void		PanedWindowCmdDeletedProc(void *clientData);
 static int		ConfigurePanedWindow(Tcl_Interp *interp,
 			    PanedWindow *pwPtr, int objc,
 			    Tcl_Obj *const objv[]);
 static void		DestroyPanedWindow(PanedWindow *pwPtr);
-static void		DisplayPanedWindow(ClientData clientData);
-static void		PanedWindowEventProc(ClientData clientData,
-			    XEvent *eventPtr);
-static void		ProxyWindowEventProc(ClientData clientData,
-			    XEvent *eventPtr);
-static void		DisplayProxyWindow(ClientData clientData);
-static void		PanedWindowWorldChanged(ClientData instanceData);
-static int		PanedWindowWidgetObjCmd(ClientData clientData,
+static void		DisplayPanedWindow(void *clientData);
+static void		PanedWindowEventProc(void *clientData,
+			    XEvent *eventPtr);
+static void		ProxyWindowEventProc(void *clientData,
+			    XEvent *eventPtr);
+static void		DisplayProxyWindow(void *clientData);
+static void		PanedWindowWorldChanged(void *instanceData);
+static int		PanedWindowWidgetObjCmd(void *clientData,
 			    Tcl_Interp *, int objc, Tcl_Obj * const objv[]);
-static void		PanedWindowLostPaneProc(ClientData clientData,
+static void		PanedWindowLostPaneProc(void *clientData,
 			    Tk_Window tkwin);
-static void		PanedWindowReqProc(ClientData clientData,
+static void		PanedWindowReqProc(void *clientData,
 			    Tk_Window tkwin);
-static void		ArrangePanes(ClientData clientData);
+static void		ArrangePanes(void *clientData);
 static void		Unlink(Pane *panePtr);
 static Pane *		GetPane(PanedWindow *pwPtr, Tk_Window tkwin);
 static void		GetFirstLastVisiblePane(PanedWindow *pwPtr,
 			    int *firstPtr, int *lastPtr);
-static void		PaneStructureProc(ClientData clientData,
+static void		PaneStructureProc(void *clientData,
 			    XEvent *eventPtr);
 static int		PanedWindowSashCommand(PanedWindow *pwPtr,
 			    Tcl_Interp *interp, int objc,
 			    Tcl_Obj * const objv[]);
 static int		PanedWindowProxyCommand(PanedWindow *pwPtr,
@@ -219,19 +219,19 @@
 			    Tcl_Obj * const objv[]);
 static void		ComputeGeometry(PanedWindow *pwPtr);
 static int		ConfigurePanes(PanedWindow *pwPtr,
 			    Tcl_Interp *interp, int objc,
 			    Tcl_Obj * const objv[]);
-static void		DestroyOptionTables(ClientData clientData,
+static void		DestroyOptionTables(void *clientData,
 			    Tcl_Interp *interp);
-static int		SetSticky(ClientData clientData, Tcl_Interp *interp,
+static int		SetSticky(void *clientData, Tcl_Interp *interp,
 			    Tk_Window tkwin, Tcl_Obj **value, char *recordPtr,
 			    TkSizeT internalOffset, char *oldInternalPtr,
 			    int flags);
-static Tcl_Obj *	GetSticky(ClientData clientData, Tk_Window tkwin,
+static Tcl_Obj *	GetSticky(void *clientData, Tk_Window tkwin,
 			    char *recordPtr, TkSizeT internalOffset);
-static void		RestoreSticky(ClientData clientData, Tk_Window tkwin,
+static void		RestoreSticky(void *clientData, Tk_Window tkwin,
 			    char *internalPtr, char *oldInternalPtr);
 static void		AdjustForSticky(int sticky, int cavityWidth,
 			    int cavityHeight, int *xPtr, int *yPtr,
 			    int *paneWidthPtr, int *paneHeightPtr);
 static void		MoveSash(PanedWindow *pwPtr, int sash, int diff);
@@ -273,96 +273,96 @@
     0
 };
 
 static const Tk_OptionSpec optionSpecs[] = {
     {TK_OPTION_BORDER, "-background", "background", "Background",
-	 DEF_PANEDWINDOW_BG_COLOR, TCL_INDEX_NONE, offsetof(PanedWindow, background), 0,
-	 DEF_PANEDWINDOW_BG_MONO, 0},
+	DEF_PANEDWINDOW_BG_COLOR, TCL_INDEX_NONE, offsetof(PanedWindow, background), 0,
+	DEF_PANEDWINDOW_BG_MONO, 0},
     {TK_OPTION_SYNONYM, "-bd", NULL, NULL,
-	 NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
+	NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
     {TK_OPTION_SYNONYM, "-bg", NULL, NULL,
-	 NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
+	NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
     {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
-	 DEF_PANEDWINDOW_BORDERWIDTH, TCL_INDEX_NONE, offsetof(PanedWindow, borderWidth),
-	 0, 0, GEOMETRY},
+	DEF_PANEDWINDOW_BORDERWIDTH, TCL_INDEX_NONE, offsetof(PanedWindow, borderWidth),
+	0, 0, GEOMETRY},
     {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
-	 DEF_PANEDWINDOW_CURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, cursor),
-	 TK_OPTION_NULL_OK, 0, 0},
+	DEF_PANEDWINDOW_CURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, cursor),
+	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_PIXELS, "-handlepad", "handlePad", "HandlePad",
-	 DEF_PANEDWINDOW_HANDLEPAD, TCL_INDEX_NONE, offsetof(PanedWindow, handlePad),
-	 0, 0, GEOMETRY},
+	DEF_PANEDWINDOW_HANDLEPAD, TCL_INDEX_NONE, offsetof(PanedWindow, handlePad),
+	0, 0, GEOMETRY},
     {TK_OPTION_PIXELS, "-handlesize", "handleSize", "HandleSize",
-	 DEF_PANEDWINDOW_HANDLESIZE, offsetof(PanedWindow, handleSizePtr),
-	 offsetof(PanedWindow, handleSize), 0, 0, GEOMETRY},
+	DEF_PANEDWINDOW_HANDLESIZE, offsetof(PanedWindow, handleSizePtr),
+	offsetof(PanedWindow, handleSize), 0, 0, GEOMETRY},
     {TK_OPTION_PIXELS, "-height", "height", "Height",
-	 DEF_PANEDWINDOW_HEIGHT, offsetof(PanedWindow, heightPtr),
-	 offsetof(PanedWindow, height), TK_OPTION_NULL_OK, 0, GEOMETRY},
+	DEF_PANEDWINDOW_HEIGHT, offsetof(PanedWindow, heightPtr),
+	offsetof(PanedWindow, height), TK_OPTION_NULL_OK, 0, GEOMETRY},
     {TK_OPTION_BOOLEAN, "-opaqueresize", "opaqueResize", "OpaqueResize",
-	 DEF_PANEDWINDOW_OPAQUERESIZE, TCL_INDEX_NONE,
-	 offsetof(PanedWindow, resizeOpaque), 0, 0, 0},
+	DEF_PANEDWINDOW_OPAQUERESIZE, TCL_INDEX_NONE,
+	offsetof(PanedWindow, resizeOpaque), 0, 0, 0},
     {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
-	 DEF_PANEDWINDOW_ORIENT, TCL_INDEX_NONE, offsetof(PanedWindow, orient),
-	 0, orientStrings, GEOMETRY},
+	DEF_PANEDWINDOW_ORIENT, TCL_INDEX_NONE, offsetof(PanedWindow, orient),
+	TK_OPTION_ENUM_VAR, orientStrings, GEOMETRY},
     {TK_OPTION_BORDER, "-proxybackground", "proxyBackground", "ProxyBackground",
-	 0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyBackground), TK_OPTION_NULL_OK,
-	 (ClientData) DEF_PANEDWINDOW_BG_MONO, 0},
+	0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyBackground), TK_OPTION_NULL_OK,
+	(void *)DEF_PANEDWINDOW_BG_MONO, 0},
     {TK_OPTION_PIXELS, "-proxyborderwidth", "proxyBorderWidth", "ProxyBorderWidth",
-	 DEF_PANEDWINDOW_PROXYBORDER, offsetof(PanedWindow, proxyBorderWidthPtr),
-	 offsetof(PanedWindow, proxyBorderWidth), 0, 0, GEOMETRY},
+	DEF_PANEDWINDOW_PROXYBORDER, offsetof(PanedWindow, proxyBorderWidthPtr),
+	offsetof(PanedWindow, proxyBorderWidth), 0, 0, GEOMETRY},
     {TK_OPTION_RELIEF, "-proxyrelief", "proxyRelief", "Relief",
-	 0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyRelief),
-	 TK_OPTION_NULL_OK, 0, 0},
+	0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyRelief),
+	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
-	 DEF_PANEDWINDOW_RELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, relief), 0, 0, 0},
+	DEF_PANEDWINDOW_RELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, relief), 0, 0, 0},
     {TK_OPTION_CURSOR, "-sashcursor", "sashCursor", "Cursor",
-	 DEF_PANEDWINDOW_SASHCURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, sashCursor),
-	 TK_OPTION_NULL_OK, 0, 0},
+	DEF_PANEDWINDOW_SASHCURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, sashCursor),
+	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_PIXELS, "-sashpad", "sashPad", "SashPad",
-	 DEF_PANEDWINDOW_SASHPAD, TCL_INDEX_NONE, offsetof(PanedWindow, sashPad),
-	 0, 0, GEOMETRY},
+	DEF_PANEDWINDOW_SASHPAD, TCL_INDEX_NONE, offsetof(PanedWindow, sashPad),
+	0, 0, GEOMETRY},
     {TK_OPTION_RELIEF, "-sashrelief", "sashRelief", "Relief",
-	 DEF_PANEDWINDOW_SASHRELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, sashRelief),
-	 0, 0, 0},
+	DEF_PANEDWINDOW_SASHRELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, sashRelief),
+	0, 0, 0},
     {TK_OPTION_PIXELS, "-sashwidth", "sashWidth", "Width",
-	 DEF_PANEDWINDOW_SASHWIDTH, offsetof(PanedWindow, sashWidthPtr),
-	 offsetof(PanedWindow, sashWidth), 0, 0, GEOMETRY},
+	DEF_PANEDWINDOW_SASHWIDTH, offsetof(PanedWindow, sashWidthPtr),
+	offsetof(PanedWindow, sashWidth), 0, 0, GEOMETRY},
     {TK_OPTION_BOOLEAN, "-showhandle", "showHandle", "ShowHandle",
-	 DEF_PANEDWINDOW_SHOWHANDLE, TCL_INDEX_NONE, offsetof(PanedWindow, showHandle),
-	 0, 0, GEOMETRY},
+	DEF_PANEDWINDOW_SHOWHANDLE, TCL_INDEX_NONE, offsetof(PanedWindow, showHandle),
+	0, 0, GEOMETRY},
     {TK_OPTION_PIXELS, "-width", "width", "Width",
-	 DEF_PANEDWINDOW_WIDTH, offsetof(PanedWindow, widthPtr),
-	 offsetof(PanedWindow, width), TK_OPTION_NULL_OK, 0, GEOMETRY},
+	DEF_PANEDWINDOW_WIDTH, offsetof(PanedWindow, widthPtr),
+	offsetof(PanedWindow, width), TK_OPTION_NULL_OK, 0, GEOMETRY},
     {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
 };
 
 static const Tk_OptionSpec paneOptionSpecs[] = {
     {TK_OPTION_WINDOW, "-after", NULL, NULL,
-	 DEF_PANEDWINDOW_PANE_AFTER, TCL_INDEX_NONE, offsetof(Pane, after),
-	 TK_OPTION_NULL_OK, 0, 0},
+	DEF_PANEDWINDOW_PANE_AFTER, TCL_INDEX_NONE, offsetof(Pane, after),
+	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_WINDOW, "-before", NULL, NULL,
-	 DEF_PANEDWINDOW_PANE_BEFORE, TCL_INDEX_NONE, offsetof(Pane, before),
-	 TK_OPTION_NULL_OK, 0, 0},
+	DEF_PANEDWINDOW_PANE_BEFORE, TCL_INDEX_NONE, offsetof(Pane, before),
+	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_PIXELS, "-height", NULL, NULL,
-	 DEF_PANEDWINDOW_PANE_HEIGHT, offsetof(Pane, heightPtr),
-	 offsetof(Pane, height), TK_OPTION_NULL_OK, 0, 0},
+	DEF_PANEDWINDOW_PANE_HEIGHT, offsetof(Pane, heightPtr),
+	offsetof(Pane, height), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_BOOLEAN, "-hide", "hide", "Hide",
-	 DEF_PANEDWINDOW_PANE_HIDE, TCL_INDEX_NONE, offsetof(Pane, hide), 0,0,GEOMETRY},
+	DEF_PANEDWINDOW_PANE_HIDE, TCL_INDEX_NONE, offsetof(Pane, hide), 0,0,GEOMETRY},
     {TK_OPTION_PIXELS, "-minsize", NULL, NULL,
-	 DEF_PANEDWINDOW_PANE_MINSIZE, TCL_INDEX_NONE, offsetof(Pane, minSize), 0, 0, 0},
+	DEF_PANEDWINDOW_PANE_MINSIZE, TCL_INDEX_NONE, offsetof(Pane, minSize), 0, 0, 0},
     {TK_OPTION_PIXELS, "-padx", NULL, NULL,
-	 DEF_PANEDWINDOW_PANE_PADX, TCL_INDEX_NONE, offsetof(Pane, padx), 0, 0, 0},
+	DEF_PANEDWINDOW_PANE_PADX, TCL_INDEX_NONE, offsetof(Pane, padx), 0, 0, 0},
     {TK_OPTION_PIXELS, "-pady", NULL, NULL,
-	 DEF_PANEDWINDOW_PANE_PADY, TCL_INDEX_NONE, offsetof(Pane, pady), 0, 0, 0},
+	DEF_PANEDWINDOW_PANE_PADY, TCL_INDEX_NONE, offsetof(Pane, pady), 0, 0, 0},
     {TK_OPTION_CUSTOM, "-sticky", NULL, NULL,
-	 DEF_PANEDWINDOW_PANE_STICKY, TCL_INDEX_NONE, offsetof(Pane, sticky), 0,
-	 &stickyOption, 0},
+	DEF_PANEDWINDOW_PANE_STICKY, TCL_INDEX_NONE, offsetof(Pane, sticky),
+	0, &stickyOption, 0},
     {TK_OPTION_STRING_TABLE, "-stretch", "stretch", "Stretch",
-	DEF_PANEDWINDOW_PANE_STRETCH, TCL_INDEX_NONE, offsetof(Pane, stretch), 0,
-	(ClientData) stretchStrings, 0},
+	DEF_PANEDWINDOW_PANE_STRETCH, TCL_INDEX_NONE, offsetof(Pane, stretch),
+	TK_OPTION_ENUM_VAR, stretchStrings, 0},
     {TK_OPTION_PIXELS, "-width", NULL, NULL,
-	 DEF_PANEDWINDOW_PANE_WIDTH, offsetof(Pane, widthPtr),
-	 offsetof(Pane, width), TK_OPTION_NULL_OK, 0, 0},
+	DEF_PANEDWINDOW_PANE_WIDTH, offsetof(Pane, widthPtr),
+	offsetof(Pane, width), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
 };
 
 /*
  *--------------------------------------------------------------
@@ -381,11 +381,11 @@
  *--------------------------------------------------------------
  */
 
 int
 Tk_PanedWindowObjCmd(
-    TCL_UNUSED(ClientData),	/* NULL. */
+    TCL_UNUSED(void *),	/* NULL. */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj * const objv[])	/* Argument objects. */
 {
     PanedWindow *pwPtr;
@@ -408,11 +408,11 @@
 	    Tcl_GetAssocData(interp, "PanedWindowOptionTables", NULL);
     if (pwOpts == NULL) {
 	/*
 	 * The first time this function is invoked, the option tables will be
 	 * NULL. We then create the option tables from the templates and store
-	 * a pointer to the tables as the command's clinical so we'll have
+	 * a pointer to the tables as the command's clientData so we'll have
 	 * easy access to it in the future.
 	 */
 
 	pwOpts = (OptionTables *)ckalloc(sizeof(OptionTables));
 
@@ -528,11 +528,11 @@
  *--------------------------------------------------------------
  */
 
 static int
 PanedWindowWidgetObjCmd(
-    ClientData clientData,	/* Information about square widget. */
+    void *clientData,	/* Information about square widget. */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj * const objv[])	/* Argument objects. */
 {
     PanedWindow *pwPtr = (PanedWindow *)clientData;
@@ -1013,14 +1013,18 @@
     memset(newPanes, 0, i);
     if (index == -1) {
 	/*
 	 * If none of the existing panes have to be moved, just copy the old
 	 * and append the new.
+	 * Be careful about the case pwPtr->numPanes == 0 since in this case
+	 * pwPtr->panes is NULL, and the memcpy would have undefined behavior.
 	 */
-	memcpy((void *)&(newPanes[0]), pwPtr->panes,
-		sizeof(Pane *) * pwPtr->numPanes);
-	memcpy((void *)&(newPanes[pwPtr->numPanes]), inserts,
+	if (pwPtr->numPanes) {
+	    memcpy(newPanes, pwPtr->panes,
+		    sizeof(Pane *) * pwPtr->numPanes);
+	}
+	memcpy(&newPanes[pwPtr->numPanes], inserts,
 		sizeof(Pane *) * numNewPanes);
     } else {
 	/*
 	 * If some of the existing panes were moved, the old panes array
 	 * will be partially populated, with some valid and some invalid
@@ -1035,11 +1039,11 @@
 		newPanes[j] = pwPtr->panes[i];
 		j++;
 	    }
 	}
 
-	memcpy((void *)&(newPanes[j]), inserts, sizeof(Pane *)*insertIndex);
+	memcpy(&newPanes[j], inserts, sizeof(Pane *)*insertIndex);
 	j += firstOptionArg - 2;
 
 	for (i = index; i < pwPtr->numPanes; i++) {
 	    if (pwPtr->panes[i] != NULL) {
 		newPanes[j] = pwPtr->panes[i];
@@ -1288,11 +1292,11 @@
  *----------------------------------------------------------------------
  */
 
 static void
 PanedWindowWorldChanged(
-    ClientData instanceData)	/* Information about the paned window. */
+    void *instanceData)	/* Information about the paned window. */
 {
     XGCValues gcValues;
     GC newGC;
     PanedWindow *pwPtr = (PanedWindow *)instanceData;
 
@@ -1346,11 +1350,11 @@
  *--------------------------------------------------------------
  */
 
 static void
 PanedWindowEventProc(
-    ClientData clientData,	/* Information about window. */
+    void *clientData,	/* Information about window. */
     XEvent *eventPtr)		/* Information about event. */
 {
     PanedWindow *pwPtr = (PanedWindow *)clientData;
     int i;
 
@@ -1400,11 +1404,11 @@
  *----------------------------------------------------------------------
  */
 
 static void
 PanedWindowCmdDeletedProc(
-    ClientData clientData)	/* Pointer to widget record for widget. */
+    void *clientData)	/* Pointer to widget record for widget. */
 {
     PanedWindow *pwPtr = (PanedWindow *)clientData;
 
     /*
      * This function could be invoked either because the window was destroyed
@@ -1437,11 +1441,11 @@
  *--------------------------------------------------------------
  */
 
 static void
 DisplayPanedWindow(
-    ClientData clientData)	/* Information about window. */
+    void *clientData)	/* Information about window. */
 {
     PanedWindow *pwPtr = (PanedWindow *)clientData;
     Pane *panePtr;
     Pixmap pixmap;
     Tk_Window tkwin = pwPtr->tkwin;
@@ -1622,11 +1626,11 @@
  *--------------------------------------------------------------
  */
 
 static void
 PanedWindowReqProc(
-    ClientData clientData,	/* Paned window's information about window
+    void *clientData,	/* Paned window's information about window
 				 * that got new preferred geometry. */
     TCL_UNUSED(Tk_Window))		/* Other Tk-related information about the
 				 * window. */
 {
     Pane *panePtr = (Pane *)clientData;
@@ -1668,11 +1672,11 @@
  *--------------------------------------------------------------
  */
 
 static void
 PanedWindowLostPaneProc(
-    ClientData clientData,	/* Grid structure for the pane that was
+    void *clientData,	/* Grid structure for the pane that was
 				 * stolen away. */
     TCL_UNUSED(Tk_Window))		/* Tk's handle for the pane. */
 {
     Pane *panePtr = (Pane *)clientData;
     PanedWindow *pwPtr = (PanedWindow *) panePtr->containerPtr;
@@ -1708,11 +1712,11 @@
  *--------------------------------------------------------------
  */
 
 static void
 ArrangePanes(
-    ClientData clientData)	/* Structure describing parent whose panes
+    void *clientData)	/* Structure describing parent whose panes
 				 * are to be re-layed out. */
 {
     PanedWindow *pwPtr = (PanedWindow *)clientData;
     Pane *panePtr;
     int i, newPaneWidth, newPaneHeight, paneX, paneY;
@@ -2154,11 +2158,11 @@
  *--------------------------------------------------------------
  */
 
 static void
 PaneStructureProc(
-    ClientData clientData,	/* Pointer to record describing window item. */
+    void *clientData,	/* Pointer to record describing window item. */
     XEvent *eventPtr)		/* Describes what just happened. */
 {
     Pane *panePtr = (Pane *)clientData;
     PanedWindow *pwPtr = panePtr->containerPtr;
 
@@ -2366,11 +2370,11 @@
  *----------------------------------------------------------------------
  */
 
 static void
 DestroyOptionTables(
-    ClientData clientData,	/* Pointer to the OptionTables struct */
+    void *clientData,	/* Pointer to the OptionTables struct */
     TCL_UNUSED(Tcl_Interp *))		/* Pointer to the calling interp */
 {
     ckfree(clientData);
 }
 
@@ -2749,11 +2753,11 @@
  *--------------------------------------------------------------
  */
 
 static void
 ProxyWindowEventProc(
-    ClientData clientData,	/* Information about window. */
+    void *clientData,	/* Information about window. */
     XEvent *eventPtr)		/* Information about event. */
 {
     PanedWindow *pwPtr = (PanedWindow *)clientData;
 
     if (eventPtr->type == Expose) {
@@ -2782,11 +2786,11 @@
  *--------------------------------------------------------------
  */
 
 static void
 DisplayProxyWindow(
-    ClientData clientData)	/* Information about window. */
+    void *clientData)	/* Information about window. */
 {
     PanedWindow *pwPtr = (PanedWindow *)clientData;
     Pixmap pixmap;
     Tk_Window tkwin = pwPtr->proxywin;
     pwPtr->flags &= ~PROXY_REDRAW_PENDING;

Index: generic/tkPkgConfig.c
==================================================================
--- generic/tkPkgConfig.c
+++ generic/tkPkgConfig.c
@@ -2,12 +2,12 @@
  * tkPkgConfig.c --
  *
  *	This file contains the configuration information to embed into the tcl
  *	binary library.
  *
- * Copyright (c) 2002 Andreas Kupries <andreas_kupries@users.sourceforge.net>
- * Copyright (c) 2017 Stuart Cassoff <stwo@users.sourceforge.net>
+ * Copyright © 2002 Andreas Kupries <andreas_kupries@users.sourceforge.net>
+ * Copyright © 2017 Stuart Cassoff <stwo@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -93,19 +93,18 @@
 #else
 #  define CFG_FONTSYSTEM	"x11"
 #endif
 
 static const Tcl_Config cfg[] = {
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
     {"debug",			CFG_DEBUG},
     {"threaded",		CFG_THREADED},
     {"profiled",		CFG_PROFILED},
     {"64bit",			CFG_64},
     {"optimized",		CFG_OPTIMIZED},
-#ifdef TK_NO_DEPRECATED
-    {"nodeprecated",	"1"},
-#endif
     {"mem_debug",		CFG_MEMDEBUG},
+#endif
     {"fontsystem",		CFG_FONTSYSTEM},
 
     /* Runtime paths to various stuff */
 
 #ifdef CFG_RUNTIME_LIBDIR
@@ -124,10 +123,13 @@
     {"docdir,runtime",		CFG_RUNTIME_DOCDIR},
 #endif
 #ifdef CFG_RUNTIME_DEMODIR
     {"demodir,runtime",		CFG_RUNTIME_DEMODIR},
 #endif
+#if !defined(STATIC_BUILD)
+    {"dllfile,runtime",		CFG_RUNTIME_DLLFILE},
+#endif
 
     /* Installation paths to various stuff */
 
 #ifdef CFG_INSTALL_LIBDIR
     {"libdir,install",		CFG_INSTALL_LIBDIR},

Index: generic/tkPlace.c
==================================================================
--- generic/tkPlace.c
+++ generic/tkPlace.c
@@ -2,12 +2,12 @@
  * tkPlace.c --
  *
  *	This file contains code to implement a simple geometry manager for Tk
  *	based on absolute placement or "rubber-sheet" placement.
  *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -23,14 +23,14 @@
  * BM_IGNORE:		border issues are ignored: place relative to container's
  *			actual window size.
  */
 
 static const char *const borderModeStrings[] = {
-    "inside", "outside", "ignore", NULL
+    "inside", "ignore", "outside", NULL
 };
 
-typedef enum {BM_INSIDE, BM_OUTSIDE, BM_IGNORE} BorderMode;
+typedef enum {BM_INSIDE, BM_IGNORE, BM_OUTSIDE} BorderMode;
 
 /*
  * For each window whose geometry is managed by the placer there is a
  * structure of the following type:
  */
@@ -68,12 +68,10 @@
     Tcl_Obj *relWidthPtr;
     Tcl_Obj *relHeightPtr;
     Tk_Anchor anchor;		/* Which point on tkwin is placed at the given
 				 * position. */
     BorderMode borderMode;	/* How to treat borders of container window. */
-    int flags;			/* Various flags; see below for bit
-				 * definitions. */
 } Content;
 
 /*
  * Type masks for options:
  */
@@ -82,11 +80,11 @@
 
 static const Tk_OptionSpec optionSpecs[] = {
     {TK_OPTION_ANCHOR, "-anchor", NULL, NULL, "nw", TCL_INDEX_NONE,
 	 offsetof(Content, anchor), 0, 0, 0},
     {TK_OPTION_STRING_TABLE, "-bordermode", NULL, NULL, "inside", TCL_INDEX_NONE,
-	 offsetof(Content, borderMode), 0, borderModeStrings, 0},
+	 offsetof(Content, borderMode), TK_OPTION_ENUM_VAR, borderModeStrings, 0},
     {TK_OPTION_PIXELS, "-height", NULL, NULL, "", offsetof(Content, heightPtr),
 	 offsetof(Content, height), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_WINDOW, "-in", NULL, NULL, "", TCL_INDEX_NONE, offsetof(Content, inTkwin),
 	 0, 0, IN_MASK},
     {TK_OPTION_DOUBLE, "-relheight", NULL, NULL, "",
@@ -106,24 +104,10 @@
     {TK_OPTION_PIXELS, "-y", NULL, NULL, "0", offsetof(Content, yPtr),
 	 offsetof(Content, y), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
 };
 
-/*
- * Flag definitions for Content structures:
- *
- * CHILD_WIDTH -		1 means -width was specified;
- * CHILD_REL_WIDTH -		1 means -relwidth was specified.
- * CHILD_HEIGHT -		1 means -height was specified;
- * CHILD_REL_HEIGHT -		1 means -relheight was specified.
- */
-
-#define CHILD_WIDTH		1
-#define CHILD_REL_WIDTH		2
-#define CHILD_HEIGHT		4
-#define CHILD_REL_HEIGHT	8
-
 /*
  * For each container window that has a content managed by the placer there is a
  * structure of the following form:
  */
 
@@ -277,12 +261,12 @@
 	Tcl_InitHashTable(&dispPtr->containerTable, TCL_ONE_WORD_KEYS);
 	Tcl_InitHashTable(&dispPtr->contentTable, TCL_ONE_WORD_KEYS);
 	dispPtr->placeInit = 1;
     }
 
-    if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings,
-	    sizeof(char *), "option", 0, &index) != TCL_OK) {
+    if (Tcl_GetIndexFromObj(NULL, objv[1], optionStrings,
+	    "option", 0, &index) != TCL_OK) {
 	/*
 	 * Call it again without the deprecated ones to get a proper error
 	 * message. This works well since there can't be any ambiguity between
 	 * deprecated and new options.
 	 */
@@ -408,10 +392,14 @@
     memset(contentPtr, 0, sizeof(Content));
     contentPtr->tkwin = tkwin;
     contentPtr->inTkwin = NULL;
     contentPtr->anchor = TK_ANCHOR_NW;
     contentPtr->borderMode = BM_INSIDE;
+    contentPtr->width = INT_MIN;
+    contentPtr->height = INT_MIN;
+    contentPtr->relWidth = NAN;
+    contentPtr->relHeight = NAN;
     contentPtr->optionTable = table;
     Tcl_SetHashValue(hPtr, contentPtr);
     Tk_CreateEventHandler(tkwin, StructureNotifyMask, ContentStructureProc,
 	    contentPtr);
     return contentPtr;
@@ -435,10 +423,13 @@
 
 static void
 FreeContent(
     Content *contentPtr)
 {
+    if (contentPtr->containerPtr && (contentPtr->containerPtr->flags & PARENT_RECONFIG_PENDING)) {
+	Tcl_CancelIdleCall(RecomputePlacement, contentPtr->containerPtr);
+    }
     Tk_FreeConfigOptions((char *) contentPtr, contentPtr->optionTable,
 	    contentPtr->tkwin);
     ckfree(contentPtr);
 }
 
@@ -644,31 +635,10 @@
     if (Tk_SetOptions(interp, contentPtr, table, objc, objv,
 	    contentPtr->tkwin, &savedOptions, &mask) != TCL_OK) {
 	goto error;
     }
 
-    /*
-     * Set content flags. First clear the field, then add bits as needed.
-     */
-
-    contentPtr->flags = 0;
-    if (contentPtr->heightPtr) {
-	contentPtr->flags |= CHILD_HEIGHT;
-    }
-
-    if (contentPtr->relHeightPtr) {
-	contentPtr->flags |= CHILD_REL_HEIGHT;
-    }
-
-    if (contentPtr->relWidthPtr) {
-	contentPtr->flags |= CHILD_REL_WIDTH;
-    }
-
-    if (contentPtr->widthPtr) {
-	contentPtr->flags |= CHILD_WIDTH;
-    }
-
     if (!(mask & IN_MASK) && (contentPtr->containerPtr != NULL)) {
 	/*
 	 * If no -in option was passed and the content is already placed then
 	 * just recompute the placement.
 	 */
@@ -822,27 +792,27 @@
 	Tcl_AppendToObj(infoObj, " ", -1);
     }
     Tcl_AppendPrintfToObj(infoObj,
 	    "-x %d -relx %.4g -y %d -rely %.4g",
 	    contentPtr->x, contentPtr->relX, contentPtr->y, contentPtr->relY);
-    if (contentPtr->flags & CHILD_WIDTH) {
+    if (contentPtr->widthPtr) {
 	Tcl_AppendPrintfToObj(infoObj, " -width %d", contentPtr->width);
     } else {
 	Tcl_AppendToObj(infoObj, " -width {}", -1);
     }
-    if (contentPtr->flags & CHILD_REL_WIDTH) {
+    if (contentPtr->relWidthPtr) {
 	Tcl_AppendPrintfToObj(infoObj,
 		" -relwidth %.4g", contentPtr->relWidth);
     } else {
 	Tcl_AppendToObj(infoObj, " -relwidth {}", -1);
     }
-    if (contentPtr->flags & CHILD_HEIGHT) {
+    if (contentPtr->heightPtr) {
 	Tcl_AppendPrintfToObj(infoObj, " -height %d", contentPtr->height);
     } else {
 	Tcl_AppendToObj(infoObj, " -height {}", -1);
     }
-    if (contentPtr->flags & CHILD_REL_HEIGHT) {
+    if (contentPtr->relHeightPtr) {
 	Tcl_AppendPrintfToObj(infoObj,
 		" -relheight %.4g", contentPtr->relHeight);
     } else {
 	Tcl_AppendToObj(infoObj, " -relheight {}", -1);
     }
@@ -934,16 +904,16 @@
 
 	x1 = contentPtr->x + containerX + (contentPtr->relX*containerWidth);
 	x = (int) (x1 + ((x1 > 0) ? 0.5 : -0.5));
 	y1 = contentPtr->y + containerY + (contentPtr->relY*containerHeight);
 	y = (int) (y1 + ((y1 > 0) ? 0.5 : -0.5));
-	if (contentPtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) {
+	if ((contentPtr->widthPtr) || contentPtr->relWidthPtr) {
 	    width = 0;
-	    if (contentPtr->flags & CHILD_WIDTH) {
+	    if (contentPtr->widthPtr) {
 		width += contentPtr->width;
 	    }
-	    if (contentPtr->flags & CHILD_REL_WIDTH) {
+	    if (contentPtr->relWidthPtr) {
 		/*
 		 * The code below is a bit tricky. In order to round correctly
 		 * when both relX and relWidth are specified, compute the
 		 * location of the right edge and round that, then compute
 		 * width. If we compute the width and round it, rounding
@@ -956,16 +926,16 @@
 	    }
 	} else {
 	    width = Tk_ReqWidth(contentPtr->tkwin)
 		    + 2*Tk_Changes(contentPtr->tkwin)->border_width;
 	}
-	if (contentPtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT)) {
+	if (contentPtr->heightPtr || contentPtr->relHeightPtr) {
 	    height = 0;
-	    if (contentPtr->flags & CHILD_HEIGHT) {
+	    if (contentPtr->heightPtr) {
 		height += contentPtr->height;
 	    }
-	    if (contentPtr->flags & CHILD_REL_HEIGHT) {
+	    if (contentPtr->relHeightPtr) {
 		/*
 		 * See note above for rounding errors in width computation.
 		 */
 
 		y2 = y1 + (contentPtr->relHeight*containerHeight);
@@ -1008,11 +978,11 @@
 	case TK_ANCHOR_W:
 	    y -= height/2;
 	    break;
 	case TK_ANCHOR_NW:
 	    break;
-	case TK_ANCHOR_CENTER:
+	default:
 	    x -= width/2;
 	    y -= height/2;
 	    break;
 	}
 
@@ -1212,12 +1182,12 @@
     TCL_UNUSED(Tk_Window))		/* Window that changed its desired size. */
 {
     Content *contentPtr = (Content *)clientData;
     Container *containerPtr;
 
-    if ((contentPtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH))
-	    && (contentPtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT))) {
+    if ((contentPtr->widthPtr || contentPtr->relWidthPtr)
+	    && (contentPtr->heightPtr || contentPtr->relHeightPtr)) {
         /*
          * Send a ConfigureNotify to indicate that the size change
          * request was rejected.
          */
 

Index: generic/tkPlatDecls.h
==================================================================
--- generic/tkPlatDecls.h
+++ generic/tkPlatDecls.h
@@ -1,11 +1,11 @@
 /*
  * tkPlatDecls.h --
  *
  *	Declarations of functions in the platform-specific public Tcl API.
  *
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright (c) 1998-1999 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkPointer.c
==================================================================
--- generic/tkPointer.c
+++ generic/tkPointer.c
@@ -4,11 +4,11 @@
  *	This file contains functions for emulating the X server pointer and
  *	grab state machine. This file is used by the Mac and Windows platforms
  *	to generate appropriate enter/leave events, and to update the global
  *	grab window information.
  *
- * Copyright (c) 1996 by Sun Microsystems, Inc.
+ * Copyright © 1996 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -500,11 +500,11 @@
 {
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
 
     if (winPtr == tsdPtr->lastWinPtr) {
-	tsdPtr->lastWinPtr = NULL;
+	tsdPtr->lastWinPtr = TkGetContainer(winPtr);
     }
     if (winPtr == tsdPtr->grabWinPtr) {
 	tsdPtr->grabWinPtr = NULL;
     }
     if (winPtr == tsdPtr->restrictWinPtr) {

Index: generic/tkRectOval.c
==================================================================
--- generic/tkRectOval.c
+++ generic/tkRectOval.c
@@ -1,12 +1,12 @@
 /*
  * tkRectOval.c --
  *
  *	This file implements rectangle and oval items for canvas widgets.
  *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkScale.c
==================================================================
--- generic/tkScale.c
+++ generic/tkScale.c
@@ -7,13 +7,13 @@
  *
  *	The modifications to use floating-point values are based on an
  *	implementation by Paul Mackerras. The -variable option is due to
  *	Henning Schulzrinne. All of these are used with permission.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-2000 by Scriptics Corporation.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -32,19 +32,10 @@
 
 static const char *const orientStrings[] = {
     "horizontal", "vertical", NULL
 };
 
-/*
- * The following table defines the legal values for the -state option. It is
- * used together with the "enum state" declaration in tkScale.h.
- */
-
-static const char *const stateStrings[] = {
-    "active", "disabled", "normal", NULL
-};
-
 static const Tk_OptionSpec optionSpecs[] = {
     {TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
 	DEF_SCALE_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, activeBorder),
 	0, DEF_SCALE_ACTIVE_BG_MONO, 0},
     {TK_OPTION_BORDER, "-background", "background", "Background",
@@ -73,11 +64,11 @@
 	NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
     {TK_OPTION_FONT, "-font", "font", "Font",
 	DEF_SCALE_FONT, TCL_INDEX_NONE, offsetof(TkScale, tkfont), 0, 0, 0},
     {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
 	DEF_SCALE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, textColorPtr), 0,
-	(ClientData) DEF_SCALE_FG_MONO, 0},
+	DEF_SCALE_FG_MONO, 0},
     {TK_OPTION_DOUBLE, "-from", "from", "From", DEF_SCALE_FROM, TCL_INDEX_NONE,
 	offsetof(TkScale, fromValue), 0, 0, 0},
     {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
 	"HighlightBackground", DEF_SCALE_HIGHLIGHT_BG_COLOR,
 	TCL_INDEX_NONE, offsetof(TkScale, highlightBorder),
@@ -93,11 +84,11 @@
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_PIXELS, "-length", "length", "Length",
 	DEF_SCALE_LENGTH, TCL_INDEX_NONE, offsetof(TkScale, length), 0, 0, 0},
     {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
 	DEF_SCALE_ORIENT, TCL_INDEX_NONE, offsetof(TkScale, orient),
-	0, orientStrings, 0},
+	TK_OPTION_ENUM_VAR, orientStrings, 0},
     {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
 	DEF_SCALE_RELIEF, TCL_INDEX_NONE, offsetof(TkScale, relief), 0, 0, 0},
     {TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
 	DEF_SCALE_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(TkScale, repeatDelay),
 	0, 0, 0},
@@ -116,11 +107,11 @@
     {TK_OPTION_RELIEF, "-sliderrelief", "sliderRelief", "SliderRelief",
 	DEF_SCALE_SLIDER_RELIEF, TCL_INDEX_NONE, offsetof(TkScale, sliderRelief),
 	0, 0, 0},
     {TK_OPTION_STRING_TABLE, "-state", "state", "State",
 	DEF_SCALE_STATE, TCL_INDEX_NONE, offsetof(TkScale, state),
-	0, stateStrings, 0},
+	TK_OPTION_ENUM_VAR, tkStateStrings, 0},
     {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
 	DEF_SCALE_TAKE_FOCUS, offsetof(TkScale, takeFocusPtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_DOUBLE, "-tickinterval", "tickInterval", "TickInterval",
 	DEF_SCALE_TICK_INTERVAL, TCL_INDEX_NONE, offsetof(TkScale, tickInterval),
@@ -1357,18 +1348,18 @@
      * interpreter is going away.
      */
 
     if (flags & TCL_TRACE_UNSETS) {
         if (!Tcl_InterpDeleted(interp) && scalePtr->varNamePtr) {
-            ClientData probe = NULL;
+            void *probe = NULL;
 
             do {
                 probe = Tcl_VarTraceInfo(interp,
                         Tcl_GetString(scalePtr->varNamePtr),
                         TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
                         ScaleVarProc, probe);
-                if (probe == (ClientData)scalePtr) {
+                if (probe == (void *)scalePtr) {
                     break;
                 }
             } while (probe);
             if (probe) {
                 /*

Index: generic/tkScale.h
==================================================================
--- generic/tkScale.h
+++ generic/tkScale.h
@@ -2,12 +2,12 @@
  * tkScale.h --
  *
  *	Declarations of types and functions used to implement the scale
  *	widget.
  *
- * Copyright (c) 1996 by Sun Microsystems, Inc.
- * Copyright (c) 1999-2000 by Scriptics Corporation.
+ * Copyright © 1996 Sun Microsystems, Inc.
+ * Copyright © 1999-2000 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkScrollbar.c
==================================================================
--- generic/tkScrollbar.c
+++ generic/tkScrollbar.c
@@ -3,12 +3,12 @@
  *
  *	This module implements a scrollbar widgets for the Tk toolkit. A
  *	scrollbar displays a slider and two arrows; mouse clicks on features
  *	within the scrollbar cause scrolling commands to be invoked.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -269,11 +269,11 @@
 	}
 	if (objc != 3) {
 		Tcl_WrongNumArgs(interp, 1, objv, "activate element");
 	    goto error;
 	}
-	c = TkGetStringFromObj(objv[2], &len)[0];
+	c = Tcl_GetStringFromObj(objv[2], &len)[0];
 	oldActiveField = scrollPtr->activeField;
 	if ((c == 'a') && (strcmp(Tcl_GetString(objv[2]), "arrow1") == 0)) {
 	    scrollPtr->activeField = TOP_ARROW;
 	} else if ((c == 'a') && (strcmp(Tcl_GetString(objv[2]), "arrow2") == 0)) {
 	    scrollPtr->activeField = BOTTOM_ARROW;

Index: generic/tkScrollbar.h
==================================================================
--- generic/tkScrollbar.h
+++ generic/tkScrollbar.h
@@ -2,11 +2,11 @@
  * tkScrollbar.h --
  *
  *	Declarations of types and functions used to implement the scrollbar
  *	widget.
  *
- * Copyright (c) 1996 by Sun Microsystems, Inc.
+ * Copyright © 1996 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkSelect.c
==================================================================
--- generic/tkSelect.c
+++ generic/tkSelect.c
@@ -2,12 +2,12 @@
  * tkSelect.c --
  *
  *	This file manages the selection for the Tk toolkit, translating
  *	between the standard X ICCCM conventions and Tcl commands.
  *
- * Copyright (c) 1990-1993 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1993 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -898,11 +898,11 @@
 	} else if (formatName != NULL) {
 	    format = Tk_InternAtom(tkwin, formatName);
 	} else {
 	    format = XA_STRING;
 	}
-	string = TkGetStringFromObj(objs[1], &cmdLength);
+	string = Tcl_GetStringFromObj(objs[1], &cmdLength);
 	if (cmdLength == 0) {
 	    Tk_DeleteSelHandler(tkwin, selection, target);
 	} else {
 	    cmdInfoPtr = (CommandInfo *)ckalloc(offsetof(CommandInfo, command)
 		    + 1 + cmdLength);
@@ -1189,11 +1189,11 @@
 
     /*
      * Using UTF8_STRING instead of the XA_UTF8_STRING macro allows us to
      * support older X servers that didn't have UTF8_STRING yet. This is
      * necessary on Unix systems. For more information, see:
-     *	  http://www.cl.cam.ac.uk/~mgk25/unicode.html#x11
+     *	  https://www.cl.cam.ac.uk/~mgk25/unicode.html#x11
      */
 
 #if !defined(_WIN32)
     dispPtr->utf8Atom		= Tk_InternAtom(tkwin, "UTF8_STRING");
 #else
@@ -1397,16 +1397,16 @@
 	if (cmdInfoPtr->interp != NULL) {
 	    if (length <= (int)maxBytes) {
 		cmdInfoPtr->charOffset += Tcl_NumUtfChars(string, -1);
 		cmdInfoPtr->buffer[0] = '\0';
 	    } else {
-		int ch;
+		Tcl_UniChar ch = 0;
 		p = string;
 		string += count;
 		numChars = 0;
 		while (p < string) {
-		    p += TkUtfToUniChar(p, &ch);
+		    p += Tcl_UtfToUniChar(p, &ch);
 		    numChars++;
 		}
 		cmdInfoPtr->charOffset += numChars;
 		length = p - string;
 		if (length > 0) {

Index: generic/tkSelect.h
==================================================================
--- generic/tkSelect.h
+++ generic/tkSelect.h
@@ -2,11 +2,11 @@
  * tkSelect.h --
  *
  *	Declarations of types shared among the files that implement selection
  *	support.
  *
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright © 1995 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkSquare.c
==================================================================
--- generic/tkSquare.c
+++ generic/tkSquare.c
@@ -5,11 +5,11 @@
  *	"square" is a widget that displays a single square that can be moved
  *	around and resized. This file is intended as an example of how to
  *	build a widget; it isn't included in the normal wish, but it is
  *	included in "tktest".
  *
- * Copyright (c) 1997 Sun Microsystems, Inc.
+ * Copyright © 1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkStubInit.c
==================================================================
--- generic/tkStubInit.c
+++ generic/tkStubInit.c
@@ -1,11 +1,11 @@
 /*
  * tkStubInit.c --
  *
  *	This file contains the initializers for the Tk stub vectors.
  *
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright © 1998-1999 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -23,10 +23,12 @@
 
 #if defined(MAC_OSX_TK)
 /* we could have used _TKMACINT */
 #include "tkMacOSXInt.h"
 #include "tkMacOSXPrivate.h"
+#else
+#   define Tk_ClipDrawableToRect 0
 #endif
 
 /* TODO: These ought to come in some other way */
 #include "tkPlatDecls.h"
 #include "tkIntXlibDecls.h"
@@ -56,10 +58,21 @@
 #else
 #   define Tk_TranslateWinEvent 0
 #   define Tk_PointerEvent 0
 #   define TkWinGetPlatformId 0
 #endif
+
+#if defined(TK_NO_DEPRECATED) || (TCL_MAJOR_VERSION > 8)
+#   define TkSetWindowMenuBar 0
+#   define TkpDrawHighlightBorder 0
+#   define TkpUseWindow 0
+#   define TkpSetMainMenubar 0
+#   define TkpGetOtherWindow 0
+#   define TkpGetSystemDefault 0
+#   define TkpMakeContainer 0
+#   define TkpMakeWindow 0
+#endif
 
 static int
 doNothing(void)
 {
     /* dummy implementation, no need to do anything */
@@ -105,11 +118,11 @@
 		int offset))(void *)TkCanvasTagsParseProc
 #define Tk_CanvasTagsPrintProc \
 		(const char *(*) (void *,Tk_Window, char *, int, \
 		Tcl_FreeProc **))(void *)TkCanvasTagsPrintProc
 
-#if !defined(MAC_OSX_TK) && defined(MAC_OSX_TCL)
+#if !defined(MAC_OSX_TK)
 #   undef TkpWillDrawWidget
 #   undef TkpRedrawWidget
 #   define TkpWillDrawWidget ((int (*)(Tk_Window))(void *)doNothing)
 #   define TkpRedrawWidget ((void (*)(Tk_Window))(void *)doNothing)
 #endif
@@ -499,28 +512,12 @@
     TkSmoothPrintProc, /* 180 */
     TkDrawAngledTextLayout, /* 181 */
     TkUnderlineAngledTextLayout, /* 182 */
     TkIntersectAngledTextLayout, /* 183 */
     TkDrawAngledChars, /* 184 */
-#if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */
-    0, /* 185 */
-#endif /* UNIX */
-#if defined(_WIN32) /* WIN */
-    0, /* 185 */
-#endif /* WIN */
-#ifdef MAC_OSX_TCL /* MACOSX */
     TkpRedrawWidget, /* 185 */
-#endif /* MACOSX */
-#if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */
-    0, /* 186 */
-#endif /* UNIX */
-#if defined(_WIN32) /* WIN */
-    0, /* 186 */
-#endif /* WIN */
-#ifdef MAC_OSX_TCL /* MACOSX */
     TkpWillDrawWidget, /* 186 */
-#endif /* MACOSX */
     TkDebugPhotoStringMatchDef, /* 187 */
 };
 
 static const TkIntPlatStubs tkIntPlatStubs = {
     TCL_STUB_MAGIC,
@@ -1330,10 +1327,21 @@
     Tk_GetButtonMask, /* 275 */
     Tk_GetDoublePixelsFromObj, /* 276 */
     Tk_NewWindowObj, /* 277 */
     Tk_SendVirtualEvent, /* 278 */
     Tk_FontGetDescription, /* 279 */
+    Tk_CreatePhotoImageFormatVersion3, /* 280 */
+    Tk_DrawHighlightBorder, /* 281 */
+    Tk_SetMainMenubar, /* 282 */
+    Tk_SetWindowMenubar, /* 283 */
+    Tk_ClipDrawableToRect, /* 284 */
+    Tk_GetSystemDefault, /* 285 */
+    Tk_UseWindow, /* 286 */
+    Tk_MakeContainer, /* 287 */
+    Tk_GetOtherWindow, /* 288 */
+    Tk_Get3DBorderColors, /* 289 */
+    Tk_MakeWindow, /* 290 */
 };
 
 /* !END!: Do not edit above this line. */
 
 

Index: generic/tkStubLib.c
==================================================================
--- generic/tkStubLib.c
+++ generic/tkStubLib.c
@@ -2,12 +2,12 @@
  * tkStubLib.c --
  *
  *	Stub object that will be statically linked into extensions that want
  *	to access Tk.
  *
- * Copyright (c) 1998-1999 by Scriptics Corporation.
- * Copyright (c) 1998 Paul Duffin.
+ * Copyright © 1998-1999 Scriptics Corporation.
+ * Copyright © 1998 Paul Duffin.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -73,19 +73,23 @@
 Tk_InitStubs(
     Tcl_Interp *interp,
     const char *version,
     int exact)
 {
-    const char *packageName = "Tk";
+    const char *packageName = "tk";
     const char *errMsg = NULL;
     void *clientData = NULL;
     const char *actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp,
 	    packageName, version, 0, &clientData);
-    const TkStubs *stubsPtr = (const TkStubs *)clientData;
 
     if (actualVersion == NULL) {
-	return NULL;
+	packageName = "Tk";
+	actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp,
+    	    packageName, version, 0, &clientData);
+	if (actualVersion == NULL) {
+	    return NULL;
+	}
     }
 
     if (exact) {
 	const char *p = version;
 	int count = 0;
@@ -111,19 +115,19 @@
 	    if (actualVersion == NULL) {
 		return NULL;
 	    }
 	}
     }
-    if (stubsPtr == NULL) {
+    if (clientData == NULL) {
 	errMsg = "missing stub table pointer";
     } else {
-	tkStubsPtr = stubsPtr;
-	if (stubsPtr->hooks) {
-	    tkPlatStubsPtr = stubsPtr->hooks->tkPlatStubs;
-	    tkIntStubsPtr = stubsPtr->hooks->tkIntStubs;
-	    tkIntPlatStubsPtr = stubsPtr->hooks->tkIntPlatStubs;
-	    tkIntXlibStubsPtr = stubsPtr->hooks->tkIntXlibStubs;
+	tkStubsPtr = (const TkStubs *)clientData;
+	if (tkStubsPtr->hooks) {
+	    tkPlatStubsPtr = tkStubsPtr->hooks->tkPlatStubs;
+	    tkIntStubsPtr = tkStubsPtr->hooks->tkIntStubs;
+	    tkIntPlatStubsPtr = tkStubsPtr->hooks->tkIntPlatStubs;
+	    tkIntXlibStubsPtr = tkStubsPtr->hooks->tkIntXlibStubs;
 	} else {
 	    tkPlatStubsPtr = NULL;
 	    tkIntStubsPtr = NULL;
 	    tkIntPlatStubsPtr = NULL;
 	    tkIntXlibStubsPtr = NULL;

Index: generic/tkStyle.c
==================================================================
--- generic/tkStyle.c
+++ generic/tkStyle.c
@@ -1,12 +1,12 @@
 /*
  * tkStyle.c --
  *
  *	This file implements the widget styles and themes support.
  *
- * Copyright (c) 1990-1993 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1993 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkTest.c
==================================================================
--- generic/tkTest.c
+++ generic/tkTest.c
@@ -4,13 +4,13 @@
  *	This file contains C command functions for a bunch of additional Tcl
  *	commands that are used for testing out Tcl's C interfaces. These
  *	commands are not normally included in Tcl applications; they're only
  *	used for testing.
  *
- * Copyright (c) 1993-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright © 1993-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-1999 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -85,11 +85,11 @@
 /*
  * The type record for test images:
  */
 
 static int		ImageCreate(Tcl_Interp *interp,
-			    const char *name, int argc, Tcl_Obj *const objv[],
+			    const char *name, int objc, Tcl_Obj *const objv[],
 			    const Tk_ImageType *typePtr, Tk_ImageModel model,
 			    ClientData *clientDataPtr);
 static ClientData	ImageGet(Tk_Window tkwin, ClientData clientData);
 static void		ImageDisplay(ClientData clientData,
 			    Display *display, Drawable drawable,
@@ -245,52 +245,52 @@
 
     /*
      * Create additional commands for testing Tk.
      */
 
-    if (Tcl_PkgProvideEx(interp, "Tktest", TK_PATCH_LEVEL, NULL) == TCL_ERROR) {
+    if (Tcl_PkgProvideEx(interp, "tk::test", TK_PATCH_LEVEL, NULL) == TCL_ERROR) {
 	return TCL_ERROR;
     }
 
     Tcl_CreateObjCommand(interp, "square", SquareObjCmd, NULL, NULL);
     Tcl_CreateObjCommand(interp, "testbitmap", TestbitmapObjCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
     Tcl_CreateObjCommand(interp, "testborder", TestborderObjCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
     Tcl_CreateObjCommand(interp, "testcolor", TestcolorObjCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
     Tcl_CreateObjCommand(interp, "testcursor", TestcursorObjCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
     Tcl_CreateObjCommand(interp, "testdeleteapps", TestdeleteappsObjCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
     Tcl_CreateObjCommand(interp, "testembed", TkpTestembedCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
     Tcl_CreateObjCommand(interp, "testobjconfig", TestobjconfigObjCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
     Tcl_CreateObjCommand(interp, "testfont", TestfontObjCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
     Tcl_CreateObjCommand(interp, "testmakeexist", TestmakeexistObjCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
     Tcl_CreateObjCommand(interp, "testprop", TestpropObjCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
     Tcl_CreateObjCommand(interp, "testprintf", TestprintfObjCmd, NULL, NULL);
     Tcl_CreateObjCommand(interp, "testtext", TkpTesttextCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
     Tcl_CreateObjCommand(interp, "testphotostringmatch",
-            TestPhotoStringMatchCmd, (ClientData) Tk_MainWindow(interp),
+            TestPhotoStringMatchCmd, Tk_MainWindow(interp),
             NULL);
 
 #if defined(_WIN32)
     Tcl_CreateObjCommand(interp, "testmetrics", TestmetricsObjCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
 #elif !defined(__CYGWIN__) && !defined(MAC_OSX_TK)
     Tcl_CreateObjCommand(interp, "testmenubar", TestmenubarObjCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
     Tcl_CreateObjCommand(interp, "testsend", TkpTestsendCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
     Tcl_CreateObjCommand(interp, "testwrapper", TestwrapperObjCmd,
-	    (ClientData) Tk_MainWindow(interp), NULL);
+	    Tk_MainWindow(interp), NULL);
 #endif /* _WIN32 */
 
     /*
      * Create test image type.
      */
@@ -365,11 +365,11 @@
  *----------------------------------------------------------------------
  */
 
 static int
 TestborderObjCmd(
-    TCL_UNUSED(ClientData),	/* Main window for application. */
+    TCL_UNUSED(void *),	/* Main window for application. */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     if (objc < 2) {
@@ -571,10 +571,11 @@
 	    Tcl_Obj *booleanPtr;
 	    Tcl_Obj *integerPtr;
 	    Tcl_Obj *doublePtr;
 	    Tcl_Obj *stringPtr;
 	    Tcl_Obj *stringTablePtr;
+	    Tcl_Obj *stringTablePtr2;
 	    Tcl_Obj *colorPtr;
 	    Tcl_Obj *fontPtr;
 	    Tcl_Obj *bitmapPtr;
 	    Tcl_Obj *borderPtr;
 	    Tcl_Obj *reliefPtr;
@@ -587,14 +588,17 @@
 	    Tcl_Obj *customPtr;
 	} TypesRecord;
 	TypesRecord *recordPtr;
 	static const char *const stringTable[] = {
 	    "one", "two", "three", "four", NULL
+	};
+	static const char *const stringTable2[] = {
+	    "one", "two", NULL
 	};
 	static const Tk_OptionSpec typesSpecs[] = {
-	    {TK_OPTION_BOOLEAN, "-boolean", "boolean", "Boolean", "1",
-		offsetof(TypesRecord, booleanPtr), TCL_INDEX_NONE, 0, 0, 0x1},
+	    {TK_OPTION_BOOLEAN, "-boolean", "boolean", "Boolean", NULL,
+		offsetof(TypesRecord, booleanPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, 0, 0x1},
 	    {TK_OPTION_INT, "-integer", "integer", "Integer", "7",
 		offsetof(TypesRecord, integerPtr), TCL_INDEX_NONE, 0, 0, 0x2},
 	    {TK_OPTION_DOUBLE, "-double", "double", "Double", "3.14159",
 		offsetof(TypesRecord, doublePtr), TCL_INDEX_NONE, 0, 0, 0x4},
 	    {TK_OPTION_STRING, "-string", "string", "String",
@@ -602,10 +606,14 @@
 		TK_CONFIG_NULL_OK, 0, 0x8},
 	    {TK_OPTION_STRING_TABLE,
 		"-stringtable", "StringTable", "stringTable",
 		"one", offsetof(TypesRecord, stringTablePtr), TCL_INDEX_NONE,
 		TK_CONFIG_NULL_OK, stringTable, 0x10},
+	    {TK_OPTION_STRING_TABLE,
+		"-stringtable2", "StringTable2", "stringTable2",
+		"two", offsetof(TypesRecord, stringTablePtr2), TCL_INDEX_NONE,
+		TK_CONFIG_NULL_OK, stringTable2, 0x10},
 	    {TK_OPTION_COLOR, "-color", "color", "Color",
 		"red", offsetof(TypesRecord, colorPtr), TCL_INDEX_NONE,
 		TK_CONFIG_NULL_OK, "black", 0x20},
 	    {TK_OPTION_FONT, "-font", "font", "Font", "Helvetica 12",
 		offsetof(TypesRecord, fontPtr), TCL_INDEX_NONE,
@@ -614,20 +622,20 @@
 		offsetof(TypesRecord, bitmapPtr), TCL_INDEX_NONE,
 		TK_CONFIG_NULL_OK, 0, 0x80},
 	    {TK_OPTION_BORDER, "-border", "border", "Border",
 		"blue", offsetof(TypesRecord, borderPtr), TCL_INDEX_NONE,
 		TK_CONFIG_NULL_OK, "white", 0x100},
-	    {TK_OPTION_RELIEF, "-relief", "relief", "Relief", "raised",
+	    {TK_OPTION_RELIEF, "-relief", "relief", "Relief", NULL,
 		offsetof(TypesRecord, reliefPtr), TCL_INDEX_NONE,
 		TK_CONFIG_NULL_OK, 0, 0x200},
 	    {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", "xterm",
 		offsetof(TypesRecord, cursorPtr), TCL_INDEX_NONE,
 		TK_CONFIG_NULL_OK, 0, 0x400},
 	    {TK_OPTION_JUSTIFY, "-justify", NULL, NULL, "left",
 		offsetof(TypesRecord, justifyPtr), TCL_INDEX_NONE,
 		TK_CONFIG_NULL_OK, 0, 0x800},
-	    {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", NULL,
+	    {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "center",
 		offsetof(TypesRecord, anchorPtr), TCL_INDEX_NONE,
 		TK_CONFIG_NULL_OK, 0, 0x1000},
 	    {TK_OPTION_PIXELS, "-pixel", "pixel", "Pixel",
 		"1", offsetof(TypesRecord, pixelPtr), TCL_INDEX_NONE,
 		TK_CONFIG_NULL_OK, 0, 0x2000},
@@ -666,19 +674,20 @@
 	recordPtr->justifyPtr = NULL;
 	recordPtr->anchorPtr = NULL;
 	recordPtr->pixelPtr = NULL;
 	recordPtr->mmPtr = NULL;
 	recordPtr->stringTablePtr = NULL;
+	recordPtr->stringTablePtr2 = NULL;
 	recordPtr->customPtr = NULL;
 	result = Tk_InitOptions(interp, recordPtr, optionTable,
 		tkwin);
 	if (result == TCL_OK) {
 	    recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp,
 		    Tcl_GetString(objv[2]), TrivialConfigObjCmd,
-		    (ClientData) recordPtr, TrivialCmdDeletedProc);
+		    recordPtr, TrivialCmdDeletedProc);
 	    Tk_CreateEventHandler(tkwin, StructureNotifyMask,
-		    TrivialEventProc, (ClientData) recordPtr);
+		    TrivialEventProc, recordPtr);
 	    result = Tk_SetOptions(interp, recordPtr, optionTable,
 		    objc-3, objv+3, tkwin, NULL, NULL);
 	    if (result != TCL_OK) {
 		Tk_DestroyWindow(tkwin);
 	    }
@@ -720,13 +729,13 @@
 	    }
 	}
 	if (result == TCL_OK) {
 	    recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp,
 		    Tcl_GetString(objv[2]), TrivialConfigObjCmd,
-		    (ClientData) recordPtr, TrivialCmdDeletedProc);
+		    recordPtr, TrivialCmdDeletedProc);
 	    Tk_CreateEventHandler(tkwin, StructureNotifyMask,
-		    TrivialEventProc, (ClientData) recordPtr);
+		    TrivialEventProc, recordPtr);
 	    Tcl_SetObjResult(interp, objv[2]);
 	}
 	break;
     }
 
@@ -742,11 +751,11 @@
 		offsetof(ExtensionWidgetRecord, base2ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
 	    {TK_OPTION_STRING,
 		"-oneAgain", "oneAgain", "OneAgain", "one again",
 		offsetof(ExtensionWidgetRecord, extension5ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
 	    {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
-		(ClientData) baseSpecs, 0}
+		baseSpecs, 0}
 	};
 	Tk_OptionTable optionTable;
 
 	tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData,
 		Tcl_GetString(objv[2]), NULL);
@@ -773,13 +782,13 @@
 	    }
 	}
 	if (result == TCL_OK) {
 	    recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp,
 		    Tcl_GetString(objv[2]), TrivialConfigObjCmd,
-		    (ClientData) recordPtr, TrivialCmdDeletedProc);
+		    recordPtr, TrivialCmdDeletedProc);
 	    Tk_CreateEventHandler(tkwin, StructureNotifyMask,
-		    TrivialEventProc, (ClientData) recordPtr);
+		    TrivialEventProc, recordPtr);
 	    Tcl_SetObjResult(interp, objv[2]);
 	}
 	break;
     }
 
@@ -788,11 +797,11 @@
 	    Tcl_Obj *intPtr;
 	} ErrorWidgetRecord;
 	ErrorWidgetRecord widgetRecord;
 	static const Tk_OptionSpec errorSpecs[] = {
 	    {TK_OPTION_INT, "-int", "integer", "Integer", "bogus",
-		offsetof(ErrorWidgetRecord, intPtr), 0, 0, NULL, 0},
+		offsetof(ErrorWidgetRecord, intPtr), 0, TK_OPTION_NULL_OK, NULL, 0},
 	    {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
 	};
 	Tk_OptionTable optionTable;
 
 	widgetRecord.intPtr = NULL;
@@ -862,11 +871,11 @@
 	static const char *const internalStringTable[] = {
 	    "one", "two", "three", "four", NULL
 	};
 	static const Tk_OptionSpec internalSpecs[] = {
 	    {TK_OPTION_BOOLEAN, "-boolean", "boolean", "Boolean", "1",
-		TCL_INDEX_NONE, offsetof(InternalRecord, boolean), 0, 0, 0x1},
+		TCL_INDEX_NONE, offsetof(InternalRecord, boolean), TK_CONFIG_NULL_OK, 0, 0x1},
 	    {TK_OPTION_INT, "-integer", "integer", "Integer", "148962237",
 		TCL_INDEX_NONE, offsetof(InternalRecord, integer), 0, 0, 0x2},
 	    {TK_OPTION_DOUBLE, "-double", "double", "Double", "3.14159",
 		TCL_INDEX_NONE, offsetof(InternalRecord, doubleValue), 0, 0, 0x4},
 	    {TK_OPTION_STRING, "-string", "string", "String", "foo",
@@ -886,20 +895,20 @@
 		TCL_INDEX_NONE, offsetof(InternalRecord, bitmap),
 		TK_CONFIG_NULL_OK, 0, 0x80},
 	    {TK_OPTION_BORDER, "-border", "border", "Border", "blue",
 		TCL_INDEX_NONE, offsetof(InternalRecord, border),
 		TK_CONFIG_NULL_OK, "white", 0x100},
-	    {TK_OPTION_RELIEF, "-relief", "relief", "Relief", "raised",
+	    {TK_OPTION_RELIEF, "-relief", "relief", "Relief", NULL,
 		TCL_INDEX_NONE, offsetof(InternalRecord, relief),
 		TK_CONFIG_NULL_OK, 0, 0x200},
 	    {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", "xterm",
 		TCL_INDEX_NONE, offsetof(InternalRecord, cursor),
 		TK_CONFIG_NULL_OK, 0, 0x400},
 	    {TK_OPTION_JUSTIFY, "-justify", NULL, NULL, "left",
 		TCL_INDEX_NONE, offsetof(InternalRecord, justify),
 		TK_CONFIG_NULL_OK, 0, 0x800},
-	    {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", NULL,
+	    {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "center",
 		TCL_INDEX_NONE, offsetof(InternalRecord, anchor),
 		TK_CONFIG_NULL_OK, 0, 0x1000},
 	    {TK_OPTION_PIXELS, "-pixel", "pixel", "Pixel", "1",
 		TCL_INDEX_NONE, offsetof(InternalRecord, pixels),
 		TK_CONFIG_NULL_OK, 0, 0x2000},
@@ -938,11 +947,11 @@
 	recordPtr->bitmap = None;
 	recordPtr->border = NULL;
 	recordPtr->relief = TK_RELIEF_FLAT;
 	recordPtr->cursor = NULL;
 	recordPtr->justify = TK_JUSTIFY_LEFT;
-	recordPtr->anchor = TK_ANCHOR_N;
+	recordPtr->anchor = TK_ANCHOR_CENTER;
 	recordPtr->pixels = 0;
 	recordPtr->mm = 0.0;
 	recordPtr->tkwin = NULL;
 	recordPtr->custom = NULL;
 	result = Tk_InitOptions(interp, recordPtr, optionTable,
@@ -1013,11 +1022,11 @@
 		    recordPtr->header.optionTable, objc - 3, objv + 3,
 		    (Tk_Window) NULL, NULL, NULL);
 	    if (result == TCL_OK) {
 		recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp,
 			Tcl_GetString(objv[2]), TrivialConfigObjCmd,
-			(ClientData) recordPtr, TrivialCmdDeletedProc);
+			recordPtr, TrivialCmdDeletedProc);
 	    } else {
 		Tk_FreeConfigOptions(recordPtr,
 			recordPtr->header.optionTable, (Tk_Window) NULL);
 	    }
 	}
@@ -1931,15 +1940,11 @@
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument strings. */
 {
     char buffer[256];
     Tcl_WideInt wideInt;
-#ifdef _WIN32
-    __int64 longLongInt;
-#else
     long long longLongInt;
-#endif
     (void)dummy;
 
     if (objc != 2) {
 	Tcl_WrongNumArgs(interp, 1, objv, "wideint");
 	return TCL_ERROR;
@@ -1954,11 +1959,11 @@
      * which still woudn't tell if the assumed size is correct: We want this
      * test-case to fail if the 64-bit value is printed as truncated to 32-bit.
      */
     sprintf(buffer, "%s%s%s%s%s%s%s%s%" TCL_LL_MODIFIER "d %"
 	    TCL_LL_MODIFIER "u", "", "", "", "", "", "", "", "",
-	    (Tcl_WideInt)longLongInt, (Tcl_WideUInt)longLongInt);
+	    longLongInt, (unsigned long long)longLongInt);
     Tcl_AppendResult(interp, buffer, NULL);
     return TCL_OK;
 }
 
 #if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__))

Index: generic/tkText.c
==================================================================
--- generic/tkText.c
+++ generic/tkText.c
@@ -4,13 +4,13 @@
  *	This module provides a big chunk of the implementation of multi-line
  *	editable text widgets for Tk. Among other things, it provides the Tcl
  *	command interfaces to text widgets. The B-tree representation of text
  *	and its actual display are implemented elsewhere.
  *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1996 Sun Microsystems, Inc.
- * Copyright (c) 1999 by Scriptics Corporation.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1996 Sun Microsystems, Inc.
+ * Copyright © 1999 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -40,37 +40,27 @@
  * commonly used functions. Must be > 0.
  */
 
 #define PIXEL_CLIENTS 5
 
-/*
- * The 'TkTextState' enum in tkText.h is used to define a type for the -state
- * option of the Text widget. These values are used as indices into the string
- * table below.
- */
-
-static const char *const stateStrings[] = {
-    "disabled", "normal", NULL
-};
-
 /*
  * The 'TkWrapMode' enum in tkText.h is used to define a type for the -wrap
  * option of the Text widget. These values are used as indices into the string
  * table below.
  */
 
-static const char *const wrapStrings[] = {
+const char *const tkTextWrapStrings[] = {
     "char", "none", "word", NULL
 };
 
 /*
  * The 'TkTextTabStyle' enum in tkText.h is used to define a type for the
  * -tabstyle option of the Text widget. These values are used as indices into
  * the string table below.
  */
 
-static const char *const tabStyleStrings[] = {
+const char *const tkTextTabStyleStrings[] = {
     "tabular", "wordprocessor", NULL
 };
 
 /*
  * The 'TkTextInsertUnfocussed' enum in tkText.h is used to define a type for
@@ -177,21 +167,21 @@
 	TCL_INDEX_NONE, offsetof(TkText, insertBorder),
 	0, 0, 0},
     {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth",
 	"BorderWidth", DEF_TEXT_INSERT_BD_COLOR, TCL_INDEX_NONE,
 	offsetof(TkText, insertBorderWidth), 0,
-	(ClientData) DEF_TEXT_INSERT_BD_MONO, 0},
+	DEF_TEXT_INSERT_BD_MONO, 0},
     {TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime",
 	DEF_TEXT_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(TkText, insertOffTime),
 	0, 0, 0},
     {TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime",
 	DEF_TEXT_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(TkText, insertOnTime),
 	0, 0, 0},
     {TK_OPTION_STRING_TABLE,
 	"-insertunfocussed", "insertUnfocussed", "InsertUnfocussed",
 	DEF_TEXT_INSERT_UNFOCUSSED, TCL_INDEX_NONE, offsetof(TkText, insertUnfocussed),
-	0, insertUnfocussedStrings, 0},
+	TK_OPTION_ENUM_VAR, insertUnfocussedStrings, 0},
     {TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
 	DEF_TEXT_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(TkText, insertWidth),
 	0, 0, 0},
     {TK_OPTION_INT, "-maxundo", "maxUndo", "MaxUndo",
 	DEF_TEXT_MAX_UNDO, TCL_INDEX_NONE, offsetof(TkText, maxUndo),
@@ -228,17 +218,17 @@
     {TK_OPTION_CUSTOM, "-startline", NULL, NULL,
 	 NULL, TCL_INDEX_NONE, offsetof(TkText, start), TK_OPTION_NULL_OK,
 	 &lineOption, TK_TEXT_LINE_RANGE},
     {TK_OPTION_STRING_TABLE, "-state", "state", "State",
 	DEF_TEXT_STATE, TCL_INDEX_NONE, offsetof(TkText, state),
-	0, stateStrings, 0},
+	0, &tkStateStrings[1], 0},
     {TK_OPTION_STRING, "-tabs", "tabs", "Tabs",
 	DEF_TEXT_TABS, offsetof(TkText, tabOptionPtr), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK, 0, TK_TEXT_LINE_GEOMETRY},
     {TK_OPTION_STRING_TABLE, "-tabstyle", "tabStyle", "TabStyle",
 	DEF_TEXT_TABSTYLE, TCL_INDEX_NONE, offsetof(TkText, tabStyle),
-	0, tabStyleStrings, TK_TEXT_LINE_GEOMETRY},
+	0, tkTextTabStyleStrings, TK_TEXT_LINE_GEOMETRY},
     {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
 	DEF_TEXT_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(TkText, takeFocus),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_BOOLEAN, "-undo", "undo", "Undo",
 	DEF_TEXT_UNDO, TCL_INDEX_NONE, offsetof(TkText, undo),
@@ -246,11 +236,11 @@
     {TK_OPTION_INT, "-width", "width", "Width",
 	DEF_TEXT_WIDTH, TCL_INDEX_NONE, offsetof(TkText, width), 0, 0,
 	TK_TEXT_LINE_GEOMETRY},
     {TK_OPTION_STRING_TABLE, "-wrap", "wrap", "Wrap",
 	DEF_TEXT_WRAP, TCL_INDEX_NONE, offsetof(TkText, wrapMode),
-	0, wrapStrings, TK_TEXT_LINE_GEOMETRY},
+	TK_OPTION_ENUM_VAR, tkTextWrapStrings, TK_TEXT_LINE_GEOMETRY},
     {TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
 	DEF_TEXT_XSCROLL_COMMAND, TCL_INDEX_NONE, offsetof(TkText, xScrollCmd),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
 	DEF_TEXT_YSCROLL_COMMAND, TCL_INDEX_NONE, offsetof(TkText, yScrollCmd),
@@ -863,11 +853,11 @@
 	}
 
 	for (i = 2; i < objc-2; i++) {
 	    int value;
 	    TkSizeT length;
-	    const char *option = TkGetStringFromObj(objv[i], &length);
+	    const char *option = Tcl_GetStringFromObj(objv[i], &length);
 	    char c;
 
 	    if (length < 2 || option[0] != '-') {
 		goto badOption;
 	    }
@@ -1273,16 +1263,16 @@
 	 * -displaychars (or any unique prefix).
 	 */
 
 	i = 2;
 	if (objc > 3) {
-	    name = TkGetStringFromObj(objv[i], &length);
+	    name = Tcl_GetStringFromObj(objv[i], &length);
 	    if (length > 1 && name[0] == '-') {
 		if (strncmp("-displaychars", name, length) == 0) {
 		    i++;
 		    visible = 1;
-		    name = TkGetStringFromObj(objv[i], &length);
+		    name = Tcl_GetStringFromObj(objv[i], &length);
 		}
 		if ((i < objc-1) && (length == 2) && !strcmp("--", name)) {
 		    i++;
 		}
 	    }
@@ -1541,11 +1531,11 @@
 		    Tcl_DecrRefCount(textPtr->afterSyncCmd);
 		}
 		textPtr->afterSyncCmd = cmd;
 	    } else {
 		textPtr->afterSyncCmd = cmd;
-		Tcl_DoWhenIdle(TkTextRunAfterSyncCmd, (ClientData) textPtr);
+		Tcl_DoWhenIdle(TkTextRunAfterSyncCmd, textPtr);
 	    }
 	    break;
 	} else if (objc != 2) {
 	    Tcl_WrongNumArgs(interp, 2, objv, "?-command command?");
 	    result = TCL_ERROR;
@@ -2271,11 +2261,11 @@
     } else {
 	textPtr->selTagPtr->selFgColor = textPtr->selFgColorPtr;
     }
     textPtr->selTagPtr->affectsDisplay = 0;
     textPtr->selTagPtr->affectsDisplayGeometry = 0;
-    if ((textPtr->selTagPtr->elideString != NULL)
+    if ((textPtr->selTagPtr->elide >= 0)
 	    || (textPtr->selTagPtr->tkfont != NULL)
 	    || (textPtr->selTagPtr->justifyString != NULL)
 	    || (textPtr->selTagPtr->lMargin1String != NULL)
 	    || (textPtr->selTagPtr->lMargin2String != NULL)
 	    || (textPtr->selTagPtr->offsetString != NULL)
@@ -2282,11 +2272,15 @@
 	    || (textPtr->selTagPtr->rMarginString != NULL)
 	    || (textPtr->selTagPtr->spacing1String != NULL)
 	    || (textPtr->selTagPtr->spacing2String != NULL)
 	    || (textPtr->selTagPtr->spacing3String != NULL)
 	    || (textPtr->selTagPtr->tabStringPtr != NULL)
-	    || (textPtr->selTagPtr->wrapMode != TEXT_WRAPMODE_NULL)) {
+	    || (textPtr->selTagPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR)
+	    || (textPtr->selTagPtr->tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR)
+	    || (textPtr->selTagPtr->wrapMode == TEXT_WRAPMODE_CHAR)
+	    || (textPtr->selTagPtr->wrapMode == TEXT_WRAPMODE_NONE)
+	    || (textPtr->selTagPtr->wrapMode == TEXT_WRAPMODE_WORD)) {
 	textPtr->selTagPtr->affectsDisplay = 1;
 	textPtr->selTagPtr->affectsDisplayGeometry = 1;
     }
     if ((textPtr->selTagPtr->border != NULL)
 	    || (textPtr->selTagPtr->selBorder != NULL)
@@ -2293,13 +2287,13 @@
 	    || (textPtr->selTagPtr->reliefString != NULL)
 	    || (textPtr->selTagPtr->bgStipple != None)
 	    || (textPtr->selTagPtr->fgColor != NULL)
 	    || (textPtr->selTagPtr->selFgColor != NULL)
 	    || (textPtr->selTagPtr->fgStipple != None)
-	    || (textPtr->selTagPtr->overstrikeString != NULL)
+	    || (textPtr->selTagPtr->overstrike >= 0)
 	    || (textPtr->selTagPtr->overstrikeColor != NULL)
-	    || (textPtr->selTagPtr->underlineString != NULL)
+	    || (textPtr->selTagPtr->underline >= 0)
 	    || (textPtr->selTagPtr->underlineColor != NULL)
 	    || (textPtr->selTagPtr->lMarginColor != NULL)
 	    || (textPtr->selTagPtr->rMarginColor != NULL)) {
 	textPtr->selTagPtr->affectsDisplay = 1;
     }
@@ -2634,11 +2628,11 @@
     TkSizeT length;
     TkText *tPtr;
     int *lineAndByteIndex;
     int resetViewCount;
     int pixels[2*PIXEL_CLIENTS];
-    const char *string = TkGetStringFromObj(stringPtr, &length);
+    const char *string = Tcl_GetStringFromObj(stringPtr, &length);
 
     if (sharedTextPtr == NULL) {
 	sharedTextPtr = textPtr->sharedTextPtr;
     }
 
@@ -2960,11 +2954,12 @@
 				 * shared text data structure. */
     Tcl_Obj *objPtr)		/* Arguments of a command to be handled by the
 				 * shared text data structure. */
 {
     TkSharedText *sharedPtr = (TkSharedText *)clientData;
-    int res, objc;
+    int res;
+    TkSizeT objc;
     Tcl_Obj **objv;
     TkText *textPtr;
 
     res = Tcl_ListObjGetElements(interp, objPtr, &objc, &objv);
     if (res != TCL_OK) {
@@ -3125,11 +3120,11 @@
     int *lineAndByteIndex;
     int resetViewCount;
     int pixels[2*PIXEL_CLIENTS];
     Tcl_HashSearch search;
     Tcl_HashEntry *hPtr;
-    int i;
+    TkSizeT i;
 
     if (sharedTextPtr == NULL) {
 	sharedTextPtr = textPtr->sharedTextPtr;
     }
 
@@ -3171,11 +3166,11 @@
 
     line1 = TkBTreeLinesTo(textPtr, index1.linePtr);
     line2 = TkBTreeLinesTo(textPtr, index2.linePtr);
     if (line2 == TkBTreeNumLines(sharedTextPtr->tree, textPtr)) {
 	TkTextTag **arrayPtr;
-	int arraySize;
+	TkSizeT arraySize;
 	TkTextIndex oldIndex2;
 
 	oldIndex2 = index2;
 	TkTextIndexBackChars(NULL, &oldIndex2, 1, &index2, COUNT_INDICES);
 	line2--;
@@ -3344,33 +3339,25 @@
 		    TkTextMakeByteIndex(sharedTextPtr->tree, textPtr, line,
 			    byteIndex, &indexTmp);
 		    TkTextSetYView(tPtr, &indexTmp, 0);
 		}
 	    } else {
-		TkTextMakeByteIndex(sharedTextPtr->tree, tPtr, line,
+		TkTextMakeByteIndex(sharedTextPtr->tree, NULL, line,
 			byteIndex, &indexTmp);
 		/*
 		 * line may be before -startline of tPtr and must be
 		 * clamped to -startline before providing it to
 		 * TkTextSetYView otherwise lines before -startline
 		 * would be displayed.
 		 * There is no need to worry about -endline however,
 		 * because the view will only be reset if the deletion
-		 * involves the TOP line of the screen
+		 * involves the TOP line of the screen. That said,
+		 * the following call adjusts to both.
 		 */
 
-		if (tPtr->start != NULL) {
-		    int start;
-		    TkTextIndex indexStart;
-
-		    start = TkBTreeLinesTo(NULL, tPtr->start);
-		    TkTextMakeByteIndex(sharedTextPtr->tree, NULL, start,
-			    0, &indexStart);
-		    if (TkTextIndexCmp(&indexTmp, &indexStart) < 0) {
-			indexTmp = indexStart;
-		    }
-		}
+		TkTextIndexAdjustToStartEnd(tPtr, &indexTmp, 0);
+
 		TkTextSetYView(tPtr, &indexTmp, 0);
 	    }
 	}
 	resetViewCount += 2;
     }
@@ -3741,16 +3728,16 @@
 		viewUpdate);
 
 	if (objc > (j+1)) {
 	    Tcl_Obj **tagNamePtrs;
 	    TkTextTag **oldTagArrayPtr;
-	    int numTags;
+	    TkSizeT numTags;
 
 	    TkTextIndexForwBytes(textPtr, &index1, length, &index2);
 	    oldTagArrayPtr = TkBTreeGetTags(&index1, NULL, &numTags);
 	    if (oldTagArrayPtr != NULL) {
-		int i;
+		TkSizeT i;
 
 		for (i = 0; i < numTags; i++) {
 		    TkBTreeTag(&index1, &index2, oldTagArrayPtr[i], 0);
 		}
 		ckfree(oldTagArrayPtr);
@@ -3757,11 +3744,11 @@
 	    }
 	    if (Tcl_ListObjGetElements(interp, objv[j+1], &numTags,
 		    &tagNamePtrs) != TCL_OK) {
 		return TCL_ERROR;
 	    } else {
-		int i;
+		TkSizeT i;
 
 		for (i = 0; i < numTags; i++) {
 		    const char *strTag = Tcl_GetString(tagNamePtrs[i]);
 
 		    TkBTreeTag(&index1, &index2,
@@ -3988,11 +3975,11 @@
  *
  * TextSearchGetLineIndex --
  *
  *	Extract a row, text offset index position from an objPtr
  *
- *	This means we ignore any embedded windows/images and elidden text
+ *	This means we ignore any embedded windows/images and elided text
  *	(unless we are searching that).
  *
  * Results:
  *	Standard Tcl error code (with a message in the interpreter on error
  *	conditions).
@@ -4060,11 +4047,11 @@
  * TextSearchIndexInLine --
  *
  *	Find textual index of 'byteIndex' in the searchable characters of
  *	'linePtr'.
  *
- *	This means we ignore any embedded windows/images and elidden text
+ *	This means we ignore any embedded windows/images and elided text
  *	(unless we are searching that).
  *
  * Results:
  *	The returned index is a utf-8 char* byte index for exact searches, and
  *	a Unicode character index for regexp searches.
@@ -4293,11 +4280,11 @@
 	}
     }
 
     /*
      * Calculate the character count, which may need augmenting if there are
-     * embedded windows or elidden text.
+     * embedded windows or elided text.
      */
 
     if (searchSpecPtr->exact) {
 	const char *startOfLine = Tcl_GetString(theLine);
 
@@ -4503,11 +4490,11 @@
     Tcl_Interp *interp,		/* Used for error reporting. */
     TkText *textPtr,		/* Information about the text widget. */
     Tcl_Obj *stringPtr)		/* Description of the tab stops. See the text
 				 * manual entry for details. */
 {
-    int objc, i, count;
+    TkSizeT objc, i, count;
     Tcl_Obj **objv;
     TkTextTabArray *tabArrayPtr;
     TkTextTab *tabPtr;
     int ch;
     double prevStop, lastStop;
@@ -4757,11 +4744,11 @@
 	const char *str;
 
 	if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index2) != TCL_OK) {
 	    return TCL_ERROR;
 	}
-	str = TkGetStringFromObj(objv[arg], &length);
+	str = Tcl_GetStringFromObj(objv[arg], &length);
 	if (strncmp(str, "end", length) == 0) {
 	    atEnd = 1;
 	}
     }
     if (TkTextIndexCmp(&index1, &index2) >= 0) {
@@ -5611,17 +5598,17 @@
 	    ckfree((char *) textPtr);
 	}
 	return;
     }
 
-    Tcl_Preserve((ClientData) textPtr->interp);
+    Tcl_Preserve(textPtr->interp);
     code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL);
     if (code == TCL_ERROR) {
 	Tcl_AddErrorInfo(textPtr->interp, "\n    (text sync)");
 	Tcl_BackgroundException(textPtr->interp, TCL_ERROR);
     }
-    Tcl_Release((ClientData) textPtr->interp);
+    Tcl_Release(textPtr->interp);
     Tcl_DecrRefCount(textPtr->afterSyncCmd);
     textPtr->afterSyncCmd = NULL;
 }
 
 /*
@@ -5826,11 +5813,11 @@
 	 * We only need to set the matchLength once for exact searches, and we
 	 * do it here. It is also used below as the actual pattern length, so
 	 * it has dual purpose.
 	 */
 
-	pattern = TkGetStringFromObj(patObj, &matchLength);
+	pattern = Tcl_GetStringFromObj(patObj, &matchLength);
 	nl = strchr(pattern, '\n');
 
 	/*
 	 * If there is no newline, or it is the very end of the string, then
 	 * we don't need any special treatment, since single-line matching

Index: generic/tkText.h
==================================================================
--- generic/tkText.h
+++ generic/tkText.h
@@ -280,13 +280,15 @@
  * widget. These structures are kept in sharedTextPtr->tagTable and referred
  * to in other structures.
  */
 
 typedef enum {
-    TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD,
-    TEXT_WRAPMODE_NULL
+    TEXT_WRAPMODE_NULL = -1,
+    TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD
 } TkWrapMode;
+
+MODULE_SCOPE const char *const tkTextWrapStrings[];
 
 typedef struct TkTextTag {
     const char *name;		/* Name of this tag. This field is actually a
 				 * pointer to the key from the entry in
 				 * sharedTextPtr->tagTable, so it needn't be
@@ -333,11 +335,11 @@
 				 * foreground stuff. None means no value
 				 * specified here.*/
     char *justifyString;	/* -justify option string (malloc-ed). NULL
 				 * means option not specified. */
     Tk_Justify justify;		/* How to justify text: TK_JUSTIFY_LEFT,
-				 * TK_JUSTIFY_RIGHT, or TK_JUSTIFY_CENTER.
+				 * TK_JUSTIFY_RIGHT, TK_JUSTIFY_CENTER, or TK_JUSTIFY_NULL.
 				 * Only valid if justifyString is non-NULL. */
     char *lMargin1String;	/* -lmargin1 option string (malloc-ed). NULL
 				 * means option not specified. */
     int lMargin1;		/* Left margin for first display line of each
 				 * text line, in pixels. Only valid if
@@ -354,15 +356,14 @@
 				 * means option not specified. */
     int offset;			/* Vertical offset of text's baseline from
 				 * baseline of line. Used for superscripts and
 				 * subscripts. Only valid if offsetString is
 				 * non-NULL. */
-    char *overstrikeString;	/* -overstrike option string (malloc-ed). NULL
+    Tcl_Obj *overstrikePtr;	/* -overstrike option. NULL
 				 * means option not specified. */
-    int overstrike;		/* Non-zero means draw horizontal line through
-				 * middle of text. Only valid if
-				 * overstrikeString is non-NULL. */
+    int overstrike;		/* > 0 means draw horizontal line through
+				 * middle of text. -1 means not specified. */
     XColor *overstrikeColor;    /* Color for the overstrike. NULL means same
                                  * color as foreground. */
     char *rMarginString;	/* -rmargin option string (malloc-ed). NULL
 				 * means option not specified. */
     int rMargin;		/* Right margin for text, in pixels. Only
@@ -391,28 +392,27 @@
     Tcl_Obj *tabStringPtr;	/* -tabs option string. NULL means option not
 				 * specified. */
     struct TkTextTabArray *tabArrayPtr;
 				/* Info about tabs for tag (malloc-ed) or
 				 * NULL. Corresponds to tabString. */
-    int tabStyle;		/* One of TABULAR or WORDPROCESSOR or NONE (if
-				 * not specified). */
-    char *underlineString;	/* -underline option string (malloc-ed). NULL
+    int tabStyle;		/* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR
+				 * or TK_TEXT_TABSTYLE_NULL (if not specified). */
+    Tcl_Obj *underlinePtr;	/* -underline option. NULL
 				 * means option not specified. */
-    int underline;		/* Non-zero means draw underline underneath
-				 * text. Only valid if underlineString is
-				 * non-NULL. */
+    int underline;		/* > 0 means draw underline underneath
+				 * text. -1 means not specified. */
     XColor *underlineColor;     /* Color for the underline. NULL means same
                                  * color as foreground. */
     TkWrapMode wrapMode;	/* How to handle wrap-around for this tag.
 				 * Must be TEXT_WRAPMODE_CHAR,
 				 * TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, or
 				 * TEXT_WRAPMODE_NULL to use wrapmode for
 				 * whole widget. */
-    char *elideString;		/* -elide option string (malloc-ed). NULL
+    Tcl_Obj *elidePtr;	/* -elide option. NULL
 				 * means option not specified. */
-    int elide;			/* Non-zero means that data under this tag
-				 * should not be displayed. */
+    int elide;			/* > 0 means that data under this tag
+				 * should not be displayed. -1 means not specified. */
     int affectsDisplay;		/* Non-zero means that this tag affects the
 				 * way information is displayed on the screen
 				 * (so need to redisplay if tag changes). */
     Tk_OptionTable optionTable;	/* Token representing the configuration
 				 * specifications. */
@@ -464,18 +464,20 @@
 
 typedef enum {LEFT, RIGHT, CENTER, NUMERIC} TkTextTabAlign;
 
 /*
  * The following are the supported styles of tabbing, used for the -tabstyle
- * option of the text widget. The last element is only used for tag options.
+ * option of the text widget. The first element is only used for tag options.
  */
 
 typedef enum {
+    TK_TEXT_TABSTYLE_NULL = -1,
     TK_TEXT_TABSTYLE_TABULAR,
-    TK_TEXT_TABSTYLE_WORDPROCESSOR,
-    TK_TEXT_TABSTYLE_NONE
+    TK_TEXT_TABSTYLE_WORDPROCESSOR
 } TkTextTabStyle;
+
+MODULE_SCOPE const char *const tkTextTabStyleStrings[];
 
 typedef struct TkTextTab {
     int location;		/* Offset in pixels of this tab stop from the
 				 * left margin (lmargin2) of the text. */
     TkTextTabAlign alignment;	/* Where the tab stop appears relative to the
@@ -693,11 +695,11 @@
     Tcl_Obj *tabOptionPtr; 	/* Value of -tabs option string. */
     TkTextTabArray *tabArrayPtr;
 				/* Information about tab stops (malloc'ed).
 				 * NULL means perform default tabbing
 				 * behavior. */
-    int tabStyle;		/* One of TABULAR or WORDPROCESSOR. */
+    int tabStyle;		/* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR. */
 
     /*
      * Additional information used for displaying:
      */
 
@@ -1022,11 +1024,11 @@
 			    const TkText *textPtr, int line);
 MODULE_SCOPE TkTextLine *TkBTreeFindPixelLine(TkTextBTree tree,
 			    const TkText *textPtr, int pixels,
 			    int *pixelOffset);
 MODULE_SCOPE TkTextTag **TkBTreeGetTags(const TkTextIndex *indexPtr,
-			    const TkText *textPtr, int *numTagsPtr);
+			    const TkText *textPtr, TkSizeT *numTagsPtr);
 MODULE_SCOPE void	TkBTreeInsertChars(TkTextBTree tree,
 			    TkTextIndex *indexPtr, const char *string);
 MODULE_SCOPE int	TkBTreeLinesTo(const TkText *textPtr,
 			    TkTextLine *linePtr);
 MODULE_SCOPE int	TkBTreePixelsTo(const TkText *textPtr,
@@ -1168,14 +1170,16 @@
 MODULE_SCOPE int	TkTextYviewCmd(TkText *textPtr, Tcl_Interp *interp,
 			    int objc, Tcl_Obj *const objv[]);
 MODULE_SCOPE void	TkTextWinFreeClient(Tcl_HashEntry *hPtr,
 			    TkTextEmbWindowClient *client);
 MODULE_SCOPE void       TkTextRunAfterSyncCmd(ClientData clientData);
+MODULE_SCOPE int        TkTextIndexAdjustToStartEnd(TkText *textPtr,
+			    TkTextIndex *indexPtr, int err);
 #endif /* _TKTEXT */
 
 /*
  * Local Variables:
  * mode: c
  * c-basic-offset: 4
  * fill-column: 78
  * End:
  */

Index: generic/tkTextBTree.c
==================================================================
--- generic/tkTextBTree.c
+++ generic/tkTextBTree.c
@@ -3,12 +3,12 @@
  *
  *	This file contains code that manages the B-tree representation of text
  *	for Tk's text widget and implements character and toggle segment
  *	types.
  *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1995 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -1725,10 +1725,30 @@
 	if (linePtr == NULL) {
 	    Tcl_Panic("TkBTreeFindPixelLine ran out of lines");
 	}
 	pixels -= linePtr->pixels[2 * pixelReference];
     }
+
+    /*
+     * Check for any start/end offset for this text widget.
+     */
+
+    if (textPtr->start != NULL) {
+	int lineBoundary = TkBTreeLinesTo(NULL, textPtr->start);
+
+	if (TkBTreeLinesTo(NULL, linePtr) < lineBoundary) {
+	    linePtr = TkBTreeFindLine(tree, NULL, lineBoundary);
+	}
+    }
+    if (textPtr->end != NULL) {
+	int lineBoundary = TkBTreeLinesTo(NULL, textPtr->end);
+
+	if (TkBTreeLinesTo(NULL, linePtr) > lineBoundary) {
+	    linePtr = TkBTreeFindLine(tree, NULL, lineBoundary);
+	}
+    }
+
     if (pixelOffset != NULL && linePtr != NULL) {
 	*pixelOffset = pixels;
     }
     return linePtr;
 }
@@ -1876,11 +1896,11 @@
  *	Given a pointer to a line in a B-tree, return the numerical pixel
  *	index of the top of that line (i.e. the result does not include the
  *	height of the given line).
  *
  *	Since the last line of text (the artificial one) has zero height by
- *	defintion, calling this with the last line will return the total
+ *	definition, calling this with the last line will return the total
  *	number of pixels in the widget.
  *
  * Results:
  *	The result is the pixel height of the top of the given line.
  *
@@ -3339,11 +3359,11 @@
     const TkTextIndex *indexPtr,/* Indicates a particular position in the
 				 * B-tree. */
     const TkText *textPtr,	/* If non-NULL, then only return tags for this
 				 * text widget (when there are peer
 				 * widgets). */
-    int *numTagsPtr)		/* Store number of tags found at this
+    TkSizeT *numTagsPtr)		/* Store number of tags found at this
 				 * location. */
 {
     Node *nodePtr;
     TkTextLine *siblingLinePtr;
     TkTextSegment *segPtr;
@@ -3530,11 +3550,11 @@
     segPtr = linePtr->segPtr;
     while ((index + (int)segPtr->size) <= indexPtr->byteIndex) {
 	if ((segPtr->typePtr == &tkTextToggleOnType)
 		|| (segPtr->typePtr == &tkTextToggleOffType)) {
 	    tagPtr = segPtr->body.toggle.tagPtr;
-	    if (tagPtr->elideString != NULL) {
+	    if (tagPtr->elide >= 0) {
 		infoPtr->tagPtrs[tagPtr->priority] = tagPtr;
 		infoPtr->tagCnts[tagPtr->priority]++;
 	    }
 	}
 
@@ -3570,11 +3590,11 @@
 	for (segPtr = siblingLinePtr->segPtr; segPtr != NULL;
 		segPtr = segPtr->nextPtr) {
 	    if ((segPtr->typePtr == &tkTextToggleOnType)
 		    || (segPtr->typePtr == &tkTextToggleOffType)) {
 		tagPtr = segPtr->body.toggle.tagPtr;
-		if (tagPtr->elideString != NULL) {
+		if (tagPtr->elide >= 0) {
 		    infoPtr->tagPtrs[tagPtr->priority] = tagPtr;
 		    infoPtr->tagCnts[tagPtr->priority]++;
 		}
 	    }
 	}
@@ -3594,11 +3614,11 @@
 		siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) {
 	    for (summaryPtr = siblingPtr->summaryPtr; summaryPtr != NULL;
 		    summaryPtr = summaryPtr->nextPtr) {
 		if (summaryPtr->toggleCount & 1) {
 		    tagPtr = summaryPtr->tagPtr;
-		    if (tagPtr->elideString != NULL) {
+		    if (tagPtr->elide >= 0) {
 			infoPtr->tagPtrs[tagPtr->priority] = tagPtr;
 			infoPtr->tagCnts[tagPtr->priority] +=
 				summaryPtr->toggleCount;
 		    }
 		}
@@ -3612,11 +3632,11 @@
      */
 
     infoPtr->elidePriority = -1;
     for (i = infoPtr->numTags-1; i >=0; i--) {
 	if (infoPtr->tagCnts[i] & 1) {
-	    infoPtr->elide = infoPtr->tagPtrs[i]->elide;
+	    infoPtr->elide = infoPtr->tagPtrs[i]->elide > 0;
 
 	    /*
 	     * Note: i == infoPtr->tagPtrs[i]->priority
 	     */
 

Index: generic/tkTextDisp.c
==================================================================
--- generic/tkTextDisp.c
+++ generic/tkTextDisp.c
@@ -4,12 +4,12 @@
  *	This module provides facilities to display text widgets. It is the
  *	only place where information is kept about the screen layout of text
  *	widgets. (Well, strictly, each TkTextLine and B-tree node caches its
  *	last observed pixel height, but that information originates here).
  *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -20,16 +20,13 @@
 #include "tkWinInt.h"
 #elif defined(__CYGWIN__)
 #include "tkUnixInt.h"
 #elif defined(MAC_OSX_TK)
 #include "tkMacOSXInt.h"
-#define OK_TO_LOG (!TkpWillDrawWidget(textPtr->tkwin))
 #endif
 
-#if !defined(MAC_OSX_TK)
-#define OK_TO_LOG 1
-#endif
+#define OK_TO_LOG (!TkpWillDrawWidget(textPtr->tkwin))
 
 /*
  * "Calculations of line pixel heights and the size of the vertical
  * scrollbar."
  *
@@ -151,11 +148,11 @@
     int spacing1;		/* Spacing above first dline in text line. */
     int spacing2;		/* Spacing between lines of dline. */
     int spacing3;		/* Spacing below last dline in text line. */
     TkTextTabArray *tabArrayPtr;/* Locations and types of tab stops (may be
 				 * NULL). */
-    int tabStyle;		/* One of TABULAR or WORDPROCESSOR. */
+    int tabStyle;		/* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR. */
     int underline;		/* Non-zero means draw underline underneath
 				 * text. */
     XColor *underlineColor;	/* Foreground color for underline underneath
                                  * text. */
     int elide;			/* Zero means draw text, otherwise not. */
@@ -438,11 +435,11 @@
 /*
  * In TkTextDispChunk structures for character segments, the clientData field
  * points to one of the following structures:
  */
 
-#if !defined(TK_LAYOUT_WITH_BASE_CHUNKS)
+#ifndef TK_LAYOUT_WITH_BASE_CHUNKS
 
 typedef struct CharInfo {
     int numBytes;		/* Number of bytes to display. */
     char chars[TKFLEXARRAY];		/* UTF characters to display.
 				 * Allocated as large as necessary. THIS MUST BE THE LAST
@@ -775,11 +772,12 @@
     TkTextTag **tagPtrs;
     TkTextTag *tagPtr;
     StyleValues styleValues;
     TextStyle *stylePtr;
     Tcl_HashEntry *hPtr;
-    int numTags, isNew, i;
+    TkSizeT numTags, i;
+    int isNew;
     int isSelected;
     XGCValues gcValues;
     unsigned long mask;
     /*
      * The variables below keep track of the highest-priority specification
@@ -923,13 +921,13 @@
 	if ((tagPtr->offsetString != NULL)
 		&& (tagPtr->priority > offsetPrio)) {
 	    styleValues.offset = tagPtr->offset;
 	    offsetPrio = tagPtr->priority;
 	}
-	if ((tagPtr->overstrikeString != NULL)
+	if ((tagPtr->overstrike >= 0)
 		&& (tagPtr->priority > overstrikePrio)) {
-	    styleValues.overstrike = tagPtr->overstrike;
+	    styleValues.overstrike = tagPtr->overstrike > 0;
 	    overstrikePrio = tagPtr->priority;
             if (tagPtr->overstrikeColor != NULL) {
                  styleValues.overstrikeColor = tagPtr->overstrikeColor;
             } else if (fgColor != NULL) {
                  styleValues.overstrikeColor = fgColor;
@@ -963,31 +961,34 @@
 	if ((tagPtr->tabStringPtr != NULL)
 		&& (tagPtr->priority > tabPrio)) {
 	    styleValues.tabArrayPtr = tagPtr->tabArrayPtr;
 	    tabPrio = tagPtr->priority;
 	}
-	if ((tagPtr->tabStyle != TK_TEXT_TABSTYLE_NONE)
+	if (((tagPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR)
+		|| (tagPtr->tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR))
 		&& (tagPtr->priority > tabStylePrio)) {
 	    styleValues.tabStyle = tagPtr->tabStyle;
 	    tabStylePrio = tagPtr->priority;
 	}
-	if ((tagPtr->underlineString != NULL)
+	if ((tagPtr->underline >= 0)
 		&& (tagPtr->priority > underlinePrio)) {
-	    styleValues.underline = tagPtr->underline;
+	    styleValues.underline = tagPtr->underline > 0;
 	    underlinePrio = tagPtr->priority;
             if (tagPtr->underlineColor != NULL) {
                  styleValues.underlineColor = tagPtr->underlineColor;
             } else if (fgColor != NULL) {
                  styleValues.underlineColor = fgColor;
             }
 	}
-	if ((tagPtr->elideString != NULL)
+	if ((tagPtr->elide >= 0)
 		&& (tagPtr->priority > elidePrio)) {
-	    styleValues.elide = tagPtr->elide;
+	    styleValues.elide = tagPtr->elide > 0;
 	    elidePrio = tagPtr->priority;
 	}
-	if ((tagPtr->wrapMode != TEXT_WRAPMODE_NULL)
+	if (((tagPtr->wrapMode == TEXT_WRAPMODE_CHAR)
+		|| (tagPtr->wrapMode == TEXT_WRAPMODE_NONE)
+		|| (tagPtr->wrapMode == TEXT_WRAPMODE_WORD))
 		&& (tagPtr->priority > wrapPrio)) {
 	    styleValues.wrapMode = tagPtr->wrapMode;
 	    wrapPrio = tagPtr->priority;
 	}
     }
@@ -1168,11 +1169,11 @@
 				 * previous tab stop. */
     int maxBytes;		/* Maximum number of bytes to include in this
 				 * chunk. */
     TkTextTabArray *tabArrayPtr;/* Tab stops for line; taken from style for
 				 * the first character on line. */
-    int tabStyle;		/* One of TABULAR or WORDPROCESSOR. */
+    int tabStyle;		/* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR. */
     int tabSize;		/* Number of pixels consumed by current tab
 				 * stop. */
     TkTextDispChunk *lastCharChunkPtr;
 				/* Pointer to last chunk in display lines with
 				 * numBytes > 0. Used to drop 0-sized chunks
@@ -1242,11 +1243,11 @@
 		 * The elide state only changes if this tag is either the
 		 * current highest priority tag (and is therefore being
 		 * toggled off), or it's a new tag with higher priority.
 		 */
 
-		if (tagPtr->elideString != NULL) {
+		if (tagPtr->elide >= 0) {
 		    info.tagCnts[tagPtr->priority]++;
 		    if (info.tagCnts[tagPtr->priority] & 1) {
 			info.tagPtrs[tagPtr->priority] = tagPtr;
 		    }
 		    if (tagPtr->priority >= info.elidePriority) {
@@ -1268,16 +1269,16 @@
 
 			    elide = 0;
 			    while (--info.elidePriority > 0) {
 				if (info.tagCnts[info.elidePriority] & 1) {
 				    elide = info.tagPtrs[info.elidePriority]
-					    ->elide;
+					    ->elide > 0;
 				    break;
 				}
 			    }
 			} else {
-			    elide = tagPtr->elide;
+			    elide = tagPtr->elide > 0;
 			    info.elidePriority = tagPtr->priority;
 			}
 		    }
 		}
 	    }
@@ -1389,13 +1390,13 @@
 		 * If have we have a tag toggle, there is a chance that
 		 * invisibility state changed, so bail out.
 		 */
 	    } else if ((segPtr->typePtr == &tkTextToggleOffType)
 		    || (segPtr->typePtr == &tkTextToggleOnType)) {
-		if (segPtr->body.toggle.tagPtr->elideString != NULL) {
+		if (segPtr->body.toggle.tagPtr->elide >= 0) {
 		    elide = (segPtr->typePtr == &tkTextToggleOffType)
-			    ^ segPtr->body.toggle.tagPtr->elide;
+			    ^ (segPtr->body.toggle.tagPtr->elide > 0);
 		}
 	    }
 
 	    byteOffset = 0;
 	    segPtr = segPtr->nextPtr;
@@ -2463,11 +2464,11 @@
     } else {
 	y_off = 0;
     }
 
 #ifdef TK_NO_DOUBLE_BUFFERING
-    TkpClipDrawableToRect(display, pixmap, dInfoPtr->x, y + y_off,
+    Tk_ClipDrawableToRect(display, pixmap, dInfoPtr->x, y + y_off,
 	    dInfoPtr->maxX - dInfoPtr->x, height);
 #endif /* TK_NO_DOUBLE_BUFFERING */
 
     /*
      * First, clear the area of the line to the background color for the text
@@ -2562,10 +2563,17 @@
 		    y + dlPtr->spaceAbove, dlPtr->height - dlPtr->spaceAbove -
 		    dlPtr->spaceBelow, dlPtr->baseline - dlPtr->spaceAbove,
 		    display, pixmap, dlPtr->y + dlPtr->spaceAbove);
 	}
 
+	if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) {
+	    /*
+	     * A displayProc called in the loop above invoked a binding
+	     * that caused the widget to be deleted. Don't do anything.
+	     */
+	    return;
+	}
 	if (dInfoPtr->dLinesInvalidated) {
 	    return;
 	}
     }
 
@@ -2581,11 +2589,11 @@
 
     XCopyArea(display, pixmap, Tk_WindowId(textPtr->tkwin), dInfoPtr->copyGC,
 	    dInfoPtr->x, y + y_off, (unsigned) (dInfoPtr->maxX - dInfoPtr->x),
 	    (unsigned) height, dInfoPtr->x, dlPtr->y + y_off);
 #else
-    TkpClipDrawableToRect(display, pixmap, 0, 0, -1, -1);
+    Tk_ClipDrawableToRect(display, pixmap, 0, 0, -1, -1);
 #endif /* TK_NO_DOUBLE_BUFFERING */
     linesRedrawn++;
 }
 
 /*
@@ -3075,18 +3083,18 @@
 	 */
 
         if (textPtr->afterSyncCmd) {
             int code;
 	    Tcl_CancelIdleCall(TkTextRunAfterSyncCmd, textPtr);
-            Tcl_Preserve((ClientData) textPtr->interp);
+            Tcl_Preserve(textPtr->interp);
             code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd,
                     TCL_EVAL_GLOBAL);
 	    if (code == TCL_ERROR) {
                 Tcl_AddErrorInfo(textPtr->interp, "\n    (text sync)");
                 Tcl_BackgroundException(textPtr->interp, TCL_ERROR);
 	    }
-            Tcl_Release((ClientData) textPtr->interp);
+            Tcl_Release(textPtr->interp);
             Tcl_DecrRefCount(textPtr->afterSyncCmd);
             textPtr->afterSyncCmd = NULL;
 	}
 
         /*
@@ -4218,11 +4226,11 @@
 	CLEAR("tk_textRedraw");
     }
 
     /*
      * Choose a new current item if that is needed (this could cause event
-     * handlers to be invoked, hence the preserve/release calls and the loop,
+     * handlers to be invoked, hence the refcount management and the loop,
      * since the handlers could conceivably necessitate yet another current
      * item calculation). The tkwin check is because the whole window could go
      * away in the Tcl_Release call.
      */
 
@@ -4412,14 +4420,14 @@
 	    bgGC = Tk_GCForColor(textPtr->highlightBgColorPtr,
 		    Tk_WindowId(textPtr->tkwin));
 	    if (textPtr->flags & GOT_FOCUS) {
 		fgGC = Tk_GCForColor(textPtr->highlightColorPtr,
 			Tk_WindowId(textPtr->tkwin));
-		TkpDrawHighlightBorder(textPtr->tkwin, fgGC, bgGC,
+		Tk_DrawHighlightBorder(textPtr->tkwin, fgGC, bgGC,
 			textPtr->highlightWidth, Tk_WindowId(textPtr->tkwin));
 	    } else {
-		TkpDrawHighlightBorder(textPtr->tkwin, bgGC, bgGC,
+		Tk_DrawHighlightBorder(textPtr->tkwin, bgGC, bgGC,
 			textPtr->highlightWidth, Tk_WindowId(textPtr->tkwin));
 	    }
 	}
 	borders = textPtr->borderWidth + textPtr->highlightWidth;
 	if (textPtr->padY > 0) {
@@ -4497,15 +4505,22 @@
 
 		    TkTextPrintIndex(textPtr, &dlPtr->index, string);
 		    LOG("tk_textRedraw", string);
 		}
 		DisplayDLine(textPtr, dlPtr, prevPtr, pixmap);
+		if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) {
+		    /*
+		     * DisplayDLine called a displayProc which invoked a binding
+		     * that caused the widget to be deleted. Don't do anything.
+		     */
+		    goto end;
+		}
 		if (dInfoPtr->dLinesInvalidated) {
 #ifndef TK_NO_DOUBLE_BUFFERING
 		    Tk_FreePixmap(Tk_Display(textPtr->tkwin), pixmap);
 #endif /* TK_NO_DOUBLE_BUFFERING */
-		    return;
+		    goto end;
 		}
 		dlPtr->oldY = dlPtr->y;
 		dlPtr->flags &= ~(NEW_LAYOUT | OLD_Y_INVALID);
 #ifdef MAC_OSX_TK
 	    } else if (dlPtr->chunkPtr != NULL) {
@@ -4724,16 +4739,21 @@
     rect.width = width;
     rect.height = height;
     TkUnionRectWithRegion(&rect, damageRgn, damageRgn);
 
     TextInvalidateRegion(textPtr, damageRgn);
+
+    TkDestroyRegion(damageRgn);
+
+    /*
+     * Schedule the redisplay operation if there isn't one already scheduled.
+     */
 
     if (!(dInfoPtr->flags & REDRAW_PENDING)) {
 	dInfoPtr->flags |= REDRAW_PENDING;
 	Tcl_DoWhenIdle(DisplayText, textPtr);
     }
-    TkDestroyRegion(damageRgn);
 }
 
 /*
  *----------------------------------------------------------------------
  *
@@ -4777,14 +4797,10 @@
     }
     if (dInfoPtr->topOfEof < maxY) {
 	dInfoPtr->topOfEof = maxY;
     }
 
-    /*
-     * Schedule the redisplay operation if there isn't one already scheduled.
-     */
-
     inset = textPtr->borderWidth + textPtr->highlightWidth;
     if ((rect.x < (inset + textPtr->padX))
 	    || (rect.y < (inset + textPtr->padY))
 	    || ((int) (rect.x + rect.width) > (Tk_Width(textPtr->tkwin)
 		    - inset - textPtr->padX))
@@ -6180,11 +6196,11 @@
      */
 
     pickPlace = 0;
     if (Tcl_GetString(objv[2])[0] == '-') {
 	const char *switchStr =
-		TkGetStringFromObj(objv[2], &switchLength);
+		Tcl_GetStringFromObj(objv[2], &switchLength);
 
 	if ((switchLength >= 2) && (strncmp(switchStr, "-pickplace",
 		(unsigned) switchLength) == 0)) {
 	    pickPlace = 1;
 	    if (objc != 4) {
@@ -6440,11 +6456,11 @@
 	dInfoPtr->scanMarkX = x;
 	dInfoPtr->scanTotalYScroll = 0;
 	dInfoPtr->scanMarkY = y;
     } else {
 	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
-		"bad scan option \"%s\": must be mark or dragto",
+		"bad scan option \"%s\": must be dragto or mark",
 		Tcl_GetString(objv[2])));
 	Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "scan option",
 		Tcl_GetString(objv[2]), NULL);
 	return TCL_ERROR;
     }
@@ -7654,19 +7670,19 @@
     tkfont = chunkPtr->stylePtr->sValuePtr->tkfont;
 
 #ifdef TK_LAYOUT_WITH_BASE_CHUNKS
     if (baseCharChunkPtr == NULL) {
 	baseCharChunkPtr = chunkPtr;
-	bciPtr = ckalloc(sizeof(BaseCharInfo));
+	bciPtr = (BaseCharInfo *)ckalloc(sizeof(BaseCharInfo));
 	baseString = &bciPtr->baseChars;
 	Tcl_DStringInit(baseString);
 	bciPtr->width = 0;
 
 	ciPtr = &bciPtr->ci;
     } else {
-	bciPtr = baseCharChunkPtr->clientData;
-	ciPtr = ckalloc(sizeof(CharInfo));
+	bciPtr = (BaseCharInfo *)baseCharChunkPtr->clientData;
+	ciPtr = (CharInfo *)ckalloc(sizeof(CharInfo));
 	baseString = &bciPtr->baseChars;
     }
 
     lineOffset = Tcl_DStringLength(baseString);
     line = Tcl_DStringAppend(baseString,p,maxBytes);
@@ -7765,11 +7781,11 @@
     chunkPtr->minDescent = fm.descent - chunkPtr->stylePtr->sValuePtr->offset;
     chunkPtr->minHeight = 0;
     chunkPtr->width = nextX - chunkPtr->x;
     chunkPtr->breakIndex = -1;
 
-#if !defined(TK_LAYOUT_WITH_BASE_CHUNKS)
+#ifndef TK_LAYOUT_WITH_BASE_CHUNKS
     ciPtr = (CharInfo *)ckalloc(offsetof(CharInfo, chars) + 1 + bytesThatFit);
     chunkPtr->clientData = ciPtr;
     memcpy(ciPtr->chars, p, bytesThatFit);
 #endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
 
@@ -7881,11 +7897,11 @@
 				 * here. */
 {
     Tk_Font tkfont = chunkPtr->stylePtr->sValuePtr->tkfont;
     CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData;
 
-#if !defined(TK_LAYOUT_WITH_BASE_CHUNKS)
+#ifndef TK_LAYOUT_WITH_BASE_CHUNKS
     if (chars == NULL) {
 	chars = ciPtr->chars;
 	charsLen = ciPtr->numBytes;
     }
     if (end == -1) {
@@ -7986,11 +8002,11 @@
 
 	return;
     }
 
 #ifdef TK_DRAW_IN_CONTEXT
-    bciPtr = ciPtr->baseChunkPtr->clientData;
+    bciPtr = (BaseCharInfo *)ciPtr->baseChunkPtr->clientData;
     numBytes = Tcl_DStringLength(&bciPtr->baseChars);
     string = Tcl_DStringValue(&bciPtr->baseChars);
 
 #elif defined(TK_LAYOUT_WITH_BASE_CHUNKS)
     if (ciPtr->baseChunkPtr != chunkPtr) {
@@ -8897,11 +8913,11 @@
 #endif /* TK_DRAW_IN_CONTEXT */
 
 	if (chunkPtr->displayProc != CharDisplayProc) {
 	    continue;
 	}
-	ciPtr = chunkPtr->clientData;
+	ciPtr = (CharInfo *)chunkPtr->clientData;
 	if (ciPtr->baseChunkPtr != baseCharChunkPtr) {
 	    break;
 	}
 	ciPtr->chars = baseChars + ciPtr->baseOffset;
 
@@ -8914,11 +8930,11 @@
 	}
 #endif /* TK_DRAW_IN_CONTEXT */
     }
 
     if (addChunkPtr != NULL) {
-	ciPtr = addChunkPtr->clientData;
+	ciPtr = (CharInfo *)addChunkPtr->clientData;
 	ciPtr->chars = baseChars + ciPtr->baseOffset;
 
 #ifdef TK_DRAW_IN_CONTEXT
 	addChunkPtr->x += widthAdjust;
 	CharChunkMeasureChars(addChunkPtr, NULL, 0, 0, -1, 0, -1, 0,
@@ -8965,11 +8981,11 @@
 
     for (chunkPtr=baseChunkPtr; chunkPtr!=NULL; chunkPtr=chunkPtr->nextPtr) {
 	if (chunkPtr->undisplayProc != CharUndisplayProc) {
 	    continue;
 	}
-	ciPtr = chunkPtr->clientData;
+	ciPtr = (CharInfo *)chunkPtr->clientData;
 	if (ciPtr->baseChunkPtr != baseChunkPtr) {
 	    break;
 	}
 
 	ciPtr->baseChunkPtr = NULL;
@@ -9015,11 +9031,11 @@
 
     if (style1 == style2) {
 	return 1;
     }
 
-#if !defined(TK_DRAW_IN_CONTEXT)
+#ifndef TK_DRAW_IN_CONTEXT
     if (
 #ifdef MAC_OSX_TK
 	    !TkMacOSXCompareColors(style1->fgGC->foreground,
 		    style2->fgGC->foreground)
 #else
@@ -9085,18 +9101,18 @@
 
     /*
      * Reinstitute this base chunk for re-layout.
      */
 
-    ciPtr = chunkPtr->clientData;
+    ciPtr = (CharInfo *)chunkPtr->clientData;
     baseCharChunkPtr = ciPtr->baseChunkPtr;
 
     /*
      * Remove the chunk data from the base chunk data.
      */
 
-    bciPtr = baseCharChunkPtr->clientData;
+    bciPtr = (BaseCharInfo *)baseCharChunkPtr->clientData;
 
 #ifdef DEBUG_LAYOUT_WITH_BASE_CHUNKS
     if ((ciPtr->baseOffset + ciPtr->numBytes)
 	    != Tcl_DStringLength(&bciPtr->baseChars)) {
 	fprintf(stderr,"RemoveFromBaseChunk called with wrong chunk "

Index: generic/tkTextImage.c
==================================================================
--- generic/tkTextImage.c
+++ generic/tkTextImage.c
@@ -2,11 +2,11 @@
  * tkImage.c --
  *
  *	This file contains code that allows images to be nested inside text
  *	widgets. It also implements the "image" widget command for texts.
  *
- * Copyright (c) 1997 Sun Microsystems, Inc.
+ * Copyright © 1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -767,13 +767,13 @@
  *
  *	Given the name of an embedded image within a text widget, returns an
  *	index corresponding to the image's position in the text.
  *
  * Results:
- *	The return value is 1 if there is an embedded image by the given name
- *	in the text widget, 0 otherwise. If the image exists, *indexPtr is
- *	filled in with its index.
+ *	The return value is TCL_OK if there is an embedded image by the given
+ *	name in the text widget, TCL_ERROR otherwise. If the image exists,
+ *	*indexPtr is filled in with its index.
  *
  * Side effects:
  *	None.
  *
  *--------------------------------------------------------------
@@ -787,22 +787,33 @@
 {
     Tcl_HashEntry *hPtr;
     TkTextSegment *eiPtr;
 
     if (textPtr == NULL) {
-	return 0;
+	return TCL_ERROR;
     }
 
     hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->imageTable, name);
     if (hPtr == NULL) {
-	return 0;
+	return TCL_ERROR;
     }
     eiPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
     indexPtr->tree = textPtr->sharedTextPtr->tree;
     indexPtr->linePtr = eiPtr->body.ei.linePtr;
     indexPtr->byteIndex = TkTextSegToOffset(eiPtr, indexPtr->linePtr);
-    return 1;
+
+    /*
+     * If indexPtr refers to somewhere outside the -startline/-endline
+     * range limits of the widget, error out since the image indeed is not
+     * reachable from this text widget (it may be reachable from a peer).
+     */
+
+    if (TkTextIndexAdjustToStartEnd(textPtr, indexPtr, 1) == TCL_ERROR) {
+	return TCL_ERROR;
+    }
+
+    return TCL_OK;
 }
 
 /*
  *--------------------------------------------------------------
  *

Index: generic/tkTextIndex.c
==================================================================
--- generic/tkTextIndex.c
+++ generic/tkTextIndex.c
@@ -2,12 +2,12 @@
  * tkTextIndex.c --
  *
  *	This module provides functions that manipulate indices for text
  *	widgets.
  *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -41,10 +41,18 @@
 			    TkText *textPtr, const char *string,
 			    TkTextIndex *indexPtr, int *canCachePtr);
 static int              IndexCountBytesOrdered(const TkText *textPtr,
                             const TkTextIndex *indexPtr1,
                             const TkTextIndex *indexPtr2);
+
+#if defined(USE_TCL_STUBS) && (TCL_MAJOR_VERSION < 9)
+#   undef Tcl_UtfPrev
+#   define Tcl_UtfPrev (((&tclStubsPtr->tcl_PkgProvideEx)[631]) ? \
+		((const char * (*)(const char *, const char *))(void *)((&tclStubsPtr->tcl_PkgProvideEx)[656])) \
+		: ((const char * (*)(const char *, const char *))(void *)((&tclStubsPtr->tcl_PkgProvideEx)[331])))
+#endif
+
 
 /*
  * The "textindex" Tcl_Obj definition:
  */
 
@@ -434,11 +442,11 @@
 		 * falls in the middle of a UTF-8 character, it will be
 		 * adjusted to the end of that UTF-8 character.
 		 */
 
 		start = segPtr->body.chars + (byteIndex - index);
-		p = TkUtfPrev(start, segPtr->body.chars);
+		p = Tcl_UtfPrev(start, segPtr->body.chars);
 		p += TkUtfToUniChar(p, &ch);
 		indexPtr->byteIndex += p - start;
 	    }
 	    break;
 	}
@@ -478,11 +486,11 @@
     TkTextIndex *indexPtr)	/* Structure to fill in. */
 {
     TkTextSegment *segPtr;
     char *p, *start, *end;
     int index, offset;
-    int ch;
+    Tcl_UniChar ch = 0;
 
     indexPtr->tree = tree;
     if (lineIndex < 0) {
 	lineIndex = 0;
 	charIndex = 0;
@@ -525,11 +533,11 @@
 		if (charIndex == 0) {
 		    indexPtr->byteIndex = index;
 		    return indexPtr;
 		}
 		charIndex--;
-		offset = TkUtfToUniChar(p, &ch);
+		offset = Tcl_UtfToUniChar(p, &ch);
 		index += offset;
 	    }
 	} else {
 	    if (charIndex < (int)segPtr->size) {
 		indexPtr->byteIndex = index;
@@ -759,15 +767,15 @@
 
     if (TkTextMarkNameToIndex(textPtr, string, indexPtr) == TCL_OK) {
 	goto done;
     }
 
-    if (TkTextWindowIndex(textPtr, string, indexPtr) != 0) {
+    if (TkTextWindowIndex(textPtr, string, indexPtr) == TCL_OK) {
 	goto done;
     }
 
-    if (TkTextImageIndex(textPtr, string, indexPtr) != 0) {
+    if (TkTextImageIndex(textPtr, string, indexPtr) == TCL_OK) {
 	goto done;
     }
 
     /*
      *------------------------------------------------
@@ -915,11 +923,11 @@
 
 	c = *endOfBase;
 	*endOfBase = 0;
 	result = TkTextWindowIndex(textPtr, Tcl_DStringValue(&copy), indexPtr);
 	*endOfBase = c;
-	if (result != 0) {
+	if (result == TCL_OK) {
 	    goto gotBase;
 	}
     }
     if ((string[0] == 'e')
 	    && (strncmp(string, "end",
@@ -952,11 +960,11 @@
 
 	c = *endOfBase;
 	*endOfBase = 0;
 	result = TkTextImageIndex(textPtr, Tcl_DStringValue(&copy), indexPtr);
 	*endOfBase = c;
-	if (result != 0) {
+	if (result == TCL_OK) {
 	    goto gotBase;
 	}
     }
     goto error;
 
@@ -995,18 +1003,80 @@
 	*canCachePtr = canCache;
     }
     if (indexPtr->linePtr == NULL) {
 	Tcl_Panic("Bad index created");
     }
+    TkTextIndexAdjustToStartEnd(textPtr, indexPtr, 0);
     return TCL_OK;
 
   error:
     Tcl_DStringFree(&copy);
     Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad text index \"%s\"", string));
     Tcl_SetErrorCode(interp, "TK", "TEXT", "BAD_INDEX", NULL);
     return TCL_ERROR;
 }
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TkTextIndexAdjustToStartEnd --
+ *
+ *      Adjust indexPtr to the -startline/-endline range, or just check
+ *      if indexPtr is out of this range.
+ *
+ * Results:
+ *	The return value is a standard Tcl return result. If check is true,
+ *      return TCL_ERROR if indexPtr is outside the -startline/-endline
+ *      range (indexPtr is not modified).
+ *      If check is false, adjust indexPtr to -startline/-endline.
+ *
+ * Side effects:
+ *	None.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+int
+TkTextIndexAdjustToStartEnd(
+    TkText *textPtr,
+    TkTextIndex *indexPtr,  /* Pointer to index. */
+    int check)		    /* 1 means only check indexPtr against
+			     * the -startline/-endline range
+			     * 0 means adjust to this range */
+{
+    int bound;
+    TkTextIndex indexBound;
+
+    if (!textPtr) {
+	return TCL_OK;
+    }
+    if (textPtr->start != NULL) {
+	bound = TkBTreeLinesTo(NULL, textPtr->start);
+	TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, bound, 0,
+		&indexBound);
+	if (TkTextIndexCmp(indexPtr, &indexBound) < 0) {
+	    if (check) {
+		return TCL_ERROR;
+	    }
+	    TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, bound, 0,
+		    indexPtr);
+	}
+    }
+    if (textPtr->end != NULL) {
+	bound = TkBTreeLinesTo(NULL, textPtr->end);
+	TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, bound, 0,
+		&indexBound);
+	if (TkTextIndexCmp(indexPtr, &indexBound) > 0) {
+	    if (check) {
+		return TCL_ERROR;
+	    }
+	    TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, bound, 0,
+		    indexPtr);
+	}
+    }
+    return TCL_OK;
+}
 
 /*
  *---------------------------------------------------------------------------
  *
  * TkTextPrintIndex --
@@ -1543,11 +1613,11 @@
 		 * The elide state only changes if this tag is either the
 		 * current highest priority tag (and is therefore being
 		 * toggled off), or it's a new tag with higher priority.
 		 */
 
-		if (tagPtr->elideString != NULL) {
+		if (tagPtr->elide >= 0) {
 		    infoPtr->tagCnts[tagPtr->priority]++;
 		    if (infoPtr->tagCnts[tagPtr->priority] & 1) {
 			infoPtr->tagPtrs[tagPtr->priority] = tagPtr;
 		    }
 
@@ -1571,16 +1641,16 @@
 			    elide = 0;
 			    while (--infoPtr->elidePriority > 0) {
 				if (infoPtr->tagCnts[infoPtr->elidePriority]
 					& 1) {
 				    elide = infoPtr->tagPtrs
-					    [infoPtr->elidePriority]->elide;
+					    [infoPtr->elidePriority]->elide > 0;
 				    break;
 				}
 			    }
 			} else {
-			    elide = tagPtr->elide;
+			    elide = tagPtr->elide > 0;
 			    infoPtr->elidePriority = tagPtr->priority;
 			}
 		    }
 		}
 	    }
@@ -1793,11 +1863,11 @@
 		     * The elide state only changes if this tag is either the
 		     * current highest priority tag (and is therefore being
 		     * toggled off), or it's a new tag with higher priority.
 		     */
 
-		    if (tagPtr->elideString != NULL) {
+		    if (tagPtr->elide >= 0) {
 			infoPtr->tagCnts[tagPtr->priority]++;
 			if (infoPtr->tagCnts[tagPtr->priority] & 1) {
 			    infoPtr->tagPtrs[tagPtr->priority] = tagPtr;
 			}
 			if (tagPtr->priority >= infoPtr->elidePriority) {
@@ -1821,16 +1891,16 @@
 				elide = 0;
 				while (--infoPtr->elidePriority > 0) {
 				    if (infoPtr->tagCnts[
 					    infoPtr->elidePriority] & 1) {
 					elide = infoPtr->tagPtrs[
-						infoPtr->elidePriority]->elide;
+						infoPtr->elidePriority]->elide > 0;
 					break;
 				    }
 				}
 			    } else {
-				elide = tagPtr->elide;
+				elide = tagPtr->elide > 0;
 				infoPtr->elidePriority = tagPtr->priority;
 			    }
 			}
 		    }
 		}
@@ -2082,11 +2152,11 @@
 	     * The elide state only changes if this tag is either the current
 	     * highest priority tag (and is therefore being toggled off), or
 	     * it's a new tag with higher priority.
 	     */
 
-	    if (tagPtr->elideString != NULL) {
+	    if (tagPtr->elide >= 0) {
 		infoPtr->tagCnts[tagPtr->priority]++;
 		if (infoPtr->tagCnts[tagPtr->priority] & 1) {
 		    infoPtr->tagPtrs[tagPtr->priority] = tagPtr;
 		}
 		if (tagPtr->priority >= infoPtr->elidePriority) {
@@ -2108,16 +2178,16 @@
 
 			elide = 0;
 			while (--infoPtr->elidePriority > 0) {
 			    if (infoPtr->tagCnts[infoPtr->elidePriority] & 1) {
 				elide = infoPtr->tagPtrs[
-					infoPtr->elidePriority]->elide;
+					infoPtr->elidePriority]->elide > 0;
 				break;
 			    }
 			}
 		    } else {
-			elide = tagPtr->elide;
+			elide = tagPtr->elide > 0;
 			infoPtr->elidePriority = tagPtr->priority;
 		    }
 		}
 	    }
 	}
@@ -2124,19 +2194,24 @@
 
 	if (!elide) {
 	    if (segPtr->typePtr == &tkTextCharType) {
 		start = segPtr->body.chars;
 		end = segPtr->body.chars + segSize;
-		for (p = end; ; p = TkUtfPrev(p, start)) {
+		for (p = end; ; p = Tcl_UtfPrev(p, start)) {
 		    if (charCount == 0) {
 			dstPtr->byteIndex -= (end - p);
 			goto backwardCharDone;
 		    }
 		    if (p == start) {
 			break;
 		    }
-		    charCount--;
+		    if ((sizeof(Tcl_UniChar) == 2) &&  (unsigned)(UCHAR(*p) - 0xF0) <= 5) {
+			charCount--; /* Characters > U+FFFF count as 2 here */
+		    }
+		    if (charCount != 0) {
+			charCount--;
+		    }
 		}
 	    } else {
 		if (type & COUNT_INDICES) {
 		    if (charCount <= segSize) {
 			dstPtr->byteIndex -= charCount;
@@ -2365,27 +2440,27 @@
 		if (!Tcl_UniCharIsWordChar(ch)) {
 		    break;
 		}
 		if (offset + 1 > 1) {
 		    chSize = (segPtr->body.chars + offset
-			    - TkUtfPrev(segPtr->body.chars + offset,
+			    - Tcl_UtfPrev(segPtr->body.chars + offset,
 			    segPtr->body.chars));
 		}
 		firstChar = 0;
 	    }
-            if (offset == 0) {
-                if (modifier == TKINDEX_DISPLAY) {
-                    TkTextIndexBackChars(textPtr, indexPtr, 1, indexPtr,
-                        COUNT_DISPLAY_INDICES);
-                } else {
-                    TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr,
-                        COUNT_INDICES);
-                }
-            } else {
-                indexPtr->byteIndex -= chSize;
-            }
-            offset -= chSize;
+	    if (offset == 0) {
+		if (modifier == TKINDEX_DISPLAY) {
+		    TkTextIndexBackChars(textPtr, indexPtr, 1, indexPtr,
+			    COUNT_DISPLAY_INDICES);
+		} else {
+		    TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr,
+			    COUNT_INDICES);
+		}
+	    } else {
+		indexPtr->byteIndex -= chSize;
+	    }
+	    offset -= chSize;
 	    if ((int)offset < 0) {
 		if (indexPtr->byteIndex == 0) {
 		    goto done;
 		}
 		segPtr = TkTextIndexToSeg(indexPtr, &offset);

Index: generic/tkTextMark.c
==================================================================
--- generic/tkTextMark.c
+++ generic/tkTextMark.c
@@ -2,12 +2,12 @@
  * tkTextMark.c --
  *
  *	This file contains the functions that implement marks for text
  *	widgets.
  *
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -131,11 +131,11 @@
 
 	if (objc < 4 || objc > 5) {
 	    Tcl_WrongNumArgs(interp, 3, objv, "markName ?gravity?");
 	    return TCL_ERROR;
 	}
-	str = TkGetStringFromObj(objv[3], &length);
+	str = Tcl_GetStringFromObj(objv[3], &length);
 	if (length == 6 && !strcmp(str, "insert")) {
 	    markPtr = textPtr->insertMarkPtr;
 	} else if (length == 7 && !strcmp(str, "current")) {
 	    markPtr = textPtr->currentMarkPtr;
 	} else {
@@ -158,11 +158,11 @@
 		typeStr = "left";
 	    }
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj(typeStr, -1));
 	    return TCL_OK;
 	}
-	str = TkGetStringFromObj(objv[4],&length);
+	str = Tcl_GetStringFromObj(objv[4],&length);
 	c = str[0];
 	if ((c == 'l') && (strncmp(str, "left", length) == 0)) {
 	    newTypePtr = &tkTextLeftMarkType;
 	} else if ((c == 'r') &&
 		(strncmp(str, "right", length) == 0)) {
@@ -432,12 +432,10 @@
     TkText *textPtr,		/* Text widget containing mark. */
     const char *name,		/* Name of mark. */
     TkTextIndex *indexPtr)	/* Index information gets stored here. */
 {
     TkTextSegment *segPtr;
-    TkTextIndex index;
-    int start, end;
 
     if (textPtr == NULL) {
         return TCL_ERROR;
     }
 
@@ -454,32 +452,21 @@
 	}
 	segPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
     }
     TkTextMarkSegToIndex(textPtr, segPtr, indexPtr);
 
-    /* If indexPtr refers to somewhere outside the -startline/-endline
+    /*
+     * If indexPtr refers to somewhere outside the -startline/-endline
      * range limits of the widget, error out since the mark indeed is not
      * reachable from this text widget (it may be reachable from a peer)
      * (bug 1630271).
      */
 
-    if (textPtr->start != NULL) {
-	start = TkBTreeLinesTo(NULL, textPtr->start);
-	TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, start, 0,
-		&index);
-	if (TkTextIndexCmp(indexPtr, &index) < 0) {
-	    return TCL_ERROR;
-	}
-    }
-    if (textPtr->end != NULL) {
-	end = TkBTreeLinesTo(NULL, textPtr->end);
-	TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, end, 0,
-		&index);
-	if (TkTextIndexCmp(indexPtr, &index) > 0) {
-	    return TCL_ERROR;
-	}
-    }
+    if (TkTextIndexAdjustToStartEnd(textPtr, indexPtr, 1) == TCL_ERROR) {
+	return TCL_ERROR;
+    }
+
     return TCL_OK;
 }
 
 /*
  *--------------------------------------------------------------

Index: generic/tkTextTag.c
==================================================================
--- generic/tkTextTag.c
+++ generic/tkTextTag.c
@@ -3,54 +3,32 @@
  *
  *	This module implements the "tag" subcommand of the widget command for
  *	text widgets, plus most of the other high-level functions related to
  *	tags.
  *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
 #include "tkInt.h"
 #include "tkText.h"
 #include "default.h"
 
-/*
- * The 'TkWrapMode' enum in tkText.h is used to define a type for the -wrap
- * option of tags in a Text widget. These values are used as indices into the
- * string table below. Tags are allowed an empty wrap value, but the widget as
- * a whole is not.
- */
-
-static const char *const wrapStrings[] = {
-    "char", "none", "word", "", NULL
-};
-
-/*
- * The 'TkTextTabStyle' enum in tkText.h is used to define a type for the
- * -tabstyle option of the Text widget. These values are used as indices into
- * the string table below. Tags are allowed an empty tabstyle value, but the
- * widget as a whole is not.
- */
-
-static const char *const tabStyleStrings[] = {
-    "tabular", "wordprocessor", "", NULL
-};
-
 static const Tk_OptionSpec tagOptionSpecs[] = {
     {TK_OPTION_BORDER, "-background", NULL, NULL,
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, border), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_BITMAP, "-bgstipple", NULL, NULL,
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, bgStipple), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_PIXELS, "-borderwidth", NULL, NULL,
 	NULL, offsetof(TkTextTag, borderWidthPtr), offsetof(TkTextTag, borderWidth),
-	TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0},
-    {TK_OPTION_STRING, "-elide", NULL, NULL,
-	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, elideString),
-	TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0},
+	TK_OPTION_NULL_OK, 0, 0},
+    {TK_OPTION_BOOLEAN, "-elide", NULL, NULL,
+	NULL, offsetof(TkTextTag, elidePtr), offsetof(TkTextTag, elide),
+	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_BITMAP, "-fgstipple", NULL, NULL,
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, fgStipple), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_FONT, "-font", NULL, NULL,
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, tkfont), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_COLOR, "-foreground", NULL, NULL,
@@ -63,16 +41,16 @@
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMargin2String), TK_OPTION_NULL_OK,0,0},
     {TK_OPTION_BORDER, "-lmargincolor", NULL, NULL,
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMarginColor), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING, "-offset", NULL, NULL,
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, offsetString), TK_OPTION_NULL_OK, 0, 0},
-    {TK_OPTION_STRING, "-overstrike", NULL, NULL,
-	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, overstrikeString),
+    {TK_OPTION_BOOLEAN, "-overstrike", NULL, NULL,
+	NULL, offsetof(TkTextTag, overstrikePtr), offsetof(TkTextTag, overstrike),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_COLOR, "-overstrikefg", NULL, NULL,
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, overstrikeColor),
-        TK_OPTION_NULL_OK, 0, 0},
+	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING, "-relief", NULL, NULL,
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING, "-rmargin", NULL, NULL,
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0},
     {TK_OPTION_BORDER, "-rmargincolor", NULL, NULL,
@@ -89,20 +67,20 @@
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, spacing3String), TK_OPTION_NULL_OK,0,0},
     {TK_OPTION_STRING, "-tabs", NULL, NULL,
 	NULL, offsetof(TkTextTag, tabStringPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING_TABLE, "-tabstyle", NULL, NULL,
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, tabStyle),
-	TK_OPTION_NULL_OK, tabStyleStrings, 0},
-    {TK_OPTION_STRING, "-underline", NULL, NULL,
-	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, underlineString),
+	TK_OPTION_NULL_OK, tkTextTabStyleStrings, 0},
+    {TK_OPTION_BOOLEAN, "-underline", NULL, NULL,
+	NULL, offsetof(TkTextTag, underlinePtr), offsetof(TkTextTag, underline),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_COLOR, "-underlinefg", NULL, NULL,
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, underlineColor),
-        TK_OPTION_NULL_OK, 0, 0},
+	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING_TABLE, "-wrap", NULL, NULL,
 	NULL, TCL_INDEX_NONE, offsetof(TkTextTag, wrapMode),
-	TK_OPTION_NULL_OK, wrapStrings, 0},
+	TK_OPTION_NULL_OK|TK_OPTION_ENUM_VAR, tkTextWrapStrings, 0},
     {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
 };
 
 /*
  * Forward declarations for functions defined later in this file:
@@ -151,11 +129,12 @@
     enum tagOptions {
 	TAG_ADD, TAG_BIND, TAG_CGET, TAG_CONFIGURE, TAG_DELETE, TAG_LOWER,
 	TAG_NAMES, TAG_NEXTRANGE, TAG_PREVRANGE, TAG_RAISE, TAG_RANGES,
 	TAG_REMOVE
     };
-    int optionIndex, i;
+    int optionIndex;
+    TkSizeT i;
     TkTextTag *tagPtr;
     TkTextIndex index1, index2;
 
     if (objc < 3) {
 	Tcl_WrongNumArgs(interp, 2, objv, "option ?arg ...?");
@@ -181,24 +160,24 @@
 	    Tcl_WrongNumArgs(interp, 3, objv,
 		    "tagName index1 ?index2 index1 index2 ...?");
 	    return TCL_ERROR;
 	}
 	tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]), NULL);
-	if (tagPtr->elide) {
+	if (tagPtr->elide > 0) {
 		/*
 		* Indices are potentially obsolete after adding or removing
 		* elided character ranges, especially indices having "display"
 		* or "any" submodifier, therefore increase the epoch.
 		*/
 		textPtr->sharedTextPtr->stateEpoch++;
 	}
-	for (i = 4; i < objc; i += 2) {
+	for (i = 4; i < (TkSizeT)objc; i += 2) {
 	    if (TkTextGetObjIndex(interp, textPtr, objv[i],
 		    &index1) != TCL_OK) {
 		return TCL_ERROR;
 	    }
-	    if (objc > (i+1)) {
+	    if ((TkSizeT)objc > (i+1)) {
 		if (TkTextGetObjIndex(interp, textPtr, objv[i+1],
 			&index2) != TCL_OK) {
 		    return TCL_ERROR;
 		}
 		if (TkTextIndexCmp(&index1, &index2) >= 0) {
@@ -277,19 +256,19 @@
 	    const char *fifth = Tcl_GetString(objv[5]);
 
 	    if (fifth[0] == 0) {
 		return Tk_DeleteBinding(interp,
 			textPtr->sharedTextPtr->bindingTable,
-			(ClientData) tagPtr->name, Tcl_GetString(objv[4]));
+			(void *) tagPtr->name, Tcl_GetString(objv[4]));
 	    }
 	    if (fifth[0] == '+') {
 		fifth++;
 		append = 1;
 	    }
 	    mask = Tk_CreateBinding(interp,
 		    textPtr->sharedTextPtr->bindingTable,
-		    (ClientData) tagPtr->name, Tcl_GetString(objv[4]), fifth,
+		    (void *) tagPtr->name, Tcl_GetString(objv[4]), fifth,
 		    append);
 	    if (mask == 0) {
 		return TCL_ERROR;
 	    }
 	    if (mask & ~(unsigned long)(ButtonMotionMask|Button1MotionMask
@@ -296,11 +275,11 @@
 		    |Button2MotionMask|Button3MotionMask|Button4MotionMask
 		    |Button5MotionMask|ButtonPressMask|ButtonReleaseMask
 		    |EnterWindowMask|LeaveWindowMask|KeyPressMask
 		    |KeyReleaseMask|PointerMotionMask|VirtualEventMask)) {
 		Tk_DeleteBinding(interp, textPtr->sharedTextPtr->bindingTable,
-			(ClientData) tagPtr->name, Tcl_GetString(objv[4]));
+			(void *) tagPtr->name, Tcl_GetString(objv[4]));
 		Tcl_SetObjResult(interp, Tcl_NewStringObj(
 			"requested illegal events; only key, button, motion,"
 			" enter, leave, and virtual events may be used", -1));
 		Tcl_SetErrorCode(interp, "TK", "TEXT", "TAG_BIND_EVENT",NULL);
 		return TCL_ERROR;
@@ -308,11 +287,11 @@
 	} else if (objc == 5) {
 	    const char *command;
 
 	    command = Tk_GetBinding(interp,
 		    textPtr->sharedTextPtr->bindingTable,
-		    (ClientData) tagPtr->name, Tcl_GetString(objv[4]));
+		    (void *) tagPtr->name, Tcl_GetString(objv[4]));
 	    if (command == NULL) {
 		const char *string = Tcl_GetString(Tcl_GetObjResult(interp));
 
 		/*
 		 * Ignore missing binding errors. This is a special hack that
@@ -327,11 +306,11 @@
 	    } else {
 		Tcl_SetObjResult(interp, Tcl_NewStringObj(command, -1));
 	    }
 	} else {
 	    Tk_GetAllBindings(interp, textPtr->sharedTextPtr->bindingTable,
-		    (ClientData) tagPtr->name);
+		    (void *) tagPtr->name);
 	}
 	break;
     case TAG_CGET:
 	if (objc != 5) {
 	    Tcl_WrongNumArgs(interp, 1, objv, "tag cget tagName option");
@@ -416,16 +395,10 @@
 	    if (tagPtr->offsetString != NULL) {
 		if (Tk_GetPixels(interp, textPtr->tkwin, tagPtr->offsetString,
 			&tagPtr->offset) != TCL_OK) {
 		    return TCL_ERROR;
 		}
-	    }
-	    if (tagPtr->overstrikeString != NULL) {
-		if (Tcl_GetBoolean(interp, tagPtr->overstrikeString,
-			&tagPtr->overstrike) != TCL_OK) {
-		    return TCL_ERROR;
-		}
 	    }
 	    if (tagPtr->rMarginString != NULL) {
 		if (Tk_GetPixels(interp, textPtr->tkwin,
 			tagPtr->rMarginString, &tagPtr->rMargin) != TCL_OK) {
 		    return TCL_ERROR;
@@ -467,22 +440,11 @@
 			TkTextGetTabs(interp, textPtr, tagPtr->tabStringPtr);
 		if (tagPtr->tabArrayPtr == NULL) {
 		    return TCL_ERROR;
 		}
 	    }
-	    if (tagPtr->underlineString != NULL) {
-		if (Tcl_GetBoolean(interp, tagPtr->underlineString,
-			&tagPtr->underline) != TCL_OK) {
-		    return TCL_ERROR;
-		}
-	    }
-	    if (tagPtr->elideString != NULL) {
-		if (Tcl_GetBoolean(interp, tagPtr->elideString,
-			&tagPtr->elide) != TCL_OK) {
-		    return TCL_ERROR;
-		}
-
+	    if (tagPtr->elide >= 0) {
 		/*
 		 * Indices are potentially obsolete after changing -elide,
 		 * especially those computed with "display" or "any"
 		 * submodifier, therefore increase the epoch.
 		 */
@@ -513,11 +475,11 @@
                 }
 	    }
 
 	    tagPtr->affectsDisplay = 0;
 	    tagPtr->affectsDisplayGeometry = 0;
-	    if ((tagPtr->elideString != NULL)
+	    if ((tagPtr->elide >= 0)
 		    || (tagPtr->tkfont != NULL)
 		    || (tagPtr->justifyString != NULL)
 		    || (tagPtr->lMargin1String != NULL)
 		    || (tagPtr->lMargin2String != NULL)
 		    || (tagPtr->offsetString != NULL)
@@ -524,12 +486,15 @@
 		    || (tagPtr->rMarginString != NULL)
 		    || (tagPtr->spacing1String != NULL)
 		    || (tagPtr->spacing2String != NULL)
 		    || (tagPtr->spacing3String != NULL)
 		    || (tagPtr->tabStringPtr != NULL)
-		    || (tagPtr->tabStyle != TK_TEXT_TABSTYLE_NONE)
-		    || (tagPtr->wrapMode != TEXT_WRAPMODE_NULL)) {
+		    || (tagPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR)
+		    || (tagPtr->tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR)
+		    || (tagPtr->wrapMode == TEXT_WRAPMODE_CHAR)
+		    || (tagPtr->wrapMode == TEXT_WRAPMODE_NONE)
+		    || (tagPtr->wrapMode == TEXT_WRAPMODE_WORD)) {
 		tagPtr->affectsDisplay = 1;
 		tagPtr->affectsDisplayGeometry = 1;
 	    }
 	    if ((tagPtr->border != NULL)
 		    || (tagPtr->selBorder != NULL)
@@ -536,13 +501,13 @@
 		    || (tagPtr->reliefString != NULL)
 		    || (tagPtr->bgStipple != None)
 		    || (tagPtr->fgColor != NULL)
 		    || (tagPtr->selFgColor != NULL)
 		    || (tagPtr->fgStipple != None)
-		    || (tagPtr->overstrikeString != NULL)
+		    || (tagPtr->overstrike >= 0)
                     || (tagPtr->overstrikeColor != NULL)
-		    || (tagPtr->underlineString != NULL)
+		    || (tagPtr->underline >= 0)
                     || (tagPtr->underlineColor != NULL)
                     || (tagPtr->lMarginColor != NULL)
                     || (tagPtr->rMarginColor != NULL)) {
 		tagPtr->affectsDisplay = 1;
 	    }
@@ -570,11 +535,11 @@
 
 	if (objc < 4) {
 	    Tcl_WrongNumArgs(interp, 3, objv, "tagName ?tagName ...?");
 	    return TCL_ERROR;
 	}
-	for (i = 3; i < objc; i++) {
+	for (i = 3; i < (TkSizeT)objc; i++) {
 	    hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->tagTable,
 		    Tcl_GetString(objv[i]));
 	    if (hPtr == NULL) {
 		/*
 		 * Either this tag doesn't exist or it's the 'sel' tag (which
@@ -632,11 +597,11 @@
 	TkTextRedrawTag(textPtr->sharedTextPtr, NULL, NULL, NULL, tagPtr, 1);
 	break;
     }
     case TAG_NAMES: {
 	TkTextTag **arrayPtr;
-	int arraySize;
+	TkSizeT arraySize;
 	Tcl_Obj *listObj;
 
 	if ((objc != 3) && (objc != 4)) {
 	    Tcl_WrongNumArgs(interp, 3, objv, "?index?");
 	    return TCL_ERROR;
@@ -1033,20 +998,20 @@
     tagPtr->bgStipple = None;
     tagPtr->fgColor = NULL;
     tagPtr->tkfont = NULL;
     tagPtr->fgStipple = None;
     tagPtr->justifyString = NULL;
-    tagPtr->justify = TK_JUSTIFY_LEFT;
+    tagPtr->justify = TK_JUSTIFY_NULL;
     tagPtr->lMargin1String = NULL;
     tagPtr->lMargin1 = 0;
     tagPtr->lMargin2String = NULL;
     tagPtr->lMargin2 = 0;
     tagPtr->lMarginColor = NULL;
     tagPtr->offsetString = NULL;
     tagPtr->offset = 0;
-    tagPtr->overstrikeString = NULL;
-    tagPtr->overstrike = 0;
+    tagPtr->overstrikePtr = NULL;
+    tagPtr->overstrike = -1;
     tagPtr->overstrikeColor = NULL;
     tagPtr->rMarginString = NULL;
     tagPtr->rMargin = 0;
     tagPtr->rMarginColor = NULL;
     tagPtr->selBorder = NULL;
@@ -1057,16 +1022,16 @@
     tagPtr->spacing2 = 0;
     tagPtr->spacing3String = NULL;
     tagPtr->spacing3 = 0;
     tagPtr->tabStringPtr = NULL;
     tagPtr->tabArrayPtr = NULL;
-    tagPtr->tabStyle = TK_TEXT_TABSTYLE_NONE;
-    tagPtr->underlineString = NULL;
-    tagPtr->underline = 0;
+    tagPtr->tabStyle = TK_TEXT_TABSTYLE_NULL;
+    tagPtr->underlinePtr = NULL;
+    tagPtr->underline = -1;
     tagPtr->underlineColor = NULL;
-    tagPtr->elideString = NULL;
-    tagPtr->elide = 0;
+    tagPtr->elidePtr = NULL;
+    tagPtr->elide = -1;
     tagPtr->wrapMode = TEXT_WRAPMODE_NULL;
     tagPtr->affectsDisplay = 0;
     tagPtr->affectsDisplayGeometry = 0;
     textPtr->sharedTextPtr->numTags++;
     if (!strcmp(tagName, "sel")) {
@@ -1109,11 +1074,11 @@
 {
     Tcl_HashEntry *hPtr;
     TkSizeT len;
     const char *str;
 
-    str = TkGetStringFromObj(tagName, &len);
+    str = Tcl_GetStringFromObj(tagName, &len);
     if (len == 3 && !strcmp(str, "sel")) {
 	return textPtr->selTagPtr;
     }
     hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->tagTable,
 	    Tcl_GetString(tagName));
@@ -1181,11 +1146,11 @@
 	 * are still valid in other peer widgets.
 	 */
 
 	if (textPtr->sharedTextPtr->bindingTable != NULL) {
 	    Tk_DeleteAllBindings(textPtr->sharedTextPtr->bindingTable,
-		    (ClientData) tagPtr->name);
+		    (void *) tagPtr->name);
 	}
     }
 
     /*
      * Update the tag priorities to reflect the deletion of this tag.
@@ -1479,15 +1444,35 @@
 	} else {
 	    textPtr->flags &= ~BUTTON_DOWN;
 	}
 	TkTextPickCurrent(textPtr, eventPtr);
     }
-    if ((textPtr->numCurTags > 0)
-	    && (textPtr->sharedTextPtr->bindingTable != NULL)
+
+    if ((textPtr->sharedTextPtr->bindingTable != NULL)
 	    && (textPtr->tkwin != NULL) && !(textPtr->flags & DESTROYED)) {
-	TagBindEvent(textPtr, eventPtr, textPtr->numCurTags,
+	if (textPtr->numCurTags > 0) {
+	    /*
+	     * The mouse is inside the text widget, the 'current' mark was updated.
+	     */
+
+	    TagBindEvent(textPtr, eventPtr, textPtr->numCurTags,
 		textPtr->curTagArrayPtr);
+	} else if ((eventPtr->type == KeyPress) || (eventPtr->type == KeyRelease)) {
+	    /*
+	     * Key events fire independently of the 'current' mark and use the
+	     * 'insert' mark.
+	     */
+
+	    TkTextIndex index;
+	    TkTextTag** tagArrayPtr;
+	    TkSizeT numTags;
+
+	    TkTextMarkNameToIndex(textPtr, "insert", &index);
+	    tagArrayPtr = TkBTreeGetTags(&index, textPtr, &numTags);
+	    SortTags(numTags, tagArrayPtr);
+	    TagBindEvent(textPtr, eventPtr, numTags, tagArrayPtr);
+	}
     }
     if (repick) {
 	unsigned int oldState;
 
 	oldState = eventPtr->xbutton.state;
@@ -1538,11 +1523,12 @@
     TkTextIndex index;
     TkTextTag **oldArrayPtr, **newArrayPtr;
     TkTextTag **copyArrayPtr = NULL;
 				/* Initialization needed to prevent compiler
 				 * warning. */
-    int numOldTags, numNewTags, i, j, nearby;
+    int numOldTags, i, nearby;
+    TkSizeT numNewTags, j;
     size_t size;
     XEvent event;
 
     /*
      * If a button is down, then don't do anything at all; we'll be called

Index: generic/tkTextWind.c
==================================================================
--- generic/tkTextWind.c
+++ generic/tkTextWind.c
@@ -3,12 +3,12 @@
  *
  *	This file contains code that allows arbitrary windows to be nested
  *	inside text widgets. It also implements the "window" widget command
  *	for texts.
  *
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -524,11 +524,10 @@
     ClientData clientData,	/* Pointer to record describing window item. */
     XEvent *eventPtr)		/* Describes what just happened. */
 {
     TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
     TkTextSegment *ewPtr = client->parent;
-    TkTextIndex index;
     Tcl_HashEntry *hPtr;
 
     if (eventPtr->type != DestroyNotify) {
 	return;
     }
@@ -543,16 +542,11 @@
 	Tcl_DeleteHashEntry(hPtr);
     }
 
     ewPtr->body.ew.tkwin = NULL;
     client->tkwin = NULL;
-    index.tree = ewPtr->body.ew.sharedTextPtr->tree;
-    index.linePtr = ewPtr->body.ew.linePtr;
-    index.byteIndex = TkTextSegToOffset(ewPtr, ewPtr->body.ew.linePtr);
-    TkTextChanged(ewPtr->body.ew.sharedTextPtr, NULL, &index, &index);
-    TkTextInvalidateLineMetrics(ewPtr->body.ew.sharedTextPtr, NULL,
-	    index.linePtr, 0, TK_TEXT_INVALIDATE_ONLY);
+    EmbWinRequestProc(client, NULL);
 }
 
 /*
  *--------------------------------------------------------------
  *
@@ -572,19 +566,27 @@
  */
 
 static void
 EmbWinRequestProc(
     ClientData clientData,	/* Pointer to record for window item. */
-    TCL_UNUSED(Tk_Window))		/* Window that changed its desired size. */
+    TCL_UNUSED(Tk_Window))	/* Window that changed its desired size. */
 {
     TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
     TkTextSegment *ewPtr = client->parent;
     TkTextIndex index;
 
     index.tree = ewPtr->body.ew.sharedTextPtr->tree;
     index.linePtr = ewPtr->body.ew.linePtr;
-    index.byteIndex = TkTextSegToOffset(ewPtr, ewPtr->body.ew.linePtr);
+
+    /*
+     * ewPtr->body.ew.tkwin == NULL means the embedded window is already
+     * destroyed. The ewPtr segment is no longer linked, TkTextSegToOffset
+     * cannot find it within the line pointed by ewPtr->body.ew.linePtr.
+     */
+
+    index.byteIndex =  ewPtr->body.ew.tkwin ?
+	    TkTextSegToOffset(ewPtr, ewPtr->body.ew.linePtr) : 0;
     TkTextChanged(ewPtr->body.ew.sharedTextPtr, NULL, &index, &index);
     TkTextInvalidateLineMetrics(ewPtr->body.ew.sharedTextPtr, NULL,
 	    index.linePtr, 0, TK_TEXT_INVALIDATE_ONLY);
 }
 
@@ -1318,13 +1320,13 @@
  *
  *	Given the name of an embedded window within a text widget, returns an
  *	index corresponding to the window's position in the text.
  *
  * Results:
- *	The return value is 1 if there is an embedded window by the given name
- *	in the text widget, 0 otherwise. If the window exists, *indexPtr is
- *	filled in with its index.
+ *	The return value is TCL_OK if there is an embedded window by the given
+ *	name in the text widget, TCL_ERROR otherwise. If the window exists,
+ *	*indexPtr is filled in with its index.
  *
  * Side effects:
  *	None.
  *
  *--------------------------------------------------------------
@@ -1338,23 +1340,34 @@
 {
     Tcl_HashEntry *hPtr;
     TkTextSegment *ewPtr;
 
     if (textPtr == NULL) {
-	return 0;
+	return TCL_ERROR;
     }
 
     hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->windowTable, name);
     if (hPtr == NULL) {
-	return 0;
+	return TCL_ERROR;
     }
 
     ewPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
     indexPtr->tree = textPtr->sharedTextPtr->tree;
     indexPtr->linePtr = ewPtr->body.ew.linePtr;
     indexPtr->byteIndex = TkTextSegToOffset(ewPtr, indexPtr->linePtr);
-    return 1;
+
+    /*
+     * If indexPtr refers to somewhere outside the -startline/-endline
+     * range limits of the widget, error out since the window indeed is not
+     * reachable from this text widget (it may be reachable from a peer).
+     */
+
+    if (TkTextIndexAdjustToStartEnd(textPtr, indexPtr, 1) == TCL_ERROR) {
+	return TCL_ERROR;
+    }
+
+    return TCL_OK;
 }
 
 /*
  *--------------------------------------------------------------
  *

Index: generic/tkTrig.c
==================================================================
--- generic/tkTrig.c
+++ generic/tkTrig.c
@@ -3,12 +3,12 @@
  *
  *	This file contains a collection of trigonometry utility routines that
  *	are used by Tk and in particular by the canvas code. It also has
  *	miscellaneous geometry functions used by canvases.
  *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -37,13 +37,13 @@
  *--------------------------------------------------------------
  */
 
 double
 TkLineToPoint(
-    double end1Ptr[2],		/* Coordinates of first end-point of line. */
-    double end2Ptr[2],		/* Coordinates of second end-point of line. */
-    double pointPtr[2])		/* Points to coords for point. */
+    double end1Ptr[],		/* Coordinates of first end-point of line. */
+    double end2Ptr[],		/* Coordinates of second end-point of line. */
+    double pointPtr[])		/* Points to coords for point. */
 {
     double x, y;
 
     /*
      * Compute the point on the line that is closest to the point. This must
@@ -141,15 +141,15 @@
  *--------------------------------------------------------------
  */
 
 int
 TkLineToArea(
-    double end1Ptr[2],		/* X and y coordinates for one endpoint of
+    double end1Ptr[],		/* X and y coordinates for one endpoint of
 				 * line. */
-    double end2Ptr[2],		/* X and y coordinates for other endpoint of
+    double end2Ptr[],		/* X and y coordinates for other endpoint of
 				 * line. */
-    double rectPtr[4])		/* Points to coords for rectangle, in the
+    double rectPtr[])		/* Points to coords for rectangle, in the
 				 * order x1, y1, x2, y2. X1 must be no larger
 				 * than x2, and y1 no larger than y2. */
 {
     int inside1, inside2;
 
@@ -651,18 +651,18 @@
  *--------------------------------------------------------------
  */
 
 double
 TkOvalToPoint(
-    double ovalPtr[4],		/* Pointer to array of four coordinates (x1,
+    double ovalPtr[],		/* Pointer to array of four coordinates (x1,
 				 * y1, x2, y2) defining oval's bounding
 				 * box. */
     double width,		/* Width of outline for oval. */
     int filled,			/* Non-zero means oval should be treated as
 				 * filled; zero means only consider
 				 * outline. */
-    double pointPtr[2])		/* Coordinates of point. */
+    double pointPtr[])		/* Coordinates of point. */
 {
     double xDelta, yDelta, scaledDistance, distToOutline, distToCenter;
     double xDiam, yDiam;
 
     /*

Index: generic/tkUndo.c
==================================================================
--- generic/tkUndo.c
+++ generic/tkUndo.c
@@ -1,12 +1,12 @@
 /*
  * tkUndo.c --
  *
  *	This module provides the implementation of an undo stack.
  *
- * Copyright (c) 2002 by Ludwig Callewaert.
- * Copyright (c) 2003-2004 by Vincent Darley.
+ * Copyright © 2002 Ludwig Callewaert.
+ * Copyright © 2003-2004 Vincent Darley.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkUndo.h
==================================================================
--- generic/tkUndo.h
+++ generic/tkUndo.h
@@ -1,11 +1,11 @@
 /*
  * tkUndo.h --
  *
  *	Declarations shared among the files that implement an undo stack.
  *
- * Copyright (c) 2002 Ludwig Callewaert.
+ * Copyright © 2002 Ludwig Callewaert.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkUtil.c
==================================================================
--- generic/tkUtil.c
+++ generic/tkUtil.c
@@ -2,12 +2,12 @@
  * tkUtil.c --
  *
  *	This file contains miscellaneous utility functions that are used by
  *	the rest of Tk, such as a function for drawing a focus highlight.
  *
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -582,11 +582,11 @@
  * Tk_DrawFocusHighlight --
  *
  *	This function draws a rectangular ring around the outside of a widget
  *	to indicate that it has received the input focus.
  *
- *	This function is now deprecated. Use TkpDrawHighlightBorder instead,
+ *	This function is now deprecated. Use Tk_DrawHighlightBorder instead,
  *	since this function does not handle drawing the Focus ring properly on
  *	the Macintosh - you need to know the background GC as well as the
  *	foreground since the Mac focus ring separated from the widget by a 1
  *	pixel border.
  *
@@ -729,11 +729,11 @@
 				 * any. */
     int *intPtr)		/* Filled in with number of pages or lines to
 				 * scroll, if any. */
 {
     TkSizeT length;
-    const char *arg = TkGetStringFromObj(objv[2], &length);
+    const char *arg = Tcl_GetStringFromObj(objv[2], &length);
 
 #define ArgPfxEq(str) \
 	((arg[0] == str[0]) && !strncmp(arg, str, length))
 
     if (ArgPfxEq("moveto")) {
@@ -757,11 +757,11 @@
 	*intPtr = (d >= 0) ? ceil(d) : floor(d);
 	if (dblPtr) {
 	    *dblPtr = d;
 	}
 
-	arg = TkGetStringFromObj(objv[4], &length);
+	arg = Tcl_GetStringFromObj(objv[4], &length);
 	if (ArgPfxEq("pages")) {
 	    return TK_SCROLL_PAGES;
 	} else if (ArgPfxEq("units")) {
 	    return TK_SCROLL_UNITS;
 	}
@@ -818,21 +818,21 @@
     case TK_ANCHOR_W:
     case TK_ANCHOR_SW:
 	*xPtr = Tk_InternalBorderLeft(tkwin) + padX;
 	break;
 
-    case TK_ANCHOR_N:
-    case TK_ANCHOR_CENTER:
-    case TK_ANCHOR_S:
-	*xPtr = (Tk_Width(tkwin) - innerWidth - Tk_InternalBorderLeft(tkwin) -
-		Tk_InternalBorderRight(tkwin)) / 2 +
-		Tk_InternalBorderLeft(tkwin);
+    case TK_ANCHOR_NE:
+    case TK_ANCHOR_E:
+    case TK_ANCHOR_SE:
+	*xPtr = Tk_Width(tkwin) - Tk_InternalBorderRight(tkwin) - padX
+		- innerWidth;
 	break;
 
     default:
-	*xPtr = Tk_Width(tkwin) - Tk_InternalBorderRight(tkwin) - padX
-		- innerWidth;
+	*xPtr = (Tk_Width(tkwin) - innerWidth - Tk_InternalBorderLeft(tkwin) -
+		Tk_InternalBorderRight(tkwin)) / 2 +
+		Tk_InternalBorderLeft(tkwin);
 	break;
     }
 
     /*
      * Handle the vertical parts.
@@ -843,21 +843,21 @@
     case TK_ANCHOR_N:
     case TK_ANCHOR_NE:
 	*yPtr = Tk_InternalBorderTop(tkwin) + padY;
 	break;
 
-    case TK_ANCHOR_W:
-    case TK_ANCHOR_CENTER:
-    case TK_ANCHOR_E:
-	*yPtr = (Tk_Height(tkwin) - innerHeight- Tk_InternalBorderTop(tkwin) -
-		Tk_InternalBorderBottom(tkwin)) / 2 +
-		Tk_InternalBorderTop(tkwin);
+    case TK_ANCHOR_SW:
+    case TK_ANCHOR_S:
+    case TK_ANCHOR_SE:
+	*yPtr = Tk_Height(tkwin) - Tk_InternalBorderBottom(tkwin) - padY
+		- innerHeight;
 	break;
 
     default:
-	*yPtr = Tk_Height(tkwin) - Tk_InternalBorderBottom(tkwin) - padY
-		- innerHeight;
+	*yPtr = (Tk_Height(tkwin) - innerHeight- Tk_InternalBorderTop(tkwin) -
+		Tk_InternalBorderBottom(tkwin)) / 2 +
+		Tk_InternalBorderTop(tkwin);
 	break;
     }
 }
 
 /*
@@ -1190,15 +1190,17 @@
     event.general.xany.send_event = False;
     event.general.xany.window = Tk_WindowId(target);
     event.general.xany.display = Tk_Display(target);
     event.virt.name = Tk_GetUid(eventName);
     event.virt.user_data = detail;
+    if (detail) Tcl_IncrRefCount(detail); // Event code will DecrRefCount
 
     Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
 }
 
-#if TCL_UTF_MAX <= 4
+/* Tcl 8.6 has a different definition of Tcl_UniChar than other Tcl versions for TCL_UTF_MAX > 3 */
+#if TCL_UTF_MAX <= (3 + (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 6))
 /*
  *---------------------------------------------------------------------------
  *
  * TkUtfToUniChar --
  *
@@ -1223,19 +1225,14 @@
 			 * the UTF-8 string. */
 {
     Tcl_UniChar uniChar = 0;
 
     size_t len = Tcl_UtfToUniChar(src, &uniChar);
-    if ((sizeof(Tcl_UniChar) == 2)
-	    && ((uniChar & 0xFC00) == 0xD800)
-#if TCL_MAJOR_VERSION > 8
-	    && (len == 1)
-#endif
-	) {
+    if ((uniChar & 0xFC00) == 0xD800) {
 	Tcl_UniChar low = uniChar;
-	/* This can only happen if Tcl is compiled with TCL_UTF_MAX=4,
-	 * or when a high surrogate character is detected in UTF-8 form */
+	/* This can only happen if sizeof(Tcl_UniChar)== 2 and src points
+	 * to a character > U+FFFF  */
 	size_t len2 = Tcl_UtfToUniChar(src+len, &low);
 	if ((low & 0xFC00) == 0xDC00) {
 	    *chPtr = (((uniChar & 0x3FF) << 10) | (low & 0x3FF)) + 0x10000;
 	    return len + len2;
 	}
@@ -1263,72 +1260,21 @@
  *---------------------------------------------------------------------------
  */
 
 size_t TkUniCharToUtf(int ch, char *buf)
 {
-    if ((sizeof(Tcl_UniChar) == 2) && (((unsigned)(ch - 0x10000) <= 0xFFFFF))) {
+    if ((unsigned)(ch - 0x10000) <= 0xFFFFF) {
 	/* Spit out a 4-byte UTF-8 character or 2 x 3-byte UTF-8 characters, depending on Tcl
 	 * version and/or TCL_UTF_MAX build value */
 	int len = Tcl_UniCharToUtf(0xD800 | ((ch - 0x10000) >> 10), buf);
 	return len + Tcl_UniCharToUtf(0xDC00 | (ch & 0x7FF), buf + len);
     }
     return Tcl_UniCharToUtf(ch, buf);
 }
-/*
- *---------------------------------------------------------------------------
- *
- * TkUtfPrev --
- *
- *	Almost the same as Tcl_UtfPrev.
- *	This function is capable of jumping over a upper/lower surrogate pair.
- *	So, might jump back up to 6 bytes.
- *
- * Results:
- *	pointer to the first byte of the current UTF-8 character. A surrogate
- *	pair is also handled as being a single entity.
- *
- * Side effects:
- *	None.
- *
- *---------------------------------------------------------------------------
- */
-
-const char *
-TkUtfPrev(
-    const char *src,	/* The UTF-8 string. */
-    const char *start)		/* Start position of string */
-{
-    const char *p = Tcl_UtfPrev(src, start);
-    const char *first = Tcl_UtfPrev(p, start);
-    int ch;
-
-#if TCL_UTF_MAX == 3
-    if ((src - start > 3) && ((src[-1] & 0xC0) == 0x80) && ((src[-2] & 0xC0) == 0x80)
-	    && ((src[-3] & 0xC0) == 0x80) && (UCHAR(src[-4]) >= 0xF0)) {
-	return src - 4;
-    }
-#endif
-
-    return (first + TkUtfToUniChar(first, &ch) >= src) ? first : p ;
-}
-
-#endif
-
-#if TCL_MAJOR_VERSION > 8
-unsigned char *
-TkGetByteArrayFromObj(
-	Tcl_Obj *objPtr,
-	size_t *lengthPtr
-) {
-    unsigned char *result = Tcl_GetByteArrayFromObj(objPtr, NULL);
-    *lengthPtr = *(size_t *) objPtr->internalRep.twoPtrValue.ptr1;
-    return result;
-}
-#endif /* TCL_MAJOR_VERSION > 8 */
-
+#endif
 /*
  * Local Variables:
  * mode: c
  * c-basic-offset: 4
  * fill-column: 78
  * End:
  */

Index: generic/tkVisual.c
==================================================================
--- generic/tkVisual.c
+++ generic/tkVisual.c
@@ -3,12 +3,12 @@
  *
  *	This file contains library procedures for allocating and freeing
  *	visuals and colormaps. This code is based on a prototype
  *	implementation by Paul Mackerras.
  *
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: generic/tkWindow.c
==================================================================
--- generic/tkWindow.c
+++ generic/tkWindow.c
@@ -3,12 +3,12 @@
  *
  *	This file provides basic window-manipulation functions, which are
  *	equivalent to functions in Xlib (and even invoke them) but also
  *	maintain the local Tk_Window structure.
  *
- * Copyright (c) 1989-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1989-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -17,10 +17,11 @@
 #ifdef _WIN32
 #include "tkWinInt.h"
 #elif !defined(MAC_OSX_TK)
 #include "tkUnixInt.h"
 #endif
+#include "tkUuid.h"
 
 /*
  * Type used to keep track of Window objects that were only partially
  * deallocated by Tk_DestroyWindow.
  */
@@ -91,12 +92,13 @@
 
 #define ISSAFE 1
 #define PASSMAINWINDOW 2
 #define WINMACONLY 4
 #define USEINITPROC 8
+#define SAVEUPDATECMD 16 /* better only be one of these! */
 
-typedef int (TkInitProc)(Tcl_Interp *interp, ClientData clientData);
+typedef int (TkInitProc)(Tcl_Interp *interp, void *clientData);
 typedef struct {
     const char *name;		/* Name of command. */
     Tcl_ObjCmdProc *objProc;	/* Command's object- (or string-) based
 				 * function, or initProc. */
     int flags;
@@ -124,11 +126,11 @@
     {"place",		Tk_PlaceObjCmd,		PASSMAINWINDOW|ISSAFE},
     {"raise",		Tk_RaiseObjCmd,		PASSMAINWINDOW|ISSAFE},
     {"selection",	Tk_SelectionObjCmd,	PASSMAINWINDOW},
     {"tk",		(Tcl_ObjCmdProc *)(void *)TkInitTkCmd,  USEINITPROC|PASSMAINWINDOW|ISSAFE},
     {"tkwait",		Tk_TkwaitObjCmd,	PASSMAINWINDOW|ISSAFE},
-    {"update",		Tk_UpdateObjCmd,	PASSMAINWINDOW|ISSAFE},
+    {"update",		Tk_UpdateObjCmd,	PASSMAINWINDOW|ISSAFE|SAVEUPDATECMD},
     {"winfo",		Tk_WinfoObjCmd,		PASSMAINWINDOW|ISSAFE},
     {"wm",		Tk_WmObjCmd,		PASSMAINWINDOW},
 
     /*
      * Default widget class commands.
@@ -204,11 +206,11 @@
  */
 
 static Tk_Window	CreateTopLevelWindow(Tcl_Interp *interp,
 			    Tk_Window parent, const char *name,
 			    const char *screenName, unsigned int flags);
-static void		DeleteWindowsExitProc(ClientData clientData);
+static void		DeleteWindowsExitProc(void *clientData);
 static TkDisplay *	GetScreen(Tcl_Interp *interp, const char *screenName,
 			    int *screenPtr);
 static int		Initialize(Tcl_Interp *interp);
 static int		NameWindow(Tcl_Interp *interp, TkWindow *winPtr,
 			    TkWindow *parentPtr, const char *name);
@@ -332,13 +334,13 @@
 
 	/*
 	 * Create built-in photo image formats.
 	 */
 
-        Tk_CreatePhotoImageFormat(&tkImgFmtDefault);
-	Tk_CreatePhotoImageFormat(&tkImgFmtGIF);
-	Tk_CreatePhotoImageFormat(&tkImgFmtPNG);
+	Tk_CreatePhotoImageFormat(&tkImgFmtDefault);
+	Tk_CreatePhotoImageFormatVersion3(&tkImgFmtGIF);
+	Tk_CreatePhotoImageFormatVersion3(&tkImgFmtPNG);
 	Tk_CreatePhotoImageFormat(&tkImgFmtPPM);
 	Tk_CreatePhotoImageFormat(&tkImgFmtSVGnano);
     }
 
     if ((parent != NULL) && (screenName != NULL) && (screenName[0] == '\0')) {
@@ -654,11 +656,11 @@
     winPtr->handlerList = NULL;
     winPtr->ximGeneration = 0;
     winPtr->inputContext = NULL;
     winPtr->tagPtr = NULL;
     winPtr->numTags = 0;
-    winPtr->optionLevel = -1;
+    winPtr->optionLevel = TCL_INDEX_NONE;
     winPtr->selHandlerList = NULL;
     winPtr->geomMgrPtr = NULL;
     winPtr->geomData = NULL;
     winPtr->geomMgrName = NULL;
     winPtr->maintainerPtr = NULL;
@@ -813,10 +815,15 @@
  *	necessary to make it globally unique. Tk-related commands are bound
  *	into interp.
  *
  *----------------------------------------------------------------------
  */
+
+#ifndef STRINGIFY
+#  define STRINGIFY(x) STRINGIFY1(x)
+#  define STRINGIFY1(x) #x
+#endif
 
 Tk_Window
 TkCreateMainWindow(
     Tcl_Interp *interp,		/* Interpreter to use for error reporting. */
     const char *screenName,	/* Name of screen on which to create window.
@@ -829,11 +836,12 @@
     int dummy, isSafe;
     Tcl_HashEntry *hPtr;
     TkMainInfo *mainPtr;
     TkWindow *winPtr;
     const TkCmd *cmdPtr;
-    ClientData clientData;
+    void *clientData;
+    Tcl_CmdInfo info;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
 
     /*
      * Panic if someone updated the TkWindow structure without also updating
@@ -874,10 +882,14 @@
     mainPtr->displayFocusPtr = NULL;
     mainPtr->optionRootPtr = NULL;
     Tcl_InitHashTable(&mainPtr->imageTable, TCL_STRING_KEYS);
     mainPtr->strictMotif = 0;
     mainPtr->alwaysShowSelection = 0;
+    mainPtr->tclUpdateObjProc = NULL;
+#if TCL_MAJOR_VERSION > 8
+    mainPtr->tclUpdateObjProc2 = NULL;
+#endif
     if (Tcl_LinkVar(interp, "tk_strictMotif", (char *) &mainPtr->strictMotif,
 	    TCL_LINK_BOOLEAN) != TCL_OK) {
 	Tcl_ResetResult(interp);
     }
     if (Tcl_CreateNamespace(interp, "::tk", NULL, NULL) == NULL) {
@@ -913,16 +925,18 @@
      * Bind in Tk's commands.
      */
 
     isSafe = Tcl_IsSafe(interp);
     for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) {
+	Tcl_CmdInfo cmdInfo;
+
 	if (cmdPtr->objProc == NULL) {
 	    Tcl_Panic("TkCreateMainWindow: builtin command with NULL string and object procs");
 	}
 
 #if defined(_WIN32) && !defined(STATIC_BUILD)
-	if ((cmdPtr->flags & WINMACONLY) && tclStubsPtr->reserved9) {
+	if ((cmdPtr->flags & WINMACONLY) && tclStubsPtr->tcl_CreateFileHandler) {
 	    /*
 	     * We are running on Cygwin, so don't use the win32 dialogs.
 	     */
 
 	    continue;
@@ -931,10 +945,22 @@
 
 	if (cmdPtr->flags & PASSMAINWINDOW) {
 	    clientData = tkwin;
 	} else {
 	    clientData = NULL;
+	}
+	if ((cmdPtr->flags & SAVEUPDATECMD) &&
+	    Tcl_GetCommandInfo(interp, cmdPtr->name, &cmdInfo) &&
+	    cmdInfo.isNativeObjectProc && !cmdInfo.deleteProc) {
+#if TCL_MAJOR_VERSION > 8
+	    if ((cmdInfo.isNativeObjectProc == 2) && !cmdInfo.objClientData2) {
+		mainPtr->tclUpdateObjProc2 = cmdInfo.objProc2;
+	    } else
+#endif
+	    if (!cmdInfo.objClientData ) {
+		mainPtr->tclUpdateObjProc = cmdInfo.objProc;
+	    }
 	}
 	if (cmdPtr->flags & USEINITPROC) {
 	    ((TkInitProc *)(void *)cmdPtr->objProc)(interp, clientData);
 	} else {
 	    Tcl_CreateObjCommand(interp, cmdPtr->name, cmdPtr->objProc,
@@ -941,10 +967,93 @@
 		    clientData, NULL);
 	}
 	if (isSafe && !(cmdPtr->flags & ISSAFE)) {
 	    Tcl_HideCommand(interp, cmdPtr->name, cmdPtr->name);
 	}
+    }
+    if (Tcl_GetCommandInfo(interp, "::tcl::build-info", &info)) {
+	static const char version[] = TK_PATCH_LEVEL "+" STRINGIFY(TK_VERSION_UUID)
+#if defined(MAC_OSX_TK)
+		".aqua"
+#endif
+#if defined(__clang__) && defined(__clang_major__)
+		".clang-" STRINGIFY(__clang_major__)
+#if __clang_minor__ < 10
+		"0"
+#endif
+		STRINGIFY(__clang_minor__)
+#endif
+#if defined(__cplusplus) && !defined(__OBJC__)
+		".cplusplus"
+#endif
+#ifndef NDEBUG
+		".debug"
+#endif
+#if !defined(__clang__) && !defined(__INTEL_COMPILER) && defined(__GNUC__)
+		".gcc-" STRINGIFY(__GNUC__)
+#if __GNUC_MINOR__ < 10
+		"0"
+#endif
+		STRINGIFY(__GNUC_MINOR__)
+#endif
+#ifdef __INTEL_COMPILER
+		".icc-" STRINGIFY(__INTEL_COMPILER)
+#endif
+#ifdef TCL_MEM_DEBUG
+		".memdebug"
+#endif
+#if defined(_MSC_VER)
+		".msvc-" STRINGIFY(_MSC_VER)
+#endif
+#ifdef USE_NMAKE
+		".nmake"
+#endif
+#ifdef TK_NO_DEPRECATED
+		".no-deprecate"
+#endif
+#ifndef TCL_CFG_OPTIMIZED
+		".no-optimize"
+#endif
+#ifdef __OBJC__
+		".objective-c"
+#if defined(__cplusplus)
+		"plusplus"
+#endif
+#endif
+#ifdef TCL_CFG_PROFILED
+		".profile"
+#endif
+#ifdef PURIFY
+		".purify"
+#endif
+#ifdef STATIC_BUILD
+		".static"
+#endif
+#if TCL_UTF_MAX <= (3 + (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 6))
+		".utf-16"
+#endif
+#if defined(_WIN32)
+		".win32"
+#endif
+#if !defined(_WIN32) && !defined(MAC_OSX_TK)
+		".x11"
+#if !defined(HAVE_XFT)
+		".no-xft"
+#endif
+#endif
+		;
+#if TCL_MAJOR_VERSION > 8
+	if (info.isNativeObjectProc == 2) {
+	    Tcl_CreateObjCommand2(interp, "::tk::build-info",
+		    info.objProc2, (void *)
+		    version, NULL);
+
+	} else
+#endif
+	Tcl_CreateObjCommand(interp, "::tk::build-info",
+		info.objProc, (void *)
+		version, NULL);
     }
 
     /*
      * Set variables for the interpreter.
      */
@@ -1230,11 +1339,11 @@
 
 void
 Tk_DestroyWindow(
     Tk_Window tkwin)		/* Window to destroy. */
 {
-    TkWindow *winPtr = (TkWindow *) tkwin;
+    TkWindow *winPtr = (TkWindow *)tkwin;
     TkDisplay *dispPtr = winPtr->dispPtr;
     XEvent event;
     TkHalfdeadWindow *halfdeadPtr, *prev_halfdeadPtr;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -1266,11 +1375,11 @@
 	tsdPtr->halfdeadWindowList = halfdeadPtr;
     }
 
     /*
      * Some cleanup needs to be done immediately, rather than later, because
-     * it needs information that will be destoyed before we get to the main
+     * it needs information that will be destroyed before we get to the main
      * cleanup point. For example, TkFocusDeadWindow needs to access the
      * parentPtr field from a window, but if a Destroy event handler deletes
      * the window's parent this field will be NULL before the main cleanup
      * point is reached.
      */
@@ -1347,14 +1456,14 @@
 	 * application is also in this process. Delete the embedded window
 	 * in-line here, for the same reasons we delete children in-line
 	 * (otherwise, for example, the Tk window may appear to exist even
 	 * though its X window is gone; this could cause errors). Special
 	 * note: it's possible that the embedded window has already been
-	 * deleted, in which case TkpGetOtherWindow will return NULL.
+	 * deleted, in which case Tk_GetOtherWindow will return NULL.
 	 */
 
-	TkWindow *childPtr = TkpGetOtherWindow(winPtr);
+	TkWindow *childPtr = (TkWindow *)Tk_GetOtherWindow(tkwin);
 
 	if (childPtr != NULL) {
 	    childPtr->flags |= TK_DONT_DESTROY_WINDOW;
 	    Tk_DestroyWindow((Tk_Window) childPtr);
 	}
@@ -1494,14 +1603,33 @@
 	     * being deleted. If it *is*, the interpreter cleanup will do all
 	     * the needed work.
 	     */
 
 	    if ((winPtr->mainPtr->interp != NULL) &&
-		    !Tcl_InterpDeleted(winPtr->mainPtr->interp)) {
+		!Tcl_InterpDeleted(winPtr->mainPtr->interp)) {
 		for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) {
-		    Tcl_CreateObjCommand(winPtr->mainPtr->interp, cmdPtr->name,
-			    TkDeadAppObjCmd, NULL, NULL);
+		    if (cmdPtr->flags & SAVEUPDATECMD) {
+			/* Restore Tcl's version of [update] */
+#if TCL_MAJOR_VERSION > 8
+			if (winPtr->mainPtr->tclUpdateObjProc2 != NULL) {
+			    Tcl_CreateObjCommand2(winPtr->mainPtr->interp,
+				    cmdPtr->name,
+				    winPtr->mainPtr->tclUpdateObjProc2,
+				    NULL, NULL);
+			} else
+#endif
+			if (winPtr->mainPtr->tclUpdateObjProc != NULL) {
+			    Tcl_CreateObjCommand(winPtr->mainPtr->interp,
+				    cmdPtr->name,
+				    winPtr->mainPtr->tclUpdateObjProc,
+				    NULL, NULL);
+			}
+		    } else {
+			Tcl_CreateObjCommand(winPtr->mainPtr->interp,
+					     cmdPtr->name, TkDeadAppObjCmd,
+					     NULL, NULL);
+		    }
 		}
 		Tcl_CreateObjCommand(winPtr->mainPtr->interp, "send",
 			TkDeadAppObjCmd, NULL, NULL);
 		Tcl_UnlinkVar(winPtr->mainPtr->interp, "tk_strictMotif");
 		Tcl_UnlinkVar(winPtr->mainPtr->interp,
@@ -1640,11 +1768,11 @@
     event.xmap.send_event = False;
     event.xmap.display = winPtr->display;
     event.xmap.event = winPtr->window;
     event.xmap.window = winPtr->window;
     event.xmap.override_redirect = winPtr->atts.override_redirect;
-    TkpHandleMapOrUnmap((Tk_Window)winPtr, &event);
+    Tk_HandleEvent(&event);
 }
 
 /*
  *--------------------------------------------------------------
  *
@@ -1691,11 +1819,11 @@
 
     createProc = Tk_GetClassProc(winPtr->classProcsPtr, createProc);
     if (createProc != NULL && parent != None) {
 	winPtr->window = createProc(tkwin, parent, winPtr->instanceData);
     } else {
-	winPtr->window = TkpMakeWindow(winPtr, parent);
+	winPtr->window = Tk_MakeWindow(tkwin, parent);
     }
 
     hPtr = Tcl_CreateHashEntry(&winPtr->dispPtr->winTable,
 	    (char *) winPtr->window, &isNew);
     Tcl_SetHashValue(hPtr, winPtr);
@@ -1802,11 +1930,11 @@
 	event.xunmap.send_event = False;
 	event.xunmap.display = winPtr->display;
 	event.xunmap.event = winPtr->window;
 	event.xunmap.window = winPtr->window;
 	event.xunmap.from_configure = False;
-	TkpHandleMapOrUnmap((Tk_Window)winPtr, &event);
+	Tk_HandleEvent(&event);
     }
 }
 
 void
 Tk_ConfigureWindow(
@@ -2247,11 +2375,11 @@
 
 void
 Tk_SetClassProcs(
     Tk_Window tkwin,		/* Token for window to modify. */
     const Tk_ClassProcs *procs,	/* Class procs structure. */
-    ClientData instanceData)	/* Data to be passed to class functions. */
+    void *instanceData)	/* Data to be passed to class functions. */
 {
     TkWindow *winPtr = (TkWindow *) tkwin;
 
     winPtr->classProcsPtr = procs;
     winPtr->instanceData = instanceData;
@@ -2736,11 +2864,11 @@
  *----------------------------------------------------------------------
  */
 
 static void
 DeleteWindowsExitProc(
-    ClientData clientData)	/* tsdPtr when handler was created. */
+    void *clientData)	/* tsdPtr when handler was created. */
 {
     TkDisplay *dispPtr, *nextPtr;
     Tcl_Interp *interp;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)clientData;
 
@@ -2842,11 +2970,11 @@
     WCHAR name[MAX_PATH];
     size_t len;
     void (*tkmainex)(int, char **, Tcl_AppInitProc *, Tcl_Interp *);
 
     /* construct "<path>/libtk8.?.dll", from "<path>/tk8?.dll" */
-    len = GetModuleFileNameW(Tk_GetHINSTANCE(), name, MAX_PATH);
+    len = GetModuleFileNameW((HINSTANCE)Tk_GetHINSTANCE(), name, MAX_PATH);
     name[len-2] = '.';
     name[len-1] = name[len-5];
     wcscpy(name+len, L".dll");
     memcpy(name+len-8, L"libtk8", 6 * sizeof(WCHAR));
 
@@ -2999,16 +3127,14 @@
  *----------------------------------------------------------------------
  */
 
 static int
 CopyValue(
-    ClientData dummy,
+    TCL_UNUSED(void *),
     Tcl_Obj *objPtr,
     void *dstPtr)
 {
-    (void)dummy;
-
     *(Tcl_Obj **)dstPtr = objPtr;
     return 1;
 }
 
 static int
@@ -3148,11 +3274,11 @@
 
 	value = Tcl_GetVar2Ex(interp, "argv", NULL, TCL_GLOBAL_ONLY);
     }
 
     if (value) {
-	int objc;
+	TkSizeT objc;
 	Tcl_Obj **objv, **rest;
 	Tcl_Obj *parseList = Tcl_NewListObj(1, NULL);
 
 	Tcl_ListObjAppendElement(NULL, parseList, Tcl_NewObj());
 
@@ -3199,11 +3325,11 @@
      * The -class argument is always the ToTitle of the -name
      */
 
     {
 	TkSizeT numBytes;
-	const char *bytes = TkGetStringFromObj(nameObj, &numBytes);
+	const char *bytes = Tcl_GetStringFromObj(nameObj, &numBytes);
 
 	classObj = Tcl_NewStringObj(bytes, numBytes);
 
 	numBytes = Tcl_UtfToTitle(Tcl_GetString(classObj));
 	Tcl_SetObjLength(classObj, numBytes);
@@ -3281,15 +3407,19 @@
 	    goto done;
 	}
     }
 
     /*
-     * Provide Tk and its stub table.
+     * Provide "tk" and its stub table.
      */
 
-    code = Tcl_PkgProvideEx(interp, "Tk", TK_PATCH_LEVEL,
-	    (ClientData) &tkStubs);
+#ifndef TK_NO_DEPRECATED
+    Tcl_PkgProvideEx(interp, "Tk", TK_PATCH_LEVEL,
+	    (void *)&tkStubs);
+#endif
+    code = Tcl_PkgProvideEx(interp, "tk", TK_PATCH_LEVEL,
+	    (void *)&tkStubs);
     if (code != TCL_OK) {
 	goto done;
     }
 
     /*
@@ -3379,11 +3509,11 @@
 Tk_PkgInitStubsCheck(
     Tcl_Interp *interp,
     const char * version,
     int exact)
 {
-    const char *actualVersion = Tcl_PkgRequireEx(interp, "Tk", version, 0, NULL);
+    const char *actualVersion = Tcl_PkgRequireEx(interp, "tk", version, 0, NULL);
 
     if (exact && actualVersion) {
 	const char *p = version;
 	int count = 0;
 
@@ -3391,15 +3521,15 @@
 	    count += !isdigit(UCHAR(*p++));
 	}
 	if (count == 1) {
 	    if (0 != strncmp(version, actualVersion, strlen(version))) {
 		/* Construct error message */
-		Tcl_PkgPresentEx(interp, "Tk", version, 1, NULL);
+		Tcl_PkgPresentEx(interp, "tk", version, 1, NULL);
 		return NULL;
 	    }
 	} else {
-	    return Tcl_PkgPresentEx(interp, "Tk", version, 1, NULL);
+	    return Tcl_PkgPresentEx(interp, "tk", version, 1, NULL);
 	}
     }
     return actualVersion;
 }
 

Index: generic/ttk/ttkButton.c
==================================================================
--- generic/ttk/ttkButton.c
+++ generic/ttk/ttkButton.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, Joe English
+ * Copyright © 2003, Joe English
  *
  * label, button, checkbutton, radiobutton, and menubutton widgets.
  */
 
 #include "tkInt.h"
@@ -22,11 +22,11 @@
      * Text element resources:
      */
     Tcl_Obj *textObj;
     Tcl_Obj *justifyObj;
     Tcl_Obj *textVariableObj;
-    Tcl_Obj *underlineObj;
+    int underline;
     Tcl_Obj *widthObj;
 
     Ttk_TraceHandle	*textVariableTrace;
     Ttk_ImageSpec	*imageSpec;
 
@@ -55,21 +55,20 @@
 } Base;
 
 static const Tk_OptionSpec BaseOptionSpecs[] =
 {
     {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
-        "left", offsetof(Base,base.justifyObj), TCL_INDEX_NONE,
-        TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
+	"left", offsetof(Base,base.justifyObj), TCL_INDEX_NONE,
+	TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
     {TK_OPTION_STRING, "-text", "text", "Text", "",
 	offsetof(Base,base.textObj), TCL_INDEX_NONE,
 	0,0,GEOMETRY_CHANGED },
     {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", "",
 	offsetof(Base,base.textVariableObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
-    {TK_OPTION_INT, "-underline", "underline", "Underline",
-	"-1", offsetof(Base,base.underlineObj), TCL_INDEX_NONE,
-	0,0,0 },
+    {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+	TK_OPTION_UNDERLINE_DEF(Base, base.underline), 0},
     /* SB: OPTION_INT, see <<NOTE-NULLOPTIONS>> */
     {TK_OPTION_STRING, "-width", "width", "Width",
 	NULL, offsetof(Base,base.widthObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
 
@@ -82,23 +81,23 @@
 
     /*
      * Compound base/image options
      */
     {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
-	 NULL, offsetof(Base,base.compoundObj), TCL_INDEX_NONE,
-	 TK_OPTION_NULL_OK, (void *)ttkCompoundStrings,
-         GEOMETRY_CHANGED },
+	NULL, offsetof(Base,base.compoundObj), TCL_INDEX_NONE,
+	TK_OPTION_NULL_OK, ttkCompoundStrings,
+	GEOMETRY_CHANGED },
     {TK_OPTION_STRING, "-padding", "padding", "Pad",
 	NULL, offsetof(Base,base.paddingObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED},
 
     /*
      * Compatibility/legacy options
      */
     {TK_OPTION_STRING, "-state", "state", "State",
-	 "normal", offsetof(Base,base.stateObj), TCL_INDEX_NONE,
-	 0,0,STATE_CHANGED },
+	"normal", offsetof(Base,base.stateObj), TCL_INDEX_NONE,
+	0,0,STATE_CHANGED },
 
     WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
 };
 
 /*
@@ -257,29 +256,30 @@
 	TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
     {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
 	NULL, offsetof(Label,label.reliefObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
     {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
-	NULL, offsetof(Label,label.anchorObj), TCL_INDEX_NONE,
-	TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED},
+	"w", offsetof(Label,label.anchorObj), TCL_INDEX_NONE,
+	0, 0, GEOMETRY_CHANGED},
     {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
-	NULL, offsetof(Label, label.justifyObj), TCL_INDEX_NONE,
-	TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
+	"left", offsetof(Label, label.justifyObj), TCL_INDEX_NONE,
+	0,0,GEOMETRY_CHANGED },
     {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
 	NULL, offsetof(Label, label.wrapLengthObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED /*SB: SIZE_CHANGED*/ },
 
     WIDGET_TAKEFOCUS_FALSE,
     WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
 };
 
 static const Ttk_Ensemble LabelCommands[] = {
-    { "configure",	TtkWidgetConfigureCommand,0 },
     { "cget",		TtkWidgetCgetCommand,0 },
+    { "configure",	TtkWidgetConfigureCommand,0 },
+    { "identify",	TtkWidgetIdentifyCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
-    { "identify",	TtkWidgetIdentifyCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { 0,0,0 }
 };
 
 static const WidgetSpec LabelWidgetSpec =
 {
@@ -328,11 +328,11 @@
 {
     {TK_OPTION_STRING, "-command", "command", "Command",
 	"", offsetof(Button, button.commandObj), TCL_INDEX_NONE, 0,0,0},
     {TK_OPTION_STRING_TABLE, "-default", "default", "Default",
 	"normal", offsetof(Button, button.defaultStateObj), TCL_INDEX_NONE,
-	0, (void *)ttkDefaultStrings, DEFAULTSTATE_CHANGED},
+	0, ttkDefaultStrings, DEFAULTSTATE_CHANGED},
 
     WIDGET_TAKEFOCUS_TRUE,
     WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
 };
 
@@ -376,16 +376,17 @@
     }
     return Tcl_EvalObjEx(interp, buttonPtr->button.commandObj, TCL_EVAL_GLOBAL);
 }
 
 static const Ttk_Ensemble ButtonCommands[] = {
-    { "configure",	TtkWidgetConfigureCommand,0 },
     { "cget",		TtkWidgetCgetCommand,0 },
-    { "invoke",		ButtonInvokeCommand,0 },
+    { "configure",	TtkWidgetConfigureCommand,0 },
+    { "identify",	TtkWidgetIdentifyCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
+    { "invoke",		ButtonInvokeCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
-    { "identify",	TtkWidgetIdentifyCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { 0,0,0 }
 };
 
 static const WidgetSpec ButtonWidgetSpec =
 {
@@ -583,16 +584,17 @@
     return Tcl_EvalObjEx(interp,
 	checkPtr->checkbutton.commandObj, TCL_EVAL_GLOBAL);
 }
 
 static const Ttk_Ensemble CheckbuttonCommands[] = {
-    { "configure",	TtkWidgetConfigureCommand,0 },
     { "cget",		TtkWidgetCgetCommand,0 },
-    { "invoke",		CheckbuttonInvokeCommand,0 },
+    { "configure",	TtkWidgetConfigureCommand,0 },
+    { "identify",	TtkWidgetIdentifyCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
+    { "invoke",		CheckbuttonInvokeCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
-    { "identify",	TtkWidgetIdentifyCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     /* MISSING: select, deselect, toggle */
     { 0,0,0 }
 };
 
 static const WidgetSpec CheckbuttonWidgetSpec =
@@ -759,16 +761,17 @@
     return Tcl_EvalObjEx(interp,
 	radioPtr->radiobutton.commandObj, TCL_EVAL_GLOBAL);
 }
 
 static const Ttk_Ensemble RadiobuttonCommands[] = {
-    { "configure",	TtkWidgetConfigureCommand,0 },
     { "cget",		TtkWidgetCgetCommand,0 },
-    { "invoke",		RadiobuttonInvokeCommand,0 },
+    { "configure",	TtkWidgetConfigureCommand,0 },
+    { "identify",	TtkWidgetIdentifyCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
+    { "invoke",		RadiobuttonInvokeCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
-    { "identify",	TtkWidgetIdentifyCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     /* MISSING: select, deselect */
     { 0,0,0 }
 };
 
 static const WidgetSpec RadiobuttonWidgetSpec =
@@ -821,11 +824,11 @@
 {
     {TK_OPTION_STRING, "-menu", "menu", "Menu",
 	"", offsetof(Menubutton, menubutton.menuObj), TCL_INDEX_NONE, 0,0,0},
     {TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction",
 	"below", offsetof(Menubutton, menubutton.directionObj), TCL_INDEX_NONE,
-	0, (void *)directionStrings, GEOMETRY_CHANGED},
+	0, directionStrings, GEOMETRY_CHANGED},
 
     WIDGET_TAKEFOCUS_TRUE,
     WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
 };
 
@@ -833,10 +836,11 @@
     { "configure",	TtkWidgetConfigureCommand,0 },
     { "cget",		TtkWidgetCgetCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
     { "identify",	TtkWidgetIdentifyCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { 0,0,0 }
 };
 
 static const WidgetSpec MenubuttonWidgetSpec =
 {

Index: generic/ttk/ttkCache.c
==================================================================
--- generic/ttk/ttkCache.c
+++ generic/ttk/ttkCache.c
@@ -1,9 +1,9 @@
 /*
  *      Theme engine resource cache.
  *
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004, Joe English
  *
  * The problem:
  *
  * Tk maintains reference counts for fonts, colors, and images,
  * and deallocates them when the reference count goes to zero.

Index: generic/ttk/ttkClamTheme.c
==================================================================
--- generic/ttk/ttkClamTheme.c
+++ generic/ttk/ttkClamTheme.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (C) 2004 Joe English
+ * Copyright © 2004 Joe English
  *
  * "clam" theme; inspired by the XFCE family of Gnome themes.
  */
 
 #include "tkInt.h"

Index: generic/ttk/ttkClassicTheme.c
==================================================================
--- generic/ttk/ttkClassicTheme.c
+++ generic/ttk/ttkClassicTheme.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004, Joe English
  *
  * "classic" theme; implements the classic Motif-like Tk look.
  *
  */
 

Index: generic/ttk/ttkDecls.h
==================================================================
--- generic/ttk/ttkDecls.h
+++ generic/ttk/ttkDecls.h
@@ -11,11 +11,15 @@
 	Tcl_Interp *, const char *version, int epoch, int revision);
 #define Ttk_InitStubs(interp) TtkInitializeStubs( \
 	interp, TTK_VERSION, TTK_STUBS_EPOCH, TTK_STUBS_REVISION)
 #else
 
-#define Ttk_InitStubs(interp) Tcl_PkgRequireEx(interp, "Ttk", TTK_VERSION, 0, NULL)
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
+#   define Ttk_InitStubs(interp) Tcl_PkgRequireEx(interp, "Ttk", TTK_VERSION, 0, NULL)
+#else
+#   define Ttk_InitStubs(interp) Tcl_PkgRequireEx(interp, "ttk", TTK_VERSION, 0, NULL)
+#endif
 
 #endif
 
 #if !defined(BUILD_tk)
 # define TTK_DEPRECATED(msg) TTKAPI TCL_DEPRECATED_API(msg)

Index: generic/ttk/ttkDefaultTheme.c
==================================================================
--- generic/ttk/ttkDefaultTheme.c
+++ generic/ttk/ttkDefaultTheme.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, Joe English
+ * Copyright © 2003 Joe English
  *
  * Tk alternate theme, intended to match the MSUE and Gtk's (old) default theme
  */
 
 #include "tkInt.h"

Index: generic/ttk/ttkElements.c
==================================================================
--- generic/ttk/ttkElements.c
+++ generic/ttk/ttkElements.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, Joe English
+ * Copyright © 2003 Joe English
  *
  * Default implementation for themed elements.
  *
  */
 

Index: generic/ttk/ttkEntry.c
==================================================================
--- generic/ttk/ttkEntry.c
+++ generic/ttk/ttkEntry.c
@@ -1,13 +1,13 @@
 /*
  * DERIVED FROM: tk/generic/tkEntry.c r1.35.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 2000 Ajuba Solutions.
- * Copyright (c) 2002 ActiveState Corporation.
- * Copyright (c) 2004 Joe English
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2000 Ajuba Solutions.
+ * Copyright © 2002 ActiveState Corporation.
+ * Copyright © 2004 Joe English
  */
 
 #include "tkInt.h"
 #include "ttkTheme.h"
 #include "ttkWidget.h"
@@ -179,11 +179,11 @@
     {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
 	NULL, offsetof(Entry, entry.textVariableObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,TEXTVAR_CHANGED},
     {TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate",
 	"none", TCL_INDEX_NONE, offsetof(Entry, entry.validate),
-	0, (void *) validateStrings, 0},
+	TK_OPTION_ENUM_VAR, validateStrings, 0},
     {TK_OPTION_STRING, "-validatecommand", "validateCommand", "ValidateCommand",
 	NULL, TCL_INDEX_NONE, offsetof(Entry, entry.validateCmd),
 	TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_INT, "-width", "width", "Width",
 	DEF_ENTRY_WIDTH, offsetof(Entry, entry.widthObj), TCL_INDEX_NONE,
@@ -323,11 +323,11 @@
 	    Tk_GetFontFromObj(entryPtr->core.tkwin, entryPtr->entry.fontObj),
 	    entryPtr->entry.displayString, entryPtr->entry.numChars,
 	    0/*wraplength*/, entryPtr->entry.justify, TK_IGNORE_NEWLINES,
 	    &entryPtr->entry.layoutWidth, &entryPtr->entry.layoutHeight);
     } else {
-        text = TkGetStringFromObj(entryPtr->entry.placeholderObj, &length);
+        text = Tcl_GetStringFromObj(entryPtr->entry.placeholderObj, &length);
         entryPtr->entry.textLayout = Tk_ComputeTextLayout(
 	    Tk_GetFontFromObj(entryPtr->core.tkwin, entryPtr->entry.fontObj),
 	    text, length,
 	    0/*wraplength*/, entryPtr->entry.justify, TK_IGNORE_NEWLINES,
 	    &entryPtr->entry.layoutWidth, &entryPtr->entry.layoutHeight);
@@ -1306,15 +1306,15 @@
 		&& (entryPtr->entry.placeholderObj != NULL)) {
 	/* No text displayed, but -placeholder is given */
 	if (Tcl_GetCharLength(es.placeholderForegroundObj) > 0) {
 	    foregroundObj = es.placeholderForegroundObj;
 	} else {
-            foregroundObj = es.foregroundObj;
+	    foregroundObj = es.foregroundObj;
 	}
 	/* Use placeholder text width */
 	leftIndex = 0;
-	(void)TkGetStringFromObj(entryPtr->entry.placeholderObj, &rightIndex);
+	(void)Tcl_GetStringFromObj(entryPtr->entry.placeholderObj, &rightIndex);
     } else {
 	foregroundObj = es.foregroundObj;
     }
     gc = EntryGetGC(entryPtr, foregroundObj, clipRegion);
     if (showSelection) {
@@ -1391,18 +1391,20 @@
 #   define EntryWidth(e) (Tk_Width(entryPtr->core.tkwin)) /* Not Right */
     TkSizeT length, idx;
     const char *string;
 
     if (TCL_OK == TkGetIntForIndex(indexObj, entryPtr->entry.numChars - 1, 1, &idx)) {
-    	if ((idx != TCL_INDEX_NONE) && (idx > entryPtr->entry.numChars)) {
-    	    idx = entryPtr->entry.numChars;
-    	}
-    	*indexPtr = idx;
-    	return TCL_OK;
+	if (idx == TCL_INDEX_NONE) {
+	    idx = 0;
+	} else if (idx > entryPtr->entry.numChars) {
+	    idx = entryPtr->entry.numChars;
+	}
+	*indexPtr = idx;
+	return TCL_OK;
     }
 
-    string = TkGetStringFromObj(indexObj, &length);
+    string = Tcl_GetStringFromObj(indexObj, &length);
 
     if (strncmp(string, "insert", length) == 0) {
 	*indexPtr = entryPtr->entry.insertPos;
     } else if (strncmp(string, "left", length) == 0) {	/* for debugging */
 	*indexPtr = entryPtr->entry.xscroll.first;
@@ -1743,10 +1745,11 @@
     { "index", 		EntryIndexCommand,0 },
     { "insert", 	EntryInsertCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
     { "selection", 	0,EntrySelectionCommands },
     { "state",  	TtkWidgetStateCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { "validate", 	EntryValidateCommand,0 },
     { "xview", 		EntryXViewCommand,0 },
     { 0,0,0 }
 };
 
@@ -1871,20 +1874,20 @@
 	return TCL_OK;
     } else if (objc == 3) {
 	TkSizeT idx;
 
 	if (TCL_OK == TkGetIntForIndex(objv[2], nValues - 1, 0, &idx)) {
-	    if (idx == TCL_INDEX_NONE || idx > (TkSizeT)nValues) {
+	    if (idx == TCL_INDEX_NONE || idx >= (TkSizeT)nValues) {
 	        Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 		        "index \"%s\" out of range", Tcl_GetString(objv[2])));
 	        Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL);
 	        return TCL_ERROR;
 	    }
 	    currentIndex = idx;
 	} else {
 	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
-		    "Incorrect index %s", Tcl_GetString(objv[2])));
+		    "bad index \"%s\"", Tcl_GetString(objv[2])));
 	    Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_VALUE", NULL);
 	    return TCL_ERROR;
 	}
 
 	cbPtr->combobox.currentIndex = currentIndex;
@@ -1911,12 +1914,13 @@
     { "identify",	TtkWidgetIdentifyCommand,0 },
     { "index", 		EntryIndexCommand,0 },
     { "insert", 	EntryInsertCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
     { "selection", 	0,EntrySelectionCommands },
-    { "state",  	TtkWidgetStateCommand,0 },
     { "set", 		EntrySetCommand,0 },
+    { "state",  	TtkWidgetStateCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { "validate",	EntryValidateCommand,0 },
     { "xview", 		EntryXViewCommand,0 },
     { 0,0,0 }
 };
 
@@ -2023,12 +2027,13 @@
     { "identify",	TtkWidgetIdentifyCommand,0 },
     { "index", 		EntryIndexCommand,0 },
     { "insert", 	EntryInsertCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
     { "selection", 	0,EntrySelectionCommands },
-    { "state",  	TtkWidgetStateCommand,0 },
     { "set", 		EntrySetCommand,0 },
+    { "state",  	TtkWidgetStateCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { "validate",	EntryValidateCommand,0 },
     { "xview", 		EntryXViewCommand,0 },
     { 0,0,0 }
 };
 

Index: generic/ttk/ttkFrame.c
==================================================================
--- generic/ttk/ttkFrame.c
+++ generic/ttk/ttkFrame.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004 Joe English
  *
  * ttk::frame and ttk::labelframe widgets.
  */
 
 #include "tkInt.h"
@@ -46,15 +46,16 @@
     WIDGET_TAKEFOCUS_FALSE,
     WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
 };
 
 static const Ttk_Ensemble FrameCommands[] = {
-    { "configure",	TtkWidgetConfigureCommand,0 },
     { "cget",   	TtkWidgetCgetCommand,0 },
+    { "configure",	TtkWidgetConfigureCommand,0 },
+    { "identify",	TtkWidgetIdentifyCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
-    { "identify",	TtkWidgetIdentifyCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { 0,0,0 }
 };
 
 /*
  * FrameMargins --
@@ -232,11 +233,11 @@
  * Labelframe widget record:
  */
 typedef struct {
     Tcl_Obj 	*labelAnchorObj;
     Tcl_Obj	*textObj;
-    Tcl_Obj 	*underlineObj;
+    int	underline;
     Tk_Window	labelWidget;
 
     Ttk_Manager	*mgr;
     Ttk_Layout	labelLayout;	/* Sublayout for label */
     Ttk_Box	labelParcel;	/* Set in layoutProc */
@@ -255,13 +256,12 @@
 	"nw", offsetof(Labelframe, label.labelAnchorObj),TCL_INDEX_NONE,
         0,0,GEOMETRY_CHANGED},
     {TK_OPTION_STRING, "-text", "text", "Text", "",
 	offsetof(Labelframe,label.textObj), TCL_INDEX_NONE,
 	0,0,GEOMETRY_CHANGED },
-    {TK_OPTION_INT, "-underline", "underline", "Underline",
-	"-1", offsetof(Labelframe,label.underlineObj), TCL_INDEX_NONE,
-	0,0,0 },
+    {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+	TK_OPTION_UNDERLINE_DEF(Labelframe, label.underline), 0},
     {TK_OPTION_WINDOW, "-labelwidget", "labelWidget", "LabelWidget", NULL,
 	TCL_INDEX_NONE, offsetof(Labelframe,label.labelWidget),
 	TK_OPTION_NULL_OK,0,LABELWIDGET_CHANGED|GEOMETRY_CHANGED },
 
     WIDGET_INHERIT_OPTIONS(FrameOptionSpecs)

Index: generic/ttk/ttkImage.c
==================================================================
--- generic/ttk/ttkImage.c
+++ generic/ttk/ttkImage.c
@@ -1,10 +1,10 @@
 /*
  *	Image specifications and image element factory.
  *
- * Copyright (C) 2004 Pat Thoyts <patthoyts@users.sf.net>
- * Copyright (C) 2004 Joe English
+ * Copyright © 2004 Pat Thoyts <patthoyts@users.sf.net>
+ * Copyright © 2004 Joe English
  *
  * An imageSpec is a multi-element list; the first element
  * is the name of the default image to use, the remainder of the
  * list is a sequence of statespec/imagename options as per
  * [style map].
@@ -256,11 +256,11 @@
  */
 
 typedef struct {		/* ClientData for image elements */
     Ttk_ImageSpec *imageSpec;	/* Image(s) to use */
     int minWidth;		/* Minimum width; overrides image width */
-    int minHeight;		/* Minimum width; overrides image width */
+    int minHeight;		/* Minimum height; overrides image height */
     Ttk_Sticky sticky;		/* -stickiness specification */
     Ttk_Padding border;		/* Fixed border region */
     Ttk_Padding padding;	/* Internal padding */
 
 #ifdef TILE_07_COMPAT

Index: generic/ttk/ttkInit.c
==================================================================
--- generic/ttk/ttkInit.c
+++ generic/ttk/ttkInit.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, Joe English
+ * Copyright © 2003 Joe English
  *
  * Ttk package: initialization routine and miscellaneous utilities.
  */
 
 #include "tkInt.h"
@@ -11,19 +11,19 @@
 /*
  * Legal values for the button -default option.
  * See also: enum Ttk_ButtonDefaultState.
  */
 const char *const ttkDefaultStrings[] = {
-    "normal", "active", "disabled", NULL
+    "active", "disabled", "normal", NULL
 };
 
 int Ttk_GetButtonDefaultStateFromObj(
     Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_ButtonDefaultState *statePtr)
 {
     int state = (int)TTK_BUTTON_DEFAULT_DISABLED;
-    int result = Tcl_GetIndexFromObjStruct(interp, objPtr, ttkDefaultStrings,
-	    sizeof(char *), "default state", 0, &state);
+    int result = Tcl_GetIndexFromObj(interp, objPtr, ttkDefaultStrings,
+	    "default state", 0, &state);
 
     *statePtr = (Ttk_ButtonDefaultState)state;
     return result;
 }
 
@@ -38,12 +38,12 @@
 
 int Ttk_GetCompoundFromObj(
     Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Compound *compoundPtr)
 {
     int compound = (int)TTK_COMPOUND_NONE;
-    int result = Tcl_GetIndexFromObjStruct(interp, objPtr, ttkCompoundStrings,
-	    sizeof(char *), "compound layout", 0, &compound);
+    int result = Tcl_GetIndexFromObj(interp, objPtr, ttkCompoundStrings,
+	    "compound layout", 0, &compound);
 
     *compoundPtr = (Ttk_Compound)compound;
     return result;
 }
 
@@ -58,21 +58,21 @@
 #if !defined(TK_NO_DEPRECATED) && TK_MAJOR_VERSION < 9
 int Ttk_GetOrientFromObj(
     Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr)
 {
     *resultPtr = TTK_ORIENT_HORIZONTAL;
-    return Tcl_GetIndexFromObjStruct(interp, objPtr, ttkOrientStrings,
-	    sizeof(char *), "orientation", 0, resultPtr);
+    return Tcl_GetIndexFromObj(interp, objPtr, ttkOrientStrings,
+	    "orientation", 0, resultPtr);
 }
 #endif
 
 int TtkGetOrientFromObj(
     Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Orient *resultPtr)
 {
     int orient = (int)TTK_ORIENT_HORIZONTAL;
-    int result = Tcl_GetIndexFromObjStruct(interp, objPtr, ttkOrientStrings,
-    	    sizeof(char *), "orientation", 0, &orient);
+    int result = Tcl_GetIndexFromObj(interp, objPtr, ttkOrientStrings,
+    	    "orientation", 0, &orient);
 
     *resultPtr = (Ttk_Orient)orient;
     return result;
 }
 
@@ -79,17 +79,17 @@
 /*
  * Recognized values for the -state compatibility option.
  * Other options are accepted and interpreted as synonyms for "normal".
  */
 static const char *const ttkStateStrings[] = {
-    "normal", "readonly", "disabled", "active", NULL
+    "active", "disabled", "normal", "readonly", NULL
 };
 enum {
-    TTK_COMPAT_STATE_NORMAL,
-    TTK_COMPAT_STATE_READONLY,
+    TTK_COMPAT_STATE_ACTIVE,
     TTK_COMPAT_STATE_DISABLED,
-    TTK_COMPAT_STATE_ACTIVE
+    TTK_COMPAT_STATE_NORMAL,
+    TTK_COMPAT_STATE_READONLY
 };
 
 /* TtkCheckStateOption --
  * 	Handle -state compatibility option.
  *
@@ -102,12 +102,12 @@
 {
     int stateOption = TTK_COMPAT_STATE_NORMAL;
     unsigned all = TTK_STATE_DISABLED|TTK_STATE_READONLY|TTK_STATE_ACTIVE;
 #   define SETFLAGS(f) TtkWidgetChangeState(corePtr, f, all^f)
 
-    (void)Tcl_GetIndexFromObjStruct(NULL, objPtr, ttkStateStrings,
-	    sizeof(char *), "", 0, &stateOption);
+    Tcl_GetIndexFromObj(NULL, objPtr, ttkStateStrings,
+	    "", 0, &stateOption);
     switch (stateOption) {
 	case TTK_COMPAT_STATE_NORMAL:
 	default:
 	    SETFLAGS(0);
 	    break;
@@ -269,11 +269,14 @@
     RegisterWidgets(interp);
     RegisterThemes(interp);
 
     Ttk_PlatformInit(interp);
 
+#ifndef TK_NO_DEPRECATED
     Tcl_PkgProvideEx(interp, "Ttk", TTK_PATCH_LEVEL, (void *)&ttkStubs);
+#endif
+    Tcl_PkgProvideEx(interp, "ttk", TTK_PATCH_LEVEL, (void *)&ttkStubs);
 
     return TCL_OK;
 }
 
 /*EOF*/

Index: generic/ttk/ttkLabel.c
==================================================================
--- generic/ttk/ttkLabel.c
+++ generic/ttk/ttkLabel.c
@@ -28,11 +28,11 @@
     Tcl_Obj	*underlineObj;
     Tcl_Obj	*widthObj;
     Tcl_Obj	*anchorObj;
     Tcl_Obj	*justifyObj;
     Tcl_Obj	*wrapLengthObj;
-    Tcl_Obj     *embossedObj;
+    Tcl_Obj	*embossedObj;
 
     /*
      * Computed resources:
      */
     Tk_Font		tkfont;
@@ -51,12 +51,16 @@
 	offsetof(TextElement,textObj), "" },
     { "-font", TK_OPTION_FONT,
 	offsetof(TextElement,fontObj), DEFAULT_FONT },
     { "-foreground", TK_OPTION_COLOR,
 	offsetof(TextElement,foregroundObj), "black" },
-    { "-underline", TK_OPTION_INT,
+    { "-underline", TK_OPTION_INDEX,
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
 	offsetof(TextElement,underlineObj), "-1"},
+#else
+	offsetof(TextElement,underlineObj), NULL},
+#endif
     { "-width", TK_OPTION_INT,
 	offsetof(TextElement,widthObj), "-1"},
     { "-anchor", TK_OPTION_ANCHOR,
 	offsetof(TextElement,anchorObj), "w"},
     { "-justify", TK_OPTION_JUSTIFY,
@@ -124,11 +128,11 @@
  * 	Called by TextElementDraw() and LabelElementDraw().
  */
 static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b)
 {
     XColor *color = Tk_GetColorFromObj(tkwin, text->foregroundObj);
-    int underline = -1;
+    TkSizeT underline = TCL_INDEX_NONE;
     XGCValues gcValues;
     GC gc1, gc2;
     Tk_Anchor anchor = TK_ANCHOR_CENTER;
     TkRegion clipRegion = NULL;
 
@@ -168,18 +172,23 @@
 	    text->textLayout, b.x+1, b.y+1, 0/*firstChar*/, -1/*lastChar*/);
     }
     Tk_DrawTextLayout(Tk_Display(tkwin), d, gc1,
 	    text->textLayout, b.x, b.y, 0/*firstChar*/, -1/*lastChar*/);
 
-    Tcl_GetIntFromObj(NULL, text->underlineObj, &underline);
-    if (underline >= 0) {
-	if (text->embossed) {
-	    Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc2,
-		text->textLayout, b.x+1, b.y+1, underline);
-	}
-	Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc1,
-	    text->textLayout, b.x, b.y, underline);
+    if (text->underlineObj != NULL) {
+	TkGetIntForIndex(text->underlineObj, TCL_INDEX_END, 0, &underline);
+	if (underline != TCL_INDEX_NONE) {
+	    if ((size_t)underline > (size_t)TCL_INDEX_END>>1) {
+		underline++;
+	    }
+	    if (text->embossed) {
+		Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc2,
+			text->textLayout, b.x+1, b.y+1, underline);
+	    }
+	    Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc1,
+		    text->textLayout, b.x, b.y, underline);
+	}
     }
 
     if (clipRegion != NULL) {
 #ifdef HAVE_XFT
 	TkUnixSetXftClipRegion(NULL);
@@ -461,12 +470,16 @@
 	offsetof(LabelElement,text.textObj), "" },
     { "-font", TK_OPTION_FONT,
 	offsetof(LabelElement,text.fontObj), DEFAULT_FONT },
     { "-foreground", TK_OPTION_COLOR,
 	offsetof(LabelElement,text.foregroundObj), "black" },
-    { "-underline", TK_OPTION_INT,
+    { "-underline", TK_OPTION_INDEX,
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
 	offsetof(LabelElement,text.underlineObj), "-1"},
+#else
+	offsetof(LabelElement,text.underlineObj), NULL},
+#endif
     { "-width", TK_OPTION_INT,
 	offsetof(LabelElement,text.widthObj), ""},
     { "-anchor", TK_OPTION_ANCHOR,
 	offsetof(LabelElement,text.anchorObj), "w"},
     { "-justify", TK_OPTION_JUSTIFY,

Index: generic/ttk/ttkLayout.c
==================================================================
--- generic/ttk/ttkLayout.c
+++ generic/ttk/ttkLayout.c
@@ -1,11 +1,11 @@
 /*
  * ttkLayout.c --
  *
  * Generic layout processing.
  *
- * Copyright (c) 2003 Joe English.  Freely redistributable.
+ * Copyright © 2003 Joe English.  Freely redistributable.
  */
 
 #include "tkInt.h"
 #include "ttkThemeInt.h"
 
@@ -218,12 +218,11 @@
 	case TK_ANCHOR_SE:	return TTK_STICK_S | TTK_STICK_E;
 	case TK_ANCHOR_S:	return TTK_STICK_S;
 	case TK_ANCHOR_SW:	return TTK_STICK_S | TTK_STICK_W;
 	case TK_ANCHOR_W:	return TTK_STICK_W;
 	case TK_ANCHOR_NW:	return TTK_STICK_N | TTK_STICK_W;
-	default:
-	case TK_ANCHOR_CENTER:	return 0;
+	default:	return 0;
     }
 }
 
 /*
  * Ttk_AnchorBox --
@@ -1244,10 +1243,41 @@
     if (node->child) {
 	Ttk_PlaceNodeList(layout, node->child, 0,
 	    Ttk_PadBox(b, Ttk_LayoutNodeInternalPadding(layout, node)));
     }
 }
+
+/*
+ * AnchorToPosition --
+ * 	Convert a Tk_Anchor enum to a position bitmask.
+ */
+static Ttk_PositionSpec AnchorToPosition(Tk_Anchor anchor)
+{
+    switch (anchor)
+    {
+	case TK_ANCHOR_N:	return TTK_PACK_TOP;
+	case TK_ANCHOR_S:	return TTK_PACK_BOTTOM;
+	case TK_ANCHOR_NE:	return TTK_PACK_RIGHT|TTK_STICK_N;
+	case TK_ANCHOR_SE:	return TTK_PACK_RIGHT|TTK_STICK_S;
+	case TK_ANCHOR_E:	return TTK_PACK_RIGHT;
+	case TK_ANCHOR_NW:	return TTK_PACK_LEFT|TTK_STICK_N;
+	case TK_ANCHOR_SW:	return TTK_PACK_LEFT|TTK_STICK_S;
+	case TK_ANCHOR_W:	return TTK_PACK_LEFT;
+	case TK_ANCHOR_CENTER:	return 0;
+	default:;
+    }
+    return TTK_PACK_LEFT;
+}
+
+/*
+ * Ttk_AnchorElement --
+ * 	Explicitly specify an element's anchoring.
+ */
+void Ttk_AnchorElement(Ttk_Element node, Tk_Anchor anchor)
+{
+    node->flags = AnchorToPosition(anchor);
+}
 
 /*
  * Ttk_ChangeElementState --
  */
 void Ttk_ChangeElementState(Ttk_LayoutNode *node,unsigned set,unsigned clr)

Index: generic/ttk/ttkManager.c
==================================================================
--- generic/ttk/ttkManager.c
+++ generic/ttk/ttkManager.c
@@ -312,26 +312,27 @@
 
 void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window window)
 {
     Ttk_Manager *mgr = (Ttk_Manager *)clientData;
     TkSizeT index = Ttk_ContentIndex(mgr, window);
-    int reqWidth = Tk_ReqWidth(window);
-    int reqHeight= Tk_ReqHeight(window);
 
-    if (mgr->managerSpec->ContentRequest(
-		mgr->managerData, index, reqWidth, reqHeight))
-    {
-	ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED);
+    if (index != TCL_INDEX_NONE) {
+	int reqWidth = Tk_ReqWidth(window);
+	int reqHeight= Tk_ReqHeight(window);
+	if (mgr->managerSpec->ContentRequest(
+	    mgr->managerData, index, reqWidth, reqHeight)) {
+	    ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED);
+	}
     }
 }
 
 void Ttk_LostContentProc(ClientData clientData, Tk_Window window)
 {
     Ttk_Manager *mgr = (Ttk_Manager *)clientData;
     TkSizeT index = Ttk_ContentIndex(mgr, window);
 
-    /* ASSERT: index >= 0 */
+    /* ASSERT: index != TCL_INDEX_NONE */
     RemoveContent(mgr, index);
 }
 
 /*------------------------------------------------------------------------
  * +++ Public API.
@@ -420,11 +421,11 @@
 /*------------------------------------------------------------------------
  * +++ Utility routines.
  */
 
 /* ++ Ttk_ContentIndex --
- * 	Returns the index of specified content window, -1 if not found.
+ * 	Returns the index of specified content window, TCL_INDEX_NONE if not found.
  */
 TkSizeT Ttk_ContentIndex(Ttk_Manager *mgr, Tk_Window window)
 {
     TkSizeT index;
     for (index = 0; index < mgr->nContent; ++index)
@@ -450,11 +451,11 @@
     Tk_Window tkwin;
 
     /* Try interpreting as an integer first:
      */
     if (TkGetIntForIndex(objPtr, mgr->nContent - 1, 1, &index) == TCL_OK) {
-	if (index + 1 > mgr->nContent + 1) {
+	if (index == TCL_INDEX_NONE || index > mgr->nContent) {
 	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 		"Managed window index %d out of bounds", (int)index));
 	    Tcl_SetErrorCode(interp, "TTK", "MANAGED", "INDEX", NULL);
 	    return TCL_ERROR;
 	}

Index: generic/ttk/ttkManager.h
==================================================================
--- generic/ttk/ttkManager.h
+++ generic/ttk/ttkManager.h
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2005, Joe English.  Freely redistributable.
+ * Copyright © 2005 Joe English.  Freely redistributable.
  *
  * Geometry manager utilities.
  */
 
 #ifndef _TTKMANAGER

Index: generic/ttk/ttkNotebook.c
==================================================================
--- generic/ttk/ttkNotebook.c
+++ generic/ttk/ttkNotebook.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004 Joe English
  */
 
 #include "tkInt.h"
 #include "ttkTheme.h"
 #include "ttkWidget.h"
@@ -14,13 +14,13 @@
  * +++ Tab resources.
  */
 
 #define DEFAULT_MIN_TAB_WIDTH 24
 
-static const char *const TabStateStrings[] = { "normal", "disabled", "hidden", 0 };
+static const char *const TabStateStrings[] = { "disabled", "hidden", "normal", 0 };
 typedef enum {
-    TAB_STATE_NORMAL, TAB_STATE_DISABLED, TAB_STATE_HIDDEN
+    TAB_STATE_DISABLED, TAB_STATE_HIDDEN, TAB_STATE_NORMAL
 } TAB_STATE;
 
 typedef struct
 {
     /* Internal data:
@@ -42,11 +42,11 @@
     /* Label options:
      */
     Tcl_Obj *textObj;
     Tcl_Obj *imageObj;
     Tcl_Obj *compoundObj;
-    Tcl_Obj *underlineObj;
+    int underline;
 
 } Tab;
 
 /* Two different option tables are used for tabs:
  * TabOptionSpecs is used to draw the tab, and only includes resources
@@ -57,20 +57,20 @@
  */
 static const Tk_OptionSpec TabOptionSpecs[] =
 {
     {TK_OPTION_STRING_TABLE, "-state", "", "",
 	"normal", TCL_INDEX_NONE, offsetof(Tab,state),
-	0, (void *)TabStateStrings, 0 },
+	TK_OPTION_ENUM_VAR, TabStateStrings, 0 },
     {TK_OPTION_STRING, "-text", "text", "Text", "",
 	offsetof(Tab,textObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED },
     {TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/,
 	offsetof(Tab,imageObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED },
     {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
 	NULL, offsetof(Tab,compoundObj), TCL_INDEX_NONE,
-	TK_OPTION_NULL_OK,(void *)ttkCompoundStrings,GEOMETRY_CHANGED },
-    {TK_OPTION_INT, "-underline", "underline", "Underline", "-1",
-	offsetof(Tab,underlineObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED },
+	TK_OPTION_NULL_OK,ttkCompoundStrings,GEOMETRY_CHANGED },
+    {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+	TK_OPTION_UNDERLINE_DEF(Tab, underline), GEOMETRY_CHANGED},
     {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0 }
 };
 
 static const Tk_OptionSpec PaneOptionSpecs[] =
 {
@@ -897,11 +897,11 @@
 static int NotebookAddCommand(
     void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 {
     Notebook *nb = (Notebook *)recordPtr;
     Tk_Window window;
-    int index;
+    TkSizeT index;
     Tab *tab;
 
     if (objc <= 2 || objc % 2 != 1) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?-option value ...?");
 	return TCL_ERROR;
@@ -911,11 +911,11 @@
     if (!window) {
 	return TCL_ERROR;
     }
     index = Ttk_ContentIndex(nb->notebook.mgr, window);
 
-    if (index < 0) { /* New tab */
+    if (index == TCL_INDEX_NONE) { /* New tab */
 	return AddTab(interp, nb, Ttk_NumberContent(nb->notebook.mgr), window, objc-3,objv+3);
     }
 
     tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
     if (tab->state == TAB_STATE_HIDDEN) {
@@ -1049,14 +1049,14 @@
 
     tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
     tab->state = TAB_STATE_HIDDEN;
     if (index == nb->notebook.currentIndex) {
 	SelectNearestTab(nb);
+    } else {
+        TtkRedisplayWidget(&nb->core);
     }
 
-    TtkRedisplayWidget(&nb->core);
-
     return TCL_OK;
 }
 
 /* $nb identify $x $y --
  * 	Returns name of tab element at $x,$y; empty string if none.
@@ -1104,11 +1104,13 @@
 
 		Tcl_SetObjResult(interp, Tcl_NewStringObj(elementName, -1));
 	    }
 	    break;
 	case IDENTIFY_TAB:
+#if !defined TK_NO_DEPRECATED && (TCL_MAJOR_VERSION < 9)
 	    if (tabIndex != TCL_INDEX_NONE)
+#endif
 	    Tcl_SetObjResult(interp, TkNewIndexObj(tabIndex));
 	    break;
     }
     return TCL_OK;
 }
@@ -1130,11 +1132,13 @@
 	return TCL_ERROR;
     }
 
     status = FindTabIndex(interp, nb, objv[2], &index);
 	if (status == TCL_OK) {
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
 	if (index != TCL_INDEX_NONE)
+#endif
 	Tcl_SetObjResult(interp, TkNewIndexObj(index));
     }
 
     return status;
 }
@@ -1240,20 +1244,21 @@
 
 /* Subcommand table:
  */
 static const Ttk_Ensemble NotebookCommands[] = {
     { "add",    	NotebookAddCommand,0 },
-    { "configure",	TtkWidgetConfigureCommand,0 },
     { "cget",		TtkWidgetCgetCommand,0 },
+    { "configure",	TtkWidgetConfigureCommand,0 },
     { "forget",		NotebookForgetCommand,0 },
     { "hide",		NotebookHideCommand,0 },
     { "identify",	NotebookIdentifyCommand,0 },
     { "index",		NotebookIndexCommand,0 },
     { "insert",  	NotebookInsertCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
     { "select",		NotebookSelectCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { "tab",   		NotebookTabCommand,0 },
     { "tabs",   	NotebookTabsCommand,0 },
     { 0,0,0 }
 };
 

Index: generic/ttk/ttkPanedwindow.c
==================================================================
--- generic/ttk/ttkPanedwindow.c
+++ generic/ttk/ttkPanedwindow.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2005, Joe English.  Freely redistributable.
+ * Copyright © 2005 Joe English.  Freely redistributable.
  *
  * ttk::panedwindow widget implementation.
  *
  * TODO: track active/pressed sash.
  */
@@ -75,11 +75,11 @@
 /* @@@ NOTE: -orient is readonly 'cause dynamic oriention changes NYI
  */
 static const Tk_OptionSpec PanedOptionSpecs[] = {
     {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical",
 	offsetof(Paned,paned.orientObj), offsetof(Paned,paned.orient),
-	0, (void *)ttkOrientStrings, READONLY_OPTION|STYLE_CHANGED },
+	0, ttkOrientStrings, READONLY_OPTION|STYLE_CHANGED },
     {TK_OPTION_INT, "-width", "width", "Width", "0",
 	TCL_INDEX_NONE, offsetof(Paned, paned.width),
 	0, 0, GEOMETRY_CHANGED },
     {TK_OPTION_INT, "-height", "height", "Height", "0",
 	TCL_INDEX_NONE, offsetof(Paned, paned.height),
@@ -880,20 +880,21 @@
     return TCL_OK;
 }
 
 static const Ttk_Ensemble PanedCommands[] = {
     { "add", 		PanedAddCommand,0 },
-    { "configure",	TtkWidgetConfigureCommand,0 },
     { "cget",		TtkWidgetCgetCommand,0 },
+    { "configure",	TtkWidgetConfigureCommand,0 },
     { "forget", 	PanedForgetCommand,0 },
     { "identify", 	PanedIdentifyCommand,0 },
     { "insert", 	PanedInsertCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
     { "pane",   	PanedPaneCommand,0 },
     { "panes",   	PanedPanesCommand,0 },
     { "sashpos",  	PanedSashposCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { 0,0,0 }
 };
 
 /*------------------------------------------------------------------------
  * +++ Widget specification.

Index: generic/ttk/ttkProgress.c
==================================================================
--- generic/ttk/ttkProgress.c
+++ generic/ttk/ttkProgress.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) Joe English, Pat Thoyts, Michael Kirkham
+ * Copyright © Joe English, Pat Thoyts, Michael Kirkham
  *
  * ttk::progressbar widget.
  */
 
 #include "tkInt.h"
@@ -61,19 +61,19 @@
 	TK_OPTION_NULL_OK,0,0 },
     {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
 	"left", offsetof(Progressbar,progress.justifyObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
     {TK_OPTION_PIXELS, "-length", "length", "Length",
-        DEF_PROGRESSBAR_LENGTH, offsetof(Progressbar,progress.lengthObj), TCL_INDEX_NONE,
+	DEF_PROGRESSBAR_LENGTH, offsetof(Progressbar,progress.lengthObj), TCL_INDEX_NONE,
 	0, 0, GEOMETRY_CHANGED },
     {TK_OPTION_DOUBLE, "-maximum", "maximum", "Maximum",
 	"100", offsetof(Progressbar,progress.maximumObj), TCL_INDEX_NONE,
 	0, 0, 0 },
     {TK_OPTION_STRING_TABLE, "-mode", "mode", "ProgressMode", "determinate",
 	offsetof(Progressbar,progress.modeObj),
 	offsetof(Progressbar,progress.mode),
-	0, (void *)ProgressbarModeStrings, 0 },
+	0, ProgressbarModeStrings, 0 },
     {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
 	"horizontal", offsetof(Progressbar,progress.orientObj), TCL_INDEX_NONE,
 	0, (void *)ttkOrientStrings, STYLE_CHANGED },
     {TK_OPTION_INT, "-phase", "phase", "Phase",
 	"0", offsetof(Progressbar,progress.phaseObj), TCL_INDEX_NONE,
@@ -123,31 +123,32 @@
 static void AnimateProgressProc(ClientData clientData)
 {
     Progressbar *pb = (Progressbar *)clientData;
 
     pb->progress.timer = 0;
-
     if (AnimationEnabled(pb)) {
 	int phase = 0;
 	Tcl_GetIntFromObj(NULL, pb->progress.phaseObj, &phase);
 
 	/*
 	 * Update -phase:
 	 */
+
 	++phase;
-	if (pb->progress.maxPhase)
-	    phase %= pb->progress.maxPhase;
+	if (phase > pb->progress.maxPhase) {
+	    phase = 0;
+	}
 	Tcl_DecrRefCount(pb->progress.phaseObj);
 	pb->progress.phaseObj = Tcl_NewWideIntObj(phase);
 	Tcl_IncrRefCount(pb->progress.phaseObj);
 
 	/*
 	 * Reschedule:
 	 */
+
 	pb->progress.timer = Tcl_CreateTimerHandler(
 	    pb->progress.period, AnimateProgressProc, clientData);
-
 	TtkRedisplayWidget(&pb->core);
     }
 }
 
 /* CheckAnimation --
@@ -516,18 +517,19 @@
     return ProgressbarStartStopCommand(
 	    interp, "::ttk::progressbar::stop", objc, objv);
 }
 
 static const Ttk_Ensemble ProgressbarCommands[] = {
-    { "configure",	TtkWidgetConfigureCommand,0 },
     { "cget",		TtkWidgetCgetCommand,0 },
+    { "configure",	TtkWidgetConfigureCommand,0 },
     { "identify",	TtkWidgetIdentifyCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
     { "start", 		ProgressbarStartCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
     { "step", 		ProgressbarStepCommand,0 },
     { "stop", 		ProgressbarStopCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { 0,0,0 }
 };
 
 /*
  * Widget specification:

Index: generic/ttk/ttkScale.c
==================================================================
--- generic/ttk/ttkScale.c
+++ generic/ttk/ttkScale.c
@@ -1,12 +1,11 @@
 /*
- * Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
+ * Copyright © 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
  *
  * ttk::scale widget.
  */
 
-#include "tkInt.h"
 #include "tkInt.h"
 #include "ttkTheme.h"
 #include "ttkWidget.h"
 
 #define DEF_SCALE_LENGTH "100"
@@ -59,12 +58,12 @@
     {TK_OPTION_STRING, "-variable", "variable", "Variable", "",
 	offsetof(Scale,scale.variableObj), TCL_INDEX_NONE,
 	0, 0, 0},
     {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
 	offsetof(Scale,scale.orientObj),
-	offsetof(Scale,scale.orient), 0,
-	(void *)ttkOrientStrings, STYLE_CHANGED },
+	offsetof(Scale,scale.orient),
+	0, ttkOrientStrings, STYLE_CHANGED },
 
     {TK_OPTION_DOUBLE, "-from", "from", "From", "0",
 	offsetof(Scale,scale.fromObj), TCL_INDEX_NONE, 0, 0, 0},
     {TK_OPTION_DOUBLE, "-to", "to", "To", "1.0",
 	offsetof(Scale,scale.toObj), TCL_INDEX_NONE, 0, 0, 0},
@@ -481,18 +480,19 @@
     }
     return pt;
 }
 
 static const Ttk_Ensemble ScaleCommands[] = {
-    { "configure",   TtkWidgetConfigureCommand,0 },
     { "cget",        TtkWidgetCgetCommand,0 },
-    { "state",       TtkWidgetStateCommand,0 },
-    { "instate",     TtkWidgetInstateCommand,0 },
+    { "configure",   TtkWidgetConfigureCommand,0 },
+    { "coords",      ScaleCoordsCommand,0 },
+    { "get",         ScaleGetCommand,0 },
     { "identify",    TtkWidgetIdentifyCommand,0 },
+    { "instate",     TtkWidgetInstateCommand,0 },
     { "set",         ScaleSetCommand,0 },
-    { "get",         ScaleGetCommand,0 },
-    { "coords",      ScaleCoordsCommand,0 },
+    { "state",       TtkWidgetStateCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { 0,0,0 }
 };
 
 static const WidgetSpec ScaleWidgetSpec =
 {

Index: generic/ttk/ttkScrollbar.c
==================================================================
--- generic/ttk/ttkScrollbar.c
+++ generic/ttk/ttkScrollbar.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, Joe English
+ * Copyright © 2003 Joe English
  *
  * ttk::scrollbar widget.
  */
 
 #include "tkInt.h"
@@ -37,11 +37,11 @@
 	offsetof(Scrollbar, scrollbar.commandObj), TCL_INDEX_NONE, 0, 0, 0},
 
     {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical",
 	offsetof(Scrollbar, scrollbar.orientObj),
 	offsetof(Scrollbar, scrollbar.orient),
-	0, (void *)ttkOrientStrings, STYLE_CHANGED },
+	0, ttkOrientStrings, STYLE_CHANGED },
 
     WIDGET_TAKEFOCUS_FALSE,
     WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
 };
 
@@ -280,19 +280,20 @@
     Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fraction));
     return TCL_OK;
 }
 
 static const Ttk_Ensemble ScrollbarCommands[] = {
-    { "configure",	TtkWidgetConfigureCommand,0 },
     { "cget",		TtkWidgetCgetCommand,0 },
+    { "configure",	TtkWidgetConfigureCommand,0 },
     { "delta",    	ScrollbarDeltaCommand,0 },
     { "fraction",    	ScrollbarFractionCommand,0 },
     { "get",    	ScrollbarGetCommand,0 },
     { "identify",	TtkWidgetIdentifyCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
     { "set",  		ScrollbarSetCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { 0,0,0 }
 };
 
 /*------------------------------------------------------------------------
  * +++ Widget specification.

Index: generic/ttk/ttkSeparator.c
==================================================================
--- generic/ttk/ttkSeparator.c
+++ generic/ttk/ttkSeparator.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004 Joe English
  *
  * ttk::separator and ttk::sizegrip widgets.
  */
 
 #include "tkInt.h"
@@ -24,11 +24,11 @@
 
 static const Tk_OptionSpec SeparatorOptionSpecs[] = {
     {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
 	offsetof(Separator,separator.orientObj),
 	offsetof(Separator,separator.orient),
-	0, (void *)ttkOrientStrings, STYLE_CHANGED },
+	0, ttkOrientStrings, STYLE_CHANGED },
 
     WIDGET_TAKEFOCUS_FALSE,
     WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
 };
 
@@ -46,15 +46,16 @@
 
 /*
  * Widget commands:
  */
 static const Ttk_Ensemble SeparatorCommands[] = {
-    { "configure",	TtkWidgetConfigureCommand,0 },
     { "cget",		TtkWidgetCgetCommand,0 },
+    { "configure",	TtkWidgetConfigureCommand,0 },
     { "identify",	TtkWidgetIdentifyCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { 0,0,0 }
 };
 
 /*
  * Widget specification:
@@ -87,15 +88,16 @@
     WIDGET_TAKEFOCUS_FALSE,
     WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
 };
 
 static const Ttk_Ensemble SizegripCommands[] = {
-    { "configure",	TtkWidgetConfigureCommand,0 },
     { "cget",		TtkWidgetCgetCommand,0 },
+    { "configure",	TtkWidgetConfigureCommand,0 },
     { "identify",	TtkWidgetIdentifyCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { 0,0,0 }
 };
 
 static const WidgetSpec SizegripWidgetSpec =
 {

Index: generic/ttk/ttkSquare.c
==================================================================
--- generic/ttk/ttkSquare.c
+++ generic/ttk/ttkSquare.c
@@ -1,6 +1,6 @@
-/* square.c - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
+/* square.c - Copyright © 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
  *
  * Minimal sample ttk widget.
  */
 
 #include "tkInt.h"
@@ -70,11 +70,11 @@
 
     {TK_OPTION_RELIEF, "-relief", "relief", "Relief",
      NULL, offsetof(Square,square.reliefObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
 
     {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
-     NULL, offsetof(Square,square.anchorObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
+     "center", offsetof(Square,square.anchorObj), TCL_INDEX_NONE, 0, 0, 0},
 
     WIDGET_TAKEFOCUS_TRUE,
     WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
 };
 
@@ -127,15 +127,16 @@
  * subcommands are listed here. Ttk provides default implementations
  * that are sufficient for our needs.
  */
 
 static const Ttk_Ensemble SquareCommands[] = {
-    { "configure",	TtkWidgetConfigureCommand,0 },
     { "cget",		TtkWidgetCgetCommand,0 },
+    { "configure",	TtkWidgetConfigureCommand,0 },
     { "identify",	TtkWidgetIdentifyCommand,0 },
     { "instate",	TtkWidgetInstateCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { 0,0,0 }
 };
 
 /*
  * The Widget specification structure holds all the implementation

Index: generic/ttk/ttkState.c
==================================================================
--- generic/ttk/ttkState.c
+++ generic/ttk/ttkState.c
@@ -1,9 +1,9 @@
 /*
  * Tk widget state utilities.
  *
- * Copyright (c) 2003 Joe English.  Freely redistributable.
+ * Copyright © 2003 Joe English.  Freely redistributable.
  *
  */
 
 #include "tkInt.h"
 #include "ttkTheme.h"

Index: generic/ttk/ttkStubLib.c
==================================================================
--- generic/ttk/ttkStubLib.c
+++ generic/ttk/ttkStubLib.c
@@ -32,21 +32,27 @@
 MODULE_SCOPE const char *
 TtkInitializeStubs(
     Tcl_Interp *interp, const char *version, int epoch, int revision)
 {
     int exact = 0;
-    const char *packageName = "Ttk";
+    const char *packageName = "ttk";
     const char *errMsg = NULL;
     void *pkgClientData = NULL;
     const char *actualVersion = Tcl_PkgRequireEx(
 	interp, packageName, version, exact, &pkgClientData);
-    const TtkStubs *stubsPtr = (const TtkStubs *)pkgClientData;
+    const TtkStubs *stubsPtr;
 
     if (!actualVersion) {
-	return NULL;
+	packageName = "Ttk";
+	actualVersion = Tcl_PkgRequireEx(
+		interp, packageName, version, exact, &pkgClientData);
+	if (!actualVersion) {
+	    return NULL;
+	}
     }
 
+    stubsPtr = (const TtkStubs *)pkgClientData;
     if (!stubsPtr) {
 	errMsg = "missing stub table pointer";
 	goto error;
     }
     if (stubsPtr->epoch != epoch) {

Index: generic/ttk/ttkTagSet.c
==================================================================
--- generic/ttk/ttkTagSet.c
+++ generic/ttk/ttkTagSet.c
@@ -1,9 +1,9 @@
 /*
  * Tag tables.  3/4-baked, work in progress.
  *
- * Copyright (C) 2005, Joe English.  Freely redistributable.
+ * Copyright © 2005, Joe English.  Freely redistributable.
  */
 
 #include "tkInt.h"
 #include "ttkTheme.h"
 #include "ttkWidget.h"
@@ -138,11 +138,11 @@
 	ckfree(tagset);
     	return NULL;
     }
 
     tagset->tags = (Ttk_Tag *)ckalloc((objc+1) * sizeof(Ttk_Tag));
-    for (i=0; i<objc; ++i) {
+    for (i = 0; i < objc; ++i) {
 	tagset->tags[i] = Ttk_GetTagFromObj(tagTable, objv[i]);
     }
     tagset->tags[i] = NULL;
     tagset->nTags = objc;
 
@@ -199,10 +199,39 @@
     tagset->tags = (Ttk_Tag *)ckrealloc(tagset->tags,
 	    (tagset->nTags+1)*sizeof(tagset->tags[0]));
     tagset->tags[tagset->nTags++] = tag;
     return 1;
 }
+
+/* Ttk_TagSetAddSet -- add a tag set to a tag set.
+ *
+ * Returns: 0 if tagset already contained tags,
+ * 1 if tagset was modified.
+ */
+int Ttk_TagSetAddSet(Ttk_TagSet tagset, Ttk_TagSet tagsetFrom)
+{
+    int i, j, result = 0, found, total, nTags = tagset->nTags;
+    Ttk_Tag tag;
+
+    total = tagsetFrom->nTags + tagset->nTags;
+    tagset->tags = (Ttk_Tag *)ckrealloc(tagset->tags,
+	    (total)*sizeof(tagset->tags[0]));
+    for (j = 0; j < tagsetFrom->nTags; ++j) {
+	tag = tagsetFrom->tags[j];
+	found = 0;
+	for (i = 0; i < nTags; ++i) {
+	    if (tagset->tags[i] == tag) {
+		found = 1;
+		break;
+	    }
+	}
+	if (found) continue;
+	tagset->tags[tagset->nTags++] = tag;
+	result = 1;
+    }
+    return result;
+}
 
 /* Ttk_TagSetRemove -- remove a tag from a tag set.
  *
  * Returns: 0 if tagset did not contain tag,
  * 1 if tagset was modified.
@@ -269,18 +298,29 @@
 /*------------------------------------------------------------------------
  * +++ Tag values.
  */
 
 #define OBJ_AT(record, offset) (*(Tcl_Obj**)(((char*)record)+offset))
+
+void Ttk_TagSetDefaults(Ttk_TagTable tagTable, Ttk_Style style, void *record)
+{
+    const Tk_OptionSpec *optionSpec = tagTable->optionSpecs;
+    memset(record, 0, tagTable->recordSize);
+
+    while (optionSpec->type != TK_OPTION_END) {
+	int offset = optionSpec->objOffset;
+	const char *optionName = optionSpec->optionName;
+	OBJ_AT(record, offset) = Ttk_StyleDefault(style, optionName);
+	++optionSpec;
+    }
+}
 
 void Ttk_TagSetValues(Ttk_TagTable tagTable, Ttk_TagSet tagSet, void *record)
 {
     const int LOWEST_PRIORITY = 0x7FFFFFFF;
     int i, j;
 
-    memset(record, 0, tagTable->recordSize);
-
     for (i = 0; tagTable->optionSpecs[i].type != TK_OPTION_END; ++i) {
 	const Tk_OptionSpec *optionSpec = tagTable->optionSpecs + i;
 	TkSizeT offset = optionSpec->objOffset;
 	int prio = LOWEST_PRIORITY;
 
@@ -303,12 +343,10 @@
 	TkSizeT offset = optionSpec->objOffset;
 	const char *optionName = optionSpec->optionName;
 	Tcl_Obj *val = Ttk_StyleMap(style, optionName, state);
 	if (val) {
 	    OBJ_AT(record, offset) = val;
-	} else if (OBJ_AT(record, offset) == 0) {
-	    OBJ_AT(record, offset) = Ttk_StyleDefault(style, optionName);
 	}
 	++optionSpec;
     }
 }
 

Index: generic/ttk/ttkTheme.c
==================================================================
--- generic/ttk/ttkTheme.c
+++ generic/ttk/ttkTheme.c
@@ -1,12 +1,12 @@
 /*
  * ttkTheme.c --
  *
  *	This file implements the widget styles and themes support.
  *
- * Copyright (c) 2002 Frederic Bonnet
- * Copyright (c) 2003 Joe English
+ * Copyright © 2002 Frederic Bonnet
+ * Copyright © 2003 Joe English
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -93,11 +93,11 @@
     return 0;
 }
 
 /*
  * Ttk_StyleDefault --
- * 	Look up default resource setting the in the specified style.
+ * 	Look up default resource setting in the specified style.
  */
 Tcl_Obj *Ttk_StyleDefault(Ttk_Style style, const char *optionName)
 {
     while (style) {
 	Tcl_HashEntry *entryPtr =
@@ -1260,14 +1260,14 @@
     }
 
     styleName = Tcl_GetString(objv[2]);
     stylePtr = Ttk_GetStyle(theme, styleName);
 
-    if (objc == 3) {		/* style default $styleName */
+    if (objc == 3) {		/* style configure $styleName */
 	Tcl_SetObjResult(interp, HashTableToDict(&stylePtr->defaultsTable));
 	return TCL_OK;
-    } else if (objc == 4) {	/* style default $styleName -option */
+    } else if (objc == 4) {	/* style configure $styleName -option */
 	const char *optionName = Tcl_GetString(objv[3]);
 	Tcl_HashEntry *entryPtr =
 	    Tcl_FindHashEntry(&stylePtr->defaultsTable, optionName);
 	if (entryPtr) {
 	    Tcl_SetObjResult(interp, (Tcl_Obj*)Tcl_GetHashValue(entryPtr));
@@ -1313,13 +1313,11 @@
 	Tcl_WrongNumArgs(interp, 2, objv, "style -option ?state? ?default?");
 	return TCL_ERROR;
     }
 
     style = Ttk_GetStyle(theme, Tcl_GetString(objv[2]));
-    if (!style) {
-	return TCL_ERROR;
-    }
+
     optionName = Tcl_GetString(objv[3]);
 
     if (objc >= 5) {
 	Ttk_StateSpec stateSpec;
 	/* @@@ SB: Ttk_GetStateFromObj(); 'offbits' spec is ignored */
@@ -1609,10 +1607,35 @@
 	Ttk_RegisterLayoutTemplate(theme, layoutName, layoutTemplate);
 	ThemeChanged(pkgPtr);
     }
     return TCL_OK;
 }
+
+/* + style theme styles ?$theme? --
+ * 	Return list of styles available in $theme.
+ *      Use the current theme if $theme is omitted.
+ */
+static int StyleThemeStylesCmd(
+    TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+{
+    Ttk_Theme themePtr;
+
+    if (objc < 3 || objc > 4) {
+        Tcl_WrongNumArgs(interp, 3, objv, "?theme?");
+        return TCL_ERROR;
+    }
+
+    if (objc == 3) {
+        themePtr = Ttk_GetCurrentTheme(interp);
+    } else {
+        themePtr = Ttk_GetTheme(interp, Tcl_GetString(objv[3]));
+    }
+    if (!themePtr)
+        return TCL_ERROR;
+
+    return TtkEnumerateHashTable(interp, &themePtr->styleTable);
+}
 
 /* + style theme use $theme --
  *  	Sets the current theme to $theme
  */
 static int
@@ -1649,10 +1672,11 @@
 
 static const Ttk_Ensemble StyleThemeEnsemble[] = {
     { "create", StyleThemeCreateCmd, 0 },
     { "names", StyleThemeNamesCmd, 0 },
     { "settings", StyleThemeSettingsCmd, 0 },
+    { "styles", StyleThemeStylesCmd, 0 },
     { "use", StyleThemeUseCmd, 0 },
     { NULL, 0, 0 }
 };
 
 static const Ttk_Ensemble StyleElementEnsemble[] = {

Index: generic/ttk/ttkTheme.h
==================================================================
--- generic/ttk/ttkTheme.h
+++ generic/ttk/ttkTheme.h
@@ -306,10 +306,11 @@
 MODULE_SCOPE Ttk_Box Ttk_LayoutNodeInternalParcel(Ttk_Layout,Ttk_Element);
 MODULE_SCOPE Ttk_Padding Ttk_LayoutNodeInternalPadding(Ttk_Layout,Ttk_Element);
 MODULE_SCOPE void Ttk_LayoutNodeReqSize(Ttk_Layout, Ttk_Element, int *w, int *h);
 
 MODULE_SCOPE void Ttk_PlaceElement(Ttk_Layout, Ttk_Element, Ttk_Box);
+MODULE_SCOPE void Ttk_AnchorElement(Ttk_Element node, Tk_Anchor anchor);
 MODULE_SCOPE void Ttk_ChangeElementState(Ttk_Element,unsigned set,unsigned clr);
 
 MODULE_SCOPE Tcl_Obj *Ttk_QueryOption(Ttk_Layout, const char *, Ttk_State);
 
 TTKAPI Ttk_Style Ttk_LayoutStyle(Ttk_Layout);
@@ -348,13 +349,13 @@
  * +++ Miscellaneous enumerations.
  * 	Other stuff that element implementations need to know about.
  */
 typedef enum 			/* -default option values */
 {
-    TTK_BUTTON_DEFAULT_NORMAL,	/* widget defaultable */
     TTK_BUTTON_DEFAULT_ACTIVE,	/* currently the default widget */
-    TTK_BUTTON_DEFAULT_DISABLED	/* not defaultable */
+    TTK_BUTTON_DEFAULT_DISABLED,	/* not defaultable */
+    TTK_BUTTON_DEFAULT_NORMAL	/* widget defaultable */
 } Ttk_ButtonDefaultState;
 
 TTKAPI int Ttk_GetButtonDefaultStateFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_ButtonDefaultState *);
 
 typedef enum 			/* -compound option values */

Index: generic/ttk/ttkTrack.c
==================================================================
--- generic/ttk/ttkTrack.c
+++ generic/ttk/ttkTrack.c
@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004, Joe English
  *
  * TtkTrackElementState() -- helper routine for widgets
  * like scrollbars in which individual elements may
  * be active or pressed instead of the widget as a whole.
  *

Index: generic/ttk/ttkTreeview.c
==================================================================
--- generic/ttk/ttkTreeview.c
+++ generic/ttk/ttkTreeview.c
@@ -1,27 +1,32 @@
 /*
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004, Joe English
  *
  * ttk::treeview widget implementation.
  */
 
 #include "tkInt.h"
-#include "ttkTheme.h"
+#include "ttkThemeInt.h"
 #include "ttkWidget.h"
 
 #define DEF_TREE_ROWS		"10"
+#define DEF_TITLECOLUMNS	"0"
+#define DEF_TITLEITEMS		"0"
+#define DEF_STRIPED		"0"
 #define DEF_COLWIDTH		"200"
 #define DEF_MINWIDTH		"20"
 
-static const int DEFAULT_ROWHEIGHT 	= 20;
+static const Tk_Anchor DEFAULT_IMAGEANCHOR = TK_ANCHOR_W;
 static const int DEFAULT_INDENT 	= 20;
-static const int HALO   		= 4;	/* separator */
+static const int HALO   		= 4;	/* heading separator */
 
 #define TTK_STATE_OPEN TTK_STATE_USER1
 #define TTK_STATE_LEAF TTK_STATE_USER2
 
 #define STATE_CHANGED	 	(0x100)	/* item state option changed */
+
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
 
 /*------------------------------------------------------------------------
  * +++ Tree items.
  *
  * INVARIANTS:
@@ -46,28 +51,47 @@
     Tcl_Obj	*textObj;
     Tcl_Obj	*imageObj;
     Tcl_Obj	*valuesObj;
     Tcl_Obj	*openObj;
     Tcl_Obj	*tagsObj;
+    Tcl_Obj     *selObj;
+    Tcl_Obj     *imageAnchorObj;
+    int 	hidden;
+    int		height; 	/* Height is in number of row heights */
+
+    Ttk_TagSet  *cellTagSets;
+    TkSizeT	nTagSets;
 
     /*
      * Derived resources:
      */
     Ttk_TagSet	tagset;
     Ttk_ImageSpec *imagespec;
+    int itemPos; 		/* Counting items */
+    int visiblePos; 		/* Counting visible items */
+    int rowPos;			/* Counting rows (visible physical space) */
 };
 
 #define ITEM_OPTION_TAGS_CHANGED	0x100
 #define ITEM_OPTION_IMAGE_CHANGED	0x200
 
 static const Tk_OptionSpec ItemOptionSpecs[] = {
     {TK_OPTION_STRING, "-text", "text", "Text",
 	"", offsetof(TreeItem,textObj), TCL_INDEX_NONE,
+	0,0,0 },
+    {TK_OPTION_INT, "-height", "height", "Height",
+	"1", TCL_INDEX_NONE, offsetof(TreeItem,height),
+	0,0,0 },
+    {TK_OPTION_BOOLEAN, "-hidden", "hidden", "Hidden",
+	"0", TCL_INDEX_NONE, offsetof(TreeItem,hidden),
 	0,0,0 },
     {TK_OPTION_STRING, "-image", "image", "Image",
 	NULL, offsetof(TreeItem,imageObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,ITEM_OPTION_IMAGE_CHANGED },
+    {TK_OPTION_ANCHOR, "-imageanchor", "imageAnchor", "ImageAnchor",
+	NULL, offsetof(TreeItem,imageAnchorObj), TCL_INDEX_NONE,
+	TK_OPTION_NULL_OK,0,0 },
     {TK_OPTION_STRING, "-values", "values", "Values",
 	NULL, offsetof(TreeItem,valuesObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,0 },
     {TK_OPTION_BOOLEAN, "-open", "open", "Open",
 	"0", offsetof(TreeItem,openObj), TCL_INDEX_NONE,
@@ -77,12 +101,13 @@
 	TK_OPTION_NULL_OK,0,ITEM_OPTION_TAGS_CHANGED },
 
     {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
 };
 
-/* Forward declaration */
+/* Forward declarations */
 static void RemoveTag(TreeItem *, Ttk_Tag);
+static void RemoveTagFromCellsAtItem(TreeItem *, Ttk_Tag);
 
 /* + NewItem --
  * 	Allocate a new, uninitialized, unlinked item
  */
 static TreeItem *NewItem(void)
@@ -96,10 +121,16 @@
     item->textObj = NULL;
     item->imageObj = NULL;
     item->valuesObj = NULL;
     item->openObj = NULL;
     item->tagsObj = NULL;
+    item->selObj = NULL;
+    item->imageAnchorObj = NULL;
+    item->hidden = 0;
+    item->height = 1;
+    item->cellTagSets = NULL;
+    item->nTagSets = 0;
 
     item->tagset = NULL;
     item->imagespec = NULL;
 
     return item;
@@ -108,18 +139,29 @@
 /* + FreeItem --
  * 	Destroy an item
  */
 static void FreeItem(TreeItem *item)
 {
+    TkSizeT i;
     if (item->textObj) { Tcl_DecrRefCount(item->textObj); }
     if (item->imageObj) { Tcl_DecrRefCount(item->imageObj); }
     if (item->valuesObj) { Tcl_DecrRefCount(item->valuesObj); }
     if (item->openObj) { Tcl_DecrRefCount(item->openObj); }
     if (item->tagsObj) { Tcl_DecrRefCount(item->tagsObj); }
+    if (item->selObj) { Tcl_DecrRefCount(item->selObj); }
+    if (item->imageAnchorObj) { Tcl_DecrRefCount(item->imageAnchorObj); }
 
     if (item->tagset)	{ Ttk_FreeTagSet(item->tagset); }
     if (item->imagespec) { TtkFreeImageSpec(item->imagespec); }
+    if (item->cellTagSets) {
+	for (i = 0; i < item->nTagSets; ++i) {
+	    if (item->cellTagSets[i] != NULL) {
+		Ttk_FreeTagSet(item->cellTagSets[i]);
+	    }
+	}
+	ckfree(item->cellTagSets);
+    }
 
     ckfree(item);
 }
 
 static void FreeItemCB(void *clientData) { FreeItem((TreeItem *)clientData); }
@@ -181,39 +223,56 @@
  * +++ Display items and tag options.
  */
 
 typedef struct {
     Tcl_Obj *textObj;		/* taken from item / data cell */
-    Tcl_Obj *imageObj;		/* taken from item */
+    Tcl_Obj *imageObj;		/* taken from item or tag*/
+    Tcl_Obj *imageAnchorObj;	/* taken from item or tag */
     Tcl_Obj *anchorObj;		/* from column <<NOTE-ANCHOR>> */
     Tcl_Obj *backgroundObj;	/* remainder from tag */
+    Tcl_Obj *stripedBgObj;
     Tcl_Obj *foregroundObj;
     Tcl_Obj *fontObj;
+    Tcl_Obj *paddingObj;
 } DisplayItem;
 
-static const Tk_OptionSpec TagOptionSpecs[] = {
+static const Tk_OptionSpec DisplayOptionSpecs[] = {
     {TK_OPTION_STRING, "-text", "text", "Text",
 	NULL, offsetof(DisplayItem,textObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,0 },
+    {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
+	"center", offsetof(DisplayItem,anchorObj), TCL_INDEX_NONE,
+	0, 0, GEOMETRY_CHANGED},	/* <<NOTE-ANCHOR>> */
+    /* From here down are the tags options. The index in TagOptionSpecs
+     * below should be kept in synch with this position.
+     */
     {TK_OPTION_STRING, "-image", "image", "Image",
 	NULL, offsetof(DisplayItem,imageObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,0 },
-    {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
-	NULL, offsetof(DisplayItem,anchorObj), TCL_INDEX_NONE,
-	TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED},	/* <<NOTE-ANCHOR>> */
+    {TK_OPTION_ANCHOR, "-imageanchor", "imageAnchor", "ImageAnchor",
+	NULL, offsetof(DisplayItem,imageAnchorObj), TCL_INDEX_NONE,
+	TK_OPTION_NULL_OK,0,0 },
     {TK_OPTION_COLOR, "-background", "windowColor", "WindowColor",
 	NULL, offsetof(DisplayItem,backgroundObj), TCL_INDEX_NONE,
+	TK_OPTION_NULL_OK,0,0 },
+    {TK_OPTION_COLOR, "-stripedbackground", "windowColor", "WindowColor",
+	NULL, offsetof(DisplayItem,stripedBgObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,0 },
     {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
 	NULL, offsetof(DisplayItem,foregroundObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,0 },
     {TK_OPTION_FONT, "-font", "font", "Font",
 	NULL, offsetof(DisplayItem,fontObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
+    {TK_OPTION_STRING, "-padding", "padding", "Pad",
+	NULL, offsetof(DisplayItem,paddingObj), TCL_INDEX_NONE,
+	TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
 
     {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
 };
+
+static const Tk_OptionSpec *TagOptionSpecs = &DisplayOptionSpecs[2];
 
 /*------------------------------------------------------------------------
  * +++ Columns.
  *
  * There are separate option tables associated with the column record:
@@ -222,10 +281,11 @@
  */
 typedef struct {
     int 	width;		/* Column width, in pixels */
     int 	minWidth;	/* Minimum column width, in pixels */
     int 	stretch;	/* Should column stretch while resizing? */
+    int         separator;      /* Should this column have a separator? */
     Tcl_Obj	*idObj;		/* Column identifier, from -columns option */
 
     Tcl_Obj	*anchorObj;	/* -anchor for cell data <<NOTE-ANCHOR>> */
 
     /* Column heading data:
@@ -238,17 +298,20 @@
     Ttk_State	headingState;		/* ... */
 
     /* Temporary storage for cell data
      */
     Tcl_Obj 	*data;
+    int         selected;
+    Ttk_TagSet	tagset;
 } TreeColumn;
 
 static void InitColumn(TreeColumn *column)
 {
-    column->width = 200;
-    column->minWidth = 20;
+    column->width = atoi(DEF_COLWIDTH);
+    column->minWidth = atoi(DEF_MINWIDTH);
     column->stretch = 1;
+    column->separator = 0;
     column->idObj = 0;
     column->anchorObj = 0;
 
     column->headingState = 0;
     column->headingObj = 0;
@@ -256,10 +319,11 @@
     column->headingAnchorObj = 0;
     column->headingStateObj = 0;
     column->headingCommandObj = 0;
 
     column->data = 0;
+    column->tagset = NULL;
 }
 
 static void FreeColumn(TreeColumn *column)
 {
     if (column->idObj) { Tcl_DecrRefCount(column->idObj); }
@@ -278,10 +342,13 @@
     {TK_OPTION_INT, "-width", "width", "Width",
 	DEF_COLWIDTH, TCL_INDEX_NONE, offsetof(TreeColumn,width),
 	0,0,GEOMETRY_CHANGED },
     {TK_OPTION_INT, "-minwidth", "minWidth", "MinWidth",
 	DEF_MINWIDTH, TCL_INDEX_NONE, offsetof(TreeColumn,minWidth),
+	0,0,0 },
+    {TK_OPTION_BOOLEAN, "-separator", "separator", "Separator",
+	"0", TCL_INDEX_NONE, offsetof(TreeColumn,separator),
 	0,0,0 },
     {TK_OPTION_BOOLEAN, "-stretch", "stretch", "Stretch",
 	"1", TCL_INDEX_NONE, offsetof(TreeColumn,stretch),
 	0,0,GEOMETRY_CHANGED },
     {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
@@ -366,23 +433,25 @@
     /* Resources acquired at initialization-time:
      */
     Tk_OptionTable itemOptionTable;
     Tk_OptionTable columnOptionTable;
     Tk_OptionTable headingOptionTable;
-    Tk_OptionTable tagOptionTable;
+    Tk_OptionTable displayOptionTable;
     Tk_BindingTable bindingTable;
     Ttk_TagTable tagTable;
 
     /* Acquired in GetLayout hook:
      */
     Ttk_Layout itemLayout;
     Ttk_Layout cellLayout;
     Ttk_Layout headingLayout;
     Ttk_Layout rowLayout;
+    Ttk_Layout separatorLayout;
 
     int headingHeight;		/* Space for headings */
     int rowHeight;		/* Height of each item */
+    int colSeparatorWidth;	/* Width of column separator, if used */
     int indent;			/* #pixels horizontal offset for child items */
 
     /* Tree data:
      */
     Tcl_HashTable items;	/* Map: item name -> item */
@@ -400,31 +469,37 @@
     Tcl_Obj *columnsObj;	/* List of symbolic column names */
     Tcl_Obj *displayColumnsObj;	/* List of columns to display */
 
     Tcl_Obj *heightObj;		/* height (rows) */
     Tcl_Obj *paddingObj;	/* internal padding */
+    int nTitleColumns;	/* -titlecolumns */
+    int nTitleItems;		/* -titleitems */
+    int striped;		/* -striped option */
 
     Tcl_Obj *showObj;		/* -show list */
     Tcl_Obj *selectModeObj;	/* -selectmode option */
+    Tcl_Obj *selectTypeObj;	/* -selecttype option */
 
     Scrollable xscroll;
     ScrollHandle xscrollHandle;
     Scrollable yscroll;
     ScrollHandle yscrollHandle;
 
     /* Derived resources:
      */
     Tcl_HashTable columnNames;	/* Map: column name -> column table entry */
-    int nColumns; 		/* #columns */
-    unsigned showFlags;		/* bitmask of subparts to display */
-
+    TkSizeT nColumns; 		/* #columns */
+    TkSizeT nDisplayColumns;	/* #display columns */
     TreeColumn **displayColumns; /* List of columns for display (incl tree) */
-    int nDisplayColumns;	/* #display columns */
+    int titleWidth;		/* Width of non-scrolled columns */
+    int titleRows;		/* Height of non-scrolled items, in rows */
+    int totalRows;		/* Height of non-hidden items, in rows */
+    int rowPosNeedsUpdate;	/* Internal rowPos data needs update */
     Ttk_Box headingArea;	/* Display area for column headings */
     Ttk_Box treeArea;   	/* Display area for tree */
     int slack;			/* Slack space (see Resizing section) */
-
+    unsigned showFlags;		/* bitmask of subparts to display */
 } TreePart;
 
 typedef struct {
     WidgetCore core;
     TreePart tree;
@@ -435,10 +510,11 @@
 #define DCOLUMNS_CHANGED	(USER_MASK<<1)
 #define SCROLLCMD_CHANGED	(USER_MASK<<2)
 #define SHOW_CHANGED 		(USER_MASK<<3)
 
 static const char *const SelectModeStrings[] = { "none", "browse", "extended", NULL };
+static const char *const SelectTypeStrings[] = { "item", "cell", NULL };
 
 static const Tk_OptionSpec TreeviewOptionSpecs[] = {
     {TK_OPTION_STRING, "-columns", "columns", "Columns",
 	"", offsetof(Treeview,tree.columnsObj), TCL_INDEX_NONE,
 	0, 0,COLUMNS_CHANGED | GEOMETRY_CHANGED /*| READONLY_OPTION*/ },
@@ -449,18 +525,30 @@
 	DEFAULT_SHOW, offsetof(Treeview,tree.showObj), TCL_INDEX_NONE,
 	0, 0,SHOW_CHANGED | GEOMETRY_CHANGED },
 
     {TK_OPTION_STRING_TABLE, "-selectmode", "selectMode", "SelectMode",
 	"extended", offsetof(Treeview,tree.selectModeObj), TCL_INDEX_NONE,
-	0, (void *)SelectModeStrings, 0 },
+	0, SelectModeStrings, 0 },
+    {TK_OPTION_STRING_TABLE, "-selecttype", "selectType", "SelectType",
+	"item", offsetof(Treeview,tree.selectTypeObj), TCL_INDEX_NONE,
+	0, SelectTypeStrings, 0 },
 
     {TK_OPTION_PIXELS, "-height", "height", "Height",
 	DEF_TREE_ROWS, offsetof(Treeview,tree.heightObj), TCL_INDEX_NONE,
 	0, 0,GEOMETRY_CHANGED},
     {TK_OPTION_STRING, "-padding", "padding", "Pad",
 	NULL, offsetof(Treeview,tree.paddingObj), TCL_INDEX_NONE,
 	TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
+    {TK_OPTION_INT, "-titlecolumns", "titlecolumns", "Titlecolumns",
+	DEF_TITLECOLUMNS, TCL_INDEX_NONE, offsetof(Treeview,tree.nTitleColumns),
+	0,0,GEOMETRY_CHANGED},
+    {TK_OPTION_INT, "-titleitems", "titleitems", "Titleitems",
+	DEF_TITLEITEMS, TCL_INDEX_NONE, offsetof(Treeview,tree.nTitleItems),
+	0,0,GEOMETRY_CHANGED},
+    {TK_OPTION_BOOLEAN, "-striped", "striped", "Striped",
+	DEF_STRIPED, TCL_INDEX_NONE, offsetof(Treeview,tree.striped),
+	0,0,GEOMETRY_CHANGED},
 
     {TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
 	NULL, TCL_INDEX_NONE, offsetof(Treeview, tree.xscroll.scrollCmd),
 	TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED},
     {TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
@@ -483,10 +571,24 @@
     while (entryPtr != NULL) {
 	func(Tcl_GetHashValue(entryPtr));
 	entryPtr = Tcl_NextHashEntry(&search);
     }
 }
+
+static int CellSelectionClear(Treeview *tv)
+{
+    TreeItem *item;
+    int anyChange = 0;
+    for (item=tv->tree.root; item; item = NextPreorder(item)) {
+	if (item->selObj != NULL) {
+	    Tcl_DecrRefCount(item->selObj);
+	    item->selObj = NULL;
+	    anyChange = 1;
+	}
+    }
+    return anyChange;
+}
 
 /* + unshareObj(objPtr) --
  * 	Ensure that a Tcl_Obj * has refcount 1 -- either return objPtr
  * 	itself,	or a duplicated copy.
  */
@@ -509,10 +611,37 @@
 {
     Ttk_RebindSublayout(layout, recordPtr);
     Ttk_PlaceLayout(layout, state, b);
     Ttk_DrawLayout(layout, state, d);
 }
+
+/* DisplayLayoutTree --
+ *	Like DisplayLayout, but for the tree column.
+ */
+static void DisplayLayoutTree(
+    Tk_Anchor imageAnchor, Tk_Anchor textAnchor,
+    Ttk_Layout layout, void *recordPtr, Ttk_State state, Ttk_Box b, Drawable d)
+{
+    Ttk_Element elem;
+    Ttk_RebindSublayout(layout, recordPtr);
+
+    elem = Ttk_FindElement(layout, "image");
+    if (elem != NULL) {
+	Ttk_AnchorElement(elem, imageAnchor);
+    }
+    elem = Ttk_FindElement(layout, "text");
+    if (elem != NULL) {
+	Ttk_AnchorElement(elem, textAnchor);
+    }
+    elem = Ttk_FindElement(layout, "focus");
+    if (elem != NULL) {
+	Ttk_AnchorElement(elem, textAnchor);
+    }
+
+    Ttk_PlaceLayout(layout, state, b);
+    Ttk_DrawLayout(layout, state, d);
+}
 
 /* + GetColumn --
  * 	Look up column by name or number.
  * 	Returns: pointer to column table entry, NULL if not found.
  * 	Leaves an error message in interp->result on error.
@@ -519,26 +648,26 @@
  */
 static TreeColumn *GetColumn(
     Tcl_Interp *interp, Treeview *tv, Tcl_Obj *columnIDObj)
 {
     Tcl_HashEntry *entryPtr;
-    int columnIndex;
+    TkSizeT columnIndex;
 
     /* Check for named column:
      */
     entryPtr = Tcl_FindHashEntry(
 	    &tv->tree.columnNames, Tcl_GetString(columnIDObj));
     if (entryPtr) {
 	return (TreeColumn *)Tcl_GetHashValue(entryPtr);
     }
 
-    /* Check for number:
+    /* Check for index:
      */
-    if (Tcl_GetIntFromObj(NULL, columnIDObj, &columnIndex) == TCL_OK) {
-	if (columnIndex < 0 || columnIndex >= tv->tree.nColumns) {
+    if (TkGetIntForIndex(columnIDObj, tv->tree.nColumns - 1, 1, &columnIndex) == TCL_OK) {
+	if (columnIndex == TCL_INDEX_NONE || columnIndex >= tv->tree.nColumns) {
 	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
-		    "Column index %s out of bounds",
+		    "Column index \"%s\" out of bounds",
 		    Tcl_GetString(columnIDObj)));
 	    Tcl_SetErrorCode(interp, "TTK", "TREE", "COLBOUND", NULL);
 	    return NULL;
 	}
 
@@ -554,15 +683,15 @@
  * 	Look up column by name, number, or display index.
  */
 static TreeColumn *FindColumn(
     Tcl_Interp *interp, Treeview *tv, Tcl_Obj *columnIDObj)
 {
-    int colno;
+    TkSizeT colno;
 
-    if (sscanf(Tcl_GetString(columnIDObj), "#%d", &colno) == 1)
+    if (sscanf(Tcl_GetString(columnIDObj), "#%" TKSIZET_MODIFIER "d", &colno) == 1)
     {	/* Display column specification, #n */
-	if (colno >= 0 && colno < tv->tree.nDisplayColumns) {
+	if (colno != TCL_INDEX_NONE && (TkSizeT)colno < tv->tree.nDisplayColumns) {
 	    return tv->tree.displayColumns[colno];
 	}
 	/* else */
 	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 	    "Column %s out of range", Tcl_GetString(columnIDObj)));
@@ -602,11 +731,11 @@
 static TreeItem **GetItemListFromObj(
     Tcl_Interp *interp, Treeview *tv, Tcl_Obj *objPtr)
 {
     TreeItem **items;
     Tcl_Obj **elements;
-    int i, nElements;
+    TkSizeT i, nElements;
 
     if (Tcl_ListObjGetElements(interp,objPtr,&nElements,&elements) != TCL_OK) {
 	return NULL;
     }
 
@@ -646,11 +775,11 @@
 /* + TreeviewFreeColumns --
  * 	Free column data.
  */
 static void TreeviewFreeColumns(Treeview *tv)
 {
-    int i;
+    TkSizeT i;
 
     Tcl_DeleteHashTable(&tv->tree.columnNames);
     Tcl_InitHashTable(&tv->tree.columnNames, TCL_STRING_KEYS);
 
     if (tv->tree.columns) {
@@ -695,14 +824,14 @@
 	    &tv->tree.columnNames, Tcl_GetString(columnName), &isNew);
 	Tcl_SetHashValue(entryPtr, tv->tree.columns + i);
 
 	InitColumn(tv->tree.columns + i);
 	Tk_InitOptions(
-	    interp, (ClientData)(tv->tree.columns + i),
+	    interp, tv->tree.columns + i,
 	    tv->tree.columnOptionTable, tv->core.tkwin);
 	Tk_InitOptions(
-	    interp, (ClientData)(tv->tree.columns + i),
+	    interp, tv->tree.columns + i,
 	    tv->tree.headingOptionTable, tv->core.tkwin);
 	Tcl_IncrRefCount(columnName);
 	tv->tree.columns[i].idObj = columnName;
     }
 
@@ -764,15 +893,22 @@
 /* + TreeWidth --
  * 	Compute the requested tree width from the sum of visible column widths.
  */
 static int TreeWidth(Treeview *tv)
 {
-    int i = FirstColumn(tv);
+    TkSizeT i = FirstColumn(tv);
     int width = 0;
 
+    tv->tree.titleWidth = 0;
     while (i < tv->tree.nDisplayColumns) {
+	if (i == (TkSizeT)tv->tree.nTitleColumns) {
+	    tv->tree.titleWidth = width;
+	}
 	width += tv->tree.displayColumns[i++]->width;
+    }
+    if ((TkSizeT)tv->tree.nTitleColumns >= tv->tree.nDisplayColumns) {
+	tv->tree.titleWidth = width;
     }
     return width;
 }
 
 /* + RecomputeSlack --
@@ -844,11 +980,11 @@
  * 	Adjust width of (stretchable) columns to the right by N pixels.
  * 	Returns: leftover slack.
  */
 static int ShoveRight(Treeview *tv, int i, int n)
 {
-    while (n != 0 && i < tv->tree.nDisplayColumns) {
+    while (n != 0 && (TkSizeT)i < tv->tree.nDisplayColumns) {
 	TreeColumn *c = tv->tree.displayColumns[i];
 	if (c->stretch) {
 	    n -= Stretch(c, n);
 	}
 	++i;
@@ -865,11 +1001,12 @@
  */
 static int DistributeWidth(Treeview *tv, int n)
 {
     int w = TreeWidth(tv);
     int m = 0;
-    int i, d, r;
+    TkSizeT  i;
+    int d, r;
 
     for (i = FirstColumn(tv); i < tv->tree.nDisplayColumns; ++i) {
 	if (tv->tree.displayColumns[i]->stretch) {
 	    ++m;
 	}
@@ -914,16 +1051,126 @@
     TreeColumn *c = tv->tree.displayColumns[i];
     int dl = delta - ShoveLeft(tv, i-1, delta - Stretch(c, delta));
     int dr = ShoveRight(tv, i+1, PickupSlack(tv, -dl));
     DepositSlack(tv, dr);
 }
+
+/*------------------------------------------------------------------------
+ * +++ Cells.
+ */
+
+typedef struct {
+    TreeItem *item;
+    TreeColumn *column;
+    Tcl_Obj *colObj;
+} TreeCell;
+
+/* + GetCellFromObj
+ * 	Get Row and Column from a cell ID.
+ */
+static int GetCellFromObj(
+    Tcl_Interp *interp, Treeview *tv, Tcl_Obj *obj,
+    int displayColumnOnly, int *displayColumn,
+    TreeCell *cell)
+{
+    int nElements;
+    Tcl_Obj **elements;
+
+    if (Tcl_ListObjGetElements(interp, obj, &nElements, &elements) != TCL_OK) {
+	return TCL_ERROR;
+    }
+    if (nElements != 2) {
+	Tcl_SetObjResult(interp, Tcl_NewStringObj(
+		"Cell id must be a list of two elements", -1));
+	Tcl_SetErrorCode(interp, "TTK", "TREE", "CELL", NULL);
+	return TCL_ERROR;
+    }
+    /* Valid item/column in each pair? */
+    cell->item = FindItem(interp, tv, elements[0]);
+    if (!cell->item) {
+	return TCL_ERROR;
+    }
+    cell->column = FindColumn(interp, tv, elements[1]);
+    if (!cell->column) {
+	return TCL_ERROR;
+    }
+    /* colObj is short lived and do not keep a reference counted */
+    cell->colObj = elements[1];
+    if (displayColumnOnly) {
+	TkSizeT i = FirstColumn(tv);
+	while (i < tv->tree.nDisplayColumns) {
+	    if (tv->tree.displayColumns[i] == cell->column) {
+		break;
+	    }
+	    ++i;
+	}
+	if (i == tv->tree.nDisplayColumns) { /* specified column unviewable */
+	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
+		    "Cell id must be in a visible column", -1));
+	    Tcl_SetErrorCode(interp, "TTK", "TREE", "CELL", NULL);
+	    return TCL_ERROR;
+	}
+	if (displayColumn != NULL) {
+	    *displayColumn = i;
+	}
+    }
+    return TCL_OK;
+}
+
+/* + GetCellListFromObj --
+ * 	Parse a Tcl_Obj * as a list of cells.
+ * 	Returns an array of cells; result must be ckfree()d.
+ *      On error, returns NULL and leaves an error
+ * 	message in interp.
+ */
+
+static TreeCell *GetCellListFromObj(
+	Tcl_Interp *interp, Treeview *tv, Tcl_Obj *objPtr, TkSizeT *nCells)
+{
+    TreeCell *cells;
+    TreeCell cell;
+    Tcl_Obj **elements;
+    Tcl_Obj *oneCell;
+    TkSizeT i;
+    int n;
+
+    if (Tcl_ListObjGetElements(interp, objPtr, &n, &elements) != TCL_OK) {
+	return NULL;
+    }
+
+    /* A two element list might be a single cell */
+    if (n == 2) {
+	if (GetCellFromObj(interp, tv, objPtr, 0, NULL, &cell)
+		== TCL_OK) {
+	    n = 1;
+	    oneCell = objPtr;
+	    elements = &oneCell;
+	} else {
+	    Tcl_ResetResult(interp);
+	}
+    }
+
+    cells = (TreeCell *) ckalloc(n * sizeof(TreeCell));
+    for (i = 0; i < (TkSizeT)n; ++i) {
+	if (GetCellFromObj(interp, tv, elements[i], 0, NULL, &cells[i]) != TCL_OK) {
+	    ckfree(cells);
+	    return NULL;
+	}
+    }
+
+    if (nCells) {
+	*nCells = n;
+    }
+    return cells;
+}
 
 /*------------------------------------------------------------------------
  * +++ Event handlers.
  */
 
 static TreeItem *IdentifyItem(Treeview *tv, int y); /*forward*/
+static TkSizeT IdentifyDisplayColumn(Treeview *tv, int x, int *x1); /*forward*/
 
 static const unsigned long TreeviewBindEventMask =
       KeyPressMask|KeyReleaseMask
     | ButtonPressMask|ButtonReleaseMask
     | PointerMotionMask|ButtonMotionMask
@@ -933,10 +1180,13 @@
 static void TreeviewBindEventProc(void *clientData, XEvent *event)
 {
     Treeview *tv = (Treeview *)clientData;
     TreeItem *item = NULL;
     Ttk_TagSet tagset;
+    int unused;
+    TkSizeT colno = TCL_INDEX_NONE;
+    TreeColumn *column = NULL;
 
     /*
      * Figure out where to deliver the event.
      */
     switch (event->type)
@@ -947,13 +1197,15 @@
 	    item = tv->tree.focus;
 	    break;
 	case ButtonPress:
 	case ButtonRelease:
 	    item = IdentifyItem(tv, event->xbutton.y);
+	    colno = IdentifyDisplayColumn(tv, event->xbutton.x, &unused);
 	    break;
 	case MotionNotify:
 	    item = IdentifyItem(tv, event->xmotion.y);
+	    colno = IdentifyDisplayColumn(tv, event->xmotion.x, &unused);
 	    break;
 	default:
 	    break;
     }
 
@@ -964,10 +1216,27 @@
     /* ASSERT: Ttk_GetTagSetFromObj succeeds.
      * NB: must use a local copy of the tagset,
      * in case a binding script stomps on -tags.
      */
     tagset = Ttk_GetTagSetFromObj(NULL, tv->tree.tagTable, item->tagsObj);
+
+    /*
+     * Pick up any cell tags.
+     */
+    if (colno != TCL_INDEX_NONE) {
+	column = tv->tree.displayColumns[colno];
+	if (column == &tv->tree.column0) {
+	    colno = 0;
+	} else {
+	    colno = column - tv->tree.columns + 1;
+	}
+	if (colno < item->nTagSets) {
+	    if (item->cellTagSets[colno] != NULL) {
+		Ttk_TagSetAddSet(tagset, item->cellTagSets[colno]);
+	    }
+	}
+    }
 
     /*
      * Fire binding:
      */
     Tcl_Preserve(clientData);
@@ -991,12 +1260,12 @@
 	Tk_CreateOptionTable(interp, ItemOptionSpecs);
     tv->tree.columnOptionTable =
 	Tk_CreateOptionTable(interp, ColumnOptionSpecs);
     tv->tree.headingOptionTable =
 	Tk_CreateOptionTable(interp, HeadingOptionSpecs);
-    tv->tree.tagOptionTable =
-	Tk_CreateOptionTable(interp, TagOptionSpecs);
+    tv->tree.displayOptionTable =
+	Tk_CreateOptionTable(interp, DisplayOptionSpecs);
 
     tv->tree.tagTable = Ttk_CreateTagTable(
 	interp, tv->core.tkwin, TagOptionSpecs, sizeof(DisplayItem));
     tv->tree.bindingTable = Tk_CreateBindingTable(interp);
     Tk_CreateEventHandler(tv->core.tkwin,
@@ -1004,26 +1273,37 @@
 
     tv->tree.itemLayout
 	= tv->tree.cellLayout
 	= tv->tree.headingLayout
 	= tv->tree.rowLayout
+	= tv->tree.separatorLayout
 	= 0;
-    tv->tree.headingHeight = tv->tree.rowHeight = DEFAULT_ROWHEIGHT;
+    tv->tree.headingHeight = tv->tree.rowHeight = 0;
+    tv->tree.colSeparatorWidth = 1;
     tv->tree.indent = DEFAULT_INDENT;
 
     Tcl_InitHashTable(&tv->tree.columnNames, TCL_STRING_KEYS);
     tv->tree.nColumns = tv->tree.nDisplayColumns = 0;
+    tv->tree.nTitleColumns = 0;
+    tv->tree.nTitleItems = 0;
+    tv->tree.titleWidth = 0;
+    tv->tree.titleRows = 0;
+    tv->tree.totalRows = 0;
+    tv->tree.rowPosNeedsUpdate = 1;
+    tv->tree.striped = 0;
     tv->tree.columns = NULL;
     tv->tree.displayColumns = NULL;
     tv->tree.showFlags = ~0;
 
     InitColumn(&tv->tree.column0);
+    tv->tree.column0.idObj = Tcl_NewStringObj("#0", 2);
+    Tcl_IncrRefCount(tv->tree.column0.idObj);
     Tk_InitOptions(
-	interp, (ClientData)(&tv->tree.column0),
+	interp, &tv->tree.column0,
 	tv->tree.columnOptionTable, tv->core.tkwin);
     Tk_InitOptions(
-	interp, (ClientData)(&tv->tree.column0),
+	interp, &tv->tree.column0,
 	tv->tree.headingOptionTable, tv->core.tkwin);
 
     Tcl_InitHashTable(&tv->tree.items, TCL_STRING_KEYS);
     tv->tree.serial = 0;
 
@@ -1030,11 +1310,11 @@
     tv->tree.focus = tv->tree.endPtr = 0;
 
     /* Create root item "":
      */
     tv->tree.root = NewItem();
-    Tk_InitOptions(interp, (ClientData)tv->tree.root,
+    Tk_InitOptions(interp, tv->tree.root,
 	tv->tree.itemOptionTable, tv->core.tkwin);
     tv->tree.root->tagset = Ttk_GetTagSetFromObj(NULL, tv->tree.tagTable, NULL);
     tv->tree.root->entryPtr = Tcl_CreateHashEntry(&tv->tree.items, "", &unused);
     Tcl_SetHashValue(tv->tree.root->entryPtr, tv->tree.root);
 
@@ -1060,15 +1340,17 @@
 
     if (tv->tree.itemLayout) Ttk_FreeLayout(tv->tree.itemLayout);
     if (tv->tree.cellLayout) Ttk_FreeLayout(tv->tree.cellLayout);
     if (tv->tree.headingLayout) Ttk_FreeLayout(tv->tree.headingLayout);
     if (tv->tree.rowLayout) Ttk_FreeLayout(tv->tree.rowLayout);
+    if (tv->tree.separatorLayout) Ttk_FreeLayout(tv->tree.separatorLayout);
 
+    FreeColumn(&tv->tree.column0);
     TreeviewFreeColumns(tv);
 
     if (tv->tree.displayColumns)
-	ckfree((ClientData)tv->tree.displayColumns);
+	ckfree(tv->tree.displayColumns);
 
     foreachHashEntry(&tv->tree.items, FreeItemCB);
     Tcl_DeleteHashTable(&tv->tree.items);
 
     TtkFreeScrollHandle(tv->tree.xscrollHandle);
@@ -1093,10 +1375,27 @@
 	mask |= DCOLUMNS_CHANGED;
     }
     if (mask & DCOLUMNS_CHANGED) {
 	if (TreeviewInitDisplayColumns(interp, tv) != TCL_OK)
 	    return TCL_ERROR;
+    }
+    if (mask & COLUMNS_CHANGED) {
+	CellSelectionClear(tv);
+    }
+    if (tv->tree.nTitleColumns < 0) {
+        Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+                "\"#%d\" is out of range",
+                tv->tree.nTitleColumns));
+	Tcl_SetErrorCode(interp, "TTK", "TREE", "TITLECOLUMNS", NULL);
+	return TCL_ERROR;
+    }
+    if (tv->tree.nTitleItems < 0) {
+        Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+                "\"%d\" is out of range",
+                tv->tree.nTitleItems));
+	Tcl_SetErrorCode(interp, "TTK", "TREE", "TITLEITEMS", NULL);
+	return TCL_ERROR;
     }
     if (mask & SCROLLCMD_CHANGED) {
 	TtkScrollbarUpdateRequired(tv->tree.xscrollHandle);
 	TtkScrollbarUpdateRequired(tv->tree.yscrollHandle);
     }
@@ -1108,10 +1407,11 @@
 
     if (TtkCoreConfigure(interp, recordPtr, mask) != TCL_OK) {
 	return TCL_ERROR;
     }
 
+    tv->tree.rowPosNeedsUpdate = 1;
     tv->tree.showFlags = showFlags;
 
     if (mask & (SHOW_CHANGED | DCOLUMNS_CHANGED)) {
 	RecomputeSlack(tv);
     }
@@ -1142,10 +1442,19 @@
     if (item->valuesObj) {
 	int unused;
 	if (Tcl_ListObjLength(interp, item->valuesObj, &unused) != TCL_OK)
 	    goto error;
     }
+
+    /* Check -height
+     */
+    if (item->height < 1) {
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"Invalid item height %d", item->height));
+	Tcl_SetErrorCode(interp, "TTK", "TREE", "HEIGHT", NULL);
+	goto error;
+    }
 
     /* Check -image.
      */
     if ((mask & ITEM_OPTION_IMAGE_CHANGED) && item->imageObj) {
 	newImageSpec = TtkGetImageSpec(interp, tv->core.tkwin, item->imageObj);
@@ -1188,10 +1497,11 @@
     }
     if (mask & ITEM_OPTION_IMAGE_CHANGED) {
 	if (item->imagespec) { TtkFreeImageSpec(item->imagespec); }
 	item->imagespec = newImageSpec;
     }
+    tv->tree.rowPosNeedsUpdate = 1;
     TtkRedisplayWidget(&tv->core);
     return TCL_OK;
 
 error:
     Tk_RestoreSavedOptions(&savedOptions);
@@ -1288,72 +1598,99 @@
 
 /*------------------------------------------------------------------------
  * +++ Geometry routines.
  */
 
-/* + CountRows --
- * 	Returns the number of viewable rows rooted at item
- */
-static int CountRows(TreeItem *item)
-{
-    int rows = 1;
-
-    if (item->state & TTK_STATE_OPEN) {
-	TreeItem *child = item->children;
-	while (child) {
-	    rows += CountRows(child);
-	    child = child->next;
-	}
-    }
-    return rows;
-}
-
-/* + IdentifyRow --
- * 	Recursive search for item at specified y position.
- * 	Main work routine for IdentifyItem()
- */
-static TreeItem *IdentifyRow(
-    Treeview *tv,	/* Widget record */
-    TreeItem *item, 	/* Where to start search */
-    int *ypos,		/* Scan position */
-    int y)		/* Target y coordinate */
-{
-    while (item) {
-	int next_ypos = *ypos + tv->tree.rowHeight;
-	if (*ypos <= y && y <= next_ypos) {
-	    return item;
-	}
-	*ypos = next_ypos;
-	if (item->state & TTK_STATE_OPEN) {
-	    TreeItem *subitem = IdentifyRow(tv, item->children, ypos, y);
-	    if (subitem) {
-		return subitem;
-	    }
-	}
-	item = item->next;
-    }
-    return 0;
+/* + UpdatePositionItem --
+ * 	Update position data for all visible items.
+ */
+static void UpdatePositionItem(
+    Treeview *tv, TreeItem *item, int hidden,
+    int *rowPos, int *itemPos, int *visiblePos)
+{
+    TreeItem *child = item->children;
+    item->itemPos = *itemPos;
+    *itemPos += 1;
+
+    if (item->hidden) {
+	hidden = 1;
+    }
+
+    if (hidden) {
+	item->rowPos = -1;
+	item->visiblePos = -1;
+    } else {
+	item->rowPos = *rowPos;
+	item->visiblePos = *visiblePos;
+	if (*visiblePos == tv->tree.nTitleItems) {
+	    tv->tree.titleRows = *rowPos;
+	}
+
+	*visiblePos += 1;
+	*rowPos += item->height;
+    }
+
+    if (!(item->state & TTK_STATE_OPEN)) {
+	hidden = 1;
+    }
+    while (child) {
+	UpdatePositionItem(tv, child, hidden, rowPos, itemPos, visiblePos);
+	child = child->next;
+    }
+}
+
+/* + UpdatePositionTree --
+ * 	Update position data for all visible items.
+ */
+static void UpdatePositionTree(Treeview *tv)
+{
+    /* -1 for the invisible root */
+    int rowPos = -1, itemPos = -1, visiblePos = -1;
+    tv->tree.titleRows = 0;
+    UpdatePositionItem(tv, tv->tree.root, 0, &rowPos, &itemPos, &visiblePos);
+    tv->tree.totalRows = rowPos;
+    tv->tree.rowPosNeedsUpdate = 0;
 }
 
 /* + IdentifyItem --
  * 	Locate the item at the specified y position, if any.
  */
 static TreeItem *IdentifyItem(Treeview *tv, int y)
 {
+    TreeItem *item;
     int rowHeight = tv->tree.rowHeight;
-    int ypos = tv->tree.treeArea.y - rowHeight * tv->tree.yscroll.first;
-    return IdentifyRow(tv, tv->tree.root->children, &ypos, y);
+    int ypos = tv->tree.treeArea.y;
+    int nextRow, row;
+    if (y < ypos) {
+	return NULL;
+    }
+    if (tv->tree.rowPosNeedsUpdate) {
+	UpdatePositionTree(tv);
+    }
+    row = (y - ypos) / rowHeight;
+    if (row >= tv->tree.titleRows) {
+	row += tv->tree.yscroll.first;
+    }
+    for (item = tv->tree.root->children; item; item = NextPreorder(item)) {
+	nextRow = item->rowPos + item->height;
+	if (item->rowPos <= row && row < nextRow) break;
+    }
+    return item;
 }
 
 /* + IdentifyDisplayColumn --
  * 	Returns the display column number at the specified x position,
  * 	or -1 if x is outside any columns.
  */
-static int IdentifyDisplayColumn(Treeview *tv, int x, int *x1)
+static TkSizeT IdentifyDisplayColumn(Treeview *tv, int x, int *x1)
 {
-    int colno = FirstColumn(tv);
-    int xpos = tv->tree.treeArea.x - tv->tree.xscroll.first;
+    TkSizeT colno = FirstColumn(tv);
+    int xpos = tv->tree.treeArea.x;
+
+    if ((TkSizeT)tv->tree.nTitleColumns <= colno) {
+	xpos -= tv->tree.xscroll.first;
+    }
 
     while (colno < tv->tree.nDisplayColumns) {
 	TreeColumn *column = tv->tree.displayColumns[colno];
 	int next_xpos = xpos + column->width;
 	if (xpos <= x && x <= next_xpos + HALO) {
@@ -1360,44 +1697,16 @@
 	    *x1 = next_xpos;
 	    return colno;
 	}
 	++colno;
 	xpos = next_xpos;
-    }
-
-    return -1;
-}
-
-/* + RowNumber --
- * 	Calculate which row the specified item appears on;
- * 	returns -1 if the item is not viewable.
- * 	Xref: DrawForest, IdentifyItem.
- */
-static int RowNumber(Treeview *tv, TreeItem *item)
-{
-    TreeItem *p = tv->tree.root->children;
-    int n = 0;
-
-    while (p) {
-	if (p == item)
-	    return n;
-
-	++n;
-
-	/* Find next viewable item in preorder traversal order
-	 */
-	if (p->children && (p->state & TTK_STATE_OPEN)) {
-	    p = p->children;
-	} else {
-	    while (!p->next && p && p->parent)
-		p = p->parent;
-	    if (p)
-		p = p->next;
-	}
-    }
-
-    return -1;
+	if ((TkSizeT)tv->tree.nTitleColumns == colno) {
+	    xpos -= tv->tree.xscroll.first;
+	}
+    }
+
+    return TCL_INDEX_NONE;
 }
 
 /* + ItemDepth -- return the depth of a tree item.
  * 	The depth of an item is equal to the number of proper ancestors,
  * 	not counting the root node.
@@ -1410,35 +1719,27 @@
 	item = item->parent;
     }
     return depth-1;
 }
 
-/* + ItemRow --
- * 	Returns row number of specified item relative to root,
- * 	-1 if item is not viewable.
+/* + DisplayRow --
+ * 	Returns the position row has on screen, or -1 if off-screen.
  */
-static int ItemRow(Treeview *tv, TreeItem *p)
-{
-    TreeItem *root = tv->tree.root;
-    int rowNumber = 0;
-
-    for (;;) {
-	if (p->prev) {
-	    p = p->prev;
-	    rowNumber += CountRows(p);
-	} else {
-	    p = p->parent;
-	    if (!(p && (p->state & TTK_STATE_OPEN))) {
-		/* detached or closed ancestor */
-		return -1;
-	    }
-	    if (p == root) {
-		return rowNumber;
-	    }
-	    ++rowNumber;
-	}
-    }
+static int DisplayRow(int row, Treeview *tv)
+{
+    int visibleRows = tv->tree.treeArea.height / tv->tree.rowHeight
+	    - tv->tree.titleRows;
+    if (row < tv->tree.titleRows) {
+	return row;
+    }
+    row -= tv->tree.titleRows;
+    if (row < tv->tree.yscroll.first
+	    || row > tv->tree.yscroll.first + visibleRows) {
+	/* not viewable, or off-screen */
+	return -1;
+    }
+    return row - tv->tree.yscroll.first + tv->tree.titleRows;
 }
 
 /* + BoundingBox --
  * 	Compute the parcel of the specified column of the specified item,
  *	(or the entire item if column is NULL)
@@ -1448,26 +1749,31 @@
     Treeview *tv,		/* treeview widget */
     TreeItem *item,		/* desired item */
     TreeColumn *column,		/* desired column */
     Ttk_Box *bbox_rtn)		/* bounding box of item */
 {
-    int row = ItemRow(tv, item);
+    int dispRow;
     Ttk_Box bbox = tv->tree.treeArea;
 
-    if (row < tv->tree.yscroll.first || row > tv->tree.yscroll.last) {
+    if (tv->tree.rowPosNeedsUpdate) {
+	UpdatePositionTree(tv);
+    }
+    dispRow = DisplayRow(item->rowPos, tv);
+    if (dispRow < 0) {
 	/* not viewable, or off-screen */
 	return 0;
     }
 
-    bbox.y += (row - tv->tree.yscroll.first) * tv->tree.rowHeight;
-    bbox.height = tv->tree.rowHeight;
+    bbox.y += dispRow * tv->tree.rowHeight;
+    bbox.height = tv->tree.rowHeight * item->height;
 
     bbox.x -= tv->tree.xscroll.first;
     bbox.width = TreeWidth(tv);
 
     if (column) {
-	int xpos = 0, i = FirstColumn(tv);
+	int xpos = 0;
+	TkSizeT i = FirstColumn(tv);
 	while (i < tv->tree.nDisplayColumns) {
 	    if (tv->tree.displayColumns[i] == column) {
 		break;
 	    }
 	    xpos += tv->tree.displayColumns[i]->width;
@@ -1476,10 +1782,15 @@
 	if (i == tv->tree.nDisplayColumns) { /* specified column unviewable */
 	    return 0;
 	}
 	bbox.x += xpos;
 	bbox.width = column->width;
+
+	if (i < (TkSizeT)tv->tree.nTitleColumns) {
+	    /* Unscrollable column, remove scroll shift */
+	    bbox.x += tv->tree.xscroll.first;
+	}
 
 	/* Account for indentation in tree column:
 	 */
 	if (column == &tv->tree.column0) {
 	    int indent = tv->tree.indent * ItemDepth(item);
@@ -1506,15 +1817,15 @@
     "nothing", "heading", "separator", "tree", "cell", 0
 };
 
 static TreeRegion IdentifyRegion(Treeview *tv, int x, int y)
 {
-    int x1 = 0, colno;
+    int x1 = 0;
+    TkSizeT colno = IdentifyDisplayColumn(tv, x, &x1);
 
-    colno = IdentifyDisplayColumn(tv, x, &x1);
     if (Ttk_BoxContains(tv->tree.headingArea, x, y)) {
-	if (colno < 0) {
+	if (colno == TCL_INDEX_NONE) {
 	    return REGION_NOTHING;
 	} else if (-HALO <= x1 - x  && x1 - x <= HALO) {
 	    return REGION_SEPARATOR;
 	} else {
 	    return REGION_HEADING;
@@ -1563,39 +1874,62 @@
     Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr)
 {
     Treeview *tv = (Treeview *)recordPtr;
     Ttk_Layout treeLayout = TtkWidgetGetLayout(interp, themePtr, recordPtr);
     Tcl_Obj *objPtr;
-    int unused;
+    int unused, cellHeight;
+    DisplayItem displayItem;
+    Ttk_Style style;
 
     if (!(
 	treeLayout
      && GetSublayout(interp, themePtr, treeLayout, ".Item",
-	    tv->tree.tagOptionTable, &tv->tree.itemLayout)
+	    tv->tree.displayOptionTable, &tv->tree.itemLayout)
      && GetSublayout(interp, themePtr, treeLayout, ".Cell",
-	    tv->tree.tagOptionTable, &tv->tree.cellLayout)
+	    tv->tree.displayOptionTable, &tv->tree.cellLayout)
      && GetSublayout(interp, themePtr, treeLayout, ".Heading",
 	    tv->tree.headingOptionTable, &tv->tree.headingLayout)
      && GetSublayout(interp, themePtr, treeLayout, ".Row",
-	    tv->tree.tagOptionTable, &tv->tree.rowLayout)
+	    tv->tree.displayOptionTable, &tv->tree.rowLayout)
+     && GetSublayout(interp, themePtr, treeLayout, ".Separator",
+	    tv->tree.displayOptionTable, &tv->tree.separatorLayout)
     )) {
 	return 0;
     }
 
     /* Compute heading height.
      */
     Ttk_RebindSublayout(tv->tree.headingLayout, &tv->tree.column0);
     Ttk_LayoutSize(tv->tree.headingLayout, 0, &unused, &tv->tree.headingHeight);
 
-    /* Get item height, indent from style:
-     * @@@ TODO: sanity-check.
+    /* Get row height from style, or compute it to fit Item and Cell.
+     * Pick up default font from the Treeview style.
      */
-    tv->tree.rowHeight = DEFAULT_ROWHEIGHT;
-    tv->tree.indent = DEFAULT_INDENT;
+    style = Ttk_LayoutStyle(treeLayout);
+    Ttk_TagSetDefaults(tv->tree.tagTable, style, &displayItem);
+
+    Ttk_RebindSublayout(tv->tree.itemLayout, &displayItem);
+    Ttk_LayoutSize(tv->tree.itemLayout, 0, &unused, &tv->tree.rowHeight);
+
+    Ttk_RebindSublayout(tv->tree.cellLayout, &displayItem);
+    Ttk_LayoutSize(tv->tree.cellLayout, 0, &unused, &cellHeight);
+
+    if (cellHeight > tv->tree.rowHeight) {
+	tv->tree.rowHeight = cellHeight;
+    }
+
     if ((objPtr = Ttk_QueryOption(treeLayout, "-rowheight", 0))) {
 	(void)Tcl_GetIntFromObj(NULL, objPtr, &tv->tree.rowHeight);
     }
+    if ((objPtr = Ttk_QueryOption(treeLayout, "-columnseparatorwidth", 0))) {
+	(void)Tcl_GetIntFromObj(NULL, objPtr, &tv->tree.colSeparatorWidth);
+    }
+
+    /* Get item indent from style:
+     * @@@ TODO: sanity-check.
+     */
+    tv->tree.indent = DEFAULT_INDENT;
     if ((objPtr = Ttk_QueryOption(treeLayout, "-indent", 0))) {
 	(void)Tcl_GetIntFromObj(NULL, objPtr, &tv->tree.indent);
     }
 
     return treeLayout;
@@ -1611,20 +1945,21 @@
  */
 static void TreeviewDoLayout(void *clientData)
 {
     Treeview *tv = (Treeview *)clientData;
     int visibleRows;
+    int first, last, total;
 
     Ttk_PlaceLayout(tv->core.layout,tv->core.state,Ttk_WinBox(tv->core.tkwin));
     tv->tree.treeArea = Ttk_ClientRegion(tv->core.layout, "treearea");
 
     ResizeColumns(tv, tv->tree.treeArea.width);
 
-    TtkScrolled(tv->tree.xscrollHandle,
-	    tv->tree.xscroll.first,
-	    tv->tree.xscroll.first + tv->tree.treeArea.width,
-	    TreeWidth(tv));
+    first = tv->tree.xscroll.first;
+    last = first + tv->tree.treeArea.width - tv->tree.titleWidth;
+    total = TreeWidth(tv) - tv->tree.titleWidth;
+    TtkScrolled(tv->tree.xscrollHandle, first, last, total);
 
     if (tv->tree.showFlags & SHOW_HEADINGS) {
 	tv->tree.headingArea = Ttk_PackBox(
 	    &tv->tree.treeArea, 1, tv->tree.headingHeight, TTK_SIDE_TOP);
     } else {
@@ -1631,14 +1966,15 @@
 	tv->tree.headingArea = Ttk_MakeBox(0,0,0,0);
     }
 
     visibleRows = tv->tree.treeArea.height / tv->tree.rowHeight;
     tv->tree.root->state |= TTK_STATE_OPEN;
-    TtkScrolled(tv->tree.yscrollHandle,
-	    tv->tree.yscroll.first,
-	    tv->tree.yscroll.first + visibleRows,
-	    CountRows(tv->tree.root) - 1);
+    UpdatePositionTree(tv);
+    first = tv->tree.yscroll.first;
+    last = tv->tree.yscroll.first + visibleRows - tv->tree.titleRows;
+    total = tv->tree.totalRows - tv->tree.titleRows;
+    TtkScrolled(tv->tree.yscrollHandle, first, last, total);
 }
 
 /* + TreeviewSize --
  * 	SizeProc() widget hook.  Size is determined by
  * 	-height option and column widths.
@@ -1678,156 +2014,380 @@
 /* + DrawHeadings --
  *	Draw tree headings.
  */
 static void DrawHeadings(Treeview *tv, Drawable d)
 {
-    const int x0 = tv->tree.headingArea.x - tv->tree.xscroll.first;
+    int x0 = tv->tree.headingArea.x - tv->tree.xscroll.first;
     const int y0 = tv->tree.headingArea.y;
     const int h0 = tv->tree.headingArea.height;
-    int i = FirstColumn(tv);
+    TkSizeT i = FirstColumn(tv);
     int x = 0;
+
+    if ((TkSizeT)tv->tree.nTitleColumns > i) {
+	x = tv->tree.titleWidth;
+	i = tv->tree.nTitleColumns;
+    }
 
     while (i < tv->tree.nDisplayColumns) {
 	TreeColumn *column = tv->tree.displayColumns[i];
 	Ttk_Box parcel = Ttk_MakeBox(x0+x, y0, column->width, h0);
+	if (x0+x+column->width > tv->tree.titleWidth) {
+	    DisplayLayout(tv->tree.headingLayout,
+		    column, column->headingState, parcel, d);
+	}
+	x += column->width;
+	++i;
+    }
+
+    x0 = tv->tree.headingArea.x;
+    i = FirstColumn(tv);
+    x = 0;
+    while ((i < (TkSizeT)tv->tree.nTitleColumns) && (i < tv->tree.nDisplayColumns)) {
+	TreeColumn *column = tv->tree.displayColumns[i];
+	Ttk_Box parcel = Ttk_MakeBox(x0+x, y0, column->width, h0);
 	DisplayLayout(tv->tree.headingLayout,
 	    column, column->headingState, parcel, d);
 	x += column->width;
 	++i;
     }
 }
+
+/* + DrawSeparators --
+ *	Draw separators between columns
+ */
+static void DrawSeparators(Treeview *tv, Drawable d)
+{
+    const int y0 = tv->tree.treeArea.y;
+    const int h0 = tv->tree.treeArea.height;
+    DisplayItem displayItem;
+    Ttk_Style style = Ttk_LayoutStyle(tv->tree.separatorLayout);
+    int x = tv->tree.treeArea.x;
+    TkSizeT i;
+
+    Ttk_TagSetDefaults(tv->tree.tagTable, style, &displayItem);
+
+    for (i = FirstColumn(tv); i < tv->tree.nDisplayColumns; ++i) {
+	TreeColumn *column = tv->tree.displayColumns[i];
+	Ttk_Box parcel;
+	int xDraw = x + column->width;
+	x += column->width;
+
+	if (!column->separator) continue;
+
+	if (i >= (TkSizeT)tv->tree.nTitleColumns) {
+	    xDraw -= tv->tree.xscroll.first;
+	    if (xDraw < tv->tree.titleWidth) continue;
+	}
+
+	parcel = Ttk_MakeBox(xDraw - (tv->tree.colSeparatorWidth+1)/2, y0,
+		tv->tree.colSeparatorWidth, h0);
+	DisplayLayout(tv->tree.separatorLayout, &displayItem, 0, parcel, d);
+    }
+}
+
+/* + OverrideStriped --
+ * 	Each level of settings might add stripedbackground, and it should
+ * 	override background if this is indeed on a striped item.
+ * 	By copying it between each level, and NULL-ing stripedBgObj,
+ * 	it can be detected if the next level overrides it.
+ */
+ static void OverrideStriped(
+    Treeview *tv, TreeItem *item, DisplayItem *displayItem)
+{
+    int striped = item->visiblePos % 2 && tv->tree.striped;
+    if (striped && displayItem->stripedBgObj) {
+	displayItem->backgroundObj = displayItem->stripedBgObj;
+	displayItem->stripedBgObj = NULL;
+    }
+}
 
 /* + PrepareItem --
  * 	Fill in a displayItem record.
  */
 static void PrepareItem(
-    Treeview *tv, TreeItem *item, DisplayItem *displayItem)
+    Treeview *tv, TreeItem *item, DisplayItem *displayItem, Ttk_State state)
 {
     Ttk_Style style = Ttk_LayoutStyle(tv->core.layout);
-    Ttk_State state = ItemState(tv, item);
 
+    Ttk_TagSetDefaults(tv->tree.tagTable, style, displayItem);
+    OverrideStriped(tv, item, displayItem);
     Ttk_TagSetValues(tv->tree.tagTable, item->tagset, displayItem);
+    OverrideStriped(tv, item, displayItem);
     Ttk_TagSetApplyStyle(tv->tree.tagTable, style, state, displayItem);
 }
+
+/* Fill in data from item to temporary storage in columns. */
+static void PrepareCells(
+   Treeview *tv, TreeItem *item)
+{
+    TkSizeT i;
+    int nValues = 0;
+    Tcl_Obj **values = NULL;
+    TreeColumn *column;
+
+    if (item->valuesObj) {
+	Tcl_ListObjGetElements(NULL, item->valuesObj, &nValues, &values);
+    }
+    for (i = 0; i < tv->tree.nColumns; ++i) {
+	tv->tree.columns[i].data = (i < (TkSizeT)nValues) ? values[i] : 0;
+	tv->tree.columns[i].selected = 0;
+	tv->tree.columns[i].tagset = NULL;
+    }
+    tv->tree.column0.data = NULL;
+    tv->tree.column0.selected = 0;
+    tv->tree.column0.tagset = NULL;
+
+    if (item->selObj != NULL) {
+	Tcl_ListObjGetElements(NULL, item->selObj, &nValues, &values);
+	for (i = 0; i < (TkSizeT)nValues; ++i) {
+	    column = FindColumn(NULL, tv, values[i]);
+	    /* Just in case. It should not be possible for column to be NULL */
+	    if (column != NULL) {
+		column->selected = 1;
+	    }
+	}
+    }
+    if (item->nTagSets > 0) {
+	tv->tree.column0.tagset = item->cellTagSets[0];
+    }
+    for (i = 1; i < item->nTagSets && i <= tv->tree.nColumns; ++i) {
+	tv->tree.columns[i-1].tagset = item->cellTagSets[i];
+    }
+}
 
 /* + DrawCells --
  *	Draw data cells for specified item.
  */
 static void DrawCells(
-    Treeview *tv, TreeItem *item, DisplayItem *displayItem,
-    Drawable d, int x, int y)
+    Treeview *tv, TreeItem *item,
+    DisplayItem *displayItem, DisplayItem *displayItemSel,
+    Drawable d, int x, int y, int title)
 {
     Ttk_Layout layout = tv->tree.cellLayout;
+    Ttk_Style style = Ttk_LayoutStyle(tv->core.layout);
     Ttk_State state = ItemState(tv, item);
     Ttk_Padding cellPadding = {4, 0, 4, 0};
-    int rowHeight = tv->tree.rowHeight;
-    int nValues = 0;
-    Tcl_Obj **values = 0;
-    int i;
+    DisplayItem displayItemLocal;
+    DisplayItem displayItemCell, displayItemCellSel;
+    int rowHeight = tv->tree.rowHeight * item->height;
+    int xPad = 0, defaultPadding = 1;
+    TkSizeT i;
 
-    if (!item->valuesObj) {
-	return;
+    /* Adjust if the tree column has a separator */
+    if (tv->tree.showFlags & SHOW_TREE && tv->tree.column0.separator) {
+	xPad = tv->tree.colSeparatorWidth/2;
     }
 
-    Tcl_ListObjGetElements(NULL, item->valuesObj, &nValues, &values);
-    for (i = 0; i < tv->tree.nColumns; ++i) {
-	tv->tree.columns[i].data = (i < nValues) ? values[i] : 0;
+    /* An Item's image should not propagate to a Cell.
+       A Cell's image can only be set by cell tags. */
+    displayItemCell = *displayItem;
+    displayItemCellSel = *displayItemSel;
+    displayItemCell.imageObj = NULL;
+    displayItemCellSel.imageObj = NULL;
+    displayItemCell.imageAnchorObj = NULL;
+    displayItemCellSel.imageAnchorObj = NULL;
+
+    /* If explicit padding was asked for, skip default. */
+    if (Ttk_QueryStyle(Ttk_LayoutStyle(tv->tree.cellLayout), &displayItemCell,
+		    tv->tree.displayOptionTable, "-padding", state) != NULL) {
+	defaultPadding = 0;
     }
 
     for (i = 1; i < tv->tree.nDisplayColumns; ++i) {
 	TreeColumn *column = tv->tree.displayColumns[i];
-	Ttk_Box parcel = Ttk_PadBox(
-	    Ttk_MakeBox(x, y, column->width, rowHeight), cellPadding);
+	int parcelX = x + xPad;
+	int parcelWidth = column->separator ?
+		column->width - tv->tree.colSeparatorWidth : column->width;
+	Ttk_Box parcel = Ttk_MakeBox(parcelX, y, parcelWidth, rowHeight);
+	DisplayItem *displayItemUsed = &displayItemCell;
+	Ttk_State stateCell = state;
+	Tk_Anchor textAnchor, imageAnchor;
+	xPad = column->separator ? tv->tree.colSeparatorWidth/2 : 0;
 
-	displayItem->textObj = column->data;
-	displayItem->anchorObj = column->anchorObj;	/* <<NOTE-ANCHOR>> */
-
-	DisplayLayout(layout, displayItem, state, parcel, d);
 	x += column->width;
+	if (title  && i >= (TkSizeT)tv->tree.nTitleColumns) break;
+	if (!title && i <  (TkSizeT)tv->tree.nTitleColumns) continue;
+	if (!title && x <  tv->tree.titleWidth) continue;
+
+	if (column->selected) {
+	    displayItemUsed = &displayItemCellSel;
+	    stateCell |= TTK_STATE_SELECTED;
+	}
+
+	if (column->tagset) {
+	    displayItemLocal = *displayItemUsed;
+	    displayItemUsed = &displayItemLocal;
+	    Ttk_TagSetValues(tv->tree.tagTable, column->tagset,
+		    displayItemUsed);
+	    OverrideStriped(tv, item, displayItemUsed);
+	    Ttk_TagSetApplyStyle(tv->tree.tagTable, style, stateCell,
+		    displayItemUsed);
+	}
+
+	displayItemUsed->textObj = column->data;
+	displayItemUsed->anchorObj = column->anchorObj;/* <<NOTE-ANCHOR>> */
+	Tk_GetAnchorFromObj(NULL, column->anchorObj, &textAnchor);
+
+	imageAnchor = DEFAULT_IMAGEANCHOR;
+	if (displayItemUsed->imageAnchorObj) {
+	    Tk_GetAnchorFromObj(NULL, displayItemUsed->imageAnchorObj,
+		    &imageAnchor);
+	}
+	/* displayItem was used to draw the full item backgound.
+	   Redraw cell background if needed. */
+	if (displayItemUsed != &displayItemCell) {
+	    DisplayLayout(tv->tree.rowLayout, displayItemUsed, stateCell,
+		    parcel, d);
+	}
+
+	if (defaultPadding && displayItemUsed->paddingObj == NULL) {
+	    /* If no explicit padding was asked for, add some default. */
+	    parcel = Ttk_PadBox(parcel, cellPadding);
+	}
+
+	DisplayLayoutTree(imageAnchor, textAnchor,
+		layout, displayItemUsed, state, parcel, d);
     }
 }
 
 /* + DrawItem --
  * 	Draw an item (row background, tree label, and cells).
  */
 static void DrawItem(
-    Treeview *tv, TreeItem *item, Drawable d, int depth, int row)
+    Treeview *tv, TreeItem *item, Drawable d, int depth)
 {
+    Ttk_Style style = Ttk_LayoutStyle(tv->core.layout);
     Ttk_State state = ItemState(tv, item);
-    DisplayItem displayItem;
-    int rowHeight = tv->tree.rowHeight;
+    DisplayItem displayItem, displayItemSel, displayItemLocal;
+    int rowHeight = tv->tree.rowHeight * item->height;
     int x = tv->tree.treeArea.x - tv->tree.xscroll.first;
-    int y = tv->tree.treeArea.y + rowHeight * (row - tv->tree.yscroll.first);
+    int xTitle = tv->tree.treeArea.x;
+    int dispRow = DisplayRow(item->rowPos, tv);
+    int y = tv->tree.treeArea.y + tv->tree.rowHeight * dispRow;
 
-    if (row % 2) state |= TTK_STATE_ALTERNATE;
-
-    PrepareItem(tv, item, &displayItem);
+    PrepareItem(tv, item, &displayItem, state);
+    PrepareItem(tv, item, &displayItemSel, state | TTK_STATE_SELECTED);
 
     /* Draw row background:
      */
     {
 	Ttk_Box rowBox = Ttk_MakeBox(x, y, TreeWidth(tv), rowHeight);
 	DisplayLayout(tv->tree.rowLayout, &displayItem, state, rowBox, d);
     }
 
-    /* Draw tree label:
+    /* Make room for tree label:
      */
     if (tv->tree.showFlags & SHOW_TREE) {
-	int indent = depth * tv->tree.indent;
-	int colwidth = tv->tree.column0.width;
-	Ttk_Box parcel = Ttk_MakeBox(
-		x+indent, y, colwidth-indent, rowHeight);
-	if (item->textObj) { displayItem.textObj = item->textObj; }
-	if (item->imageObj) { displayItem.imageObj = item->imageObj; }
-        displayItem.anchorObj = tv->tree.column0.anchorObj;
-	DisplayLayout(tv->tree.itemLayout, &displayItem, state, parcel, d);
-	x += colwidth;
+	x += tv->tree.column0.width;
     }
 
     /* Draw data cells:
      */
-    DrawCells(tv, item, &displayItem, d, x, y);
+    PrepareCells(tv, item);
+    DrawCells(tv, item, &displayItem, &displayItemSel, d, x, y, 0);
+
+    /* Draw row background for non-scrolled area:
+     */
+    if ((TkSizeT)tv->tree.nTitleColumns >= 1) {
+	Ttk_Box rowBox = Ttk_MakeBox(tv->tree.treeArea.x, y,
+		tv->tree.titleWidth, rowHeight);
+	DisplayLayout(tv->tree.rowLayout, &displayItem, state, rowBox, d);
+    }
+
+    /* Draw tree label:
+     */
+    x = tv->tree.treeArea.x - tv->tree.xscroll.first;
+    if (tv->tree.showFlags & SHOW_TREE) {
+	TreeColumn *column = &tv->tree.column0;
+	int indent = depth * tv->tree.indent;
+	int colwidth = tv->tree.column0.width -
+		(tv->tree.column0.separator ? tv->tree.colSeparatorWidth/2 : 0);
+	int xTree = tv->tree.nTitleColumns >= 1 ? xTitle : x;
+	Ttk_Box parcel = Ttk_MakeBox(xTree, y, colwidth, rowHeight);
+	DisplayItem *displayItemUsed = &displayItem;
+	Ttk_State stateCell = state;
+	Tk_Anchor textAnchor, imageAnchor = DEFAULT_IMAGEANCHOR;
+	Ttk_Padding cellPadding = {indent, 0, 0, 0};
+
+	if (column->selected) {
+	    displayItemUsed = &displayItemSel;
+ 	    stateCell |= TTK_STATE_SELECTED;
+	}
+
+	if (column->tagset) {
+	    displayItemLocal = *displayItemUsed;
+	    displayItemUsed = &displayItemLocal;
+	    Ttk_TagSetValues(tv->tree.tagTable, column->tagset,
+		    displayItemUsed);
+	    OverrideStriped(tv, item, displayItemUsed);
+	    Ttk_TagSetApplyStyle(tv->tree.tagTable, style, stateCell,
+		    displayItemUsed);
+	}
+
+        displayItem.anchorObj = tv->tree.column0.anchorObj;
+	Tk_GetAnchorFromObj(NULL, column->anchorObj, &textAnchor);
+	displayItemUsed->textObj = item->textObj;
+	/* Item's image can be null, and may come from the tag */
+	if (item->imageObj) {
+	    displayItemUsed->imageObj = item->imageObj;
+	}
+	if (item->imageAnchorObj) {
+	    displayItemUsed->imageAnchorObj = item->imageAnchorObj;
+	}
+	if (displayItemUsed->imageAnchorObj) {
+	    Tk_GetAnchorFromObj(NULL, displayItemUsed->imageAnchorObj,
+		    &imageAnchor);
+	}
+
+	if (displayItemUsed != &displayItem) {
+	    DisplayLayout(tv->tree.rowLayout, displayItemUsed, stateCell,
+		    parcel, d);
+	}
+
+	parcel = Ttk_PadBox(parcel, cellPadding);
+	DisplayLayoutTree(imageAnchor, textAnchor,
+		tv->tree.itemLayout, displayItemUsed, state, parcel, d);
+	xTitle += colwidth;
+    }
+
+    /* Draw non-scrolled data cells:
+     */
+    if ((TkSizeT)tv->tree.nTitleColumns > 1) {
+	DrawCells(tv, item, &displayItem, &displayItemSel, d, xTitle, y, 1);
+    }
 }
 
 /* + DrawSubtree --
  * 	Draw an item and all of its (viewable) descendants.
- *
- * Returns:
- * 	Row number of the last item drawn.
  */
 
-static int DrawForest(	/* forward */
-    Treeview *tv, TreeItem *item, Drawable d, int depth, int row);
-
-static int DrawSubtree(
-    Treeview *tv, TreeItem *item, Drawable d, int depth, int row)
-{
-    if (row >= tv->tree.yscroll.first) {
-	DrawItem(tv, item, d, depth, row);
+static void DrawForest(	/* forward */
+    Treeview *tv, TreeItem *item, Drawable d, int depth);
+
+static void DrawSubtree(
+    Treeview *tv, TreeItem *item, Drawable d, int depth)
+{
+    int dispRow = DisplayRow(item->rowPos, tv);
+    if (dispRow >= 0) {
+	DrawItem(tv, item, d, depth);
     }
 
     if (item->state & TTK_STATE_OPEN) {
-	return DrawForest(tv, item->children, d, depth + 1, row + 1);
-    } else {
-	return row + 1;
+	DrawForest(tv, item->children, d, depth + 1);
     }
 }
 
 /* + DrawForest --
  * 	Draw a sequence of items and their visible descendants.
- *
- * Returns:
- * 	Row number of the last item drawn.
  */
-static int DrawForest(
-    Treeview *tv, TreeItem *item, Drawable d, int depth, int row)
+static void DrawForest(
+    Treeview *tv, TreeItem *item, Drawable d, int depth)
 {
-    while (item && row < tv->tree.yscroll.last) {
-        row = DrawSubtree(tv, item, d, depth, row);
+    while (item) {
+        DrawSubtree(tv, item, d, depth);
 	item = item->next;
     }
-    return row;
 }
 
 /* + TreeviewDisplay --
  * 	Display() widget hook.  Draw the widget contents.
  */
@@ -1837,11 +2397,12 @@
 
     Ttk_DrawLayout(tv->core.layout, tv->core.state, d);
     if (tv->tree.showFlags & SHOW_HEADINGS) {
 	DrawHeadings(tv, d);
     }
-    DrawForest(tv, tv->tree.root->children, d, 0,0);
+    DrawForest(tv, tv->tree.root->children, d, 0);
+    DrawSeparators(tv, d);
 }
 
 /*------------------------------------------------------------------------
  * +++ Utilities for widget commands
  */
@@ -1974,11 +2535,11 @@
 	if (!newChildren)
 	    return TCL_ERROR;
 
 	/* Sanity-check:
 	 */
-	for (i=0; newChildren[i]; ++i) {
+	for (i = 0; newChildren[i]; ++i) {
 	    if (!AncestryCheck(interp, tv, newChildren[i], item)) {
 		ckfree(newChildren);
 		return TCL_ERROR;
 	    }
 	}
@@ -1992,20 +2553,20 @@
 	    child = next;
 	}
 
 	/* Detach new children from their current locations:
 	 */
-	for (i=0; newChildren[i]; ++i) {
+	for (i = 0; newChildren[i]; ++i) {
 	    DetachItem(newChildren[i]);
 	}
 
 	/* Reinsert new children:
 	 * Note: it is not an error for an item to be listed more than once,
 	 * though it probably should be...
 	 */
 	child = 0;
-	for (i=0; newChildren[i]; ++i) {
+	for (i = 0; newChildren[i]; ++i) {
 	    if (newChildren[i]->parent) {
 		/* This is a duplicate element which has already been
 		 * inserted.  Ignore it.
 		 */
 		continue;
@@ -2013,10 +2574,11 @@
 	    InsertItem(item, child, newChildren[i]);
 	    child = newChildren[i];
 	}
 
 	ckfree(newChildren);
+	tv->tree.rowPosNeedsUpdate = 1;
 	TtkRedisplayWidget(&tv->core);
     }
 
     return TCL_OK;
 }
@@ -2164,11 +2726,11 @@
 
     item = FindItem(interp, tv, objv[2]);
     if (!item) {
 	return TCL_ERROR;
     }
-    if (objc >=4 && (column = FindColumn(interp,tv,objv[3])) == NULL) {
+    if (objc >= 4 && (column = FindColumn(interp,tv,objv[3])) == NULL) {
 	return TCL_ERROR;
     }
 
     if (BoundingBox(tv, item, column, &bbox)) {
 	Tcl_SetObjResult(interp, Ttk_NewBoxObj(bbox));
@@ -2190,12 +2752,12 @@
     Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], Treeview *tv)
 {
     const char *what = "nothing", *detail = NULL;
     TreeItem *item = 0;
     Tcl_Obj *result;
-    int dColumnNumber;
-    char dcolbuf[16];
+    TkSizeT dColumnNumber;
+    char dcolbuf[32];
     int x, y, x1;
     (void)objc;
 
     /* ASSERT: objc == 4 */
 
@@ -2203,14 +2765,14 @@
 	    || Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK) {
 	return TCL_ERROR;
     }
 
     dColumnNumber = IdentifyDisplayColumn(tv, x, &x1);
-    if (dColumnNumber < 0) {
+    if (dColumnNumber == TCL_INDEX_NONE) {
 	goto done;
     }
-    sprintf(dcolbuf, "#%d", dColumnNumber);
+    sprintf(dcolbuf, "#%" TKSIZET_MODIFIER "u", dColumnNumber);
 
     if (Ttk_BoxContains(tv->tree.headingArea,x,y)) {
 	if (-HALO <= x1 - x  && x1 - x <= HALO) {
 	    what = "separator";
 	} else {
@@ -2225,17 +2787,18 @@
 	} else if (item) {
 	    Ttk_Layout layout = tv->tree.itemLayout;
 	    Ttk_Box itemBox;
 	    DisplayItem displayItem;
 	    Ttk_Element element;
+	    Ttk_State state = ItemState(tv, item);
 
 	    BoundingBox(tv, item, NULL, &itemBox);
-	    PrepareItem(tv, item, &displayItem);
+	    PrepareItem(tv, item, &displayItem, state);
             if (item->textObj) { displayItem.textObj = item->textObj; }
             if (item->imageObj) { displayItem.imageObj = item->imageObj; }
 	    Ttk_RebindSublayout(layout, &displayItem);
-	    Ttk_PlaceLayout(layout, ItemState(tv,item), itemBox);
+	    Ttk_PlaceLayout(layout, state, itemBox);
 	    element = Ttk_IdentifyElement(layout, x, y);
 
 	    if (element) {
 		what = "item";
 		detail = Ttk_ElementName(element);
@@ -2263,22 +2826,23 @@
 
 static int TreeviewIdentifyCommand(
     void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 {
     static const char *const submethodStrings[] =
-	 { "region", "item", "column", "row", "element", NULL };
-    enum { I_REGION, I_ITEM, I_COLUMN, I_ROW, I_ELEMENT };
+	 { "region", "item", "column", "row", "element", "cell", NULL };
+    enum { I_REGION, I_ITEM, I_COLUMN, I_ROW, I_ELEMENT, I_CELL };
 
     Treeview *tv = (Treeview *)recordPtr;
     int submethod;
     int x, y;
 
     TreeRegion region;
     Ttk_Box bbox;
     TreeItem *item;
     TreeColumn *column = 0;
-    int colno, x1;
+    TkSizeT colno;
+    int x1;
 
     if (objc == 4) {	/* Old form */
 	return TreeviewHorribleIdentify(interp, objc, objv, tv);
     } else if (objc != 5) {
 	Tcl_WrongNumArgs(interp, 2, objv, "command x y");
@@ -2294,11 +2858,11 @@
     }
 
     region = IdentifyRegion(tv, x, y);
     item = IdentifyItem(tv, y);
     colno = IdentifyDisplayColumn(tv, x, &x1);
-    column = (colno >= 0) ?  tv->tree.displayColumns[colno] : NULL;
+    column = (colno != TCL_INDEX_NONE) ?  tv->tree.displayColumns[colno] : NULL;
 
     switch (submethod)
     {
 	case I_REGION :
 	    Tcl_SetObjResult(interp,Tcl_NewStringObj(regionStrings[region],-1));
@@ -2310,20 +2874,30 @@
 		Tcl_SetObjResult(interp, ItemID(tv, item));
 	    }
 	    break;
 
 	case I_COLUMN :
-	    if (colno >= 0) {
-		Tcl_SetObjResult(interp, Tcl_ObjPrintf("#%d", colno));
+	    if (colno != TCL_INDEX_NONE) {
+		Tcl_SetObjResult(interp, Tcl_ObjPrintf("#%" TKSIZET_MODIFIER "u", colno));
+	    }
+	    break;
+
+	case I_CELL :
+	    if (item && colno != TCL_INDEX_NONE) {
+		Tcl_Obj *elem[2];
+		elem[0] = ItemID(tv, item);
+		elem[1] = Tcl_ObjPrintf("#%" TKSIZET_MODIFIER "u", colno);
+		Tcl_SetObjResult(interp, Tcl_NewListObj(2, elem));
 	    }
 	    break;
 
 	case I_ELEMENT :
 	{
 	    Ttk_Layout layout = 0;
 	    DisplayItem displayItem;
 	    Ttk_Element element;
+	    Ttk_State state;
 
 	    switch (region) {
 		case REGION_NOTHING:
 		    layout = tv->core.layout;
 		    return TCL_OK; /* @@@ NYI */
@@ -2337,19 +2911,22 @@
 		case REGION_CELL:
 		    layout = tv->tree.cellLayout;
 		    break;
 	    }
 
+	    if (item == NULL) {
+		return TCL_OK;
+	    }
 	    if (!BoundingBox(tv, item, column, &bbox)) {
 		return TCL_OK;
 	    }
-
-	    PrepareItem(tv, item, &displayItem);
+	    state = ItemState(tv, item);
+	    PrepareItem(tv, item, &displayItem, state);
             if (item->textObj) { displayItem.textObj = item->textObj; }
             if (item->imageObj) { displayItem.imageObj = item->imageObj; }
 	    Ttk_RebindSublayout(layout, &displayItem);
-	    Ttk_PlaceLayout(layout, ItemState(tv,item), bbox);
+	    Ttk_PlaceLayout(layout, state, bbox);
 	    element = Ttk_IdentifyElement(layout, x, y);
 
 	    if (element) {
 		const char *elementName = Ttk_ElementName(element);
 		Tcl_SetObjResult(interp, Tcl_NewStringObj(elementName, -1));
@@ -2457,11 +3034,11 @@
     void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 {
     Treeview *tv = (Treeview *)recordPtr;
     TreeItem *item;
     TreeColumn *column;
-    int columnNumber;
+    TkSizeT columnNumber;
 
     if (objc < 3 || objc > 5) {
 	Tcl_WrongNumArgs(interp, 2, objv, "item ?column ?value??");
 	return TCL_ERROR;
     }
@@ -2478,11 +3055,11 @@
     if (objc == 3) {
 	/* Return dictionary:
 	 */
 	Tcl_Obj *result = Tcl_NewListObj(0,0);
 	Tcl_Obj *value;
-	for (columnNumber=0; columnNumber<tv->tree.nColumns; ++columnNumber) {
+	for (columnNumber = 0; columnNumber < tv->tree.nColumns; ++columnNumber) {
 	    Tcl_ListObjIndex(interp, item->valuesObj, columnNumber, &value);
 	    if (value) {
 		Tcl_ListObjAppendElement(NULL, result,
 			tv->tree.columns[columnNumber].idObj);
 		Tcl_ListObjAppendElement(NULL, result, value);
@@ -2524,11 +3101,11 @@
 	item->valuesObj = unshareObj(item->valuesObj);
 
 	/* Make sure -values is fully populated:
 	 */
 	Tcl_ListObjLength(interp, item->valuesObj, &length);
-	while (length < tv->tree.nColumns) {
+	while ((TkSizeT)length < tv->tree.nColumns) {
 	    Tcl_Obj *empty = Tcl_NewStringObj("",0);
 	    Tcl_ListObjAppendElement(interp, item->valuesObj, empty);
 	    ++length;
 	}
 
@@ -2604,11 +3181,11 @@
 
     /* Create and configure new item:
      */
     newItem = NewItem();
     Tk_InitOptions(
-	interp, (ClientData)newItem, tv->tree.itemOptionTable, tv->core.tkwin);
+	interp, newItem, tv->tree.itemOptionTable, tv->core.tkwin);
     newItem->tagset = Ttk_GetTagSetFromObj(NULL, tv->tree.tagTable, NULL);
     if (ConfigureItem(interp, tv, newItem, objc, objv) != TCL_OK) {
     	Tcl_DeleteHashEntry(entryPtr);
 	FreeItem(newItem);
 	return TCL_ERROR;
@@ -2617,18 +3194,19 @@
     /* Store in hash table, link into tree:
      */
     Tcl_SetHashValue(entryPtr, newItem);
     newItem->entryPtr = entryPtr;
     InsertItem(parent, sibling, newItem);
+    tv->tree.rowPosNeedsUpdate = 1;
     TtkRedisplayWidget(&tv->core);
 
     Tcl_SetObjResult(interp, ItemID(tv, newItem));
     return TCL_OK;
 }
 
-/* + $tv detach $item --
- * 	Unlink $item from the tree.
+/* + $tv detach $items --
+ * 	Unlink each item in $items from the tree.
  */
 static int TreeviewDetachCommand(
     void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 {
     Treeview *tv = (Treeview *)recordPtr;
@@ -2656,10 +3234,11 @@
 
     for (i = 0; items[i]; ++i) {
 	DetachItem(items[i]);
     }
 
+    tv->tree.rowPosNeedsUpdate = 1;
     TtkRedisplayWidget(&tv->core);
     ckfree(items);
     return TCL_OK;
 }
 
@@ -2678,11 +3257,11 @@
 static int TreeviewDeleteCommand(
     void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 {
     Treeview *tv = (Treeview *)recordPtr;
     TreeItem **items, *delq;
-    int i, selItemDeleted = 0;
+    int i, selChange = 0;
 
     if (objc != 3) {
 	Tcl_WrongNumArgs(interp, 2, objv, "items");
 	return TCL_ERROR;
     }
@@ -2691,11 +3270,11 @@
 	return TCL_ERROR;
     }
 
     /* Sanity-check:
      */
-    for (i=0; items[i]; ++i) {
+    for (i = 0; items[i]; ++i) {
 	if (items[i] == tv->tree.root) {
 	    ckfree(items);
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
 		"Cannot delete root item", -1));
 	    Tcl_SetErrorCode(interp, "TTK", "TREE", "ROOT", NULL);
@@ -2704,14 +3283,20 @@
     }
 
     /* Remove items from hash table.
      */
     delq = 0;
-    for (i=0; items[i]; ++i) {
+    for (i = 0; items[i]; ++i) {
         if (items[i]->state & TTK_STATE_SELECTED) {
-            selItemDeleted = 1;
-        }
+            selChange = 1;
+        } else if (items[i]->selObj != NULL) {
+	    int length;
+	    Tcl_ListObjLength(interp, items[i]->selObj, &length);
+	    if (length > 0) {
+		selChange = 1;
+	    }
+	}
 	delq = DeleteItems(items[i], delq);
     }
 
     /* Free items:
      */
@@ -2724,13 +3309,14 @@
 	FreeItem(delq);
 	delq = next;
     }
 
     ckfree(items);
-    if (selItemDeleted) {
+    if (selChange) {
         Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL);
     }
+    tv->tree.rowPosNeedsUpdate = 1;
     TtkRedisplayWidget(&tv->core);
     return TCL_OK;
 }
 
 /* + $tv move $item $parent $index
@@ -2788,10 +3374,11 @@
     /* Move item:
      */
     DetachItem(item);
     InsertItem(parent, sibling, item);
 
+    tv->tree.rowPosNeedsUpdate = 1;
     TtkRedisplayWidget(&tv->core);
     return TCL_OK;
 }
 
 /*------------------------------------------------------------------------
@@ -2818,11 +3405,11 @@
 static int TreeviewSeeCommand(
     void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 {
     Treeview *tv = (Treeview *)recordPtr;
     TreeItem *item, *parent;
-    int rowNumber;
+    int scrollRow1, scrollRow2, visibleRows;
 
     if (objc != 3) {
 	Tcl_WrongNumArgs(interp, 2, objv, "item");
 	return TCL_ERROR;
     }
@@ -2835,22 +3422,32 @@
     for (parent = item->parent; parent; parent = parent->parent) {
 	if (!(parent->state & TTK_STATE_OPEN)) {
 	    parent->openObj = unshareObj(parent->openObj);
 	    Tcl_SetBooleanObj(parent->openObj, 1);
 	    parent->state |= TTK_STATE_OPEN;
+	    tv->tree.rowPosNeedsUpdate = 1;
 	    TtkRedisplayWidget(&tv->core);
 	}
+    }
+    if (tv->tree.rowPosNeedsUpdate) {
+	UpdatePositionTree(tv);
     }
 
     /* Make sure item is visible:
      */
-    rowNumber = RowNumber(tv, item);
-    if (rowNumber < tv->tree.yscroll.first) {
-	TtkScrollTo(tv->tree.yscrollHandle, rowNumber, 1);
-    } else if (rowNumber >= tv->tree.yscroll.last) {
-	TtkScrollTo(tv->tree.yscrollHandle,
-	    tv->tree.yscroll.first + (1+rowNumber - tv->tree.yscroll.last), 1);
+    if (item->rowPos < tv->tree.titleRows) {
+	return TCL_OK;
+    }
+    visibleRows = tv->tree.treeArea.height / tv->tree.rowHeight
+	    - tv->tree.titleRows;
+    scrollRow1 = item->rowPos - tv->tree.titleRows;
+    scrollRow2 = scrollRow1 + item->height - 1;
+    if (scrollRow1 < tv->tree.yscroll.first || item->height > visibleRows) {
+	TtkScrollTo(tv->tree.yscrollHandle, scrollRow1, 1);
+    } else if (scrollRow2 >= tv->tree.yscroll.first + visibleRows) {
+	scrollRow1 = 1 + scrollRow2 - visibleRows;
+	TtkScrollTo(tv->tree.yscrollHandle, scrollRow1, 1);
     }
 
     return TCL_OK;
 }
 
@@ -2864,11 +3461,11 @@
 static int TreeviewDragCommand(
     void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 {
     Treeview *tv = (Treeview *)recordPtr;
     int left = tv->tree.treeArea.x - tv->tree.xscroll.first;
-    int i = FirstColumn(tv);
+    TkSizeT i = FirstColumn(tv);
     TreeColumn *column;
     int newx;
 
     if (objc != 4) {
 	Tcl_WrongNumArgs(interp, 2, objv, "column xposition");
@@ -2882,10 +3479,14 @@
 
     for (;i < tv->tree.nDisplayColumns; ++i) {
 	TreeColumn *c = tv->tree.displayColumns[i];
 	int right = left + c->width;
 	if (c == column) {
+	    if (i < (TkSizeT)tv->tree.nTitleColumns) {
+	        /* Unscrollable column, remove scroll shift */
+                right += tv->tree.xscroll.first;
+	    }
 	    DragColumn(tv, i, newx - right);
 	    TtkRedisplayWidget(&tv->core);
 	    return TCL_OK;
 	}
 	left = right;
@@ -2951,11 +3552,11 @@
     static const char *const selopStrings[] = {
 	"set", "add", "remove", "toggle", NULL
     };
 
     Treeview *tv = (Treeview *)recordPtr;
-    int selop, i;
+    int selop, i, selChange = 0;
     TreeItem *item, **items;
 
     if (objc == 2) {
 	Tcl_Obj *result = Tcl_NewListObj(0,0);
 	for (item = tv->tree.root->children; item; item = NextPreorder(item)) {
@@ -2982,33 +3583,292 @@
     }
 
     switch (selop)
     {
 	case SELECTION_SET:
+	    /* Clear */
 	    for (item=tv->tree.root; item; item = NextPreorder(item)) {
-		item->state &= ~TTK_STATE_SELECTED;
+		if (item->state & TTK_STATE_SELECTED) {
+		    item->state &= ~TTK_STATE_SELECTED;
+		    selChange = 1;
+		}
 	    }
-	    /*FALLTHRU*/
-	case SELECTION_ADD:
 	    for (i=0; items[i]; ++i) {
 		items[i]->state |= TTK_STATE_SELECTED;
+		selChange = 1;
+	    }
+	    break;
+	case SELECTION_ADD:
+	    for (i=0; items[i]; ++i) {
+		if (!(items[i]->state & TTK_STATE_SELECTED)) {
+		    items[i]->state |= TTK_STATE_SELECTED;
+		    selChange = 1;
+		}
 	    }
 	    break;
 	case SELECTION_REMOVE:
 	    for (i=0; items[i]; ++i) {
-		items[i]->state &= ~TTK_STATE_SELECTED;
+		if (items[i]->state & TTK_STATE_SELECTED) {
+		    items[i]->state &= ~TTK_STATE_SELECTED;
+		    selChange = 1;
+		}
 	    }
 	    break;
 	case SELECTION_TOGGLE:
 	    for (i=0; items[i]; ++i) {
 		items[i]->state ^= TTK_STATE_SELECTED;
+		selChange = 1;
 	    }
 	    break;
     }
 
     ckfree(items);
-    Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL);
+    if (selChange) {
+	Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL);
+    }
+    TtkRedisplayWidget(&tv->core);
+
+    return TCL_OK;
+}
+
+/* + SelObjChangeElement --
+ * 	Change an element in a cell selection list.
+ */
+static int SelObjChangeElement(
+    Treeview *tv, Tcl_Obj *listPtr, Tcl_Obj *elemPtr,
+    int add, TCL_UNUSED(int) /*remove*/, int toggle)
+{
+    int i, nElements, anyChange = 0;
+    TreeColumn *column, *elemColumn;
+    Tcl_Obj **elements;
+
+    elemColumn = FindColumn(NULL, tv, elemPtr);
+    Tcl_ListObjGetElements(NULL, listPtr, &nElements, &elements);
+    for (i = 0; i < nElements; i++) {
+	column = FindColumn(NULL, tv, elements[i]);
+	if (column == elemColumn) {
+	    if (add) {
+		return anyChange;
+	    }
+	    Tcl_ListObjReplace(NULL, listPtr, i, 1, 0, NULL);
+	    anyChange = 1;
+	    return anyChange;
+	}
+    }
+    if (add || toggle) {
+	Tcl_ListObjAppendElement(NULL, listPtr, elemColumn->idObj);
+	anyChange = 1;
+    }
+    return anyChange;
+}
+
+/* + $tree cellselection ?add|remove|set|toggle $items?
+ */
+static int CellSelectionRange(
+    Tcl_Interp *interp, Treeview *tv, Tcl_Obj *fromCell, Tcl_Obj *toCell,
+    int add, int remove, int toggle)
+{
+    TreeCell cellFrom, cellTo;
+    TreeItem *item;
+    Tcl_Obj *columns, **elements;
+    int colno, nElements, i, fromNo, toNo, anyChange = 0;
+    int set = !(add || remove || toggle);
+
+    if (GetCellFromObj(interp, tv, fromCell, 1, &fromNo, &cellFrom)
+	    != TCL_OK) {
+	return TCL_ERROR;
+    }
+    if (GetCellFromObj(interp, tv, toCell, 1, &toNo, &cellTo)
+	    != TCL_OK) {
+	return TCL_ERROR;
+    }
+
+    /* Correct order.
+     */
+    if (fromNo > toNo) {
+	colno = fromNo;
+	fromNo = toNo;
+	toNo = colno;
+    }
+
+    /* Make a list of columns in this rectangle.
+     */
+    columns = Tcl_NewListObj(0, 0);
+    Tcl_IncrRefCount(columns);
+    for (colno = fromNo; colno <= toNo; colno++) {
+	Tcl_ListObjAppendElement(NULL, columns,
+		tv->tree.displayColumns[colno]->idObj);
+    }
+
+    /* Set is the only operation that affects items outside its rectangle.
+     * Start with clearing out.
+     */
+    if (set) {
+	anyChange = CellSelectionClear(tv);
+    }
+
+    /* Correct order.
+     */
+    if (tv->tree.rowPosNeedsUpdate) {
+	UpdatePositionTree(tv);
+    }
+    if (cellFrom.item->itemPos > cellTo.item->itemPos) {
+	item = cellFrom.item;
+	cellFrom.item = cellTo.item;
+	cellTo.item = item;
+    }
+
+    /* Go through all items in this rectangle.
+     */
+    for (item = cellFrom.item; item; item = NextPreorder(item)) {
+	if (item->selObj != NULL) {
+	    item->selObj = unshareObj(item->selObj);
+
+	    Tcl_ListObjGetElements(NULL, columns, &nElements, &elements);
+	    for (i = 0; i < nElements; ++i) {
+		anyChange |= SelObjChangeElement(tv, item->selObj, elements[i],
+			add, remove, toggle);
+	    }
+	} else {
+	    /* Set, add and toggle do the same thing when empty before.
+	     */
+	    if (!remove) {
+		item->selObj = columns;
+		Tcl_IncrRefCount(item->selObj);
+		anyChange = 1;
+	    }
+	}
+	if (item == cellTo.item) {
+	    break;
+	}
+    }
+
+    Tcl_DecrRefCount(columns);
+
+    if (anyChange) {
+	Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL);
+    }
+    TtkRedisplayWidget(&tv->core);
+    return TCL_OK;
+}
+
+/* + $tree cellselection ?add|remove|set|toggle $items?
+ */
+static int TreeviewCellSelectionCommand(
+    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+{
+    enum {
+	SELECTION_SET, SELECTION_ADD, SELECTION_REMOVE, SELECTION_TOGGLE
+    };
+    static const char *const selopStrings[] = {
+	"set", "add", "remove", "toggle", NULL
+    };
+
+    Treeview *tv = (Treeview *)recordPtr;
+    int selop, anyChange = 0;
+    TkSizeT i, nCells;
+    TreeCell *cells;
+    TreeItem *item;
+
+    if (objc == 2) {
+	Tcl_Obj *result = Tcl_NewListObj(0,0);
+	for (item = tv->tree.root->children; item; item = NextPreorder(item)) {
+	    if (item->selObj != NULL) {
+		int n;
+		TkSizeT elemc;
+		Tcl_Obj **elemv;
+
+		Tcl_ListObjGetElements(interp, item->selObj, &n, &elemv);
+		elemc = n;
+		for (i = 0; i < elemc; ++i) {
+		    Tcl_Obj *elem[2];
+		    elem[0] = ItemID(tv, item);
+		    elem[1] = elemv[i];
+		    Tcl_ListObjAppendElement(NULL, result,
+			    Tcl_NewListObj(2, elem));
+		}
+	    }
+	}
+	Tcl_SetObjResult(interp, result);
+	return TCL_OK;
+    }
+
+    if (objc < 4 || objc > 5) {
+    	Tcl_WrongNumArgs(interp, 2, objv, "?add|remove|set|toggle arg...?");
+	return TCL_ERROR;
+    }
+
+    if (Tcl_GetIndexFromObjStruct(interp, objv[2], selopStrings,
+	    sizeof(char *), "cellselection operation", 0, &selop) != TCL_OK) {
+	return TCL_ERROR;
+    }
+
+    if (objc == 5) {
+	switch (selop)
+	{
+	    case SELECTION_SET:
+		return CellSelectionRange(interp, tv, objv[3], objv[4], 0, 0, 0);
+	    case SELECTION_ADD:
+		return CellSelectionRange(interp, tv, objv[3], objv[4], 1, 0, 0);
+	    case SELECTION_REMOVE:
+		return CellSelectionRange(interp, tv, objv[3], objv[4], 0, 1, 0);
+	    case SELECTION_TOGGLE:
+		return CellSelectionRange(interp, tv, objv[3], objv[4], 0, 0, 1);
+	}
+    }
+
+    cells = GetCellListFromObj(interp, tv, objv[3], &nCells);
+    if (cells == NULL) {
+	return TCL_ERROR;
+    }
+
+    switch (selop)
+    {
+	case SELECTION_SET:
+	    anyChange = CellSelectionClear(tv);
+	    /*FALLTHRU*/
+	case SELECTION_ADD:
+	    for (i = 0; i < nCells; i++) {
+		item = cells[i].item;
+		if (item->selObj == NULL) {
+		    item->selObj = Tcl_NewListObj(0, 0);
+		    Tcl_IncrRefCount(item->selObj);
+		}
+		item->selObj = unshareObj(item->selObj);
+		anyChange |= SelObjChangeElement(tv, item->selObj,
+			cells[i].colObj, 1, 0, 0);
+	    }
+	    break;
+	case SELECTION_REMOVE:
+	    for (i = 0; i < nCells; i++) {
+		item = cells[i].item;
+		if (item->selObj == NULL) {
+		    continue;
+		}
+		item->selObj = unshareObj(item->selObj);
+		anyChange |= SelObjChangeElement(tv, item->selObj,
+			cells[i].colObj, 0, 1, 0);
+	    }
+	    break;
+	case SELECTION_TOGGLE:
+	    for (i = 0; i < nCells; i++) {
+		item = cells[i].item;
+		if (item->selObj == NULL) {
+		    item->selObj = Tcl_NewListObj(0, 0);
+		    Tcl_IncrRefCount(item->selObj);
+		}
+		item->selObj = unshareObj(item->selObj);
+		anyChange = SelObjChangeElement(tv, item->selObj,
+			cells[i].colObj, 0, 0, 1);
+	    }
+	    break;
+    }
+
+    ckfree(cells);
+    if (anyChange) {
+	Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL);
+    }
     TtkRedisplayWidget(&tv->core);
 
     return TCL_OK;
 }
 
@@ -3114,16 +3974,18 @@
 	Tcl_WrongNumArgs(interp, 3, objv, "tagName");
 	return TCL_ERROR;
     }
 
     tag = Ttk_GetTagFromObj(tagTable, objv[3]);
-    /* remove the tag from all items */
+    /* remove the tag from all cells and items */
     while (item) {
+        RemoveTagFromCellsAtItem(item, tag);
 	RemoveTag(item, tag);
 	item = NextPreorder(item);
     }
     /* then remove the tag from the tag table */
+    Tk_DeleteAllBindings(tv->tree.bindingTable, tag);
     Ttk_DeleteTagFromTable(tagTable, tag);
     TtkRedisplayWidget(&tv->core);
 
     return TCL_OK;
 }
@@ -3162,11 +4024,73 @@
     	Tcl_WrongNumArgs(interp, 3, objv, "tagName ?item?");
 	return TCL_ERROR;
     }
 }
 
-/* + $tv tag names $tag
+/* + $tv tag cell has $tag ?$cell?
+ */
+static int TreeviewCtagHasCommand(
+    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+{
+    Treeview *tv = (Treeview *)recordPtr;
+    TreeCell cell;
+    TkSizeT i, columnNumber;
+
+    if (objc == 5) {	/* Return list of all cells with tag */
+	Ttk_Tag tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[4]);
+	TreeItem *item = tv->tree.root;
+	Tcl_Obj *result = Tcl_NewListObj(0,0);
+
+	while (item) {
+	    for (i = 0; i < item->nTagSets && i <= tv->tree.nColumns; ++i) {
+		if (item->cellTagSets[i] != NULL) {
+		    if (Ttk_TagSetContains(item->cellTagSets[i], tag)) {
+			Tcl_Obj *elem[2];
+			elem[0] = ItemID(tv, item);
+			if (i == 0) {
+			    elem[1] = tv->tree.column0.idObj;
+			} else {
+			    elem[1] = tv->tree.columns[i-1].idObj;
+			}
+			Tcl_ListObjAppendElement(NULL, result,
+				Tcl_NewListObj(2, elem));
+		    }
+		}
+	    }
+	    item = NextPreorder(item);
+	}
+
+	Tcl_SetObjResult(interp, result);
+	return TCL_OK;
+    } else if (objc == 6) {	/* Test if cell has specified tag */
+	Ttk_Tag tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[4]);
+	int result = 0;
+	if (GetCellFromObj(interp, tv, objv[5], 0, NULL, &cell) != TCL_OK) {
+	    return TCL_ERROR;
+	}
+	if (cell.column == &tv->tree.column0) {
+	    columnNumber = 0;
+	} else {
+	    columnNumber = cell.column - tv->tree.columns + 1;
+	}
+	if (columnNumber < cell.item->nTagSets) {
+	    if (cell.item->cellTagSets[columnNumber] != NULL) {
+		result = Ttk_TagSetContains(
+			cell.item->cellTagSets[columnNumber],
+			tag);
+	    }
+	}
+
+	Tcl_SetObjResult(interp, Tcl_NewWideIntObj(result));
+	return TCL_OK;
+    } else {
+    	Tcl_WrongNumArgs(interp, 4, objv, "tagName ?cell?");
+	return TCL_ERROR;
+    }
+}
+
+/* + $tv tag names
  */
 static int TreeviewTagNamesCommand(
     void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 {
     Treeview *tv = (Treeview *)recordPtr;
@@ -3208,14 +4132,79 @@
 
     if (!items) {
 	return TCL_ERROR;
     }
 
-    for (i=0; items[i]; ++i) {
+    for (i = 0; items[i]; ++i) {
 	AddTag(items[i], tag);
     }
+    ckfree(items);
+
+    TtkRedisplayWidget(&tv->core);
+
+    return TCL_OK;
+}
+
+/* Make sure tagset at column is allocated and initialised */
+static void AllocCellTagSets(Treeview *tv, TreeItem *item, TkSizeT columnNumber)
+{
+    TkSizeT i, newSize = MAX(columnNumber + 1, tv->tree.nColumns + 1);
+    if (item->nTagSets < newSize) {
+	if (item->cellTagSets == NULL) {
+	    item->cellTagSets = (Ttk_TagSet *)
+		    ckalloc(sizeof(Ttk_TagSet)*newSize);
+	} else {
+	    item->cellTagSets = (Ttk_TagSet *)
+		    ckrealloc(item->cellTagSets, sizeof(Ttk_TagSet) * newSize);
+	}
+	for (i = item->nTagSets; i < newSize; i++) {
+	    item->cellTagSets[i] = NULL;
+	}
+	item->nTagSets = newSize;
+    }
+
+    if (item->cellTagSets[columnNumber] == NULL) {
+	item->cellTagSets[columnNumber] =
+		Ttk_GetTagSetFromObj(NULL, tv->tree.tagTable, NULL);
+    }
+}
+
+/* + $tv tag cell add $tag $cells
+ */
+static int TreeviewCtagAddCommand(
+    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+{
+    Treeview *tv = (Treeview *)recordPtr;
+    Ttk_Tag tag;
+    TreeCell *cells;
+    TreeItem *item;
+    TkSizeT i, nCells, columnNumber;
+
+    if (objc != 6) {
+	Tcl_WrongNumArgs(interp, 4, objv, "tagName cells");
+	return TCL_ERROR;
+    }
+
+    cells = GetCellListFromObj(interp, tv, objv[5], &nCells);
+    if (cells == NULL) {
+	return TCL_ERROR;
+    }
+
+    tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[4]);
+
+    for (i = 0; i < nCells; i++) {
+	if (cells[i].column == &tv->tree.column0) {
+	    columnNumber = 0;
+	} else {
+	    columnNumber = cells[i].column - tv->tree.columns  + 1;
+	}
+	item = cells[i].item;
+	AllocCellTagSets(tv, item, columnNumber);
+	Ttk_TagSetAdd(item->cellTagSets[columnNumber], tag);
+    }
 
+    ckfree(cells);
     TtkRedisplayWidget(&tv->core);
 
     return TCL_OK;
 }
 
@@ -3227,19 +4216,32 @@
 	if (item->tagsObj) Tcl_DecrRefCount(item->tagsObj);
 	item->tagsObj = Ttk_NewTagSetObj(item->tagset);
 	Tcl_IncrRefCount(item->tagsObj);
     }
 }
+
+/* Remove tag from all cells at row 'item'
+ */
+static void RemoveTagFromCellsAtItem(TreeItem *item, Ttk_Tag tag)
+{
+    TkSizeT i;
+
+    for (i = 0; i < item->nTagSets; i++) {
+        if (item->cellTagSets[i] != NULL) {
+            Ttk_TagSetRemove(item->cellTagSets[i], tag);
+        }
+    }
+}
 
 static int TreeviewTagRemoveCommand(
     void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 {
     Treeview *tv = (Treeview *)recordPtr;
     Ttk_Tag tag;
 
-    if (objc < 4) {
-	Tcl_WrongNumArgs(interp, 3, objv, "tagName items");
+    if (objc < 4 || objc > 5) {
+	Tcl_WrongNumArgs(interp, 3, objv, "tagName ?items?");
 	return TCL_ERROR;
     }
 
     tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[3]);
 
@@ -3248,13 +4250,14 @@
 	int i;
 
 	if (!items) {
 	    return TCL_ERROR;
 	}
-	for (i=0; items[i]; ++i) {
+	for (i = 0; items[i]; ++i) {
 	    RemoveTag(items[i], tag);
 	}
+	ckfree(items);
     } else if (objc == 4) {
 	TreeItem *item = tv->tree.root;
 	while (item) {
 	    RemoveTag(item, tag);
 	    item = NextPreorder(item);
@@ -3263,14 +4266,70 @@
 
     TtkRedisplayWidget(&tv->core);
 
     return TCL_OK;
 }
+
+/* + $tv tag cell remove $tag ?$cells?
+ */
+static int TreeviewCtagRemoveCommand(
+    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+{
+    Treeview *tv = (Treeview *)recordPtr;
+    Ttk_Tag tag;
+    TreeCell *cells;
+    TreeItem *item;
+    TkSizeT i, nCells, columnNumber;
+
+    if (objc < 5 || objc > 6) {
+	Tcl_WrongNumArgs(interp, 4, objv, "tagName ?cells?");
+	return TCL_ERROR;
+    }
+
+    tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[4]);
+
+    if (objc == 6) {
+	cells = GetCellListFromObj(interp, tv, objv[5], &nCells);
+	if (cells == NULL) {
+	    return TCL_ERROR;
+	}
+
+	for (i = 0; i < nCells; i++) {
+	    if (cells[i].column == &tv->tree.column0) {
+		columnNumber = 0;
+	    } else {
+		columnNumber = cells[i].column - tv->tree.columns  + 1;
+	    }
+	    item = cells[i].item;
+	    AllocCellTagSets(tv, item, columnNumber);
+	    Ttk_TagSetRemove(item->cellTagSets[columnNumber], tag);
+	}
+	ckfree(cells);
+    } else {
+	item = tv->tree.root;
+	while (item) {
+            RemoveTagFromCellsAtItem(item, tag);
+	    item = NextPreorder(item);
+	}
+    }
+
+    TtkRedisplayWidget(&tv->core);
+
+    return TCL_OK;
+}
+
+static const Ttk_Ensemble TreeviewCtagCommands[] = {
+    { "add",		TreeviewCtagAddCommand,0 },
+    { "has",		TreeviewCtagHasCommand,0 },
+    { "remove",		TreeviewCtagRemoveCommand,0 },
+    { 0,0,0 }
+};
 
 static const Ttk_Ensemble TreeviewTagCommands[] = {
     { "add",		TreeviewTagAddCommand,0 },
     { "bind",		TreeviewTagBindCommand,0 },
+    { "cell",    	0,TreeviewCtagCommands },
     { "configure",	TreeviewTagConfigureCommand,0 },
     { "delete",		TreeviewTagDeleteCommand,0 },
     { "has",		TreeviewTagHasCommand,0 },
     { "names",		TreeviewTagNamesCommand,0 },
     { "remove",		TreeviewTagRemoveCommand,0 },
@@ -3280,10 +4339,11 @@
 /*------------------------------------------------------------------------
  * +++ Widget commands record.
  */
 static const Ttk_Ensemble TreeviewCommands[] = {
     { "bbox",  		TreeviewBBoxCommand,0 },
+    { "cellselection" ,	TreeviewCellSelectionCommand,0 },
     { "children",	TreeviewChildrenCommand,0 },
     { "cget",		TtkWidgetCgetCommand,0 },
     { "column", 	TreeviewColumnCommand,0 },
     { "configure",	TtkWidgetConfigureCommand,0 },
     { "delete", 	TreeviewDeleteCommand,0 },
@@ -3293,21 +4353,22 @@
     { "exists", 	TreeviewExistsCommand,0 },
     { "focus", 		TreeviewFocusCommand,0 },
     { "heading", 	TreeviewHeadingCommand,0 },
     { "identify",  	TreeviewIdentifyCommand,0 },
     { "index",  	TreeviewIndexCommand,0 },
-    { "instate",	TtkWidgetInstateCommand,0 },
     { "insert", 	TreeviewInsertCommand,0 },
+    { "instate",	TtkWidgetInstateCommand,0 },
     { "item", 		TreeviewItemCommand,0 },
     { "move", 		TreeviewMoveCommand,0 },
     { "next", 		TreeviewNextCommand,0 },
     { "parent", 	TreeviewParentCommand,0 },
     { "prev", 		TreeviewPrevCommand,0 },
     { "see", 		TreeviewSeeCommand,0 },
     { "selection" ,	TreeviewSelectionCommand,0 },
     { "set",  		TreeviewSetCommand,0 },
     { "state",  	TtkWidgetStateCommand,0 },
+    { "style",		TtkWidgetStyleCommand,0 },
     { "tag",    	0,TreeviewTagCommands },
     { "xview",  	TreeviewXViewCommand,0 },
     { "yview",  	TreeviewYViewCommand,0 },
     { 0,0,0 }
 };
@@ -3348,10 +4409,11 @@
 	TTK_NODE("Treeitem.image", TTK_PACK_LEFT)
 	TTK_NODE("Treeitem.text", TTK_FILL_BOTH)))
 
 TTK_LAYOUT("Cell",
     TTK_GROUP("Treedata.padding", TTK_FILL_BOTH,
+	TTK_NODE("Treeitem.image", TTK_PACK_LEFT)
 	TTK_NODE("Treeitem.text", TTK_FILL_BOTH)))
 
 TTK_LAYOUT("Heading",
     TTK_NODE("Treeheading.cell", TTK_FILL_BOTH)
     TTK_GROUP("Treeheading.border", TTK_FILL_BOTH,
@@ -3360,10 +4422,13 @@
 	    TTK_NODE("Treeheading.text", TTK_FILL_X))))
 
 TTK_LAYOUT("Row",
     TTK_NODE("Treeitem.row", TTK_FILL_BOTH))
 
+TTK_LAYOUT("Separator",
+    TTK_NODE("Treeitem.separator", TTK_FILL_BOTH))
+
 TTK_END_LAYOUT_TABLE
 
 /*------------------------------------------------------------------------
  * +++ Tree indicator element.
  */
@@ -3488,12 +4553,13 @@
     RegisterWidget(interp, "ttk::treeview", &TreeviewWidgetSpec);
 
     Ttk_RegisterElement(interp, theme, "Treeitem.indicator",
 	    &TreeitemIndicatorElementSpec, 0);
     Ttk_RegisterElement(interp, theme, "Treeitem.row", &RowElementSpec, 0);
+    Ttk_RegisterElement(interp, theme, "Treeitem.separator", &RowElementSpec, 0);
     Ttk_RegisterElement(interp, theme, "Treeheading.cell", &RowElementSpec, 0);
     Ttk_RegisterElement(interp, theme, "treearea", &ttkNullElementSpec, 0);
 
     Ttk_RegisterLayouts(theme, LayoutTable);
 }
 
 /*EOF*/

Index: generic/ttk/ttkWidget.c
==================================================================
--- generic/ttk/ttkWidget.c
+++ generic/ttk/ttkWidget.c
@@ -1,19 +1,15 @@
 /*
- * Copyright (c) 2003, Joe English
+ * Copyright © 2003, Joe English
  *
  * Core widget utilities.
  */
 
 #include "tkInt.h"
-#include "ttkTheme.h"
+#include "ttkThemeInt.h"
 #include "ttkWidget.h"
 
-#ifdef MAC_OSX_TK
-#define TK_NO_DOUBLE_BUFFERING 1
-#endif
-
 /*------------------------------------------------------------------------
  * +++ Internal helper routines.
  */
 
 /* UpdateLayout --
@@ -116,10 +112,24 @@
     if (!(corePtr->flags & REDISPLAY_PENDING)) {
 	Tcl_DoWhenIdle(DrawWidget, corePtr);
 	corePtr->flags |= REDISPLAY_PENDING;
     }
 }
+
+/*
+ * WidgetWorldChanged --
+ * 	Default Tk_ClassWorldChangedProc() for widgets.
+ * 	Invoked whenever fonts or other system resources are changed;
+ * 	recomputes geometry.
+ */
+static void WidgetWorldChanged(ClientData clientData)
+{
+    WidgetCore *corePtr = (WidgetCore *)clientData;
+    (void)UpdateLayout(corePtr->interp, corePtr);
+    SizeChanged(corePtr);
+    TtkRedisplayWidget(corePtr);
+}
 
 /* TtkResizeWidget --
  * 	Recompute widget size, schedule geometry propagation and redisplay.
  */
 void TtkResizeWidget(WidgetCore *corePtr)
@@ -126,12 +136,11 @@
 {
     if (corePtr->flags & WIDGET_DESTROYED) {
 	return;
     }
 
-    SizeChanged(corePtr);
-    TtkRedisplayWidget(corePtr);
+    WidgetWorldChanged(corePtr);
 }
 
 /* TtkWidgetChangeState --
  * 	Set / clear the specified bits in the 'state' flag,
  */
@@ -310,40 +319,25 @@
 	    TtkRedisplayWidget(corePtr);
 	    break;
 	case VirtualEvent: {
 	    const char *name = ((XVirtualEvent *)eventPtr)->name;
 	    if ((name != NULL) && !strcmp("ThemeChanged", name)) {
-		(void)UpdateLayout(corePtr->interp, corePtr);
-		SizeChanged(corePtr);
-		TtkRedisplayWidget(corePtr);
+		WidgetWorldChanged(corePtr);
 	    }
 	    break;
 	}
 	default:
 	    /* can't happen... */
 	    break;
     }
 }
 
-/*
- * WidgetWorldChanged --
- * 	Default Tk_ClassWorldChangedProc() for widgets.
- * 	Invoked whenever fonts or other system resources are changed;
- * 	recomputes geometry.
- */
-static void WidgetWorldChanged(ClientData clientData)
-{
-    WidgetCore *corePtr = (WidgetCore *)clientData;
-    SizeChanged(corePtr);
-    TtkRedisplayWidget(corePtr);
-}
-
 static const Tk_ClassProcs widgetClassProcs = {
     sizeof(Tk_ClassProcs),	/* size */
-    WidgetWorldChanged,	/* worldChangedProc */
-    NULL,					/* createProc */
-    NULL					/* modalProc */
+    WidgetWorldChanged,		/* worldChangedProc */
+    NULL,			/* createProc */
+    NULL			/* modalProc */
 };
 
 /*
  * TtkWidgetConstructorObjCmd --
  *	General-purpose widget constructor command implementation.
@@ -792,9 +786,29 @@
     if (element) {
 	const char *elementName = Ttk_ElementName(element);
 	Tcl_SetObjResult(interp,Tcl_NewStringObj(elementName,-1));
     }
 
+    return TCL_OK;
+}
+
+/* $w style
+ * 	Return the style currently applied to the widget.
+ */
+
+int TtkWidgetStyleCommand(
+    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+{
+    WidgetCore *corePtr = (WidgetCore *)recordPtr;
+
+    if (objc != 2) {
+	Tcl_WrongNumArgs(interp, 2, objv, "");
+	return TCL_ERROR;
+    }
+
+    Tcl_SetObjResult(interp, Tcl_NewStringObj(
+            Ttk_StyleName(Ttk_LayoutStyle(corePtr->layout)), -1));
+
     return TCL_OK;
 }
 
 /*EOF*/

Index: generic/ttk/ttkWidget.h
==================================================================
--- generic/ttk/ttkWidget.h
+++ generic/ttk/ttkWidget.h
@@ -87,29 +87,31 @@
 
 MODULE_SCOPE int TtkCoreConfigure(Tcl_Interp*, void *, int mask);
 
 /* Common widget commands:
  */
+MODULE_SCOPE int TtkWidgetCgetCommand(
+	void *,Tcl_Interp *, int, Tcl_Obj*const[]);
 MODULE_SCOPE int TtkWidgetConfigureCommand(
 	void *,Tcl_Interp *, int, Tcl_Obj*const[]);
-MODULE_SCOPE int TtkWidgetCgetCommand(
+MODULE_SCOPE int TtkWidgetIdentifyCommand(
 	void *,Tcl_Interp *, int, Tcl_Obj*const[]);
 MODULE_SCOPE int TtkWidgetInstateCommand(
 	void *,Tcl_Interp *, int, Tcl_Obj*const[]);
 MODULE_SCOPE int TtkWidgetStateCommand(
 	void *,Tcl_Interp *, int, Tcl_Obj*const[]);
-MODULE_SCOPE int TtkWidgetIdentifyCommand(
+MODULE_SCOPE int TtkWidgetStyleCommand(
 	void *,Tcl_Interp *, int, Tcl_Obj*const[]);
 
 /* Widget constructor:
  */
 MODULE_SCOPE int TtkWidgetConstructorObjCmd(
 	ClientData, Tcl_Interp*, int, Tcl_Obj*const[]);
 
 #define RegisterWidget(interp, name, specPtr) \
     Tcl_CreateObjCommand(interp, name, \
-	TtkWidgetConstructorObjCmd, (ClientData)specPtr,NULL)
+	TtkWidgetConstructorObjCmd, (void *)specPtr,NULL)
 
 /* WIDGET_TAKEFOCUS_TRUE --
  * WIDGET_TAKEFOCUS_FALSE --
  *	Add one or the other of these to each OptionSpecs table
  *	to indicate whether the widget should take focus
@@ -233,12 +235,14 @@
 
 MODULE_SCOPE void Ttk_FreeTagSet(Ttk_TagSet);
 
 MODULE_SCOPE int Ttk_TagSetContains(Ttk_TagSet, Ttk_Tag tag);
 MODULE_SCOPE int Ttk_TagSetAdd(Ttk_TagSet, Ttk_Tag tag);
+MODULE_SCOPE int Ttk_TagSetAddSet(Ttk_TagSet, Ttk_TagSet);
 MODULE_SCOPE int Ttk_TagSetRemove(Ttk_TagSet, Ttk_Tag tag);
 
+MODULE_SCOPE void Ttk_TagSetDefaults(Ttk_TagTable, Ttk_Style, void *);
 MODULE_SCOPE void Ttk_TagSetValues(Ttk_TagTable, Ttk_TagSet, void *record);
 MODULE_SCOPE void Ttk_TagSetApplyStyle(Ttk_TagTable,Ttk_Style,Ttk_State,void*);
 
 /*
  * String tables for widget resource specifications:

Index: library/bgerror.tcl
==================================================================
--- library/bgerror.tcl
+++ library/bgerror.tcl
@@ -4,12 +4,12 @@
 #	the error message and gives the user a chance to see a more detailed
 #	stack trace, and possible do something more interesting with that
 #	trace (like save it to a log).  This is adapted from work done by
 #	Donal K. Fellows.
 #
-# Copyright © 1998-2000 by Ajuba Solutions.
-# Copyright © 2007 by ActiveState Software Inc.
+# Copyright © 1998-2000 Ajuba Solutions.
+# Copyright © 2007 ActiveState Software Inc.
 # Copyright © 2007 Daniel A. Steffen <das@users.sourceforge.net>
 # Copyright © 2009 Pat Thoyts <patthoyts@users.sourceforge.net>
 
 namespace eval ::tk::dialog::error {
     namespace import -force ::tk::msgcat::*

Index: library/button.tcl
==================================================================
--- library/button.tcl
+++ library/button.tcl
@@ -39,14 +39,14 @@
     bind Checkbutton <Leave> {
 	tk::ButtonLeave %W
     }
 }
 if {"win32" eq [tk windowingsystem]} {
-    bind Checkbutton <equal> {
+    bind Checkbutton <=> {
 	tk::CheckRadioInvoke %W select
     }
-    bind Checkbutton <plus> {
+    bind Checkbutton <+> {
 	tk::CheckRadioInvoke %W select
     }
     bind Checkbutton <minus> {
 	tk::CheckRadioInvoke %W deselect
     }

Index: library/choosedir.tcl
==================================================================
--- library/choosedir.tcl
+++ library/choosedir.tcl
@@ -1,10 +1,10 @@
 # choosedir.tcl --
 #
 #	Choose directory dialog implementation for Unix/Mac.
 #
-# Copyright © 1998-2000 by Scriptics Corporation.
+# Copyright © 1998-2000 Scriptics Corporation.
 # All rights reserved.
 
 # Make sure the tk::dialog namespace, in which all dialogs should live, exists
 namespace eval ::tk::dialog {}
 namespace eval ::tk::dialog::file {}

Index: library/comdlg.tcl
==================================================================
--- library/comdlg.tcl
+++ library/comdlg.tcl
@@ -27,11 +27,12 @@
 # specs = {
 #    {-commandlineswitch resourceName ResourceClass defaultValue verifier}
 #    {....}
 # }
 #
-# flags = currently unused.
+# flags = a list of flags. Currently supported flags are:
+#     DONTSETDEFAULTS = skip default values setting
 #
 # argList = The list of  "-option value" pairs.
 #
 proc tclParseConfigSpec {w specs flags argList} {
     upvar #0 $w data
@@ -61,12 +62,14 @@
 	    "value for \"$cmdsw\" missing"
     }
 
     # 2: set the default values
     #
-    foreach cmdsw [array names cmd] {
-	set data($cmdsw) $def($cmdsw)
+    if {"DONTSETDEFAULTS" ni $flags} {
+        foreach cmdsw [array names cmd] {
+	    set data($cmdsw) $def($cmdsw)
+        }
     }
 
     # 3: parse the argument list
     #
     foreach {cmdsw value} $argList {

Index: library/console.tcl
==================================================================
--- library/console.tcl
+++ library/console.tcl
@@ -89,33 +89,33 @@
 		-command tk::ConsoleAbout
     }
 
     AmpMenuArgs .menubar.edit add separator
     if {$::tk::console::useFontchooser} {
-        if {[tk windowingsystem] eq "aqua"} {
-            .menubar.edit add command -label tk_choose_font_marker
-            set index [.menubar.edit index tk_choose_font_marker]
-            .menubar.edit entryconfigure $index \
-                -label [mc "Show Fonts"]\
-                -accelerator "$mod-T"\
-                -command [list ::tk::console::FontchooserToggle]
-            bind Console <<TkFontchooserVisibility>> \
-                [list ::tk::console::FontchooserVisibility $index]
+	if {[tk windowingsystem] eq "aqua"} {
+	    .menubar.edit add command -label tk_choose_font_marker
+	    set index [.menubar.edit index tk_choose_font_marker]
+	    .menubar.edit entryconfigure $index \
+		-label [mc "Show Fonts"]\
+		-accelerator "$mod-T"\
+		-command [list ::tk::console::FontchooserToggle]
+	    bind Console <<TkFontchooserVisibility>> \
+		[list ::tk::console::FontchooserVisibility $index]
 	    ::tk::console::FontchooserVisibility $index
-        } else {
-            AmpMenuArgs .menubar.edit add command -label [mc "&Font..."] \
-                -command [list ::tk::console::FontchooserToggle]
-        }
+	} else {
+	    AmpMenuArgs .menubar.edit add command -label [mc "&Font..."] \
+		-command [list ::tk::console::FontchooserToggle]
+	}
 	bind Console <FocusIn>  [list ::tk::console::FontchooserFocus %W 1]
 	bind Console <FocusOut> [list ::tk::console::FontchooserFocus %W 0]
     }
     AmpMenuArgs .menubar.edit add command -label [mc "&Increase Font Size"] \
-        -accel "$mod++" -command {event generate .console <<Console_FontSizeIncr>>}
+	-accel "$mod++" -command {event generate .console <<Console_FontSizeIncr>>}
     AmpMenuArgs .menubar.edit add command -label [mc "&Decrease Font Size"] \
-        -accel "$mod+-" -command {event generate .console <<Console_FontSizeDecr>>}
+	-accel "$mod+-" -command {event generate .console <<Console_FontSizeDecr>>}
     AmpMenuArgs .menubar.edit add command -label [mc "Fit To Screen Width"] \
-        -command {event generate .console <<Console_FitScreenWidth>>}
+	-command {event generate .console <<Console_FitScreenWidth>>}
 
     if {[tk windowingsystem] eq "aqua"} {
 	.menubar add cascade -label [mc Window] -menu [menu .menubar.window]
 	.menubar add cascade -label [mc Help] -menu [menu .menubar.help]
     }
@@ -124,35 +124,35 @@
 
     # See if we can find a better font than the TkFixedFont
     catch {font create TkConsoleFont {*}[font configure TkFixedFont]}
     set families [font families]
     switch -exact -- [tk windowingsystem] {
-        aqua { set preferred {Monaco 10} }
-        win32 { set preferred {ProFontWindows 8 Consolas 8} }
-        default { set preferred {} }
+	aqua { set preferred {Monaco 10} }
+	win32 { set preferred {ProFontWindows 8 Consolas 8} }
+	default { set preferred {} }
     }
     foreach {family size} $preferred {
-        if {$family in $families} {
-            font configure TkConsoleFont -family $family -size $size
-            break
-        }
+	if {$family in $families} {
+	    font configure TkConsoleFont -family $family -size $size
+	    break
+	}
     }
 
     # Provide the right border for the text widget (platform dependent).
     ::ttk::style layout ConsoleFrame {
-        Entry.field -sticky news -border 1 -children {
-            ConsoleFrame.padding -sticky news
-        }
+	Entry.field -sticky news -border 1 -children {
+	    ConsoleFrame.padding -sticky news
+	}
     }
     ::ttk::frame .consoleframe -style ConsoleFrame
 
     set con [text .console -yscrollcommand [list .sb set] -setgrid true \
-                 -borderwidth 0 -highlightthickness 0 -font TkConsoleFont]
+		 -borderwidth 0 -highlightthickness 0 -font TkConsoleFont]
     if {[tk windowingsystem] eq "aqua"} {
-        scrollbar .sb -command [list $con yview]
+	scrollbar .sb -command [list $con yview]
     } else {
-        ::ttk::scrollbar .sb -command [list $con yview]
+	::ttk::scrollbar .sb -command [list $con yview]
     }
     pack .sb  -in .consoleframe -fill both -side right -padx 1 -pady 1
     pack $con -in .consoleframe -fill both -expand 1 -side left -padx 1 -pady 1
     pack .consoleframe -fill both -expand 1 -side left
 
@@ -213,11 +213,11 @@
 	    -title [mc "Select a file to source"] \
 	    -filetypes [list \
 	    [list [mc "Tcl Scripts"] .tcl] \
 	    [list [mc "All Files"] *]]]
     if {$filename ne ""} {
-    	set cmd [list source -encoding utf-8 $filename]
+	set cmd [list source -encoding utf-8 $filename]
 	if {[catch {consoleinterp eval $cmd} result]} {
 	    ConsoleOutput stderr "$result\n"
 	}
     }
 }
@@ -271,26 +271,26 @@
 set ::tk::HistNum 1
 proc ::tk::ConsoleHistory {cmd} {
     variable HistNum
 
     switch $cmd {
-    	prev {
+	prev {
 	    incr HistNum -1
 	    if {$HistNum == 0} {
 		set cmd {history event [expr {[history nextid] -1}]}
 	    } else {
 		set cmd "history event $HistNum"
 	    }
-    	    if {[catch {consoleinterp eval $cmd} cmd]} {
-    	    	incr HistNum
-    	    	return
-    	    }
+	    if {[catch {consoleinterp eval $cmd} cmd]} {
+		incr HistNum
+		return
+	    }
 	    .console delete promptEnd end
-    	    .console insert promptEnd $cmd {input stdin}
+	    .console insert promptEnd $cmd {input stdin}
 	    .console see end
-    	}
-    	next {
+	}
+	next {
 	    incr HistNum
 	    if {$HistNum == 0} {
 		set cmd {history event [expr {[history nextid] -1}]}
 	    } elseif {$HistNum > 0} {
 		set cmd ""
@@ -302,14 +302,14 @@
 		catch {consoleinterp eval $cmd} cmd
 	    }
 	    .console delete promptEnd end
 	    .console insert promptEnd $cmd {input stdin}
 	    .console see end
-    	}
-    	reset {
-    	    set HistNum 1
-    	}
+	}
+	reset {
+	    set HistNum 1
+	}
     }
 }
 
 # ::tk::ConsolePrompt --
 # This procedure draws the prompt.  If tcl_prompt1 or tcl_prompt2
@@ -322,23 +322,23 @@
 proc ::tk::ConsolePrompt {{partial normal}} {
     set w .console
     if {$partial eq "normal"} {
 	set temp [$w index "end - 1 char"]
 	$w mark set output end
-    	if {[consoleinterp eval "info exists tcl_prompt1"]} {
-    	    consoleinterp eval "eval \[set tcl_prompt1\]"
-    	} else {
-    	    puts -nonewline [EvalAttached $::tk::console::defaultPrompt]
-    	}
+	if {[consoleinterp eval "info exists tcl_prompt1"]} {
+	    consoleinterp eval "eval \[set tcl_prompt1\]"
+	} else {
+	    puts -nonewline [EvalAttached $::tk::console::defaultPrompt]
+	}
     } else {
 	set temp [$w index output]
 	$w mark set output end
-    	if {[consoleinterp eval "info exists tcl_prompt2"]} {
-    	    consoleinterp eval "eval \[set tcl_prompt2\]"
-    	} else {
+	if {[consoleinterp eval "info exists tcl_prompt2"]} {
+	    consoleinterp eval "eval \[set tcl_prompt2\]"
+	} else {
 	    puts -nonewline "> "
-    	}
+	}
     }
     flush stdout
     $w mark set output $temp
     ::tk::TextSetCursor $w end
     $w mark set promptEnd insert
@@ -348,37 +348,37 @@
 }
 
 # Copy selected text from the console
 proc ::tk::console::Copy {w} {
     if {![catch {set data [$w get sel.first sel.last]}]} {
-        clipboard clear -displayof $w
-        clipboard append -displayof $w $data
+	clipboard clear -displayof $w
+	clipboard append -displayof $w $data
     }
 }
 # Copies selected text. If the selection is within the current active edit
 # region then it will be cut, if not it is only copied.
 proc ::tk::console::Cut {w} {
     if {![catch {set data [$w get sel.first sel.last]}]} {
-        clipboard clear -displayof $w
-        clipboard append -displayof $w $data
-        if {[$w compare sel.first >= output]} {
-            $w delete sel.first sel.last
+	clipboard clear -displayof $w
+	clipboard append -displayof $w $data
+	if {[$w compare sel.first >= output]} {
+	    $w delete sel.first sel.last
 	}
     }
 }
 # Paste text from the clipboard
 proc ::tk::console::Paste {w} {
     catch {
-        set clip [::tk::GetSelection $w CLIPBOARD]
-        set list [split $clip \n\r]
-        tk::ConsoleInsert $w [lindex $list 0]
-        foreach x [lrange $list 1 end] {
-            $w mark set insert {end - 1c}
-            tk::ConsoleInsert $w "\n"
-            tk::ConsoleInvoke
-            tk::ConsoleInsert $w $x
-        }
+	set clip [::tk::GetSelection $w CLIPBOARD]
+	set list [split $clip \n\r]
+	tk::ConsoleInsert $w [lindex $list 0]
+	foreach x [lrange $list 1 end] {
+	    $w mark set insert {end - 1c}
+	    tk::ConsoleInsert $w "\n"
+	    tk::ConsoleInvoke
+	    tk::ConsoleInsert $w $x
+	}
     }
 }
 
 # Fit TkConsoleFont to window width
 proc ::tk::console::FitScreenWidth {w} {
@@ -386,18 +386,18 @@
     set cwidth [$w cget -width]
     set s -50
     set fit 0
     array set fi [font configure TkConsoleFont]
     while {$s < 0} {
-        set fi(-size) $s
-        set f [font create {*}[array get fi]]
-        set c [font measure $f "eM"]
-        font delete $f
-        if {$c * $cwidth < 1.667 * $width} {
-            font configure TkConsoleFont -size $s
-            break
-        }
+	set fi(-size) $s
+	set f [font create {*}[array get fi]]
+	set c [font measure $f "eM"]
+	font delete $f
+	if {$c * $cwidth < 1.667 * $width} {
+	    font configure TkConsoleFont -size $s
+	    break
+	}
 	incr s 2
     }
 }
 
 # ::tk::ConsoleBind --
@@ -422,18 +422,20 @@
 
     # For the moment, transpose isn't enabled until the console
     # gets and overhaul of how it handles input -- hobbs
     bind Console <Control-t> {}
 
-    # Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
+    # Ignore all Alt, Meta, Control, Command, and Fn keypresses unless explicitly bound.
     # Otherwise, if a widget binding for one of these is defined, the
     # <Keypress> class binding will also fire and insert the character
     # which is wrong.
 
     bind Console <Alt-Key> {# nothing }
     bind Console <Meta-Key> {# nothing}
     bind Console <Control-Key> {# nothing}
+    bind Console <Command-Key> {# nothing}
+    bind Console <Fn-Key> {# nothing}
 
     foreach {ev key} {
 	<<Console_NextImmediate>>	<Control-n>
 	<<Console_PrevImmediate>>	<Control-p>
 	<<Console_PrevSearch>>		<Control-r>
@@ -452,27 +454,20 @@
 	<<Console_Clear>>		<Control-l>
 	<<Console_KillLine>>		<Control-k>
 	<<Console_Transpose>>		<Control-t>
 	<<Console_ClearLine>>		<Control-u>
 	<<Console_SaveCommand>>		<Control-z>
-	<<Console_FontSizeIncr>>	<Control-plus>
+	<<Console_FontSizeIncr>>	<Control-+>
 	<<Console_FontSizeDecr>>	<Control-minus>
+	<<Console_FontSizeIncr>>	<Command-+>
+	<<Console_FontSizeDecr>>	<Command-minus>
     } {
 	event add $ev $key
 	bind Console $key {}
     }
-    if {[tk windowingsystem] eq "aqua"} {
-	foreach {ev key} {
-	    <<Console_FontSizeIncr>>	<Command-plus>
-	    <<Console_FontSizeDecr>>	<Command-minus>
-	} {
-	    event add $ev $key
-	    bind Console $key {}
-	}
-	if {$::tk::console::useFontchooser} {
-	    bind Console <Command-t> [list ::tk::console::FontchooserToggle]
-	}
+    if {$::tk::console::useFontchooser} {
+	bind Console <Command-t> [list ::tk::console::FontchooserToggle]
     }
     bind Console <<Console_Expand>> {
 	if {[%W compare insert > promptEnd]} {
 	    ::tk::console::Expand %W
 	}
@@ -592,34 +587,32 @@
     }
     bind Console <F9> {
 	eval destroy [winfo child .]
 	source -encoding utf-8 [file join $tk_library console.tcl]
     }
-    if {[tk windowingsystem] eq "aqua"} {
-	bind Console <Command-q> {
-	    exit
-	}
+    bind Console <Command-q> {
+	exit
     }
     bind Console <<Cut>> { ::tk::console::Cut %W }
     bind Console <<Copy>> { ::tk::console::Copy %W }
     bind Console <<Paste>> { ::tk::console::Paste %W }
 
     bind Console <<Console_FontSizeIncr>> {
-        set size [font configure TkConsoleFont -size]
-        if {$size < 0} {set sign -1} else {set sign 1}
-        set size [expr {(abs($size) + 1) * $sign}]
-        font configure TkConsoleFont -size $size
+	set size [font configure TkConsoleFont -size]
+	if {$size < 0} {set sign -1} else {set sign 1}
+	set size [expr {(abs($size) + 1) * $sign}]
+	font configure TkConsoleFont -size $size
 	if {$::tk::console::useFontchooser} {
 	    tk fontchooser configure -font TkConsoleFont
 	}
     }
     bind Console <<Console_FontSizeDecr>> {
-        set size [font configure TkConsoleFont -size]
-        if {abs($size) < 2} { return }
-        if {$size < 0} {set sign -1} else {set sign 1}
-        set size [expr {(abs($size) - 1) * $sign}]
-        font configure TkConsoleFont -size $size
+	set size [font configure TkConsoleFont -size]
+	if {abs($size) < 2} { return }
+	if {$size < 0} {set sign -1} else {set sign 1}
+	set size [expr {(abs($size) - 1) * $sign}]
+	font configure TkConsoleFont -size $size
 	if {$::tk::console::useFontchooser} {
 	    tk fontchooser configure -font TkConsoleFont
 	}
     }
     bind Console <<Console_FitScreenWidth>> {

Index: library/demos/cscroll.tcl
==================================================================
--- library/demos/cscroll.tcl
+++ library/demos/cscroll.tcl
@@ -112,11 +112,11 @@
 
 if {[tk windowingsystem] eq "x11" && ![package vsatisfies [package provide Tk] 8.7-]} {
     # Support for mousewheels on Linux/Unix commonly comes through mapping
     # the wheel to the extended buttons.  If you have a mousewheel, find
     # Linux configuration info at:
-    #	http://linuxreviews.org/howtos/xfree/mouse/
+    #	https://linuxreviews.org/HOWTO_change_the_mouse_speed_in_X
     bind $c <Button-4> {
 	if {!$tk_strictMotif} {
 	    %W yview scroll -5 units
 	}
     }

Index: library/demos/en.msg
==================================================================
--- library/demos/en.msg
+++ library/demos/en.msg
@@ -7,44 +7,35 @@
 ::msgcat::mcset en "&Quit"
 ::msgcat::mcset en "Meta+Q"		;# Displayed hotkey
 ::msgcat::mcset en "Meta-q"		;# Actual binding sequence
 ::msgcat::mcset en "Ctrl+Q"		;# Displayed hotkey
 ::msgcat::mcset en "Control-q"		;# Actual binding sequence
+::msgcat::mcset en "See Variables"
 ::msgcat::mcset en "Variable values"
 ::msgcat::mcset en "Variable values:"
 ::msgcat::mcset en "OK"
 ::msgcat::mcset en "Run the \"%s\" sample program"
 ::msgcat::mcset en "Dismiss"
 ::msgcat::mcset en "Rerun Demo"
+::msgcat::mcset en "Print Code"
 ::msgcat::mcset en "Demo code: %s"
 ::msgcat::mcset en "About Widget Demo"
-::msgcat::mcset en "Tk widget demonstration application"
+::msgcat::mcset en "Tk widget demonstration"
 ::msgcat::mcset en "Copyright © %s"
-::msgcat::mcset en "
-    @@title
-    Tk Widget Demonstrations
-    @@newline
-    @@normal
-    @@newline
-
-    This application provides a front end for several short scripts
-    that demonstrate what you can do with Tk widgets.  Each of the
-    numbered lines below describes a demonstration;  you can click on
-    it to invoke the demonstration.  Once the demonstration window
-    appears, you can click the
-    @@bold
-    See Code
-    @@normal
-    button to see the Tcl/Tk code that created the demonstration.  If
-    you wish, you can edit the code and click the
-    @@bold
-    Rerun Demo
-    @@normal
-    button in the code window to reinvoke the demonstration with the
-    modified code.
-    @@newline
-"
+
+::msgcat::mcset en "Tk Widget Demonstrations"
+::msgcat::mcset en "This application provides a front end for several short scripts"
+::msgcat::mcset en "that demonstrate what you can do with Tk widgets.  Each of the"
+::msgcat::mcset en "numbered lines below describes a demonstration;  you can click on"
+::msgcat::mcset en "it to invoke the demonstration.  Once the demonstration window"
+::msgcat::mcset en "appears, you can click the"
+::msgcat::mcset en "See Code"  "See Code"	;# This is also button text!
+::msgcat::mcset en "button to see the Tcl/Tk code that created the demonstration.  If"
+::msgcat::mcset en "you wish, you can edit the code and click the"
+::msgcat::mcset en "button in the code window to reinvoke the demonstration with the"
+::msgcat::mcset en "modified code."
+
 ::msgcat::mcset en "Labels, buttons, checkbuttons, and radiobuttons"
 ::msgcat::mcset en "Labels (text and bitmaps)"
 ::msgcat::mcset en "Labels and UNICODE text"
 ::msgcat::mcset en "Buttons"
 ::msgcat::mcset en "Check-buttons (select any of a group)"
@@ -52,37 +43,43 @@
 ::msgcat::mcset en "A 15-puzzle game made out of buttons"
 ::msgcat::mcset en "Iconic buttons that use bitmaps"
 ::msgcat::mcset en "Two labels displaying images"
 ::msgcat::mcset en "A simple user interface for viewing images"
 ::msgcat::mcset en "Labelled frames"
+
 ::msgcat::mcset en "Listboxes"
 ::msgcat::mcset en "The 50 states"
 ::msgcat::mcset en "Colors: change the color scheme for the application"
 ::msgcat::mcset en "A collection of famous and infamous sayings"
+
 ::msgcat::mcset en "Entries and Spin-boxes"
 ::msgcat::mcset en "Entries without scrollbars"
 ::msgcat::mcset en "Entries with scrollbars"
 ::msgcat::mcset en "Validated entries and password fields"
 ::msgcat::mcset en "Spin-boxes"
 ::msgcat::mcset en "Simple Rolodex-like form"
+
 ::msgcat::mcset en "Text"
 ::msgcat::mcset en "Basic editable text"
 ::msgcat::mcset en "Text display styles"
 ::msgcat::mcset en "Hypertext (tag bindings)"
 ::msgcat::mcset en "A text widget with embedded windows"
 ::msgcat::mcset en "A search tool built with a text widget"
+
 ::msgcat::mcset en "Canvases"
 ::msgcat::mcset en "The canvas item types"
 ::msgcat::mcset en "A simple 2-D plot"
 ::msgcat::mcset en "Text items in canvases"
 ::msgcat::mcset en "An editor for arrowheads on canvas lines"
 ::msgcat::mcset en "A ruler with adjustable tab stops"
 ::msgcat::mcset en "A building floor plan"
 ::msgcat::mcset en "A simple scrollable canvas"
+
 ::msgcat::mcset en "Scales"
 ::msgcat::mcset en "Horizontal scale"
 ::msgcat::mcset en "Vertical scale"
+
 ::msgcat::mcset en "Paned Windows"
 ::msgcat::mcset en "Horizontal paned window"
 ::msgcat::mcset en "Vertical paned window"
 ::msgcat::mcset en "Menus"
 ::msgcat::mcset en "Menus and cascades (sub-menus)"
@@ -89,9 +86,18 @@
 ::msgcat::mcset en "Menu-buttons"
 ::msgcat::mcset en "Common Dialogs"
 ::msgcat::mcset en "Message boxes"
 ::msgcat::mcset en "File selection dialog"
 ::msgcat::mcset en "Color picker"
+::msgcat::mcset en "Font selection dialog"
+::msgcat::mcset en "System tray icon and notification"
+::msgcat::mcset en "Printing from canvas and text widgets"
+::msgcat::mcset en "Animation"
+::msgcat::mcset en "Animated labels"
+::msgcat::mcset en "Animated wave"
+::msgcat::mcset en "Pendulum simulation"
+::msgcat::mcset en "A celebration of Rube Goldberg"
 ::msgcat::mcset en "Miscellaneous"
 ::msgcat::mcset en "The built-in bitmaps"
 ::msgcat::mcset en "A dialog box with a local grab"
 ::msgcat::mcset en "A dialog box with a global grab"
+::msgcat::mcset en "Window icons and badges"

Index: library/demos/entry3.tcl
==================================================================
--- library/demos/entry3.tcl
+++ library/demos/entry3.tcl
@@ -62,17 +62,17 @@
 }
 
 labelframe $w.l1 -text "Integer Entry"
 # Alternatively try using {string is digit} for arbitrary length numbers,
 # and not just 32-bit ones.
-entry $w.l1.e -validate focus -vcmd {string is integer %P}
+entry $w.l1.e -validate focus -validatecommand {string is integer %P}
 $w.l1.e configure -invalidcommand \
 	"focusAndFlash %W [$w.l1.e cget -fg] [$w.l1.e cget -bg]"
 pack $w.l1.e -fill x -expand 1 -padx 1m -pady 1m
 
 labelframe $w.l2 -text "Length-Constrained Entry"
-entry $w.l2.e -validate key -invcmd bell -vcmd {expr {[string length %P]<10}}
+entry $w.l2.e -validate key -invcmd bell -validatecommand {expr {[string length %P]<10}}
 pack $w.l2.e -fill x -expand 1 -padx 1m -pady 1m
 
 ### PHONE NUMBER ENTRY ###
 # Note that the source to this is quite a bit longer as the behaviour
 # demonstrated is a lot more ambitious than with the others.
@@ -159,11 +159,11 @@
     }
 }
 
 labelframe $w.l3 -text "US Phone-Number Entry"
 entry $w.l3.e -validate key  -invcmd bell  -textvariable entry3content \
-	-vcmd {validatePhoneChange %W %v %i %S}
+	-validatecommand {validatePhoneChange %W %v %i %S}
 # Click to focus goes to the first editable character...
 bind $w.l3.e <FocusIn> {
     if {"%d" ne "NotifyAncestor"} {
 	%W icursor 3
 	after idle {%W selection clear}
@@ -172,14 +172,14 @@
 bind $w.l3.e <<PrevChar>> {phoneSkipLeft  %W}
 bind $w.l3.e <<NextChar>> {phoneSkipRight %W}
 pack $w.l3.e -fill x -expand 1 -padx 1m -pady 1m
 
 labelframe $w.l4 -text "Password Entry"
-entry $w.l4.e -validate key -show "*" -vcmd {expr {[string length %P]<=8}}
+entry $w.l4.e -validate key -show "*" -validatecommand {expr {[string length %P]<=8}}
 pack $w.l4.e -fill x -expand 1 -padx 1m -pady 1m
 
 lower [frame $w.mid]
 grid $w.l1 $w.l2 -in $w.mid -padx 3m -pady 1m -sticky ew
 grid $w.l3 $w.l4 -in $w.mid -padx 3m -pady 1m -sticky ew
 grid columnconfigure $w.mid {0 1} -uniform 1
 pack $w.msg -side top
 pack $w.mid -fill both -expand 1

Index: library/demos/floor.tcl
==================================================================
--- library/demos/floor.tcl
+++ library/demos/floor.tcl
@@ -331,199 +331,199 @@
 # w -		The canvas window.
 # color -	Color to use for drawing foreground information.
 
 proc fg1 {w color} {
     global floorLabels floorItems
-    set i [$w create polygon 375 246 375 172 341 172 341 246 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 101
     set {floorItems(101)} $i
     $w create text 358 209 -text 101 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 307 240 339 240 339 206 307 206 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) {Pub Lift1}
     set {floorItems(Pub Lift1)} $i
     $w create text 323 223 -text {Pub Lift1} -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 339 205 307 205 307 171 339 171 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) {Priv Lift1}
     set {floorItems(Priv Lift1)} $i
     $w create text 323 188 -text {Priv Lift1} -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 42 389 42 337 1 337 1 389 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 42 389 42 337 1 337 1 389 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 110
     set {floorItems(110)} $i
     $w create text 21.5 363 -text 110 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 59 389 59 385 90 385 90 337 44 337 44 389 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 59 389 59 385 90 385 90 337 44 337 44 389 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 109
     set {floorItems(109)} $i
     $w create text 67 363 -text 109 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 51 300 51 253 6 253 6 300 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 51 300 51 253 6 253 6 300 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 111
     set {floorItems(111)} $i
     $w create text 28.5 276.5 -text 111 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 98 248 98 309 79 309 79 248 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 98 248 98 309 79 309 79 248 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 117B
     set {floorItems(117B)} $i
     $w create text 88.5 278.5 -text 117B -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 51 251 51 204 6 204 6 251 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 51 251 51 204 6 204 6 251 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 112
     set {floorItems(112)} $i
     $w create text 28.5 227.5 -text 112 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 6 156 51 156 51 203 6 203 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 6 156 51 156 51 203 6 203 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 113
     set {floorItems(113)} $i
     $w create text 28.5 179.5 -text 113 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 85 169 79 169 79 192 85 192 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 85 169 79 169 79 192 85 192 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 117A
     set {floorItems(117A)} $i
     $w create text 82 180.5 -text 117A -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 77 302 77 168 53 168 53 302 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 77 302 77 168 53 168 53 302 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 117
     set {floorItems(117)} $i
     $w create text 65 235 -text 117 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 51 155 51 115 6 115 6 155 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 51 155 51 115 6 115 6 155 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 114
     set {floorItems(114)} $i
     $w create text 28.5 135 -text 114 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 95 115 53 115 53 168 95 168 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 95 115 53 115 53 168 95 168 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 115
     set {floorItems(115)} $i
     $w create text 74 141.5 -text 115 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 87 113 87 27 10 27 10 113 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 87 113 87 27 10 27 10 113 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 116
     set {floorItems(116)} $i
     $w create text 48.5 70 -text 116 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 89 91 128 91 128 113 89 113 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 89 91 128 91 128 113 89 113 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 118
     set {floorItems(118)} $i
     $w create text 108.5 102 -text 118 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 178 128 178 132 216 132 216 91 163 91 163 112 149 112 149 128 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 178 128 178 132 216 132 216 91 163 91 163 112 149 112 149 128 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 120
     set {floorItems(120)} $i
     $w create text 189.5 111.5 -text 120 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 79 193 87 193 87 169 136 169 136 192 156 192 156 169 175 169 175 246 79 246 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 79 193 87 193 87 169 136 169 136 192 156 192 156 169 175 169 175 246 79 246 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 122
     set {floorItems(122)} $i
     $w create text 131 207.5 -text 122 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 138 169 154 169 154 191 138 191 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 138 169 154 169 154 191 138 191 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 121
     set {floorItems(121)} $i
     $w create text 146 180 -text 121 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 99 300 126 300 126 309 99 309 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 99 300 126 300 126 309 99 309 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 106A
     set {floorItems(106A)} $i
     $w create text 112.5 304.5 -text 106A -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 128 299 128 309 150 309 150 248 99 248 99 299 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 128 299 128 309 150 309 150 248 99 248 99 299 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 105
     set {floorItems(105)} $i
     $w create text 124.5 278.5 -text 105 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 174 309 174 300 152 300 152 309 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 174 309 174 300 152 300 152 309 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 106B
     set {floorItems(106B)} $i
     $w create text 163 304.5 -text 106B -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 176 299 176 309 216 309 216 248 152 248 152 299 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 176 299 176 309 216 309 216 248 152 248 152 299 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 104
     set {floorItems(104)} $i
     $w create text 184 278.5 -text 104 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 138 385 138 337 91 337 91 385 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 138 385 138 337 91 337 91 385 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 108
     set {floorItems(108)} $i
     $w create text 114.5 361 -text 108 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 256 337 140 337 140 385 256 385 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 256 337 140 337 140 385 256 385 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 107
     set {floorItems(107)} $i
     $w create text 198 361 -text 107 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 300 353 300 329 260 329 260 353 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 300 353 300 329 260 329 260 353 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) Smoking
     set {floorItems(Smoking)} $i
     $w create text 280 341 -text Smoking -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 314 135 314 170 306 170 306 246 177 246 177 135 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 314 135 314 170 306 170 306 246 177 246 177 135 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 123
     set {floorItems(123)} $i
     $w create text 245.5 190.5 -text 123 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 217 248 301 248 301 326 257 326 257 310 217 310 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 217 248 301 248 301 326 257 326 257 310 217 310 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 103
     set {floorItems(103)} $i
     $w create text 259 287 -text 103 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 396 188 377 188 377 169 316 169 316 131 396 131 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 396 188 377 188 377 169 316 169 316 131 396 131 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 124
     set {floorItems(124)} $i
     $w create text 356 150 -text 124 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 397 226 407 226 407 189 377 189 377 246 397 246 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 397 226 407 226 407 189 377 189 377 246 397 246 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 125
     set {floorItems(125)} $i
     $w create text 392 217.5 -text 125 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 399 187 409 187 409 207 474 207 474 164 399 164 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 399 187 409 187 409 207 474 207 474 164 399 164 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 126
     set {floorItems(126)} $i
     $w create text 436.5 185.5 -text 126 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 409 209 409 229 399 229 399 253 486 253 486 239 474 239 474 209 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 409 209 409 229 399 229 399 253 486 253 486 239 474 239 474 209 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 127
     set {floorItems(127)} $i
     $w create text 436.5 231 -text 127 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 501 164 501 174 495 174 495 188 490 188 490 204 476 204 476 164 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 501 164 501 174 495 174 495 188 490 188 490 204 476 204 476 164 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) MShower
     set {floorItems(MShower)} $i
     $w create text 488.5 184 -text MShower -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 497 176 513 176 513 204 492 204 492 190 497 190 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 497 176 513 176 513 204 492 204 492 190 497 190 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) Closet
     set {floorItems(Closet)} $i
     $w create text 502.5 190 -text Closet -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 476 237 476 206 513 206 513 254 488 254 488 237 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 476 237 476 206 513 206 513 254 488 254 488 237 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) WShower
     set {floorItems(WShower)} $i
     $w create text 494.5 230 -text WShower -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 486 131 558 131 558 135 724 135 724 166 697 166 697 275 553 275 531 254 515 254 515 174 503 174 503 161 486 161 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 486 131 558 131 558 135 724 135 724 166 697 166 697 275 553 275 531 254 515 254 515 174 503 174 503 161 486 161 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 130
     set {floorItems(130)} $i
     $w create text 638.5 205 -text 130 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 308 242 339 242 339 248 342 248 342 246 397 246 397 276 393 276 393 309 300 309 300 248 308 248 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 308 242 339 242 339 248 342 248 342 246 397 246 397 276 393 276 393 309 300 309 300 248 308 248 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 102
     set {floorItems(102)} $i
     $w create text 367.5 278.5 -text 102 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 397 255 486 255 486 276 397 276 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 397 255 486 255 486 276 397 276 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 128
     set {floorItems(128)} $i
     $w create text 441.5 265.5 -text 128 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 510 309 486 309 486 255 530 255 552 277 561 277 561 325 510 325 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 510 309 486 309 486 255 530 255 552 277 561 277 561 325 510 325 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 129
     set {floorItems(129)} $i
     $w create text 535.5 293 -text 129 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 696 281 740 281 740 387 642 387 642 389 561 389 561 277 696 277 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 696 281 740 281 740 387 642 387 642 389 561 389 561 277 696 277 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 133
     set {floorItems(133)} $i
     $w create text 628.5 335 -text 133 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 742 387 742 281 800 281 800 387 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 742 387 742 281 800 281 800 387 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 132
     set {floorItems(132)} $i
     $w create text 771 334 -text 132 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 800 168 800 280 699 280 699 168 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 800 168 800 280 699 280 699 168 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 134
     set {floorItems(134)} $i
     $w create text 749.5 224 -text 134 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 726 131 726 166 800 166 800 131 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 726 131 726 166 800 166 800 131 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 135
     set {floorItems(135)} $i
     $w create text 763 148.5 -text 135 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 340 360 335 363 331 365 326 366 304 366 304 312 396 312 396 288 400 288 404 288 409 290 413 292 418 297 421 302 422 309 421 318 417 325 411 330 405 332 397 333 344 333 340 334 336 336 335 338 332 342 331 347 332 351 334 354 336 357 341 359 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 340 360 335 363 331 365 326 366 304 366 304 312 396 312 396 288 400 288 404 288 409 290 413 292 418 297 421 302 422 309 421 318 417 325 411 330 405 332 397 333 344 333 340 334 336 336 335 338 332 342 331 347 332 351 334 354 336 357 341 359 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) {Ramona Stair}
     set {floorItems(Ramona Stair)} $i
     $w create text 368 323 -text {Ramona Stair} -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 30 23 30 5 93 5 98 5 104 7 110 10 116 16 119 20 122 28 123 32 123 68 220 68 220 87 90 87 90 23 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 30 23 30 5 93 5 98 5 104 7 110 10 116 16 119 20 122 28 123 32 123 68 220 68 220 87 90 87 90 23 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) {University Stair}
     set {floorItems(University Stair)} $i
     $w create text 155 77.5 -text {University Stair} -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 282 37 295 40 312 49 323 56 337 70 352 56 358 48 363 39 365 29 348 25 335 22 321 14 300 5 283 1 260 0 246 0 242 2 236 4 231 8 227 13 223 17 221 22 220 34 260 34 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 282 37 295 40 312 49 323 56 337 70 352 56 358 48 363 39 365 29 348 25 335 22 321 14 300 5 283 1 260 0 246 0 242 2 236 4 231 8 227 13 223 17 221 22 220 34 260 34 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) {Plaza Stair}
     set {floorItems(Plaza Stair)} $i
     $w create text 317.5 28.5 -text {Plaza Stair} -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 220 34 260 34 282 37 295 40 312 49 323 56 337 70 350 83 365 94 377 100 386 104 386 128 220 128 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 220 34 260 34 282 37 295 40 312 49 323 56 337 70 350 83 365 94 377 100 386 104 386 128 220 128 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) {Plaza Deck}
     set {floorItems(Plaza Deck)} $i
     $w create text 303 81 -text {Plaza Deck} -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 257 336 77 336 6 336 6 301 77 301 77 310 257 310 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 257 336 77 336 6 336 6 301 77 301 77 310 257 310 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 106
     set {floorItems(106)} $i
     $w create text 131.5 318.5 -text 106 -fill $color -anchor c -tags {floor1 label}
-    set i [$w create polygon 146 110 162 110 162 91 130 91 130 115 95 115 95 128 114 128 114 151 157 151 157 153 112 153 112 130 97 130 97 168 175 168 175 131 146 131 -outline {} -tags {floor1 room}]
+    set i [$w create polygon 146 110 162 110 162 91 130 91 130 115 95 115 95 128 114 128 114 151 157 151 157 153 112 153 112 130 97 130 97 168 175 168 175 131 146 131 -fill {} -outline {} -tags {floor1 room}]
     set floorLabels($i) 119
     set {floorItems(119)} $i
     $w create text 143.5 133 -text 119 -fill $color -anchor c -tags {floor1 label}
     $w create line 155 191 155 189 -fill $color -tags {floor1 wall}
     $w create line 155 177 155 169 -fill $color -tags {floor1 wall}
@@ -694,211 +694,211 @@
 # w -		The canvas window.
 # color -	Color to use for drawing foreground information.
 
 proc fg2 {w color} {
     global floorLabels floorItems
-    set i [$w create polygon 748 188 755 188 755 205 758 205 758 222 800 222 800 168 748 168 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 748 188 755 188 755 205 758 205 758 222 800 222 800 168 748 168 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 238
     set {floorItems(238)} $i
     $w create text 774 195 -text 238 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 726 188 746 188 746 166 800 166 800 131 726 131 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 726 188 746 188 746 166 800 166 800 131 726 131 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 237
     set {floorItems(237)} $i
     $w create text 763 148.5 -text 237 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 497 187 497 204 559 204 559 324 641 324 643 324 643 291 641 291 641 205 696 205 696 291 694 291 694 314 715 314 715 291 715 205 755 205 755 190 724 190 724 187 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 497 187 497 204 559 204 559 324 641 324 643 324 643 291 641 291 641 205 696 205 696 291 694 291 694 314 715 314 715 291 715 205 755 205 755 190 724 190 724 187 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 246
     set {floorItems(246)} $i
     $w create text 600 264 -text 246 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 694 279 643 279 643 314 694 314 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 694 279 643 279 643 314 694 314 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 247
     set {floorItems(247)} $i
     $w create text 668.5 296.5 -text 247 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 232 250 308 250 308 242 339 242 339 246 397 246 397 255 476 255 476 250 482 250 559 250 559 274 482 274 482 278 396 278 396 274 232 274 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 232 250 308 250 308 242 339 242 339 246 397 246 397 255 476 255 476 250 482 250 559 250 559 274 482 274 482 278 396 278 396 274 232 274 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 202
     set {floorItems(202)} $i
     $w create text 285.5 260 -text 202 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 53 228 53 338 176 338 233 338 233 196 306 196 306 180 175 180 175 169 156 169 156 196 176 196 176 228 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 53 228 53 338 176 338 233 338 233 196 306 196 306 180 175 180 175 169 156 169 156 196 176 196 176 228 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 206
     set {floorItems(206)} $i
     $w create text 143 267 -text 206 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 51 277 6 277 6 338 51 338 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 51 277 6 277 6 338 51 338 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 212
     set {floorItems(212)} $i
     $w create text 28.5 307.5 -text 212 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 557 276 486 276 486 309 510 309 510 325 557 325 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 557 276 486 276 486 309 510 309 510 325 557 325 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 245
     set {floorItems(245)} $i
     $w create text 521.5 300.5 -text 245 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 560 389 599 389 599 326 560 326 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 560 389 599 389 599 326 560 326 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 244
     set {floorItems(244)} $i
     $w create text 579.5 357.5 -text 244 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 601 389 601 326 643 326 643 389 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 601 389 601 326 643 326 643 389 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 243
     set {floorItems(243)} $i
     $w create text 622 357.5 -text 243 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 688 316 645 316 645 365 688 365 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 688 316 645 316 645 365 688 365 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 242
     set {floorItems(242)} $i
     $w create text 666.5 340.5 -text 242 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 802 367 759 367 759 226 802 226 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 802 367 759 367 759 226 802 226 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) {Barbecue Deck}
     set {floorItems(Barbecue Deck)} $i
     $w create text 780.5 296.5 -text {Barbecue Deck} -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 755 262 755 314 717 314 717 262 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 755 262 755 314 717 314 717 262 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 240
     set {floorItems(240)} $i
     $w create text 736 288 -text 240 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 755 316 689 316 689 365 755 365 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 755 316 689 316 689 365 755 365 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 241
     set {floorItems(241)} $i
     $w create text 722 340.5 -text 241 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 755 206 717 206 717 261 755 261 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 755 206 717 206 717 261 755 261 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 239
     set {floorItems(239)} $i
     $w create text 736 233.5 -text 239 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 695 277 643 277 643 206 695 206 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 695 277 643 277 643 206 695 206 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 248
     set {floorItems(248)} $i
     $w create text 669 241.5 -text 248 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 676 135 676 185 724 185 724 135 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 676 135 676 185 724 185 724 135 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 236
     set {floorItems(236)} $i
     $w create text 700 160 -text 236 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 675 135 635 135 635 145 628 145 628 185 675 185 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 675 135 635 135 635 145 628 145 628 185 675 185 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 235
     set {floorItems(235)} $i
     $w create text 651.5 160 -text 235 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 626 143 633 143 633 135 572 135 572 143 579 143 579 185 626 185 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 626 143 633 143 633 135 572 135 572 143 579 143 579 185 626 185 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 234
     set {floorItems(234)} $i
     $w create text 606 160 -text 234 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 557 135 571 135 571 145 578 145 578 185 527 185 527 131 557 131 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 557 135 571 135 571 145 578 145 578 185 527 185 527 131 557 131 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 233
     set {floorItems(233)} $i
     $w create text 552.5 158 -text 233 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 476 249 557 249 557 205 476 205 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 476 249 557 249 557 205 476 205 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 230
     set {floorItems(230)} $i
     $w create text 516.5 227 -text 230 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 476 164 486 164 486 131 525 131 525 185 476 185 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 476 164 486 164 486 131 525 131 525 185 476 185 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 232
     set {floorItems(232)} $i
     $w create text 500.5 158 -text 232 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 476 186 495 186 495 204 476 204 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 476 186 495 186 495 204 476 204 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 229
     set {floorItems(229)} $i
     $w create text 485.5 195 -text 229 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 474 207 409 207 409 187 399 187 399 164 474 164 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 474 207 409 207 409 187 399 187 399 164 474 164 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 227
     set {floorItems(227)} $i
     $w create text 436.5 185.5 -text 227 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 399 228 399 253 474 253 474 209 409 209 409 228 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 399 228 399 253 474 253 474 209 409 209 409 228 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 228
     set {floorItems(228)} $i
     $w create text 436.5 231 -text 228 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 397 246 397 226 407 226 407 189 377 189 377 246 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 397 246 397 226 407 226 407 189 377 189 377 246 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 226
     set {floorItems(226)} $i
     $w create text 392 217.5 -text 226 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 377 169 316 169 316 131 397 131 397 188 377 188 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 377 169 316 169 316 131 397 131 397 188 377 188 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 225
     set {floorItems(225)} $i
     $w create text 356.5 150 -text 225 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 234 198 306 198 306 249 234 249 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 234 198 306 198 306 249 234 249 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 224
     set {floorItems(224)} $i
     $w create text 270 223.5 -text 224 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 270 179 306 179 306 170 314 170 314 135 270 135 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 270 179 306 179 306 170 314 170 314 135 270 135 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 223
     set {floorItems(223)} $i
     $w create text 292 157 -text 223 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 268 179 221 179 221 135 268 135 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 268 179 221 179 221 135 268 135 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 222
     set {floorItems(222)} $i
     $w create text 244.5 157 -text 222 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 177 179 219 179 219 135 177 135 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 177 179 219 179 219 135 177 135 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 221
     set {floorItems(221)} $i
     $w create text 198 157 -text 221 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 299 327 349 327 349 284 341 284 341 276 299 276 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 299 327 349 327 349 284 341 284 341 276 299 276 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 204
     set {floorItems(204)} $i
     $w create text 324 301.5 -text 204 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 234 276 297 276 297 327 257 327 257 338 234 338 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 234 276 297 276 297 327 257 327 257 338 234 338 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 205
     set {floorItems(205)} $i
     $w create text 265.5 307 -text 205 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 256 385 256 340 212 340 212 385 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 256 385 256 340 212 340 212 385 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 207
     set {floorItems(207)} $i
     $w create text 234 362.5 -text 207 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 210 340 164 340 164 385 210 385 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 210 340 164 340 164 385 210 385 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 208
     set {floorItems(208)} $i
     $w create text 187 362.5 -text 208 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 115 340 162 340 162 385 115 385 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 115 340 162 340 162 385 115 385 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 209
     set {floorItems(209)} $i
     $w create text 138.5 362.5 -text 209 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 89 228 89 156 53 156 53 228 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 89 228 89 156 53 156 53 228 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 217
     set {floorItems(217)} $i
     $w create text 71 192 -text 217 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 89 169 97 169 97 190 89 190 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 89 169 97 169 97 190 89 190 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 217A
     set {floorItems(217A)} $i
     $w create text 93 179.5 -text 217A -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 89 156 89 168 95 168 95 135 53 135 53 156 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 89 156 89 168 95 168 95 135 53 135 53 156 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 216
     set {floorItems(216)} $i
     $w create text 71 145.5 -text 216 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 51 179 51 135 6 135 6 179 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 51 179 51 135 6 135 6 179 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 215
     set {floorItems(215)} $i
     $w create text 28.5 157 -text 215 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 51 227 6 227 6 180 51 180 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 51 227 6 227 6 180 51 180 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 214
     set {floorItems(214)} $i
     $w create text 28.5 203.5 -text 214 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 51 275 6 275 6 229 51 229 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 51 275 6 275 6 229 51 229 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 213
     set {floorItems(213)} $i
     $w create text 28.5 252 -text 213 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 114 340 67 340 67 385 114 385 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 114 340 67 340 67 385 114 385 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 210
     set {floorItems(210)} $i
     $w create text 90.5 362.5 -text 210 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 59 389 59 385 65 385 65 340 1 340 1 389 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 59 389 59 385 65 385 65 340 1 340 1 389 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 211
     set {floorItems(211)} $i
     $w create text 33 364.5 -text 211 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 393 309 350 309 350 282 342 282 342 276 393 276 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 393 309 350 309 350 282 342 282 342 276 393 276 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 203
     set {floorItems(203)} $i
     $w create text 367.5 292.5 -text 203 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 99 191 91 191 91 226 174 226 174 198 154 198 154 192 109 192 109 169 99 169 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 99 191 91 191 91 226 174 226 174 198 154 198 154 192 109 192 109 169 99 169 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 220
     set {floorItems(220)} $i
     $w create text 132.5 208.5 -text 220 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 339 205 307 205 307 171 339 171 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) {Priv Lift2}
     set {floorItems(Priv Lift2)} $i
     $w create text 323 188 -text {Priv Lift2} -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 307 240 339 240 339 206 307 206 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) {Pub Lift 2}
     set {floorItems(Pub Lift 2)} $i
     $w create text 323 223 -text {Pub Lift 2} -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 175 168 97 168 97 131 175 131 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 175 168 97 168 97 131 175 131 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 218
     set {floorItems(218)} $i
     $w create text 136 149.5 -text 218 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 154 191 111 191 111 169 154 169 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 154 191 111 191 111 169 154 169 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 219
     set {floorItems(219)} $i
     $w create text 132.5 180 -text 219 -fill $color -anchor c -tags {floor2 label}
-    set i [$w create polygon 375 246 375 172 341 172 341 246 -outline {} -tags {floor2 room}]
+    set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor2 room}]
     set floorLabels($i) 201
     set {floorItems(201)} $i
     $w create text 358 209 -text 201 -fill $color -anchor c -tags {floor2 label}
     $w create line 641 186 678 186 -fill $color -tags {floor2 wall}
     $w create line 757 350 757 367 -fill $color -tags {floor2 wall}
@@ -1064,139 +1064,139 @@
 # w -		The canvas window.
 # color -	Color to use for drawing foreground information.
 
 proc fg3 {w color} {
     global floorLabels floorItems
-    set i [$w create polygon 89 228 89 180 70 180 70 228 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 89 228 89 180 70 180 70 228 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 316
     set {floorItems(316)} $i
     $w create text 79.5 204 -text 316 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 115 368 162 368 162 323 115 323 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 115 368 162 368 162 323 115 323 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 309
     set {floorItems(309)} $i
     $w create text 138.5 345.5 -text 309 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 164 323 164 368 211 368 211 323 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 164 323 164 368 211 368 211 323 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 308
     set {floorItems(308)} $i
     $w create text 187.5 345.5 -text 308 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 256 368 212 368 212 323 256 323 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 256 368 212 368 212 323 256 323 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 307
     set {floorItems(307)} $i
     $w create text 234 345.5 -text 307 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 244 276 297 276 297 327 260 327 260 321 244 321 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 244 276 297 276 297 327 260 327 260 321 244 321 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 305
     set {floorItems(305)} $i
     $w create text 270.5 301.5 -text 305 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 251 219 251 203 244 203 244 219 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 251 219 251 203 244 203 244 219 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 324B
     set {floorItems(324B)} $i
     $w create text 247.5 211 -text 324B -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 251 249 244 249 244 232 251 232 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 251 249 244 249 244 232 251 232 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 324A
     set {floorItems(324A)} $i
     $w create text 247.5 240.5 -text 324A -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 223 135 223 179 177 179 177 135 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 223 135 223 179 177 179 177 135 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 320
     set {floorItems(320)} $i
     $w create text 200 157 -text 320 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 114 368 114 323 67 323 67 368 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 114 368 114 323 67 323 67 368 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 310
     set {floorItems(310)} $i
     $w create text 90.5 345.5 -text 310 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 23 277 23 321 68 321 68 277 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 23 277 23 321 68 321 68 277 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 312
     set {floorItems(312)} $i
     $w create text 45.5 299 -text 312 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 23 229 68 229 68 275 23 275 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 23 229 68 229 68 275 23 275 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 313
     set {floorItems(313)} $i
     $w create text 45.5 252 -text 313 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 68 227 23 227 23 180 68 180 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 68 227 23 227 23 180 68 180 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 314
     set {floorItems(314)} $i
     $w create text 45.5 203.5 -text 314 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 95 179 95 135 23 135 23 179 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 95 179 95 135 23 135 23 179 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 315
     set {floorItems(315)} $i
     $w create text 59 157 -text 315 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 99 226 99 204 91 204 91 226 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 99 226 99 204 91 204 91 226 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 316B
     set {floorItems(316B)} $i
     $w create text 95 215 -text 316B -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 91 202 99 202 99 180 91 180 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 91 202 99 202 99 180 91 180 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 316A
     set {floorItems(316A)} $i
     $w create text 95 191 -text 316A -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 97 169 109 169 109 192 154 192 154 198 174 198 174 226 101 226 101 179 97 179 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 97 169 109 169 109 192 154 192 154 198 174 198 174 226 101 226 101 179 97 179 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 319
     set {floorItems(319)} $i
     $w create text 141.5 209 -text 319 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 65 368 58 368 58 389 1 389 1 333 23 333 23 323 65 323 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 65 368 58 368 58 389 1 389 1 333 23 333 23 323 65 323 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 311
     set {floorItems(311)} $i
     $w create text 29.5 361 -text 311 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 154 191 111 191 111 169 154 169 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 154 191 111 191 111 169 154 169 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 318
     set {floorItems(318)} $i
     $w create text 132.5 180 -text 318 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 175 168 97 168 97 131 175 131 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 175 168 97 168 97 131 175 131 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 317
     set {floorItems(317)} $i
     $w create text 136 149.5 -text 317 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 274 194 274 221 306 221 306 194 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 274 194 274 221 306 221 306 194 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 323
     set {floorItems(323)} $i
     $w create text 290 207.5 -text 323 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 306 222 274 222 274 249 306 249 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 306 222 274 222 274 249 306 249 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 325
     set {floorItems(325)} $i
     $w create text 290 235.5 -text 325 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 263 179 224 179 224 135 263 135 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 263 179 224 179 224 135 263 135 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 321
     set {floorItems(321)} $i
     $w create text 243.5 157 -text 321 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 314 169 306 169 306 192 273 192 264 181 264 135 314 135 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 314 169 306 169 306 192 273 192 264 181 264 135 314 135 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 322
     set {floorItems(322)} $i
     $w create text 293.5 163.5 -text 322 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 307 240 339 240 339 206 307 206 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) {Pub Lift3}
     set {floorItems(Pub Lift3)} $i
     $w create text 323 223 -text {Pub Lift3} -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 339 205 307 205 307 171 339 171 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) {Priv Lift3}
     set {floorItems(Priv Lift3)} $i
     $w create text 323 188 -text {Priv Lift3} -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 350 284 376 284 376 276 397 276 397 309 350 309 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 350 284 376 284 376 276 397 276 397 309 350 309 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 303
     set {floorItems(303)} $i
     $w create text 373.5 292.5 -text 303 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 272 203 272 249 252 249 252 230 244 230 244 221 252 221 252 203 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 272 203 272 249 252 249 252 230 244 230 244 221 252 221 252 203 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 324
     set {floorItems(324)} $i
     $w create text 262 226 -text 324 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 299 276 299 327 349 327 349 284 341 284 341 276 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 299 276 299 327 349 327 349 284 341 284 341 276 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 304
     set {floorItems(304)} $i
     $w create text 324 301.5 -text 304 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 375 246 375 172 341 172 341 246 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 301
     set {floorItems(301)} $i
     $w create text 358 209 -text 301 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 397 246 377 246 377 185 397 185 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 397 246 377 246 377 185 397 185 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 327
     set {floorItems(327)} $i
     $w create text 387 215.5 -text 327 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 316 131 316 169 377 169 377 185 397 185 397 131 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 316 131 316 169 377 169 377 185 397 185 397 131 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 326
     set {floorItems(326)} $i
     $w create text 356.5 150 -text 326 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 308 251 242 251 242 274 342 274 342 282 375 282 375 274 397 274 397 248 339 248 339 242 308 242 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 308 251 242 251 242 274 342 274 342 282 375 282 375 274 397 274 397 248 339 248 339 242 308 242 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 302
     set {floorItems(302)} $i
     $w create text 319.5 261 -text 302 -fill $color -anchor c -tags {floor3 label}
-    set i [$w create polygon 70 321 242 321 242 200 259 200 259 203 272 203 272 193 263 180 242 180 175 180 175 169 156 169 156 196 177 196 177 228 107 228 70 228 70 275 107 275 107 248 160 248 160 301 107 301 107 275 70 275 -outline {} -tags {floor3 room}]
+    set i [$w create polygon 70 321 242 321 242 200 259 200 259 203 272 203 272 193 263 180 242 180 175 180 175 169 156 169 156 196 177 196 177 228 107 228 70 228 70 275 107 275 107 248 160 248 160 301 107 301 107 275 70 275 -fill {} -outline {} -tags {floor3 room}]
     set floorLabels($i) 306
     set {floorItems(306)} $i
     $w create text 200.5 284.5 -text 306 -fill $color -anchor c -tags {floor3 label}
     $w create line 341 275 341 283 -fill $color -tags {floor3 wall}
     $w create line 162 197 155 197 -fill $color -tags {floor3 wall}

Index: library/demos/goldberg.tcl
==================================================================
--- library/demos/goldberg.tcl
+++ library/demos/goldberg.tcl
@@ -75,11 +75,10 @@
 set MSTART 0; set MGO 1; set MPAUSE 2; set MSSTEP 3; set MBSTEP 4; set MDONE 5
 set S(mode) $::MSTART
 
 # Colors for everything
 set C(fg) black
-set C(bg) gray75
 set C(bg) cornflowerblue
 
 set C(0) white;		set C(1a) darkgreen;	set C(1b) yellow
 set C(2) red;		set C(3a) green;	set C(3b) darkblue
 set C(4) $C(fg);	set C(5a) brown;	set C(5b) white
@@ -90,10 +89,11 @@
 set C(15a) green;	set C(15b) yellow;	set C(16) gray65
 set C(17) \#A65353;	set C(18) $C(fg);	set C(19) gray50
 set C(20) cyan;		set C(21) gray65;	set C(22) $C(20)
 set C(23a) blue;	set C(23b) red;		set C(23c) yellow
 set C(24a) red;		set C(24b) white;
+set C(24c) black;	set C(26) $C(0);
 
 proc DoDisplay {w} {
     global S C
 
     ttk::frame $w.ctrl -relief ridge -borderwidth 2 -padding 5
@@ -1584,10 +1584,11 @@
 	}
 	$w.c create poly $xy -tag I24 -fill $::C(24b) -outline $::C(24a) \
 		-width 10 -smooth 1
 	set msg [subst $S(message)]
 	$w.c create text [Centroid $w I24] -text $msg -tag {I24 I24t} \
+		-fill $::C(24c) \
 		-justify center -font {{Times Roman} 18 bold}
 	return 1
     }
 
     $w.c itemconfig I24t -font [list {Times Roman} [expr {18 + 6*$step}] bold]
@@ -1617,10 +1618,11 @@
     set step [GetStep 26 $step]
 
     if {$step >= 3} {
 	$w.c delete I24 I26
 	$w.c create text 430 755 -anchor s -tag I26 \
+		-fill $::C(26) \
 		-text "click to continue" -font {{Times Roman} 24 bold}
 	bind $w.c <Button-1> [list Reset $w]
 	return 4
     }
 

Index: library/demos/image2.tcl
==================================================================
--- library/demos/image2.tcl
+++ library/demos/image2.tcl
@@ -92,11 +92,11 @@
 labelframe $w.f -text "File:" -padx 2m -pady 2m
 
 listbox $w.f.list -width 20 -height 10 -yscrollcommand "$w.f.scroll set"
 ttk::scrollbar $w.f.scroll -command "$w.f.list yview"
 pack $w.f.list $w.f.scroll -side left -fill y -expand 1
-$w.f.list insert 0 earth.gif earthris.gif teapot.ppm
+$w.f.list insert 0 earth.gif earthris.gif teapot.ppm Tcl.svg
 bind $w.f.list <Double-Button-1> "loadImage $w %x %y"
 
 catch {image delete image2a}
 image create photo image2a
 labelframe $w.image -text "Image:"

ADDED   library/demos/images/Tcl.svg
Index: library/demos/images/Tcl.svg
==================================================================
--- /dev/null
+++ library/demos/images/Tcl.svg
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://web.resource.org/cc/"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="124.98526"
+   height="264.6875"
+   id="svg2309"
+   sodipodi:version="0.32"
+   inkscape:version="0.45"
+   sodipodi:modified="true"
+   version="1.0">
+  <defs
+     id="defs2311" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     gridtolerance="10000"
+     guidetolerance="10"
+     objecttolerance="10"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="0.35"
+     inkscape:cx="375"
+     inkscape:cy="520"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     inkscape:window-width="910"
+     inkscape:window-height="626"
+     inkscape:window-x="5"
+     inkscape:window-y="49" />
+  <metadata
+     id="metadata2314">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(-311.79308,-365.73272)">
+    <g
+       style="opacity:1;display:inline"
+       id="g2244"
+       transform="translate(308.95998,366.42022)">
+      <path
+         id="path4426"
+         d="M 445.52492,372.22514 C 445.90652,395.55723 445.21415,418.63757 425.02492,440.56889 L 424.27492,441.41264 L 425.39992,441.41264 L 433.64992,441.53764 C 420.24442,469.42405 411.52244,497.23134 392.24367,525.00639 L 391.55617,526.00639 L 392.74367,525.78764 L 402.93117,523.85014 C 395.71427,542.16045 383.37359,554.28293 369.99367,558.35014 C 366.31107,506.78151 392.04593,461.26308 413.89992,415.88139 C 413.92002,415.83965 413.94233,415.79813 413.96242,415.75639 L 413.14992,415.19389 C 377.36425,455.2074 361.23872,511.6427 355.14992,558.19389 C 343.02146,551.34666 338.97913,542.28079 334.86867,529.94389 L 343.33742,533.50639 L 344.21242,533.88139 L 344.02492,532.94389 C 337.58858,504.32416 347.5814,483.78143 357.27492,456.78764 L 364.24367,461.44389 L 365.05617,462.00639 L 365.02492,461.03764 C 364.47892,439.10645 379.24595,417.08983 398.83742,397.44389 L 401.55617,404.72514 L 401.93117,405.69389 L 402.46242,404.78764 L 408.43117,394.85014 L 408.46242,394.78764 C 418.31429,381.21812 428.72988,376.80082 445.52492,372.22514 z "
+         style="fill:#c3b15f;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;display:inline"
+         transform="translate(-324.02492,-364.63139)" />
+      <path
+         sodipodi:nodetypes="ccccccccccccccccccccccc"
+         id="path7600"
+         d="M 121.54988,7.5808058 C 104.81215,12.147023 94.270242,16.613077 84.4375,30.15625 L 84.40625,30.21875 L 78.4375,40.15625 L 77.90625,41.0625 L 77.53125,40.09375 L 74.8125,32.8125 C 55.22103,52.45844 40.454,74.47506 41,96.40625 L 41.03125,97.375 L 40.21875,96.8125 L 33.25,92.15625 C 23.55648,119.15004 13.56366,139.69277 20,168.3125 L 20.1875,169.25 L 19.3125,168.875 L 10.9375,165.34375 C 10.96447,165.51523 11.003113,165.67421 11.03125,165.84375 C 15.080346,177.9015 19.176955,186.81713 31.125,193.5625 C 31.596616,189.95681 32.122231,186.27456 32.71875,182.5625 C 18.12816,148.39836 30.79293,123.2814 36.5625,100.6875 L 45.4375,105.8125 C 44.211577,84.657017 56.63174,61.842112 72.78125,41.9375 L 77.46875,50.1875 C 89.477498,25.486664 98.97512,15.57175 121.54988,7.5808058 z "
+         style="opacity:1;fill:#eff1cb;fill-opacity:1;fill-rule:evenodd;stroke:#eff1cb;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;display:inline" />
+      <path
+         style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;display:inline"
+         d="M 126.9375,-0.6875 L 126.40625,-0.59375 C 106.72165,2.83976 87.4508,10.07244 79,27.375 L 75.4375,21.15625 L 75.125,20.59375 L 74.65625,21.0625 C 64.96254,30.33838 54.55574,42.35306 46.875,54.15625 C 39.66528,65.23562 34.88327,76.07934 35.40625,84.375 L 30.375,78.09375 L 29.875,77.46875 L 29.53125,78.1875 C 23.40732,91.41649 17.22694,107.69157 13.53125,122.625 C 10.02725,136.78385 8.77244,149.67206 12.03125,157.78125 L 3.75,152.96875 L 3.0625,152.5625 L 3,153.375 C 1.44089,176.99202 11.0382,188.26833 22.0625,199.15625 L 12.875,201.4375 L 11.03125,201.90625 L 12.875,202.40625 C 18.14953,203.83558 23.15023,205.44485 26.625,208.125 C 30.09977,210.80515 32.09598,214.49082 31.5,220.375 L 31.5,220.40625 L 31.5,245.90625 L 31.5,246.0625 L 31.59375,246.1875 L 43.09375,262.6875 L 44,264 L 44,262.40625 L 44,223.53125 C 45.52181,216.98735 47.30807,212.4833 49.875,209.5 C 52.44193,206.5167 55.78211,204.98483 60.5625,204.40625 L 62.28125,204.1875 L 60.71875,203.46875 L 54.65625,200.59375 C 69.11174,191.89001 85.3013,170.55445 89.5625,150.28125 L 89.75,149.46875 L 88.96875,149.6875 L 81.46875,151.71875 C 88.13174,145.46249 94.84392,133.06721 101.21875,118.625 C 107.9798,103.3078 114.29247,85.96032 119.46875,72.09375 L 119.75,71.34375 L 118.96875,71.40625 L 113.1875,71.8125 C 120.3346,64.22669 124.30703,51.6996 126.25,38.46875 C 128.27227,24.69793 128.13035,10.1977 127,-0.15625 L 126.9375,-0.6875 z M 121.5,7.59375 C 121.8816,30.92584 121.18923,54.00618 101,75.9375 L 100.25,76.78125 L 101.375,76.78125 L 109.625,76.90625 C 96.2195,104.79266 87.49752,132.59995 68.21875,160.375 L 67.53125,161.375 L 68.71875,161.15625 L 78.90625,159.21875 C 71.68935,177.52906 59.34867,189.65154 45.96875,193.71875 C 42.28615,142.15012 68.02101,96.63169 89.875,51.25 C 89.8951,51.20826 89.91741,51.16674 89.9375,51.125 L 89.125,50.5625 C 53.33933,90.57601 37.2138,147.01131 31.125,193.5625 C 18.99654,186.71527 14.95421,177.6494 10.84375,165.3125 L 19.3125,168.875 L 20.1875,169.25 L 20,168.3125 C 13.56366,139.69277 23.55648,119.15004 33.25,92.15625 L 40.21875,96.8125 L 41.03125,97.375 L 41,96.40625 C 40.454,74.47506 55.22103,52.45844 74.8125,32.8125 L 77.53125,40.09375 L 77.90625,41.0625 L 78.4375,40.15625 L 84.40625,30.21875 L 84.4375,30.15625 C 94.28937,16.58673 104.70496,12.16943 121.5,7.59375 z "
+         id="path2177" />
+    </g>
+  </g>
+</svg>

ADDED   library/demos/images/Tk_feather.png
Index: library/demos/images/Tk_feather.png
==================================================================
--- /dev/null
+++ library/demos/images/Tk_feather.png
cannot compute difference between binary files

Index: library/demos/images/earth.gif
==================================================================
--- library/demos/images/earth.gif
+++ library/demos/images/earth.gif
cannot compute difference between binary files

ADDED   library/demos/images/plowed_field.png
Index: library/demos/images/plowed_field.png
==================================================================
--- /dev/null
+++ library/demos/images/plowed_field.png
cannot compute difference between binary files

ADDED   library/demos/images/starry_night.png
Index: library/demos/images/starry_night.png
==================================================================
--- /dev/null
+++ library/demos/images/starry_night.png
cannot compute difference between binary files

ADDED   library/demos/mac_styles.tcl
Index: library/demos/mac_styles.tcl
==================================================================
--- /dev/null
+++ library/demos/mac_styles.tcl
@@ -0,0 +1,268 @@
+# mac_styles.tcl --
+#
+# This demonstration script creates a toplevel window containing a notebook
+# whose pages provide examples of the various mac-specific widgets that are
+# provided via special values for the -style option.
+
+if {![info exists widgetDemo]} {
+    error "This script should be run from the \"widget\" demo."
+}
+
+package require Tk
+
+set w .mac_styles
+catch {destroy $w}
+toplevel $w
+package require Tk
+wm title $w "Tk Aqua Widgets"
+wm iconname $w "mac_styles"
+positionWindow $w
+##
+# System images we use in our buttons
+
+set featherImg [file join $tk_demoDirectory images Tk_feather.png]
+set starryImg [file join $tk_demoDirectory images starry_night.png]
+set fieldImg [file join $tk_demoDirectory images plowed_field.png]
+image create nsimage action -source NSAction -width 48 -height 48
+image create nsimage bonjour -source NSBonjour -width 48 -height 48
+image create nsimage bonjour1 -source NSBonjour -width 48 -height 48 -pressed 1
+image create nsimage tkfeather -source $featherImg -as file -width 48 -height 48
+image create nsimage tkfeather1 -source $featherImg -as file -width 48 -height 48 -pressed 1
+image create nsimage starry -source $starryImg -as file -width 96 -radius 10
+image create nsimage starry1 -source $starryImg -as file -width 96 -radius 10 -pressed 1
+image create nsimage starry2 -source $starryImg -as file -width 96 -radius 10 -ring 3
+image create nsimage field -source $fieldImg -as file -width 96 -radius 10
+image create nsimage field1 -source $fieldImg -as file -width 96 -radius 10 -pressed 1
+image create nsimage field2 -source $fieldImg -as file -width 96 -radius 10 -ring 3
+image create nsimage add -source NSAddTemplate -width 11 -height 11
+image create nsimage remove -source NSRemoveTemplate -width 11 -height 11
+
+# Off state and variables for checkbuttons and radio buttons
+set off {!selected !alternate}
+variable $w.checkVar
+variable $w.radioVar
+variable $w.triangleVar
+variable $w.popupVar
+variable $w.stepVar
+variable $w.comboVar
+
+# Make a disclosure triangle change state when clicked.
+proc toggleTriangle {tri} {
+    $tri instate {user1} {
+	$tri state {!user1}
+	return
+    }
+    $tri instate {!user1} {
+	$tri state {user1}
+    }
+}
+
+proc popupButton {win varName firstValue args} {
+    upvar #0 $varName var
+    if {![info exists var]} {
+	set var $firstValue
+    }
+    ttk::menubutton $win -textvariable $varName -menu $win.menu -direction flush
+    menu $win.menu -tearoff 0
+    $win.menu add radiobutton -label $firstValue -variable $varName
+    foreach i $args {
+	$win.menu add radiobutton -label $i -variable $varName
+    }
+    return $win.menu
+}
+
+set mag [encoding convertfrom utf-8 "\xf0\x9f\x94\x8d"]
+
+proc searchFocusOut {e} {
+    global mag
+    if {[$e get] eq ""} {
+	$e configure -foreground gray60
+	$e insert 0 "Search"
+    }
+}
+
+proc searchFocusIn {e} {
+    if {[$e cget -foreground] == {gray60}} {
+	$e delete 0 end
+	$e configure -foreground black
+    }
+}
+
+## Make the notebook and set up Ctrl+Tab traversal
+ttk::notebook $w.notebook
+ttk::notebook::enableTraversal $w.notebook
+
+# Frames pane
+set framesFrame [ttk::frame $w.notebook.frames -padding {40 35 40 50}]
+$w.notebook add $framesFrame -text "Frames"
+pack [ttk::labelframe $framesFrame.darker -text Darker -padding {50 30 50 50}] \
+    -fill both -expand 1
+pack [ttk::label $framesFrame.darker.label -padding {0 0 0 6} \
+	  -text "This Group Box is nested to depth 2"] \
+    -fill x
+pack [ttk::labelframe $framesFrame.darker.darker -text "Darker Still" -padding 24] \
+    -fill both -expand 1
+pack [ttk::label $framesFrame.darker.darker.label \
+	  -text "This Group Box is nested to depth 3"] -fill x
+pack [button $framesFrame.darker.darker.tkbutton -text "Tk Button" -width 7 \
+	  -highlightbackground systemWindowBackgroundColor3] -pady 10
+pack [ttk::button $framesFrame.darker.darker.ttkbutton -text "Ttk Button" \
+	  -width 7 -padding {-4 0 -4 0}] \
+	  -pady 3
+# Button pane
+set buttonFrame [ttk::frame $w.notebook.buttons -padding {100 20 0 20}]
+$w.notebook add $buttonFrame -text "Buttons"
+grid columnconfigure $buttonFrame 0 -minsize 100
+grid columnconfigure $buttonFrame 1 -minsize 100
+
+set plain [ttk::button $buttonFrame.plain -text Button -padding {-12 0}]
+popupButton $buttonFrame.options .popupVar "Item 1" "Item 2" "Item 3"
+set options $buttonFrame.options
+set check [ttk::checkbutton $buttonFrame.check -text Check -variable .checkVar]
+set radio [ttk::frame $buttonFrame.radio]
+pack [ttk::radiobutton $radio.r1 -text "Radio 1" -variable .radioVar -value 1] -pady 4
+pack [ttk::radiobutton $radio.r2 -text "Radio 2" -variable .radioVar -value 2] -pady 4
+set triangle [ttk::checkbutton $buttonFrame.triangle -style Item -variable TriangleVar]
+bind $triangle <Button-1> {toggleTriangle %W}
+set bonjour [ttk::button $buttonFrame.bonjour -style ImageButton -text Bonjour \
+ 		     -image {bonjour pressed bonjour1}]
+set feather [ttk::button $buttonFrame.feather -style ImageButton -text Tk \
+		      -image {tkfeather pressed tkfeather1}]
+set gradient [ttk::frame $buttonFrame.gradient]
+pack [ttk::button $buttonFrame.gradient.add -style GradientButton \
+		  -image add -padding 7] -side left
+pack [ttk::button $buttonFrame.gradient.remove -style GradientButton \
+		-image remove -padding 7] -side left
+set disclosure [ttk::checkbutton $buttonFrame.disclosure -style DisclosureButton]
+set help [ttk::button $buttonFrame.help -style HelpButton];
+
+$check state $off
+$radio.r1 state $off
+$radio.r2 state $off
+
+grid [ttk::label $buttonFrame.plainLabel -text "Push Button:"]\
+    -row 0 -column 0 -padx 4 -sticky e
+grid $plain -pady 4 -row 0 -column 1 -sticky w
+grid [ttk::label $buttonFrame.optionsLabel -text "Pop-up Button:"]\
+    -row 1 -column 0 -padx 4 -sticky e
+grid $options  -pady 4 -row 1 -column 1 -sticky w
+grid [ttk::label $buttonFrame.checkLabel -text "Check Button:"]\
+    -row 2 -column 0 -padx 4 -sticky e
+grid $check    -pady 4 -row 2 -column 1 -sticky w
+grid [ttk::label $buttonFrame.radioLabel -text "Radio Buttons:"]\
+    -row 3 -column 0 -padx 4 -sticky e
+grid $radio    -pady 4 -row 3 -column 1 -sticky w
+grid [ttk::label $buttonFrame.triangleLabel -text "Disclosure Triangle:"]\
+    -row 4 -column 0 -padx 4 -sticky e
+grid $triangle -pady 4 -row 4 -column 1 -sticky w
+grid [ttk::label $buttonFrame.disclosureLabel -text "Disclosure Button:"]\
+    -row 5 -column 0 -padx 4 -sticky e
+grid $disclosure -row 5 -column 1 -sticky w
+grid [ttk::label $buttonFrame.imageLabel -text "Image Buttons:"]\
+    -row 7 -column 0 -padx 4 -sticky e
+grid $bonjour -pady 4 -row 6 -rowspan 4 -column 1 -sticky w
+grid $feather -padx 10 -pady 4 -row 6 -rowspan 4 -column 2
+grid [ttk::label $buttonFrame.gradentLabel -text "Gradient Buttons:"]\
+-row 10 -column 0 -padx 4 -sticky e
+grid $gradient -pady 4 -row 10 -column 1 -sticky w
+grid [ttk::label $buttonFrame.helpLabel -text "Help Button:"]\
+-row 11 -column 0 -padx 4 -sticky e
+grid $help -row 11 -column 1 -sticky w
+
+#ttk::button .f.b1 -style Toolbutton -image action
+#pack $buttonFrame
+
+# Entries Frame
+set entryFrame [ttk::frame $w.notebook.entries -padding {0 30 80 0}]
+grid columnconfigure $entryFrame 0 -minsize 200
+$w.notebook add $entryFrame -text "Entries"
+
+set textfield [ttk::entry $entryFrame.text -width 17]
+set searchfield [ttk::entry $entryFrame.search -width 1]
+set combo [ttk::combobox $entryFrame.combo -width 1 -textvariable comboVar \
+	   -values {"Item 1" "Item 2" "Item 3"}]
+set stepper [ttk::spinbox $entryFrame.stepper -width 1 -textvariable stepVar \
+		 -from 99000 -to 101000 -increment 1]
+set stepVar 100000
+searchFocusOut $searchfield
+bind $searchfield <FocusIn> {searchFocusIn %W}
+bind $searchfield <FocusOut> {searchFocusOut %W}
+
+grid [ttk::label $entryFrame.l0 -text "Text Field"] -row 0 -column 0 -padx 20 -sticky e
+grid $textfield -sticky ew -row 0 -column 1 -pady 13
+grid [ttk::label $entryFrame.l1 -text "Search Field"] -row 1 -column 0 -padx 20 -sticky e
+grid $searchfield -sticky ew -row 1 -column 1 -pady 13
+grid [ttk::label $entryFrame.l2 -text "Combo Box"] -row 2 -column 0 -padx 20 -sticky e
+grid $combo -sticky ew -row 2 -column 1 -pady 13
+grid [ttk::label $entryFrame.l3 -text "Stepper"] -row 3 -column 0 -padx 20 -sticky e
+grid $stepper -sticky ew -row 3 -column 1 -pady 13
+
+#Scales Frame
+set scaleFrame [ttk::frame $w.notebook.scales -padding {0 40 0 80}]
+$w.notebook add $scaleFrame -text "Scales"
+
+variable topVar 50
+set topSlider [ttk::scale $scaleFrame.topSlider -from 0 -to 100 \
+		   -length 280 -variable topVar]
+set topProgress [ttk::progressbar $scaleFrame.topProgress \
+		     -maximum 100 -variable topVar]
+
+variable bottomVar 50
+set bottomSlider [ttk::scale $scaleFrame.bottomSlider -from 0 -to 100 \
+		      -length 280 -variable bottomVar]
+$bottomSlider state alternate
+set bottomProgress [ttk::progressbar $scaleFrame.bottomProgress \
+		    -maximum 100 -variable bottomVar]
+
+
+grid $topSlider -padx 80 -pady 12 -sticky ew -row 0 -column 0 -columnspan 2
+grid $topProgress -padx 120 -pady 15 -sticky ew -row 1 -column 0 -columnspan 2
+grid [ttk::frame $scaleFrame.spacer] -row 2 -column 0 -columnspan 2 -pady 32
+
+grid $bottomSlider -padx 80 -sticky new -row 3 -column 0 -columnspan 2
+grid [ttk::label $scaleFrame.low -text Low -padding {70 0 0 0}] \
+    -row 4 -column 0 -sticky sw
+grid [ttk::label $scaleFrame.high -text High -padding {0 0 70 0}] \
+    -row 4 -column 1 -sticky se
+grid $bottomProgress -padx 120 -pady 15 -sticky ew -row 5 -column 0 -columnspan 2
+
+#Appearance Frame
+set appearanceFrame [ttk::frame $w.notebook.appearance -padding {0 40 0 80}]
+grid [ttk::label $w.notebook.appearance.info -justify left -padding {0 20 0 40}\
+	  -text "Use the image buttons below to view this demo in light or dark mode."] \
+    -row 0 -column 0 -columnspan 3
+set light [ttk::button $appearanceFrame.light -style ImageButton -text Light \
+	       -image {field pressed field1 selected field2} \
+	       -command "beLight $appearanceFrame $w"]
+grid columnconfigure $appearanceFrame 1 -minsize 10
+grid $light -row 1 -column 0 -sticky e
+set dark [ttk::button $appearanceFrame.dark -style ImageButton -text Dark \
+	      -image {starry pressed starry1 selected starry2} \
+	      -command "beDark $appearanceFrame $w"]
+grid $dark -row 1 -column 2 -sticky w
+if { [::tk::unsupported::MacWindowStyle isdark $w] } {
+    $dark state selected
+} else {
+    $light state selected
+}
+proc beLight {f w} {
+    ::tk::unsupported::MacWindowStyle appearance $w aqua
+    $f.dark state !selected
+    $f.light state selected
+    after 10 $f.light state !hover
+}
+
+proc beDark {f w} {
+    ::tk::unsupported::MacWindowStyle appearance $w darkaqua
+    $f.light state !selected
+    $f.dark state selected
+    after 10 $f.dark state !hover
+}
+$w.notebook add $appearanceFrame -text "Appearance"
+
+## See Code / Dismiss
+pack [addSeeDismiss $w.buttons $w] -side bottom -fill x
+
+## Notebook
+pack $w.notebook -side bottom -fill both -expand 1 -padx 16 -pady 16
+

Index: library/demos/mclist.tcl
==================================================================
--- library/demos/mclist.tcl
+++ library/demos/mclist.tcl
@@ -19,11 +19,14 @@
 ## Explanatory text
 ttk::label $w.msg -font $font -wraplength 4i -justify left -anchor n -padding {10 2 10 6} -text "Ttk is the new Tk themed widget set. One of the widgets it includes is a tree widget, which can be configured to display multiple columns of informational data without displaying the tree itself. This is a simple way to build a listbox that has multiple columns. Clicking on the heading for a column will sort the data by that column. You can also change the width of the columns by dragging the boundary between them."
 pack $w.msg -fill x
 
 ## See Code / Dismiss
-pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x
+pack [addSeeDismiss $w.seeDismiss $w {} {
+    ttk::checkbutton $w.seeDismiss.cb1 -text Grid -variable mclistGrid -command tglGrid
+}] -side bottom -fill x
+
 
 ttk::frame $w.container
 ttk::treeview $w.tree -columns {country capital currency} -show headings \
     -yscroll "$w.vsb set" -xscroll "$w.hsb set"
 ttk::scrollbar $w.vsb -orient vertical -command "$w.tree yview"
@@ -115,5 +118,20 @@
 	$tree heading $col state "user1"
     } else {
 	$tree heading $col -image [expr {$direction?"upArrow":"downArrow"}]
     }
 }
+
+set mclistGrid 0
+proc tglGrid {} {
+    if {$::mclistGrid} {
+        .mclist.tree configure -stripe 1
+        foreach col [.mclist.tree cget -columns] {
+            .mclist.tree column $col -separator 1
+        }
+    } else {
+        .mclist.tree configure -stripe 0
+        foreach col [.mclist.tree cget -columns] {
+            .mclist.tree column $col -separator 0
+        }
+    }
+}

Index: library/demos/menu.tcl
==================================================================
--- library/demos/menu.tcl
+++ library/demos/menu.tcl
@@ -16,11 +16,10 @@
 wm iconname $w "menu"
 positionWindow $w
 
 label $w.msg -font $font -wraplength 4i -justify left
 if {[tk windowingsystem] eq "aqua"} {
-    catch {set origUseCustomMDEF $::tk::mac::useCustomMDEF; set ::tk::mac::useCustomMDEF 1}
     $w.msg configure -text "This window has a menubar with cascaded menus.  You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by selecting the first item in the menu."
 } else {
     $w.msg configure -text "This window contains a menubar with cascaded menus.  You can post a menu from the keyboard by typing Alt+x, where \"x\" is the character underlined on the menu.  You can then traverse among the menus using the arrow keys.  When a menu is posted, you can invoke the current entry by typing space, or you can invoke any entry by typing its underlined character.  If a menu entry has an accelerator, you can invoke the entry without posting the menu just by typing the accelerator. The rightmost menu can be torn off into a palette by selecting the first item in the menu."
 }
 pack $w.msg -side top
@@ -61,11 +60,11 @@
 } else {
     set modifier Meta
 }
 foreach i {A B C D E F} {
     $m add command -label "Print letter \"$i\"" -underline 14 \
-	    -accelerator Meta+$i -command "puts $i" -accelerator $modifier+$i
+	    -accelerator $modifier+$i -command "puts $i"
     bind $w <$modifier-[string tolower $i]> "puts $i"
 }
 
 set m $w.menu.cascade
 $w.menu add cascade -label "Cascades" -menu $m -underline 0
@@ -132,10 +131,12 @@
 $w.menu add cascade -label "More" -menu $m -underline 0
 menu $m -tearoff 0
 foreach i {{An entry} {Another entry} {Does nothing} {Does almost nothing} {Does almost nothing also} {Make life meaningful}} {
     $m add command -label $i -command [list puts "You invoked \"$i\""]
 }
+set emojiLabel [encoding convertfrom utf-8 "\xF0\x9F\x98\x8D Make friends"]
+$m add command -label $emojiLabel -command [list puts "Menu labels can include non-BMP characters."]
 $m entryconfigure "Does almost nothing" -bitmap questhead -compound left \
 	-command [list \
 	tk_dialog $w.compound {Compound Menu Entry} \
 		"The menu entry you invoked displays both a bitmap and a\
 		text string.  Other than this, it is just like any other\
@@ -149,13 +150,28 @@
 		menu entry." {} 0 OK ]
 
 set m $w.menu.colors
 $w.menu add cascade -label "Colors" -menu $m -underline 1
 menu $m -tearoff 1
-foreach i {red orange yellow green blue} {
-    $m add command -label $i -background $i -command [list \
-	    puts "You invoked \"$i\"" ]
+if {[tk windowingsystem] eq "aqua"} {
+    # Aqua ignores the -background and -foreground options, but a compound
+    # button can be used for selecting colors.
+    foreach i {red orange yellow green blue} {
+	image create photo image_$i -height 16 -width 16
+	image_$i put black -to 0 0 16 1
+	image_$i put black -to 0 1 1 16
+	image_$i put black -to 0 15 16 16
+	image_$i put black -to 15 1 16 16
+	image_$i put $i -to 1 1 15 15
+	$m add command -label $i -image image_$i -compound left -command [list \
+	puts "You invoked \"$i\"" ]
+    }
+} else {
+    foreach i {red orange yellow green blue} {
+	$m add command -label $i -background $i -command [list \
+	puts "You invoked \"$i\"" ]
+    }
 }
 
 $w configure -menu $w.menu
 
 bind Menu <<MenuSelect>> {
@@ -164,7 +180,5 @@
 	set label "    "
     }
     set menustatus $label
     update idletasks
 }
-
-if {[tk windowingsystem] eq "aqua"} {catch {set ::tk::mac::useCustomMDEF $origUseCustomMDEF}}

Index: library/demos/menubu.tcl
==================================================================
--- library/demos/menubu.tcl
+++ library/demos/menubu.tcl
@@ -16,11 +16,10 @@
 wm iconname $w "menubutton"
 positionWindow $w
 
 frame $w.body
 pack $w.body -expand 1 -fill both
-if {[tk windowingsystem] eq "aqua"} {catch {set origUseCustomMDEF $::tk::mac::useCustomMDEF; set ::tk::mac::useCustomMDEF 1}}
 
 menubutton $w.body.below -text "Below" -underline 0 -direction below -menu $w.body.below.m -relief raised
 menu $w.body.below.m -tearoff 0
 $w.body.below.m add command -label "Below menu: first item" -command "puts \"You have selected the first item from the Below menu.\""
 $w.body.below.m add command -label "Below menu: second item" -command "puts \"You have selected the second item from the Below menu.\""
@@ -84,7 +83,5 @@
 foreach i {Black gray75 gray50 White} {
 	$m entryconfigure $i -columnbreak 1
 }
 
 pack $body.buttons.colors -side left -padx 25 -pady 25
-
-if {[tk windowingsystem] eq "aqua"} {catch {set ::tk::mac::useCustomMDEF $origUseCustomMDEF}}

Index: library/demos/nl.msg
==================================================================
--- library/demos/nl.msg
+++ library/demos/nl.msg
@@ -1,21 +1,23 @@
 ::msgcat::mcset nl "Widget Demonstration" "Demonstratie van widgets"
-::msgcat::mcset nl "tkWidgetDemo" "tkWidgetDemo"
+::msgcat::mcset nl "tkWidgetDemo"
 ::msgcat::mcset nl "&File"     "&Bestand"
 ::msgcat::mcset nl "About..."  "Info..."
 ::msgcat::mcset nl "&About..." "&Info..."
 ::msgcat::mcset nl "<F1>"      "<F1>"
 ::msgcat::mcset nl "&Quit"     "&Einde"
 ::msgcat::mcset nl "Meta+Q"    "Meta+E"		;# Displayed hotkey
 ::msgcat::mcset nl "Meta-q"    "Meta-e"		;# Actual binding sequence
 ::msgcat::mcset nl "Ctrl+Q"    "Ctrl+E"		;# Displayed hotkey
 ::msgcat::mcset nl "Control-q" "Control-e"	;# Actual binding sequence
-::msgcat::mcset nl "Dismiss"   "Sluiten"
 ::msgcat::mcset nl "See Variables"    "Bekijk Variabelen"
-::msgcat::mcset nl "Variable Values"  "Waarden Variabelen"
-::msgcat::mcset nl "OK"        "OK"
+::msgcat::mcset nl "Variable values"  "Waarden variabelen"
+::msgcat::mcset nl "Variable values:"  "Waarden variabelen"
+::msgcat::mcset nl "OK"
 ::msgcat::mcset nl "Run the \"%s\" sample program" "Start voorbeeld \"%s\""
+::msgcat::mcset nl "Dismiss"   "Sluiten"
+::msgcat::mcset nl "Rerun Demo" "Herstart Demo"	;# This is also button text!
 ::msgcat::mcset nl "Print Code" "Code Afdrukken"
 ::msgcat::mcset nl "Demo code: %s" "Code van Demo %s"
 ::msgcat::mcset nl "About Widget Demo" "Over deze demonstratie"
 ::msgcat::mcset nl "Tk widget demonstration" "Demonstratie van Tk widgets"
 ::msgcat::mcset nl "Copyright © %s"
@@ -34,19 +36,17 @@
 ::msgcat::mcset nl "See Code"  "Bekijk Code"	;# This is also button text!
 ::msgcat::mcset nl "button to see the Tcl/Tk code that created the demonstration.  If" \
     "drukken om de achterliggende Tcl/Tk code te zien.  Als je dat wilt,"
 ::msgcat::mcset nl "you wish, you can edit the code and click the" \
     "kun je de code wijzigen en op de knop"
-::msgcat::mcset nl "Rerun Demo" "Herstart Demo"	;# This is also button text!
 ::msgcat::mcset nl "button in the code window to reinvoke the demonstration with the" \
     "drukken in het codevenster om de demonstratie uit te voeren met de"
 ::msgcat::mcset nl "modified code." \
     "nieuwe code."
 
 ::msgcat::mcset nl "Labels, buttons, checkbuttons, and radiobuttons" \
     "Labels, knoppen, vinkjes/aankruishokjes en radioknoppen"
-
 ::msgcat::mcset nl "Labels (text and bitmaps)" "Labels (tekst en plaatjes)"
 ::msgcat::mcset nl "Labels and UNICODE text"   "Labels en tekst in UNICODE"
 ::msgcat::mcset nl "Buttons" "Buttons (drukknoppen)"
 ::msgcat::mcset nl "Check-buttons (select any of a group)" \
     "Check-buttons (een of meer uit een groep)"
@@ -104,22 +104,29 @@
 ::msgcat::mcset nl "Vertical scale"          "Verticale schaal"
 
 ::msgcat::mcset nl "Paned Windows" "Vensters opgedeeld in stukken"
 ::msgcat::mcset nl "Horizontal paned window"   "Horizontaal gedeeld venster"
 ::msgcat::mcset nl "Vertical paned window"     "Verticaal gedeeld venster"
-
 ::msgcat::mcset nl "Menus" "Menu's"
 ::msgcat::mcset nl "Menus and cascades (sub-menus)" \
     "Menu's en cascades (submenu's)"
 ::msgcat::mcset nl "Menu-buttons" "Menu-buttons"
-
 ::msgcat::mcset nl "Common Dialogs" "Veel voorkomende dialoogvensters"
 ::msgcat::mcset nl "Message boxes"  "Mededeling (message box)"
 ::msgcat::mcset nl "File selection dialog"     "Selectie van bestanden"
 ::msgcat::mcset nl "Color picker"              "Kleurenpalet"
-
+::msgcat::mcset nl "Font selection dialog"     "Selectie van fonts"
+::msgcat::mcset nl "System tray icon and notification" "Systeemvakpictogram en melding"
+::msgcat::mcset nl "Printing from canvas and text widgets" "Afdrukken van canvas en tekst widgets"
+::msgcat::mcset nl "Animation" "Animaties"
+::msgcat::mcset nl "Animated labels" "Geanimeerde labels"
+::msgcat::mcset nl "Animated wave" "Geanimeerde golf"
+::msgcat::mcset nl "Pendulum simulation" "Pendulum simulatie"
+::msgcat::mcset nl "A celebration of Rube Goldberg" "Een viering van Rube Goldberg"
 ::msgcat::mcset nl "Miscellaneous"             "Diversen"
 ::msgcat::mcset nl "The built-in bitmaps"      "Ingebouwde plaatjes"
 ::msgcat::mcset nl "A dialog box with a local grab" \
     "Een dialoogvenster met een locale \"grab\""
 ::msgcat::mcset nl "A dialog box with a global grab" \
     "Een dialoogvenster met een globale \"grab\""
+::msgcat::mcset nl "Window icons and badges" "Vensterpictogrammen en badges"
+

Index: library/demos/pendulum.tcl
==================================================================
--- library/demos/pendulum.tcl
+++ library/demos/pendulum.tcl
@@ -92,11 +92,11 @@
 # respect to time.)
 proc showPhase {canvas} {
     global Theta dTheta points psw psh
     lappend points [expr {$Theta+$psw}] [expr {-20*$dTheta+$psh}]
     if {[llength $points] > 100} {
-    	 set points [lrange $points end-99 end]
+	set points [lrange $points end-99 end]
     }
     for {set i 0} {$i<100} {incr i 10} {
 	set list [lrange $points end-[expr {$i-1}] end-[expr {$i-12}]]
 	if {[llength $list] >= 4} {
 	    $canvas coords graph$i $list

ADDED   library/demos/print.tcl
Index: library/demos/print.tcl
==================================================================
--- /dev/null
+++ library/demos/print.tcl
@@ -0,0 +1,53 @@
+# print.tcl --
+#
+# This demonstration script showcases the tk print commands.
+#
+
+if {![info exists widgetDemo]} {
+    error "This script should be run from the \"widget\" demo."
+}
+
+set w .print
+destroy $w
+toplevel $w
+wm title $w "Printing Demonstration"
+positionWindow $w
+
+image create photo logo -data {R0lGODlhMABLAPUAAP//////zP//mf//AP/MzP/Mmf/MAP+Zmf+ZZv+ZAMz//8zM/8zMzMyZzMyZmcyZZsyZAMxmZsxmM8xmAMwzM8wzAJnMzJmZzJmZmZlmmZlmZplmM5kzZpkzM5kzAGaZzGZmzGZmmWYzZmYzMzNmzDNmmTMzmTMzZgAzmQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH+BSAtZGwtACH5BAEKAAIALAAAAAAwAEsAAAb+QIFwSCwahY9HRMI8Op/JJVNSqVqv2OvjyRU8slbIJGwYg60S5ZR6jRi/4ITBOhkYIOd8dltEnAdmFQMJeoVXCEd/VnKGjRVOZ3NVgHlsjpBxVRCEYBIEAAARl4lgZmVgEQAKFx8Mo0ZnpqgAFyi2JqKGmGebWRIAILbCIo27cYFWASTCtievRXqSVwQfzLYeeYESxlnSVRIW1igjWHJmjBXbpKXeFQTizlh1eJNVHbYf0LGc39XW2PIoVZE0whasWPSqFBBHrkKEA3QG0DFTEMXBUsjCWesg4oMFAGwgtKsiwqA+jGiCiRPGAM6pLCVLGKHQ6EGJlc0IuDxzAgX+CCOW9DjAaUsEyAoT+GHpeSRoHgxEUWgAUEUpFhMWgTbKEPUBAU15TBZxekYD0RMEqCDLIpYIWTAcmGEd9rWQBxQyjeQqdK/ZTWEO3mK5l+9No75SrcHhm9WwnlzNoA5zdM+JHz0HCPQdUauZowoFnSw+c2CBvw6dUXT4LMKE6EIHUqMexgCiIREknOwl7Q+FhNQoLuzOc6Kw3kIIVOLqjYKBYCwinmgo9CBEswfMAziK7mRDoQhcUZxwoBKFibq3n3jXI0GyCPLC0DrS8GR1oaEoRBRYVhT99/qG4DcCA/yNU4Ajbjhhnx4P2DJggR3YZog6RyyYxwM9PSgMBaP+sQdgIRL0JAKBwnTooRMAFWLdiPyJ8JwvTnyQoh5midCASh149ZkTIFAmHnzOZOBfIU6U4Mhd4zF34DNEoDAhARGY50BvJkioyxFOGkKAShGkFsJwejiR5Xf8aZAaBp89coQJjuDXAQOApekEm45ANaAtIbyYxREf0OlICCK841uaahZBQjyfjXCACYjuaASjhFagRKSFNtloHg+hYWIxRohnBQWCSSAhBVZ+hkgRnlbxwJIVgIqGlaU6wkeTxHxjm6gVLImrFbHWVEQ1taZjWxJX7KqqnqgUEUxDwtqajrOaRkqhEDcxWwECbEjxTYe9gojqOJQ6JO231ob72bSqAjh4RgfsjiDCCfDCK8K8I9TL7r33nvGtCO7CO1dUAONk3LcBFxzwwEMwZ/DC4iAsRIE+CWNCbzeV8FfEtoDwVwnlacxMkcKQYIE/F5TQ2QcedUZCagyc3NsFGrXVZMipWVBCzKv4Q0JvCviDsjAwf4ylxBeX0KcwGs81ccgqGS3MBxc3RjDDVAvdBRcfeFy1MFd3bcQHJEQdlddkP5E1Cf9yXfbaV2d9RBAAOw==
+}
+
+
+pack [label $w.l -text "This demonstration showcases
+        the tk print command. Clicking the buttons below
+        print the data from the canvas and text widgets
+        using platform-native dialogs."] -side top
+
+pack [frame $w.m] -fill both -expand yes -side top
+
+set c [canvas $w.m.c -bg white]
+pack $c -fill both -expand no -side left
+
+$c create rectangle 30 10 200 50 -fill blue -outline black
+$c create oval 30 60 200 110 -fill green
+$c create image 130 150 -image logo
+$c create text 150 250   -anchor n -font {Helvetica 12}  \
+	-text "A short demo of simple canvas elements."
+
+set txt {
+Tcl, or Tool Command Language, is an open-source multi-purpose C library which includes a powerful dynamic scripting language. Together they provide ideal cross-platform development environment for any programming project. It has served for decades as an essential system component in organizations ranging from NASA to Cisco Systems, is a must-know language in the fields of EDA, and powers companies such as FlightAware and F5 Networks.
+
+Tcl is fit for both the smallest and largest programming tasks, obviating the need to decide whether it is overkill for a given job or whether a system written in Tcl will scale up as needed. Wherever a shell script might be used Tcl is a better choice, and entire web ecosystems and mission-critical control and testing systems have also been written in Tcl. Tcl excels in all these roles due to the minimal syntax of the language, the unique programming paradigm exposed at the script level, and the careful engineering that has gone into the design of the Tcl internals.
+}
+
+set t [text $w.m.t -wrap word]
+pack $t -side right -fill both -expand no
+$t insert end $txt
+
+pack [frame $w.f] -side top -fill both -expand no
+pack [button $w.f.b -text "Print Canvas" -command [list tk print $w.m.c]]  -expand no
+pack [button $w.f.x -text "Print Text" -command [list tk print $w.m.t]]   -expand no
+
+## See Code / Dismiss buttons
+pack [addSeeDismiss $w.buttons $w] -side bottom -fill x
+
+

Index: library/demos/puzzle.tcl
==================================================================
--- library/demos/puzzle.tcl
+++ library/demos/puzzle.tcl
@@ -9,11 +9,11 @@
 
 package require Tk
 
 # puzzleSwitch --
 # This procedure is invoked when the user clicks on a particular button;
-# if the button is next to the empty space, it moves the button into th
+# if the button is next to the empty space, it moves the button into the
 # empty space.
 
 proc puzzleSwitch {w num} {
     global xpos ypos
     if {(($ypos($num) >= ($ypos(space) - .01))

Index: library/demos/spin.tcl
==================================================================
--- library/demos/spin.tcl
+++ library/demos/spin.tcl
@@ -36,11 +36,11 @@
     Canberra Sydney Melbourne Perth Adelaide Brisbane
     Hobart Darwin "Alice Springs"
 }
 
 spinbox $w.s1 -from 1 -to 10 -width 10 -validate key \
-	-vcmd {string is integer %P}
+	-validatecommand {string is integer %P}
 spinbox $w.s2 -from 0 -to 3 -increment .5 -format %05.2f -width 10
 spinbox $w.s3 -values $australianCities -width 10
 
 #entry $w.e1
 #entry $w.e2

Index: library/demos/square
==================================================================
--- library/demos/square
+++ library/demos/square
@@ -9,12 +9,12 @@
 # bindings for the widget:
 #
 # Button-1 press/drag:		moves square to mouse
 # "a":				toggle size animation on/off
 
-package require Tk		;# We use Tk generally, and...
-package require Tktest		;# ... we use the square widget too.
+package require tk		;# We use Tk generally, and...
+package require tk::test	;# ... we use the square widget too.
 
 square .s
 pack .s -expand yes -fill both
 wm minsize . 1 1
 

ADDED   library/demos/systray.tcl
Index: library/demos/systray.tcl
==================================================================
--- /dev/null
+++ library/demos/systray.tcl
@@ -0,0 +1,89 @@
+# systray.tcl --
+#
+# This demonstration script showcases the tk systray and tk sysnotify commands.
+#
+
+if {![info exists widgetDemo]} {
+    error "This script should be run from the \"widget\" demo."
+}
+
+set w .systray
+destroy $w
+toplevel $w
+wm title $w "System Tray Demonstration"
+positionWindow $w
+
+catch {tk systray destroy}
+set trayIconExists false
+
+set iconmenu .menubar
+destroy $iconmenu
+menu $iconmenu
+$iconmenu add command -label "Status" -command { puts "status icon clicked" }
+$iconmenu add command -label "Exit" -command exit
+
+pack [label $w.l -text "This demonstration showcases
+        the tk systray and tk sysnotify commands.
+        Running this demo creates the systray icon.
+        Clicking the buttons below modifies and destroys the icon
+        and displays the notification."]
+
+image create photo book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+
+labelframe $w.f -text "Tray Icon"
+button $w.f.b0 -text "Create" -command create
+button $w.f.b1 -text "Modify" -command modify
+button $w.f.b2 -text "Destroy" -command remove
+pack $w.f.b0 $w.f.b1 $w.f.b2 -padx 5 -pady 3 -side left -expand true -fill x
+
+button $w.b3 -text "Display Notification" -command notify
+pack $w.f $w.b3 -expand true -fill x -padx 5 -pady 5
+
+proc create {} {
+    global trayIconExists
+    if {$trayIconExists} {
+        tk_messageBox -message "Systray icon already exists"
+        return
+    }
+    tk systray create -image book -text "Systray sample" \
+            -button1 {puts "foo"} \
+            -button3 {tk_popup $iconmenu [winfo pointerx .] [winfo pointery .]}
+    set trayIconExists true
+}
+
+proc modify {} {
+    global trayIconExists
+    if {!$trayIconExists} {
+        tk_messageBox -message "Please create systray icon first"
+        return
+    }
+    image create photo page -data R0lGODlhCwAPAKIAAP//////AMDAwICAgAAA/wAAAAAAAAAAACwAAAAACwAPAAADMzi6CzAugiAgDGE68aB0RXgRJBFVX0SNpQlUWfahQOvSsgrX7eZJMlQMWBEYj8iQchlKAAA7
+    tk systray configure -image page
+    tk systray configure -text "Modified text"
+    tk systray configure -button1 {puts "this is a different output"}
+    tk systray configure -button3 {puts "hello yall"}
+}
+
+proc notify {} {
+    global trayIconExists
+    if {!$trayIconExists} {
+        tk_messageBox -message "Please create systray icon first"
+        return
+    }
+    tk sysnotify  "Alert" "This is an alert"
+}
+
+proc remove {} {
+    global trayIconExists
+    if {!$trayIconExists} {
+        tk_messageBox -message "Systray icon was already destroyed"
+        return
+    }
+    tk systray destroy
+    set trayIconExists false
+}
+
+create
+
+## See Code / Dismiss buttons
+pack [addSeeDismiss $w.buttons $w] -side bottom -fill x

Index: library/demos/tclIndex
==================================================================
--- library/demos/tclIndex
+++ library/demos/tclIndex
@@ -63,5 +63,8 @@
 set auto_index(setHeight) [list source -encoding utf-8 [file join $dir vscale.tcl]]
 set auto_index(showMessageBox) [list source -encoding utf-8 [file join $dir msgbox.tcl]]
 set auto_index(setColor) [list source -encoding utf-8 [file join $dir clrpick.tcl]]
 set auto_index(setColor_helper) [list source -encoding utf-8 [file join $dir clrpick.tcl]]
 set auto_index(fileDialog) [list source -encoding utf-8 [file join $dir filebox.tcl]]
+set auto_index(systray) [list source -encoding utf-8 [file join $dir systray.tcl]]
+set auto_index(windoicons [list source -encoding utf-8 [file join $dir windowicons.tcl]]
+

Index: library/demos/widget
==================================================================
--- library/demos/widget
+++ library/demos/widget
@@ -327,11 +327,18 @@
     @@demo icon		Iconic buttons that use bitmaps
     @@demo image1	Two labels displaying images
     @@demo image2	A simple user interface for viewing images
     @@demo labelframe	Labelled frames
     @@demo ttkbut	The simple Themed Tk widgets
-
+}
+if {[tk windowingsystem] eq "aqua"} {
+    addFormattedText {
+	@@new
+	@@demo mac_styles	Special widgets for macOS
+    }
+}
+addFormattedText {
     @@subtitle	Listboxes and Trees
     @@demo states	The 50 states
     @@demo colors	Colors: change the color scheme for the application
     @@demo sayings	A collection of famous and infamous sayings
     @@demo mclist	A multi-column list of countries
@@ -364,11 +371,10 @@
     @@demo knightstour  A Knight's tour of the chess board
 
     @@subtitle	Scales and Progress Bars
     @@demo hscale	Horizontal scale
     @@demo vscale	Vertical scale
-    @@new
     @@demo ttkscale	Themed scale linked to a label with traces
     @@demo ttkprogress	Progress bar
 
     @@subtitle	Paned Windows and Notebooks
     @@demo paned1	Horizontal paned window
@@ -385,10 +391,14 @@
     @@subtitle	Common Dialogs
     @@demo msgbox	Message boxes
     @@demo filebox	File selection dialog
     @@demo clrpick	Color picker
     @@demo fontchoose	Font selection dialog
+    @@new
+    @@demo systray      System tray icon and notification
+    @@new
+    @@demo print        Printing from canvas and text widgets
 
     @@subtitle	Animation
     @@demo anilabel	Animated labels
     @@demo aniwave	Animated wave
     @@demo pendulum	Pendulum simulation
@@ -396,10 +406,12 @@
 
     @@subtitle	Miscellaneous
     @@demo bitmap	The built-in bitmaps
     @@demo dialog1	A dialog box with a local grab
     @@demo dialog2	A dialog box with a global grab
+    @@new
+    @@demo windowicons  Window icons and badges
 }
 
 ##############################################################################
 
 .t configure -state disabled
@@ -622,11 +634,11 @@
 	raise $top
     }
     wm title $top [mc "Demo code: %s" [file join $tk_demoDirectory $file]]
     wm iconname $top $file
     set id [open [file join $tk_demoDirectory $file]]
-    fconfigure $id -encoding utf-8 -eofchar \032
+    fconfigure $id -encoding utf-8 -eofchar "\032 {}"
     $top.f.text delete 1.0 end
     $top.f.text insert 1.0 [read $id]
     $top.f.text mark set insert 1.0
     close $id
 }
@@ -638,84 +650,11 @@
 # Arguments:
 # w -		Name of text widget containing code to print
 # file -		Name of the original file (implicitly for title)
 
 proc printCode {w file} {
-    set code [$w get 1.0 end-1c]
-
-    set dir "."
-    if {[info exists ::env(HOME)]} {
-	set dir "$::env(HOME)"
-    }
-    if {[info exists ::env(TMP)]} {
-	set dir $::env(TMP)
-    }
-    if {[info exists ::env(TEMP)]} {
-	set dir $::env(TEMP)
-    }
-
-    set filename [file join $dir "tkdemo-$file"]
-    set outfile [open $filename "w"]
-    puts $outfile $code
-    close $outfile
-
-    switch -- $::tcl_platform(platform) {
-	unix {
-	    if {[catch {exec lp -c $filename} msg]} {
-		tk_messageBox -title "Print spooling failure" \
-			-message "Print spooling probably failed: $msg"
-	    }
-	}
-	windows {
-	    if {[catch {PrintTextWin32 $filename} msg]} {
-		tk_messageBox -title "Print spooling failure" \
-			-message "Print spooling probably failed: $msg"
-	    }
-	}
-	default {
-	    tk_messageBox -title "Operation not Implemented" \
-		    -message "Wow! Unknown platform: $::tcl_platform(platform)"
-	}
-    }
-
-    #
-    # Be careful to throw away the temporary file in a gentle manner ...
-    #
-    if {[file exists $filename]} {
-	catch {file delete $filename}
-    }
-}
-
-# PrintTextWin32 --
-#    Print a file under Windows using all the "intelligence" necessary
-#
-# Arguments:
-# filename -		Name of the file
-#
-# Note:
-# Taken from the Wiki page by Keith Vetter, "Printing text files under
-# Windows".
-# Note:
-# Do not execute the command in the background: that way we can dispose of the
-# file smoothly.
-#
-proc PrintTextWin32 {filename} {
-    package require registry
-    set app [auto_execok notepad.exe]
-    set pcmd "$app /p %1"
-    catch {
-	set app [registry get {HKEY_CLASSES_ROOT\.txt} {}]
-	set pcmd [registry get \
-		{HKEY_CLASSES_ROOT\\$app\\shell\\print\\command} {}]
-    }
-
-    regsub -all {%1} $pcmd $filename pcmd
-    puts $pcmd
-
-    regsub -all {\\} $pcmd {\\\\} pcmd
-    set command "[auto_execok start] /min $pcmd"
-    eval exec $command
+    tk print $w
 }
 
 # tkAboutDialog --
 #
 #	Pops up a message box with an "about" message
@@ -724,11 +663,12 @@
     tk_messageBox -icon info -type ok -title [mc "About Widget Demo"] \
 	    -message [mc "Tk widget demonstration application"] -detail \
 "[mc "Copyright © %s" {1996-1997 Sun Microsystems, Inc.}]
 [mc "Copyright © %s" {1997-2000 Ajuba Solutions, Inc.}]
 [mc "Copyright © %s" {2001-2009 Donal K. Fellows}]
-[mc "Copyright © %s" {2002-2007 Daniel A. Steffen}]"
+[mc "Copyright © %s" {2002-2007 Daniel A. Steffen}]
+[mc "Copyright © %s" {2021 Kevin Walzer}]"
 }
 
 # Local Variables:
 # mode: tcl
 # End:

ADDED   library/demos/windowicons.tcl
Index: library/demos/windowicons.tcl
==================================================================
--- /dev/null
+++ library/demos/windowicons.tcl
@@ -0,0 +1,99 @@
+# windowicons.tcl --
+#
+# This demonstration script showcases the wm iconphoto and wm iconbadge commands.
+#
+
+if {![info exists widgetDemo]} {
+    error "This script should be run from the \"widget\" demo."
+}
+
+set w .windowicons
+destroy $w
+toplevel $w
+wm title $w "Window Icon Demonstration"
+positionWindow $w
+
+image create photo icon -data {
+    iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGP
+    C/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3Cc
+    ulE8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAArQNAAK0DQEdFIm+AAAJ
+    QElEQVRYw+WXW2xdV5nHf/ty7lcf2/FxYsdOnMSNC0HTpDiRKJWAQjWCEQNU
+    SEAFfUOiQqrEC2+IxwpemDLSzNBBCCQeQEKqRJgBSikiuGlN22TqhsR27OPL
+    8eWc43Pdt7X22osHHydOm4FBPM6Slr69paX9/32Xtb614f/7MP6vC3O5f8L3
+    G7HJyZPHBwfz5wrF7HQ6nRwxLTOhQuU4PW+z3eq9Xa+33rq9cms7k8pHjvfS
+    3w8wOfk52u1u8oHpiUff897JJ8+dO/nI6LHho6OjQ3ahkMYwTTZ2O2zXutS3
+    G/7ayubq7Vtr/7Ve2f7RytLam4ViXq1t/vRvB0ilPsjzz3+LZ5/9j7MzM5Nf
+    /8hj5//5H97/YNbK5hkfTFLMxAEQQvD766v0yBGIEBEEuPUGi9dv7lx77cb3
+    Vm9vfqc0WNi9evUKWr/xLh3rfuLj45+l0bjM7m768U98/OJ/fulLH/3wiemx
+    eCafxRcKw7TJxKC+12RpbYdAx7HsOCrSRNpg+sQQj1w8nS0N5h8JAvm+rWr9
+    9ZmZB2qWdZq9vWt/GWBm5im+9rUn6HRGPv7EE4/++2P/eOFkV0FkJTDQgCaX
+    TbO1tcV2R2EmCxBJQixs2+R9EwV00MFAceJE2ZiZOT7VaTsPLyxU5orFTK1c
+    fphq9bX7A8zOfoV8Ps3c3NsXPvWpD37vc5//0ETNt8gNjDAzlsdAE0vliTCR
+    xEhnC2CaRIZNMmZiaonv9mh1PcrDJQZzCfK5OGNjQ8e2tvZO37y5+ctk0naq
+    1fn7A4yOnmd5uVp4/PGHn/vylz8xe+zoEIP5JAMpA0OHeK6DG4TEk2li8Tha
+    QxRpIg0q6DGUNjg6UuLYSInhYoYoigiCgHQ6TrGYnlpd3Q1ffvk3L128+ITe
+    2Hj1XoBLl55menqcbDb1haeeevyrDz102tJaE7ctLBMqG1X23Ag7kcKOJzAA
+    DSilCVWEZdmMDaXJJCxSiRimaaK1RkqJ7/uUSlk6Hed0oxG9HI9bm+Pjs2xs
+    vIp5AKC15oUX/lA8f/7MF2dnz8YADMNASslypYqrUxSHyqSy+f31hzaRZRpM
+    DKVYr+7y4usVri1WWavWCWSIZZkYhoFSIRcuTI1MTAw9OTf33Tu7zz54SCRi
+    nD17/Pzs7AMPFQqZPlTE8vo2DlmGhgbo12BffD/8SmukitiuNxHKoDwyzPJG
+    nTdXmtiWwdnRNCN5GxWGDA/nOH26/NGpqSfHgPU7AJcuPc0nP/kBrl698YGZ
+    mYmMEIJmx6Hn+my0DUZGC6gIzEOnhu4Lh2GEbRocGyxRSO/7c3QgiRuEVOtd
+    EvEQrSN8IVEq5MSJ4YlSKX3OMKJ14G4KnnnmM9bkZPk92VyKy3M3eentJjd3
+    FUYyjxuEeELt7/NoP+eBVAipCFXEsYE4xcydYFIeSHKynOXhUwM0mh32egH1
+    tsdL16oo007kcskHs7kYly49fRcALqby+fQopklkZ4jHY3g6gQgjHF/QcgQd
+    V+7DHJoGmnzSQuvD0QGlIsJQkU4luLXR4kgxxcRgjM1mQCyZHrv0sUe4JwKF
+    XMmu7/VSXV9xaXqI0YzC8328QOJ4gq4raHQDGt2AtitwfIEbSAwibOvdJ7pS
+    CiElR3IxGh2X5Y0GV66v0wnAsq3MN5759L1FqKMoCkQoX19u0QkkD47lKSYi
+    Th1NoSLYafu0ehrTNNBaE2mNUop2z+DEUJKBbPxecSEIgoAoUjwwmmZpdZPl
+    muL4oIFWkbx8rXIvQMfZ9p2e1xBCstOJcFe6nB1NcWokhW1ZHMkazK90qXXD
+    fZFII0NFIBW/XQiZHraoNbsU81mmjhbxfZ8gCAiCgELKQitJGCoIQ6SQO//2
+    ze/fm4Kf/Px50dzr3Aoch1Ap2o4kn8tgW/sHynAxzcVTBQYzFp4v6boBjidw
+    fcFCpcmPf7/Oz+ZrvPBalb12D9/370DUGk1evr6NacWIfD/yveDmXq3F3Nxz
+    dwH+5dkfUq8155rb9dA2QcqQcjFx57DRGgaySR47d4RHZ0pYeh/C9QSOJ3EE
+    CGWw3fJZ323j+x6e5xH4Pgu3d6g0FMWUjdvu7bo9/5oK1d0IzM09hwhCGrvN
+    ubXFylI2pum4AZXtDqEURFGE1hoNxGMW5ZyB22nS8wQ9r1+QvsDzBc1uQGW7
+    jee6eN4+RMfxMdHkYgatWmtur9ZaOnD8TgQMA27c+uH68s3KT8O9BoYBv3pj
+    kxuVGo7Tw+1/MAh83lreYm1P9r3fT4XjSVxf4voC1/NwHAfXdXFcB891KGVj
+    hO2e16q3fzR2cjQwDPPeZrSx8SqXL2/RqDU2EnH7I8dPjQ8v7Tqs1RwmSzEs
+    QoQQSBHw1lKVha0AEUb4IiQQIb4I8YUkkCHTQwa5WIjne9xY2mT+VouRfI7N
+    xfVfrK8sfTuRSAavXP3Xd7fjavWPRq1+3TeiQTVcGnh0oHwktlZzmBq0SNsR
+    QgiuXLvNL/+nQU/aBFL1xSW+kAghEb5PEkE5q3Bdl7dv72LGCrTXdzf+9Nb8
+    N5dXfrG6Wf1jeNDP3nkjigOFWm2xpvx0+tjI8LnMYMnMxQT5eIjruVye36LS
+    TRAqRSD3vZdCIqUgEj5R4CEDj2O5kMZei3rHoLXV6Sy88cp3Fhf/ew6IAAGE
+    9wOIARmtw9Tu7vKa1yY+Wiqeee+ZYdsi4HdvrjK/HiKUiZQhoZREQhDJAC18
+    tPSIhEfouwSuQ9cx2VxpNK/PX/n+4uKvXwQdAAHgA/J+AAaQABJRJOydnVsr
+    zZ1O13eMcSuezC61LJzQRgY+KvCJhI+WPpH0IAywIkEhaVIupAhdHS0t3F66
+    Nv/iD9bW/nAFtAM4QA9wAXX3RnEvQBoYODSL+fzEmalTsx+emjl3YWjsaMlM
+    pcwg0ggZEimFoSNsI8JSCtF1wtpmdWt1aeGVSuW133leYwNoA01gr297BzVw
+    v/8CA0gBBaDYtzkw87ns6PhI+czM0JHjp/PFUjmZSmUM07RCKUPP6XVae/Vq
+    fbdys1ZbvOX5ja2+ULcP0Opbt18H/G8Ah+shDWQPzVQ/RSnLTGRsO5U0TMuM
+    VKjC0PUjLd1+fgPAOxTybl9YcvdC9VcBDobV3x0JINm3MfYbmdX/hu57FfZF
+    Dgot6Fe8eqfw3wLwzvVmX9jsvx8AHEAcnn91/BlySEFKTpuCtgAAABN0RVh0
+    QXV0aG9yAHdhcnN6YXdpYW5rYQy+S5cAAABYdEVYdENvcHlyaWdodABDQzAg
+    UHVibGljIERvbWFpbiBEZWRpY2F0aW9uIGh0dHA6Ly9jcmVhdGl2ZWNvbW1v
+    bnMub3JnL3B1YmxpY2RvbWFpbi96ZXJvLzEuMC/G4735AAAAIXRFWHRDcmVh
+    dGlvbiBUaW1lADIwMTAtMDMtMjlUMDg6MDg6MzD47LxwAAAAJXRFWHRkYXRl
+    OmNyZWF0ZQAyMDIxLTA4LTE1VDIwOjU0OjM5LTA0OjAwNBT3DQAAACV0RVh0
+    ZGF0ZTptb2RpZnkAMjAyMS0wOC0xNVQyMDo1NDoxMS0wNDowMDSDBqsAAADI
+    elRYdERlc2NyaXB0aW9uAAAY042OwQqCQBCGn6B3GOy+Cl0qTAjEc1HRJVhW
+    HXUrd2pmLXr7tDrVpcMP838w/F+wxxxyprsgB2ALclAxtRAbaBirRdB4f5mH
+    oTeuJlUxYoly8nRRxHW4HahO30SvmI5Y+CCBF4dPhzg0CYwOLs45GdKfG+sK
+    hBuy2H4xUlM1i76+BhcBwwirLj/bAlJqjXXzP9UyxmuHzp8feiknLPW6Q/H9
+    moy3yK1oqvROUE2yH99suX45PwEyf2MTOoCNrQAAABl0RVh0U29mdHdhcmUA
+    d3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABWdEVYdFNvdXJjZQBodHRwczovL29w
+    ZW5jbGlwYXJ0Lm9yZy9kZXRhaWwvMzUyMzMvdGFuZ28taW5ldHJuZXQtd2Vi
+    LWJyb3dzZXItYnktd2Fyc3phd2lhbmth5nAuRgAAACB0RVh0VGl0bGUAdGF
+    uZ28gaW5ldHJuZXQgd2ViIGJyb3dzZXLyr62TAAAAAElFTkSuQmCC
+}
+
+set ::tk::icons::base_icon(.) icon
+
+pack [button $w.i -text "Set Window Icon to Globe" -image $::tk::icons::base_icon(.) \
+        -compound top -command {wm iconphoto . $::tk::icons::base_icon(.) }]
+pack [button $w.b -text "Set Badge to 3" -command {wm iconbadge . 3}]
+pack [button $w.e -text "Set Badge to 11" -command {wm iconbadge . 11}]
+pack [button $w.f -text "Reset Badge" -command {wm iconbadge . ""}]
+
+## See Code / Dismiss buttons
+pack [addSeeDismiss $w.buttons $w] -side bottom -fill x

Index: library/entry.tcl
==================================================================
--- library/entry.tcl
+++ library/entry.tcl
@@ -117,21 +117,21 @@
 bind Entry <Control-Button-1> {
     %W icursor @%x
 }
 
 bind Entry <<PrevChar>> {
-    tk::EntrySetCursor %W [expr {[%W index insert]-1}]
+    tk::EntrySetCursor %W [tk::EntryPreviousChar %W insert]
 }
 bind Entry <<NextChar>> {
-    tk::EntrySetCursor %W [expr {[%W index insert]+1}]
+    tk::EntrySetCursor %W [tk::EntryNextChar %W insert]
 }
 bind Entry <<SelectPrevChar>> {
-    tk::EntryKeySelect %W [expr {[%W index insert]-1}]
+    tk::EntryKeySelect %W [tk::EntryPreviousChar %W insert]
     tk::EntrySeeInsert %W
 }
 bind Entry <<SelectNextChar>> {
-    tk::EntryKeySelect %W [expr {[%W index insert]+1}]
+    tk::EntryKeySelect %W [tk::EntryNextChar %W insert]
     tk::EntrySeeInsert %W
 }
 bind Entry <<PrevWord>> {
     tk::EntrySetCursor %W [tk::EntryPreviousWord %W insert]
 }
@@ -163,11 +163,12 @@
 
 bind Entry <Delete> {
     if {[%W selection present]} {
 	%W delete sel.first sel.last
     } else {
-	%W delete insert
+	%W delete [tk::startOfCluster [%W get] [%W index insert]] \
+		[tk::endOfCluster [%W get] [%W index insert]]
     }
 }
 bind Entry <BackSpace> {
     tk::EntryBackspace %W
 }
@@ -193,11 +194,11 @@
 bind Entry <Key> {
     tk::CancelRepeat
     tk::EntryInsert %W %A
 }
 
-# Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
+# Ignore all Alt, Meta, Control, Command, and Fn keypresses unless explicitly bound.
 # Otherwise, if a widget binding for one of these is defined, the
 # <Key> class binding will also fire and insert the character,
 # which is wrong.  Ditto for Escape, Return, and Tab.
 
 bind Entry <Alt-Key> {# nothing}
@@ -207,13 +208,12 @@
 bind Entry <Return> {# nothing}
 bind Entry <KP_Enter> {# nothing}
 bind Entry <Tab> {# nothing}
 bind Entry <Prior> {# nothing}
 bind Entry <Next> {# nothing}
-if {[tk windowingsystem] eq "aqua"} {
-    bind Entry <Command-Key> {# nothing}
-}
+bind Entry <Command-Key> {# nothing}
+bind Entry <Fn-Key> {# nothing}
 # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663]
 bind Entry <<NextLine>> {# nothing}
 bind Entry <<PrevLine>> {# nothing}
 
 # On Windows, paste is done using Shift-Insert.  Shift-Insert already
@@ -276,22 +276,35 @@
 
 bind Entry <<TkStartIMEMarkedText>> {
     dict set ::tk::Priv(IMETextMark) "%W" [%W index insert]
 }
 bind Entry <<TkEndIMEMarkedText>> {
-    if {[catch {dict get $::tk::Priv(IMETextMark) "%W"} mark]} {
-	bell
-    } else {
-	%W selection range $mark insert
-    }
+    ::tk::EntryEndIMEMarkedText %W
 }
 bind Entry <<TkClearIMEMarkedText>> {
     %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert]
 }
 bind Entry <<TkAccentBackspace>> {
     tk::EntryBackspace %W
 }
+
+# ::tk::EntryEndIMEMarkedText --
+# Handles input method text marking in an entry
+#
+# Arguments:
+# w -		The entry window.
+
+proc ::tk::EntryEndIMEMarkedText {w} {
+    variable Priv
+    if {[catch {
+	set mark [dict get $Priv(IMETextMark) $w]
+    }]} {
+	bell
+	return
+    }
+    $w selection range $mark insert
+}
 
 # A few additional bindings of my own.
 
 bind Entry <Button-2> {
     if {!$tk_strictMotif} {
@@ -375,21 +388,21 @@
 		}
 	    }
 	}
 	word {
 	    if {$cur < $anchor} {
-		set before [tcl_wordBreakBefore [$w get] $cur]
-		set after [tcl_wordBreakAfter [$w get] $anchor-1]
+		set before [tk::wordBreakBefore [$w get] $cur]
+		set after [tk::wordBreakAfter [$w get] $anchor-1]
 	    } elseif {$cur > $anchor} {
-		set before [tcl_wordBreakBefore [$w get] $anchor]
-		set after [tcl_wordBreakAfter [$w get] $cur-1]
+		set before [tk::wordBreakBefore [$w get] $anchor]
+		set after [tk::wordBreakAfter [$w get] $cur-1]
 	    } else {
 		if {[$w index @$Priv(pressX)] < $anchor} {
 		      incr anchor -1
 		}
-		set before [tcl_wordBreakBefore [$w get] $anchor]
-		set after [tcl_wordBreakAfter [$w get] $anchor]
+		set before [tk::wordBreakBefore [$w get] $anchor]
+		set after [tk::wordBreakAfter [$w get] $anchor]
 	    }
 	    if {$before < 0} {
 		set before 0
 	    }
 	    if {$after < 0} {
@@ -503,13 +516,14 @@
 
 proc ::tk::EntryBackspace w {
     if {[$w selection present]} {
 	$w delete sel.first sel.last
     } else {
-	set x [$w index insert]
-	if {$x > 0} {
-	    $w delete [expr {$x-1}]
+	set x [expr {[$w index insert] - 1}]
+	if {$x >= 0} {
+	    $w delete [tk::startOfCluster [$w get] $x] \
+		      [tk::endOfCluster [$w get] $x]
 	}
 	if {[$w index @0] >= [$w index insert]} {
 	    set range [$w xview]
 	    set left [lindex $range 0]
 	    set right [lindex $range 1]
@@ -563,11 +577,11 @@
 	incr i
     }
     if {$i < 2} {
 	return
     }
-    set first [expr {$i-2}]
+    set first $i-2
     set data [$w get]
     set new [string index $data $i-1][string index $data $first]
     $w delete $first $i
     $w insert insert $new
     EntrySeeInsert $w
@@ -583,22 +597,22 @@
 # w -		The entry window in which the cursor is to move.
 # start -	Position at which to start search.
 
 if {[tk windowingsystem] eq "win32"}  {
     proc ::tk::EntryNextWord {w start} {
-	set pos [tcl_endOfWord [$w get] [$w index $start]]
+	set pos [tk::endOfWord [$w get] [$w index $start]]
 	if {$pos >= 0} {
-	    set pos [tcl_startOfNextWord [$w get] $pos]
+	    set pos [tk::startOfNextWord [$w get] $pos]
 	}
 	if {$pos < 0} {
 	    return end
 	}
 	return $pos
     }
 } else {
     proc ::tk::EntryNextWord {w start} {
-	set pos [tcl_endOfWord [$w get] [$w index $start]]
+	set pos [tk::endOfWord [$w get] [$w index $start]]
 	if {$pos < 0} {
 	    return end
 	}
 	return $pos
     }
@@ -612,16 +626,33 @@
 # Arguments:
 # w -		The entry window in which the cursor is to move.
 # start -	Position at which to start search.
 
 proc ::tk::EntryPreviousWord {w start} {
-    set pos [tcl_startOfPreviousWord [$w get] [$w index $start]]
+    set pos [tk::startOfPreviousWord [$w get] [$w index $start]]
+    if {$pos < 0} {
+	return 0
+    }
+    return $pos
+}
+
+proc ::tk::EntryNextChar {w start} {
+    set pos [tk::endOfCluster [$w get] [$w index $start]]
+    if {$pos < 0} {
+	return end
+    }
+    return $pos
+}
+
+proc ::tk::EntryPreviousChar {w start} {
+    set pos [tk::startOfCluster [$w get] [expr {[$w index $start]-1}]]
     if {$pos < 0} {
 	return 0
     }
     return $pos
 }
+
 
 # ::tk::EntryScanMark --
 #
 # Marks the start of a possible scan drag operation
 #

Index: library/fontchooser.tcl
==================================================================
--- library/fontchooser.tcl
+++ library/fontchooser.tcl
@@ -1,56 +1,70 @@
 # fontchooser.tcl -
 #
 #	A themeable Tk font selection dialog. See TIP #324.
 #
-# Copyright (C) 2008 Keith Vetter
-# Copyright (C) 2008 Pat Thoyts <patthoyts@users.sourceforge.net>
+# Copyright © 2008 Keith Vetter
+# Copyright © 2008 Pat Thoyts <patthoyts@users.sourceforge.net>
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
 namespace eval ::tk::fontchooser {
     variable S
 
     set S(W) .__tk__fontchooser
-    set S(fonts) [lsort -dictionary [font families]]
+    set S(fonts) [lsort -dictionary -unique [font families]]
     set S(styles) [list \
-	[::msgcat::mc "Regular"] \
-	[::msgcat::mc "Italic"] \
-	[::msgcat::mc "Bold"] \
-	[::msgcat::mc "Bold Italic"] \
+            [::msgcat::mc Regular] \
+            [::msgcat::mc Italic] \
+            [::msgcat::mc Bold] \
+            [::msgcat::mc {Bold Italic}] \
     ]
-
     set S(sizes) {8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72}
     set S(strike) 0
     set S(under) 0
     set S(first) 1
-    set S(sampletext) [::msgcat::mc "AaBbYyZz01"]
     set S(-parent) .
-    set S(-title) [::msgcat::mc "Font"]
+    set S(-title) {}
     set S(-command) ""
     set S(-font) TkDefaultFont
+    set S(bad) [list ]
+}
+
+proc ::tk::fontchooser::Canonical {} {
+    variable S
+
+    foreach style $S(styles) {
+        lappend S(styles,lcase) [string tolower $style]
+    }
+    set S(sizes,lcase) $S(sizes)
+    set S(sampletext) [::msgcat::mc "AaBbYyZz01"]
+
+    # Canonical versions of font families, styles, etc. for easier searching
+    set S(fonts,lcase) {}
+    foreach font $S(fonts) {
+        lappend S(fonts,lcase) [string tolower $font]
+    }
+    set S(styles,lcase) {}
+    foreach style $S(styles) {
+        lappend S(styles,lcase) [string tolower $style]
+    }
 }
 
 proc ::tk::fontchooser::Setup {} {
     variable S
 
-    # Canonical versions of font families, styles, etc. for easier searching
-    set S(fonts,lcase) {}
-    foreach font $S(fonts) {lappend S(fonts,lcase) [string tolower $font]}
-    set S(styles,lcase) {}
-    foreach style $S(styles) {lappend S(styles,lcase) [string tolower $style]}
-    set S(sizes,lcase) $S(sizes)
+    Canonical
 
     ::ttk::style layout FontchooserFrame {
         Entry.field -sticky news -border true -children {
             FontchooserFrame.padding -sticky news
         }
     }
     bind [winfo class .] <<ThemeChanged>> \
-        [list +ttk::style layout FontchooserFrame \
-             [ttk::style layout FontchooserFrame]]
+            [list +ttk::style layout FontchooserFrame \
+                    [ttk::style layout FontchooserFrame]]
 
     namespace ensemble create -map {
         show ::tk::fontchooser::Show
         hide ::tk::fontchooser::Hide
         configure ::tk::fontchooser::Configure
@@ -58,18 +72,28 @@
 }
 ::tk::fontchooser::Setup
 
 proc ::tk::fontchooser::Show {} {
     variable S
+
+    Canonical
+
     if {![winfo exists $S(W)]} {
         Create
         wm transient $S(W) [winfo toplevel $S(-parent)]
         tk::PlaceWindow $S(W) widget $S(-parent)
+        if {[string trim $S(-title)] eq ""} {
+            wm title $S(W) [::msgcat::mc "Font"]
+        } else {
+            wm title $S(W) $S(-title)
+        }
     }
-    set S(fonts) [lsort -dictionary [font families]]
+    set S(fonts) [lsort -dictionary -unique [font families]]
     set S(fonts,lcase) {}
-    foreach font $S(fonts) { lappend S(fonts,lcase) [string tolower $font]}
+    foreach font $S(fonts) {
+        lappend S(fonts,lcase) [string tolower $font]
+    }
     wm deiconify $S(W)
 }
 
 proc ::tk::fontchooser::Hide {} {
     variable S
@@ -89,14 +113,14 @@
     if {[llength $args] == 0} {
         set result {}
         foreach spec $specs {
             foreach {name xx yy default} $spec break
             lappend result $name \
-                [expr {[info exists S($name)] ? $S($name) : $default}]
+                    [expr {[info exists S($name)] ? $S($name) : $default}]
         }
         lappend result -visible \
-            [expr {[winfo exists $S(W)] && [winfo ismapped $S(W)]}]
+                [expr {[winfo exists $S(W)] && [winfo ismapped $S(W)]}]
         return $result
     }
     if {[llength $args] == 1} {
         set option [lindex $args 0]
         if {[string equal $option "-visible"]} {
@@ -103,29 +127,36 @@
             return [expr {[winfo exists $S(W)] && [winfo ismapped $S(W)]}]
         } elseif {[info exists S($option)]} {
             return $S($option)
         }
         return -code error -errorcode [list TK LOOKUP OPTION $option] \
-	    "bad option \"$option\": must be\
-            -command, -font, -parent, -title or -visible"
+                "bad option \"$option\": must be\
+                -command, -font, -parent, -title or -visible"
     }
-
     set cache [dict create -parent $S(-parent) -title $S(-title) \
-                   -font $S(-font) -command $S(-command)]
-    set r [tclParseConfigSpec [namespace which -variable S] $specs "" $args]
+            -font $S(-font) -command $S(-command)]
+    set r [tclParseConfigSpec [namespace which -variable S] $specs DONTSETDEFAULTS $args]
     if {![winfo exists $S(-parent)]} {
-	set code [list TK LOOKUP WINDOW $S(-parent)]
+        set code [list TK LOOKUP WINDOW $S(-parent)]
         set err "bad window path name \"$S(-parent)\""
         array set S $cache
         return -code error -errorcode $code $err
     }
-    if {[string trim $S(-title)] eq ""} {
-        set S(-title) [::msgcat::mc "Font"]
-    }
-    if {[winfo exists $S(W)] && ("-font" in $args)} {
-	Init $S(-font)
-	event generate $S(-parent) <<TkFontchooserFontChanged>>
+
+    if {[winfo exists $S(W)]} {
+        if {{-font} in $args} {
+            Init $S(-font)
+            event generate $S(-parent) <<TkFontchooserFontChanged>>
+        }
+
+        if {[string trim $S(-title)] eq {}} {
+            wm title $S(W) [::msgcat::mc Font]
+        } else {
+            wm title $S(W) $S(-title)
+        }
+        $S(W).ok configure -state $S(nstate)
+        $S(W).apply configure -state $S(nstate)
     }
     return $r
 }
 
 proc ::tk::fontchooser::Create {} {
@@ -138,11 +169,13 @@
     }
 
     # Now build the dialog
     if {![winfo exists $S(W)]} {
         toplevel $S(W) -class TkFontDialog
-        if {[package provide tcltest] ne {}} {set ::tk_dialog $S(W)}
+        if {[package provide tcltest] ne {}} {
+            set ::tk_dialog $S(W)
+        }
         wm withdraw $S(W)
         wm title $S(W) $S(-title)
         wm transient $S(W) [winfo toplevel $S(-parent)]
 
         set scaling [tk scaling]
@@ -151,60 +184,62 @@
         set outer [::ttk::frame $S(W).outer -padding {10 10}]
         ::tk::AmpWidget ::ttk::label $S(W).font -text [::msgcat::mc "&Font:"]
         ::tk::AmpWidget ::ttk::label $S(W).style -text [::msgcat::mc "Font st&yle:"]
         ::tk::AmpWidget ::ttk::label $S(W).size -text [::msgcat::mc "&Size:"] -width $sizeWidth
         ttk::entry $S(W).efont -width 18 \
-            -textvariable [namespace which -variable S](font)
+                -textvariable [namespace which -variable S](font)
         ttk::entry $S(W).estyle -width 10 \
-            -textvariable [namespace which -variable S](style)
+                -textvariable [namespace which -variable S](style)
         ttk::entry $S(W).esize -textvariable [namespace which -variable S](size) \
-            -width 3 -validate key -validatecommand {string is double %P}
+                -width 3 -validate key -validatecommand {regexp -- {^-*[0-9]*$} %P}
 
         ttk_slistbox $S(W).lfonts -height 7 -exportselection 0 \
-            -selectmode browse -activestyle none \
-            -listvariable [namespace which -variable S](fonts)
+                -selectmode browse -activestyle none \
+                -listvariable [namespace which -variable S](fonts)
         ttk_slistbox $S(W).lstyles -width 5 -height 7 -exportselection 0 \
-            -selectmode browse -activestyle none \
-            -listvariable [namespace which -variable S](styles)
+                -selectmode browse -activestyle none \
+                -listvariable [namespace which -variable S](styles)
         ttk_slistbox $S(W).lsizes -width 4 -height 7 -exportselection 0 \
-            -selectmode browse -activestyle none \
-            -listvariable [namespace which -variable S](sizes)
+                -selectmode browse -activestyle none \
+                -listvariable [namespace which -variable S](sizes)
 
         set WE $S(W).effects
         ::ttk::labelframe $WE -text [::msgcat::mc "Effects"]
         ::tk::AmpWidget ::ttk::checkbutton $WE.strike \
-            -variable [namespace which -variable S](strike) \
-            -text [::msgcat::mc "Stri&keout"] \
-            -command [namespace code [list Click strike]]
+                -variable [namespace which -variable S](strike) \
+                -text [::msgcat::mc "Stri&keout"] \
+                -command [namespace code [list Click strike]]
         ::tk::AmpWidget ::ttk::checkbutton $WE.under \
-            -variable [namespace which -variable S](under) \
-            -text [::msgcat::mc "&Underline"] \
-            -command [namespace code [list Click under]]
+                -variable [namespace which -variable S](under) \
+                -text [::msgcat::mc "&Underline"] \
+                -command [namespace code [list Click under]]
 
         set bbox [::ttk::frame $S(W).bbox]
         ::ttk::button $S(W).ok -text [::msgcat::mc OK] -default active\
-            -command [namespace code [list Done 1]]
+                -command [namespace code [list Done 1]]
         ::ttk::button $S(W).cancel -text [::msgcat::mc Cancel] \
-            -command [namespace code [list Done 0]]
+                -command [namespace code [list Done 0]]
         ::tk::AmpWidget ::ttk::button $S(W).apply -text [::msgcat::mc "&Apply"] \
-            -command [namespace code [list Apply]]
+                -command [namespace code [list Apply]]
         wm protocol $S(W) WM_DELETE_WINDOW [namespace code [list Done 0]]
 
         # Calculate minimum sizes
         ttk::scrollbar $S(W).tmpvs
         set scroll_width [winfo reqwidth $S(W).tmpvs]
         destroy $S(W).tmpvs
         set minsize(gap) 10
         set minsize(bbox) [winfo reqwidth $S(W).ok]
         set minsize(fonts) \
-            [expr {[font measure TkDefaultFont "Helvetica"] + $scroll_width}]
+                [expr {[font measure TkDefaultFont "Helvetica"] + $scroll_width}]
         set minsize(styles) \
-            [expr {[font measure TkDefaultFont "Bold Italic"] + $scroll_width}]
+                [expr {[font measure TkDefaultFont "Bold Italic"] + $scroll_width}]
         set minsize(sizes) \
-            [expr {[font measure TkDefaultFont "-99"] + $scroll_width}]
+                [expr {[font measure TkDefaultFont "-99"] + $scroll_width}]
         set min [expr {$minsize(gap) * 4}]
-        foreach {what width} [array get minsize] {incr min $width}
+        foreach {what width} [array get minsize] {
+            incr min $width
+        }
         wm minsize $S(W) $min 260
 
         bind $S(W) <Return> [namespace code [list Done 1]]
         bind $S(W) <Escape> [namespace code [list Done 0]]
         bind $S(W) <Map> [namespace code [list Visibility %W 1]]
@@ -222,22 +257,20 @@
         bind $WE.under <<AltUnderlined>> [list $WE.under invoke]
 
         set WS $S(W).sample
         ::ttk::labelframe $WS -text [::msgcat::mc "Sample"]
         ::ttk::label $WS.sample -relief sunken -anchor center \
-            -textvariable [namespace which -variable S](sampletext)
+                -textvariable [namespace which -variable S](sampletext)
         set S(sample) $WS.sample
         grid $WS.sample -sticky news -padx 6 -pady 4
         grid rowconfigure $WS 0 -weight 1
         grid columnconfigure $WS 0 -weight 1
         grid propagate $WS 0
 
         grid $S(W).ok     -in $bbox -sticky new -pady {0 2}
         grid $S(W).cancel -in $bbox -sticky new -pady 2
-        if {$S(-command) ne ""} {
-            grid $S(W).apply -in $bbox -sticky new -pady 2
-        }
+        grid $S(W).apply  -in $bbox -sticky new -pady 2
         grid columnconfigure $bbox 0 -weight 1
 
         grid $WE.strike -sticky w -padx 10
         grid $WE.under -sticky w -padx 10 -pady {0 30}
         grid columnconfigure $WE 1 -weight 1
@@ -245,10 +278,11 @@
         grid $S(W).font   x $S(W).style   x $S(W).size   x       -in $outer -sticky w
         grid $S(W).efont  x $S(W).estyle  x $S(W).esize  x $bbox -in $outer -sticky ew
         grid $S(W).lfonts x $S(W).lstyles x $S(W).lsizes x ^     -in $outer -sticky news
         grid $WE          x $WS           - -            x ^     -in $outer -sticky news -pady {15 30}
         grid configure $bbox -sticky n
+        grid rowconfigure $outer 2 -weight 1
         grid columnconfigure $outer {1 3 5} -minsize $minsize(gap)
         grid columnconfigure $outer {0 2 4} -weight 1
         grid columnconfigure $outer 0 -minsize $minsize(fonts)
         grid columnconfigure $outer 2 -minsize $minsize(styles)
         grid columnconfigure $outer 4 -minsize $minsize(sizes)
@@ -259,18 +293,22 @@
         grid columnconfigure $S(W) 0 -weight 1
 
         Init $S(-font)
 
         trace add variable [namespace which -variable S](size) \
-            write [namespace code [list Tracer]]
+                write [namespace code [list Tracer]]
         trace add variable [namespace which -variable S](style) \
-            write [namespace code [list Tracer]]
+                write [namespace code [list Tracer]]
         trace add variable [namespace which -variable S](font) \
-            write [namespace code [list Tracer]]
-    } else {
-        Init $S(-font)
+                write [namespace code [list Tracer]]
+        trace add variable [namespace which -variable S](strike) \
+                write [namespace code [list Tracer]]
+        trace add variable [namespace which -variable S](under) \
+                write [namespace code [list Tracer]]
     }
+
+    Init $S(-font)
 
     return
 }
 
 # ::tk::fontchooser::Done --
@@ -287,13 +325,18 @@
         set S(result) ""
     }
     trace vdelete S(size) w [namespace code [list Tracer]]
     trace vdelete S(style) w [namespace code [list Tracer]]
     trace vdelete S(font) w [namespace code [list Tracer]]
+    trace vdelete S(strike) w [namespace code [list Tracer]]
+    trace vdelete S(under) w [namespace code [list Tracer]]
     destroy $S(W)
-    if {$ok && $S(-command) ne ""} {
-        uplevel #0 $S(-command) [list $S(result)]
+    if {$ok} {
+        if {$S(-command) ne ""} {
+            uplevel #0 $S(-command) [list $S(result)]
+        }
+        event generate $S(-parent) <<TkFontchooserFontChanged>>
     }
 }
 
 # ::tk::fontchooser::Apply --
 #
@@ -319,33 +362,30 @@
 #
 proc ::tk::fontchooser::Init {{defaultFont ""}} {
     variable S
 
     if {$S(first) || $defaultFont ne ""} {
+        Canonical
         if {$defaultFont eq ""} {
             set defaultFont [[entry .___e] cget -font]
             destroy .___e
         }
         array set F [font actual $defaultFont]
         set S(font) $F(-family)
+        set S(style) [::msgcat::mc "Regular"]
         set S(size) $F(-size)
         set S(strike) $F(-overstrike)
         set S(under) $F(-underline)
-        set S(style) [::msgcat::mc "Regular"]
         if {$F(-weight) eq "bold" && $F(-slant) eq "italic"} {
             set S(style) [::msgcat::mc "Bold Italic"]
         } elseif {$F(-weight) eq "bold"} {
             set S(style) [::msgcat::mc "Bold"]
         } elseif {$F(-slant) eq "italic"} {
             set S(style) [::msgcat::mc "Italic"]
         }
-
         set S(first) 0
     }
-
-    Tracer a b c
-    Update
 }
 
 # ::tk::fontchooser::Click --
 #
 #       Handles all button clicks, updating the appropriate widgets
@@ -353,19 +393,17 @@
 # Arguments:
 #       who             which widget got pressed
 #
 proc ::tk::fontchooser::Click {who} {
     variable S
-
     if {$who eq "font"} {
         set S(font) [$S(W).lfonts get [$S(W).lfonts curselection]]
     } elseif {$who eq "style"} {
         set S(style) [$S(W).lstyles get [$S(W).lstyles curselection]]
     } elseif {$who eq "size"} {
         set S(size) [$S(W).lsizes get [$S(W).lsizes curselection]]
     }
-    Update
 }
 
 # ::tk::fontchooser::Tracer --
 #
 #       Handles traces on key variables, updating the appropriate widgets
@@ -373,36 +411,47 @@
 # Arguments:
 #       standard trace arguments (not used)
 #
 proc ::tk::fontchooser::Tracer {var1 var2 op} {
     variable S
-
-    set bad 0
-    set nstate normal
-    # Make selection in each listbox
-    foreach var {font style size} {
-        set value [string tolower $S($var)]
-        $S(W).l${var}s selection clear 0 end
-        set n [lsearch -exact $S(${var}s,lcase) $value]
-        $S(W).l${var}s selection set $n
-        if {$n >= 0} {
-            set S($var) [lindex $S(${var}s) $n]
-            $S(W).e$var icursor end
-            $S(W).e$var selection clear
-        } else {                                ;# No match, try prefix
-            # Size is weird: valid numbers are legal but don't display
-            # unless in the font size list
-            set n [lsearch -glob $S(${var}s,lcase) "$value*"]
-            set bad 1
-            if {$var ne "size" || ! [string is double -strict $value]} {
-                set nstate disabled
-            }
-        }
-        $S(W).l${var}s see $n
-    }
-    if {!$bad} {Update}
-    $S(W).ok configure -state $nstate
+    # We don't need to process strike and under
+    if {$var2 ni [list strike under]} {
+        # Make selection in listbox
+        set value [string tolower $S($var2)]
+        $S(W).l${var2}s selection clear 0 end
+        set n [lsearch -exact $S(${var2}s,lcase) $value]
+        $S(W).l${var2}s selection set $n
+        if {$n >= 0} {
+            set S($var2) [lindex $S(${var2}s) $n]
+            $S(W).e$var2 icursor end
+            $S(W).e$var2 selection clear
+            if {[set i [lsearch $S(bad) $var2]] >= 0} {
+                set S(bad) [lreplace $S(bad) $i $i]
+            }
+        } else {
+            # No match, try prefix
+            set n [lsearch -glob $S(${var2}s,lcase) "$value*"]
+            if {$var2 ne "size" || !([regexp -- {^(-[0-9]+|[0-9]+)$} $value] && $value >= -4096 && $value <= 4096)} {
+                 if {[lsearch $S(bad) $var2] < 0} {
+                     lappend S(bad) $var2
+                 }
+            } else {
+                if {[set i [lsearch $S(bad) $var2]] >= 0} {
+                    set S(bad) [lreplace $S(bad) $i $i]
+                }
+            }
+        }
+        $S(W).l${var2}s see $n
+    }
+    if {[llength $S(bad)] == 0} {
+        set S(nstate) normal
+        Update
+    } else {
+        set S(nstate) disabled
+    }
+    $S(W).ok configure -state $S(nstate)
+    $S(W).apply configure -state $S(nstate)
 }
 
 # ::tk::fontchooser::Update --
 #
 #       Shows a sample of the currently selected font
@@ -409,17 +458,28 @@
 #
 proc ::tk::fontchooser::Update {} {
     variable S
 
     set S(result) [list $S(font) $S(size)]
-    if {$S(style) eq [::msgcat::mc "Bold"]} {lappend S(result) bold}
-    if {$S(style) eq [::msgcat::mc "Italic"]} {lappend S(result) italic}
-    if {$S(style) eq [::msgcat::mc "Bold Italic"]} {lappend S(result) bold italic}
-    if {$S(strike)} {lappend S(result) overstrike}
-    if {$S(under)} {lappend S(result) underline}
+    if {$S(style) eq [::msgcat::mc "Bold"]} {
+        lappend S(result) bold
+    }
+    if {$S(style) eq [::msgcat::mc "Italic"]} {
+        lappend S(result) italic
+    }
+    if {$S(style) eq [::msgcat::mc "Bold Italic"]} {
+        lappend S(result) bold italic
+    }
+    if {$S(strike)} {
+        lappend S(result) overstrike
+    }
+    if {$S(under)} {
+        lappend S(result) underline
+    }
 
     $S(sample) configure -font $S(result)
+    set S(-font) $S(result)
 }
 
 # ::tk::fontchooser::Visibility --
 #
 #	Notify the parent when the dialog visibility changes
@@ -429,11 +489,11 @@
     if {$w eq $S(W)} {
         event generate $S(-parent) <<TkFontchooserVisibility>>
     }
 }
 
-# ::tk::fontchooser::ttk_listbox --
+# ::tk::fontchooser::ttk_slistbox --
 #
 #	Create a properly themed scrolled listbox.
 #	This is exactly right on XP but may need adjusting on other platforms.
 #
 proc ::tk::fontchooser::ttk_slistbox {w args} {

ADDED   library/iconbadges.tcl
Index: library/iconbadges.tcl
==================================================================
--- /dev/null
+++ library/iconbadges.tcl
@@ -0,0 +1,254 @@
+# iconbadges.tcl --
+#
+#	Notification badges for Tk applications.
+#
+#
+# Copyright © 2021 Kevin Walzer/WordTech Communications LLC
+
+namespace eval ::tk::icons {}
+
+image create photo ::tk::icons::1-badge -data {
+    iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh
+    BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA
+    kFBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/
+    AAD/AAD/AAD/AAD/HBz/V1f/Rkb/BQX/Dw//oKD/////y8v/Bgb/Pz//ra3/+/v/
+    zMz/Li7/5ub/+vr/8fH/Ly//uLj/Zmb/n5//Bwf/Dg7/kpL/YWH/rq7/h4f/Cgr/
+    AQH/AgLXmjE+AAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34AAAABYktHRBib
+    aYUeAAAAnElEQVQY022Q5w6DMBCD78hi03RQuvegg77/25ULCakq/MenT4piGwAQ
+    A8aFlIKzABGAiAojbRSFihhinOheSdwyVKn+UaoQsry7x5PpjDzPgBWGlPNqUdJR
+    MODky9V6U20N0hwE2W5/ODokQJKdzperQ7JDt7uuPRL299o/5P+IuxA9akO4qI/n
+    622jukLNp3GFBmoPjOMnHNkJv3kDExXHctm+AAAAJXRFWHRkYXRlOmNyZWF0ZQAy
+    MDIxLTA4LTEwVDA4OjM1OjE0LTA0OjAw0aX6GwAAACV0RVh0ZGF0ZTptb2RpZnkA
+    MjAyMS0wOC0xMFQwODozNToxNC0wNDowMKD4QqcAAAAASUVORK5CYII=
+}
+image create photo ::tk::icons::2-badge -data {
+    iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh
+    BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA
+    21BMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/
+    AAD/AAD/AAD/AAD/Cwv/ODj/UlL/UFD/MjL/CAj/ExP/oKD/8fH//v7//f3/7u7/
+    kJD/DAz/ZWX/9fX/jIz/lpb/+vr/9/f/TEz/TU3/m5v/iYn/Ly//6+v/////YmL/
+    nJz/5OT/MDD/KSn/srL/7Oz/ZGT/AQH/Nzf/zs7/zc3/SUn/AgL/ICD/ysr/7e3/
+    gYH/VVX/WVn/Kir/fX3/eXn/AwP/dnb/rKz/qan/q6vjChO4AAAAEXRSTlMAAA5V
+    q9/4NK/0St3cDa7z4Pnet34AAAABYktHRCy63XGrAAAAwElEQVQY021Q1xLCMAxz
+    uktpS9hQoOwZ9t57/P8XUSesB/RinXz2SQIAQiRZUTVNVWSJEABUdMOkHKaho0ZI
+    yKIfWKFAI3qY/iCsE7AdZNFYPJFMIXNskN1gpjNZL5cv+AF1ZVBwVfRK5Uq1Vkeu
+    gIqj0Wz57Q7rIldBe/1N91h/gER7S8ORN55MhcQP6WzOFssVFYf8/XrDtrv94Sje
+    cxMnxnEWJtDq5Xq7B3gkhFUeaCUwFYH+xP5TzrfCyKvCJ3EzGUFH/1QDAAAAJXRF
+    WHRkYXRlOmNyZWF0ZQAyMDIxLTA4LTEwVDA4OjM1OjE0LTA0OjAw0aX6GwAAACV0
+    RVh0ZGF0ZTptb2RpZnkAMjAyMS0wOC0xMFQwODozNToxNC0wNDowMKD4QqcAAAAA
+    SUVORK5CYII=
+}
+image create photo ::tk::icons::3-badge -data {
+    iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh
+    BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA
+    +VBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/
+    AAD/AAD/AAD/AAD/CQn/NTX/UlL/Tk7/Kir/BAT/ERH/mZn/8PD/+Pj/+vr/5ub/
+    cHD/AgL/Vlb/9PT/5eX/X1//nZ3/////29v/HR3/Fhb/QED/RET/Cwv/f3//1dX/
+    Ghr/Bwf/mpr/9vb/+fn/b2//lZX/2tr//Pz/wsL/Jyf/Dg7/Bgb/MzP/c3P/XV3/
+    wMD/qqr/ExP/KSn/4+P/bm7/Q0P/6ur/vb3/x8f/19f/KCj/SEj/qan/zc3/y8v/
+    oKD/ODj/BQX/DQ3/AwON+4wDAAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34A
+    AAABYktHRCXDAckPAAAAx0lEQVQY021Q1RLCQBDbo4qW4l7ssOLu7g7//zH07oo8
+    kJfNZGczyQIAQhaOF0RR4DkLQgBEkWSrSmGVJaIhZLOrH9hthoYkh/oDh4TA6SLM
+    4/X5A0HCXE7gFGOGwpFoLJ7QDKpwwJNVMpXOZHEuTzgPAhmFYkkv40qVcAFEZlur
+    N5otysS3pLc73V6fSfRQ8wyGozges0NqP5nO5oslXjF7GmK96W53eH9gIWhU7Xg6
+    X643M6pZ6D54PN+F/tT+85zvC93mC1+z9hl5VNGhJwAAACV0RVh0ZGF0ZTpjcmVh
+    dGUAMjAyMS0wOC0xMFQwODozNToxNC0wNDowMNGl+hsAAAAldEVYdGRhdGU6bW9k
+    aWZ5ADIwMjEtMDgtMTBUMDg6MzU6MTQtMDQ6MDCg+EKnAAAAAElFTkSuQmCC
+}
+image create photo ::tk::icons::4-badge -data {
+    iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh
+    BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA
+    1VBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/
+    AAD/AAD/AAD/AAD/AgL/OTn/W1v/ODj/QED/4uL/////oaH/AQH/KSn/zs7/oqL/
+    Fhb/tbX/9PT/1NT/Cgr/l5f//Pz/h4f/fHz/dXX/+/v/trb/HBz/fX3/qKj/DAz/
+    EBD/ysr/4eH/zc3/5eX/8fH/lJT/BAT/Dw//uLj/5+f/5ub/8vL/+vr/paX/BQX/
+    HR3/JCT/ISH/iYn/sLD/Ghr/Tk7/rq7/a2vT0ZXAAAAAEXRSTlMAAA5Vq9/4NK/0
+    St3cDa7z4Pnet34AAAABYktHRBibaYUeAAAAvklEQVQY022QVRPCMBCEL1RSg5Ji
+    Ibi7W9Hi//8n0aRBHtiXvflm7mZvAQChmKJquq6pSgwhAE6wYRIh08CcIWTZ5CPb
+    ChnCDvmRgxHEE9HspdIZ7ok4KG6EsjmaZ6G7CqgRKRQpLXFEVNAEKVeqNYk00LnV
+    G81WWyJdINbp9voDOhxFiC+OJ3Q6m9PFciUW+fn1xt/6O7o/HMV5HsI7BcH5Qq83
+    JkK8o5L74ymjfh5iHpMP/Xn7TznfCpOywhdM6Ra8aC+AYwAAACV0RVh0ZGF0ZTpj
+    cmVhdGUAMjAyMS0wOC0xMFQwODozNToxNS0wNDowMHfS8a8AAAAldEVYdGRhdGU6
+    bW9kaWZ5ADIwMjEtMDgtMTBUMDg6MzU6MTUtMDQ6MDAGj0kTAAAAAElFTkSuQmCC
+}
+image create photo ::tk::icons::5-badge -data {
+    iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh
+    BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA
+    7VBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/
+    AAD/AAD/AAD/AAD/ICD/MjL/Li7/CQn/Bgb/q6v/8/P/8vL/9PT/4uL/FRX/0tL/
+    ////wsL/xcX/uLj/Jib/Kyv/6ur/8fH/aGj/XV3/SUn/Fhb/AQH/+Pj//Pz/7Oz/
+    +fn/l5f/Dg7/ODj/qan/sLD/W1v/fn7/9/f/+vr/WVn/EBD/Ghr/2dn/gID/X1//
+    oKD/EhL/5OT/Y2P/S0v/7e3/vb3/ycn/yMj/HR3/AwP/Skr/zc3/LCz/BQX/DAz/
+    AgKLBoLHAAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34AAAABYktHRB5yCiAr
+    AAAAyUlEQVQY021Q1RLDMAxzVhp1XcbYMXXMzIz//zmLk9HD9GKdzvZJAgBCbJKs
+    qKoiSzZCAFDR7A7K4bBrqBHidNEPXE6mEc1Nf+DWCOgeZD4/QyDImEcHyWAzFI5E
+    I7F4gFFDAhmXEkkzmUpnsshlUHDk8oViqVyxkCug4ihXa/VGtNlCrgqp3en2+oPh
+    SEj80AqO6WRqzsQhfz/PLJa5lbkW77mJzba225uHozDBrZ7Oncu+eaXC6ivQrXV/
+    vAP9if2nnG+F3leFT2jDGOnV8F/uAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIxLTA4
+    LTEwVDA4OjM1OjE1LTA0OjAwd9LxrwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMS0w
+    OC0xMFQwODozNToxNS0wNDowMAaPSRMAAAAASUVORK5CYII=
+}
+image create photo ::tk::icons::6-badge -data {
+    iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh
+    BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA
+    9lBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/
+    AAD/AAD/AAD/AAD/AQH/ICD/S0v/UlL/NDT/CAj/WVn/2dn/+Pj/+fn/8PD/jY3/
+    Cgr/LCz/4OD//f3/hob/cHD/5eX/1NT/NTX/bGz/////39//T0//Bwf/j4//5ub/
+    wcH/7+//4uL/f3//CQn/lpb/+/v/n5//iIj/8vL/9/f/UVH/hYX/3t7/Hx//vb3/
+    VVX/6Oj/MzP/ExP/x8f/e3v/EhL/t7f/0tL/wMD/MTH/IiL/xsb/zc3/qKj/QkL/
+    AgL/Cwv/Dg7/BQWiS7IgAAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34AAAAB
+    YktHRCi9sLWyAAAAyklEQVQY021Q1RLCQBDbowalBYq7y+FWirs7/P/PwPawB/Ky
+    mezsThIAIMTC8YIoCjxnIQQAFclq00zYrBJqhMh27QO7/NSIpGg/UCQCqgOZ2+P1
+    +QPIHCpwTlSCoXAkGos/qZMDHleJZCqdyebyyHkQcBRoMeEvecrIBRBxVGi1Vm80
+    W8hFJrWp3jG6vT6TzMMBHY4CY2qwQ/P9RJ/O5gu6ZO9NE6s13Wz14o6ZYFb3scPx
+    dHYzq69Al+vt/g70J/afcr4Vul4VPgDLCRmO3FuJegAAACV0RVh0ZGF0ZTpjcmVh
+    dGUAMjAyMS0wOC0xMFQwODozNToxNS0wNDowMHfS8a8AAAAldEVYdGRhdGU6bW9k
+    aWZ5ADIwMjEtMDgtMTBUMDg6MzU6MTUtMDQ6MDAGj0kTAAAAAElFTkSuQmCC
+}
+image create photo ::tk::icons::7-badge -data {
+    iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh
+    BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA
+    xlBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/
+    AAD/AAD/AAD/AAD/Hh7/Njb/NTX/Ghr/i4v/9/f/8/P/8vL/8fH/9PT/eHj/fHz/
+    3Nz/2Nj/19f/6Oj/////+Pj/YGD/DQ3/Fxf/FRX/IiL/trb/j4//CQn/Zmb/+/v/
+    xsb/GBj/HR3/0tL//f3/Xl7/ZGT/1dX/BAT/p6f/n5//AQH/Fhb/09P/c3P/GRn/
+    mZn/qqr/PT3/AgKXVg1iAAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34AAAAB
+    YktHRCJdZVysAAAAu0lEQVQY022Q1xKCMBBFN5LQixFR7Bp77wU7//9TJgTFB+7L
+    njmTydxdAECooGCiqgQrBYQAhNF0gyYxdE04hEyL/mKZ3CHNpn+xNQSOy6Hkl3n8
+    gKPrgOLxWamGYa3eaHL0FMDieavd6fZYfyAYAxFjOBpPpmw2F0xATf9dLFfrBNSv
+    2mx3e5oqIuHAjoEkIr+npzO7RFJhWYJeb+wuDS+RVKWP5+stFa8qF4riOFsoZ+2c
+    42QnLKYn/ADYChWCRPB9rQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0wOC0xMFQw
+    ODozNToxNS0wNDowMHfS8a8AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDgtMTBU
+    MDg6MzU6MTUtMDQ6MDAGj0kTAAAAAElFTkSuQmCC
+}
+image create photo ::tk::icons::8-badge -data {
+    iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh
+    BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA
+    6lBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/
+    AAD/AAD/AAD/AAD/Bwf/MjL/UVH/TU3/Kir/BAT/DAz/j4//7e3/+Pj/5+f/eXn/
+    BQX/Skr/9/f/7+//Z2f/fn7/+/v/6ur/MDD/UFD/4uL/Jib/QUH/9PT/NTX/EhL/
+    srL/////09P/2tr/m5v/CAj/ycn//f3/y8v/1dX/s7P/GBj/hYX/HR3/Zmb/0dH/
+    LCz/5eX/dHT/S0v/wsL/NDT/V1f/sLD/zc3/ysr/paX/RUX/AQH/Bgb/Dg7/DQ3m
+    iTf5AAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34AAAABYktHRC8j1CARAAAA
+    yklEQVQY021Q1RLCQBDbowZFSpEWh+J+xd3d/v936N5hD+QlmezsTrIAQIhLECVZ
+    lkTBRQgAOorbozN43Ap6hKhe/QOv6nhE8ek/8CkE/AFUoXAkapioAn4QNIdj8UQy
+    mUpnHKkJIOIom7PyhWKpjFoECalSrNbqDauJWgIZqdWmdod2e6hlbhn9wXBExxNu
+    scUptWfhFJ3zRXY+TheT5Yqu+XkWYmMNtkNa3fEQLGpmfziezpcrj/oqdLs/zHeh
+    P7X/POf7wuDrhU+46hlBGTVCQgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0wOC0x
+    MFQwODozNToxNS0wNDowMHfS8a8AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDgt
+    MTBUMDg6MzU6MTUtMDQ6MDAGj0kTAAAAAElFTkSuQmCC
+}
+image create photo ::tk::icons::9-badge -data {
+    iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh
+    BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA
+    8FBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/
+    AAD/AAD/AAD/AAD/DAz/OTn/U1P/R0f/HBz/AQH/Fhb/oqL/8/P/+fn/+Pj/1NT/
+    S0v/cXH/////29v/W1v/mJj/0ND/AgL/paX/np7/Ly//7e3//Pz/lZX/vr7/GBj/
+    VVX/9fX/c3P/QED/5ub//f3/19f/4OD/+/v/eXn/Pz//mZn/oaH/dXX/6Oj/Z2f/
+    Kir/cHD/enr/FRX/TU3/8PD/Ojr/Ozv/2tr/nJz/CAj/Tk7/sbH/z8//wcH/Bgb/
+    Dw//CgoJOUsyAAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34AAAABYktHRCCz
+    az2AAAAAy0lEQVQY022Q1RLCQAxFs9QovlAozuLu7u72/39D0y3yQB6SO2cmmXsD
+    AITYBFGSZUkUbIQAIFHsKjVLtSvICHE46aecDoMRxUV/yqUQcHtQ+QNaMKSj8rhB
+    8BozHInG4okkIq8AIs4US2eyLBdCLYJk9HyBFWmpXNEQSSDjqLJavdFkLdQyR+1O
+    t9cfsCFHuEj10XgynbE5XzTPL5ar9Sa+3fHzpon9rFI7sOOJmzCt5s+X6221tqxa
+    ge6Pp/4O9Cf2n+d8X+izXvgCm5cZM7QQ1AwAAAAldEVYdGRhdGU6Y3JlYXRlADIw
+    MjEtMDgtMTBUMDg6MzU6MTUtMDQ6MDB30vGvAAAAJXRFWHRkYXRlOm1vZGlmeQAy
+    MDIxLTA4LTEwVDA4OjM1OjE1LTA0OjAwBo9JEwAAAABJRU5ErkJggg==
+}
+
+image create photo ::tk::icons::9plus-badge -data {
+    iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh
+    BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAB
+    OFBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/
+    AAD/ERH/AAD/NDT/AQH/AAD/AAD/Cgr/Nzf/U1P/SUn/Hx//AQH/mJj/8fH/+fn/
+    2dn/VFT/BAT/YmL//f3/4uL/YGD/j4//IyP/GBj/xsb/xcX/Fxf/lZX/////rKz/
+    JSX/5eX/3t7/3Nz/AgL/hob/yMj/Hh7/Skr/fn7/MTH/srL/vr7/9fX/NDT/NTX/
+    39///v7/3d3/+vr/g4P/RET/9PT/+/v/8/P/R0f/OTn/lpb/pKT/c3P/4eH/dHT/
+    Dw//Pz//VVX/5ub/ExP/JCT/bW3/fX3/Ghr/QUH/Rkb/Gxv/wsL/1dX/p6f/DAz/
+    e3v/enr/Dg7/ra3/zs7/w8P/gYH/GRn/Bgb/CwuphzIHAAAAFHRSTlMAAA5Vq9/4
+    NK/0St3cDa7z8/Ou4A5hHfoAAAABYktHRCy63XGrAAAA+ElEQVQY02NgYGBkZGJm
+    YWVjY2VhZmJkZGAAibBzcIqAAScHO0iMkZGLWwQOuLmAYozsPCJIgIedkYGXT1RM
+    XEJSCibGx8vAzC8tIysrJw/kKUhKKogIMDOwKCopq6gqyamJiKhraGqJiLAwsGrr
+    6Erp6euoABUZGEoqGLEysBnrmJiayeiYW1haWVtbWdqwMbDZ2tnLOTjqODm7uNrb
+    u7q5szGwinh4enn76Pj6+QcE6gf4B7EysASHhIaFu1lHiIhEGhiGgYxnFvSxj4rW
+    iYkVEfGLi08AOYJXKCIxKTklFcmpQA+lJaRLIXsIi7exBA4iCIWhQQgAiNMk9J5+
+    e/MAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjEtMDgtMTBUMDg6MzU6MTYtMDQ6MDBG
+    OusyAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTA4LTEwVDA4OjM1OjE2LTA0OjAw
+    N2dTjgAAAABJRU5ErkJggg==
+}
+image create photo ::tk::icons::!-badge -data {
+    iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh
+    BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA
+    olBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/
+    AAD/AAD/AAD/AAD/Fhb/QED/Pj7/ExP/VVX/9PT/8PD/SUn/WFj//v7/+fn/S0v/
+    SEj/PDz/MjL/6Oj/Jyf/ICD/4+P/2Nj/Fxf/Dw//qKj/nZ3/Cgr/IyP/hIT/gYH/
+    Hh7/PT3/Ly//paX/oqL/KCj/AgL///8V6AjgAAAAEXRSTlMAAA5Vq9/4NK/0St3c
+    Da7z4Pnet34AAAABYktHRDXettlrAAAAoElEQVQY022QxxKCQBBEZ9hERkygophz
+    lv//NmF3Bz0wp1dd1V3dAwCIDuNCSsGZgwjQKMr1Un2eqxoN0Q/S9gK/1lCF6d+F
+    CiGKNfYHw5GGOAKWaBpn+URDwoAbw3RWzA1xEAYWRVYaEiANLPPV2pAkabPd7Umy
+    xsPxdCajjb9cb3eKtyXq+AeVsFWfr/eHqtKgqmoHdczueM7vhT37wi9PRRMHXNeq
+    aAAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0wOC0xMFQwODozNToxNi0wNDowMEY6
+    6zIAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDgtMTBUMDg6MzU6MTYtMDQ6MDA3
+    Z1OOAAAAAElFTkSuQmCC
+}
+
+
+if {[tk windowingsystem] eq "x11"} {
+
+    # ::tk::icons::IconBadge --
+    # This procedure creates an icon with an overlay badge on systems that
+    # do not have a native icon/badge API.
+    #
+    # Arguments:
+    # win - window name
+    # badgenumber - badge number to draw over the window icon
+
+    proc ::tk::icons::IconBadge {win badgenumber} {
+
+	variable ::tk::icons::base_icon
+
+	if {![info exists ::tk::icons::base_icon]} {
+	    return -code error "::tk::icons::base_icon($win) must be set on X11"
+	}
+
+	if {![info exists ::tk::icons::base_icon($win)]} {
+	    return -code error "::tk::icons::base_icon($win) must be set on X11"
+	}
+
+	if {[lsearch -exact [image names] $::tk::icons::base_icon($win)] <= 0} {
+	    return -code error "can't use \"$::tk::icons::base_icon($win)\" as iconphoto: not a photo image"
+	}
+
+	if {!([string is integer $badgenumber] && $badgenumber > 0)
+	        && [string match $badgenumber "!"] == 0
+	        && $badgenumber ne ""} {
+	    return -code error "can't use \"$badgenumber\" as icon badge"
+	}
+
+	wm iconphoto $win $::tk::icons::base_icon($win)
+
+	if {$badgenumber eq ""} {
+	    return
+	}
+
+	image create photo overlay
+
+	switch -glob -- $badgenumber {
+	    ! {
+		set badge ::tk::icons::!-badge
+	    }
+	    [1-9] {
+		set badge ::tk::icons::$badgenumber-badge
+	    }
+	    default {
+		set badge ::tk::icons::9plus-badge
+	    }
+
+        }
+
+	overlay copy $::tk::icons::base_icon($win)
+	overlay copy $badge -from 0 0 18 18 -to 18 0
+	wm iconphoto $win overlay
+
+    }
+}

Index: library/iconlist.tcl
==================================================================
--- library/iconlist.tcl
+++ library/iconlist.tcl
@@ -24,11 +24,11 @@
 #	<path> selection clear <first> ?<last>?
 #	<path> selection get
 #	<path> selection includes <item>
 #	<path> selection set <first> ?<last>?
 
-package require Tk
+package require tk
 
 ::tk::Megawidget create ::tk::IconList ::tk::FocusableWidget {
     variable w canvas sbar accel accelCB fill font index \
 	itemList itemsPerColumn list maxIH maxIW maxTH maxTW noScroll \
 	numItems oldX oldY options rect selected selection textList
@@ -336,12 +336,12 @@
 	    lassign $sublist iTag tTag rTag iW iH tW tH
 
 	    set i_dy [expr {($dy - $iH)/2}]
 	    set t_dy [expr {($dy - $tH)/2}]
 
-	    $canvas coords $iTag $x                    [expr {$y + $i_dy}]
-	    $canvas coords $tTag [expr {$x + $shift}]  [expr {$y + $t_dy}]
+	    $canvas coords $iTag $x [expr {$y + $i_dy}]
+	    $canvas coords $tTag [expr {$x + $shift}] [expr {$y + $t_dy}]
 	    $canvas coords $rTag $x $y [expr {$x+$dx}] [expr {$y+$dy}]
 
 	    incr y $dy
 	    if {($y + $dy) > $H} {
 		set y [expr {$pad * 1}] ; # *1 ?
@@ -454,12 +454,15 @@
 	bind $canvas <<NextLine>>	[namespace code {my UpDown  1}]
 	bind $canvas <<PrevChar>>	[namespace code {my LeftRight -1}]
 	bind $canvas <<NextChar>>	[namespace code {my LeftRight  1}]
 	bind $canvas <Return>		[namespace code {my ReturnKey}]
 	bind $canvas <Key>		[namespace code {my KeyPress %A}]
-	bind $canvas <Control-Key> ";"
-	bind $canvas <Alt-Key>	";"
+	bind $canvas <Alt-Key>		{# nothing}
+	bind $canvas <Meta-Key> 	{# nothing}
+	bind $canvas <Control-Key> 	{# nothing}
+	bind $canvas <Command-Key> 	{# nothing}
+	bind $canvas <Fn-Key>		{# nothing}
 
 	bind $canvas <FocusIn>		[namespace code {my FocusIn}]
 	bind $canvas <FocusOut>		[namespace code {my FocusOut}]
 
 	return $w

Index: library/icons.tcl
==================================================================
--- library/icons.tcl
+++ library/icons.tcl
@@ -2,11 +2,11 @@
 #
 #	A set of stock icons for use in Tk dialogs. The icons used here
 #	were provided by the Tango Desktop project which provides a
 #	unified set of high quality icons licensed under the
 #	Creative Commons Attribution Share-Alike license
-#	(http://creativecommons.org/licenses/by-sa/3.0/)
+#	(https://creativecommons.org/licenses/by-sa/3.0/)
 #
 #	See http://tango.freedesktop.org/Tango_Desktop_Project
 #
 # Copyright © 2009 Pat Thoyts <patthoyts@users.sourceforge.net>
 

Index: library/listbox.tcl
==================================================================
--- library/listbox.tcl
+++ library/listbox.tcl
@@ -3,11 +3,11 @@
 # This file defines the default bindings for Tk listbox widgets
 # and provides procedures that help in implementing those bindings.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1995 Sun Microsystems, Inc.
-# Copyright © 1998 by Scriptics Corporation.
+# Copyright © 1998 Scriptics Corporation.
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
 #--------------------------------------------------------------------------
@@ -175,20 +175,20 @@
 bind Listbox <B2-Motion> {
     %W scan dragto %x %y
 }
 
 bind Listbox <MouseWheel> {
-    tk::MouseWheel %W y %D -30.0
+    tk::MouseWheel %W y %D -40.0
 }
 bind Listbox <Option-MouseWheel> {
-    tk::MouseWheel %W y %D -3.0
+    tk::MouseWheel %W y %D -12.0
 }
 bind Listbox <Shift-MouseWheel> {
-    tk::MouseWheel %W x %D -30.0
+    tk::MouseWheel %W x %D -40.0
 }
 bind Listbox <Shift-Option-MouseWheel> {
-    tk::MouseWheel %W x %D -3.0
+    tk::MouseWheel %W x %D -12.0
 }
 
 # ::tk::ListboxBeginSelect --
 #
 # This procedure is typically invoked on button-1 presses.  It begins
@@ -246,11 +246,11 @@
 	    set Priv(listboxPrev) $el
 	    tk::FireListboxSelectEvent $w
 	}
 	extended {
 	    set i $Priv(listboxPrev)
-	    if {$i eq ""} {
+	    if {$i < 0} {
 		set i $el
 		$w selection set $el
 	    }
 	    if {[$w selection includes anchor]} {
 		$w selection clear $i $el
@@ -456,11 +456,11 @@
     if {[$w cget -selectmode] ne "extended"} {
 	return
     }
     set first [$w index anchor]
     set last $Priv(listboxPrev)
-    if {$last eq ""} {
+    if {$last < 0} {
 	# Not actually doing any selection right now
 	return
     }
     if {$first > $last} {
 	set tmp $first

Index: library/megawidget.tcl
==================================================================
--- library/megawidget.tcl
+++ library/megawidget.tcl
@@ -8,11 +8,11 @@
 #
 # See the file "license.terms" for information on usage and redistribution of
 # this file, and for a DISCLAIMER OF ALL WARRANTIES.
 #
 
-package require Tk
+package require tk
 
 ::oo::class create ::tk::Megawidget {
     superclass ::oo::class
     method unknown {w args} {
 	if {[string match .* $w]} {

Index: library/menu.tcl
==================================================================
--- library/menu.tcl
+++ library/menu.tcl
@@ -4,11 +4,11 @@
 # It also implements keyboard traversal of menus and implements a few
 # other utility procedures related to menus.
 #
 # Copyright © 1992-1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # Copyright © 2007 Daniel A. Steffen <das@users.sourceforge.net>
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 #
@@ -267,12 +267,12 @@
     set cur $Priv(postedMb)
     if {$cur ne ""} {
 	MenuUnpost {}
     }
     if {$::tk_strictMotif} {
-        set Priv(cursor) [$w cget -cursor]
-        $w configure -cursor arrow
+	set Priv(cursor) [$w cget -cursor]
+	$w configure -cursor arrow
     }
     if {[tk windowingsystem] ne "aqua"} {
 	set Priv(relief) [$w cget -relief]
 	$w configure -relief raised
     } else {
@@ -279,15 +279,15 @@
 	$w configure -state active
     }
 
     set Priv(postedMb) $w
     set Priv(focus) [focus]
-    $menu activate none
+    $menu activate {}
     GenerateMenuSelect $menu
     update idletasks
 
-    if {[catch {PostMenubuttonMenu $w $menu} msg opt]} {
+    if {[catch {PostMenubuttonMenu $w $menu $x $y} msg opt]} {
 	# Error posting menu (e.g. bogus -postcommand). Unpost it and
 	# reflect the error.
 	MenuUnpost {}
 	return -options $opt $msg
     }
@@ -341,11 +341,11 @@
 	if {$mb ne ""} {
 	    set menu [$mb cget -menu]
 	    $menu unpost
 	    set Priv(postedMb) {}
 	    if {$::tk_strictMotif} {
-	        $mb configure -cursor $Priv(cursor)
+		$mb configure -cursor $Priv(cursor)
 	    }
 	    if {[tk windowingsystem] ne "aqua"} {
 		$mb configure -relief $Priv(relief)
 	    } else {
 		$mb configure -state normal
@@ -362,12 +362,12 @@
 	    while {1} {
 		set parent [winfo parent $menu]
 		if {[winfo class $parent] ne "Menu" || ![winfo ismapped $parent]} {
 		    break
 		}
-		$parent activate none
-		$parent postcascade none
+		$parent activate {}
+		$parent postcascade {}
 		GenerateMenuSelect $parent
 		set type [$parent cget -type]
 		if {$type eq "menubar" || $type eq "tearoff"} {
 		    break
 		}
@@ -473,38 +473,40 @@
 # state -		Modifier state (tells whether buttons are down).
 
 proc ::tk::MenuMotion {menu x y state} {
     variable ::tk::Priv
     if {$menu eq $Priv(window)} {
-        set activeindex [$menu index active]
+	set activeindex [$menu index active]
 	if {[$menu cget -type] eq "menubar"} {
 	    if {[info exists Priv(focus)] && $menu ne $Priv(focus)} {
 		$menu activate @$x,$y
 		GenerateMenuSelect $menu
 	    }
 	} else {
 	    $menu activate @$x,$y
 	    GenerateMenuSelect $menu
 	}
-        set index [$menu index @$x,$y]
-        if {[info exists Priv(menuActivated)] \
-                && $index ne "none" \
-                && $index ne $activeindex} {
-            set mode [option get $menu clickToFocus ClickToFocus]
-            if {[string is false $mode]} {
-                set delay [expr {[$menu cget -type] eq "menubar" ? 0 : 50}]
-                if {[$menu type $index] eq "cascade"} {
-                    # Catch these postcascade commands since the menu could be
-                    # destroyed before they run.
-                    set Priv(menuActivatedTimer) \
-                        [after $delay "catch {$menu postcascade active}"]
-                } else {
-                    set Priv(menuDeactivatedTimer) \
-                        [after $delay "catch {$menu postcascade none}"]
-                }
-            }
-        }
+	set index [$menu index @$x,$y]
+	if {[info exists Priv(menuActivated)] \
+		&& $index >= 0 \
+		&& $index ne $activeindex} {
+	    set mode [option get $menu clickToFocus ClickToFocus]
+	    if {[string is false $mode]} {
+		set delay [expr {[$menu cget -type] eq "menubar" ? 0 : 50}]
+		if {[$menu type $index] eq "cascade"} {
+		    # Catch these postcascade commands since the menu could be
+		    # destroyed before they run.
+		    set Priv(menuActivatedTimer) \
+			[after $delay [list catch [list \
+			    $menu postcascade active]]]
+		} else {
+		    set Priv(menuDeactivatedTimer) \
+			[after $delay [list catch [list
+			    $menu postcascade {}]]]
+		}
+	    }
+	}
     }
 }
 
 # ::tk::MenuButtonDown --
 # Handles button presses in menus.  There are a couple of tricky things
@@ -523,17 +525,17 @@
 
 proc ::tk::MenuButtonDown menu {
     variable ::tk::Priv
 
     if {![winfo viewable $menu]} {
-        return
+	return
     }
-    if {[$menu index active] eq "none"} {
-        if {[$menu cget -type] ne "menubar" } {
-            set Priv(window) {}
-        }
-        return
+    if {[$menu index active] < 0} {
+	if {[$menu cget -type] ne "menubar" } {
+	    set Priv(window) {}
+	}
+	return
     }
     $menu postcascade active
     if {$Priv(postedMb) ne "" && [winfo viewable $Priv(postedMb)]} {
 	grab -global $Priv(postedMb)
     } else {
@@ -550,11 +552,11 @@
 		$menu configure -cursor arrow
 	    }
 	    if {[$menu type active] eq "cascade"} {
 		set Priv(menuActivated) 1
 	    }
-        }
+	}
 
 	# Don't update grab information if the grab window isn't changing.
 	# Otherwise, we'll get an error when we unpost the menus and
 	# restore the grab, since the old grab window will not be viewable
 	# anymore.
@@ -583,19 +585,19 @@
 # state -		Modifier state.
 
 proc ::tk::MenuLeave {menu rootx rooty state} {
     variable ::tk::Priv
     set Priv(window) {}
-    if {[$menu index active] eq "none"} {
+    if {[$menu index active] < 0} {
 	return
     }
     if {[$menu type active] eq "cascade" \
 	    && [winfo containing $rootx $rooty] eq \
 		[$menu entrycget active -menu]} {
 	return
     }
-    $menu activate none
+    $menu activate {}
     GenerateMenuSelect $menu
 }
 
 # ::tk::MenuInvoke --
 # This procedure is invoked when button 1 is released over a menu.
@@ -613,12 +615,12 @@
     if {$buttonRelease && $Priv(window) eq ""} {
 	# Mouse was pressed over a menu without a menu button, then
 	# dragged off the menu (possibly with a cascade posted) and
 	# released.  Unpost everything and quit.
 
-	$w postcascade none
-	$w activate none
+	$w postcascade {}
+	$w activate {}
 	event generate $w <<MenuSelect>>
 	MenuUnpost $w
 	return
     }
     if {[$w type active] eq "cascade"} {
@@ -627,20 +629,20 @@
 	MenuFirstEntry $menu
     } elseif {[$w type active] eq "tearoff"} {
 	::tk::TearOffMenu $w
 	MenuUnpost $w
     } elseif {[$w cget -type] eq "menubar"} {
-	$w postcascade none
+	$w postcascade {}
 	set active [$w index active]
 	set isCascade [string equal [$w type $active] "cascade"]
 
 	# Only de-activate the active item if it's a cascade; this prevents
 	# the annoying "activation flicker" you otherwise get with
 	# checkbuttons/commands/etc. on menubars
 
 	if { $isCascade } {
-	    $w activate none
+	    $w activate {}
 	    event generate $w <<MenuSelect>>
 	}
 
 	MenuUnpost $w
 
@@ -651,11 +653,11 @@
 	if { !$isCascade } {
 	    uplevel #0 [list $w invoke $active]
 	}
     } else {
 	set active [$w index active]
-	if {$Priv(popup) eq "" || $active ne "none"} {
+	if {$Priv(popup) eq "" || $active >= 0} {
 	    MenuUnpost $w
 	}
 	uplevel #0 [list $w invoke active]
     }
 }
@@ -755,15 +757,15 @@
 	}
     } else {
 	set count -1
 	set m2 [winfo parent $menu]
 	if {[winfo class $m2] eq "Menu"} {
-	    $menu activate none
+	    $menu activate {}
 	    GenerateMenuSelect $menu
 	    tk_menuSetFocus $m2
 
-	    $m2 postcascade none
+	    $m2 postcascade {}
 
 	    if {[$m2 cget -type] ne "menubar"} {
 		return
 	    }
 	}
@@ -795,11 +797,11 @@
 	}
 	set mb [lindex $buttons $i]
 	if {[winfo class $mb] eq "Menubutton" \
 		&& [$mb cget -state] ne "disabled" \
 		&& [$mb cget -menu] ne "" \
-		&& [[$mb cget -menu] index last] ne "none"} {
+		&& [[$mb cget -menu] index last] >= 0} {
 	    break
 	}
 	if {$mb eq $w} {
 	    return
 	}
@@ -817,17 +819,18 @@
 # menu -			Menu window that received the keystroke.
 # count -			1 means go to the next lower entry,
 #				-1 means go to the next higher entry.
 
 proc ::tk::MenuNextEntry {menu count} {
-    if {[$menu index last] eq "none"} {
+    set last [$menu index last]
+    if {$last < 0} {
 	return
     }
     set length [expr {[$menu index last]+1}]
     set quitAfter $length
     set active [$menu index active]
-    if {$active eq "none"} {
+    if {$active < 0} {
 	set i 0
     } else {
 	set i [expr {$active + $count}]
     }
     while {1} {
@@ -891,11 +894,11 @@
     set char [string tolower $char]
     set windowlist [winfo child $w]
 
     foreach child $windowlist {
 	# Don't descend into other toplevels.
-        if {[winfo toplevel $w] ne [winfo toplevel $child]} {
+	if {[winfo toplevel $w] ne [winfo toplevel $child]} {
 	    continue
 	}
 	if {[winfo class $child] eq "Menu" && \
 		[$child cget -type] eq "menubar"} {
 	    if {$char eq ""} {
@@ -917,11 +920,11 @@
 	}
     }
 
     foreach child $windowlist {
 	# Don't descend into other toplevels.
-        if {[winfo toplevel $w] ne [winfo toplevel $child]} {
+	if {[winfo toplevel $w] ne [winfo toplevel $child]} {
 	    continue
 	}
 	switch -- [winfo class $child] {
 	    Menubutton {
 		set char2 [string index [$child cget -text] \
@@ -1024,13 +1027,10 @@
     if {$char eq ""} {
 	return
     }
     set char [string tolower $char]
     set last [$w index last]
-    if {$last eq "none"} {
-	return
-    }
     for {set i 0} {$i <= $last} {incr i} {
 	if {[catch {set char2 [string index \
 		[$w entrycget $i -label] [$w entrycget $i -underline]]}]} {
 	    continue
 	}
@@ -1066,17 +1066,14 @@
 proc ::tk::MenuFirstEntry menu {
     if {$menu eq ""} {
 	return
     }
     tk_menuSetFocus $menu
-    if {[$menu index active] ne "none"} {
+    if {[$menu index active] >= 0} {
 	return
     }
     set last [$menu index last]
-    if {$last eq "none"} {
-	return
-    }
     for {set i 0} {$i <= $last} {incr i} {
 	if {([catch {set state [$menu entrycget $i -state]}] == 0) \
 		&& $state ne "disabled" && [$menu type $i] ne "tearoff"} {
 	    $menu activate $i
 	    GenerateMenuSelect $menu
@@ -1112,13 +1109,10 @@
     if {![regexp {^active$|^last$|^none$|^[0-9]|^@} $s]} {
 	catch {set i [$menu index $s]}
 	return $i
     }
     set last [$menu index last]
-    if {$last eq "none"} {
-	return
-    }
     for {set i 0} {$i <= $last} {incr i} {
 	if {![catch {$menu entrycget $i -label} label]} {
 	    if {$label eq $s} {
 		return $i
 	    }
@@ -1136,11 +1130,11 @@
 # entry is vertically aligned with the menubutton.  On the Mac this
 # will expose a small amount of the blue indicator on the right hand
 # side.  On other platforms the entry is centered over the button.
 
 if {[tk windowingsystem] eq "aqua"} {
-    proc ::tk::PostMenubuttonMenu {button menu} {
+    proc ::tk::PostMenubuttonMenu {button menu cx cy} {
 	set entry ""
 	if {[$button cget -indicatoron]} {
 	    set entry [MenuFindName $menu [$button cget -text]]
 	    if {$entry eq ""} {
 		set entry 0
@@ -1161,18 +1155,18 @@
 		incr x [expr {-[winfo reqwidth $menu]}]
 	    }
 	    right {
 		incr x [winfo width $button]
 	    }
-	    default {
+	    default {  # flush
 		incr x [expr {[winfo width $button] - [winfo reqwidth $menu] - 5}]
 	    }
 	}
 	PostOverPoint $menu $x $y $entry
     }
 } else {
-    proc ::tk::PostMenubuttonMenu {button menu} {
+    proc ::tk::PostMenubuttonMenu {button menu cx cy} {
 	set entry ""
 	if {[$button cget -indicatoron]} {
 	    set entry [MenuFindName $menu [$button cget -text]]
 	    if {$entry eq ""} {
 		set entry 0
@@ -1184,11 +1178,11 @@
 	    above {
 		incr y [expr {-[winfo reqheight $menu]}]
 		# if we go offscreen to the top, show as 'below'
 		if {$y < [winfo vrooty $button]} {
 		    set y [expr {[winfo vrooty $button] + [winfo rooty $button]\
-                           + [winfo reqheight $button]}]
+			   + [winfo reqheight $button]}]
 		}
 		set entry {}
 	    }
 	    below {
 		incr y [winfo height $button]
@@ -1199,26 +1193,28 @@
 			   + [winfo rooty $button] - $mh}]
 		}
 		set entry {}
 	    }
 	    left {
-		# It is not clear why this is needed.
-		if {[tk windowingsystem] eq "win32"} {
-		    incr x [expr {-4 - [winfo reqwidth $button] / 2}]
-		}
 		incr x [expr {- [winfo reqwidth $menu]}]
 	    }
 	    right {
 		incr x [expr {[winfo width $button]}]
 	    }
-	    default {
-		if {[$button cget -indicatoron]} {
-		    incr x [expr {([winfo width $button] - \
-				   [winfo reqwidth $menu])/ 2}]
-		} else {
-		    incr y [winfo height $button]
-		}
+	    default {  # flush
+                if {[$button cget -indicatoron]} {
+                    if {$cx ne ""} {
+                        set x [expr {$cx - [winfo reqwidth $menu] / 2}]
+                        set l [font metrics [$menu cget -font] -linespace]
+                        set y [expr {$cy - $l/2 - 2}]
+                    } else {
+                        incr x [expr {([winfo width $button] - \
+				[winfo reqwidth $menu])/ 2}]
+                    }
+                } else {
+                    incr y [winfo height $button]
+                }
 	    }
 	}
 	PostOverPoint $menu $x $y $entry
     }
 }
@@ -1240,11 +1236,12 @@
 
 if {[tk windowingsystem] ne "win32"} {
     proc ::tk::PostOverPoint {menu x y {entry {}}}  {
 	if {$entry ne ""} {
 	    $menu post $x $y $entry
-	    if {[$menu entrycget $entry -state] ne "disabled"} {
+	    if {[$menu type $entry] ni {separator tearoff} &&
+		[$menu entrycget $entry -state] ne "disabled"} {
 		$menu activate $entry
 		GenerateMenuSelect $menu
 	    }
 	} else {
 	    $menu post $x $y
@@ -1367,13 +1364,13 @@
     if {$Priv(popup) ne "" || $Priv(postedMb) ne ""} {
 	tk::MenuUnpost {}
     }
     tk::PostOverPoint $menu $x $y $entry
     if {[tk windowingsystem] eq "x11" && [winfo viewable $menu]} {
-        tk::SaveGrabInfo $menu
+	tk::SaveGrabInfo $menu
 	grab -global $menu
 	set Priv(popup) $menu
 	set Priv(window) $menu
 	set Priv(menuActivated) 1
 	tk_menuSetFocus $menu
     }
 }

Index: library/msgs/cs.msg
==================================================================
--- library/msgs/cs.msg
+++ library/msgs/cs.msg
@@ -72,6 +72,24 @@
     ::msgcat::mcset cs "ignore" "ignorovat"
     ::msgcat::mcset cs "ok"
     ::msgcat::mcset cs "red" "červeá"
     ::msgcat::mcset cs "retry" "znovu"
     ::msgcat::mcset cs "yes" "ano"
+}
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  cs "Print" "Tisknout"
+    ::msgcat::mcset  cs "Printer" "Tiskárna"
+    ::msgcat::mcset  cs "Letter " "Dopis "
+    ::msgcat::mcset  cs "Legal " "Legální "
+    ::msgcat::mcset  cs "A4" "A4"
+    ::msgcat::mcset  cs "Grayscale" "Stupně Šedi"
+    ::msgcat::mcset  cs "RGB" "RGB"
+    ::msgcat::mcset  cs "Options" "Možnosti"
+    ::msgcat::mcset  cs "Copies" "Kopie"
+    ::msgcat::mcset  cs "Paper" "Papír"
+    ::msgcat::mcset  cs "Scale" "Škála"
+    ::msgcat::mcset  cs "Orientation" "Orientace"
+    ::msgcat::mcset  cs "Portrait" "Portrét"
+    ::msgcat::mcset  cs "Landscape" "Krajina"
+    ::msgcat::mcset  cs "Output" "Výstup"
 }

Index: library/msgs/da.msg
==================================================================
--- library/msgs/da.msg
+++ library/msgs/da.msg
@@ -73,6 +73,24 @@
     ::msgcat::mcset da "ignore" "ignorer"
     ::msgcat::mcset da "ok"
     ::msgcat::mcset da "red" "rød"
     ::msgcat::mcset da "retry" "gentag"
     ::msgcat::mcset da "yes" "ja"
+}
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  da "Print" "Trykke"
+    ::msgcat::mcset  da "Printer" "Printer"
+    ::msgcat::mcset  da "Letter " "Brev"
+    ::msgcat::mcset  da "Legal " "Juridisk"
+    ::msgcat::mcset  da "A4" "A4"
+    ::msgcat::mcset  da "Grayscale" "Gråtoneskala"
+    ::msgcat::mcset  da "RGB" "Rgb"
+    ::msgcat::mcset  da "Options" "Indstillinger"
+    ::msgcat::mcset  da "Copies" "Kopier"
+    ::msgcat::mcset  da "Paper" "Papir"
+    ::msgcat::mcset  da "Scale" "Skalere"
+    ::msgcat::mcset  da "Orientation" "Orientering"
+    ::msgcat::mcset  da "Portrait" "Portræt"
+    ::msgcat::mcset  da "Landscape" "Landskab"
+    ::msgcat::mcset  da "Output" "Udskriv Publikation"
 }

Index: library/msgs/de.msg
==================================================================
--- library/msgs/de.msg
+++ library/msgs/de.msg
@@ -86,6 +86,24 @@
     ::msgcat::mcset de "ignore" "ignorieren"
     ::msgcat::mcset de "ok"
     ::msgcat::mcset de "red" "rot"
     ::msgcat::mcset de "retry" "wiederholen"
     ::msgcat::mcset de "yes" "ja"
+}
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  de "Print" "Drucken"
+    ::msgcat::mcset  de "Printer" "Drucker"
+    ::msgcat::mcset  de "Letter " "Brief"
+    ::msgcat::mcset  de "Legal " "Rechtlich"
+    ::msgcat::mcset  de "A4" "A4"
+    ::msgcat::mcset  de "Grayscale" "Graustufen"
+    ::msgcat::mcset  de "RGB" "Rgb"
+    ::msgcat::mcset  de "Options" "Optionen"
+    ::msgcat::mcset  de "Copies" "Kopien"
+    ::msgcat::mcset  de "Paper" "Papier"
+    ::msgcat::mcset  de "Scale" "Skala"
+    ::msgcat::mcset  de "Orientation" "Ausrichtung"
+    ::msgcat::mcset  de "Portrait" "Porträt"
+    ::msgcat::mcset  de "Landscape" "Landschaft"
+    ::msgcat::mcset  de "Output" "Ausgabe"
 }

Index: library/msgs/el.msg
==================================================================
--- library/msgs/el.msg
+++ library/msgs/el.msg
@@ -81,6 +81,24 @@
     ::msgcat::mcset el "ignore"             "αγνόηση"
     ::msgcat::mcset el "ok"                 "εντάξει"
     ::msgcat::mcset el "red"                "κόκκινο"
     ::msgcat::mcset el "retry"              "προσπάθησε ξανά"
     ::msgcat::mcset el "yes"                "ναι"
+}
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  el "Print" "Τυπώνω"
+    ::msgcat::mcset  el "Printer" "Εκτυπωτής"
+    ::msgcat::mcset  el "Letter " "Γράμμα"
+    ::msgcat::mcset  el "Legal " "Νομικός"
+    ::msgcat::mcset  el "A4" "Α4"
+    ::msgcat::mcset  el "Grayscale" "Κλίμακα Του Γκρι"
+    ::msgcat::mcset  el "RGB" "Rgb"
+    ::msgcat::mcset  el "Options" "Επιλογές"
+    ::msgcat::mcset  el "Copies" "Αντίγραφα"
+    ::msgcat::mcset  el "Paper" "Χαρτί"
+    ::msgcat::mcset  el "Scale" "Κλίμακα"
+    ::msgcat::mcset  el "Orientation" "Προσανατολισμός"
+    ::msgcat::mcset  el "Portrait" "Προσωπογραφία"
+    ::msgcat::mcset  el "Landscape" "Τοπίο"
+    ::msgcat::mcset  el "Output" "Έξοδος"
 }

Index: library/msgs/en.msg
==================================================================
--- library/msgs/en.msg
+++ library/msgs/en.msg
@@ -87,5 +87,24 @@
     ::msgcat::mcset en "ok"
     ::msgcat::mcset en "red"
     ::msgcat::mcset en "retry"
     ::msgcat::mcset en "yes"
 }
+
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  en "Print"
+    ::msgcat::mcset  en "Printer"
+    ::msgcat::mcset  en "Letter "
+    ::msgcat::mcset  en "Legal "
+    ::msgcat::mcset  en "A4"
+    ::msgcat::mcset  en "Grayscale"
+    ::msgcat::mcset  en "RGB"
+    ::msgcat::mcset  en "Options"
+    ::msgcat::mcset  en "Copies"
+    ::msgcat::mcset  en "Paper"
+    ::msgcat::mcset  en "Scale"
+    ::msgcat::mcset  en "Orientation"
+    ::msgcat::mcset  en "Portrait"
+    ::msgcat::mcset  en "Landscape"
+    ::msgcat::mcset  en "Output"
+}

Index: library/msgs/eo.msg
==================================================================
--- library/msgs/eo.msg
+++ library/msgs/eo.msg
@@ -1,75 +1,93 @@
 namespace eval ::tk {
-    ::msgcat::mcset eo "&Abort" "&Ĉesigo"
+    ::msgcat::mcset eo "&Abort" "&Ĉesigu"
     ::msgcat::mcset eo "&About..." "Pri..."
-    ::msgcat::mcset eo "All Files" "Ĉioj dosieroj"
-    ::msgcat::mcset eo "Application Error" "Aplikoerraro"
+    ::msgcat::mcset eo "All Files" "Ĉiuj dosieroj"
+    ::msgcat::mcset eo "Application Error" "Aplikoeraro"
     ::msgcat::mcset eo "&Blue" "&Blua"
     ::msgcat::mcset eo "Cancel" "Rezignu"
     ::msgcat::mcset eo "&Cancel" "&Rezignu"
-    ::msgcat::mcset eo "Cannot change to the directory \"%1\$s\".\nPermission denied." "Neeble ĉangi al dosierulon \"%1\$s\".\nVi ne rajtas tion."
-    ::msgcat::mcset eo "Choose Directory" "Elektu Dosierujo"
-    ::msgcat::mcset eo "Cl&ear" "&Klaru"
-    ::msgcat::mcset eo "&Clear Console" "&Klaru konzolon"
-    ::msgcat::mcset eo "Color" "Farbo"
+    ::msgcat::mcset eo "Cannot change to the directory \"%1\$s\".\nPermission denied." "Neeble ŝanĝi al dosierujo \"%1\$s\".\nVi ne rajtas tion."
+    ::msgcat::mcset eo "Choose Directory" "Elektu Dosierujon"
+    ::msgcat::mcset eo "Cl&ear" "&Vakigu"
+    ::msgcat::mcset eo "&Clear Console" "&Vakigu konzolon"
+    ::msgcat::mcset eo "Color" "Koloro"
     ::msgcat::mcset eo "Console" "Konzolo"
     ::msgcat::mcset eo "&Copy" "&Kopiu"
-    ::msgcat::mcset eo "Cu&t" "&Enpoŝigu"
-    ::msgcat::mcset eo "&Delete" "&Forprenu"
+    ::msgcat::mcset eo "Cu&t" "&Eltondu"
+    ::msgcat::mcset eo "&Delete" "&Forigu"
     ::msgcat::mcset eo "Details >>" "Detaloj >>"
     ::msgcat::mcset eo "Directory \"%1\$s\" does not exist." "La dosierujo \"%1\$s\" ne ekzistas."
     ::msgcat::mcset eo "&Directory:" "&Dosierujo:"
     ::msgcat::mcset eo "&Edit" "&Redaktu"
     ::msgcat::mcset eo "Error: %1\$s" "Eraro: %1\$s"
     ::msgcat::mcset eo "E&xit" "&Eliru"
     ::msgcat::mcset eo "&File" "&Dosiero"
-    ::msgcat::mcset eo "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "La dosiero \"%1\$s\" jam ekzistas.\nĈu vi volas anstataûigi la dosieron?"
-    ::msgcat::mcset eo "File \"%1\$s\" already exists.\n\n" "La dosiero \"%1\$s\" jam egzistas. \n\n"
-    ::msgcat::mcset eo "File \"%1\$s\" does not exist." "La dosierp \"%1\$s\" ne estas."
+    ::msgcat::mcset eo "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "La dosiero \"%1\$s\" jam ekzistas.\nĈu vi volas anstataŭigi la dosieron?"
+    ::msgcat::mcset eo "File \"%1\$s\" already exists.\n\n" "La dosiero \"%1\$s\" jam ekzistas. \n\n"
+    ::msgcat::mcset eo "File \"%1\$s\" does not exist." "La dosiero \"%1\$s\" ne ekzistas."
     ::msgcat::mcset eo "File &name:" "Dosiero&nomo:"
     ::msgcat::mcset eo "File &names:" "Dosiero&nomoj:"
-    ::msgcat::mcset eo "Files of &type:" "Dosieroj de &Typo:"
+    ::msgcat::mcset eo "Files of &type:" "Dosieroj de &Tipo:"
     ::msgcat::mcset eo "Fi&les:" "Do&sieroj:"
     ::msgcat::mcset eo "&Filter" "&Filtrilo"
     ::msgcat::mcset eo "Fil&ter:" "&Filtrilo:"
     ::msgcat::mcset eo "&Green" "&Verda"
     ::msgcat::mcset eo "&Help" "&Helpu"
     ::msgcat::mcset eo "Hi" "Saluton"
     ::msgcat::mcset eo "&Hide Console" "&Kaŝu konzolon"
     ::msgcat::mcset eo "&Ignore" "&Ignoru"
     ::msgcat::mcset eo "Invalid file name \"%1\$s\"." "Malvalida dosieronomo \"%1\$s\"."
-    ::msgcat::mcset eo "Log Files" "Protokolo"
+    ::msgcat::mcset eo "Log Files" "Protokolaj dosieroj"
     ::msgcat::mcset eo "&No" "&Ne"
-    ::msgcat::mcset eo "&OK"
-    ::msgcat::mcset eo "OK"
-    ::msgcat::mcset eo "Ok"
+    ::msgcat::mcset eo "&OK" "&Bone"
+    ::msgcat::mcset eo "OK" "Bone"
+    ::msgcat::mcset eo "Ok" "Bone"
     ::msgcat::mcset eo "Open" "Malfermu"
     ::msgcat::mcset eo "&Open" "&Malfermu"
-    ::msgcat::mcset eo "Open Multiple Files" "Melfermu multan dosierojn"
-    ::msgcat::mcset eo "P&aste" "&Elpoŝigi"
-    ::msgcat::mcset eo "&Quit" "&Finigu"
-    ::msgcat::mcset eo "&Red" "&Rosa"
-    ::msgcat::mcset eo "Replace existing file?" "Ĉu anstataûu ekzistantan dosieron?"
-    ::msgcat::mcset eo "&Retry" "&Ripetu"
-    ::msgcat::mcset eo "&Save" "&Savu"
-    ::msgcat::mcset eo "Save As" "Savu kiel"
-    ::msgcat::mcset eo "Save To Log" "Savu en protokolon"
+    ::msgcat::mcset eo "Open Multiple Files" "Malfermu plurajn dosierojn"
+    ::msgcat::mcset eo "P&aste" "&Algluu"
+    ::msgcat::mcset eo "&Quit" "&Forlasu"
+    ::msgcat::mcset eo "&Red" "&Ruĝa"
+    ::msgcat::mcset eo "Replace existing file?" "Ĉu anstataŭigi ekzistantan dosieron?"
+    ::msgcat::mcset eo "&Retry" "&Reprovu"
+    ::msgcat::mcset eo "&Save" "&Konservu"
+    ::msgcat::mcset eo "Save As" "Konservu kiel"
+    ::msgcat::mcset eo "Save To Log" "Konservu en protokolon"
     ::msgcat::mcset eo "Select Log File" "Elektu prokolodosieron"
     ::msgcat::mcset eo "Select a file to source" "Elektu dosieron por interpreti"
     ::msgcat::mcset eo "&Selection:" "&Elekto:"
-    ::msgcat::mcset eo "Skip Messages" "transsaltu pluajn mesaĝojn"
+    ::msgcat::mcset eo "Skip Messages" "transsaltu mesaĝojn"
     ::msgcat::mcset eo "&Source..." "&Fontoprogramo..."
     ::msgcat::mcset eo "Tcl Scripts" "Tcl-skriptoj"
-    ::msgcat::mcset eo "Tcl for Windows" "Tcl por vindoso"
-    ::msgcat::mcset eo "Text Files" "Tekstodosierojn"
+    ::msgcat::mcset eo "Tcl for Windows" "Tcl por Vindozo"
+    ::msgcat::mcset eo "Text Files" "Tekstodosieroj"
     ::msgcat::mcset eo "&Yes" "&Jes"
-    ::msgcat::mcset eo "abort" "ĉesigo"
+    ::msgcat::mcset eo "abort" "ĉesigu"
     ::msgcat::mcset eo "blue" "blua"
     ::msgcat::mcset eo "cancel" "rezignu"
-    ::msgcat::mcset eo "extension" "ekspansio"
-    ::msgcat::mcset eo "extensions" "ekspansioj"
+    ::msgcat::mcset eo "extension" "kromprogramo"
+    ::msgcat::mcset eo "extensions" "kromprogramoj"
     ::msgcat::mcset eo "green" "verda"
-    ::msgcat::mcset eo "ignore" "ignorieren"
+    ::msgcat::mcset eo "ignore" "ignoru"
     ::msgcat::mcset eo "red" "ruĝa"
-    ::msgcat::mcset eo "retry" "ripetu"
+    ::msgcat::mcset eo "retry" "reprovu"
     ::msgcat::mcset eo "yes" "jes"
+}
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  eo "Print" "Presi"
+    ::msgcat::mcset  eo "Printer" "Presilo"
+    ::msgcat::mcset  eo "Letter " "Letero"
+    ::msgcat::mcset  eo "Legal " "Laŭleĝa"
+    ::msgcat::mcset  eo "A4" "A4"
+    ::msgcat::mcset  eo "Grayscale" "Grizskalo"
+    ::msgcat::mcset  eo "RGB" "RGB"
+    ::msgcat::mcset  eo "Options" "Opcioj"
+    ::msgcat::mcset  eo "Copies" "Kopioj"
+    ::msgcat::mcset  eo "Paper" "Papero"
+    ::msgcat::mcset  eo "Scale" "Skalo"
+    ::msgcat::mcset  eo "Orientation" "Orientiĝo"
+    ::msgcat::mcset  eo "Portrait" "Portreto"
+    ::msgcat::mcset  eo "Landscape" "Pejzaĝo"
+    ::msgcat::mcset  eo "Output" "Eligo"
 }

Index: library/msgs/es.msg
==================================================================
--- library/msgs/es.msg
+++ library/msgs/es.msg
@@ -71,6 +71,24 @@
     ::msgcat::mcset es "ignore" "ignorar"
     ::msgcat::mcset es "ok"
     ::msgcat::mcset es "red" "rojo"
     ::msgcat::mcset es "retry" "reintentar"
     ::msgcat::mcset es "yes" "sí"
+}
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+	::msgcat::mcset  es "Print" "Imprimir"
+	::msgcat::mcset  es "Printer" "Impresora"
+	::msgcat::mcset  es "Letter" "Carta"
+	::msgcat::mcset  es "Legal" "Legal"
+	::msgcat::mcset  es "A4" "A4"
+	::msgcat::mcset  es "Grayscale" "Escala De Grises"
+	::msgcat::mcset  es "RGB" "Color"
+	::msgcat::mcset  es "Options" "Opciones"
+	::msgcat::mcset  es "Copies" "Copias"
+	::msgcat::mcset  es "Paper" "Papel"
+	::msgcat::mcset  es "Scale" "Escala"
+	::msgcat::mcset  es "Orientation" "Orientación"
+	::msgcat::mcset  es "Portrait" "Retrato"
+	::msgcat::mcset  es "Landscape" "Paisaje"
+	::msgcat::mcset  es "Output" "Salida"
 }

ADDED   library/msgs/fi.msg
Index: library/msgs/fi.msg
==================================================================
--- /dev/null
+++ library/msgs/fi.msg
@@ -0,0 +1,114 @@
+namespace eval ::tk {
+    ::msgcat::mcset fi "AaBbYyZz01" "AaBbÄäÖö01"
+    ::msgcat::mcset fi "&Abort" "&Keskeytä"
+    ::msgcat::mcset fi "&About..." "&Tietoja..."
+    ::msgcat::mcset fi "All Files" "Kaikki tiedostot"
+    ::msgcat::mcset fi "&Apply" "Kä&ytä"
+    ::msgcat::mcset fi "Application Error" "Ohjelmavirhe"
+    ::msgcat::mcset fi "&Blue" "&Sininen"
+    ::msgcat::mcset fi "Bold" "Lihavoitu"
+    ::msgcat::mcset fi "Bold Italic" "Lihavoitu, kursivoitu"
+    ::msgcat::mcset fi "Cancel" "Peruuta"
+    ::msgcat::mcset fi "&Cancel" "&Peruuta"
+    ::msgcat::mcset fi "Cannot change to the directory \"%1\$s\".\nPermission denied." "Ei voitu vaihtaa hakemistoon \"%1\$s\".\nLupa evätty."
+    ::msgcat::mcset fi "Choose Directory" "Valitse hakemisto"
+    ::msgcat::mcset fi "Cl&ear" "&Tyhjennä"
+    ::msgcat::mcset fi "&Clear Console" "&Tyhjennä konsoli"
+    ::msgcat::mcset fi "Color" "Väri"
+    ::msgcat::mcset fi "Console" "Konsoli"
+    ::msgcat::mcset fi "&Copy" "K&opioi"
+    ::msgcat::mcset fi "Cu&t" "&Leikkaa"
+    ::msgcat::mcset fi "&Decrease Font Size" "&Pienennä kirjasinkokoa"
+    ::msgcat::mcset fi "&Delete" "&Poista"
+    ::msgcat::mcset fi "Details >>" "Lisätiedot >>"
+    ::msgcat::mcset fi "Directory \"%1\$s\" does not exist." "Hakemistoa \"%1\$s\" ei ole olemassa."
+    ::msgcat::mcset fi "&Directory:" "&Hakemisto:"
+    ::msgcat::mcset fi "&Edit" "&Muokkaa"
+    ::msgcat::mcset fi "Effects" "Tehosteet"
+    ::msgcat::mcset fi "Error: %1\$s" "Virhe: %1\$s"
+    ::msgcat::mcset fi "E&xit" "&Lopeta"
+    ::msgcat::mcset fi "&File" "&Tiedosto"
+    ::msgcat::mcset fi "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Tiedosto \"%1\$s\" on jo olemassa.\nHaluatko korvata sen?"
+    ::msgcat::mcset fi "File \"%1\$s\" already exists.\n\n" "Tiedosto \"%1\$s\" on jo olemassa.\n\n"
+    ::msgcat::mcset fi "File \"%1\$s\" does not exist." "Tiedostoa \"%1\$s\" ei ole olemassa."
+    ::msgcat::mcset fi "File &name:" "Tiedosto&nimi:"
+    ::msgcat::mcset fi "File &names:" "Tiedosto&nimet:"
+    ::msgcat::mcset fi "Files of &type:" "T&yyppi:"
+    ::msgcat::mcset fi "Fi&les:" "Ti&edostot:"
+    ::msgcat::mcset fi "&Filter" "&Suodata"
+    ::msgcat::mcset fi "Fil&ter:" "Suo&data:"
+    ::msgcat::mcset fi "Fit To Screen Width" "Sovita ruudun kokoon"
+    ::msgcat::mcset fi "Font" "Kirjasin"
+    ::msgcat::mcset fi "&Font..." "Kir&jasin..."
+    ::msgcat::mcset fi "&Font:" "&Kirjasin:"
+    ::msgcat::mcset fi "Font st&yle:" "Kirjasint&yyli:"
+    ::msgcat::mcset fi "&Green" "&Vihreä"
+    ::msgcat::mcset fi "Help" "Ohje"
+    ::msgcat::mcset fi "&Help" "&Ohje"
+    ::msgcat::mcset fi "Hi" "Hei"
+    ::msgcat::mcset fi "&Hide Console" "P&iilota konsoli"
+    ::msgcat::mcset fi "Hide Fonts" "Piilota kirjasimet"
+    ::msgcat::mcset fi "&Ignore" "&Ohita"
+    ::msgcat::mcset fi "&Increase Font Size" "&Suurenna kirjasinkokoa"
+    ::msgcat::mcset fi "Invalid file name \"%1\$s\"." "Virheellinen tiedostonimi \"%1\$s\"."
+    ::msgcat::mcset fi "Italic" "Kursivoitu"
+    ::msgcat::mcset fi "Log Files" "Lokitiedostot"
+    ::msgcat::mcset fi "&No" "&Ei"
+    ::msgcat::mcset fi "&OK"
+    ::msgcat::mcset fi "OK"
+    ::msgcat::mcset fi "Ok" "OK"
+    ::msgcat::mcset fi "Open" "Avaa"
+    ::msgcat::mcset fi "&Open" "&Avaa"
+    ::msgcat::mcset fi "Open Multiple Files" "Avaa monta tiedostoa"
+    ::msgcat::mcset fi "P&aste" "L&iitä"
+    ::msgcat::mcset fi "&Quit" "&Lopeta"
+    ::msgcat::mcset fi "&Red" "&Punainen"
+    ::msgcat::mcset fi "Regular" "Tavallinen"
+    ::msgcat::mcset fi "Replace existing file?" "Korvataanko olemassaoleva tiedosto?"
+    ::msgcat::mcset fi "&Retry" "&Yritä uudelleen"
+    ::msgcat::mcset fi "Sample" "Malli"
+    ::msgcat::mcset fi "&Save" "&Tallenna"
+    ::msgcat::mcset fi "Save As" "Tallenna nimellä"
+    ::msgcat::mcset fi "Save To Log" "Tallenna lokiin"
+    ::msgcat::mcset fi "Select Log File" "Valitse lokitiedosto"
+    ::msgcat::mcset fi "Select a file to source" "Valitse lähdetiedosto"
+    ::msgcat::mcset fi "&Selection:" "&Valinta:"
+    ::msgcat::mcset fi "Show Fonts" "Näytä kirjasimet"
+    ::msgcat::mcset fi "Skip Messages" "Jätä viestit huomiotta"
+    ::msgcat::mcset fi "&Size:" "K&oko:"
+    ::msgcat::mcset fi "&Source..." "L&ähde..."
+    ::msgcat::mcset fi "Stri&keout" "&Yliviivaa"
+    ::msgcat::mcset fi "Tcl Scripts" "Tcl-skriptit"
+    ::msgcat::mcset fi "Tcl for Windows" "Tcl Windowsille"
+    ::msgcat::mcset fi "Text Files" "Tekstitiedostot"
+    ::msgcat::mcset fi "&Underline" "&Alleviivaa"
+    ::msgcat::mcset fi "Window" "Ikkuna"
+    ::msgcat::mcset fi "&Yes" "&Kyllä"
+    ::msgcat::mcset fi "abort" "keskeytä"
+    ::msgcat::mcset fi "blue" "sininen"
+    ::msgcat::mcset fi "cancel" "peruuta"
+    ::msgcat::mcset fi "extension" "lisäosa"
+    ::msgcat::mcset fi "extensions" "lisäosat"
+    ::msgcat::mcset fi "green" "vihreä"
+    ::msgcat::mcset fi "ignore" "ohita"
+    ::msgcat::mcset fi "ok"
+    ::msgcat::mcset fi "red" "punainen"
+    ::msgcat::mcset fi "retry" "yritä uudelleen"
+    ::msgcat::mcset fi "yes" "kyllä"
+
+    ::msgcat::mcset fi "Print" "Tulosta"
+    ::msgcat::mcset fi "Printer" "Tulostin"
+    ::msgcat::mcset fi "Letter " "Letter"
+    ::msgcat::mcset fi "Legal " "Legal"
+    ::msgcat::mcset fi "A4" "A4"
+    ::msgcat::mcset fi "Grayscale" "Harmaasävy"
+    ::msgcat::mcset fi "RGB" "RGB"
+    ::msgcat::mcset fi "Options" "Asetukset"
+    ::msgcat::mcset fi "Copies" "Tulosteita"
+    ::msgcat::mcset fi "Paper" "Paperikoko"
+    ::msgcat::mcset fi "Scale" "Skaalaus"
+    ::msgcat::mcset fi "Orientation" "Suunta"
+    ::msgcat::mcset fi "Portrait" "Pysty"
+    ::msgcat::mcset fi "Landscape" "Vaaka"
+    ::msgcat::mcset fi "Output" "Tulos"
+}

Index: library/msgs/fr.msg
==================================================================
--- library/msgs/fr.msg
+++ library/msgs/fr.msg
@@ -67,6 +67,24 @@
     ::msgcat::mcset fr "ignore" "ignorer"
     ::msgcat::mcset fr "ok"
     ::msgcat::mcset fr "red" "rouge"
     ::msgcat::mcset fr "retry" "réessayer"
     ::msgcat::mcset fr "yes" "oui"
+}
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  fr "Print" "Imprimer"
+    ::msgcat::mcset  fr "Printer" "Imprimante"
+    ::msgcat::mcset  fr "Letter " "Lettre"
+    ::msgcat::mcset  fr "Legal " "Légal"
+    ::msgcat::mcset  fr "A4" "A4"
+    ::msgcat::mcset  fr "Grayscale" "Niveaux de Gris"
+    ::msgcat::mcset  fr "RGB" "RVB"
+    ::msgcat::mcset  fr "Options" "Options"
+    ::msgcat::mcset  fr "Copies" "Nombre d'exemplaires"
+    ::msgcat::mcset  fr "Paper" "Papier"
+    ::msgcat::mcset  fr "Scale" "Échelle"
+    ::msgcat::mcset  fr "Orientation" "Orientation"
+    ::msgcat::mcset  fr "Portrait" "Portrait"
+    ::msgcat::mcset  fr "Landscape" "Paysage"
+    ::msgcat::mcset  fr "Output" "Sortie"
 }

Index: library/msgs/hu.msg
==================================================================
--- library/msgs/hu.msg
+++ library/msgs/hu.msg
@@ -73,6 +73,24 @@
     ::msgcat::mcset hu "ignore" "ignorer"
     ::msgcat::mcset hu "ok"
     ::msgcat::mcset hu "red" "vörös"
     ::msgcat::mcset hu "retry" "újra"
     ::msgcat::mcset hu "yes" "igen"
+}
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  hu "Print" "Nyomtat"
+    ::msgcat::mcset  hu "Printer" "Nyomtató"
+    ::msgcat::mcset  hu "Letter " "Levél"
+    ::msgcat::mcset  hu "Legal " "Törvényes"
+    ::msgcat::mcset  hu "A4" "A4"
+    ::msgcat::mcset  hu "Grayscale" "Szürkeárnyalatos"
+    ::msgcat::mcset  hu "RGB" "Rgb"
+    ::msgcat::mcset  hu "Options" "Beállítások"
+    ::msgcat::mcset  hu "Copies" "Másolatok"
+    ::msgcat::mcset  hu "Paper" "Papír"
+    ::msgcat::mcset  hu "Scale" "Hangsor"
+    ::msgcat::mcset  hu "Orientation" "Tájékozódás"
+    ::msgcat::mcset  hu "Portrait" "Portré"
+    ::msgcat::mcset  hu "Landscape" "Táj"
+    ::msgcat::mcset  hu "Output" "Hozam"
 }

Index: library/msgs/it.msg
==================================================================
--- library/msgs/it.msg
+++ library/msgs/it.msg
@@ -68,6 +68,24 @@
     ::msgcat::mcset it "ignore" "ignora"
     ::msgcat::mcset it "ok"
     ::msgcat::mcset it "red" "rosso"
     ::msgcat::mcset it "retry" "riprova"
     ::msgcat::mcset it "yes" "sì"
+}
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  it "Print" "Stampare"
+    ::msgcat::mcset  it "Printer" "Stampante"
+    ::msgcat::mcset  it "Letter " "Lettera"
+    ::msgcat::mcset  it "Legal " "Legale"
+    ::msgcat::mcset  it "A4" "A4"
+    ::msgcat::mcset  it "Grayscale" "Scala Di Grigi"
+    ::msgcat::mcset  it "RGB" "Rgb"
+    ::msgcat::mcset  it "Options" "Opzioni"
+    ::msgcat::mcset  it "Copies" "Copie"
+    ::msgcat::mcset  it "Paper" "Carta"
+    ::msgcat::mcset  it "Scale" "Scala"
+    ::msgcat::mcset  it "Orientation" "Orientamento"
+    ::msgcat::mcset  it "Portrait" "Ritratto"
+    ::msgcat::mcset  it "Landscape" "Paesaggio"
+    ::msgcat::mcset  it "Output" "Prodotto"
 }

Index: library/msgs/nl.msg
==================================================================
--- library/msgs/nl.msg
+++ library/msgs/nl.msg
@@ -86,6 +86,24 @@
     ::msgcat::mcset nl "ignore" "negeren"
     ::msgcat::mcset nl "ok"
     ::msgcat::mcset nl "red" "rood"
     ::msgcat::mcset nl "retry" "opnieuw"
     ::msgcat::mcset nl "yes" "ja"
+}
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  nl "Print" "Afdrukken"
+    ::msgcat::mcset  nl "Printer" "Printer"
+    ::msgcat::mcset  nl "Letter " "Brief"
+    ::msgcat::mcset  nl "Legal " "Legaal"
+    ::msgcat::mcset  nl "A4" "A4"
+    ::msgcat::mcset  nl "Grayscale" "Grijswaarden"
+    ::msgcat::mcset  nl "RGB" "Rgb"
+    ::msgcat::mcset  nl "Options" "Opties"
+    ::msgcat::mcset  nl "Copies" "Kopieën"
+    ::msgcat::mcset  nl "Paper" "Papier"
+    ::msgcat::mcset  nl "Scale" "Schub"
+    ::msgcat::mcset  nl "Orientation" "Oriëntatie"
+    ::msgcat::mcset  nl "Portrait" "Portret"
+    ::msgcat::mcset  nl "Landscape" "Landschap"
+    ::msgcat::mcset  nl "Output" "Uitvoer"
 }

Index: library/msgs/pl.msg
==================================================================
--- library/msgs/pl.msg
+++ library/msgs/pl.msg
@@ -86,6 +86,24 @@
     ::msgcat::mcset pl "ignore" "ignoruj"
     ::msgcat::mcset pl "ok"
     ::msgcat::mcset pl "red" "czerwony"
     ::msgcat::mcset pl "retry" "ponów"
     ::msgcat::mcset pl "yes" "tak"
+}
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  pl "Print" "Drukować"
+    ::msgcat::mcset  pl "Printer" "Drukarka"
+    ::msgcat::mcset  pl "Letter " "Litera"
+    ::msgcat::mcset  pl "Legal " "Legalny"
+    ::msgcat::mcset  pl "A4" "A4"
+    ::msgcat::mcset  pl "Grayscale" "Skala Szarości"
+    ::msgcat::mcset  pl "RGB" "Rgb"
+    ::msgcat::mcset  pl "Options" "Opcje"
+    ::msgcat::mcset  pl "Copies" "Kopie"
+    ::msgcat::mcset  pl "Paper" "Papier"
+    ::msgcat::mcset  pl "Scale" "Skala"
+    ::msgcat::mcset  pl "Orientation" "Orientacja"
+    ::msgcat::mcset  pl "Portrait" "Portret"
+    ::msgcat::mcset  pl "Landscape" "Krajobraz"
+    ::msgcat::mcset  pl "Output" "Produkt Wyjściowy"
 }

Index: library/msgs/pt.msg
==================================================================
--- library/msgs/pt.msg
+++ library/msgs/pt.msg
@@ -69,6 +69,24 @@
     ::msgcat::mcset pt "ignore" "ignorar"
     ::msgcat::mcset pt "ok"
     ::msgcat::mcset pt "red" "vermelho"
     ::msgcat::mcset pt "retry" "tentar novamente"
     ::msgcat::mcset pt "yes" "sim"
+}
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  pt "Print" "Imprimir"
+    ::msgcat::mcset  pt "Printer" "Impressora"
+    ::msgcat::mcset  pt "Letter " "Letra"
+    ::msgcat::mcset  pt "Legal " "Legal"
+    ::msgcat::mcset  pt "A4" "A4"
+    ::msgcat::mcset  pt "Grayscale" "Escala De Cinza"
+    ::msgcat::mcset  pt "RGB" "Rgb"
+    ::msgcat::mcset  pt "Options" "Opções"
+    ::msgcat::mcset  pt "Copies" "Exemplares"
+    ::msgcat::mcset  pt "Paper" "Papel"
+    ::msgcat::mcset  pt "Scale" "Escala"
+    ::msgcat::mcset  pt "Orientation" "Orientação"
+    ::msgcat::mcset  pt "Portrait" "Retrato"
+    ::msgcat::mcset  pt "Landscape" "Paisagem"
+    ::msgcat::mcset  pt "Output" "Saída"
 }

Index: library/msgs/ru.msg
==================================================================
--- library/msgs/ru.msg
+++ library/msgs/ru.msg
@@ -1,27 +1,34 @@
 namespace eval ::tk {
     ::msgcat::mcset ru "&Abort" "&Отменить"
     ::msgcat::mcset ru "&About..." "Про..."
     ::msgcat::mcset ru "All Files" "Все файлы"
     ::msgcat::mcset ru "Application Error" "Ошибка в программе"
+    ::msgcat::mcset ru "&Apply" "&Применить"
+    ::msgcat::mcset ru "Bold" "Bold"
+    ::msgcat::mcset ru "Bold Italic" "Bold Italic"
     ::msgcat::mcset ru "&Blue" " &Голубой"
-    ::msgcat::mcset ru "Cancel" "От&мена"
+    ::msgcat::mcset ru "Cancel" "Отмена"
     ::msgcat::mcset ru "&Cancel" "От&мена"
     ::msgcat::mcset ru "Cannot change to the directory \"%1\$s\".\nPermission denied." \
 			"Не могу перейти в каталог \"%1\$s\".\nНедостаточно прав доступа"
     ::msgcat::mcset ru "Choose Directory" "Выберите каталог"
     ::msgcat::mcset ru "Cl&ear" "Очистить"
+    ::msgcat::mcset ru "&Clear Console" "&Clear Console"
     ::msgcat::mcset ru "Color" "Цвет"
     ::msgcat::mcset ru "Console" "Консоль"
     ::msgcat::mcset ru "&Copy" "Копировать"
     ::msgcat::mcset ru "Cu&t" "Вырезать"
     ::msgcat::mcset ru "&Delete" "Удалить"
     ::msgcat::mcset ru "Details >>" "Подробнее >>"
     ::msgcat::mcset ru "Directory \"%1\$s\" does not exist." "Каталога \"%1\$s\" не существует."
     ::msgcat::mcset ru "&Directory:" "&Каталог:"
+    ::msgcat::mcset ru "&Edit" "&Edit"
+    ::msgcat::mcset ru "Effects" "Эффекты"
     ::msgcat::mcset ru "Error: %1\$s" "Ошибка: %1\$s"
     ::msgcat::mcset ru "E&xit" "Выход"
+    ::msgcat::mcset ru "&File" "&File"
     ::msgcat::mcset ru "File \"%1\$s\" already exists.\nDo you want to overwrite it?" \
 			    "Файл \"%1\$s\" уже существует.\nЗаменить его?"
     ::msgcat::mcset ru "File \"%1\$s\" already exists.\n\n" "Файл \"%1\$s\" уже существует.\n\n"
     ::msgcat::mcset ru "File \"%1\$s\" does not exist." "Файл \"%1\$s\" не найден."
     ::msgcat::mcset ru "File &name:" "&Имя файла:"
@@ -28,15 +35,20 @@
     ::msgcat::mcset ru "File &names:" "&Имена файлов:"
     ::msgcat::mcset ru "Files of &type:" "&Тип файлов:"
     ::msgcat::mcset ru "Fi&les:" "Фай&лы:"
     ::msgcat::mcset ru "&Filter" "&Фильтр"
     ::msgcat::mcset ru "Fil&ter:" "Филь&тр:"
+    ::msgcat::mcset ru "Font" "Шрифт"
+    ::msgcat::mcset ru "&Font:" "&Шрифт"
+    ::msgcat::mcset ru "Font st&yle:" "&Стиль шрифта:"
     ::msgcat::mcset ru "&Green" " &Зеленый"
+    ::msgcat::mcset ru "&Help" "&Help"
     ::msgcat::mcset ru "Hi" "Привет"
     ::msgcat::mcset ru "&Hide Console" "Спрятать консоль"
     ::msgcat::mcset ru "&Ignore" "&Игнорировать"
     ::msgcat::mcset ru "Invalid file name \"%1\$s\"." "Неверное имя файла \"%1\$s\"."
+    ::msgcat::mcset ru "Italic" "Italic"
     ::msgcat::mcset ru "Log Files" "Файлы журнала"
     ::msgcat::mcset ru "&No" "&Нет"
     ::msgcat::mcset ru "&OK" "&ОК"
     ::msgcat::mcset ru "OK" "ОК"
     ::msgcat::mcset ru "Ok" "Да"
@@ -45,22 +57,29 @@
     ::msgcat::mcset ru "Open Multiple Files" "Открыть несколько файлов"
     ::msgcat::mcset ru "P&aste" "Вставить"
     ::msgcat::mcset ru "&Quit" "Выход"
     ::msgcat::mcset ru "&Red" " &Красный"
     ::msgcat::mcset ru "Replace existing file?" "Заменить существующий файл?"
+    ::msgcat::mcset ru "Regular" "Regular"
     ::msgcat::mcset ru "&Retry" "&Повторить"
+    ::msgcat::mcset ru "Sample" "Пример"
     ::msgcat::mcset ru "&Save" "&Сохранить"
     ::msgcat::mcset ru "Save As" "Сохранить как"
     ::msgcat::mcset ru "Save To Log" "Сохранить в журнал"
     ::msgcat::mcset ru "Select Log File" "Выбрать журнал"
     ::msgcat::mcset ru "Select a file to source" "Выберите файл для интерпретации"
     ::msgcat::mcset ru "&Selection:"
+    ::msgcat::mcset ru "&Size:" "&Размер:"
+    ::msgcat::mcset ru "Show &Hidden Directories" "Show &Hidden Directories"
+    ::msgcat::mcset ru "Show &Hidden Files and Directories" "Show &Hidden Files and Directories"
     ::msgcat::mcset ru "Skip Messages" "Пропустить сообщения"
     ::msgcat::mcset ru "&Source..." "Интерпретировать файл..."
+    ::msgcat::mcset ru "Stri&keout" "П&еречёркнутый"
     ::msgcat::mcset ru "Tcl Scripts" "Программа на языке TCL"
     ::msgcat::mcset ru "Tcl for Windows" "TCL для Windows"
     ::msgcat::mcset ru "Text Files" "Текстовые файлы"
+    ::msgcat::mcset ru "&Underline" "По&дчеркнутый"
     ::msgcat::mcset ru "&Yes" "&Да"
     ::msgcat::mcset ru "abort" "отмена"
     ::msgcat::mcset ru "blue" " голубой"
     ::msgcat::mcset ru "cancel" "отмена"
     ::msgcat::mcset ru "extension" "расширение"
@@ -71,5 +90,23 @@
     ::msgcat::mcset ru "red" " красный"
     ::msgcat::mcset ru "retry" "повторить"
     ::msgcat::mcset ru "yes" "да"
 }
 
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  ru "Print" "Печатать"
+    ::msgcat::mcset  ru "Printer" "Принтер"
+    ::msgcat::mcset  ru "Letter " "Письмо"
+    ::msgcat::mcset  ru "Legal " "Законный"
+    ::msgcat::mcset  ru "A4" "A4"
+    ::msgcat::mcset  ru "Grayscale" "Серый Масштаб"
+    ::msgcat::mcset  ru "RGB" "Ргб"
+    ::msgcat::mcset  ru "Options" "Параметры"
+    ::msgcat::mcset  ru "Copies" "Копии"
+    ::msgcat::mcset  ru "Paper" "Бумага"
+    ::msgcat::mcset  ru "Scale" "Шкала"
+    ::msgcat::mcset  ru "Orientation" "Ориентация"
+    ::msgcat::mcset  ru "Portrait" "Портрет"
+    ::msgcat::mcset  ru "Landscape" "Ландшафт"
+    ::msgcat::mcset  ru "Output" "Выпуск"
+}

Index: library/msgs/sv.msg
==================================================================
--- library/msgs/sv.msg
+++ library/msgs/sv.msg
@@ -71,6 +71,24 @@
     ::msgcat::mcset sv "ignore" "ignorera"
     ::msgcat::mcset sv "ok"
     ::msgcat::mcset sv "red" "röd"
     ::msgcat::mcset sv "retry" "försök igen"
     ::msgcat::mcset sv "yes" "ja"
+}
+#localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  sv "Print" "Trycka"
+    ::msgcat::mcset  sv "Printer" "Skrivare"
+    ::msgcat::mcset  sv "Letter " "Brev"
+    ::msgcat::mcset  sv "Legal " "Laglig"
+    ::msgcat::mcset  sv "A4" "A4 (På 199"
+    ::msgcat::mcset  sv "Grayscale" "Gråskala"
+    ::msgcat::mcset  sv "RGB" "Rgb"
+    ::msgcat::mcset  sv "Options" "Alternativ"
+    ::msgcat::mcset  sv "Copies" "Kopior"
+    ::msgcat::mcset  sv "Paper" "Papper"
+    ::msgcat::mcset  sv "Scale" "Skala"
+    ::msgcat::mcset  sv "Orientation" "Orientering"
+    ::msgcat::mcset  sv "Portrait" "Porträtt"
+    ::msgcat::mcset  sv "Landscape" "Landskap"
+    ::msgcat::mcset  sv "Output" "Utdata"
 }

ADDED   library/msgs/zh_cn.msg
Index: library/msgs/zh_cn.msg
==================================================================
--- /dev/null
+++ library/msgs/zh_cn.msg
@@ -0,0 +1,110 @@
+namespace eval ::tk {
+    ::msgcat::mcset zh_cn "&Abort" "&中止"
+    ::msgcat::mcset zh_cn "&About..." "&关于……"
+    ::msgcat::mcset zh_cn "All Files" "所有文件"
+    ::msgcat::mcset zh_cn "Application Error" "应用程序错误"
+    ::msgcat::mcset zh_cn "&Apply" "&添加"
+    ::msgcat::mcset zh_cn "Bold" "粗体"
+    ::msgcat::mcset zh_cn "Bold Italic" "加粗斜体"
+    ::msgcat::mcset zh_cn "&Blue" "&蓝色"
+    ::msgcat::mcset zh_cn "Cancel" "取消"
+    ::msgcat::mcset zh_cn "&Cancel" "&取消"
+    ::msgcat::mcset zh_cn "Cannot change to the directory \"%1\$s\".\nPermission denied." "无法更改目录 \"%1\$s\"。\n访问被拒绝。"
+    ::msgcat::mcset zh_cn "Choose Directory" "选择文件夹"
+    ::msgcat::mcset zh_cn "Cl&ear" "清&除"
+    ::msgcat::mcset zh_cn "&Clear Console" "&清除终端"
+    ::msgcat::mcset zh_cn "Color" "颜色"
+    ::msgcat::mcset zh_cn "Console" "终端"
+    ::msgcat::mcset zh_cn "&Copy" "&复制"
+    ::msgcat::mcset zh_cn "Cu&t" "剪&切"
+    ::msgcat::mcset zh_cn "&Delete" "&删除"
+    ::msgcat::mcset zh_cn "Details >>" "详细信息 >>"
+    ::msgcat::mcset zh_cn "Directory \"%1\$s\" does not exist." "目录 \"%1\$s\" 不存在。"
+    ::msgcat::mcset zh_cn "&Directory:" "&目录:"
+    ::msgcat::mcset zh_cn "&Edit" "&编辑"
+    ::msgcat::mcset zh_cn "Effects" "效果"
+    ::msgcat::mcset zh_cn "Error: %1\$s" "错误: %1\$s"
+    ::msgcat::mcset zh_cn "E&xit" "退&出"
+    ::msgcat::mcset zh_cn "&File" "&文件"
+    ::msgcat::mcset zh_cn "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "文件 \"%1\$s\" 已经存在。\n您想要覆盖它吗?"
+    ::msgcat::mcset zh_cn "File \"%1\$s\" already exists.\n\n" "文件 \"%1\$s\" 已经存在。\n\n"
+    ::msgcat::mcset zh_cn "File \"%1\$s\" does not exist." "文件 \"%1\$s\" 不存在。"
+    ::msgcat::mcset zh_cn "File &name:" "文件&名:"
+    ::msgcat::mcset zh_cn "File &names:" "文件&名:"
+    ::msgcat::mcset zh_cn "Files of &type:" "文件&类型:"
+    ::msgcat::mcset zh_cn "Fi&les:" "文&件:"
+    ::msgcat::mcset zh_cn "&Filter" "&过滤"
+    ::msgcat::mcset zh_cn "Fil&ter:" "过&滤:"
+    ::msgcat::mcset zh_cn "Font" "字体"
+    ::msgcat::mcset zh_cn "&Font:" "&字体:"
+    ::msgcat::mcset zh_cn "Font st&yle:" "字体&样式:"
+    ::msgcat::mcset zh_cn "&Green" "&绿色"
+    ::msgcat::mcset zh_cn "&Help" "&帮助"
+    ::msgcat::mcset zh_cn "Hi" "你好"
+    ::msgcat::mcset zh_cn "&Hide Console" "&隐藏终端"
+    ::msgcat::mcset zh_cn "&Ignore" "&忽略"
+    ::msgcat::mcset zh_cn "Invalid file name \"%1\$s\"." "无效的文件名 \"%1\$s\"。"
+    ::msgcat::mcset zh_cn "Italic" "斜体"
+    ::msgcat::mcset zh_cn "Log Files" "日志文件"
+    ::msgcat::mcset zh_cn "&No" "&取消"
+    ::msgcat::mcset zh_cn "&OK" "&确定"
+    ::msgcat::mcset zh_cn "OK" "确定"
+    ::msgcat::mcset zh_cn "Ok" "确定"
+    ::msgcat::mcset zh_cn "Open" "打开"
+    ::msgcat::mcset zh_cn "&Open" "&打开"
+    ::msgcat::mcset zh_cn "Open Multiple Files" "打开多个文件"
+    ::msgcat::mcset zh_cn "P&aste" "粘&贴"
+    ::msgcat::mcset zh_cn "&Quit" "&退出"
+    ::msgcat::mcset zh_cn "&Red" "红色"
+    ::msgcat::mcset zh_cn "Regular" "规则"
+    ::msgcat::mcset zh_cn "Replace existing file?" "替换已有文件?"
+    ::msgcat::mcset zh_cn "&Retry" "&重试"
+    ::msgcat::mcset zh_cn "Sample" "样式"
+    ::msgcat::mcset zh_cn "&Save" "&保存"
+    ::msgcat::mcset zh_cn "Save As" "另存为"
+    ::msgcat::mcset zh_cn "Save To Log" "保存到日志"
+    ::msgcat::mcset zh_cn "Select Log File" "选择日志文件"
+    ::msgcat::mcset zh_cn "Select a file to source" "选择一个源文件"
+    ::msgcat::mcset zh_cn "&Selection:" "&选择:"
+    ::msgcat::mcset zh_cn "&Size:" "&大小:"
+    ::msgcat::mcset zh_cn "Show &Hidden Directories" "显示&隐藏目录"
+    ::msgcat::mcset zh_cn "Show &Hidden Files and Directories" "显示&隐藏文件和目录"
+    ::msgcat::mcset zh_cn "Skip Messages" "跳过信息"
+    ::msgcat::mcset zh_cn "&Source..." "&来源……"
+    ::msgcat::mcset zh_cn "Stri&keout" "删&除线"
+    ::msgcat::mcset zh_cn "Tcl Scripts" "Tcl脚本"
+    ::msgcat::mcset zh_cn "Tcl for Windows" "适用于Windows的Tcl"
+    ::msgcat::mcset zh_cn "Text Files" "文本文档"
+    ::msgcat::mcset zh_cn "&Underline" "&下划线"
+    ::msgcat::mcset zh_cn "&Yes" "&确定"
+    ::msgcat::mcset zh_cn "abort" "中止"
+    ::msgcat::mcset zh_cn "blue" "蓝色"
+    ::msgcat::mcset zh_cn "cancel" "取消"
+    ::msgcat::mcset zh_cn "extension" "拓展"
+    ::msgcat::mcset zh_cn "extensions" "拓展"
+    ::msgcat::mcset zh_cn "green" "绿色"
+    ::msgcat::mcset zh_cn "ignore" "忽略"
+    ::msgcat::mcset zh_cn "ok" "确定"
+    ::msgcat::mcset zh_cn "red" "红色"
+    ::msgcat::mcset zh_cn "retry" "重试"
+    ::msgcat::mcset zh_cn "yes" "确认"
+}
+
+#Kevin Walzer通过微软翻译对打印内容进行本地化    localization of print terms by Kevin Walzer via Microsoft Translator
+namespace eval ::tk {
+    ::msgcat::mcset  zh_cn "Print" "输出"
+    ::msgcat::mcset  zh_cn "Printer" "输出器"
+    ::msgcat::mcset  zh_cn "Letter " "信 "
+    ::msgcat::mcset  zh_cn "Legal " "合法的 "
+    ::msgcat::mcset  zh_cn "A4" "A4"
+    ::msgcat::mcset  zh_cn "Grayscale" "灰度"
+    ::msgcat::mcset  zh_cn "RGB" "RGB"
+    ::msgcat::mcset  zh_cn "Options" "设置"
+    ::msgcat::mcset  zh_cn "Copies" "复制"
+    ::msgcat::mcset  zh_cn "Paper" "纸"
+    ::msgcat::mcset  zh_cn "Scale" "规模"
+    ::msgcat::mcset  zh_cn "Orientation" "方向"
+    ::msgcat::mcset  zh_cn "Portrait" "竖向"
+    ::msgcat::mcset  zh_cn "Landscape" "横向"
+    ::msgcat::mcset  zh_cn "Output" "输出"
+}

Index: library/optMenu.tcl
==================================================================
--- library/optMenu.tcl
+++ library/optMenu.tcl
@@ -35,9 +35,9 @@
 	    -relief raised -highlightthickness 1 -anchor c \
 	    -direction flush
     menu $w.menu -tearoff 0
     $w.menu add radiobutton -label $firstValue -variable $varName
     foreach i $args {
-    	$w.menu add radiobutton -label $i -variable $varName
+	$w.menu add radiobutton -label $i -variable $varName
     }
     return $w.menu
 }

ADDED   library/print.tcl
Index: library/print.tcl
==================================================================
--- /dev/null
+++ library/print.tcl
@@ -0,0 +1,1006 @@
+# print.tcl --
+
+# This file defines the 'tk print' command for printing of the canvas
+# widget and text on X11, Windows, and macOS. It implements an abstraction
+# layer that presents a consistent API across the three platforms.
+
+# Copyright © 2009 Michael I. Schwartz.
+# Copyright © 2021 Kevin Walzer/WordTech Communications LLC.
+# Copyright © 2021 Harald Oehlmann, Elmicron GmbH
+# Copyright © 2022 Emiliano Gavilan
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+
+namespace eval ::tk::print {
+    namespace import -force ::tk::msgcat::*
+
+    # makeTempFile:
+    #    Create a temporary file and populate its contents
+    # Arguments:
+    #	 filename - base of the name of the file to create
+    #    contents - what to put in the file; defaults to empty
+    # Returns:
+    #    Full filename for created file
+    #
+    proc makeTempFile {filename {contents ""}} {
+	set f [file tempfile filename $filename]
+	try {
+	    puts -nonewline $f $contents
+	    return $filename
+	} finally {
+	    close $f
+	}
+    }
+
+    if {[tk windowingsystem] eq "win32"} {
+	variable printer_name
+	variable copies
+	variable dpi_x
+	variable dpi_y
+	variable paper_width
+	variable paper_height
+	variable margin_left
+	variable margin_top
+	variable printargs
+	array set printargs {}
+
+	# Multiple utility procedures for printing text based on the
+	# C printer primitives.
+
+	# _set_dc:
+	# Select printer and set device context and other parameters
+	# for print job.
+	#
+	proc _set_dc {} {
+	    variable printargs
+	    variable printer_name
+	    variable paper_width
+	    variable paper_height
+	    variable dpi_x
+	    variable dpi_y
+	    variable copies
+
+	    #First, we select the printer.
+	    _selectprinter
+
+	    #Next, set values. Some are taken from the printer,
+	    #some are sane defaults.
+
+        if {[info exists printer_name] && $printer_name ne ""} {
+	    set printargs(hDC) $printer_name
+	    set printargs(pw) $paper_width
+	    set printargs(pl) $paper_height
+	    set printargs(lm) 1000
+	    set printargs(tm) 1000
+	    set printargs(rm) 1000
+	    set printargs(bm) 1000
+	    set printargs(resx) $dpi_x
+	    set printargs(resy) $dpi_y
+	    set printargs(copies) $copies
+	    set printargs(resolution) [list $dpi_x $dpi_y]
+		}
+	}
+
+	# _print_data
+	# This function prints multiple-page files, using a line-oriented
+	# function, taking advantage of knowing the character widths.
+	# Arguments:
+	# data -       Text data for printing
+	# breaklines - If non-zero, keep newlines in the string as
+	#              newlines in the output.
+	# font -       Font for printing
+	proc _print_data {data {breaklines 1} {font ""}} {
+	    variable printargs
+	    variable printer_name
+
+	    _set_dc
+
+	    if {![info exists printer_name]} {
+		return
+	    }
+
+	    if {$font eq ""} {
+		_gdi characters $printargs(hDC) -array printcharwid
+	    } else {
+		_gdi characters $printargs(hDC) -font $font -array printcharwid
+	    }
+	    set pagewid [expr {($printargs(pw) - $printargs(rm) ) / 1000 * $printargs(resx)}]
+	    set pagehgt [expr {($printargs(pl) - $printargs(bm) ) / 1000 * $printargs(resy)}]
+	    set totallen [string length $data]
+	    set curlen 0
+	    set curhgt [expr {$printargs(tm) * $printargs(resy) / 1000}]
+
+	    _opendoc
+	    _openpage
+
+	    while {$curlen < $totallen} {
+		set linestring [string range $data $curlen end]
+		if {$breaklines} {
+		    set endind [string first "\n" $linestring]
+		    if {$endind >= 0} {
+			set linestring [string range $linestring 0 $endind]
+			# handle blank lines....
+			if {$linestring eq ""} {
+			    set linestring " "
+			}
+		    }
+		}
+
+		set result [_print_page_nextline $linestring \
+				printcharwid printargs $curhgt $font]
+		incr curlen [lindex $result 0]
+		incr curhgt [lindex $result 1]
+		if {$curhgt + [lindex $result 1] > $pagehgt} {
+		    _closepage
+		    _openpage
+		    set curhgt [expr {$printargs(tm) * $printargs(resy) / 1000}]
+		}
+	    }
+
+	    _closepage
+	    _closedoc
+	}
+
+	# _print_file
+	# This function prints multiple-page files
+	# It will either break lines or just let them run over the
+	# margins (and thus truncate).
+	# The font argument is JUST the font name, not any additional
+	# arguments.
+	# Arguments:
+	#   filename -   File to open for printing
+	#   breaklines - 1 to break lines as done on input, 0 to ignore newlines
+	#   font -       Optional arguments to supply to the text command
+	proc _print_file {filename {breaklines 1} {font ""}} {
+	    set fn [open $filename r]
+	    set data [read $fn]
+	    close $fn
+	    _print_data $data $breaklines $font
+	}
+
+	# _print_page_nextline
+	# Returns the pair "chars y"
+	# where chars is the number of characters printed on the line
+	# and y is the height of the line printed
+	# Arguments:
+	#   string -         Data to print
+	#   pdata -         Array of values for printer characteristics
+	#   cdata -         Array of values for character widths
+	#   y -              Y value to begin printing at
+	#   font -           if non-empty specifies a font to draw the line in
+	proc _print_page_nextline {string carray parray y font} {
+	    upvar #0 $carray charwidths
+	    upvar #0 $parray printargs
+
+	    variable printargs
+
+	    set endindex 0
+	    set totwidth 0
+	    set maxwidth [expr {
+		(($printargs(pw) - $printargs(rm)) / 1000) * $printargs(resx)
+	    }]
+	    set maxstring [string length $string]
+	    set lm [expr {$printargs(lm) * $printargs(resx) / 1000}]
+
+	    for {set i 0} {($i < $maxstring) && ($totwidth < $maxwidth)} {incr i} {
+		incr totwidth $charwidths([string index $string $i])
+		# set width($i) $totwidth
+	    }
+
+	    set endindex $i
+	    set startindex $endindex
+
+	    if {$i < $maxstring} {
+		# In this case, the whole data string is not used up, and we
+		# wish to break on a word. Since we have all the partial
+		# widths calculated, this should be easy.
+
+		set endindex [expr {[string wordstart $string $endindex] - 1}]
+		set startindex [expr {$endindex + 1}]
+
+		# If the line is just too long (no word breaks), print as much
+		# as you can....
+		if {$endindex <= 1} {
+		    set endindex $i
+		    set startindex $i
+		}
+	    }
+
+	    set txt [string trim [string range $string 0 $endindex] "\r\n"]
+	    if {$font ne ""} {
+		set result [_gdi text $printargs(hDC) $lm $y \
+				 -anchor nw -justify left \
+				 -text $txt -font $font]
+	    } else {
+		set result [_gdi text $printargs(hDC) $lm $y \
+				 -anchor nw -justify left -text $txt]
+	    }
+	    return "$startindex $result"
+	}
+
+	# These procedures read in the canvas widget, and write all of
+	# its contents out to the Windows printer.
+
+	variable option
+	variable vtgPrint
+
+	proc _init_print_canvas {} {
+	    variable option
+	    variable vtgPrint
+	    variable printargs
+
+	    set vtgPrint(printer.bg) white
+	}
+
+	proc _is_win {} {
+	    variable printargs
+
+	    return [info exist tk_patchLevel]
+	}
+
+	# _print_widget
+	# Main procedure for printing a widget.  Currently supports
+	# canvas widgets.  Handles opening and closing of printer.
+	# Arguments:
+	#   wid -              The widget to be printed.
+	#   printer -          Flag whether to use the default printer.
+	#   name  -            App name to pass to printer.
+
+	proc _print_widget {wid {printer default} {name "Tk Print Output"}} {
+	    variable printargs
+	    variable printer_name
+
+	    _set_dc
+
+	    if {![info exists printer_name]} {
+		return
+	    }
+
+	    _opendoc
+	    _openpage
+
+	    # Here is where any scaling/gdi mapping should take place
+	    # For now, scale so the dimensions of the window are sized to the
+	    # width of the page. Scale evenly.
+
+	    # For normal windows, this may be fine--but for a canvas, one
+	    # wants the canvas dimensions, and not the WINDOW dimensions.
+	    if {[winfo class $wid] eq "Canvas"} {
+		set sc [$wid cget -scrollregion]
+		# if there is no scrollregion, use width and height.
+		if {$sc eq ""} {
+		    set window_x [$wid cget -width]
+		    set window_y [$wid cget -height]
+		} else {
+		    set window_x [lindex $sc 2]
+		    set window_y [lindex $sc 3]
+		}
+	    } else {
+		set window_x [winfo width $wid]
+		set window_y [winfo height $wid]
+	    }
+
+	    set printer_x [expr {
+		( $printargs(pw) - $printargs(lm) - $printargs(rm) ) *
+		$printargs(resx)  / 1000.0
+	    }]
+	    set printer_y [expr {
+		( $printargs(pl) - $printargs(tm) - $printargs(bm) ) *
+		$printargs(resy) / 1000.0
+	    }]
+	    set factor_x [expr {$window_x / $printer_x}]
+	    set factor_y [expr {$window_y / $printer_y}]
+
+	    if {$factor_x < $factor_y} {
+		set lo $window_y
+		set ph $printer_y
+	    } else {
+		set lo $window_x
+		set ph $printer_x
+	    }
+
+	    _gdi map $printargs(hDC) -logical $lo -physical $ph \
+		-offset $printargs(resolution)
+
+	    # Handling of canvas widgets.
+	    switch [winfo class $wid] {
+		Canvas {
+		    _print_canvas $printargs(hDC) $wid
+		}
+		default {
+		    puts "Can't print items of type [winfo class $wid]. No handler registered"
+		}
+	    }
+
+	    # End printing process.
+	    _closepage
+	    _closedoc
+	}
+
+	#  _print_canvas
+	# Main procedure for writing canvas widget items to printer.
+	# Arguments:
+	#    hdc -              The printer handle.
+	#    cw  -              The canvas widget.
+	proc _print_canvas {hdc cw} {
+	    variable  vtgPrint
+	    variable printargs
+
+	    # Get information about page being printed to
+	    # print_canvas.CalcSizing $cw
+	    set vtgPrint(canvas.bg) [string tolower [$cw cget -background]]
+
+	    # Re-write each widget from cw to printer
+	    foreach id [$cw find all] {
+		set type [$cw type $id]
+		if {[info commands _print_canvas.$type] eq "_print_canvas.$type"} {
+		    _print_canvas.[$cw type $id] $printargs(hDC) $cw $id
+		} else {
+		    puts "Omitting canvas item of type $type since there is no handler registered for it"
+		}
+	    }
+	}
+
+	# These procedures support the various canvas item types, reading the
+	# information about the item on the real canvas and then writing a
+	# similar item to the printer.
+
+	# _print_canvas.line
+	# Description:
+	#   Prints a line item.
+	# Arguments:
+	#   hdc -              The printer handle.
+	#   cw  -              The canvas widget.
+	#   id  -              The id of the canvas item.
+	proc _print_canvas.line {hdc cw id} {
+	    variable vtgPrint
+	    variable printargs
+
+	    set color [_print_canvas.TransColor [$cw itemcget $id -fill]]
+	    if {[string match $vtgPrint(printer.bg) $color]} {
+		return
+	    }
+
+	    set coords  [$cw coords $id]
+	    set wdth    [$cw itemcget $id -width]
+	    set arrow   [$cw itemcget $id -arrow]
+	    set arwshp  [$cw itemcget $id -arrowshape]
+	    set dash    [$cw itemcget $id -dash]
+	    set smooth  [$cw itemcget $id -smooth]
+	    set splinesteps [$cw itemcget $id -splinesteps]
+
+	    set cmdargs {}
+
+	    if {$wdth > 1} {
+		lappend cmdargs -width $wdth
+	    }
+	    if {$dash ne ""} {
+		lappend cmdargs -dash $dash
+	    }
+	    if {$smooth ne ""} {
+		lappend cmdargs -smooth $smooth
+	    }
+	    if {$splinesteps ne ""} {
+		lappend cmdargs -splinesteps $splinesteps
+	    }
+
+	    set result [_gdi line $hdc {*}$coords \
+			    -fill $color -arrow $arrow -arrowshape $arwshp \
+			    {*}$cmdargs]
+	    if {$result ne ""} {
+		puts $result
+	    }
+	}
+
+	# _print_canvas.arc
+	#   Prints a arc item.
+	# Args:
+	#   hdc -              The printer handle.
+	#   cw  -              The canvas widget.
+	#   id  -              The id of the canvas item.
+	proc _print_canvas.arc {hdc cw id} {
+	    variable vtgPrint
+	    variable printargs
+
+	    set color [_print_canvas.TransColor [$cw itemcget $id -outline]]
+	    if {[string match $vtgPrint(printer.bg) $color]} {
+		return
+	    }
+	    set coords  [$cw coords $id]
+	    set wdth    [$cw itemcget $id -width]
+	    set style   [$cw itemcget $id -style]
+	    set start   [$cw itemcget $id -start]
+	    set extent  [$cw itemcget $id -extent]
+	    set fill    [$cw itemcget $id -fill]
+
+	    set cmdargs {}
+	    if {$wdth > 1} {
+		lappend cmdargs -width $wdth
+	    }
+	    if {$fill ne ""} {
+		lappend cmdargs -fill $fill
+	    }
+
+	    _gdi arc $hdc {*}$coords \
+		-outline $color -style $style -start $start -extent $extent \
+		{*}$cmdargs
+	}
+
+	# _print_canvas.polygon
+	#   Prints a polygon item.
+	# Arguments:
+	#   hdc -              The printer handle.
+	#   cw  -              The canvas widget.
+	#   id  -              The id of the canvas item.
+	proc _print_canvas.polygon {hdc cw id} {
+	    variable vtgPrint
+	    variable printargs
+
+	    set fcolor [_print_canvas.TransColor [$cw itemcget $id -fill]]
+	    if {$fcolor eq ""} {
+		set fcolor $vtgPrint(printer.bg)
+	    }
+	    set ocolor [_print_canvas.TransColor [$cw itemcget $id -outline]]
+	    if {$ocolor eq ""} {
+		set ocolor $vtgPrint(printer.bg)
+	    }
+	    set coords  [$cw coords $id]
+	    set wdth [$cw itemcget $id -width]
+	    set smooth  [$cw itemcget $id -smooth]
+	    set splinesteps [$cw itemcget $id -splinesteps]
+
+	    set cmdargs {}
+	    if {$smooth ne ""} {
+		lappend cmdargs -smooth $smooth
+	    }
+	    if {$splinesteps ne ""} {
+		lappend cmdargs -splinesteps $splinesteps
+	    }
+
+	    _gdi polygon $hdc {*}$coords \
+		-width $wdth -fill $fcolor -outline $ocolor {*}$cmdargs
+	}
+
+	# _print_canvas.oval
+	#   Prints an oval item.
+	# Arguments:
+	#   hdc -              The printer handle.
+	#   cw  -              The canvas widget.
+	#   id  -              The id of the canvas item.
+	proc _print_canvas.oval {hdc cw id} {
+	    variable vtgPrint
+
+	    set fcolor [_print_canvas.TransColor [$cw itemcget $id -fill]]
+	    if {$fcolor eq ""} {
+		set fcolor $vtgPrint(printer.bg)
+	    }
+	    set ocolor [_print_canvas.TransColor [$cw itemcget $id -outline]]
+	    if {$ocolor eq ""} {
+		set ocolor $vtgPrint(printer.bg)
+	    }
+	    set coords  [$cw coords $id]
+	    set wdth [$cw itemcget $id -width]
+
+	    _gdi oval $hdc {*}$coords \
+		-width $wdth -fill $fcolor -outline $ocolor
+	}
+
+	# _print_canvas.rectangle
+	#   Prints a rectangle item.
+	# Arguments:
+	#   hdc -              The printer handle.
+	#   cw  -              The canvas widget.
+	#   id  -              The id of the canvas item.
+	proc _print_canvas.rectangle {hdc cw id} {
+	    variable vtgPrint
+
+	    set fcolor [_print_canvas.TransColor [$cw itemcget $id -fill]]
+	    if {$fcolor eq ""} {
+		set fcolor $vtgPrint(printer.bg)
+	    }
+	    set ocolor [_print_canvas.TransColor [$cw itemcget $id -outline]]
+	    if {$ocolor eq ""} {
+		set ocolor $vtgPrint(printer.bg)
+	    }
+	    set coords  [$cw coords $id]
+	    set wdth [$cw itemcget $id -width]
+
+	    _gdi rectangle $hdc {*}$coords \
+		-width $wdth -fill $fcolor -outline $ocolor
+	}
+
+	# _print_canvas.text
+	#   Prints a text item.
+	# Arguments:
+	#   hdc -              The printer handle.
+	#   cw  -              The canvas widget.
+	#   id  -              The id of the canvas item.
+	proc _print_canvas.text {hdc cw id} {
+	    variable vtgPrint
+	    variable printargs
+
+	    set color [_print_canvas.TransColor [$cw itemcget $id -fill]]
+	    #    if {"white" eq [string tolower $color]} {return}
+	    #    set color black
+	    set txt [$cw itemcget $id -text]
+	    if {$txt eq ""} {
+		return
+	    }
+	    set coords [$cw coords $id]
+	    set anchr [$cw itemcget $id -anchor]
+
+	    set bbox [$cw bbox $id]
+	    set wdth [expr {[lindex $bbox 2] - [lindex $bbox 0]}]
+
+	    set just [$cw itemcget $id -justify]
+
+	    # Get the real canvas font info and create a compatible font,
+	    # suitable for printer name extraction.
+	    set font [font create {*}[font actual [$cw itemcget $id -font]]]
+
+	    # Just get the name and family, or some of the _gdi commands will
+	    # fail.
+	    set font [list [font configure $font -family] \
+			  -[font configure $font -size]]
+
+	    _gdi text $hdc {*}$coords \
+		-fill $color -text $txt -font $font \
+		-anchor $anchr -width $wdth -justify $just
+	}
+
+	# _print_canvas.image
+	# Prints an image item.
+	# Arguments:
+	#   hdc -              The printer handle.
+	#   cw  -              The canvas widget.
+	#   id  -              The id of the canvas item.
+	proc _print_canvas.image {hdc cw id} {
+	    # First, we have to get the image name.
+	    set imagename [$cw itemcget $id -image]
+
+	    # Now we get the size.
+	    set wid [image width $imagename]
+	    set hgt [image height $imagename]
+
+	    # Next, we get the location and anchor
+	    set anchor [$cw itemcget $id -anchor]
+	    set coords [$cw coords $id]
+
+	    _gdi photo $hdc -destination $coords -photo $imagename
+	}
+
+	# _print_canvas.bitmap
+	#   Prints a bitmap item.
+	# Arguments:
+	#   hdc -              The printer handle.
+	#   cw  -              The canvas widget.
+	#   id  -              The id of the canvas item.
+	proc _print_canvas.bitmap {hdc cw id} {
+	    variable option
+	    variable vtgPrint
+
+	    # First, we have to get the bitmap name.
+	    set imagename [$cw itemcget $id -image]
+
+	    # Now we get the size.
+	    set wid [image width $imagename]
+	    set hgt [image height $imagename]
+
+	    #Next, we get the location and anchor.
+	    set anchor [$cw itemcget $id -anchor]
+	    set coords [$cw coords $id]
+
+	    # Since the GDI commands don't yet support images and bitmaps,
+	    # and since this represents a rendered bitmap, we CAN use
+	    # copybits IF we create a new temporary toplevel to hold the beast.
+	    # If this is too ugly, change the option!
+
+	    if {[info exist option(use_copybits)]} {
+		set firstcase $option(use_copybits)
+	    } else {
+		set firstcase 0
+	    }
+	    if {$firstcase > 0} {
+		set tl [toplevel .tmptop[expr {int( rand() * 65535 )}] \
+			    -height $hgt -width $wid \
+			    -background $vtgPrint(canvas.bg)]
+		canvas $tl.canvas -width $wid -height $hgt
+		$tl.canvas create image 0 0 -image $imagename -anchor nw
+		pack $tl.canvas -side left -expand false -fill none
+		tkwait visibility $tl.canvas
+		update
+		set srccoords [list 0 0 [expr {$wid - 1}] [expr {$hgt - 1}]]
+		set dstcoords [list [lindex $coords 0] [lindex $coords 1] [expr {$wid - 1}] [expr {$hgt - 1}]]
+		_gdi copybits $hdc -window $tl -client \
+		    -source $srccoords -destination $dstcoords
+		destroy $tl
+	    } else {
+		_gdi bitmap $hdc {*}$coords \
+		    -anchor $anchor -bitmap $imagename
+	    }
+	}
+
+	# These procedures transform attribute setting from the real
+	# canvas to the appropriate setting for printing to paper.
+
+	# _print_canvas.TransColor
+	#   Does the actual transformation of colors from the
+	#   canvas widget to paper.
+	# Arguments:
+	#   color -            The color value to be transformed.
+	proc _print_canvas.TransColor {color} {
+	    variable vtgPrint
+	    variable printargs
+
+	    switch [string toupper $color] {
+		$vtgPrint(canvas.bg)       {return $vtgPrint(printer.bg)}
+	    }
+	    return $color
+	}
+
+	# Initialize all the variables once.
+	_init_print_canvas
+    }
+    #end win32 procedures
+
+    #begin X11 procedures
+
+    # X11 procedures wrap standard Unix shell commands such as lp/lpr and
+    # lpstat for printing. Some output configuration that on other platforms
+    # is managed through the printer driver/dialog is configured through the
+    # canvas postscript command.
+
+    if {[tk windowingsystem] eq "x11"} {
+	variable printcmd {}
+
+	# print options
+	variable optlist
+	set optlist(printer) {}
+	set optlist(paper)   [list [mc "Letter"] [mc "Legal"] [mc "A4"]]
+	set optlist(orient)  [list [mc "Portrait"] [mc "Landscape"]]
+	set optlist(color)   [list [mc "Grayscale"] [mc "RGB"]]
+	set optlist(zoom)    {100 90 80 70 60 50 40 30 20 10}
+
+	# selected options
+	variable sel
+	array set sel {
+	    printer {}
+	    copies  {}
+	    paper   {}
+	    orient  {}
+	    color   {}
+	    zoom    {}
+	}
+
+	# default values for dialog widgets
+	option add *Printdialog*TLabel.anchor e
+	option add *Printdialog*TMenubutton.Menu.tearOff 0
+	option add *Printdialog*TMenubutton.width 12
+	option add *Printdialog*TSpinbox.width 12
+	# this is tempting to add, but it's better to leave it to user's taste
+	# option add *Printdialog*Menu.background snow
+
+	# returns the full qualified var name
+	proc myvar {varname} {
+	    set fqvar [uplevel 1 [list namespace which -variable $varname]]
+	    # assert var existence
+	    if {$fqvar eq ""} {
+		return -code error "Wrong varname \"$varname\""
+	    }
+	    return $fqvar
+	}
+
+	# ttk version of [tk_optionMenu]
+	# var should be a full qualified varname
+	proc ttk_optionMenu {w var args} {
+	    ttk::menubutton $w \
+		-textvariable $var \
+		-menu $w.menu
+	    menu $w.menu
+	    foreach option $args {
+		$w.menu add command \
+		    -label $option \
+		    -command [list set $var $option]
+	    }
+	    # return the same value as tk_optionMenu
+	    return $w.menu
+	}
+
+	# _setprintenv
+	#  Set the print environtment - print command, and list of printers.
+	#  Arguments:
+	#    none.
+
+	proc _setprintenv {} {
+	    variable printcmd
+	    variable optlist
+
+	    #Test for existence of lpstat command to obtain list of printers. Return error
+	    #if not found.
+
+	    catch {exec lpstat -a} msg
+	    set notfound "command not found"
+	    if {[string first $notfound $msg] >= 0} {
+		error "Unable to obtain list of printers. Please install the CUPS package \
+		for your system."
+		return
+	    }
+ 	    set notfound "No destinations added"
+ 	    if {[string first $notfound $msg] != -1} {
+		error "Please check or update your CUPS installation."
+		return
+	    }
+
+	    # Select print command. We prefer lpr, but will fall back to lp if
+	    # necessary.
+	    if {[auto_execok lpr] ne ""} {
+		set printcmd lpr
+	    } else {
+		set printcmd lp
+	    }
+
+	    #Build list of printers
+	    set printers {}
+	    set printdata [exec lpstat -a]
+	    foreach item [split $printdata \n] {
+		lappend printers [lindex [split $item] 0]
+	    }
+	    # filter out duplicates
+	    set optlist(printer) [lsort -unique $printers]
+	}
+
+	# _print
+	#  Main printer dialog. Select printer, set options, and
+	#  fire print command.
+	# Arguments:
+	#  w - widget with contents to print.
+	#
+
+	proc _print {w} {
+	# TODO: revise padding
+	    variable optlist
+	    variable sel
+
+	    # should this be called with every invocaton?
+	    _setprintenv
+	    if {$sel(printer) eq "" && [llength $optlist(printer)] > 0} {
+		set sel(printer) [lindex $optlist(printer) 0]
+	    }
+
+	    set p ._print
+	    catch {destroy $p}
+
+	    # copy the current values to a dialog's temorary variable
+	    # this allow us to cancel the dialog discarding any changes
+	    # made to the options
+	    namespace eval dlg {variable sel}
+	    array set dlg::sel [array get sel]
+
+	    # The toplevel of our dialog
+	    toplevel $p -class Printdialog
+	    place [ttk::frame $p.background] -x 0 -y 0 -relwidth 1.0 -relheight 1.0
+	    wm title $p [mc "Print"]
+	    wm resizable $p 0 0
+	    wm attributes $p -type dialog
+
+	    # The printer to use
+	    set pf [ttk::frame $p.printerf]
+	    pack $pf -side top -fill x -expand no -padx 12 -pady 12
+
+	    ttk::label $pf.printerl -text "[mc "Printer"] :"
+	    ttk::combobox $pf.printer \
+		-textvariable [myvar dlg::sel](printer) \
+		-state readonly \
+		-values $optlist(printer)
+	    pack $pf.printerl -side left -padx {0 6}
+	    pack $pf.printer  -side left
+
+	    # Start of printing options
+	    set of [ttk::labelframe $p.optionsframe -text [mc "Options"]]
+	    pack $of -fill x -padx 12 -pady {0 12} -ipadx 3 -ipady 3
+
+	    # COPIES
+	    ttk::label $of.copiesl -text "[mc "Copies"] :"
+	    ttk::spinbox $of.copies -from 1 -to 1000 \
+		-textvariable [myvar dlg::sel](copies) \
+		-width 5
+	    grid  $of.copiesl $of.copies -sticky ew -padx 3 -pady 3
+
+	    # PAPER SIZE
+	    ttk::label $of.paperl -text "[mc "Paper"] :"
+	    ttk_optionMenu $of.paper [myvar dlg::sel](paper) {*}$optlist(paper)
+	    grid $of.paperl $of.paper -sticky ew -padx 3 -pady 3
+
+	    # additional options for canvas output
+	    if {[winfo class $w] eq "Canvas"} {
+		# SCALE
+		ttk::label $of.percentl -text "[mc "Scale"] :"
+		ttk_optionMenu $of.percent [myvar dlg::sel](zoom) {*}$optlist(zoom)
+		grid $of.percentl $of.percent -sticky ew -padx 3 -pady 3
+
+		# ORIENT
+		ttk::label $of.orientl -text "[mc "Orientation"] :"
+		ttk_optionMenu $of.orient [myvar dlg::sel](orient) {*}$optlist(orient)
+		grid $of.orientl $of.orient -sticky ew -padx 3 -pady 3
+
+		# COLOR
+		ttk::label $of.colorl -text "[mc "Output"] :"
+		ttk_optionMenu $of.color [myvar dlg::sel](color) {*}$optlist(color)
+		grid $of.colorl $of.color -sticky ew -padx 3 -pady 3
+	    }
+
+	    # The buttons frame.
+	    set bf [ttk::frame $p.buttonf]
+	    pack $bf -fill x -expand no -side bottom -padx 12 -pady {0 12}
+
+	    ttk::button $bf.print -text [mc "Print"] \
+		-command [namespace code [list _runprint $w $p]]
+	    ttk::button $bf.cancel -text [mc "Cancel"] \
+		-command [namespace code [list _cancel $p]]
+	    pack $bf.print  -side right
+	    pack $bf.cancel -side right -padx {0 6}
+	    #Center the window as a dialog.
+	    ::tk::PlaceWindow $p
+	}
+
+	proc _cancel {p} {
+	    namespace delete dlg
+	    destroy $p
+	}
+
+	# _runprint -
+	#   Execute the print command--print the file.
+	# Arguments:
+	#  w - widget with contents to print.
+	#
+	proc _runprint {w p} {
+	    variable printcmd
+	    variable sel
+
+	    # copy the values back from the dialog
+	    array set sel [array get dlg::sel]
+	    namespace delete dlg
+
+	    #First, generate print file.
+	    if {[winfo class $w] eq "Text"} {
+		set file [makeTempFile tk_text.txt [$w get 1.0 end]]
+	    }
+
+	    if {[winfo class $w] eq "Canvas"} {
+		if {$sel(color) eq [mc "RGB"]} {
+		    set colormode color
+		} else {
+		    set colormode gray
+		}
+
+		if {$sel(orient) eq [mc "Landscape"]} {
+		    set willrotate "1"
+		} else {
+		    set willrotate "0"
+		}
+
+		#Scale based on size of widget, not size of paper.
+		set printwidth [expr {$sel(zoom) / 100.00 * [winfo width $w]}]
+		set file [makeTempFile tk_canvas.ps]
+		$w postscript -file $file -colormode $colormode \
+		    -rotate $willrotate -pagewidth $printwidth
+	    }
+
+	    #Build list of args to pass to print command.
+	    set printargs {}
+	    if {$printcmd eq "lpr"} {
+		lappend printargs -P $sel(printer) -# $sel(copies)
+	    } else {
+		lappend printargs -d $sel(printer) -n $sel(copies)
+	    }
+
+	    # launch the job in the background
+	    after 0 [list exec $printcmd {*}$printargs -o PageSize=$sel(paper) $file]
+	    destroy $p
+	}
+
+	# Initialize with sane defaults.
+	set sel(copies)  1
+	set sel(paper)   [mc "A4"]
+	set sel(orient)  [mc "Portrait"]
+	set sel(color)   [mc "RGB"]
+	set sel(zoom)    100
+    }
+    #end X11 procedures
+
+    #begin macOS Aqua procedures
+    if {[tk windowingsystem] eq "aqua"} {
+	# makePDF -
+	#   Convert a file to PDF
+	# Arguments:
+	#   inFilename -  file containing the data to convert; format is
+	#                 autodetected.
+	#   outFilename - base for filename to write to; conventionally should
+	#                 have .pdf as suffix
+	# Returns:
+	#   The full pathname of the generated PDF.
+	#
+	proc makePDF {inFilename outFilename} {
+	    set out [::tk::print::makeTempFile $outFilename]
+	    try {
+		exec /usr/sbin/cupsfilter $inFilename > $out
+	    } trap NONE {msg} {
+		# cupsfilter produces a lot of debugging output, which we
+		# don't want.
+		regsub -all -line {^(?:DEBUG|INFO):.*$} $msg "" msg
+		set msg [string trimleft [regsub -all {\n+} $msg "\n"] "\n"]
+		if {$msg ne ""} {
+		    # Lines should be prefixed with WARN or ERROR now
+		    puts $msg
+		}
+	    }
+	    return $out
+	}
+    }
+    #end macOS Aqua procedures
+
+    namespace export canvas text
+    namespace ensemble create
+}
+
+# tk print --
+# This procedure prints the canvas and text widgets using platform-
+# native API's.
+#   Arguments:
+#      w: Widget to print.
+proc ::tk::print {w} {
+    switch [winfo class $w],[tk windowingsystem] {
+	"Canvas,win32" {
+	    tailcall ::tk::print::_print_widget $w 0 "Tk Print Output"
+	}
+	"Canvas,x11" {
+	    tailcall ::tk::print::_print $w
+	}
+	"Canvas,aqua" {
+	    set psfile [::tk::print::makeTempFile tk_canvas.ps]
+	    try {
+		$w postscript -file $psfile
+		set printfile [::tk::print::makePDF $psfile tk_canvas.pdf]
+		::tk::print::_print $printfile
+	    } finally {
+		file delete $psfile
+	    }
+	}
+
+	"Text,win32" {
+	    tailcall ::tk::print::_print_data [$w get 1.0 end] 1 {Arial 12}
+	}
+	"Text,x11" {
+	    tailcall ::tk::print::_print $w
+	}
+	"Text,aqua" {
+	    set txtfile [::tk::print::makeTempFile tk_text.txt [$w get 1.0 end]]
+	    try {
+		set printfile [::tk::print::makePDF $txtfile tk_text.pdf]
+		::tk::print::_print $printfile
+	    } finally {
+		file delete $txtfile
+	    }
+	}
+
+	default {
+	    return -code error -errorcode {TK PRINT CLASS_UNSUPPORTED} \
+		"widgets of class [winfo class $w] are not supported on\
+		this platform"
+	}
+    }
+}
+
+#Add this command to the tk command ensemble: tk print
+#Thanks to Christian Gollwitzer for the guidance here
+namespace ensemble configure tk -map \
+    [dict merge [namespace ensemble configure tk -map] \
+	 {print ::tk::print}]
+
+return
+
+# Local Variables:
+# mode: tcl
+# fill-column: 78
+# End:

Index: library/scale.tcl
==================================================================
--- library/scale.tcl
+++ library/scale.tcl
@@ -200,11 +200,24 @@
 #		first action in an auto-repeat sequence, and "again"
 #		means this is the second repetition or later.
 
 proc ::tk::ScaleIncrement {w dir big repeat} {
     variable ::tk::Priv
+
     if {![winfo exists $w]} return
+
+    # give the cancel callback a chance to be serviced if the execution time of
+    # the -command script lasts longer than -repeatdelay
+    set clockms [clock milliseconds]
+    if {$repeat eq "again" &&
+            [expr {$clockms - $Priv(clockms)}] > [expr {[$w cget -repeatinterval] * 1.1}]} {
+        set Priv(clockms) $clockms
+	set Priv(afterId) [after [$w cget -repeatinterval] \
+		[list tk::ScaleIncrement $w $dir $big again]]
+	return
+    }
+
     if {$big eq "big"} {
 	set inc [$w cget -bigincrement]
 	if {$inc == 0} {
 	    set inc [expr {abs([$w cget -to] - [$w cget -from])/10.0}]
 	}
@@ -221,18 +234,22 @@
     } else {
         if {$inc < 0} {
             set inc [expr {-$inc}]
         }
     }
+    # this will run the -command script (if any) during the redrawing
+    # of the scale at idle time
     $w set [expr {[$w get] + $inc}]
 
     if {$repeat eq "again"} {
+        set Priv(clockms) $clockms
 	set Priv(afterId) [after [$w cget -repeatinterval] \
 		[list tk::ScaleIncrement $w $dir $big again]]
     } elseif {$repeat eq "initial"} {
 	set delay [$w cget -repeatdelay]
 	if {$delay > 0} {
+	    set Priv(clockms) $clockms
 	    set Priv(afterId) [after $delay \
 		    [list tk::ScaleIncrement $w $dir $big again]]
 	}
     }
 }

Index: library/scrlbar.tcl
==================================================================
--- library/scrlbar.tcl
+++ library/scrlbar.tcl
@@ -128,14 +128,14 @@
     tk::ScrollToPos %W 1
 }
 }
 
 bind Scrollbar <MouseWheel> {
-    tk::ScrollByUnits %W hv %D -30.0
+    tk::ScrollByUnits %W hv %D -40.0
 }
 bind Scrollbar <Option-MouseWheel> {
-    tk::ScrollByUnits %W hv %D -3.0
+    tk::ScrollByUnits %W hv %D -12.0
 }
 
 # tk::ScrollButtonDown --
 # This procedure is invoked when a button is pressed in a scrollbar.
 # It changes the way the scrollbar is displayed and takes actions

Index: library/spinbox.tcl
==================================================================
--- library/spinbox.tcl
+++ library/spinbox.tcl
@@ -127,21 +127,21 @@
 bind Spinbox <<NextLine>> {
     %W invoke buttondown
 }
 
 bind Spinbox <<PrevChar>> {
-    ::tk::EntrySetCursor %W [expr {[%W index insert] - 1}]
+    ::tk::EntrySetCursor %W [tk::EntryPreviousChar %W insert]
 }
 bind Spinbox <<NextChar>> {
-    ::tk::EntrySetCursor %W [expr {[%W index insert] + 1}]
+    ::tk::EntrySetCursor %W [tk::EntryNextChar %W insert]
 }
 bind Spinbox <<SelectPrevChar>> {
-    ::tk::EntryKeySelect %W [expr {[%W index insert] - 1}]
+    ::tk::EntryKeySelect %W [tk::EntryPreviousChar %W insert]
     ::tk::EntrySeeInsert %W
 }
 bind Spinbox <<SelectNextChar>> {
-    ::tk::EntryKeySelect %W [expr {[%W index insert] + 1}]
+    ::tk::EntryKeySelect %W [tk::EntryNextChar %W insert]
     ::tk::EntrySeeInsert %W
 }
 bind Spinbox <<PrevWord>> {
     ::tk::EntrySetCursor %W [::tk::EntryPreviousWord %W insert]
 }
@@ -173,11 +173,12 @@
 
 bind Spinbox <Delete> {
     if {[%W selection present]} {
 	%W delete sel.first sel.last
     } else {
-	%W delete insert
+	%W delete [tk::startOfCluster [%W get] [%W index insert]] \
+		[tk::endOfGlyphCluster [%W get] [%W index insert]]
     }
 }
 bind Spinbox <BackSpace> {
     ::tk::EntryBackspace %W
 }
@@ -202,11 +203,11 @@
 }
 bind Spinbox <Key> {
     ::tk::EntryInsert %W %A
 }
 
-# Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
+# Ignore all Alt, Meta, Control, Command, and Fn keypresses unless explicitly bound.
 # Otherwise, if a widget binding for one of these is defined, the
 # <Key> class binding will also fire and insert the character,
 # which is wrong.  Ditto for Escape, Return, and Tab.
 
 bind Spinbox <Alt-Key> {# nothing}
@@ -216,13 +217,12 @@
 bind Spinbox <Return> {# nothing}
 bind Spinbox <KP_Enter> {# nothing}
 bind Spinbox <Tab> {# nothing}
 bind Spinbox <Prior> {# nothing}
 bind Spinbox <Next> {# nothing}
-if {[tk windowingsystem] eq "aqua"} {
-    bind Spinbox <Command-Key> {# nothing}
-}
+bind Spinbox <Command-Key> {# nothing}
+bind Spinbox <Fn-Key> {# nothing}
 
 # On Windows, paste is done using Shift-Insert.  Shift-Insert already
 # generates the <<Paste>> event, so we don't need to do anything here.
 if {[tk windowingsystem] ne "win32"} {
     bind Spinbox <Insert> {
@@ -467,15 +467,15 @@
 		}
 	    }
 	}
 	word {
 	    if {$cur < [$w index anchor]} {
-		set before [tcl_wordBreakBefore [$w get] $cur]
-		set after [tcl_wordBreakAfter [$w get] $anchor-1]
+		set before [tk::wordBreakBefore [$w get] $cur]
+		set after [tk::wordBreakAfter [$w get] $anchor-1]
 	    } else {
-		set before [tcl_wordBreakBefore [$w get] $anchor]
-		set after [tcl_wordBreakAfter [$w get] $cur-1]
+		set before [tk::wordBreakBefore [$w get] $anchor]
+		set after [tk::wordBreakAfter [$w get] $cur-1]
 	    }
 	    if {$before < 0} {
 		set before 0
 	    }
 	    if {$after < 0} {

ADDED   library/systray.tcl
Index: library/systray.tcl
==================================================================
--- /dev/null
+++ library/systray.tcl
@@ -0,0 +1,382 @@
+# systray.tcl --
+
+# This file defines the 'tk systray' command for icon display and manipulation
+# in the system tray on X11, Windows, and macOS, and the 'tk sysnotify' command
+# for system alerts on each platform. It implements an abstraction layer that
+# presents a consistent API across the three platforms.
+
+# Copyright © 2020 Kevin Walzer/WordTech Communications LLC.
+# Copyright © 2020 Eric Boudaillier.
+# Copyright © 2020 Francois Vogel.
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+
+# Pure-Tcl system tooltip window for use with system tray icon if native
+# implementation not available.
+
+namespace eval ::tk::systray {
+    variable _created 0
+    variable _options {-image "" -text "" -button1 "" -button3 ""}
+    variable _current {}
+    variable _ico
+
+    proc _balloon {w help} {
+	bind $w <Any-Enter> "after 100 [list [namespace current]::_balloon_show %W [list $help] cursor]"
+	bind $w <Any-Leave> "destroy %W._balloon"
+    }
+
+    proc _balloon_show {w msg i} {
+	if {![winfo exists $w]} { return }
+
+	# Use string match to allow that the help will be shown when
+	# the pointer is in any child of the desired widget
+	if {([winfo class $w] ne "Menu") && ![string match $w* [eval [list winfo containing] \
+								    [winfo pointerxy $w]]]} {
+	    return
+	}
+
+	set top $w._balloon
+	catch {destroy $top}
+	toplevel $top -bg black -bd 1
+	wm overrideredirect $top 1
+	if {[tk windowingsystem] eq "aqua"}  {
+	    ::tk::unsupported::MacWindowStyle style $top help none
+	}
+	pack [message $top._txt -aspect 10000 -text $msg]
+
+	update idletasks
+	set screenw [winfo screenwidth $w]
+	set screenh [winfo screenheight $w]
+	set reqw [winfo reqwidth $top]
+	set reqh [winfo reqheight $top]
+	# When adjusting for being on the screen boundary, check that we are
+	# near the "edge" already, as Tk handles multiple monitors oddly
+	if {$i eq "cursor"} {
+	    set y [expr {[winfo pointery $w]+20}]
+	    if {($y < $screenh) && ($y+$reqh) > $screenh} {
+		set y [expr {[winfo pointery $w]-$reqh-5}]
+	    }
+	} elseif {$i ne ""} {
+	    set y [expr {[winfo rooty $w]+[winfo vrooty $w]+[$w yposition $i]+25}]
+	    if {($y < $screenh) && ($y+$reqh) > $screenh} {
+		# show above if we would be offscreen
+		set y [expr {[winfo rooty $w]+[$w yposition $i]-$reqh-5}]
+	    }
+	} else {
+	    set y [expr {[winfo rooty $w]+[winfo vrooty $w]+[winfo height $w]+5}]
+	    if {($y < $screenh) && ($y+$reqh) > $screenh} {
+		# show above if we would be offscreen
+		set y [expr {[winfo rooty $w]-$reqh-5}]
+	    }
+	}
+	if {$i eq "cursor"} {
+	    set x [winfo pointerx $w]
+	} else {
+	    set x [expr {[winfo rootx $w]+[winfo vrootx $w]+ ([winfo width $w]-$reqw)/2}]
+	}
+	# only readjust when we would appear right on the screen edge
+	if {$x<0 && ($x+$reqw)>0} {
+	    set x 0
+	} elseif {($x < $screenw) && ($x+$reqw) > $screenw} {
+	    set x [expr {$screenw-$reqw}]
+	}
+	if {[tk windowingsystem] eq "aqua"} {
+	    set focus [focus]
+	}
+
+	wm geometry $top +$x+$y
+	wm deiconify $top
+	raise $top
+
+	if {[tk windowingsystem] eq "aqua" && $focus ne ""} {
+	    # Aqua's help window steals focus on display
+	    after idle [list focus -force $focus]
+	}
+    }
+
+    proc _win_callback {msg} {
+	variable _current
+	# The API at the Tk level does not feature bindings to double  clicks. Whatever
+	# the speed the user clicks with, he expects the single click binding to fire.
+	# Therefore we need to bind to both WM_*BUTTONDOWN and to WM_*BUTTONDBLCLK.
+	switch -exact -- $msg {
+	    WM_LBUTTONDOWN - WM_LBUTTONDBLCLK {
+		uplevel #0 [dict get $_current -button1]
+	    }
+	    WM_RBUTTONDOWN - WM_RBUTTONDBLCLK {
+		uplevel #0 [dict get $_current -button3]
+	    }
+	}
+    }
+
+    namespace export create configure destroy
+    namespace ensemble create
+}
+
+
+# Pure-Tcl system notification window for use if native implementation not available.
+namespace eval ::tk::sysnotify:: {
+
+    proc _notifywindow {title msg} {
+	catch {destroy ._notify}
+	set w [toplevel ._notify]
+	if {[tk windowingsystem] eq "aqua"} {
+	    ::tk::unsupported::MacWindowStyle style $w utility {hud
+closeBox resizable}
+	    wm title $w "Alert"
+	}
+	if {[tk windowingsystem] eq "win32"} {
+	    wm attributes $w -toolwindow true
+	    wm title $w "Alert"
+	}
+	label $w.l -bg gray30 -fg white -image ::tk::icons::information
+	pack $w.l -fill both -expand yes -side left
+	message $w.message -aspect 150 -bg gray30 -fg white -aspect 150
+-text $title\n\n$msg -width 280
+	pack $w.message -side right -fill both -expand yes
+	if {[tk windowingsystem] eq "x11"} {
+	    wm overrideredirect $w true
+	}
+	wm attributes $w -alpha 0.0
+	set xpos [expr {[winfo screenwidth $w] - 325}]
+	wm geometry $w +$xpos+30
+	::tk::sysnotify::_fade_in $w
+	after 3000 ::tk::sysnotify::_fade_out $w
+    }
+
+    #Fade and destroy window.
+    proc _fade_out {w} {
+	catch {
+	    set prev_degree [wm attributes $w -alpha]
+	    set new_degree [expr {$prev_degree - 0.05}]
+	    set current_degree [wm attributes $w -alpha $new_degree]
+	    if {$new_degree > 0.0 && $new_degree != $prev_degree} {
+		after 10 [list ::tk::sysnotify::_fade_out $w]
+	    } else {
+		destroy $w
+	    }
+	}
+    }
+
+    #Fade the window into view.
+    proc _fade_in {w} {
+	catch {
+	    raise $w
+	    wm attributes $w -topmost 1
+	    set prev_degree [wm attributes $w -alpha]
+	    set new_degree [expr {$prev_degree + 0.05}]
+	    set current_degree [wm attributes $w -alpha $new_degree]
+	    focus -force $w
+	    if {$new_degree < 0.9 && $new_degree != $prev_degree} {
+		after 10 [list ::tk::sysnotify::_fade_in $w]
+	    }
+	}
+    }
+    namespace export *
+}
+
+
+# tk systray --
+# This procedure creates an icon display in the platform-specific system tray.
+#
+# Subcommands:
+#
+#     create - create systray icon.
+#         Arguments:
+#             -image - Tk image to display.
+#             -text - string to display in tooltip over image.
+#             -button1 - Tcl proc to invoke on <Button-1> event.
+#             -button3 - Tcl proc to invoke on <Button-3> event.
+#
+#     configure - change one of the systray properties.
+#         Arguments (Any or all can be called):
+#             -image - Tk image to update.
+#             -text - string to update.
+#             -button1 - Tcl proc to change for <Button-1> event.
+#             -button3  - Tcl proc to change for <Button-3> event.
+#
+#     destroy - destroy systray icon.
+#         Arguments:
+#             none.
+proc ::tk::systray::create {args} {
+    variable _created
+    variable _options
+    variable _current
+    variable _ico
+
+    if {$_created} {
+	return -code error -errorcode {TK SYSTRAY CREATE} "only one system tray icon supported per interpeter"
+    }
+    _check_options $args 0
+    if {![dict exists $args -image]} {
+	return -code error -errorcode {TK SYSTRAY CREATE} "missing required option \"-image\""
+    }
+    set values [dict merge $_options $args]
+    try {
+	switch -- [tk windowingsystem] {
+	    "win32" {
+		set _ico [_systray add -image [dict get $values -image] \
+			-text [dict get $values -text] \
+			-callback [list ::tk::systray::_win_callback %m]]
+	    }
+	    "x11" {
+		_systray ._tray -image [dict get $values -image] -visible true
+		_balloon ._tray [dict get $values -text]
+		bind ._tray <Button-1> [dict get $values -button1]
+		bind ._tray <Button-3> [dict get $values -button3]
+	    }
+	    "aqua" {
+		_systray create [dict get $values -image] [dict get $values -text] \
+			[dict get $values -button1] [dict get $values -button3]
+	    }
+	}
+    } on ok {} {
+	set _current $values
+	set _created 1
+	return
+    } on error {msg opts} {
+	return -code error -errorcode [dict get $opts -errorcode] $msg
+    }
+}
+
+# Modify the systray icon.
+proc ::tk::systray::configure {args} {
+    variable _created
+    variable _options
+    variable _current
+    variable _ico
+
+    if {!$_created} {
+	return -code error -errorcode {TK SYSTRAY CREATE} "systray not created"
+    }
+    _check_options $args 1
+    if {[llength $args] == 0} {
+	return $_current
+    } elseif {[llength $args] == 1} {
+	return [dict get $_current [lindex $args 0]]
+    }
+    set values [dict merge $_current $args]
+    try {
+	switch -- [tk windowingsystem] {
+	    "win32" {
+		if {[dict exists $args -image]} {
+		    _systray modify $_ico -image [dict get $args -image]
+		}
+		if {[dict exists $args -text]} {
+		    _systray modify $_ico -text [dict get $args -text]
+		}
+	    }
+	    "x11" {
+		if {[dict exists $args -image]} {
+		    ._tray configure -image [dict get $args -image]
+		}
+		if {[dict exists $args -text]} {
+		    _balloon ._tray [dict get $args -text]
+		}
+		if {[dict exists $args -button1]} {
+		    bind ._tray <Button-1> [dict get $args -button1]
+		}
+		if {[dict exists $args -button3]} {
+		    bind ._tray <Button-3> [dict get $args -button3]
+		}
+	    }
+	    "aqua" {
+		foreach {key opt} {image -image text \
+			-text b1_callback -button1 b3_callback -button3} {
+		    if {[dict exists $args $opt]} {
+			_systray modify $key [dict get $args $opt]
+		    }
+		}
+	    }
+	}
+    } on ok {} {
+	set _current $values
+	return
+    } on error {msg opts} {
+	return -code error -errorcode [dict get $opts -errorcode] $msg
+    }
+}
+
+
+# Remove the systray icon.
+proc ::tk::systray::destroy {} {
+    variable _created
+    variable _current
+    variable _ico
+
+    if {!$_created} {
+	return -code error -errorcode {TK SYSTRAY DESTROY} "systray not created"
+    }
+    switch -- [tk windowingsystem] {
+	"win32" {
+	    _systray delete $_ico
+	    set _ico ""
+	}
+	"x11" {
+	    ::destroy ._tray
+	}
+	"aqua" {
+	    _systray destroy
+	}
+    }
+    set _created 0
+    set _current {}
+    return
+}
+
+# Check systray options
+proc ::tk::systray::_check_options {argsList singleOk} {
+    variable _options
+
+    set len [llength $argsList]
+    while {[llength $argsList] > 0} {
+        set opt [lindex $argsList 0]
+        if {![dict exists $_options $opt]} {
+            tailcall return -code error -errorcode {TK SYSTRAY OPTION} \
+		"unknown option \"$opt\": must be -image, -text, -button1 or -button3"
+        }
+        if {[llength $argsList] == 1 && !($len == 1 && $singleOk)} {
+            tailcall return -code error -errorcode {TK SYSTRAY OPTION} \
+		"missing value for option \"$opt\""
+        }
+        set argsList [lrange $argsList 2 end]
+    }
+}
+
+# tk sysnotify --
+# This procedure implements a platform-specific system notification alert.
+#
+#   Arguments:
+#       title - main text of alert.
+#       message - body text of alert.
+
+proc ::tk::sysnotify::sysnotify {title message} {
+
+    switch -- [tk windowingsystem] {
+	"win32" {
+	    if {!$::tk::systray::_created} {
+		error "must create a system tray icon with the \"tk systray\" command first"
+	    }
+	    _sysnotify notify $::tk::systray::_ico $title $message
+	}
+	"x11" {
+	    if {[info commands ::tk::sysnotify::_sysnotify] eq ""} {
+		_notifywindow $title $message
+	    } else {
+		_sysnotify $title $message
+	    }
+	}
+	"aqua" {
+	    _sysnotify $title $message
+	}
+    }
+    return
+}
+
+#Add these commands to the tk command ensemble: tk systray, tk sysnotify
+#Thanks to Christian Gollwitzer for the guidance here
+namespace ensemble configure tk -map \
+    [dict merge [namespace ensemble configure tk -map] \
+        {systray ::tk::systray sysnotify ::tk::sysnotify::sysnotify}]
+

Index: library/tearoff.tcl
==================================================================
--- library/tearoff.tcl
+++ library/tearoff.tcl
@@ -29,14 +29,14 @@
     # it a child of the ancestor, rather than a child of the menu, it
     # can continue to live even if the menu is deleted;  it will go
     # away when the toplevel goes away.
 
     if {$x == 0} {
-    	set x [winfo rootx $w]
+	set x [winfo rootx $w]
     }
     if {$y == 0} {
-    	set y [winfo rooty $w]
+	set y [winfo rooty $w]
 	if {[tk windowingsystem] eq "aqua"} {
 	    # Shift by height of tearoff entry minus height of window titlebar
 	    catch {incr y [expr {[$w yposition 1] - 16}]}
 	    # Avoid the native menu bar which sits on top of everything.
 	    if {$y < 22} {set y 22}
@@ -64,18 +64,18 @@
     # original: if the parent is a menu, then use the text of the active
     # entry.  If it's a menubutton then use its text.
 
     set parent [winfo parent $w]
     if {[$menu cget -title] ne ""} {
-    	wm title $menu [$menu cget -title]
+	wm title $menu [$menu cget -title]
     } else {
-    	switch -- [winfo class $parent] {
+	switch -- [winfo class $parent] {
 	    Menubutton {
-	    	wm title $menu [$parent cget -text]
+		wm title $menu [$parent cget -text]
 	    }
 	    Menu {
-	    	wm title $menu [$parent entrycget active -label]
+		wm title $menu [$parent entrycget active -label]
 	    }
 	}
     }
 
     if {[tk windowingsystem] eq "win32"} {
@@ -133,11 +133,11 @@
 	}
 	lappend cmd [lindex $option 0] [lindex $option 4]
     }
     eval $cmd
     set last [$src index last]
-    if {$last eq "none"} {
+    if {$last < 0} {
 	return
     }
     for {set i [$src cget -tearoff]} {$i <= $last} {incr i} {
 	set cmd [list $dst add [$src type $i]]
 	foreach option [$src entryconfigure $i]  {

Index: library/text.tcl
==================================================================
--- library/text.tcl
+++ library/text.tcl
@@ -3,11 +3,11 @@
 # This file defines the default bindings for Tk text widgets and provides
 # procedures that help in implementing the bindings.
 #
 # Copyright © 1992-1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998 by Scriptics Corporation.
+# Copyright © 1998 Scriptics Corporation.
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 #
 
@@ -97,35 +97,35 @@
 # stop an accidental double click triggering <Double-Button-1>
 bind Text <Double-Control-Button-1> { # nothing }
 # stop an accidental movement triggering <B1-Motion>
 bind Text <Control-B1-Motion> { # nothing }
 bind Text <<PrevChar>> {
-    tk::TextSetCursor %W insert-1displayindices
+    tk::TextSetCursor %W [tk::TextPrevPos %W insert tk::startOfCluster]
 }
 bind Text <<NextChar>> {
-    tk::TextSetCursor %W insert+1displayindices
+    tk::TextSetCursor %W [tk::TextNextPos %W insert tk::endOfCluster]
 }
 bind Text <<PrevLine>> {
     tk::TextSetCursor %W [tk::TextUpDownLine %W -1]
 }
 bind Text <<NextLine>> {
     tk::TextSetCursor %W [tk::TextUpDownLine %W 1]
 }
 bind Text <<SelectPrevChar>> {
-    tk::TextKeySelect %W [%W index {insert - 1displayindices}]
+    tk::TextKeySelect %W [tk::TextPrevPos %W insert tk::startOfCluster]
 }
 bind Text <<SelectNextChar>> {
-    tk::TextKeySelect %W [%W index {insert + 1displayindices}]
+    tk::TextKeySelect %W [tk::TextNextPos %W insert tk::endOfCluster]
 }
 bind Text <<SelectPrevLine>> {
     tk::TextKeySelect %W [tk::TextUpDownLine %W -1]
 }
 bind Text <<SelectNextLine>> {
     tk::TextKeySelect %W [tk::TextUpDownLine %W 1]
 }
 bind Text <<PrevWord>> {
-    tk::TextSetCursor %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord]
+    tk::TextSetCursor %W [tk::TextPrevPos %W insert tk::startOfPreviousWord]
 }
 bind Text <<NextWord>> {
     tk::TextSetCursor %W [tk::TextNextWord %W insert]
 }
 bind Text <<PrevPara>> {
@@ -133,11 +133,11 @@
 }
 bind Text <<NextPara>> {
     tk::TextSetCursor %W [tk::TextNextPara %W insert]
 }
 bind Text <<SelectPrevWord>> {
-    tk::TextKeySelect %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord]
+    tk::TextKeySelect %W [tk::TextPrevPos %W insert tk::startOfPreviousWord]
 }
 bind Text <<SelectNextWord>> {
     tk::TextKeySelect %W [tk::TextNextWord %W insert]
 }
 bind Text <<SelectPrevPara>> {
@@ -220,21 +220,23 @@
 bind Text <Delete> {
     if {[tk::TextCursorInSelection %W]} {
 	%W delete sel.first sel.last
     } else {
 	if {[%W compare end != insert+1c]} {
-	    %W delete insert
+	    %W delete [tk::TextPrevPos %W insert+1c tk::startOfCluster] \
+		    [tk::TextNextPos %W insert tk::endOfCluster]
 	}
 	%W see insert
     }
 }
 bind Text <BackSpace> {
     if {[tk::TextCursorInSelection %W]} {
 	%W delete sel.first sel.last
     } else {
 	if {[%W compare insert != 1.0]} {
-	    %W delete insert-1c
+	    %W delete [tk::TextPrevPos %W insert tk::startOfCluster] \
+		    [tk::TextNextPos %W insert-1c tk::endOfCluster]
 	}
 	%W see insert
     }
 }
 
@@ -294,23 +296,22 @@
 }
 bind Text <Key> {
     tk::TextInsert %W %A
 }
 
-# Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
+# Ignore all Alt, Meta, Control, Command, and Fn keypresses unless explicitly bound.
 # Otherwise, if a widget binding for one of these is defined, the
 # <Key> class binding will also fire and insert the character,
 # which is wrong.  Ditto for <Escape>.
 
 bind Text <Alt-Key> {# nothing }
 bind Text <Meta-Key> {# nothing}
 bind Text <Control-Key> {# nothing}
 bind Text <Escape> {# nothing}
 bind Text <KP_Enter> {# nothing}
-if {[tk windowingsystem] eq "aqua"} {
-    bind Text <Command-Key> {# nothing}
-}
+bind Text <Command-Key> {# nothing}
+bind Text <Fn-Key> {# nothing}
 
 # Additional emacs-like bindings:
 
 bind Text <Control-d> {
     if {!$tk_strictMotif && [%W compare end != insert+1c]} {
@@ -355,11 +356,11 @@
     catch { %W edit redo }
 }
 
 bind Text <Meta-b> {
     if {!$tk_strictMotif} {
-	tk::TextSetCursor %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord]
+	tk::TextSetCursor %W [tk::TextPrevPos %W insert tk::startOfPreviousWord]
     }
 }
 bind Text <Meta-d> {
     if {!$tk_strictMotif && [%W compare end != insert+1c]} {
 	%W delete insert [tk::TextNextWord %W insert]
@@ -380,38 +381,52 @@
 	tk::TextSetCursor %W end-1c
     }
 }
 bind Text <Meta-BackSpace> {
     if {!$tk_strictMotif} {
-	%W delete [tk::TextPrevPos %W insert tcl_startOfPreviousWord] insert
+	%W delete [tk::TextPrevPos %W insert tk::startOfPreviousWord] insert
     }
 }
 bind Text <Meta-Delete> {
     if {!$tk_strictMotif} {
-	%W delete [tk::TextPrevPos %W insert tcl_startOfPreviousWord] insert
+	%W delete [tk::TextPrevPos %W insert tk::startOfPreviousWord] insert
     }
 }
 
 # Bindings for IME text input.
 
 bind Text <<TkStartIMEMarkedText>> {
     dict set ::tk::Priv(IMETextMark) "%W" [%W index insert]
 }
 bind Text <<TkEndIMEMarkedText>> {
-    if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } {
-	bell
-    } else {
-	%W tag add IMEmarkedtext $mark insert
-	%W tag configure IMEmarkedtext -underline on
-    }
+    ::tk::TextEndIMEMarkedText %W
 }
 bind Text <<TkClearIMEMarkedText>> {
     %W delete IMEmarkedtext.first IMEmarkedtext.last
 }
 bind Text <<TkAccentBackspace>> {
     %W delete insert-1c
 }
+
+# ::tk::TextEndIMEMarkedText --
+#
+# Handles input method text marking in a text widget.
+#
+# Arguments:
+# w -	The text widget
+
+proc ::tk::TextEndIMEMarkedText {w} {
+    variable Priv
+    if {[catch {
+	set mark [dict get $Priv(IMETextMark) $w]
+    }]} {
+	bell
+	return
+    }
+    $w tag add IMEmarkedtext $mark insert
+    $w tag configure IMEmarkedtext -underline on
+}
 
 # Macintosh only bindings:
 
 if {[tk windowingsystem] eq "aqua"} {
 bind Text <Control-v> {
@@ -440,20 +455,20 @@
     }
 }
 set ::tk::Priv(prevPos) {}
 
 bind Text <MouseWheel> {
-    tk::MouseWheel %W y %D -3.0 pixels
+    tk::MouseWheel %W y %D -4.0 pixels
 }
 bind Text <Option-MouseWheel> {
-    tk::MouseWheel %W y %D -0.3 pixels
+    tk::MouseWheel %W y %D -1.2 pixels
 }
 bind Text <Shift-MouseWheel> {
-    tk::MouseWheel %W x %D -3.0 pixels
+    tk::MouseWheel %W x %D -4.0 pixels
 }
 bind Text <Shift-Option-MouseWheel> {
-    tk::MouseWheel %W x %D -0.3 pixels
+    tk::MouseWheel %W x %D -1.2 pixels
 }
 
 # ::tk::TextClosestGap --
 # Given x and y coordinates, this procedure finds the closest boundary
 # between characters to the given coordinates and returns the index
@@ -573,12 +588,12 @@
 	    } elseif {[$w compare $cur > $last]} {
 		set last $cur
 	    }
 
 	    # Now find word boundaries
-	    set first [TextPrevPos $w "$first + 1c" tcl_wordBreakBefore]
-	    set last [TextNextPos $w "$last - 1c" tcl_wordBreakAfter]
+	    set first [TextPrevPos $w "$first + 1c" tk::wordBreakBefore]
+	    set last [TextNextPos $w "$last - 1c" tk::wordBreakAfter]
 	}
 	line {
 	    # Set initial range based only on the anchor
 	    set first "$anchorname linestart"
 	    set last "$anchorname lineend"
@@ -1067,16 +1082,16 @@
 # w -		The text window in which the cursor is to move.
 # start -	Position at which to start search.
 
 if {[tk windowingsystem] eq "win32"}  {
     proc ::tk::TextNextWord {w start} {
-	TextNextPos $w [TextNextPos $w $start tcl_endOfWord] \
-		tcl_startOfNextWord
+	TextNextPos $w [TextNextPos $w $start tk::endOfWord] \
+		tk::startOfNextWord
     }
 } else {
     proc ::tk::TextNextWord {w start} {
-	TextNextPos $w $start tcl_endOfWord
+	TextNextPos $w $start tk::endOfWord
     }
 }
 
 # ::tk::TextNextPos --
 # Returns the index of the next position after the given starting

Index: library/tk.tcl
==================================================================
--- library/tk.tcl
+++ library/tk.tcl
@@ -9,11 +9,11 @@
 #
 # See the file "license.terms" for information on usage and redistribution of
 # this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
 # Verify that we have Tk binary and script components from the same release
-package require -exact Tk  8.7a4
+package require -exact tk  8.7a6
 
 # Create a ::tk namespace
 namespace eval ::tk {
     # Set up the msgcat commands
     namespace eval msgcat {
@@ -377,11 +377,11 @@
 	event add <<Undo>>		<Control-z> <Control-Lock-Z>
 	event add <<Redo>>		<Control-Z> <Control-Lock-z>
 	# On Darwin/Aqua, buttons from left to right are 1,3,2.  On Darwin/X11 with recent
 	# XQuartz as the X server, they are 1,2,3; other X servers may differ.
 
-	event add <<SelectAll>>		<Control-slash>
+	event add <<SelectAll>>		<Control-/>
 	event add <<SelectNone>>	<Control-backslash>
 	event add <<NextChar>>		<Right>
 	event add <<SelectNextChar>>	<Shift-Right>
 	event add <<PrevChar>>		<Left>
 	event add <<SelectPrevChar>>	<Shift-Left>
@@ -424,11 +424,11 @@
 	event add <<Copy>>		<Control-c> <Control-Insert> <Control-Lock-C>
 	event add <<Paste>>		<Control-v> <Shift-Insert> <Control-Lock-V>
   	event add <<Undo>>		<Control-z> <Control-Lock-Z>
 	event add <<Redo>>		<Control-y> <Control-Lock-Y>
 
-	event add <<SelectAll>>		<Control-slash> <Control-a> <Control-Lock-A>
+	event add <<SelectAll>>		<Control-/> <Control-a> <Control-Lock-A>
 	event add <<SelectNone>>	<Control-backslash>
 	event add <<NextChar>>		<Right>
 	event add <<SelectNextChar>>	<Shift-Right>
 	event add <<PrevChar>>		<Left>
 	event add <<SelectPrevChar>>	<Shift-Left>
@@ -455,11 +455,11 @@
 	event add <<Copy>>		<Command-c> <F3> <Command-Lock-C>
 	event add <<Paste>>		<Command-v> <F4> <Command-Lock-V>
 	event add <<Clear>>		<Clear>
 
 	# Official bindings
-	# See http://support.apple.com/kb/HT1343
+	# See https://support.apple.com/en-us/HT201236
 	event add <<SelectAll>>		<Command-a>
 	event add <<Undo>>		<Command-Key-z> <Command-Lock-Key-Z>
 	event add <<Redo>>		<Shift-Command-Key-z> <Shift-Command-Lock-Key-z>
 	event add <<NextChar>>		<Right> <Control-Key-f> <Control-Lock-Key-F>
 	event add <<SelectNextChar>>	<Shift-Right> <Shift-Control-Key-F> <Shift-Control-Lock-Key-F>
@@ -495,18 +495,23 @@
     proc ::tk::SourceLibFile {file} {
         namespace eval :: [list source -encoding utf-8 [file join $::tk_library $file.tcl]]
     }
     namespace eval ::tk {
 	SourceLibFile icons
+	SourceLibFile iconbadges
 	SourceLibFile button
 	SourceLibFile entry
 	SourceLibFile listbox
 	SourceLibFile menu
 	SourceLibFile panedwindow
+	SourceLibFile print
 	SourceLibFile scale
 	SourceLibFile scrlbar
 	SourceLibFile spinbox
+	if {![interp issafe]} {
+	    SourceLibFile systray
+	}
 	SourceLibFile text
     }
 }
 
 # ----------------------------------------------------------------------
@@ -677,28 +682,131 @@
 	}
     }
     return $maxlen
 }
 
-# For now, turn off the custom mdef proc for the Mac:
-
-if {[tk windowingsystem] eq "aqua"} {
-    namespace eval ::tk::mac {
-	set useCustomMDEF 0
-    }
-}
-
-
 if {[tk windowingsystem] eq "aqua"} {
     #stub procedures to respond to "do script" Apple Events
     proc ::tk::mac::DoScriptFile {file} {
 	uplevel #0 $file
-    	source -encoding utf-8 $file
+	source -encoding utf-8 $file
     }
     proc ::tk::mac::DoScriptText {script} {
 	uplevel #0 $script
-    	eval $script
+	eval $script
+    }
+    #This procedure is required to silence warnings generated
+    #by inline AppleScript execution.
+    proc ::tk::mac::GetDynamicSdef {} {
+         puts ""
+     }
+}
+
+if {[info commands ::tk::endOfWord] eq ""} {
+    proc ::tk::endOfWord {str start {locale {}}} {
+	if {$start < 0} {
+	    set start -1
+	}
+	set start [tcl_endOfWord $str $start]
+	if {$start < 0} {
+	    set start ""
+	}
+	return $start
+    }
+}
+if {[info commands ::tk::startOfNextWord] eq ""} {
+    proc ::tk::startOfNextWord {str start {locale {}}} {
+	if {$start < 0} {
+	    set start -1
+	} elseif {[string match end-* $start]} {
+	    set start [expr {[string length $str]-1-[string range $start 4 end]}]
+	}
+	set start [tcl_startOfNextWord $str $start]
+	if {$start < 0} {
+	    set start ""
+	}
+	return $start
+    }
+}
+if {[info commands ::tk::startOfPreviousWord] eq ""} {
+    proc ::tk::startOfPreviousWord {str start {locale {}}} {
+	if {$start < 0} {
+	    set start -1
+	} elseif {[string match end-* $start]} {
+	    set start [expr {[string length $str]-1-[string range $start 4 end]}]
+	}
+	set start [tcl_startOfPreviousWord $str $start]
+	if {$start < 0} {
+	    set start ""
+	}
+	return $start
+    }
+}
+if {[info commands ::tk::wordBreakBefore] eq ""} {
+    proc ::tk::wordBreakBefore {str start {locale {}}} {
+	if {$start < 0} {
+	    set start -1
+	} elseif {[string match end-* $start]} {
+	    set start [expr {[string length $str]-1-[string range $start 4 end]}]
+	}
+	set start [tcl_wordBreakBefore $str $start]
+	if {$start < 0} {
+	    set start ""
+	}
+	return $start
+    }
+}
+if {[info commands ::tk::wordBreakAfter] eq ""} {
+    proc ::tk::wordBreakAfter {str start {locale {}}} {
+	if {$start < 0} {
+	    set start -1
+	} elseif {[string match end-* $start]} {
+	    set start [expr {[string length $str]-1-[string range $start 4 end]}]
+	}
+	set start [tcl_wordBreakAfter $str $start]
+	if {$start < 0} {
+	    set start ""
+	}
+	return $start
+    }
+}
+if {[info commands ::tk::endOfCluster] eq ""} {
+    proc ::tk::endOfCluster {str start {locale {}}} {
+	if {$start < 0} {
+	    set start -1
+	} elseif {$start eq "end"} {
+	    set start [expr {[string length $str]-1}]
+	} elseif {[string match end-* $start]} {
+	    set start [expr {[string length $str]-1-[string range $start 4 end]}]
+	} elseif {$start >= [string length $str]} {
+	    return ""
+	}
+	if {[string length [string index $str $start]] > 1} {
+	    incr start
+	}
+	incr start
+	return $start
+    }
+}
+if {[info commands ::tk::startOfCluster] eq ""} {
+    proc ::tk::startOfCluster {str start {locale {}}} {
+	if {$start < 0} {
+	    set start -1
+	} elseif {$start eq "end"} {
+	    set start [expr {[string length $str]-1}]
+	} elseif {[string match end-* $start]} {
+	    set start [expr {[string length $str]-1-[string range $start 4 end]}]
+	} elseif {$start >= [string length $str]} {
+	    return [string length $str]
+	}
+	if {[string length [string index $str $start]] < 1} {
+	    incr start -1
+	}
+	if {$start < 0} {
+	    return ""
+	}
+	return $start
     }
 }
 
 # Create a dictionary to store the starting index of the IME marked
 # text in an Entry or Text widget.

Index: library/tkfbox.tcl
==================================================================
--- library/tkfbox.tcl
+++ library/tkfbox.tcl
@@ -579,13 +579,13 @@
 
     # Turn on the busy cursor. BUG?? We haven't disabled X events, though,
     # so the user may still click and cause havoc ...
     #
     set entCursor [$data(ent) cget -cursor]
-    set dlgCursor [$w         cget -cursor]
+    set dlgCursor [$w cget -cursor]
     $data(ent) configure -cursor watch
-    $w         configure -cursor watch
+    $w configure -cursor watch
     update idletasks
 
     $data(icons) deleteall
 
     set showHidden $showHiddenVar
@@ -631,11 +631,11 @@
     }
 
     # turn off the busy cursor.
     #
     $data(ent) configure -cursor $entCursor
-    $w         configure -cursor $dlgCursor
+    $w configure -cursor $dlgCursor
 }
 
 # ::tk::dialog::file::SetPathSilently --
 #
 # 	Sets data(selectPath) without invoking the trace procedure
@@ -907,19 +907,19 @@
 		}
 		Done $w
 	    }
 	}
 	PATH {
-	    tk_messageBox -icon warning -type ok -parent $w \
-		    -message [mc "Directory \"%1\$s\" does not exist." $path]
+	    tk_messageBox -icon warning -type ok -parent $w -message \
+		    [mc "Directory \"%1\$s\" does not exist." $path]
 	    $data(ent) selection range 0 end
 	    $data(ent) icursor end
 	}
 	CHDIR {
 	    tk_messageBox -type ok -parent $w -icon warning -message  \
-		[mc "Cannot change to the directory\
-                     \"%1\$s\".\nPermission denied." $path]
+		    [mc "Cannot change to the directory\
+			\"%1\$s\".\nPermission denied." $path]
 	    $data(ent) selection range 0 end
 	    $data(ent) icursor end
 	}
 	ERROR {
 	    tk_messageBox -type ok -parent $w -icon warning -message \
@@ -1119,12 +1119,11 @@
 	    && [info exists data(-filetypes)] && [llength $data(-filetypes)]
 	    && [info exists data(filterType)] && $data(filterType) ne ""
 	} then {
 	    upvar #0 $data(-typevariable) typeVariable
 	    set typeVariable [lindex $data(origfiletypes) \
-	            [lsearch -exact $data(-filetypes) $data(filterType)] 0]
-
+		    [lsearch -exact $data(-filetypes) $data(filterType)] 0]
 	}
     }
     bind $data(okBtn) <Destroy> {}
     set Priv(selectFilePath) $selectFilePath
 }

Index: library/ttk/altTheme.tcl
==================================================================
--- library/ttk/altTheme.tcl
+++ library/ttk/altTheme.tcl
@@ -6,10 +6,11 @@
 
     variable colors
     array set colors {
 	-frame 		"#d9d9d9"
 	-window		"#ffffff"
+        -alternate	"#f0f0f0"
 	-darker 	"#c3c3c3"
 	-border		"#414141"
 	-activebg 	"#ececec"
 	-disabledfg	"#a3a3a3"
 	-selectbg	"#4a6984"
@@ -91,11 +92,14 @@
 	    -expand [list selected {2 2 1 0}] \
 	    ;
 
 	# Treeview:
 	ttk::style configure Heading -font TkHeadingFont -relief raised
-	ttk::style configure Treeview -background $colors(-window)
+	ttk::style configure Treeview -background $colors(-window) \
+                -stripedbackground $colors(-alternate)
+	ttk::style configure Treeview.Separator \
+                -background $colors(-alternate)
 	ttk::style map Treeview \
 	    -background [list disabled $colors(-frame)\
 				selected $colors(-selectbg)] \
 	    -foreground [list disabled $colors(-disabledfg) \
 				selected $colors(-selectfg)]

Index: library/ttk/aquaTheme.tcl
==================================================================
--- library/ttk/aquaTheme.tcl
+++ library/ttk/aquaTheme.tcl
@@ -24,34 +24,97 @@
 	    -selectforeground {
 		background systemSelectedTextColor
 		!focus systemSelectedTextColor}
 
 	# Button
-	ttk::style configure TButton -anchor center -width -6 \
+	ttk::style configure TButton -anchor center \
 	    -foreground systemControlTextColor
 	ttk::style map TButton \
 	    -foreground {
 		pressed white
-	        {alternate !pressed !background} white}
+	        {alternate !pressed !background} white
+	        disabled systemDisabledControlTextColor}
+
+	# Menubutton
 	ttk::style configure TMenubutton -anchor center -padding {2 0 0 2}
+
+	# Toolbutton
 	ttk::style configure Toolbutton -anchor center
 
+	# Inline Button
+	ttk::style configure InlineButton -anchor center -font TkHeadingFont \
+	    -foreground systemTextBackgroundColor
+	ttk::style map InlineButton \
+	    -foreground {
+		disabled systemWindowBackgroundColor
+	    }
+
+	# Image Button
+	ttk::style configure ImageButton -anchor center -width 1 \
+	    -compound top
+	ttk::style map ImageButton \
+	    -foreground {
+		pressed systemLabelColor
+		!pressed systemSecondaryLabelColor
+	    }
+
+	# Recessed (radio) button
+	font create RecessedFont -family EmphasizedSystem -size 11 -weight bold
+	ttk::style configure RecessedButton \
+	    -foreground systemControlTextColor
+	ttk::style map RecessedButton \
+	    -foreground {
+		{disabled selected} systemWindowBackgroundColor3
+		{disabled !selected} systemDisabledControlTextColor
+		selected systemTextBackgroundColor
+		active white
+		pressed white
+	    } \
+	    -font {
+		selected RecessedFont
+		active RecessedFont
+		pressed RecessedFont
+	    }
+
+	# For Entry, Combobox and Spinbox widgets the selected text background
+	# is the "Highlight color" selected in preferences when the widget
+	# has focus.  It is a gray color when the widget does not have focus or
+	# the window does not have focus. (The background state implies !focus
+	# so we only need to specify !focus.)
+
 	# Entry
 	ttk::style configure TEntry \
 	    -foreground systemTextColor \
 	    -background systemTextBackgroundColor
 	ttk::style map TEntry \
 	    -foreground {
 		disabled systemDisabledControlTextColor
 	    } \
-	    -selectforeground {
-		background systemTextColor
+	    -selectbackground {
+		!focus systemUnemphasizedSelectedTextBackgroundColor
+	    }
+
+	# Combobox:
+	ttk::style map TCombobox \
+	    -foreground {
+		disabled systemDisabledControlTextColor
 	    } \
 	    -selectbackground {
-		background systemTextBackgroundColor
+		!focus systemUnemphasizedSelectedTextBackgroundColor
 	    }
 
+	# Spinbox
+	ttk::style configure TSpinbox \
+	    -foreground systemTextColor \
+	    -background systemTextBackgroundColor
+	ttk::style map TSpinbox \
+	    -foreground {
+		disabled systemDisabledControlTextColor
+	    } \
+	    -selectbackground {
+		!focus systemUnemphasizedSelectedTextBackgroundColor
+	    }
 
 	# Workaround for #1100117:
 	# Actually, on Aqua we probably shouldn't stipple images in
 	# disabled buttons even if it did work...
 	ttk::style configure . -stipple {}
@@ -61,70 +124,42 @@
 	ttk::style configure TNotebook -padding {18 8 18 17}
 	ttk::style configure TNotebook.Tab -padding {12 3 12 2}
 	ttk::style configure TNotebook.Tab -foreground systemControlTextColor
 	ttk::style map TNotebook.Tab \
 	    -foreground {
-		background systemControlTextColor
-		disabled systemDisabledControlTextColor
-		selected systemSelectedTabTextColor}
-
-	# Combobox:
-	ttk::style configure TCombobox \
-	    -foreground systemTextColor \
-	    -background systemTransparent
-	ttk::style map TCombobox \
-	    -foreground {
-		disabled systemDisabledControlTextColor
-	    } \
-	    -selectforeground {
-		background systemTextColor
-	    } \
-	    -selectbackground {
-		background systemTransparent
-	    }
-
-	# Spinbox
-	ttk::style configure TSpinbox \
-	    -foreground systemTextColor \
-	    -background systemTextBackgroundColor \
-	    -selectforeground systemSelectedTextColor \
-	    -selectbackground systemSelectedTextBackgroundColor
-	ttk::style map TSpinbox \
-	    -foreground {
-		disabled systemDisabledControlTextColor
-	    } \
-	    -selectforeground {
-		!active systemTextColor
-	    } \
-	    -selectbackground {
-		!active systemTextBackgroundColor
-		!focus systemTextBackgroundColor
-		focus systemSelectedTextBackgroundColor
-	    }
+		{background !selected} systemControlTextColor
+		{background selected} black
+		{!background selected} systemSelectedTabTextColor
+		disabled systemDisabledControlTextColor}
 
 	# Treeview:
 	ttk::style configure Heading \
 	    -font TkHeadingFont \
 	    -foreground systemTextColor \
 	    -background systemWindowBackgroundColor
 	ttk::style configure Treeview -rowheight 18 \
 	    -background systemTextBackgroundColor \
-	    -foreground systemTextColor \
+            -stripedbackground systemDisabledControlTextColor \
+            -foreground systemTextColor \
 	    -fieldbackground systemTextBackgroundColor
 	ttk::style map Treeview \
 	    -background {
 		selected systemSelectedTextBackgroundColor
 	    }
 
 	# Enable animation for ttk::progressbar widget:
-	ttk::style configure TProgressbar -period 100 -maxphase 255
+	ttk::style configure TProgressbar -period 100 -maxphase 120
 
 	# For Aqua, labelframe labels should appear outside the border,
 	# with a 14 pixel inset and 4 pixels spacing between border and label
 	# (ref: Apple Human Interface Guidelines / Controls / Grouping Controls)
 	#
 	ttk::style configure TLabelframe \
-		-labeloutside true -labelmargins {14 0 14 4}
+	    -labeloutside true \
+	    -labelmargins {14 0 14 2}
+
+	ttk::style configure TLabelframe.Label \
+	    -font TkSmallCaptionFont
 
 	# TODO: panedwindow sashes should be 9 pixels (HIG:Controls:Split Views)
     }
 }

Index: library/ttk/button.tcl
==================================================================
--- library/ttk/button.tcl
+++ library/ttk/button.tcl
@@ -40,11 +40,11 @@
 # ...plus a few more:
 
 bind TRadiobutton <Up>  		{ ttk::button::RadioTraverse %W -1 }
 bind TRadiobutton <Down> 		{ ttk::button::RadioTraverse %W +1 }
 
-# bind TCheckbutton <plus> { %W select }
+# bind TCheckbutton <+> { %W select }
 # bind TCheckbutton <minus> { %W deselect }
 
 # activate --
 #	Simulate a button press: temporarily set the state to 'pressed',
 #	then invoke the button.
@@ -64,20 +64,20 @@
 #	that works most of the time.
 #
 proc ttk::button::RadioTraverse {w dir} {
     set group [list]
     foreach sibling [winfo children [winfo parent $w]] {
-    	if {   [winfo class $sibling] eq "TRadiobutton"
+	if {   [winfo class $sibling] eq "TRadiobutton"
 	    && [$sibling cget -variable] eq [$w cget -variable]
 	    && ![$sibling instate disabled]
 	} {
 	   lappend group $sibling
 	}
     }
 
     if {![llength $group]} {	 # Shouldn't happen, but can.
-    	return
+	return
     }
 
     set pos [expr {([lsearch -exact $group $w] + $dir) % [llength $group]}]
     tk::TabToWindow [lindex $group $pos]
 }

Index: library/ttk/clamTheme.tcl
==================================================================
--- library/ttk/clamTheme.tcl
+++ library/ttk/clamTheme.tcl
@@ -127,18 +127,21 @@
 	    ;
 
 	# Treeview:
 	ttk::style configure Heading \
 	    -font TkHeadingFont -relief raised -padding {3}
-	ttk::style configure Treeview -background $colors(-window)
+	ttk::style configure Treeview -background $colors(-window) \
+                -stripedbackground $colors(-lighter)
+	ttk::style configure Treeview.Separator \
+                -background $colors(-lighter)
 	ttk::style map Treeview \
 	    -background [list disabled $colors(-frame)\
 				selected $colors(-selectbg)] \
 	    -foreground [list disabled $colors(-disabledfg) \
 				selected $colors(-selectfg)]
 
-    	ttk::style configure TLabelframe \
+	ttk::style configure TLabelframe \
 	    -labeloutside true -labelmargins {0 0 0 4} \
 	    -borderwidth 2 -relief raised
 
 	ttk::style configure TProgressbar -background $colors(-frame)
 

Index: library/ttk/classicTheme.tcl
==================================================================
--- library/ttk/classicTheme.tcl
+++ library/ttk/classicTheme.tcl
@@ -7,10 +7,11 @@
 namespace eval ttk::theme::classic {
 
     variable colors; array set colors {
 	-frame		"#d9d9d9"
 	-window		"#ffffff"
+	-alternate	"#f0f0f0"
 	-activebg	"#ececec"
 	-troughbg	"#c3c3c3"
 	-selectbg	"#c3c3c3"
 	-selectfg	"#000000"
 	-disabledfg	"#a3a3a3"
@@ -94,11 +95,14 @@
 	    -background $colors(-troughbg)
 	ttk::style map TNotebook.Tab -background [list selected $colors(-frame)]
 
 	# Treeview:
 	ttk::style configure Heading -font TkHeadingFont -relief raised
-	ttk::style configure Treeview -background $colors(-window)
+	ttk::style configure Treeview -background $colors(-window) \
+                -stripedbackground $colors(-alternate)
+	ttk::style configure Treeview.Separator \
+                -background $colors(-alternate)
 	ttk::style map Treeview \
 	    -background [list disabled $colors(-frame)\
 				selected $colors(-selectbg)] \
 	    -foreground [list disabled $colors(-disabledfg) \
 				selected $colors(-selectfg)]

Index: library/ttk/combobox.tcl
==================================================================
--- library/ttk/combobox.tcl
+++ library/ttk/combobox.tcl
@@ -14,24 +14,21 @@
 #	On X11: WM_TRANSIENT_FOR on override-redirect windows
 #	may be used by compositing managers and by EWMH-aware
 #	window managers (even though the older ICCCM spec says
 #	it's meaningless).
 #
-#	On OSX: [wm transient] does utterly the wrong thing.
-#	Instead, we use [MacWindowStyle "help" "noActivates hideOnSuspend"].
-#	The "noActivates" attribute prevents the parent toplevel
-#	from deactivating when the popdown is posted, and is also
-#	necessary for "help" windows to receive mouse events.
-#	"hideOnSuspend" makes the popdown disappear (resp. reappear)
-#	when the parent toplevel is deactivated (resp. reactivated).
-#	(see [#1814778]).  Also set [wm resizable 0 0], to prevent
-#	TkAqua from shrinking the scrollbar to make room for a grow box
-#	that isn't there.
-#
-#	In order to work around other platform quirks in TkAqua,
-#	[grab] and [focus] are set in <Map> bindings instead of
-#	immediately after deiconifying the window.
+#       On OSX: The native combobox uses a popup menu to display the
+#       combobox choices.  So this implementation does that as well,
+#       rather than construc a Tk listbox.  Since the window manager
+#       takes care of scrolling and making sure that the menu can be
+#       displayed even when the button is close to the bottom of the
+#       screen, this actually simplifies the implementation.  The Post
+#       and PopupWindow procs have separate implementations for Aqua
+#       and other systems.  The configuration of the menu is handled
+#       by a different proc than the one which configures the listbox
+#       on other platforms -- ConfigureAquaMenu instead of
+#       ConfigureListbox.
 #
 
 namespace eval ttk::combobox {
     variable Values	;# Values($cb) is -listvariable of listbox widget
     variable State
@@ -74,10 +71,13 @@
     win32 {
 	# Dismiss listbox when user switches to a different application.
 	# NB: *only* do this on Windows (see #1814778)
 	bind ComboboxListbox <FocusOut>		{ ttk::combobox::LBCancel %W }
     }
+    aqua {
+	bind TCombobox <Destroy>		{ ttk::combobox::AquaCleanup %W }
+    }
 }
 
 ### Combobox popdown window bindings.
 #
 bind ComboboxPopdown	<Map>		{ ttk::combobox::MapPopdown %W }
@@ -96,13 +96,10 @@
 #
 switch -- [tk windowingsystem] {
     x11 {
 	option add *TCombobox*Listbox.background white widgetDefault
     }
-    aqua {
-	option add *TCombobox*Listbox.borderWidth 0 widgetDefault
-    }
 }
 
 ### Binding procedures.
 #
 
@@ -184,17 +181,20 @@
 #
 proc ttk::combobox::Scroll {cb dir {factor 1.0}} {
     $cb instate disabled { return }
     set max [llength [$cb cget -values]]
     set current [$cb current]
-    set d [expr {round($dir/factor)}]
-    if {$d == 0 && $dir != 0} {
-	if {$dir > 0} {set d 1} else {set d -1}
+    if {$current < 0} {
+	set index 0
+    } else {
+	set d [expr {$dir/$factor}]
+	set index [expr {$current + int($d > 0 ? ceil($d) : floor($d))}]
+	if {$index >= $max} {set index [expr {$max - 1}]}
+	if {$index < 0} {set index 0}
     }
-    incr current $d
-    if {$max != 0 && $current == $current % $max} {
-	SelectEntry $cb $current
+    if {$max != 0 && $index != $current} {
+	SelectEntry $cb $index
     }
 }
 
 ## LBSelected $lb -- Activation binding for listbox
 #	Set the combobox value to the currently-selected listbox value
@@ -259,38 +259,56 @@
 
 ## PopdownWindow --
 #	Returns the popdown widget associated with a combobox,
 #	creating it if necessary.
 #
-proc ttk::combobox::PopdownWindow {cb} {
-    if {![winfo exists $cb.popdown]} {
-	set poplevel [PopdownToplevel $cb.popdown]
-	set popdown [ttk::frame $poplevel.f -style ComboboxPopdownFrame]
-
-	ttk::scrollbar $popdown.sb \
-	    -orient vertical -command [list $popdown.l yview]
-	listbox $popdown.l \
-	    -listvariable ttk::combobox::Values($cb) \
-	    -yscrollcommand [list $popdown.sb set] \
-	    -exportselection false \
-	    -selectmode browse \
-	    -activestyle none \
-	    ;
-
-	bindtags $popdown.l \
-	    [list $popdown.l ComboboxListbox Listbox $popdown all]
-
-	grid $popdown.l -row 0 -column 0 -padx {1 0} -pady 1 -sticky nsew
-        grid $popdown.sb -row 0 -column 1 -padx {0 1} -pady 1 -sticky ns
-	grid columnconfigure $popdown 0 -weight 1
-	grid rowconfigure $popdown 0 -weight 1
-
-        grid $popdown -sticky news -padx 0 -pady 0
-        grid rowconfigure $poplevel 0 -weight 1
-        grid columnconfigure $poplevel 0 -weight 1
-    }
-    return $cb.popdown
+
+if {[tk windowingsystem] ne "aqua"} {
+    proc ttk::combobox::PopdownWindow {cb} {
+	if {![winfo exists $cb.popdown]} {
+	    set poplevel [PopdownToplevel $cb.popdown]
+	    set popdown [ttk::frame $poplevel.f -style ComboboxPopdownFrame]
+
+	    ttk::scrollbar $popdown.sb \
+		-orient vertical -command [list $popdown.l yview]
+	    listbox $popdown.l \
+		-listvariable ttk::combobox::Values($cb) \
+		-yscrollcommand [list $popdown.sb set] \
+		-exportselection false \
+		-selectmode browse \
+		-activestyle none \
+		;
+
+	    bindtags $popdown.l \
+		[list $popdown.l ComboboxListbox Listbox $popdown all]
+
+	    grid $popdown.l -row 0 -column 0 -padx {1 0} -pady 1 -sticky nsew
+	    grid $popdown.sb -row 0 -column 1 -padx {0 1} -pady 1 -sticky ns
+	    grid columnconfigure $popdown 0 -weight 1
+	    grid rowconfigure $popdown 0 -weight 1
+
+	    grid $popdown -sticky news -padx 0 -pady 0
+	    grid rowconfigure $poplevel 0 -weight 1
+	    grid columnconfigure $poplevel 0 -weight 1
+	}
+	return $cb.popdown
+    }
+} else {
+    proc ttk::combobox::PopdownWindow {cb} {
+	if {![winfo exists $cb.popdown]} {
+	    set poplevel [PopdownToplevel $cb.popdown]
+	    # The menu should be (at least) the same length as the button.
+	    # Since there is no direct way to control the width of a menu
+	    # in Tk, we fake it by using an invisible image in a disabled
+	    # menu item, adjusting the image size to make the menu be the
+	    # correct width.
+	    image create nsimage $cb.spacer -source NSStatusNone -as name \
+		-alpha 0
+	    set menu [menu $cb.popdown.menu -tearoff 0]
+	}
+	return $cb.popdown
+    }
 }
 
 ## PopdownToplevel -- Create toplevel window for the combobox popdown
 #
 #	See also <<NOTE-WM-TRANSIENT>>
@@ -309,14 +327,12 @@
 	    $w configure -relief flat -borderwidth 0
 	    wm overrideredirect $w true
 	    wm attributes $w -topmost 1
 	}
 	aqua {
-	    $w configure -relief solid -borderwidth 0
-	    tk::unsupported::MacWindowStyle style $w \
-	    	help {noActivates hideOnSuspend}
-	    wm resizable $w 0 0
+	    wm overrideredirect $w true
+	    wm attributes $w -alpha 0
 	}
     }
     return $w
 }
 
@@ -339,18 +355,51 @@
     $popdown.l activate $current
     $popdown.l see $current
     set height [llength $values]
     if {$height > [$cb cget -height]} {
 	set height [$cb cget -height]
-    	grid $popdown.sb
+	grid $popdown.sb
         grid configure $popdown.l -padx {1 0}
     } else {
 	grid remove $popdown.sb
         grid configure $popdown.l -padx 1
     }
     $popdown.l configure -height $height
 }
+
+proc ttk::combobox::ConfigureAquaMenu {cb width} {
+    set popdown [PopdownWindow $cb]
+    set values [$cb cget -values]
+    set current [$cb current]
+    if {$current < 0} {
+	set current 0 		;# no current entry, highlight first one
+    }
+    $cb.popdown.menu delete 0 end
+    $cb.spacer configure -width [expr {$width - 40}] -height 1
+    set i 0
+    foreach item $values {
+	if {$i == 0} {
+	    # Add spaces to the first item to make the menu as long as cb
+	    set menufont [$cb cget -font]
+	    set stretch $item
+	    while {[font measure $menufont $stretch] < [expr {$width - 32}]} {
+		set stretch "$stretch "
+	    }
+	    $cb.popdown.menu add command -label "$stretch" \
+		-command "ttk::combobox::SelectEntry $cb $i"
+	} else {
+	    $cb.popdown.menu add command -label "$item" \
+		-command "ttk::combobox::SelectEntry $cb $i"
+	}
+	incr i
+    }
+    if { $i == 0 } {
+	# There are no items.  To make an empty menu appear add a dummy item
+	# containing a transparent image of the right width.
+	$cb.popdown.menu add command -label {} -image $cb.spacer -state disabled
+    }
+}
 
 ## PlacePopdown --
 #	Set popdown window geometry.
 #
 # @@@TODO: factor with menubutton::PostPosition
@@ -364,11 +413,11 @@
     if { $style eq {} } {
       set style TCombobox
     }
     set postoffset [ttk::style lookup $style -postoffset {} {0 0 0 0}]
     foreach var {x y w h} delta $postoffset {
-    	incr $var $delta
+	incr $var $delta
     }
 
     set H [winfo reqheight $popdown]
     if {$y + $h + $H > [winfo screenheight $popdown]} {
 	set Y [expr {$y - $H}]
@@ -376,38 +425,79 @@
 	set Y [expr {$y + $h}]
     }
     wm geometry $popdown ${w}x${H}+${x}+${Y}
 }
 
-## Post $cb --
-#	Pop down the associated listbox.
-#
-proc ttk::combobox::Post {cb} {
-    # Don't do anything if disabled:
-    #
-    $cb instate disabled { return }
-
-    # ASSERT: ![$cb instate pressed]
-
-    # Run -postcommand callback:
-    #
-    uplevel #0 [$cb cget -postcommand]
-
-    set popdown [PopdownWindow $cb]
-    ConfigureListbox $cb
-    update idletasks	;# needed for geometry propagation.
-    PlacePopdown $cb $popdown
-    # See <<NOTE-WM-TRANSIENT>>
-    switch -- [tk windowingsystem] {
-	x11 - win32 { wm transient $popdown [winfo toplevel $cb] }
-    }
-
-    # Post the listbox:
-    #
-    wm attribute $popdown -topmost 1
-    wm deiconify $popdown
-    raise $popdown
+proc ttk::combobox::AquaPlacePopdown {cb popdown} {
+    set x [winfo rootx $cb]
+    set y [winfo rooty $cb]
+    set w [winfo width $cb]
+    set h [winfo height $cb]
+    set style [$cb cget -style]
+    set postoffset [ttk::style lookup $style -postoffset {} {0 0 0 0}]
+    foreach var {x y w h} delta $postoffset {
+    	incr $var $delta
+    }
+    wm geometry $popdown ${w}x${h}+${x}+${y}
+    return [list $x $y $w $h]
+}
+
+## Post $cb --
+#	Pop down the associated listbox or menu.
+#
+if {[tk windowingsystem] ne "aqua"} {
+    proc ttk::combobox::Post {cb} {
+	# Don't do anything if disabled:
+	#
+	$cb instate disabled { return }
+
+	# ASSERT: ![$cb instate pressed]
+
+	# Run -postcommand callback:
+	#
+	uplevel #0 [$cb cget -postcommand]
+
+	set popdown [PopdownWindow $cb]
+	ConfigureListbox $cb
+	update idletasks	;# needed for geometry propagation.
+	PlacePopdown $cb $popdown
+	# See <<NOTE-WM-TRANSIENT>>
+	switch -- [tk windowingsystem] {
+	    x11 - win32 { wm transient $popdown [winfo toplevel $cb] }
+	}
+
+	# Post the listbox:
+	#
+	wm attribute $popdown -topmost 1
+	wm deiconify $popdown
+	raise $popdown
+    }
+} else {
+    proc ttk::combobox::Post {cb} {
+	# Don't do anything if disabled:
+	#
+	$cb instate disabled { return }
+
+	# ASSERT: ![$cb instate pressed]
+
+	# Run -postcommand callback:
+	#
+	uplevel #0 [$cb cget -postcommand]
+
+	set popdown [PopdownWindow $cb]
+
+	# Configure the menu
+
+	foreach {x y width height} [AquaPlacePopdown $cb $popdown] { break }
+	ConfigureAquaMenu $cb [winfo width $cb]
+
+	# Post the menu.  It will have a disclosure indicator if it is too
+	# close to the bottom of the screen, and it may be posted above the
+	# button if necessary to be visible.
+
+	$popdown.menu post [expr {$x + 2}] [expr {$y + $height + 2}]
+    }
 }
 
 ## Unpost $cb --
 #	Unpost the listbox.
 #
@@ -446,7 +536,11 @@
 #
 proc ttk::combobox::LBCleanup {lb} {
     variable Values
     unset Values([LBMain $lb])
 }
+
+proc ttk::combobox::AquaCleanup {cb} {
+    catch {image delete $cb.spacer}
+}
 
 #*EOF*

Index: library/ttk/defaults.tcl
==================================================================
--- library/ttk/defaults.tcl
+++ library/ttk/defaults.tcl
@@ -6,10 +6,11 @@
     variable colors
     array set colors {
 	-frame			"#d9d9d9"
 	-foreground		"#000000"
 	-window			"#ffffff"
+	-alternate		"#e8e8e8"
 	-text   		"#000000"
 	-activebg		"#ececec"
 	-selectbg		"#4a6984"
 	-selectfg		"#ffffff"
 	-darker 		"#c3c3c3"
@@ -105,15 +106,18 @@
 
 	# Treeview.
 	#
 	ttk::style configure Heading -font TkHeadingFont -relief raised
 	ttk::style configure Treeview \
-	    -background $colors(-window) \
+            -background $colors(-window) \
+            -stripedbackground $colors(-alternate) \
 	    -foreground $colors(-text) ;
+	ttk::style configure Treeview.Separator \
+                -background $colors(-alternate)
 	ttk::style map Treeview \
 	    -background [list disabled $colors(-frame)\
-				selected $colors(-selectbg)] \
+                                selected $colors(-selectbg)] \
 	    -foreground [list disabled $colors(-disabledfg) \
 				selected $colors(-selectfg)]
 
 	# Combobox popdown frame
 	ttk::style layout ComboboxPopdownFrame {

Index: library/ttk/entry.tcl
==================================================================
--- library/ttk/entry.tcl
+++ library/ttk/entry.tcl
@@ -117,11 +117,11 @@
 #
 bind TEntry <Key> 			{ ttk::entry::Insert %W %A }
 bind TEntry <Delete>			{ ttk::entry::Delete %W }
 bind TEntry <BackSpace> 		{ ttk::entry::Backspace %W }
 
-# Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
+# Ignore all Alt, Meta, Control, Command, and Fn keypresses unless explicitly bound.
 # Otherwise, the <Key> class binding will fire and insert the character.
 # Ditto for Escape, Return, and Tab.
 #
 bind TEntry <Alt-Key>			{# nothing}
 bind TEntry <Meta-Key>			{# nothing}
@@ -128,16 +128,13 @@
 bind TEntry <Control-Key> 		{# nothing}
 bind TEntry <Escape> 			{# nothing}
 bind TEntry <Return> 			{# nothing}
 bind TEntry <KP_Enter> 			{# nothing}
 bind TEntry <Tab> 			{# nothing}
+bind TEntry <Command-Key>		{# nothing}
+bind TEntry <Fn-Key>			{# nothing}
 
-# Argh.  Apparently on Windows, the NumLock modifier is interpreted
-# as a Command modifier.
-if {[tk windowingsystem] eq "aqua"} {
-    bind TEntry <Command-Key>		{# nothing}
-}
 # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663]
 bind TEntry <<PrevLine>>		{# nothing}
 bind TEntry <<NextLine>>		{# nothing}
 
 ## Additional emacs-like bindings:
@@ -162,10 +159,23 @@
     %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert]
 }
 bind TEntry <<TkAccentBackspace>> {
     ttk::entry::Backspace %W
 }
+
+## EndIMEMarkedText -- Handle the end of input method selection.
+#
+proc ::ttk::entry::EndIMEMarkedText {w} {
+    variable ::tk::Priv
+    if {[catch {
+	set mark [dict get $Priv(IMETextMark) $w]
+    }]} {
+	bell
+	return
+    }
+    $w selection range $mark insert
+}
 
 ### Clipboard procedures.
 #
 
 ## EntrySelection -- Return the selected text of the entry.
@@ -246,13 +256,13 @@
 set ::ttk::entry::State(startNext) \
 	[string equal [tk windowingsystem] "win32"]
 
 proc ttk::entry::NextWord {w start} {
     variable State
-    set pos [tcl_endOfWord [$w get] [$w index $start]]
+    set pos [tk::endOfWord [$w get] [$w index $start]]
     if {$pos >= 0 && $State(startNext)} {
-	set pos [tcl_startOfNextWord [$w get] $pos]
+	set pos [tk::startOfNextWord [$w get] $pos]
     }
     if {$pos < 0} {
 	return end
     }
     return $pos
@@ -259,11 +269,32 @@
 }
 
 ## PrevWord -- Find the previous word position.
 #
 proc ttk::entry::PrevWord {w start} {
-    set pos [tcl_startOfPreviousWord [$w get] [$w index $start]]
+    set pos [tk::startOfPreviousWord [$w get] [$w index $start]]
+    if {$pos < 0} {
+	return 0
+    }
+    return $pos
+}
+
+## NextChar -- Find the next char position.
+#
+proc ttk::entry::NextChar {w start} {
+    variable State
+    set pos [tk::endOfCluster [$w get] [$w index $start]]
+    if {$pos < 0} {
+	return end
+    }
+    return $pos
+}
+
+## PrevChar -- Find the previous char position.
+#
+proc ttk::entry::PrevChar {w start} {
+    set pos [tk::startOfCluster [$w get] [expr {[$w index $start]-1}]]
     if {$pos < 0} {
 	return 0
     }
     return $pos
 }
@@ -270,12 +301,12 @@
 
 ## RelIndex -- Compute character/word/line-relative index.
 #
 proc ttk::entry::RelIndex {w where {index insert}} {
     switch -- $where {
-	prevchar	{ expr {[$w index $index] - 1} }
-    	nextchar	{ expr {[$w index $index] + 1} }
+	prevchar	{ PrevChar $w $index }
+    	nextchar	{ NextChar $w $index }
 	prevword	{ PrevWord $w $index }
 	nextword	{ NextWord $w $index }
 	home		{ return 0 }
 	end		{ $w index end }
 	default		{ error "Bad relative index $index" }
@@ -312,13 +343,13 @@
     set index [$w index $index]
     set insert [$w index insert]
 
     # Figure out selection anchor:
     if {![$w selection present]} {
-    	set anchor $insert
+	set anchor $insert
     } else {
-    	set selfirst [$w index sel.first]
+	set selfirst [$w index sel.first]
 	set sellast  [$w index sel.last]
 
 	if {   ($index < $selfirst)
 	    || ($insert == $selfirst && $index <= $sellast)
 	} {
@@ -330,11 +361,11 @@
 
     # Extend selection:
     if {$anchor < $index} {
 	$w selection range $anchor $index
     } else {
-    	$w selection range $index $anchor
+	$w selection range $index $anchor
     }
 
     $w icursor $index
     return $anchor
 }
@@ -390,12 +421,12 @@
 proc ttk::entry::Select {w x mode} {
     variable State
     set cur [ClosestGap $w $x]
 
     switch -- $mode {
-    	word	{ WordSelect $w $cur $cur }
-    	line	{ LineSelect $w $cur $cur }
+	word	{ WordSelect $w $cur $cur }
+	line	{ LineSelect $w $cur $cur }
 	char	{ # no-op }
     }
 
     set State(anchor) $cur
     set State(selectMode) $mode
@@ -497,15 +528,15 @@
 }
 
 ## WordBack, WordForward -- helper routines for WordSelect.
 #
 proc ttk::entry::WordBack {text index} {
-    if {[set pos [tcl_wordBreakBefore $text $index]] < 0} { return 0 }
+    if {[set pos [tk::wordBreakBefore $text $index]] < 0} { return 0 }
     return $pos
 }
 proc ttk::entry::WordForward {text index} {
-    if {[set pos [tcl_wordBreakAfter $text $index]] < 0} { return end }
+    if {[set pos [tk::wordBreakAfter $text $index]] < 0} { return end }
     return $pos
 }
 
 ## LineSelect -- Select the entire line.
 #
@@ -539,11 +570,11 @@
     }
     set left [expr {$State(scanIndex) + ($dx*$State(scanNum))/$State(scanDen)}]
     $w xview $left
 
     if {$left != [set newLeft [$w index @0]]} {
-    	# We've scanned past one end of the entry;
+	# We've scanned past one end of the entry;
 	# reset the mark so that the text will start dragging again
 	# as soon as the mouse reverses direction.
 	#
 	set State(scanX) $x
 	set State(scanIndex) $newLeft
@@ -596,17 +627,17 @@
 #	If the new insert position is offscreen to the left,
 #	scroll to place the cursor at about the middle of the window.
 #
 proc ttk::entry::Backspace {w} {
     if {[PendingDelete $w]} {
-    	See $w
+	See $w
 	return
     }
     set x [expr {[$w index insert] - 1}]
     if {$x < 0} { return }
 
-    $w delete $x
+    $w delete [tk::startOfCluster [$w get] $x] [tk::endOfCluster [$w get] $x]
 
     if {[$w index @0] >= [$w index insert]} {
 	set range [$w xview]
 	set left [lindex $range 0]
 	set right [lindex $range 1]
@@ -617,10 +648,11 @@
 ## Delete -- Delete the character after the insert cursor.
 #	If there is a selection, delete that instead.
 #
 proc ttk::entry::Delete {w} {
     if {![PendingDelete $w]} {
-	$w delete insert
+	$w delete [tk::startOfCluster [$w get] [$w index insert]] \
+		[tk::endOfCluster [$w get] [$w index insert]]
     }
 }
 
 #*EOF*

Index: library/ttk/fonts.tcl
==================================================================
--- library/ttk/fonts.tcl
+++ library/ttk/fonts.tcl
@@ -64,90 +64,85 @@
 catch {font create TkFixedFont}
 catch {font create TkIconFont}
 catch {font create TkMenuFont}
 catch {font create TkSmallCaptionFont}
 
-if {!$tip145} {
-variable F	;# miscellaneous platform-specific font parameters
+if {!$tip145} {apply {{} {
+global tcl_platform
 switch -- [tk windowingsystem] {
     win32 {
         # In safe interps there is no osVersion element.
 	if {[info exists tcl_platform(osVersion)]} {
             if {$tcl_platform(osVersion) >= 5.0} {
-                set F(family) "Tahoma"
+                set family "Tahoma"
             } else {
-                set F(family) "MS Sans Serif"
+                set family "MS Sans Serif"
             }
         } else {
             if {[lsearch -exact [font families] Tahoma] >= 0} {
-                set F(family) "Tahoma"
-            } else {
-                set F(family) "MS Sans Serif"
-            }
-        }
-	set F(size) 8
-
-	font configure TkDefaultFont -family $F(family) -size $F(size)
-	font configure TkTextFont    -family $F(family) -size $F(size)
-	font configure TkHeadingFont -family $F(family) -size $F(size)
-	font configure TkCaptionFont -family $F(family) -size $F(size) \
-	    -weight bold
-	font configure TkTooltipFont -family $F(family) -size $F(size)
-	font configure TkFixedFont   -family Courier -size 10
-	font configure TkIconFont    -family $F(family) -size $F(size)
-	font configure TkMenuFont    -family $F(family) -size $F(size)
-	font configure TkSmallCaptionFont -family $F(family) -size $F(size)
+                set family "Tahoma"
+            } else {
+                set family "MS Sans Serif"
+            }
+        }
+	set size 8
+
+	font configure TkDefaultFont -family $family -size $size
+	font configure TkTextFont    -family $family -size $size
+	font configure TkHeadingFont -family $family -size $size
+	font configure TkCaptionFont -family $family -size $size -weight bold
+	font configure TkTooltipFont -family $family -size $size
+	font configure TkFixedFont   -family Courier -size 10
+	font configure TkIconFont    -family $family -size $size
+	font configure TkMenuFont    -family $family -size $size
+	font configure TkSmallCaptionFont -family $family -size $size
     }
     aqua {
-	set F(family) "Lucida Grande"
-	set F(fixed) "Monaco"
-	set F(menusize) 14
-	set F(size) 13
-	set F(viewsize) 12
-	set F(smallsize) 11
-	set F(labelsize) 10
-	set F(fixedsize) 11
-
-	font configure TkDefaultFont -family $F(family) -size $F(size)
-	font configure TkTextFont    -family $F(family) -size $F(size)
-	font configure TkHeadingFont -family $F(family) -size $F(smallsize)
-	font configure TkCaptionFont -family $F(family) -size $F(size) \
-					-weight bold
-	font configure TkTooltipFont -family $F(family) -size $F(smallsize)
-	font configure TkFixedFont   -family $F(fixed)  -size $F(fixedsize)
-	font configure TkIconFont    -family $F(family) -size $F(size)
-	font configure TkMenuFont    -family $F(family) -size $F(menusize)
-	font configure TkSmallCaptionFont -family $F(family) -size $F(labelsize)
+	set family "Lucida Grande"
+	set fixed "Monaco"
+	set menusize 14
+	set size 13
+	set viewsize 12
+	set smallsize 11
+	set labelsize 10
+	set fixedsize 11
+
+	font configure TkDefaultFont -family $family -size $size
+	font configure TkTextFont    -family $family -size $size
+	font configure TkHeadingFont -family $family -size $smallsize
+	font configure TkCaptionFont -family $family -size $size -weight bold
+	font configure TkTooltipFont -family $family -size $smallsize
+	font configure TkFixedFont   -family $fixed  -size $fixedsize
+	font configure TkIconFont    -family $family -size $size
+	font configure TkMenuFont    -family $family -size $menusize
+	font configure TkSmallCaptionFont -family $family -size $labelsize
     }
     default -
     x11 {
-	if {![catch {tk::pkgconfig get fontsystem} F(fs)] && $F(fs) eq "xft"} {
-	    set F(family) "sans-serif"
-	    set F(fixed)  "monospace"
-	} else {
-	    set F(family) "Helvetica"
-	    set F(fixed)  "courier"
-	}
-	set F(size) 10
-	set F(ttsize) 9
-	set F(capsize) 12
-	set F(fixedsize) 10
-
-	font configure TkDefaultFont -family $F(family) -size $F(size)
-	font configure TkTextFont    -family $F(family) -size $F(size)
-	font configure TkHeadingFont -family $F(family) -size $F(size) \
-			-weight bold
-	font configure TkCaptionFont -family $F(family) -size $F(capsize) \
-			-weight bold
-	font configure TkTooltipFont -family $F(family) -size $F(ttsize)
-	font configure TkFixedFont   -family $F(fixed)  -size $F(fixedsize)
-	font configure TkIconFont    -family $F(family) -size $F(size)
-	font configure TkMenuFont    -family $F(family) -size $F(size)
-	font configure TkSmallCaptionFont -family $F(family) -size $F(ttsize)
-    }
-}
-unset -nocomplain F
-}
+	if {![catch {tk::pkgconfig get fontsystem} fs] && $fs eq "xft"} {
+	    set family "sans-serif"
+	    set fixed  "monospace"
+	} else {
+	    set family "Helvetica"
+	    set fixed  "courier"
+	}
+	set size 10
+	set ttsize 9
+	set capsize 12
+	set fixedsize 10
+
+	font configure TkDefaultFont -family $family -size $size
+	font configure TkTextFont    -family $family -size $size
+	font configure TkHeadingFont -family $family -size $size    -weight bold
+	font configure TkCaptionFont -family $family -size $capsize -weight bold
+	font configure TkTooltipFont -family $family -size $ttsize
+	font configure TkFixedFont   -family $fixed  -size $fixedsize
+	font configure TkIconFont    -family $family -size $size
+	font configure TkMenuFont    -family $family -size $size
+	font configure TkSmallCaptionFont -family $family -size $ttsize
+    }
+}
+} ::ttk}}
 
 }
 
 #*EOF*

Index: library/ttk/menubutton.tcl
==================================================================
--- library/ttk/menubutton.tcl
+++ library/ttk/menubutton.tcl
@@ -55,11 +55,11 @@
     bind TMenubutton <B1-Leave> 	{ ttk::menubutton::TransferGrab %W }
 } else {
     bind TMenubutton <Button-1>  \
 	{ %W state pressed ; ttk::menubutton::Popdown %W }
     bind TMenubutton <ButtonRelease-1>  \
-	{ if {[winfo exists %W]} { %W state !pressed } }
+	{ if {[winfo exists %W]} { %W state {!pressed}} }
 }
 
 # PostPosition --
 #	Returns x and y coordinates and a menu item index.
 #       If the index is not an empty string the menu should
@@ -75,19 +75,18 @@
 if {[tk windowingsystem] eq "aqua"} {
     proc ::ttk::menubutton::PostPosition {mb menu} {
 	set menuPad 5
 	set buttonPad 1
 	set bevelPad 4
+	set flushPad 4
 	set mh [winfo reqheight $menu]
 	set bh [expr {[winfo height $mb]} + $buttonPad]
 	set bbh [expr {[winfo height $mb]} + $bevelPad]
 	set mw [winfo reqwidth $menu]
 	set bw [winfo width $mb]
-	set dF [expr {[winfo width $mb] - [winfo reqwidth $menu] - $menuPad}]
-	set entry ""
 	set entry [::tk::MenuFindName $menu [$mb cget -text]]
-	if {$entry eq ""} {
+	if {$entry < 0} {
 	    set entry 0
 	}
 	set x [winfo rootx $mb]
 	set y [winfo rooty $mb]
 	switch [$mb cget -direction] {
@@ -105,12 +104,15 @@
 	    }
 	    right {
 		incr y $menuPad
 		incr x $bw
 	    }
+	    flush {
+		incr y $flushPad
+		incr x -$flushPad
+	    }
 	    default {
-		incr y $bbh
 	    }
 	}
 	return [list $x $y $entry]
     }
 } else {
@@ -117,34 +119,32 @@
     proc ::ttk::menubutton::PostPosition {mb menu} {
 	set mh [expr {[winfo reqheight $menu]}]
 	set bh [expr {[winfo height $mb]}]
 	set mw [expr {[winfo reqwidth $menu]}]
 	set bw [expr {[winfo width $mb]}]
-	set dF [expr {[winfo width $mb] - [winfo reqwidth $menu]}]
 	if {[tk windowingsystem] eq "win32"} {
 	    incr mh 6
 	    incr mw 16
 	}
-	set entry {}
 	set entry [::tk::MenuFindName $menu [$mb cget -text]]
-	if {$entry eq {}} {
+	if {$entry < 0} {
 	    set entry 0
 	}
 	set x [winfo rootx $mb]
 	set y [winfo rooty $mb]
 	switch [$mb cget -direction] {
 	    above {
-		set entry {}
+		set entry ""
 		incr y -$mh
 		# if we go offscreen to the top, show as 'below'
 		if {$y < [winfo vrooty $mb]} {
 		    set y [expr {[winfo vrooty $mb] + [winfo rooty $mb]\
                            + [winfo reqheight $mb]}]
 		}
 	    }
 	    below {
-		set entry {}
+		set entry ""
 		incr y $bh
 		# if we go offscreen to the bottom, show as 'above'
 		if {($y + $mh) > ([winfo vrooty $mb] + [winfo vrootheight $mb])} {
 		    set y [expr {[winfo vrooty $mb] + [winfo vrootheight $mb] \
 			   + [winfo rooty $mb] - $mh}]
@@ -154,17 +154,12 @@
 		incr x -$mw
 	    }
 	    right {
 		incr x $bw
 	    }
-	    default {
-		if {[$mb cget -style] eq ""} {
-		    incr x [expr {([winfo width $mb] - \
-				   [winfo reqwidth $menu])/ 2}]
-		} else {
-		    incr y $bh
-		}
+	    default {  # flush
+		incr x [expr {([winfo width $mb] - [winfo reqwidth $menu])/ 2}]
 	    }
 	}
 	return [list $x $y $entry]
     }
 }
@@ -194,11 +189,11 @@
     set State(oldcursor) [$mb cget -cursor]
 
     $mb state pressed
     $mb configure -cursor [$menu cget -cursor]
     foreach {x y entry} [PostPosition $mb $menu] { break }
-    if {$entry ne {}} {
+    if {$entry >= 0} {
 	$menu post $x $y $entry
     } else {
 	$menu post $x $y
     }
     tk_menuSetFocus $menu
@@ -215,11 +210,11 @@
 	$mb state {!pressed !active}
 	set State(pulldown) 0
 
 	set menu [$mb cget -menu]
 	foreach {x y entry} [PostPosition $mb $menu] { break }
-    	tk_popup $menu [winfo rootx $menu] [winfo rooty $menu]
+	tk_popup $menu [winfo rootx $menu] [winfo rooty $menu]
     }
 }
 
 # FindMenuEntry --
 #	Hack to support tk_optionMenus.
@@ -226,11 +221,11 @@
 #	Returns the index of the menu entry with a matching -label,
 #	"" if not found.
 #
 proc ttk::menubutton::FindMenuEntry {menu s} {
     set last [$menu index last]
-    if {$last eq "none" || $last eq ""} {
+    if {$last < 0} {
 	return ""
     }
     for {set i 0} {$i <= $last} {incr i} {
 	if {![catch {$menu entrycget $i -label} label]
 	    && ($label eq $s)} {

Index: library/ttk/notebook.tcl
==================================================================
--- library/ttk/notebook.tcl
+++ library/ttk/notebook.tcl
@@ -14,10 +14,12 @@
 catch {
 bind TNotebook <Control-ISO_Left_Tab>	{ ttk::notebook::CycleTab %W -1; break }
 }
 bind TNotebook <Destroy>		{ ttk::notebook::Cleanup %W }
 
+ttk::bindMouseWheel TNotebook		[list ttk::notebook::CycleTab %W]
+
 # ActivateTab $nb $tab --
 #	Select the specified tab and set focus.
 #
 #  Desired behavior:
 #	+ take focus when reselecting the currently-selected tab;
@@ -54,16 +56,20 @@
 }
 
 # CycleTab --
 #	Select the next/previous tab in the list.
 #
-proc ttk::notebook::CycleTab {w dir} {
-    if {[$w index end] != 0} {
-	set current [$w index current]
-	set select [expr {($current + $dir) % [$w index end]}]
-	while {[$w tab $select -state] != "normal" && ($select != $current)} {
-	    set select [expr {($select + $dir) % [$w index end]}]
+proc ttk::notebook::CycleTab {w dir {factor 1.0}} {
+    set current [$w index current]
+    if {$current >= 0} {
+	set tabCount [$w index end]
+	set d [expr {$dir/$factor}]
+	set d [expr {int($d > 0 ? ceil($d) : floor($d))}]
+	set select [expr {($current + $d) % $tabCount}]
+	set step [expr {$d > 0 ? 1 : -1}]
+	while {[$w tab $select -state] ne "normal" && ($select != $current)} {
+	    set select [expr {($select + $step) % $tabCount}]
 	}
 	if {$select != $current} {
 	    ActivateTab $w $select
 	}
     }
@@ -110,17 +116,12 @@
 	bind $top <Control-Tab> 	     {+ttk::notebook::TLCycleTab %W  1}
 	bind $top <Control-Shift-Tab>        {+ttk::notebook::TLCycleTab %W -1}
 	catch {
 	bind $top <Control-ISO_Left_Tab>     {+ttk::notebook::TLCycleTab %W -1}
 	}
-	if {[tk windowingsystem] eq "aqua"} {
-	    bind $top <Option-Key> \
-		+[list ttk::notebook::MnemonicActivation $top %K]
-	} else {
-	    bind $top <Alt-Key> \
-		+[list ttk::notebook::MnemonicActivation $top %K]
-	}
+	bind $top <Option-Key> \
+	    +[list ttk::notebook::MnemonicActivation $top %K]
 	bind $top <Destroy> {+ttk::notebook::TLCleanup %W}
     }
 
     lappend TLNotebooks($top) $nb
 }

Index: library/ttk/panedwindow.tcl
==================================================================
--- library/ttk/panedwindow.tcl
+++ library/ttk/panedwindow.tcl
@@ -4,11 +4,11 @@
 
 namespace eval ttk::panedwindow {
     variable State
     array set State {
 	pressed 0
-    	pressX	-
+	pressX	-
 	pressY	-
 	sash 	-
 	sashPos -
     }
 }
@@ -30,11 +30,11 @@
 proc ttk::panedwindow::Press {w x y} {
     variable State
 
     set sash [$w identify $x $y]
     if {$sash eq ""} {
-    	set State(pressed) 0
+	set State(pressed) 0
 	return
     }
     set State(pressed) 	1
     set State(pressX) 	$x
     set State(pressY) 	$y
@@ -44,12 +44,12 @@
 
 proc ttk::panedwindow::Drag {w x y} {
     variable State
     if {!$State(pressed)} { return }
     switch -- [$w cget -orient] {
-    	horizontal 	{ set delta [expr {$x - $State(pressX)}] }
-    	vertical 	{ set delta [expr {$y - $State(pressY)}] }
+	horizontal 	{ set delta [expr {$x - $State(pressX)}] }
+	vertical 	{ set delta [expr {$y - $State(pressY)}] }
     }
     $w sashpos $State(sash) [expr {$State(sashPos) + $delta}]
 }
 
 proc ttk::panedwindow::Release {w x y} {
@@ -77,15 +77,15 @@
     ttk::saveCursor $w State(userConfCursor) \
             [list [ttk::cursor hresize] [ttk::cursor vresize]]
 
     set cursor $State(userConfCursor)
     if {[llength [$w identify $x $y]]} {
-    	# Assume we're over a sash.
+	# Assume we're over a sash.
 	switch -- [$w cget -orient] {
 	    horizontal 	{ set cursor hresize }
 	    vertical 	{ set cursor vresize }
 	}
     }
     ttk::setCursor $w $cursor
 }
 
 #*EOF*

Index: library/ttk/progress.tcl
==================================================================
--- library/ttk/progress.tcl
+++ library/ttk/progress.tcl
@@ -11,17 +11,17 @@
 #
 proc ttk::progressbar::Autoincrement {pb steptime stepsize} {
     variable Timers
 
     if {![winfo exists $pb]} {
-    	# widget has been destroyed -- cancel timer
+	# widget has been destroyed -- cancel timer
 	unset -nocomplain Timers($pb)
 	return
     }
 
     set Timers($pb) [after $steptime \
-    	[list ttk::progressbar::Autoincrement $pb $steptime $stepsize] ]
+	[list ttk::progressbar::Autoincrement $pb $steptime $stepsize] ]
 
     $pb step $stepsize
 }
 
 # ttk::progressbar::start --
@@ -29,10 +29,13 @@
 #
 proc ttk::progressbar::start {pb {steptime 50} {stepsize 1}} {
     variable Timers
     if {![info exists Timers($pb)]} {
 	Autoincrement $pb $steptime $stepsize
+    }
+    if {[tk windowingsystem] eq "aqua"} {
+	$pb state selected
     }
 }
 
 # ttk::progressbar::stop --
 #	Cancel autoincrement mode. Invoked by [$pb stop] widget code.
@@ -42,8 +45,11 @@
     if {[info exists Timers($pb)]} {
 	after cancel $Timers($pb)
 	unset Timers($pb)
     }
     $pb configure -value 0
+    if {[tk windowingsystem] eq "aqua"} {
+	$pb state !selected
+    }
 }
 
 

Index: library/ttk/scale.tcl
==================================================================
--- library/ttk/scale.tcl
+++ library/ttk/scale.tcl
@@ -1,6 +1,6 @@
-# scale.tcl - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
+# scale.tcl - Copyright © 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
 #
 # Bindings for the TScale widget
 
 namespace eval ttk::scale {
     variable State

Index: library/ttk/scrollbar.tcl
==================================================================
--- library/ttk/scrollbar.tcl
+++ library/ttk/scrollbar.tcl
@@ -72,11 +72,11 @@
 }
 
 proc ttk::scrollbar::Drag {w x y} {
     variable State
     if {![info exists State(first)]} {
-    	# Initial buttonpress was not on the thumb,
+	# Initial buttonpress was not on the thumb,
 	# or something screwy has happened.  In either case, ignore:
 	return;
     }
     set xDelta [expr {$x - $State(xPress)}]
     set yDelta [expr {$y - $State(yPress)}]

Index: library/ttk/sizegrip.tcl
==================================================================
--- library/ttk/sizegrip.tcl
+++ library/ttk/sizegrip.tcl
@@ -10,11 +10,11 @@
     x11 -
     win32 {
 	option add *TSizegrip.cursor [ttk::cursor seresize] widgetDefault
     }
     aqua {
-    	# Aqua sizegrips use default Arrow cursor.
+	# Aqua sizegrips use default Arrow cursor.
     }
 }
 
 namespace eval ttk::sizegrip {
     variable State

Index: library/ttk/spinbox.tcl
==================================================================
--- library/ttk/spinbox.tcl
+++ library/ttk/spinbox.tcl
@@ -21,11 +21,11 @@
 bind TSpinbox <Down> 			{ event generate %W <<Decrement>> }
 
 bind TSpinbox <<Increment>>		{ ttk::spinbox::Spin %W +1 }
 bind TSpinbox <<Decrement>> 		{ ttk::spinbox::Spin %W -1 }
 
-ttk::bindMouseWheel TSpinbox 		[list ttk::spinbox::MouseWheel %W]
+ttk::bindMouseWheel TSpinbox 		[list ttk::spinbox::Spin %W]
 
 ## Motion --
 #	Sets cursor.
 #
 proc ttk::spinbox::Motion {w x y} {
@@ -78,17 +78,17 @@
     ttk::CancelRepeat
 }
 
 ## MouseWheel --
 #	Mousewheel callback.  Turn these into <<Increment>> (-1, up)
-# 	or <<Decrement> (+1, down) events.
+# 	or <<Decrement> (+1, down) events. Not used any more.
 #
-proc ttk::spinbox::MouseWheel {w dir {factor 1}} {
+proc ttk::spinbox::MouseWheel {w dir {factor 1.0}} {
     if {[$w instate disabled]} { return }
     if {($dir < 0) ^ ($factor < 0)} {
 	event generate $w <<Increment>>
-    } elseif {$dir > 0} {
+    } elseif {$dir != 0} {
 	event generate $w <<Decrement>>
     }
 }
 
 ## SelectAll --
@@ -132,11 +132,11 @@
 #	Handle <<Increment>> and <<Decrement>> events.
 #	If -values is specified, cycle through the list.
 #	Otherwise cycle through numeric range based on
 #	-from, -to, and -increment.
 #
-proc ttk::spinbox::Spin {w dir} {
+proc ttk::spinbox::Spin {w dir {factor -1.0}} {
     variable State
 
     if {[$w instate disabled]} { return }
 
     if {![info exists State($w,values.length)]} {
@@ -144,24 +144,26 @@
 	set State($w,values.last) {}
     }
     set State($w,values) [$w cget -values]
     set State($w,values.length) [llength $State($w,values)]
 
+    set d [expr {-($dir/$factor)}]
+    set d [expr {int($d > 0 ? ceil($d) : floor($d))}]
     if {$State($w,values.length) > 0} {
 	set value [$w get]
 	set current $State($w,values.index)
 	if {$value ne $State($w,values.last)} {
 	    set current [lsearch -exact $State($w,values) $value]
 	    if {$current < 0} {set current -1}
 	}
-	set State($w,values.index) [Adjust $w [expr {$current + $dir}] 0 \
+	set State($w,values.index) [Adjust $w [expr {$current + $d}] 0 \
 		[expr {$State($w,values.length) - 1}]]
 	set State($w,values.last) [lindex $State($w,values) $State($w,values.index)]
 	$w set $State($w,values.last)
     } else {
 	if {[catch {
-	    set v [expr {[scan [$w get] %f] + $dir * [$w cget -increment]}]
+	    set v [expr {[scan [$w get] %f] + $d * [$w cget -increment]}]
 	}]} {
 	    set v [$w cget -from]
 	}
 	$w set [FormatValue $w [Adjust $w $v [$w cget -from] [$w cget -to]]]
     }

Index: library/ttk/treeview.tcl
==================================================================
--- library/ttk/treeview.tcl
+++ library/ttk/treeview.tcl
@@ -18,10 +18,13 @@
     # For pressMode == "resize"
     set State(resizeColumn)	#0
 
     # For pressmode == "heading"
     set State(heading)  	{}
+
+    set State(cellAnchor)	{}
+    set State(cellAnchorOp)	"set"
 }
 
 ### Widget bindings.
 #
 
@@ -54,12 +57,23 @@
 ## Keynav -- Keyboard navigation
 #
 # @@@ TODO: verify/rewrite up and down code.
 #
 proc ttk::treeview::Keynav {w dir} {
+    variable State
     set focus [$w focus]
     if {$focus eq ""} { return }
+
+    set cells [expr {[$w cget -selecttype] eq "cell"}]
+
+    if {$cells} {
+        lassign $State(cellAnchor) _ colAnchor
+        # Just in case, give it a valid value
+        if {$colAnchor eq ""} {
+            set colAnchor "#1"
+        }
+    }
 
     switch -- $dir {
 	up {
 	    if {[set up [$w prev $focus]] eq ""} {
 	        set focus [$w parent $focus]
@@ -80,23 +94,50 @@
 		}
 		set focus $down
 	    }
 	}
 	left {
-	    if {[$w item $focus -open] && [llength [$w children $focus]]} {
-	    	CloseItem $w $focus
+            if {$cells} {
+                # This assumes that colAnchor is of the "#N" format.
+                set colNo [string range $colAnchor 1 end]
+                set firstCol [expr {"tree" ni [$w cget -show]}]
+                if {$colNo >  $firstCol} {
+                    incr colNo -1
+                    set colAnchor "#$colNo"
+                }
+            } elseif {[$w item $focus -open] && [llength [$w children $focus]]} {
+		CloseItem $w $focus
 	    } else {
-	    	set focus [$w parent $focus]
+		set focus [$w parent $focus]
 	    }
 	}
 	right {
-	    OpenItem $w $focus
+            if {$cells} {
+                set colNo [string range $colAnchor 1 end]
+                set dispCol [$w cget -displaycolumns]
+                if {$dispCol eq "#all"} {
+                    set lastCol [llength [$w cget -columns]]
+                } else {
+                    set lastCol [llength $dispCol]
+                }
+                if {$colNo < ($lastCol - 1)} {
+                    incr colNo
+                    set colAnchor "#$colNo"
+                }
+            } else {
+                OpenItem $w $focus
+            }
 	}
     }
 
     if {$focus != {}} {
-	SelectOp $w $focus choose
+        if {$cells} {
+            set cell [list $focus $colAnchor]
+            SelectOp $w $focus $cell choose
+        } else {
+            SelectOp $w $focus "" choose
+        }
     }
 }
 
 ## Motion -- pointer motion binding.
 #	Sets cursor, active element ...
@@ -142,18 +183,32 @@
 	}
 	set State(activeHeading) $heading
 	set State(activeWidget) $w
     }
 }
+
+## IndentifyCell -- Locate the cell at coordinate
+#	Only active when -selecttype is "cell", and leaves cell empty otherwise.
+#       Down the call chain it is enough to check cell to know the selecttype.
+proc ttk::treeview::IdentifyCell {w x y} {
+    set cell {}
+    if {[$w cget -selecttype] eq "cell"} {
+        # Later handling assumes that the column in the cell ID is of the
+        # format #N, which is always the case from "identify cell"
+        set cell [$w identify cell $x $y]
+    }
+    return $cell
+}
 
 ## Select $w $x $y $selectop
 #	Binding procedure for selection operations.
 #	See "Selection modes", below.
 #
 proc ttk::treeview::Select {w x y op} {
     if {[set item [$w identify row $x $y]] ne "" } {
-	SelectOp $w $item $op
+        set cell [IdentifyCell $w $x $y]
+	SelectOp $w $item $cell $op
     }
 }
 
 ## DoubleClick -- Double-Button-1 binding.
 #
@@ -174,11 +229,13 @@
 	heading { heading.press $w $x $y }
 	separator { resize.press $w $x $y }
 	tree -
 	cell {
 	    set item [$w identify item $x $y]
-	    SelectOp $w $item choose
+            set cell [IdentifyCell $w $x $y]
+
+	    SelectOp $w $item $cell choose
 	    switch -glob -- [$w identify element $x $y] {
 		*indicator -
 		*disclosure { Toggle $w $item }
 	    }
 	}
@@ -236,13 +293,13 @@
 proc ttk::treeview::heading.drag {w x y} {
     variable State
     if {   [$w identify region $x $y] eq "heading"
         && [$w identify column $x $y] eq $State(heading)
     } {
-    	$w heading $State(heading) state pressed
+	$w heading $State(heading) state pressed
     } else {
-    	$w heading $State(heading) state !pressed
+	$w heading $State(heading) state !pressed
     }
 }
 
 proc ttk::treeview::heading.release {w} {
     variable State
@@ -257,39 +314,55 @@
 
 ## SelectOp $w $item [ choose | extend | toggle ] --
 #	Dispatch to appropriate selection operation
 #	depending on current value of -selectmode.
 #
-proc ttk::treeview::SelectOp {w item op} {
-    select.$op.[$w cget -selectmode] $w $item
+proc ttk::treeview::SelectOp {w item cell op} {
+    select.$op.[$w cget -selectmode] $w $item $cell
 }
 
 ## -selectmode none:
 #
-proc ttk::treeview::select.choose.none {w item} { $w focus $item; $w see $item }
-proc ttk::treeview::select.toggle.none {w item} { $w focus $item; $w see $item }
-proc ttk::treeview::select.extend.none {w item} { $w focus $item; $w see $item }
+proc ttk::treeview::select.choose.none {w item cell} { $w focus $item; $w see $item }
+proc ttk::treeview::select.toggle.none {w item cell} { $w focus $item; $w see $item }
+proc ttk::treeview::select.extend.none {w item cell} { $w focus $item; $w see $item }
 
 ## -selectmode browse:
 #
-proc ttk::treeview::select.choose.browse {w item} { BrowseTo $w $item }
-proc ttk::treeview::select.toggle.browse {w item} { BrowseTo $w $item }
-proc ttk::treeview::select.extend.browse {w item} { BrowseTo $w $item }
+proc ttk::treeview::select.choose.browse {w item cell} { BrowseTo $w $item $cell }
+proc ttk::treeview::select.toggle.browse {w item cell} { BrowseTo $w $item $cell }
+proc ttk::treeview::select.extend.browse {w item cell} { BrowseTo $w $item $cell }
 
 ## -selectmode multiple:
 #
-proc ttk::treeview::select.choose.extended {w item} {
-    BrowseTo $w $item
-}
-proc ttk::treeview::select.toggle.extended {w item} {
-    $w selection toggle [list $item]
-}
-proc ttk::treeview::select.extend.extended {w item} {
-    if {[set anchor [$w focus]] ne ""} {
-	$w selection set [between $w $anchor $item]
+proc ttk::treeview::select.choose.extended {w item cell} {
+    BrowseTo $w $item $cell
+}
+proc ttk::treeview::select.toggle.extended {w item cell} {
+    variable State
+    if {$cell ne ""} {
+        $w cellselection toggle [list $cell]
+        set State(cellAnchor) $cell
+        set State(cellAnchorOp) add
+    } else {
+        $w selection toggle [list $item]
+    }
+}
+proc ttk::treeview::select.extend.extended {w item cell} {
+    variable State
+    if {$cell ne ""} {
+        if {$State(cellAnchor) ne ""} {
+            $w cellselection $State(cellAnchorOp) $State(cellAnchor) $cell
+        } else {
+            BrowseTo $w $item $cell
+        }
     } else {
-    	BrowseTo $w $item
+        if {[set anchor [$w focus]] ne ""} {
+            $w selection set [between $w $anchor $item]
+        } else {
+            BrowseTo $w $item $cell
+        }
     }
 }
 
 ### Tree structure utilities.
 #
@@ -317,14 +390,14 @@
 proc ttk::treeview::ScanBetween {tv item1 item2 item} {
     variable between
     variable selectingBetween
 
     if {$item eq $item1 || $item eq $item2} {
-    	lappend between $item
+	lappend between $item
 	set selectingBetween [expr {!$selectingBetween}]
     } elseif {$selectingBetween} {
-    	lappend between $item
+	lappend between $item
     }
     foreach child [$tv children $item] {
 	ScanBetween $tv $item1 $item2 $child
     }
 }
@@ -366,18 +439,26 @@
 ## ToggleFocus -- toggle opened/closed state of focus item
 #
 proc ttk::treeview::ToggleFocus {w} {
     set item [$w focus]
     if {$item ne ""} {
-    	Toggle $w $item
+	Toggle $w $item
     }
 }
 
 ## BrowseTo -- navigate to specified item; set focus and selection
 #
-proc ttk::treeview::BrowseTo {w item} {
+proc ttk::treeview::BrowseTo {w item cell} {
+    variable State
+
     $w see $item
     $w focus $item
-    $w selection set [list $item]
+    set State(cellAnchor) $cell
+    set State(cellAnchorOp) set
+    if {$cell ne ""} {
+        $w cellselection set [list $cell]
+    } else {
+        $w selection set [list $item]
+    }
 }
 
 #*EOF*

Index: library/ttk/utils.tcl
==================================================================
--- library/ttk/utils.tcl
+++ library/ttk/utils.tcl
@@ -71,11 +71,11 @@
 #	See the description of the -takefocus option in options(n)
 #	for details.
 #
 proc ttk::takesFocus {w} {
     if {![winfo viewable $w]} {
-    	return 0
+	return 0
     } elseif {[catch {$w cget -takefocus} takefocus]} {
 	return [GuessTakeFocus $w]
     } else {
 	switch -- $takefocus {
 	    "" { return [GuessTakeFocus $w] }
@@ -142,20 +142,20 @@
 
     set restoreGrab [set restoreFocus ""]
 
     set grabbed [grab current $w]
     if {[winfo exists $grabbed]} {
-    	switch [grab status $grabbed] {
+	switch [grab status $grabbed] {
 	    global { set restoreGrab [list grab -global $grabbed] }
 	    local  { set restoreGrab [list grab $grabbed] }
 	    none   { ;# grab window is really in a different interp }
 	}
     }
 
     set focus [focus]
     if {$focus ne ""} {
-    	set restoreFocus [list focus -force $focus]
+	set restoreFocus [list focus -force $focus]
     }
 
     set Grab($w) [list $restoreGrab $restoreFocus]
 }
 
@@ -234,21 +234,21 @@
 proc ttk::Repeatedly {args} {
     variable Repeat
     after cancel $Repeat(timer)
     set script [uplevel 1 [list namespace code $args]]
     set Repeat(script) $script
-    uplevel #0 $script
     set Repeat(timer) [after $Repeat(delay) ttk::Repeat]
+    uplevel #0 $script
 }
 
 ## Repeat --
 #	Continue auto-repeat
 #
 proc ttk::Repeat {} {
     variable Repeat
-    uplevel #0 $Repeat(script)
     set Repeat(timer) [after $Repeat(interval) ttk::Repeat]
+    uplevel #0 $Repeat(script)
 }
 
 ## ttk::CancelRepeat --
 #	Halt auto-repeat.
 #
@@ -278,32 +278,27 @@
 # Gtk+ and Qt do not appear to use as large a factor).
 #
 
 ## ttk::bindMouseWheel $bindtag $command...
 #	Adds basic mousewheel support to $bindtag.
-#	$command will be passed one additional argument
-#	specifying the mousewheel direction (-1: up, +1: down).
+#	$command will be passed two additional arguments
+#	specifying the mousewheel change and a factor.
 #
 
 proc ttk::bindMouseWheel {bindtag callback} {
-    bind $bindtag <MouseWheel> [append callback { %D -120.0}]
-    bind $bindtag <Option-MouseWheel> [append callback { %D -12.0}]
+    bind $bindtag <MouseWheel> "$callback %D -120.0"
+    bind $bindtag <Option-MouseWheel> "$callback %D -12.0"
 }
 
 ## Mousewheel bindings for standard scrollable widgets.
 #
-# Usage: [ttk::copyBindings TtkScrollable $bindtag]
-#
-# $bindtag should be for a widget that supports the
-# standard scrollbar protocol.
-#
 
 bind TtkScrollable <MouseWheel> \
-	{ tk::MouseWheel %W y %D }
+	{ tk::MouseWheel %W y %D -40.0 }
 bind TtkScrollable <Option-MouseWheel> \
 	{ tk::MouseWheel %W y %D -12.0 }
 bind TtkScrollable <Shift-MouseWheel> \
-	{ tk::MouseWheel %W x %D }
+	{ tk::MouseWheel %W x %D -40.0 }
 bind TtkScrollable <Shift-Option-MouseWheel> \
 	{ tk::MouseWheel %W x %D -12.0 }
 
 #*EOF*

Index: library/ttk/vistaTheme.tcl
==================================================================
--- library/ttk/vistaTheme.tcl
+++ library/ttk/vistaTheme.tcl
@@ -43,14 +43,17 @@
 	ttk::style map TNotebook.Tab \
 	    -expand [list selected {2 2 2 2}]
 
 	# Treeview:
 	ttk::style configure Heading -font TkHeadingFont
-	ttk::style configure Treeview -background SystemWindow
+	ttk::style configure Treeview -background SystemWindow \
+                -stripedbackground System3dLight
+	ttk::style configure Treeview.Separator \
+                -background System3dLight
 	ttk::style map Treeview \
 	    -background [list   disabled SystemButtonFace \
-				selected SystemHighlight] \
+                                selected SystemHighlight] \
 	    -foreground [list   disabled SystemGrayText \
 				selected SystemHighlightText]
 
         # Label and Toolbutton
 	ttk::style configure TLabelframe.Label -foreground SystemButtonText
@@ -89,11 +92,11 @@
 	ttk::style map TCombobox \
 	    -selectbackground [list !focus SystemWindow] \
 	    -selectforeground [list !focus SystemWindowText] \
 	    -foreground	[list \
 		disabled		SystemGrayText \
-	    	{readonly focus}	SystemHighlightText \
+		{readonly focus}	SystemHighlightText \
 	    ] \
 	    -focusfill	[list {readonly focus} SystemHighlight] \
 	    ;
 
         # Entry

Index: library/ttk/winTheme.tcl
==================================================================
--- library/ttk/winTheme.tcl
+++ library/ttk/winTheme.tcl
@@ -30,25 +30,25 @@
 
 	ttk::style configure TEntry \
 	    -padding 2 -selectborderwidth 0 -insertwidth 1
 	ttk::style map TEntry \
 	    -fieldbackground \
-	    	[list readonly SystemButtonFace disabled SystemButtonFace] \
+		[list readonly SystemButtonFace disabled SystemButtonFace] \
 	    -selectbackground [list !focus SystemWindow] \
 	    -selectforeground [list !focus SystemWindowText] \
 	    ;
 
 	ttk::style configure TCombobox -padding 2
 	ttk::style map TCombobox \
 	    -selectbackground [list !focus SystemWindow] \
 	    -selectforeground [list !focus SystemWindowText] \
 	    -fieldbackground [list \
-	    	readonly SystemButtonFace \
+		readonly SystemButtonFace \
 		disabled SystemButtonFace] \
 	    -foreground	[list \
 		disabled		SystemGrayText \
-	    	{readonly focus}	SystemHighlightText \
+		{readonly focus}	SystemHighlightText \
 	    ] \
 	    -focusfill	[list {readonly focus} SystemHighlight] \
 	    ;
 
 	ttk::style element create ComboboxPopdownFrame.border from default
@@ -69,11 +69,12 @@
 	ttk::style configure TNotebook.Tab -padding {3 1} -borderwidth 1
 	ttk::style map TNotebook.Tab -expand [list selected {2 2 2 0}]
 
 	# Treeview:
 	ttk::style configure Heading -font TkHeadingFont -relief raised
-	ttk::style configure Treeview -background SystemWindow
+	ttk::style configure Treeview -background SystemWindow \
+                -stripedbackground System3dLight
 	ttk::style map Treeview \
 	    -background [list   disabled SystemButtonFace \
 				selected SystemHighlight] \
 	    -foreground [list   disabled SystemGrayText \
 				selected SystemHighlightText]

Index: library/ttk/xpTheme.tcl
==================================================================
--- library/ttk/xpTheme.tcl
+++ library/ttk/xpTheme.tcl
@@ -40,11 +40,11 @@
 	ttk::style map TCombobox \
 	    -selectbackground [list !focus SystemWindow] \
 	    -selectforeground [list !focus SystemWindowText] \
 	    -foreground	[list \
 		disabled		SystemGrayText \
-	    	{readonly focus}	SystemHighlightText \
+		{readonly focus}	SystemHighlightText \
 	    ] \
 	    -focusfill	[list {readonly focus} SystemHighlight] \
 	    ;
 
 	ttk::style configure TSpinbox -padding {2 0 14 0}
@@ -55,13 +55,14 @@
 
 	ttk::style configure Toolbutton -padding {4 4}
 
 	# Treeview:
 	ttk::style configure Heading -font TkHeadingFont -relief raised
-	ttk::style configure Treeview -background SystemWindow
+	ttk::style configure Treeview -background SystemWindow \
+                -stripedbackground System3dLight
 	ttk::style map Treeview \
 	    -background [list   disabled SystemButtonFace \
 				selected SystemHighlight] \
 	    -foreground [list   disabled SystemGrayText \
 				selected SystemHighlightText];
     }
 }

Index: library/xmfbox.tcl
==================================================================
--- library/xmfbox.tcl
+++ library/xmfbox.tcl
@@ -81,13 +81,13 @@
     upvar ::tk::dialog::file::$dataName data
 
     MotifFDialog_Config $dataName $type $argList
 
     if {$data(-parent) eq "."} {
-        set w .$dataName
+	set w .$dataName
     } else {
-        set w $data(-parent).$dataName
+	set w $data(-parent).$dataName
     }
 
     # (re)create the dialog box if necessary
     #
     if {![winfo exists $w]} {
@@ -546,11 +546,11 @@
 proc ::tk::MotifFDialog_Update {w} {
     upvar ::tk::dialog::file::[winfo name $w] data
 
     $data(fEnt) delete 0 end
     $data(fEnt) insert 0 \
-            [::tk::dialog::file::JoinFile $data(selectPath) $data(filter)]
+	    [::tk::dialog::file::JoinFile $data(selectPath) $data(filter)]
     $data(sEnt) delete 0 end
     $data(sEnt) insert 0 [::tk::dialog::file::JoinFile $data(selectPath) \
 	    $data(selectFile)]
 
     MotifFDialog_LoadFiles $w
@@ -594,19 +594,19 @@
     set flist ""
     foreach f [glob -nocomplain .* *] {
 	if {[file isdir ./$f]} {
 	    lappend dlist $f
 	} else {
-            foreach pat $data(filter) {
-                if {[string match $pat $f]} {
+	    foreach pat $data(filter) {
+		if {[string match $pat $f]} {
 		    if {[string match .* $f]} {
 			incr top
 		    }
 		    lappend flist $f
-                    break
+		    break
 		}
-            }
+	    }
 	}
     }
     eval [list $data(dList) insert end] [lsort -dictionary $dlist]
     eval [list $data(fList) insert end] [lsort -dictionary $flist]
 

ADDED   macosx/Credits.html.in
Index: macosx/Credits.html.in
==================================================================
--- /dev/null
+++ macosx/Credits.html.in
@@ -0,0 +1,24 @@
+<!doctype htmL>
+<html>
+<head>
+</head>
+<body style="font-size:120%;font-family:Arial,sans-serif;">
+<p>
+Tcl and Tk are distributed under a modified BSD license:<br>
+<a href="https://www.tcl-lang.org/software/tcltk/license.html">
+  https://www.tcl-lang.org/software/tcltk/license.html
+</a>
+</p>
+<ul style="list-style-type:none;">
+<li>&copy; 1987-@TK_YEAR@ Tcl Core Team and Contributers.</li>
+<li>&copy; 2011-@TK_YEAR@ Kevin Walzer/WordTech Communications LLC.</li>
+<li>&copy; 2014-@TK_YEAR@ Marc Culler.</li>
+<li>&copy; 2002-2012 Daniel A. Steffen.</li>
+<li>&copy; 2001-2009 Apple Inc.</li>
+<li>&copy; 2001-2002 Jim Ingham &amp; Ian Reid.</li>
+<li>&copy; 1998-2000 Jim Ingham &amp; Ray Johnson.</li>
+<li>&copy; 1998-2000 Scriptics Inc.</li>
+<li>&copy; 1996-1997 Sun Microsystems Inc.</li>
+</ul>
+</body>
+</html>

Index: macosx/GNUmakefile
==================================================================
--- macosx/GNUmakefile
+++ macosx/GNUmakefile
@@ -44,16 +44,10 @@
 # set to non-empty value to build TkX11 instead of TkAqua:
 TK_X11			?=
 
 # Checks and overrides for subframework builds
 ifeq (${SUBFRAMEWORK}_${TK_X11},1_)
-ifeq (${DYLIB_INSTALL_DIR},)
-	@echo "Cannot install subframework with empty DYLIB_INSTALL_DIR !" && false
-endif
-ifeq (${DESTDIR},)
-	@echo "Cannot install subframework with empty DESTDIR !" && false
-endif
 override BUILD_DIR = ${DESTDIR}/build
 override INSTALL_PATH = /Frameworks
 endif
 
 #-------------------------------------------------------------------------------------------------------
@@ -143,13 +137,13 @@
 VERSION			:= ${VERSION}-X11
 wish			:= ${wish}-X11
 override EMBEDDED_BUILD :=
 endif
 
-INSTALL_TARGETS		= install-binaries install-libraries
+INSTALL_TARGETS		= install-binaries install-libraries install-headers
 ifeq (${EMBEDDED_BUILD},)
-INSTALL_TARGETS		+= install-private-headers install-headers install-demos
+INSTALL_TARGETS		+= install-private-headers install-demos
 endif
 ifeq (${INSTALL_BUILD}_${EMBEDDED_BUILD}_${BUILD_STYLE},1__Deployment)
 INSTALL_TARGETS		+= html-tk
 ifneq (${INSTALL_MANPAGES},)
 INSTALL_TARGETS		+= install-doc
@@ -191,11 +185,11 @@
 ${objdir}/Makefile: ${UNIX_DIR}/Makefile.in ${UNIX_DIR}/configure \
 		     ${UNIX_DIR}/tkConfig.sh.in Tk-Info.plist.in Wish-Info.plist.in
 	mkdir -p "${OBJ_DIR}" && cd "${OBJ_DIR}" && \
 	if [ ${UNIX_DIR}/configure -nt config.status ]; then ${UNIX_DIR}/configure -C \
 	--prefix="${PREFIX}" --bindir="${BINDIR}" --libdir="${LIBDIR}" \
-	--mandir="${MANDIR}" --enable-framework \
+	--mandir="${MANDIR}" --enable-framework --disable-zipfs \
 	--with-tcl="${TCL_DIR}" \
 	${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS}; else ./config.status; fi
 ifneq (${VERSION},${TCL_VERSION})
 	@cd "${OBJ_DIR}" && sed -e 's#/Versions/${TCL_VERSION}#/Versions/${VERSION}#' \
 	tkConfig.sh > tkConfig.sh.1 && mv -f tkConfig.sh.1 tkConfig.sh

Index: macosx/README
==================================================================
--- macosx/README
+++ macosx/README
@@ -325,14 +325,13 @@
 The macOS specific configure flags are --enable-aqua, --enable-framework and
 --disable-corefoundation (which disables CF and notably reverts to the standard
 select based notifier). Note that --enable-aqua is incompatible with
 --disable-corefoundation (for both Tcl and Tk configure).
 
-- It was once possible to build with the Xcode IDE via the projects in
+- It was once possible to build with the Xcode IDE via the project in
 tk/macosx, but this has not been tested recently. Take care to use the
 project matching your DevTools and OS version:
-	Tk.xcode: 		    for Xcode 3.1 on 10.5
 	Tk.xcodeproj:		    for Xcode 3.2 on 10.6
 These have the following targets:
 	Tk:			    calls through to tk/macosx/GNUMakefile,
 				    requires a corresponding build of the Tcl
 				    target of tcl/macosx/Tcl.xcode.
@@ -344,31 +343,27 @@
 	Debug clang:		    use clang compiler.
 	Debug llvm-gcc:		    use llvm-gcc compiler.
 	Debug gcc40:		    use gcc 4.0 compiler.
 	DebugNoGC:		    disable Objective-C garbage collection.
 	DebugNoFixAndContinue:      disable Fix & Continue.
-	DebugUnthreaded:	    disable threading.
 	DebugNoCF:		    disable corefoundation (X11 only).
-	DebugNoCFUnthreaded:	    disable corefoundation an threading.
 	DebugMemCompile:	    enable memory and bytecode debugging.
 	DebugLeaks:		    define PURIFY.
 	DebugGCov:		    enable generation of gcov data files.
-	Debug64bit:		    configure with --enable-64bit (requires
-				    building on a 64bit capable processor).
 	Release:		    release build for the active architecture.
 	ReleaseUniversal:	    32/64-bit universal build.
 	ReleaseUniversal clang:	    use clang compiler.
 	ReleaseUniversal llvm-gcc:  use llvm-gcc compiler.
 	ReleaseUniversal gcc40:	    use gcc 4.0 compiler.
 	ReleaseUniversal10.5SDK:    build against the 10.5 SDK (with 10.5
 				    deployment target).
 	Note that the non-SDK configurations have their deployment target set to
-	10.5 (Tk.xcode) resp. 10.6 (Tk.xcodeproj).
+	10.6 (Tk.xcodeproj).
 The Xcode projects refer to the toplevel tcl and tk source directories via the
 the TCL_SRCROOT and TK_SRCROOT user build settings, by default these are set to
 the project-relative paths '../../tcl' and '../../tk', if your source
-directories are named differently, e.g. '../../tcl8.6' and '../../tk8.6', you
+directories are named differently, e.g. '../../tcl8.7' and '../../tk8.7', you
 need to manually change the TCL_SRCROOT and TK_SRCROOT settings by editing your
 ${USER}.pbxuser file (located inside the Tk.xcodeproj bundle directory) with a
 text editor.
 
 - To enable weak-linking, set the MACOSX_DEPLOYMENT_TARGET environment variable
@@ -389,18 +384,16 @@
 [ (where /path_to_{tcl,tk} is the directory containing the tcl resp. tk tree)  ]
 [ or you can pass an argument of BUILD_DIR=/somewhere to the tcl and tk make.  ]
 
 - The following instructions assume the Tcl and Tk source trees are named
 "tcl${ver}" and "tk${ver}" (where ${ver} is a shell variable containing the
-Tcl/Tk version number, e.g. '8.6').
+Tcl/Tk version number, e.g. '8.7').
 Setup this shell variable as follows:
-	ver="8.6"
-If you are building from CVS, omit this step (CVS source tree names usually do
-not contain a version number).
+	ver="8.7"
 
 - Setup environment variables as desired, e.g. for a universal build on 10.5:
-	CFLAGS="-arch i386 -arch x86_64 -arch ppc -mmacosx-version-min=10.5"
+	CFLAGS="-arch x86_64 -arch arm64e -mmacosx-version-min=10.5"
 	export CFLAGS
 
 - Change to the directory containing the Tcl and Tk source trees and build:
 	make -C tcl${ver}/macosx
 	make -C tk${ver}/macosx
@@ -464,11 +457,11 @@
 DYLIB_INSTALL_DIR variable to the path which should be the install_name path of
 the shared library and set the DESTDIR variable to the pathname of a staging
 directory where the frameworks will be written.  The Tcl framework must be
 built first.
 For example, running the commands:
-	make -C ../tcl8.6/macosx install-embedded SUBFRAMEWORK=1 DESTDIR=/tmp/tcltk \
+	make -C ../tcl8.7/macosx install-embedded SUBFRAMEWORK=1 DESTDIR=/tmp/tcltk \
 	DYLIB_INSTALL_DIR=/Library/Frameworks/Some.framework/Versions/X.Y/Frameworks/Tcl.framework
 	make -C macosx install-embedded SUBFRAMEWORK=1 DESTDIR=/tmp/tcltk \
 	DYLIB_INSTALL_DIR=/Library/Frameworks/Some.framework/Versions/X.Y/Frameworks/Tk.framework
 will produce a Tcl.framework and a Tk.framework usable as subframeworks of
 Some.framework.  The frameworks will be found in /tmp/tcltk/Frameworks/
@@ -550,11 +543,11 @@
 Since the CheckProc function gets called for every Tk event, it is an
 appropriate place to drain the main NSAutoreleasePool and replace it
 with a new pool.  This is done by calling the method [NSApp
 _resetAutoreleasePool], where _resetAutoreleasePool is a method which
 we define for the subclass.  Unfortunately, by itself this is not
-sufficient for safe memory managememt because, as was made painfully
+sufficient for safe memory management because, as was made painfully
 evident with the release of OS X 10.13, it is possible for calls to
 TclDoOneEvent, and hence to CheckProc, to be nested.  Draining the
 autorelease pool in a nested call leads to crashes as objects in use
 by the outer call can get freed by the inner call and then reused later.
 One particular situation where this happens is when a modal dialogue
@@ -683,11 +676,11 @@
 6.0 Virtual events on macOS 10.14 and later
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 The 10.14 release added support for system appearance changes,
 including a "Dark Mode" that renders all window frames and menus in
-dark colors. Tk 8.6.11 provides three virtual events <<LightAqua>>,
+dark colors. Tk 8.7 provides three virtual events <<LightAqua>>,
 <<DarkAqua>> and <<AppearanceChanged>>, to allow you to update your Tk
 app's appearance when the system appearance changes.  These events are
 generated in [NSView effectiveAppearanceChanged], which is called by
 the Apple window manager when the General Preferences is changed
 either by switching between Light Mode and Dark Mode or by changing

Index: macosx/Tk-Common.xcconfig
==================================================================
--- macosx/Tk-Common.xcconfig
+++ macosx/Tk-Common.xcconfig
@@ -31,16 +31,15 @@
 CPPFLAGS = -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET) $(CPPFLAGS)
 FRAMEWORK_INSTALL_PATH = /Library/Frameworks
 INCLUDEDIR = $(PREFIX)/include
 LIBDIR = $(PREFIX)/lib
 MANDIR = $(PREFIX)/man
-PER_ARCH_CFLAGS_ppc = -mcpu=G3 -mtune=G4 $(PER_ARCH_CFLAGS_ppc)
 PREFIX = /usr/local
 TCL_BUILD_DIR = $(OBJROOT)/../tcl/Tcl.build/$(CONFIGURATION)/Tcl.build/Objects
 TCL_CONFIGURE_ARGS = --enable-dtrace
 TCL_FRAMEWORK_DIR = $(SYMROOT)/../tcl/$(CONFIGURATION)
 TCL_LIBRARY = $(LIBDIR)/tcl$(VERSION)
 TCL_PACKAGE_PATH = "$(LIBDIR)"
 TCL_DEFS = HAVE_TCL_CONFIG_H
 TK_LIBRARY = $(LIBDIR)/tk$(VERSION)
-TK_DEFS = HAVE_TK_CONFIG_H TCL_NO_DEPRECATED
+TK_DEFS = HAVE_TK_CONFIG_H
 VERSION = 8.7

Index: macosx/Tk-Release.xcconfig
==================================================================
--- macosx/Tk-Release.xcconfig
+++ macosx/Tk-Release.xcconfig
@@ -11,9 +11,9 @@
 
 #include "Tk-Common.xcconfig"
 
 DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
 // DEPLOYMENT_POSTPROCESSING = YES
-GCC_OPTIMIZATION_LEVEL = s
+GCC_OPTIMIZATION_LEVEL = 2
 GCC_PREPROCESSOR_DEFINITIONS = NDEBUG $(TCL_DEFS) $(TK_DEFS) $(GCC_PREPROCESSOR_DEFINITIONS)
 CONFIGURE_ARGS = --disable-symbols $(TCL_CONFIGURE_ARGS) $(CONFIGURE_ARGS)
 MAKE_TARGET = deploy

DELETED macosx/Tk.xcode/default.pbxuser
Index: macosx/Tk.xcode/default.pbxuser
==================================================================
--- macosx/Tk.xcode/default.pbxuser
+++ /dev/null
@@ -1,384 +0,0 @@
-// !$*UTF8*$!
-{
-	08FB7793FE84155DC02AAC07 /* Project object */ = {
-		activeBuildConfigurationName = Debug;
-		activeExecutable = F9E61D1C090A4282002B3151 /* Wish */;
-		activeTarget = F9E61D16090A3E94002B3151 /* Tk */;
-		codeSenseManager = F944EB9D08F798180049FDD4 /* Code sense */;
-		executables = (
-			F9E61D1C090A4282002B3151 /* Wish */,
-			F944EB8F08F798100049FDD4 /* tktest */,
-			F9FD31F50CC1AD070073837D /* tktest-X11 */,
-		);
-		perUserDictionary = {
-			com.apple.ide.smrt.PBXUserSmartGroupsKey.Rev10 = <040b73747265616d747970656481e8038401408484840e4e534d757461626c654172726179008484074e534172726179008484084e534f626a65637400858401690192848484134e534d757461626c6544696374696f6e6172790084840c4e5344696374696f6e6172790095960792848484084e53537472696e67019584012b046e616d658692849a9a14496d706c656d656e746174696f6e2046696c65738692849a9a146162736f6c75746550617468546f42756e646c658692849a9a008692849a9a195042585472616e7369656e744c6f636174696f6e4174546f708692849a9a06626f74746f6d8692849a9a03636c7a8692849a9a1550425846696c656e616d65536d61727447726f75708692849a9a0b6465736372697074696f6e8692849a9a103c6e6f206465736372697074696f6e3e8692849a9a0b707265666572656e63657386928497960892849a9a07666e6d617463688692849a9a008692849a9a05696d6167658692849a9a0b536d617274466f6c6465728692849a9a04726f6f748692849a9a093c50524f4a4543543e8692849a9a0572656765788692849a9a065c2e286329248692849a9a097265637572736976658692848484084e534e756d626572008484074e5356616c7565009584012a849696018692849a9a0669734c656166869284b09db296008692849a9a0763616e536176658692af92849a9a1250425850726f6a65637453636f70654b65798692849a9a03594553868692849a9a08676c6f62616c49448692849a9a18314343304541343030343335304546393030343434313042868686>;
-		};
-		sourceControlManager = F944EB9C08F798180049FDD4 /* Source Control */;
-		userBuildSettings = {
-			SYMROOT = "${SRCROOT}/../../build/tk";
-			TCL_SRCROOT = "${SRCROOT}/../../tcl";
-			TK_SRCROOT = "${SRCROOT}/../../tk";
-		};
-	};
-	8DD76FA90486AB0100D96B5E /* tktest */ = {
-		activeExec = 0;
-		executables = (
-			F944EB8F08F798100049FDD4 /* tktest */,
-		);
-	};
-	F944EB8F08F798100049FDD4 /* tktest */ = {
-		isa = PBXExecutable;
-		activeArgIndices = (
-			YES,
-			NO,
-			NO,
-			NO,
-			NO,
-			NO,
-			NO,
-		);
-		argumentStrings = (
-			"${TK_SRCROOT}/library/demos/widget",
-			"${TK_SRCROOT}/tests/all.tcl",
-			"${TK_SRCROOT}/tests/ttk/all.tcl",
-			"-geometry +0+0",
-			"-singleproc 1",
-			"-verbose \"bet\"",
-			"-skip window-2.9",
-		);
-		autoAttachOnCrash = 1;
-		breakpointsEnabled = 1;
-		configStateDict = {
-			"PBXLSLaunchAction-0" = {
-				PBXLSLaunchAction = 0;
-				PBXLSLaunchStartAction = 1;
-				PBXLSLaunchStdioStyle = 2;
-				PBXLSLaunchStyle = 0;
-				class = PBXLSRunLaunchConfig;
-				displayName = "Executable Runner";
-				identifier = com.apple.Xcode.launch.runConfig;
-				remoteHostInfo = "";
-				startActionInfo = "";
-			};
-			"PBXLSLaunchAction-1" = {
-				PBXLSLaunchAction = 1;
-				PBXLSLaunchStartAction = 1;
-				PBXLSLaunchStdioStyle = 2;
-				PBXLSLaunchStyle = 0;
-				class = PBXGDB_LaunchConfig;
-				displayName = GDB;
-				identifier = com.apple.Xcode.launch.GDBMI_Config;
-				remoteHostInfo = "";
-				startActionInfo = "";
-			};
-		};
-		customDataFormattersEnabled = 1;
-		debuggerPlugin = GDBDebugging;
-		disassemblyDisplayState = 0;
-		dylibVariantSuffix = "";
-		enableDebugStr = 0;
-		environmentEntries = (
-			{
-				active = YES;
-				name = TCL_LIBRARY;
-				value = "${TCL_SRCROOT}/library";
-			},
-			{
-				active = YES;
-				name = TK_LIBRARY;
-				value = "${TK_SRCROOT}/library";
-			},
-			{
-				active = YES;
-				name = TCLLIBPATH;
-				value = /Library/Tcl;
-			},
-			{
-				active = YES;
-				name = TK_SRCROOT;
-				value = "${TK_SRCROOT}";
-			},
-			{
-				active = NO;
-				name = TK_CONSOLE;
-				value = 1;
-			},
-			{
-				active = NO;
-				name = DYLD_PRINT_LIBRARIES;
-			},
-			{
-				active = NO;
-				name = NSTraceEvents;
-				value = YES;
-			},
-			{
-				active = NO;
-				name = MallocBadFreeAbort;
-				value = 1;
-			},
-			{
-				active = NO;
-				name = MallocLogFile;
-				value = /tmp/malloc.log;
-			},
-			{
-				active = NO;
-				name = MallocStackLogging;
-				value = 1;
-			},
-			{
-				active = NO;
-				name = MallocStackLoggingNoCompact;
-				value = 1;
-			},
-			{
-				active = NO;
-				name = MallocPreScribble;
-				value = 1;
-			},
-			{
-				active = NO;
-				name = MallocScribble;
-				value = 1;
-			},
-			{
-				active = NO;
-				name = NSZombieEnabled;
-				value = YES;
-			},
-			{
-				active = NO;
-				name = NSDeallocateZombies;
-				value = YES;
-			},
-			{
-				active = NO;
-				name = NSAutoreleaseFreedObjectCheckEnabled;
-				value = YES;
-			},
-			{
-				active = NO;
-				name = NSEnableAutoreleasePool;
-				value = NO;
-			},
-			{
-				active = NO;
-				name = AUTO_LOG_ALL;
-				value = YES;
-			},
-			{
-				active = NO;
-				name = AUTO_LOG_NOISY;
-				value = YES;
-			},
-			{
-				active = NO;
-				name = AUTO_REFERENCE_COUNT_LOGGING;
-				value = YES;
-			},
-		);
-		executableSystemSymbolLevel = 0;
-		executableUserSymbolLevel = 0;
-		libgmallocEnabled = 0;
-		name = tktest;
-		sourceDirectories = (
-		);
-	};
-	F944EB9C08F798180049FDD4 /* Source Control */ = {
-		isa = PBXSourceControlManager;
-		fallbackIsa = XCSourceControlManager;
-		isSCMEnabled = 0;
-		scmConfiguration = {
-			CVSToolPath = /usr/bin/cvs;
-			CVSUseSSH = NO;
-			SubversionToolPath = /usr/bin/svn;
-			repositoryNamesForRoots = {
-				.. = "";
-			};
-		};
-		scmType = scm.cvs;
-	};
-	F944EB9D08F798180049FDD4 /* Code sense */ = {
-		isa = PBXCodeSenseManager;
-		indexTemplatePath = "";
-	};
-	F97258A50A86873C00096C78 /* tktest-X11 */ = {
-		activeExec = 0;
-		executables = (
-			F9FD31F50CC1AD070073837D /* tktest-X11 */,
-		);
-	};
-	F9E61D16090A3E94002B3151 /* Tk */ = {
-		activeExec = 0;
-		executables = (
-			F9E61D1C090A4282002B3151 /* Wish */,
-		);
-	};
-	F9E61D1C090A4282002B3151 /* Wish */ = {
-		isa = PBXExecutable;
-		activeArgIndices = (
-			YES,
-		);
-		argumentStrings = (
-			"${TK_SRCROOT}/library/demos/widget",
-		);
-		autoAttachOnCrash = 1;
-		breakpointsEnabled = 1;
-		configStateDict = {
-			"PBXLSLaunchAction-0" = {
-				PBXLSLaunchAction = 0;
-				PBXLSLaunchStartAction = 1;
-				PBXLSLaunchStdioStyle = 2;
-				PBXLSLaunchStyle = 0;
-				class = PBXLSRunLaunchConfig;
-				displayName = "Executable Runner";
-				identifier = com.apple.Xcode.launch.runConfig;
-				remoteHostInfo = "";
-				startActionInfo = "";
-			};
-			"PBXLSLaunchAction-1" = {
-				PBXLSLaunchAction = 1;
-				PBXLSLaunchStartAction = 1;
-				PBXLSLaunchStdioStyle = 2;
-				PBXLSLaunchStyle = 0;
-				class = PBXGDB_LaunchConfig;
-				displayName = GDB;
-				identifier = com.apple.Xcode.launch.GDBMI_Config;
-				remoteHostInfo = "";
-				startActionInfo = "";
-			};
-		};
-		customDataFormattersEnabled = 1;
-		debuggerPlugin = GDBDebugging;
-		disassemblyDisplayState = 0;
-		dylibVariantSuffix = "";
-		enableDebugStr = 0;
-		environmentEntries = (
-			{
-				active = NO;
-				name = DYLD_PRINT_LIBRARIES;
-			},
-		);
-		executableSystemSymbolLevel = 0;
-		executableUserSymbolLevel = 0;
-		libgmallocEnabled = 0;
-		name = Wish;
-		sourceDirectories = (
-		);
-	};
-	F9FD31F50CC1AD070073837D /* tktest-X11 */ = {
-		isa = PBXExecutable;
-		activeArgIndices = (
-			YES,
-			NO,
-			NO,
-			NO,
-			NO,
-			NO,
-			NO,
-		);
-		argumentStrings = (
-			"${TK_SRCROOT}/library/demos/widget",
-			"${TK_SRCROOT}/tests/all.tcl",
-			"${TK_SRCROOT}/tests/ttk/all.tcl",
-			"-geometry +0+0",
-			"-singleproc 1",
-			"-verbose \"bet\"",
-			"-skip window-2.9",
-		);
-		autoAttachOnCrash = 1;
-		breakpointsEnabled = 1;
-		configStateDict = {
-			"PBXLSLaunchAction-0" = {
-				PBXLSLaunchAction = 0;
-				PBXLSLaunchStartAction = 1;
-				PBXLSLaunchStdioStyle = 2;
-				PBXLSLaunchStyle = 0;
-				class = PBXLSRunLaunchConfig;
-				displayName = "Executable Runner";
-				identifier = com.apple.Xcode.launch.runConfig;
-				remoteHostInfo = "";
-				startActionInfo = "";
-			};
-			"PBXLSLaunchAction-1" = {
-				PBXLSLaunchAction = 1;
-				PBXLSLaunchStartAction = 1;
-				PBXLSLaunchStdioStyle = 2;
-				PBXLSLaunchStyle = 0;
-				class = PBXGDB_LaunchConfig;
-				displayName = GDB;
-				identifier = com.apple.Xcode.launch.GDBMI_Config;
-				remoteHostInfo = "";
-				startActionInfo = "";
-			};
-		};
-		customDataFormattersEnabled = 1;
-		debuggerPlugin = GDBDebugging;
-		disassemblyDisplayState = 0;
-		dylibVariantSuffix = "";
-		enableDebugStr = 0;
-		environmentEntries = (
-			{
-				active = YES;
-				name = TCL_LIBRARY;
-				value = "${TCL_SRCROOT}/library";
-			},
-			{
-				active = YES;
-				name = TK_LIBRARY;
-				value = "${TK_SRCROOT}/library";
-			},
-			{
-				active = YES;
-				name = TCLLIBPATH;
-				value = /Library/Tcl;
-			},
-			{
-				active = YES;
-				name = DISPLAY;
-				value = ":0";
-			},
-			{
-				active = NO;
-				name = DYLD_PRINT_LIBRARIES;
-			},
-			{
-				active = NO;
-				name = MallocBadFreeAbort;
-				value = 1;
-			},
-			{
-				active = NO;
-				name = MallocLogFile;
-				value = /tmp/malloc.log;
-			},
-			{
-				active = NO;
-				name = MallocStackLogging;
-				value = 1;
-			},
-			{
-				active = NO;
-				name = MallocStackLoggingNoCompact;
-				value = 1;
-			},
-			{
-				active = NO;
-				name = MallocPreScribble;
-				value = 1;
-			},
-			{
-				active = NO;
-				name = MallocScribble;
-				value = 1;
-			},
-		);
-		executableSystemSymbolLevel = 0;
-		executableUserSymbolLevel = 0;
-		libgmallocEnabled = 0;
-		name = "tktest-X11";
-		sourceDirectories = (
-		);
-	};
-}

DELETED macosx/Tk.xcode/project.pbxproj
Index: macosx/Tk.xcode/project.pbxproj
==================================================================
--- macosx/Tk.xcode/project.pbxproj
+++ /dev/null
@@ -1,5774 +0,0 @@
-// !$*UTF8*$!
-{
-	archiveVersion = 1;
-	classes = {
-	};
-	objectVersion = 45;
-	objects = {
-
-/* Begin PBXBuildFile section */
-		F9067BCD0BFBA2900074F726 /* tkOldTest.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAFE08F27A39005CB29B /* tkOldTest.c */; };
-		F9152B090EAF8A5000CD5C7B /* tkBusy.c in Sources */ = {isa = PBXBuildFile; fileRef = F9152B080EAF8A5000CD5C7B /* tkBusy.c */; };
-		F9152B0A0EAF8A5700CD5C7B /* tkBusy.c in Sources */ = {isa = PBXBuildFile; fileRef = F9152B080EAF8A5000CD5C7B /* tkBusy.c */; };
-		F92EE8BF0E62F846001A6E80 /* tkImgPhInstance.c in Sources */ = {isa = PBXBuildFile; fileRef = F92EE8BE0E62F846001A6E80 /* tkImgPhInstance.c */; };
-		F92EE8D30E62F939001A6E80 /* tkImgPhInstance.c in Sources */ = {isa = PBXBuildFile; fileRef = F92EE8BE0E62F846001A6E80 /* tkImgPhInstance.c */; };
-		F93599B30DF1F75400E04F67 /* tclOO.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599B20DF1F75400E04F67 /* tclOO.c */; };
-		F93599B70DF1F76100E04F67 /* tclOOBasic.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599B60DF1F76100E04F67 /* tclOOBasic.c */; };
-		F93599B90DF1F76600E04F67 /* tclOOCall.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599B80DF1F76600E04F67 /* tclOOCall.c */; };
-		F93599BC0DF1F77000E04F67 /* tclOODefineCmds.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599BB0DF1F77000E04F67 /* tclOODefineCmds.c */; };
-		F93599BE0DF1F77400E04F67 /* tclOOInfo.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599BD0DF1F77400E04F67 /* tclOOInfo.c */; };
-		F93599C20DF1F78300E04F67 /* tclOOMethod.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599C10DF1F78300E04F67 /* tclOOMethod.c */; };
-		F93599C40DF1F78800E04F67 /* tclOOStubInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599C30DF1F78800E04F67 /* tclOOStubInit.c */; };
-		F93599C60DF1F78D00E04F67 /* tclOOStubLib.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599C50DF1F78D00E04F67 /* tclOOStubLib.c */; };
-		F94523A20E6FC2AC00C1D987 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F94523A10E6FC2AC00C1D987 /* Cocoa.framework */; };
-		F95D77EA0DFD820D00A8BF6F /* tclIORTrans.c in Sources */ = {isa = PBXBuildFile; fileRef = F95D77E90DFD820D00A8BF6F /* tclIORTrans.c */; };
-		F96437CA0EF0D4B2003F468E /* tclZlib.c in Sources */ = {isa = PBXBuildFile; fileRef = F96437C90EF0D4B2003F468E /* tclZlib.c */; };
-		F96437CB0EF0D4B2003F468E /* tclZlib.c in Sources */ = {isa = PBXBuildFile; fileRef = F96437C90EF0D4B2003F468E /* tclZlib.c */; };
-		F96437E70EF0D652003F468E /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F96437E60EF0D652003F468E /* libz.dylib */; };
-		F96437E80EF0D652003F468E /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F96437E60EF0D652003F468E /* libz.dylib */; };
-		F966BDCF08F27A3F005CB29B /* tk3d.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAAC08F27A39005CB29B /* tk3d.c */; };
-		F966BDD108F27A3F005CB29B /* tkArgv.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAAE08F27A39005CB29B /* tkArgv.c */; };
-		F966BDD208F27A3F005CB29B /* tkAtom.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAAF08F27A39005CB29B /* tkAtom.c */; };
-		F966BDD308F27A3F005CB29B /* tkBind.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB008F27A39005CB29B /* tkBind.c */; };
-		F966BDD408F27A3F005CB29B /* tkBitmap.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB108F27A39005CB29B /* tkBitmap.c */; };
-		F966BDD508F27A3F005CB29B /* tkButton.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB208F27A39005CB29B /* tkButton.c */; };
-		F966BDD708F27A3F005CB29B /* tkCanvArc.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB408F27A39005CB29B /* tkCanvArc.c */; };
-		F966BDD808F27A3F005CB29B /* tkCanvas.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB508F27A39005CB29B /* tkCanvas.c */; };
-		F966BDDA08F27A3F005CB29B /* tkCanvBmap.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB708F27A39005CB29B /* tkCanvBmap.c */; };
-		F966BDDB08F27A3F005CB29B /* tkCanvImg.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB808F27A39005CB29B /* tkCanvImg.c */; };
-		F966BDDC08F27A3F005CB29B /* tkCanvLine.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB908F27A39005CB29B /* tkCanvLine.c */; };
-		F966BDDD08F27A3F005CB29B /* tkCanvPoly.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BABA08F27A39005CB29B /* tkCanvPoly.c */; };
-		F966BDDE08F27A3F005CB29B /* tkCanvPs.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BABB08F27A39005CB29B /* tkCanvPs.c */; };
-		F966BDE008F27A3F005CB29B /* tkCanvText.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BABD08F27A39005CB29B /* tkCanvText.c */; };
-		F966BDE108F27A3F005CB29B /* tkCanvUtil.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BABE08F27A39005CB29B /* tkCanvUtil.c */; };
-		F966BDE208F27A3F005CB29B /* tkCanvWind.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BABF08F27A39005CB29B /* tkCanvWind.c */; };
-		F966BDE308F27A3F005CB29B /* tkClipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC008F27A39005CB29B /* tkClipboard.c */; };
-		F966BDE408F27A3F005CB29B /* tkCmds.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC108F27A39005CB29B /* tkCmds.c */; };
-		F966BDE508F27A3F005CB29B /* tkColor.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC208F27A39005CB29B /* tkColor.c */; };
-		F966BDE708F27A3F005CB29B /* tkConfig.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC408F27A39005CB29B /* tkConfig.c */; };
-		F966BDE808F27A3F005CB29B /* tkConsole.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC508F27A39005CB29B /* tkConsole.c */; };
-		F966BDE908F27A3F005CB29B /* tkCursor.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC608F27A39005CB29B /* tkCursor.c */; };
-		F966BDEB08F27A3F005CB29B /* tkEntry.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC808F27A39005CB29B /* tkEntry.c */; };
-		F966BDED08F27A3F005CB29B /* tkError.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BACA08F27A39005CB29B /* tkError.c */; };
-		F966BDEE08F27A3F005CB29B /* tkEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BACB08F27A39005CB29B /* tkEvent.c */; };
-		F966BDEF08F27A3F005CB29B /* tkFileFilter.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BACC08F27A39005CB29B /* tkFileFilter.c */; };
-		F966BDF108F27A3F005CB29B /* tkFocus.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BACE08F27A39005CB29B /* tkFocus.c */; };
-		F966BDF208F27A3F005CB29B /* tkFont.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BACF08F27A39005CB29B /* tkFont.c */; };
-		F966BDF408F27A3F005CB29B /* tkFrame.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD108F27A39005CB29B /* tkFrame.c */; };
-		F966BDF508F27A3F005CB29B /* tkGC.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD208F27A39005CB29B /* tkGC.c */; };
-		F966BDF608F27A3F005CB29B /* tkGeometry.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD308F27A39005CB29B /* tkGeometry.c */; };
-		F966BDF708F27A3F005CB29B /* tkGet.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD408F27A39005CB29B /* tkGet.c */; };
-		F966BDF808F27A3F005CB29B /* tkGrab.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD508F27A39005CB29B /* tkGrab.c */; };
-		F966BDF908F27A3F005CB29B /* tkGrid.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD608F27A39005CB29B /* tkGrid.c */; };
-		F966BDFA08F27A3F005CB29B /* tkImage.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD708F27A39005CB29B /* tkImage.c */; };
-		F966BDFB08F27A3F005CB29B /* tkImgBmap.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD808F27A39005CB29B /* tkImgBmap.c */; };
-		F966BDFC08F27A3F005CB29B /* tkImgGIF.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD908F27A39005CB29B /* tkImgGIF.c */; };
-		F966BDFD08F27A3F005CB29B /* tkImgPhoto.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BADA08F27A39005CB29B /* tkImgPhoto.c */; };
-		F966BDFE08F27A3F005CB29B /* tkImgPPM.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BADB08F27A39005CB29B /* tkImgPPM.c */; };
-		F966BE0708F27A3F005CB29B /* tkListbox.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAE408F27A39005CB29B /* tkListbox.c */; };
-		F966BE0808F27A3F005CB29B /* tkMacWinMenu.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAE508F27A39005CB29B /* tkMacWinMenu.c */; };
-		F966BE0908F27A3F005CB29B /* tkMain.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAE608F27A39005CB29B /* tkMain.c */; };
-		F966BE0A08F27A3F005CB29B /* tkMenu.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAE708F27A39005CB29B /* tkMenu.c */; };
-		F966BE0C08F27A3F005CB29B /* tkMenubutton.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAE908F27A39005CB29B /* tkMenubutton.c */; };
-		F966BE0E08F27A3F005CB29B /* tkMenuDraw.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAEB08F27A39005CB29B /* tkMenuDraw.c */; };
-		F966BE0F08F27A3F005CB29B /* tkMessage.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAEC08F27A39005CB29B /* tkMessage.c */; };
-		F966BE1008F27A3F005CB29B /* tkObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAED08F27A39005CB29B /* tkObj.c */; };
-		F966BE1108F27A3F005CB29B /* tkOldConfig.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAEE08F27A39005CB29B /* tkOldConfig.c */; };
-		F966BE1208F27A3F005CB29B /* tkOption.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAEF08F27A39005CB29B /* tkOption.c */; };
-		F966BE1308F27A3F005CB29B /* tkPack.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAF008F27A39005CB29B /* tkPack.c */; };
-		F966BE1408F27A3F005CB29B /* tkPanedWindow.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAF108F27A39005CB29B /* tkPanedWindow.c */; };
-		F966BE1508F27A3F005CB29B /* tkPlace.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAF208F27A39005CB29B /* tkPlace.c */; };
-		F966BE1708F27A3F005CB29B /* tkPointer.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAF408F27A39005CB29B /* tkPointer.c */; };
-		F966BE1908F27A3F005CB29B /* tkRectOval.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAF608F27A39005CB29B /* tkRectOval.c */; };
-		F966BE1A08F27A3F005CB29B /* tkScale.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAF708F27A39005CB29B /* tkScale.c */; };
-		F966BE1C08F27A40005CB29B /* tkScrollbar.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAF908F27A39005CB29B /* tkScrollbar.c */; };
-		F966BE1E08F27A40005CB29B /* tkSelect.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAFB08F27A39005CB29B /* tkSelect.c */; };
-		F966BE2008F27A40005CB29B /* tkSquare.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAFD08F27A39005CB29B /* tkSquare.c */; };
-		F966BE2208F27A40005CB29B /* tkStubInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAFF08F27A39005CB29B /* tkStubInit.c */; };
-		F966BE2308F27A40005CB29B /* tkStubLib.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0008F27A39005CB29B /* tkStubLib.c */; };
-		F966BE2408F27A40005CB29B /* tkStyle.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0108F27A39005CB29B /* tkStyle.c */; };
-		F966BE2508F27A40005CB29B /* tkTest.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0208F27A39005CB29B /* tkTest.c */; };
-		F966BE2608F27A40005CB29B /* tkText.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0308F27A39005CB29B /* tkText.c */; };
-		F966BE2808F27A40005CB29B /* tkTextBTree.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0508F27A39005CB29B /* tkTextBTree.c */; };
-		F966BE2908F27A40005CB29B /* tkTextDisp.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0608F27A39005CB29B /* tkTextDisp.c */; };
-		F966BE2B08F27A40005CB29B /* tkTextImage.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0808F27A39005CB29B /* tkTextImage.c */; };
-		F966BE2C08F27A40005CB29B /* tkTextIndex.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0908F27A39005CB29B /* tkTextIndex.c */; };
-		F966BE2D08F27A40005CB29B /* tkTextMark.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0A08F27A39005CB29B /* tkTextMark.c */; };
-		F966BE2E08F27A40005CB29B /* tkTextTag.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0B08F27A39005CB29B /* tkTextTag.c */; };
-		F966BE2F08F27A40005CB29B /* tkTextWind.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0C08F27A39005CB29B /* tkTextWind.c */; };
-		F966BE3008F27A40005CB29B /* tkTrig.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0D08F27A39005CB29B /* tkTrig.c */; };
-		F966BE3108F27A40005CB29B /* tkUndo.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0E08F27A39005CB29B /* tkUndo.c */; };
-		F966BE3308F27A40005CB29B /* tkUtil.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB1008F27A39005CB29B /* tkUtil.c */; };
-		F966BE3408F27A40005CB29B /* tkVisual.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB1108F27A39005CB29B /* tkVisual.c */; };
-		F966BE3508F27A40005CB29B /* tkWindow.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB1208F27A39005CB29B /* tkWindow.c */; };
-		F966BEDB08F27A40005CB29B /* tkMacOSXBitmap.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC508F27A3B005CB29B /* tkMacOSXBitmap.c */; };
-		F966BEDC08F27A40005CB29B /* tkMacOSXButton.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC608F27A3B005CB29B /* tkMacOSXButton.c */; };
-		F966BEDE08F27A40005CB29B /* tkMacOSXClipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC808F27A3B005CB29B /* tkMacOSXClipboard.c */; };
-		F966BEDF08F27A40005CB29B /* tkMacOSXColor.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBC908F27A3B005CB29B /* tkMacOSXColor.c */; };
-		F966BEE008F27A40005CB29B /* tkMacOSXConfig.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBCA08F27A3B005CB29B /* tkMacOSXConfig.c */; };
-		F966BEE108F27A40005CB29B /* tkMacOSXCursor.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBCB08F27A3B005CB29B /* tkMacOSXCursor.c */; };
-		F966BEE308F27A40005CB29B /* tkMacOSXDebug.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBCD08F27A3B005CB29B /* tkMacOSXDebug.c */; };
-		F966BEE608F27A40005CB29B /* tkMacOSXDialog.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBD008F27A3B005CB29B /* tkMacOSXDialog.c */; };
-		F966BEE708F27A40005CB29B /* tkMacOSXDraw.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBD108F27A3B005CB29B /* tkMacOSXDraw.c */; };
-		F966BEE808F27A40005CB29B /* tkMacOSXEmbed.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBD208F27A3B005CB29B /* tkMacOSXEmbed.c */; };
-		F966BEE908F27A40005CB29B /* tkMacOSXEntry.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBD308F27A3B005CB29B /* tkMacOSXEntry.c */; };
-		F966BEEA08F27A40005CB29B /* tkMacOSXEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBD408F27A3B005CB29B /* tkMacOSXEvent.c */; };
-		F966BEEC08F27A40005CB29B /* tkMacOSXFont.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBD608F27A3B005CB29B /* tkMacOSXFont.c */; };
-		F966BEED08F27A40005CB29B /* tkMacOSXHLEvents.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBD708F27A3B005CB29B /* tkMacOSXHLEvents.c */; };
-		F966BEEE08F27A40005CB29B /* tkMacOSXInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBD808F27A3B005CB29B /* tkMacOSXInit.c */; settings = {COMPILER_FLAGS = "-DTK_LIBRARY=\\\"$(TK_LIBRARY)\\\""; }; };
-		F966BEF108F27A40005CB29B /* tkMacOSXKeyboard.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBDB08F27A3B005CB29B /* tkMacOSXKeyboard.c */; };
-		F966BEF208F27A40005CB29B /* tkMacOSXKeyEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBDC08F27A3B005CB29B /* tkMacOSXKeyEvent.c */; };
-		F966BEF308F27A40005CB29B /* tkMacOSXMenu.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBDD08F27A3B005CB29B /* tkMacOSXMenu.c */; };
-		F966BEF608F27A40005CB29B /* tkMacOSXMenubutton.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBE008F27A3B005CB29B /* tkMacOSXMenubutton.c */; };
-		F966BEF708F27A40005CB29B /* tkMacOSXMenus.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBE108F27A3B005CB29B /* tkMacOSXMenus.c */; };
-		F966BEF808F27A40005CB29B /* tkMacOSXMouseEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBE208F27A3B005CB29B /* tkMacOSXMouseEvent.c */; };
-		F966BEF908F27A40005CB29B /* tkMacOSXNotify.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBE308F27A3B005CB29B /* tkMacOSXNotify.c */; };
-		F966BF0108F27A40005CB29B /* tkMacOSXRegion.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBEB08F27A3C005CB29B /* tkMacOSXRegion.c */; };
-		F966BF0308F27A40005CB29B /* tkMacOSXScrlbr.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBED08F27A3C005CB29B /* tkMacOSXScrlbr.c */; };
-		F966BF0408F27A40005CB29B /* tkMacOSXSend.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBEE08F27A3C005CB29B /* tkMacOSXSend.c */; };
-		F966BF0508F27A40005CB29B /* tkMacOSXSubwindows.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBEF08F27A3C005CB29B /* tkMacOSXSubwindows.c */; };
-		F966BF0608F27A40005CB29B /* tkMacOSXTest.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBF008F27A3C005CB29B /* tkMacOSXTest.c */; };
-		F966BF0708F27A40005CB29B /* tkMacOSXWindowEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBF108F27A3C005CB29B /* tkMacOSXWindowEvent.c */; };
-		F966BF0808F27A40005CB29B /* tkMacOSXWm.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBF208F27A3C005CB29B /* tkMacOSXWm.c */; };
-		F966BF0B08F27A40005CB29B /* tkMacOSXXStubs.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BBF508F27A3C005CB29B /* tkMacOSXXStubs.c */; };
-		F966BF7F08F27A41005CB29B /* tkAppInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC7508F27A3D005CB29B /* tkAppInit.c */; settings = {COMPILER_FLAGS = "-DTK_TEST"; }; };
-		F966BF8308F27A41005CB29B /* tkUnix3d.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC7908F27A3D005CB29B /* tkUnix3d.c */; };
-		F966BF9608F27A41005CB29B /* tkUnixScale.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8C08F27A3D005CB29B /* tkUnixScale.c */; };
-		F966C02A08F27A42005CB29B /* xcolors.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BD2408F27A3F005CB29B /* xcolors.c */; };
-		F966C02B08F27A42005CB29B /* xdraw.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BD2508F27A3F005CB29B /* xdraw.c */; };
-		F966C02C08F27A42005CB29B /* xgc.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BD2608F27A3F005CB29B /* xgc.c */; };
-		F966C02D08F27A42005CB29B /* ximage.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BD2708F27A3F005CB29B /* ximage.c */; };
-		F966C02E08F27A42005CB29B /* xutil.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BD2808F27A3F005CB29B /* xutil.c */; };
-		F966C07508F2820D005CB29B /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F966C07408F2820D005CB29B /* CoreFoundation.framework */; };
-		F966C07708F2821B005CB29B /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F966C07608F2821B005CB29B /* Carbon.framework */; };
-		F966C07908F28233005CB29B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F966C07808F28233005CB29B /* IOKit.framework */; };
-		F96888050AF786D5000797B5 /* ttkBlink.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E10AF786D5000797B5 /* ttkBlink.c */; };
-		F96888060AF786D5000797B5 /* ttkButton.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E20AF786D5000797B5 /* ttkButton.c */; };
-		F96888070AF786D5000797B5 /* ttkCache.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E30AF786D5000797B5 /* ttkCache.c */; };
-		F96888080AF786D5000797B5 /* ttkClamTheme.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E40AF786D5000797B5 /* ttkClamTheme.c */; };
-		F96888090AF786D5000797B5 /* ttkClassicTheme.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E50AF786D5000797B5 /* ttkClassicTheme.c */; };
-		F968880A0AF786D5000797B5 /* ttkDefaultTheme.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E70AF786D5000797B5 /* ttkDefaultTheme.c */; };
-		F968880B0AF786D5000797B5 /* ttkElements.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E80AF786D5000797B5 /* ttkElements.c */; };
-		F968880C0AF786D5000797B5 /* ttkEntry.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E90AF786D5000797B5 /* ttkEntry.c */; };
-		F968880D0AF786D5000797B5 /* ttkFrame.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887EA0AF786D5000797B5 /* ttkFrame.c */; };
-		F968880E0AF786D5000797B5 /* ttkImage.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887EB0AF786D5000797B5 /* ttkImage.c */; };
-		F968880F0AF786D5000797B5 /* ttkInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887EC0AF786D5000797B5 /* ttkInit.c */; };
-		F96888100AF786D5000797B5 /* ttkLabel.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887ED0AF786D5000797B5 /* ttkLabel.c */; };
-		F96888110AF786D5000797B5 /* ttkLayout.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887EE0AF786D5000797B5 /* ttkLayout.c */; };
-		F96888120AF786D5000797B5 /* ttkManager.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887EF0AF786D5000797B5 /* ttkManager.c */; };
-		F96888130AF786D5000797B5 /* ttkNotebook.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F10AF786D5000797B5 /* ttkNotebook.c */; };
-		F96888140AF786D5000797B5 /* ttkPanedwindow.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F20AF786D5000797B5 /* ttkPanedwindow.c */; };
-		F96888150AF786D5000797B5 /* ttkProgress.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F30AF786D5000797B5 /* ttkProgress.c */; };
-		F96888160AF786D5000797B5 /* ttkScale.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F40AF786D5000797B5 /* ttkScale.c */; };
-		F96888170AF786D5000797B5 /* ttkScroll.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F50AF786D5000797B5 /* ttkScroll.c */; };
-		F96888180AF786D5000797B5 /* ttkScrollbar.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F60AF786D5000797B5 /* ttkScrollbar.c */; };
-		F96888190AF786D5000797B5 /* ttkSeparator.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F70AF786D5000797B5 /* ttkSeparator.c */; };
-		F968881A0AF786D5000797B5 /* ttkSquare.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F80AF786D5000797B5 /* ttkSquare.c */; };
-		F968881B0AF786D5000797B5 /* ttkState.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F90AF786D5000797B5 /* ttkState.c */; };
-		F968881C0AF786D5000797B5 /* ttkStubInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887FA0AF786D5000797B5 /* ttkStubInit.c */; };
-		F968881D0AF786D5000797B5 /* ttkStubLib.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887FB0AF786D5000797B5 /* ttkStubLib.c */; };
-		F968881E0AF786D5000797B5 /* ttkTagSet.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887FC0AF786D5000797B5 /* ttkTagSet.c */; };
-		F968881F0AF786D5000797B5 /* ttkTheme.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887FD0AF786D5000797B5 /* ttkTheme.c */; };
-		F96888200AF786D5000797B5 /* ttkTrace.c in Sources */ = {isa = PBXBuildFile; fileRef = F96888000AF786D5000797B5 /* ttkTrace.c */; };
-		F96888210AF786D5000797B5 /* ttkTrack.c in Sources */ = {isa = PBXBuildFile; fileRef = F96888010AF786D5000797B5 /* ttkTrack.c */; };
-		F96888220AF786D5000797B5 /* ttkTreeview.c in Sources */ = {isa = PBXBuildFile; fileRef = F96888020AF786D5000797B5 /* ttkTreeview.c */; };
-		F96888230AF786D5000797B5 /* ttkWidget.c in Sources */ = {isa = PBXBuildFile; fileRef = F96888030AF786D5000797B5 /* ttkWidget.c */; };
-		F96888850AF78938000797B5 /* ttkMacOSXTheme.c in Sources */ = {isa = PBXBuildFile; fileRef = F96888840AF78938000797B5 /* ttkMacOSXTheme.c */; };
-		F96D456F08F272BB004A47F5 /* regcomp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3ED008F272A7004A47F5 /* regcomp.c */; };
-		F96D457208F272BB004A47F5 /* regerror.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3ED308F272A7004A47F5 /* regerror.c */; };
-		F96D457508F272BB004A47F5 /* regexec.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3ED608F272A7004A47F5 /* regexec.c */; };
-		F96D457608F272BB004A47F5 /* regfree.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3ED708F272A7004A47F5 /* regfree.c */; };
-		F96D457B08F272BB004A47F5 /* tclAlloc.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EDC08F272A7004A47F5 /* tclAlloc.c */; settings = {COMPILER_FLAGS = "-DUSE_TCLALLOC=0"; }; };
-		F96D457C08F272BB004A47F5 /* tclAsync.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EDD08F272A7004A47F5 /* tclAsync.c */; };
-		F96D457D08F272BB004A47F5 /* tclBasic.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EDE08F272A7004A47F5 /* tclBasic.c */; };
-		F96D457E08F272BC004A47F5 /* tclBinary.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EDF08F272A7004A47F5 /* tclBinary.c */; };
-		F96D457F08F272BC004A47F5 /* tclCkalloc.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE008F272A7004A47F5 /* tclCkalloc.c */; };
-		F96D458008F272BC004A47F5 /* tclClock.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE108F272A7004A47F5 /* tclClock.c */; };
-		F96D458108F272BC004A47F5 /* tclCmdAH.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE208F272A7004A47F5 /* tclCmdAH.c */; };
-		F96D458208F272BC004A47F5 /* tclCmdIL.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE308F272A7004A47F5 /* tclCmdIL.c */; };
-		F96D458308F272BC004A47F5 /* tclCmdMZ.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE408F272A7004A47F5 /* tclCmdMZ.c */; };
-		F96D458408F272BC004A47F5 /* tclCompCmds.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE508F272A7004A47F5 /* tclCompCmds.c */; };
-		F96D458508F272BC004A47F5 /* tclCompExpr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE608F272A7004A47F5 /* tclCompExpr.c */; };
-		F96D458608F272BC004A47F5 /* tclCompile.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE708F272A7004A47F5 /* tclCompile.c */; };
-		F96D458808F272BC004A47F5 /* tclConfig.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE908F272A7004A47F5 /* tclConfig.c */; };
-		F96D458908F272BC004A47F5 /* tclDate.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EEA08F272A7004A47F5 /* tclDate.c */; };
-		F96D458B08F272BC004A47F5 /* tclDictObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EEC08F272A7004A47F5 /* tclDictObj.c */; };
-		F96D458C08F272BC004A47F5 /* tclEncoding.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EED08F272A7004A47F5 /* tclEncoding.c */; };
-		F96D458D08F272BC004A47F5 /* tclEnv.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EEE08F272A7004A47F5 /* tclEnv.c */; };
-		F96D458E08F272BC004A47F5 /* tclEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EEF08F272A7004A47F5 /* tclEvent.c */; };
-		F96D458F08F272BC004A47F5 /* tclExecute.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF008F272A7004A47F5 /* tclExecute.c */; };
-		F96D459008F272BC004A47F5 /* tclFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF108F272A7004A47F5 /* tclFCmd.c */; };
-		F96D459108F272BC004A47F5 /* tclFileName.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF208F272A7004A47F5 /* tclFileName.c */; };
-		F96D459308F272BC004A47F5 /* tclGet.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF408F272A7004A47F5 /* tclGet.c */; };
-		F96D459508F272BC004A47F5 /* tclHash.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF608F272A7004A47F5 /* tclHash.c */; };
-		F96D459608F272BC004A47F5 /* tclHistory.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF708F272A7004A47F5 /* tclHistory.c */; };
-		F96D459708F272BC004A47F5 /* tclIndexObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF808F272A7004A47F5 /* tclIndexObj.c */; };
-		F96D459B08F272BC004A47F5 /* tclInterp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EFC08F272A7004A47F5 /* tclInterp.c */; };
-		F96D459D08F272BC004A47F5 /* tclIO.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EFE08F272A7004A47F5 /* tclIO.c */; };
-		F96D459F08F272BC004A47F5 /* tclIOCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0008F272A7004A47F5 /* tclIOCmd.c */; };
-		F96D45A008F272BC004A47F5 /* tclIOGT.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0108F272A7004A47F5 /* tclIOGT.c */; };
-		F96D45A108F272BC004A47F5 /* tclIORChan.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0208F272A7004A47F5 /* tclIORChan.c */; };
-		F96D45A208F272BC004A47F5 /* tclIOSock.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0308F272A7004A47F5 /* tclIOSock.c */; };
-		F96D45A308F272BC004A47F5 /* tclIOUtil.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0408F272A7004A47F5 /* tclIOUtil.c */; };
-		F96D45A408F272BC004A47F5 /* tclLink.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0508F272A7004A47F5 /* tclLink.c */; };
-		F96D45A508F272BC004A47F5 /* tclListObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0608F272A7004A47F5 /* tclListObj.c */; };
-		F96D45A608F272BC004A47F5 /* tclLiteral.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0708F272A7004A47F5 /* tclLiteral.c */; };
-		F96D45A708F272BC004A47F5 /* tclLoad.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0808F272A7004A47F5 /* tclLoad.c */; };
-		F96D45A908F272BC004A47F5 /* tclMain.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0A08F272A7004A47F5 /* tclMain.c */; };
-		F96D45AA08F272BC004A47F5 /* tclNamesp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0B08F272A7004A47F5 /* tclNamesp.c */; };
-		F96D45AB08F272BC004A47F5 /* tclNotify.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0C08F272A7004A47F5 /* tclNotify.c */; };
-		F96D45AC08F272BC004A47F5 /* tclObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0D08F272A7004A47F5 /* tclObj.c */; };
-		F96D45AD08F272BC004A47F5 /* tclPanic.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0E08F272A7004A47F5 /* tclPanic.c */; };
-		F96D45AE08F272BC004A47F5 /* tclParse.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0F08F272A7004A47F5 /* tclParse.c */; };
-		F96D45B008F272BC004A47F5 /* tclPathObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1108F272A7004A47F5 /* tclPathObj.c */; };
-		F96D45B108F272BC004A47F5 /* tclPipe.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1208F272A7004A47F5 /* tclPipe.c */; };
-		F96D45B208F272BC004A47F5 /* tclPkg.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1308F272A7004A47F5 /* tclPkg.c */; };
-		F96D45B308F272BC004A47F5 /* tclPkgConfig.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1408F272A7004A47F5 /* tclPkgConfig.c */; settings = {COMPILER_FLAGS = "-DCFG_INSTALL_LIBDIR=\\\"$(LIBDIR)\\\" -DCFG_INSTALL_BINDIR=\\\"$(BINDIR)\\\" -DCFG_INSTALL_SCRDIR=\\\"$(TCL_LIBRARY)\\\" -DCFG_INSTALL_INCDIR=\\\"$(INCLUDEDIR)\\\" -DCFG_INSTALL_DOCDIR=\\\"$(MANDIR)\\\" -DCFG_RUNTIME_LIBDIR=\\\"$(LIBDIR)\\\" -DCFG_RUNTIME_BINDIR=\\\"$(BINDIR)\\\" -DCFG_RUNTIME_SCRDIR=\\\"$(TCL_LIBRARY)\\\" -DCFG_RUNTIME_INCDIR=\\\"$(INCLUDEDIR)\\\" -DCFG_RUNTIME_DOCDIR=\\\"$(MANDIR)\\\""; }; };
-		F96D45B608F272BC004A47F5 /* tclPosixStr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1708F272A7004A47F5 /* tclPosixStr.c */; };
-		F96D45B708F272BC004A47F5 /* tclPreserve.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1808F272A7004A47F5 /* tclPreserve.c */; };
-		F96D45B808F272BC004A47F5 /* tclProc.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1908F272A7004A47F5 /* tclProc.c */; };
-		F96D45B908F272BC004A47F5 /* tclRegexp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1A08F272A7004A47F5 /* tclRegexp.c */; };
-		F96D45BB08F272BC004A47F5 /* tclResolve.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1C08F272A7004A47F5 /* tclResolve.c */; };
-		F96D45BC08F272BC004A47F5 /* tclResult.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1D08F272A7004A47F5 /* tclResult.c */; };
-		F96D45BD08F272BC004A47F5 /* tclScan.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1E08F272A7004A47F5 /* tclScan.c */; };
-		F96D45BE08F272BC004A47F5 /* tclStringObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1F08F272A7004A47F5 /* tclStringObj.c */; };
-		F96D45C308F272BC004A47F5 /* tclStrToD.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2408F272A7004A47F5 /* tclStrToD.c */; };
-		F96D45C408F272BC004A47F5 /* tclStubInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2508F272A7004A47F5 /* tclStubInit.c */; };
-		F96D45C508F272BC004A47F5 /* tclStubLib.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2608F272A7004A47F5 /* tclStubLib.c */; };
-		F96D45C908F272BC004A47F5 /* tclThread.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2A08F272A7004A47F5 /* tclThread.c */; };
-		F96D45CA08F272BC004A47F5 /* tclThreadAlloc.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2B08F272A7004A47F5 /* tclThreadAlloc.c */; };
-		F96D45CB08F272BC004A47F5 /* tclThreadJoin.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2C08F272A7004A47F5 /* tclThreadJoin.c */; };
-		F96D45CC08F272BC004A47F5 /* tclThreadStorage.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2D08F272A7004A47F5 /* tclThreadStorage.c */; };
-		F96D45CE08F272BC004A47F5 /* tclTimer.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2F08F272A7004A47F5 /* tclTimer.c */; };
-		F96D45D008F272BC004A47F5 /* tclTomMathInterface.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F3108F272A7004A47F5 /* tclTomMathInterface.c */; };
-		F96D45D108F272BC004A47F5 /* tclTrace.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F3208F272A7004A47F5 /* tclTrace.c */; };
-		F96D45D308F272BC004A47F5 /* tclUtf.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F3408F272A7004A47F5 /* tclUtf.c */; };
-		F96D45D408F272BC004A47F5 /* tclUtil.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F3508F272A7004A47F5 /* tclUtil.c */; };
-		F96D45D508F272BC004A47F5 /* tclVar.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F3608F272A7004A47F5 /* tclVar.c */; };
-		F96D48E208F272C3004A47F5 /* bn_fast_s_mp_mul_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426408F272B3004A47F5 /* bn_fast_s_mp_mul_digs.c */; };
-		F96D48E408F272C3004A47F5 /* bn_fast_s_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426608F272B3004A47F5 /* bn_fast_s_mp_sqr.c */; };
-		F96D48E708F272C3004A47F5 /* bn_mp_add.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426908F272B3004A47F5 /* bn_mp_add.c */; };
-		F96D48E808F272C3004A47F5 /* bn_mp_add_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426A08F272B3004A47F5 /* bn_mp_add_d.c */; };
-		F96D48EB08F272C3004A47F5 /* bn_mp_clamp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426D08F272B3004A47F5 /* bn_mp_clamp.c */; };
-		F96D48EC08F272C3004A47F5 /* bn_mp_clear.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426E08F272B3004A47F5 /* bn_mp_clear.c */; };
-		F96D48ED08F272C3004A47F5 /* bn_mp_clear_multi.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426F08F272B3004A47F5 /* bn_mp_clear_multi.c */; };
-		F96D48EE08F272C3004A47F5 /* bn_mp_cmp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427008F272B3004A47F5 /* bn_mp_cmp.c */; };
-		F96D48F008F272C3004A47F5 /* bn_mp_cmp_mag.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427208F272B3004A47F5 /* bn_mp_cmp_mag.c */; };
-		F96D48F208F272C3004A47F5 /* bn_mp_copy.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427408F272B3004A47F5 /* bn_mp_copy.c */; };
-		F96D48F308F272C3004A47F5 /* bn_mp_count_bits.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427508F272B3004A47F5 /* bn_mp_count_bits.c */; };
-		F96D48F408F272C3004A47F5 /* bn_mp_div.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427608F272B3004A47F5 /* bn_mp_div.c */; };
-		F96D48F508F272C3004A47F5 /* bn_mp_div_2.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427708F272B3004A47F5 /* bn_mp_div_2.c */; };
-		F96D48F608F272C3004A47F5 /* bn_mp_div_2d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427808F272B3004A47F5 /* bn_mp_div_2d.c */; };
-		F96D48F708F272C3004A47F5 /* bn_mp_div_3.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427908F272B3004A47F5 /* bn_mp_div_3.c */; };
-		F96D48F808F272C3004A47F5 /* bn_mp_div_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427A08F272B3004A47F5 /* bn_mp_div_d.c */; };
-		F96D48FC08F272C3004A47F5 /* bn_mp_exch.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427E08F272B3004A47F5 /* bn_mp_exch.c */; };
-		F96D490508F272C3004A47F5 /* bn_mp_grow.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D428708F272B3004A47F5 /* bn_mp_grow.c */; };
-		F96D490608F272C3004A47F5 /* bn_mp_init.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D428808F272B3004A47F5 /* bn_mp_init.c */; };
-		F96D490708F272C3004A47F5 /* bn_mp_init_copy.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D428908F272B3004A47F5 /* bn_mp_init_copy.c */; };
-		F96D490808F272C3004A47F5 /* bn_mp_init_multi.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D428A08F272B3004A47F5 /* bn_mp_init_multi.c */; };
-		F96D490908F272C3004A47F5 /* bn_mp_init_set.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D428B08F272B3004A47F5 /* bn_mp_init_set.c */; };
-		F96D490B08F272C3004A47F5 /* bn_mp_init_size.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D428D08F272B3004A47F5 /* bn_mp_init_size.c */; };
-		F96D491008F272C3004A47F5 /* bn_mp_karatsuba_mul.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429208F272B3004A47F5 /* bn_mp_karatsuba_mul.c */; };
-		F96D491108F272C3004A47F5 /* bn_mp_karatsuba_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429308F272B3004A47F5 /* bn_mp_karatsuba_sqr.c */; };
-		F96D491308F272C3004A47F5 /* bn_mp_lshd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429508F272B3004A47F5 /* bn_mp_lshd.c */; };
-		F96D491408F272C3004A47F5 /* bn_mp_mod.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429608F272B3004A47F5 /* bn_mp_mod.c */; };
-		F96D491508F272C3004A47F5 /* bn_mp_mod_2d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429708F272B3004A47F5 /* bn_mp_mod_2d.c */; };
-		F96D491A08F272C3004A47F5 /* bn_mp_mul.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429C08F272B3004A47F5 /* bn_mp_mul.c */; };
-		F96D491B08F272C3004A47F5 /* bn_mp_mul_2.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429D08F272B3004A47F5 /* bn_mp_mul_2.c */; };
-		F96D491C08F272C3004A47F5 /* bn_mp_mul_2d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429E08F272B3004A47F5 /* bn_mp_mul_2d.c */; };
-		F96D491D08F272C3004A47F5 /* bn_mp_mul_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429F08F272B3004A47F5 /* bn_mp_mul_d.c */; };
-		F96D492908F272C3004A47F5 /* bn_mp_radix_size.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42AB08F272B3004A47F5 /* bn_mp_radix_size.c */; };
-		F96D492A08F272C3004A47F5 /* bn_mp_radix_smap.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42AC08F272B3004A47F5 /* bn_mp_radix_smap.c */; };
-		F96D492C08F272C3004A47F5 /* bn_mp_read_radix.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42AE08F272B3004A47F5 /* bn_mp_read_radix.c */; };
-		F96D493708F272C3004A47F5 /* bn_mp_rshd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42B908F272B3004A47F5 /* bn_mp_rshd.c */; };
-		F96D493808F272C3004A47F5 /* bn_mp_set.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42BA08F272B3004A47F5 /* bn_mp_set.c */; };
-		F96D493C08F272C3004A47F5 /* bn_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42BE08F272B3004A47F5 /* bn_mp_sqr.c */; };
-		F96D493F08F272C3004A47F5 /* bn_mp_sub.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C108F272B3004A47F5 /* bn_mp_sub.c */; };
-		F96D494008F272C3004A47F5 /* bn_mp_sub_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C208F272B3004A47F5 /* bn_mp_sub_d.c */; };
-		F96D494608F272C3004A47F5 /* bn_mp_toom_mul.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C808F272B3004A47F5 /* bn_mp_toom_mul.c */; };
-		F96D494708F272C3004A47F5 /* bn_mp_toom_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C908F272B3004A47F5 /* bn_mp_toom_sqr.c */; };
-		F96D494908F272C3004A47F5 /* bn_mp_toradix_n.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42CB08F272B3004A47F5 /* bn_mp_toradix_n.c */; };
-		F96D494C08F272C3004A47F5 /* bn_mp_zero.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42CE08F272B3004A47F5 /* bn_mp_zero.c */; };
-		F96D494E08F272C3004A47F5 /* bn_reverse.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D008F272B3004A47F5 /* bn_reverse.c */; };
-		F96D494F08F272C3004A47F5 /* bn_s_mp_add.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D108F272B3004A47F5 /* bn_s_mp_add.c */; };
-		F96D495108F272C3004A47F5 /* bn_s_mp_mul_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D308F272B3004A47F5 /* bn_s_mp_mul_digs.c */; };
-		F96D495308F272C3004A47F5 /* bn_s_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D508F272B3004A47F5 /* bn_s_mp_sqr.c */; };
-		F96D495408F272C3004A47F5 /* bn_s_mp_sub.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D608F272B3004A47F5 /* bn_s_mp_sub.c */; };
-		F96D495508F272C3004A47F5 /* bncore.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D708F272B3004A47F5 /* bncore.c */; };
-		F96D49A908F272C4004A47F5 /* tclMacOSXBundle.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433908F272B5004A47F5 /* tclMacOSXBundle.c */; };
-		F96D49AD08F272C4004A47F5 /* tclMacOSXFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433D08F272B5004A47F5 /* tclMacOSXFCmd.c */; };
-		F96D49AE08F272C4004A47F5 /* tclMacOSXNotify.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433E08F272B5004A47F5 /* tclMacOSXNotify.c */; };
-		F96D4AC608F272C9004A47F5 /* tclLoadDyld.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445B08F272B9004A47F5 /* tclLoadDyld.c */; settings = {COMPILER_FLAGS = "-Wno-deprecated-declarations"; }; };
-		F96D4ACA08F272C9004A47F5 /* tclUnixChan.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445F08F272B9004A47F5 /* tclUnixChan.c */; };
-		F96D4ACB08F272C9004A47F5 /* tclUnixEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446008F272B9004A47F5 /* tclUnixEvent.c */; };
-		F96D4ACC08F272C9004A47F5 /* tclUnixFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446108F272B9004A47F5 /* tclUnixFCmd.c */; };
-		F96D4ACD08F272C9004A47F5 /* tclUnixFile.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446208F272B9004A47F5 /* tclUnixFile.c */; };
-		F96D4ACE08F272C9004A47F5 /* tclUnixInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446308F272B9004A47F5 /* tclUnixInit.c */; settings = {COMPILER_FLAGS = "-DTCL_LIBRARY=\\\"$(TCL_LIBRARY)\\\" -DTCL_PACKAGE_PATH=\\\"$(TCL_PACKAGE_PATH)\\\""; }; };
-		F96D4ACF08F272C9004A47F5 /* tclUnixNotfy.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446408F272B9004A47F5 /* tclUnixNotfy.c */; };
-		F96D4AD008F272C9004A47F5 /* tclUnixPipe.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446508F272B9004A47F5 /* tclUnixPipe.c */; };
-		F96D4AD208F272CA004A47F5 /* tclUnixSock.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446708F272B9004A47F5 /* tclUnixSock.c */; };
-		F96D4AD408F272CA004A47F5 /* tclUnixThrd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446908F272B9004A47F5 /* tclUnixThrd.c */; };
-		F96D4AD608F272CA004A47F5 /* tclUnixTime.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446B08F272B9004A47F5 /* tclUnixTime.c */; };
-		F9C9CC000E84059800E00935 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F9C9CBFF0E84059800E00935 /* ApplicationServices.framework */; };
-		F9DD99BD0F07DF850018B2E4 /* tkImgPNG.c in Sources */ = {isa = PBXBuildFile; fileRef = F9DD99BC0F07DF850018B2E4 /* tkImgPNG.c */; };
-		F9DD99BE0F07DF850018B2E4 /* tkImgPNG.c in Sources */ = {isa = PBXBuildFile; fileRef = F9DD99BC0F07DF850018B2E4 /* tkImgPNG.c */; };
-		F9E61D28090A481F002B3151 /* bn_mp_cmp_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427108F272B3004A47F5 /* bn_mp_cmp_d.c */; };
-		F9E61D29090A486C002B3151 /* bn_mp_neg.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42A208F272B3004A47F5 /* bn_mp_neg.c */; };
-		F9E61D2A090A4891002B3151 /* bn_mp_sqrt.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C008F272B3004A47F5 /* bn_mp_sqrt.c */; };
-		F9E61D2B090A48A4002B3151 /* bn_mp_and.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426C08F272B3004A47F5 /* bn_mp_and.c */; };
-		F9E61D2C090A48AC002B3151 /* bn_mp_expt_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427F08F272B3004A47F5 /* bn_mp_expt_d.c */; };
-		F9E61D2D090A48BB002B3151 /* bn_mp_xor.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42CD08F272B3004A47F5 /* bn_mp_xor.c */; };
-		F9E61D2E090A48BF002B3151 /* bn_mp_or.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42A308F272B3004A47F5 /* bn_mp_or.c */; };
-		F9E61D2F090A48C7002B3151 /* bn_mp_shrink.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42BC08F272B3004A47F5 /* bn_mp_shrink.c */; };
-		F9E61D30090A48E2002B3151 /* bn_mp_to_unsigned_bin_n.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C708F272B3004A47F5 /* bn_mp_to_unsigned_bin_n.c */; };
-		F9E61D31090A48F9002B3151 /* bn_mp_to_unsigned_bin.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C608F272B3004A47F5 /* bn_mp_to_unsigned_bin.c */; };
-		F9E61D32090A48FA002B3151 /* bn_mp_unsigned_bin_size.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42CC08F272B3004A47F5 /* bn_mp_unsigned_bin_size.c */; };
-		F9F4415E0C8BAE6F00BCCD67 /* tclDTrace.d in Sources */ = {isa = PBXBuildFile; fileRef = F9F4415D0C8BAE6F00BCCD67 /* tclDTrace.d */; };
-		F9FC77B80AB29E9100B7077D /* tclUnixCompat.c in Sources */ = {isa = PBXBuildFile; fileRef = F9FC77B70AB29E9100B7077D /* tclUnixCompat.c */; };
-		F9FD30BC0CC1AD070073837D /* regcomp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3ED008F272A7004A47F5 /* regcomp.c */; };
-		F9FD30BD0CC1AD070073837D /* regerror.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3ED308F272A7004A47F5 /* regerror.c */; };
-		F9FD30BE0CC1AD070073837D /* regexec.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3ED608F272A7004A47F5 /* regexec.c */; };
-		F9FD30BF0CC1AD070073837D /* regfree.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3ED708F272A7004A47F5 /* regfree.c */; };
-		F9FD30C00CC1AD070073837D /* tclAlloc.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EDC08F272A7004A47F5 /* tclAlloc.c */; settings = {COMPILER_FLAGS = "-DUSE_TCLALLOC=0"; }; };
-		F9FD30C10CC1AD070073837D /* tclAsync.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EDD08F272A7004A47F5 /* tclAsync.c */; };
-		F9FD30C20CC1AD070073837D /* tclBasic.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EDE08F272A7004A47F5 /* tclBasic.c */; };
-		F9FD30C30CC1AD070073837D /* tclBinary.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EDF08F272A7004A47F5 /* tclBinary.c */; };
-		F9FD30C40CC1AD070073837D /* tclCkalloc.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE008F272A7004A47F5 /* tclCkalloc.c */; };
-		F9FD30C50CC1AD070073837D /* tclClock.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE108F272A7004A47F5 /* tclClock.c */; };
-		F9FD30C60CC1AD070073837D /* tclCmdAH.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE208F272A7004A47F5 /* tclCmdAH.c */; };
-		F9FD30C70CC1AD070073837D /* tclCmdIL.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE308F272A7004A47F5 /* tclCmdIL.c */; };
-		F9FD30C80CC1AD070073837D /* tclCmdMZ.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE408F272A7004A47F5 /* tclCmdMZ.c */; };
-		F9FD30C90CC1AD070073837D /* tclCompCmds.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE508F272A7004A47F5 /* tclCompCmds.c */; };
-		F9FD30CA0CC1AD070073837D /* tclCompExpr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE608F272A7004A47F5 /* tclCompExpr.c */; };
-		F9FD30CB0CC1AD070073837D /* tclCompile.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE708F272A7004A47F5 /* tclCompile.c */; };
-		F9FD30CC0CC1AD070073837D /* tclConfig.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EE908F272A7004A47F5 /* tclConfig.c */; };
-		F9FD30CD0CC1AD070073837D /* tclDate.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EEA08F272A7004A47F5 /* tclDate.c */; };
-		F9FD30CE0CC1AD070073837D /* tclDictObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EEC08F272A7004A47F5 /* tclDictObj.c */; };
-		F9FD30CF0CC1AD070073837D /* tclEncoding.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EED08F272A7004A47F5 /* tclEncoding.c */; };
-		F9FD30D00CC1AD070073837D /* tclEnv.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EEE08F272A7004A47F5 /* tclEnv.c */; };
-		F9FD30D10CC1AD070073837D /* tclEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EEF08F272A7004A47F5 /* tclEvent.c */; };
-		F9FD30D20CC1AD070073837D /* tclExecute.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF008F272A7004A47F5 /* tclExecute.c */; };
-		F9FD30D30CC1AD070073837D /* tclFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF108F272A7004A47F5 /* tclFCmd.c */; };
-		F9FD30D40CC1AD070073837D /* tclFileName.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF208F272A7004A47F5 /* tclFileName.c */; };
-		F9FD30D50CC1AD070073837D /* tclGet.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF408F272A7004A47F5 /* tclGet.c */; };
-		F9FD30D60CC1AD070073837D /* tclHash.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF608F272A7004A47F5 /* tclHash.c */; };
-		F9FD30D70CC1AD070073837D /* tclHistory.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF708F272A7004A47F5 /* tclHistory.c */; };
-		F9FD30D80CC1AD070073837D /* tclIndexObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EF808F272A7004A47F5 /* tclIndexObj.c */; };
-		F9FD30D90CC1AD070073837D /* tclInterp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EFC08F272A7004A47F5 /* tclInterp.c */; };
-		F9FD30DA0CC1AD070073837D /* tclIO.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3EFE08F272A7004A47F5 /* tclIO.c */; };
-		F9FD30DB0CC1AD070073837D /* tclIOCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0008F272A7004A47F5 /* tclIOCmd.c */; };
-		F9FD30DC0CC1AD070073837D /* tclIOGT.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0108F272A7004A47F5 /* tclIOGT.c */; };
-		F9FD30DD0CC1AD070073837D /* tclIORChan.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0208F272A7004A47F5 /* tclIORChan.c */; };
-		F9FD30DE0CC1AD070073837D /* tclIOSock.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0308F272A7004A47F5 /* tclIOSock.c */; };
-		F9FD30DF0CC1AD070073837D /* tclIOUtil.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0408F272A7004A47F5 /* tclIOUtil.c */; };
-		F9FD30E00CC1AD070073837D /* tclLink.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0508F272A7004A47F5 /* tclLink.c */; };
-		F9FD30E10CC1AD070073837D /* tclListObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0608F272A7004A47F5 /* tclListObj.c */; };
-		F9FD30E20CC1AD070073837D /* tclLiteral.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0708F272A7004A47F5 /* tclLiteral.c */; };
-		F9FD30E30CC1AD070073837D /* tclLoad.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0808F272A7004A47F5 /* tclLoad.c */; };
-		F9FD30E40CC1AD070073837D /* tclMain.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0A08F272A7004A47F5 /* tclMain.c */; };
-		F9FD30E50CC1AD070073837D /* tclNamesp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0B08F272A7004A47F5 /* tclNamesp.c */; };
-		F9FD30E60CC1AD070073837D /* tclNotify.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0C08F272A7004A47F5 /* tclNotify.c */; };
-		F9FD30E70CC1AD070073837D /* tclObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0D08F272A7004A47F5 /* tclObj.c */; };
-		F9FD30E80CC1AD070073837D /* tclPanic.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0E08F272A7004A47F5 /* tclPanic.c */; };
-		F9FD30E90CC1AD070073837D /* tclParse.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F0F08F272A7004A47F5 /* tclParse.c */; };
-		F9FD30EA0CC1AD070073837D /* tclPathObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1108F272A7004A47F5 /* tclPathObj.c */; };
-		F9FD30EB0CC1AD070073837D /* tclPipe.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1208F272A7004A47F5 /* tclPipe.c */; };
-		F9FD30EC0CC1AD070073837D /* tclPkg.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1308F272A7004A47F5 /* tclPkg.c */; };
-		F9FD30ED0CC1AD070073837D /* tclPkgConfig.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1408F272A7004A47F5 /* tclPkgConfig.c */; settings = {COMPILER_FLAGS = "-DCFG_INSTALL_LIBDIR=\\\"$(LIBDIR)\\\" -DCFG_INSTALL_BINDIR=\\\"$(BINDIR)\\\" -DCFG_INSTALL_SCRDIR=\\\"$(TCL_LIBRARY)\\\" -DCFG_INSTALL_INCDIR=\\\"$(INCLUDEDIR)\\\" -DCFG_INSTALL_DOCDIR=\\\"$(MANDIR)\\\" -DCFG_RUNTIME_LIBDIR=\\\"$(LIBDIR)\\\" -DCFG_RUNTIME_BINDIR=\\\"$(BINDIR)\\\" -DCFG_RUNTIME_SCRDIR=\\\"$(TCL_LIBRARY)\\\" -DCFG_RUNTIME_INCDIR=\\\"$(INCLUDEDIR)\\\" -DCFG_RUNTIME_DOCDIR=\\\"$(MANDIR)\\\""; }; };
-		F9FD30EE0CC1AD070073837D /* tclPosixStr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1708F272A7004A47F5 /* tclPosixStr.c */; };
-		F9FD30EF0CC1AD070073837D /* tclPreserve.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1808F272A7004A47F5 /* tclPreserve.c */; };
-		F9FD30F00CC1AD070073837D /* tclProc.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1908F272A7004A47F5 /* tclProc.c */; };
-		F9FD30F10CC1AD070073837D /* tclRegexp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1A08F272A7004A47F5 /* tclRegexp.c */; };
-		F9FD30F20CC1AD070073837D /* tclResolve.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1C08F272A7004A47F5 /* tclResolve.c */; };
-		F9FD30F30CC1AD070073837D /* tclResult.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1D08F272A7004A47F5 /* tclResult.c */; };
-		F9FD30F40CC1AD070073837D /* tclScan.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1E08F272A7004A47F5 /* tclScan.c */; };
-		F9FD30F50CC1AD070073837D /* tclStringObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F1F08F272A7004A47F5 /* tclStringObj.c */; };
-		F9FD30F60CC1AD070073837D /* tclStrToD.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2408F272A7004A47F5 /* tclStrToD.c */; };
-		F9FD30F70CC1AD070073837D /* tclStubInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2508F272A7004A47F5 /* tclStubInit.c */; };
-		F9FD30F80CC1AD070073837D /* tclStubLib.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2608F272A7004A47F5 /* tclStubLib.c */; };
-		F9FD30F90CC1AD070073837D /* tclThread.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2A08F272A7004A47F5 /* tclThread.c */; };
-		F9FD30FA0CC1AD070073837D /* tclThreadAlloc.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2B08F272A7004A47F5 /* tclThreadAlloc.c */; };
-		F9FD30FB0CC1AD070073837D /* tclThreadJoin.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2C08F272A7004A47F5 /* tclThreadJoin.c */; };
-		F9FD30FC0CC1AD070073837D /* tclThreadStorage.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2D08F272A7004A47F5 /* tclThreadStorage.c */; };
-		F9FD30FD0CC1AD070073837D /* tclTimer.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F2F08F272A7004A47F5 /* tclTimer.c */; };
-		F9FD30FE0CC1AD070073837D /* tclTomMathInterface.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F3108F272A7004A47F5 /* tclTomMathInterface.c */; };
-		F9FD30FF0CC1AD070073837D /* tclTrace.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F3208F272A7004A47F5 /* tclTrace.c */; };
-		F9FD31000CC1AD070073837D /* tclUtf.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F3408F272A7004A47F5 /* tclUtf.c */; };
-		F9FD31010CC1AD070073837D /* tclUtil.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F3508F272A7004A47F5 /* tclUtil.c */; };
-		F9FD31020CC1AD070073837D /* tclVar.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D3F3608F272A7004A47F5 /* tclVar.c */; };
-		F9FD31030CC1AD070073837D /* bn_fast_s_mp_mul_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426408F272B3004A47F5 /* bn_fast_s_mp_mul_digs.c */; };
-		F9FD31040CC1AD070073837D /* bn_fast_s_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426608F272B3004A47F5 /* bn_fast_s_mp_sqr.c */; };
-		F9FD31050CC1AD070073837D /* bn_mp_add.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426908F272B3004A47F5 /* bn_mp_add.c */; };
-		F9FD31060CC1AD070073837D /* bn_mp_add_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426A08F272B3004A47F5 /* bn_mp_add_d.c */; };
-		F9FD31070CC1AD070073837D /* bn_mp_and.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426C08F272B3004A47F5 /* bn_mp_and.c */; };
-		F9FD31080CC1AD070073837D /* bn_mp_clamp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426D08F272B3004A47F5 /* bn_mp_clamp.c */; };
-		F9FD31090CC1AD070073837D /* bn_mp_clear.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426E08F272B3004A47F5 /* bn_mp_clear.c */; };
-		F9FD310A0CC1AD070073837D /* bn_mp_clear_multi.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D426F08F272B3004A47F5 /* bn_mp_clear_multi.c */; };
-		F9FD310B0CC1AD070073837D /* bn_mp_cmp.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427008F272B3004A47F5 /* bn_mp_cmp.c */; };
-		F9FD310C0CC1AD070073837D /* bn_mp_cmp_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427108F272B3004A47F5 /* bn_mp_cmp_d.c */; };
-		F9FD310D0CC1AD070073837D /* bn_mp_cmp_mag.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427208F272B3004A47F5 /* bn_mp_cmp_mag.c */; };
-		F9FD310E0CC1AD070073837D /* bn_mp_copy.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427408F272B3004A47F5 /* bn_mp_copy.c */; };
-		F9FD310F0CC1AD070073837D /* bn_mp_count_bits.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427508F272B3004A47F5 /* bn_mp_count_bits.c */; };
-		F9FD31100CC1AD070073837D /* bn_mp_div.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427608F272B3004A47F5 /* bn_mp_div.c */; };
-		F9FD31110CC1AD070073837D /* bn_mp_div_2.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427708F272B3004A47F5 /* bn_mp_div_2.c */; };
-		F9FD31120CC1AD070073837D /* bn_mp_div_2d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427808F272B3004A47F5 /* bn_mp_div_2d.c */; };
-		F9FD31130CC1AD070073837D /* bn_mp_div_3.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427908F272B3004A47F5 /* bn_mp_div_3.c */; };
-		F9FD31140CC1AD070073837D /* bn_mp_div_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427A08F272B3004A47F5 /* bn_mp_div_d.c */; };
-		F9FD31150CC1AD070073837D /* bn_mp_exch.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427E08F272B3004A47F5 /* bn_mp_exch.c */; };
-		F9FD31160CC1AD070073837D /* bn_mp_expt_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D427F08F272B3004A47F5 /* bn_mp_expt_d.c */; };
-		F9FD31170CC1AD070073837D /* bn_mp_grow.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D428708F272B3004A47F5 /* bn_mp_grow.c */; };
-		F9FD31180CC1AD070073837D /* bn_mp_init.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D428808F272B3004A47F5 /* bn_mp_init.c */; };
-		F9FD31190CC1AD070073837D /* bn_mp_init_copy.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D428908F272B3004A47F5 /* bn_mp_init_copy.c */; };
-		F9FD311A0CC1AD070073837D /* bn_mp_init_multi.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D428A08F272B3004A47F5 /* bn_mp_init_multi.c */; };
-		F9FD311B0CC1AD070073837D /* bn_mp_init_set.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D428B08F272B3004A47F5 /* bn_mp_init_set.c */; };
-		F9FD311C0CC1AD070073837D /* bn_mp_init_size.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D428D08F272B3004A47F5 /* bn_mp_init_size.c */; };
-		F9FD311D0CC1AD070073837D /* bn_mp_karatsuba_mul.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429208F272B3004A47F5 /* bn_mp_karatsuba_mul.c */; };
-		F9FD311E0CC1AD070073837D /* bn_mp_karatsuba_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429308F272B3004A47F5 /* bn_mp_karatsuba_sqr.c */; };
-		F9FD311F0CC1AD070073837D /* bn_mp_lshd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429508F272B3004A47F5 /* bn_mp_lshd.c */; };
-		F9FD31200CC1AD070073837D /* bn_mp_mod.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429608F272B3004A47F5 /* bn_mp_mod.c */; };
-		F9FD31210CC1AD070073837D /* bn_mp_mod_2d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429708F272B3004A47F5 /* bn_mp_mod_2d.c */; };
-		F9FD31220CC1AD070073837D /* bn_mp_mul.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429C08F272B3004A47F5 /* bn_mp_mul.c */; };
-		F9FD31230CC1AD070073837D /* bn_mp_mul_2.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429D08F272B3004A47F5 /* bn_mp_mul_2.c */; };
-		F9FD31240CC1AD070073837D /* bn_mp_mul_2d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429E08F272B3004A47F5 /* bn_mp_mul_2d.c */; };
-		F9FD31250CC1AD070073837D /* bn_mp_mul_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D429F08F272B3004A47F5 /* bn_mp_mul_d.c */; };
-		F9FD31260CC1AD070073837D /* bn_mp_neg.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42A208F272B3004A47F5 /* bn_mp_neg.c */; };
-		F9FD31270CC1AD070073837D /* bn_mp_or.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42A308F272B3004A47F5 /* bn_mp_or.c */; };
-		F9FD31280CC1AD070073837D /* bn_mp_radix_size.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42AB08F272B3004A47F5 /* bn_mp_radix_size.c */; };
-		F9FD31290CC1AD070073837D /* bn_mp_radix_smap.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42AC08F272B3004A47F5 /* bn_mp_radix_smap.c */; };
-		F9FD312A0CC1AD070073837D /* bn_mp_read_radix.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42AE08F272B3004A47F5 /* bn_mp_read_radix.c */; };
-		F9FD312B0CC1AD070073837D /* bn_mp_rshd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42B908F272B3004A47F5 /* bn_mp_rshd.c */; };
-		F9FD312C0CC1AD070073837D /* bn_mp_set.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42BA08F272B3004A47F5 /* bn_mp_set.c */; };
-		F9FD312D0CC1AD070073837D /* bn_mp_shrink.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42BC08F272B3004A47F5 /* bn_mp_shrink.c */; };
-		F9FD312E0CC1AD070073837D /* bn_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42BE08F272B3004A47F5 /* bn_mp_sqr.c */; };
-		F9FD312F0CC1AD070073837D /* bn_mp_sqrt.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C008F272B3004A47F5 /* bn_mp_sqrt.c */; };
-		F9FD31300CC1AD070073837D /* bn_mp_sub.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C108F272B3004A47F5 /* bn_mp_sub.c */; };
-		F9FD31310CC1AD070073837D /* bn_mp_sub_d.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C208F272B3004A47F5 /* bn_mp_sub_d.c */; };
-		F9FD31320CC1AD070073837D /* bn_mp_to_unsigned_bin_n.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C708F272B3004A47F5 /* bn_mp_to_unsigned_bin_n.c */; };
-		F9FD31330CC1AD070073837D /* bn_mp_to_unsigned_bin.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C608F272B3004A47F5 /* bn_mp_to_unsigned_bin.c */; };
-		F9FD31340CC1AD070073837D /* bn_mp_toom_mul.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C808F272B3004A47F5 /* bn_mp_toom_mul.c */; };
-		F9FD31350CC1AD070073837D /* bn_mp_toom_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42C908F272B3004A47F5 /* bn_mp_toom_sqr.c */; };
-		F9FD31360CC1AD070073837D /* bn_mp_toradix_n.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42CB08F272B3004A47F5 /* bn_mp_toradix_n.c */; };
-		F9FD31370CC1AD070073837D /* bn_mp_unsigned_bin_size.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42CC08F272B3004A47F5 /* bn_mp_unsigned_bin_size.c */; };
-		F9FD31380CC1AD070073837D /* bn_mp_xor.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42CD08F272B3004A47F5 /* bn_mp_xor.c */; };
-		F9FD31390CC1AD070073837D /* bn_mp_zero.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42CE08F272B3004A47F5 /* bn_mp_zero.c */; };
-		F9FD313A0CC1AD070073837D /* bn_reverse.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D008F272B3004A47F5 /* bn_reverse.c */; };
-		F9FD313B0CC1AD070073837D /* bn_s_mp_add.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D108F272B3004A47F5 /* bn_s_mp_add.c */; };
-		F9FD313C0CC1AD070073837D /* bn_s_mp_mul_digs.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D308F272B3004A47F5 /* bn_s_mp_mul_digs.c */; };
-		F9FD313D0CC1AD070073837D /* bn_s_mp_sqr.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D508F272B3004A47F5 /* bn_s_mp_sqr.c */; };
-		F9FD313E0CC1AD070073837D /* bn_s_mp_sub.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D608F272B3004A47F5 /* bn_s_mp_sub.c */; };
-		F9FD313F0CC1AD070073837D /* bncore.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D42D708F272B3004A47F5 /* bncore.c */; };
-		F9FD31400CC1AD070073837D /* tclMacOSXBundle.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433908F272B5004A47F5 /* tclMacOSXBundle.c */; };
-		F9FD31410CC1AD070073837D /* tclMacOSXFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433D08F272B5004A47F5 /* tclMacOSXFCmd.c */; };
-		F9FD31420CC1AD070073837D /* tclMacOSXNotify.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D433E08F272B5004A47F5 /* tclMacOSXNotify.c */; };
-		F9FD31430CC1AD070073837D /* tclLoadDyld.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445B08F272B9004A47F5 /* tclLoadDyld.c */; settings = {COMPILER_FLAGS = "-Wno-deprecated-declarations"; }; };
-		F9FD31440CC1AD070073837D /* tclUnixChan.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D445F08F272B9004A47F5 /* tclUnixChan.c */; };
-		F9FD31450CC1AD070073837D /* tclUnixCompat.c in Sources */ = {isa = PBXBuildFile; fileRef = F9FC77B70AB29E9100B7077D /* tclUnixCompat.c */; };
-		F9FD31460CC1AD070073837D /* tclUnixEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446008F272B9004A47F5 /* tclUnixEvent.c */; };
-		F9FD31470CC1AD070073837D /* tclUnixFCmd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446108F272B9004A47F5 /* tclUnixFCmd.c */; };
-		F9FD31480CC1AD070073837D /* tclUnixFile.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446208F272B9004A47F5 /* tclUnixFile.c */; };
-		F9FD31490CC1AD070073837D /* tclUnixInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446308F272B9004A47F5 /* tclUnixInit.c */; settings = {COMPILER_FLAGS = "-DTCL_LIBRARY=\\\"$(TCL_LIBRARY)\\\" -DTCL_PACKAGE_PATH=\\\"$(TCL_PACKAGE_PATH)\\\""; }; };
-		F9FD314A0CC1AD070073837D /* tclUnixNotfy.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446408F272B9004A47F5 /* tclUnixNotfy.c */; };
-		F9FD314B0CC1AD070073837D /* tclUnixPipe.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446508F272B9004A47F5 /* tclUnixPipe.c */; };
-		F9FD314C0CC1AD070073837D /* tclUnixSock.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446708F272B9004A47F5 /* tclUnixSock.c */; };
-		F9FD314D0CC1AD070073837D /* tclUnixThrd.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446908F272B9004A47F5 /* tclUnixThrd.c */; };
-		F9FD314E0CC1AD070073837D /* tclUnixTime.c in Sources */ = {isa = PBXBuildFile; fileRef = F96D446B08F272B9004A47F5 /* tclUnixTime.c */; };
-		F9FD314F0CC1AD070073837D /* tk3d.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAAC08F27A39005CB29B /* tk3d.c */; };
-		F9FD31500CC1AD070073837D /* tkArgv.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAAE08F27A39005CB29B /* tkArgv.c */; };
-		F9FD31510CC1AD070073837D /* tkAtom.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAAF08F27A39005CB29B /* tkAtom.c */; };
-		F9FD31520CC1AD070073837D /* tkBind.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB008F27A39005CB29B /* tkBind.c */; };
-		F9FD31530CC1AD070073837D /* tkBitmap.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB108F27A39005CB29B /* tkBitmap.c */; };
-		F9FD31540CC1AD070073837D /* tkButton.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB208F27A39005CB29B /* tkButton.c */; };
-		F9FD31550CC1AD070073837D /* tkCanvArc.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB408F27A39005CB29B /* tkCanvArc.c */; };
-		F9FD31560CC1AD070073837D /* tkCanvas.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB508F27A39005CB29B /* tkCanvas.c */; };
-		F9FD31570CC1AD070073837D /* tkCanvBmap.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB708F27A39005CB29B /* tkCanvBmap.c */; };
-		F9FD31580CC1AD070073837D /* tkCanvImg.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB808F27A39005CB29B /* tkCanvImg.c */; };
-		F9FD31590CC1AD070073837D /* tkCanvLine.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAB908F27A39005CB29B /* tkCanvLine.c */; };
-		F9FD315A0CC1AD070073837D /* tkCanvPoly.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BABA08F27A39005CB29B /* tkCanvPoly.c */; };
-		F9FD315B0CC1AD070073837D /* tkCanvPs.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BABB08F27A39005CB29B /* tkCanvPs.c */; };
-		F9FD315C0CC1AD070073837D /* tkCanvText.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BABD08F27A39005CB29B /* tkCanvText.c */; };
-		F9FD315D0CC1AD070073837D /* tkCanvUtil.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BABE08F27A39005CB29B /* tkCanvUtil.c */; };
-		F9FD315E0CC1AD070073837D /* tkCanvWind.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BABF08F27A39005CB29B /* tkCanvWind.c */; };
-		F9FD315F0CC1AD070073837D /* tkClipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC008F27A39005CB29B /* tkClipboard.c */; };
-		F9FD31600CC1AD070073837D /* tkCmds.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC108F27A39005CB29B /* tkCmds.c */; };
-		F9FD31610CC1AD070073837D /* tkColor.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC208F27A39005CB29B /* tkColor.c */; };
-		F9FD31620CC1AD070073837D /* tkConfig.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC408F27A39005CB29B /* tkConfig.c */; };
-		F9FD31630CC1AD070073837D /* tkConsole.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC508F27A39005CB29B /* tkConsole.c */; };
-		F9FD31640CC1AD070073837D /* tkCursor.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC608F27A39005CB29B /* tkCursor.c */; };
-		F9FD31650CC1AD070073837D /* tkEntry.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAC808F27A39005CB29B /* tkEntry.c */; };
-		F9FD31660CC1AD070073837D /* tkError.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BACA08F27A39005CB29B /* tkError.c */; };
-		F9FD31670CC1AD070073837D /* tkEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BACB08F27A39005CB29B /* tkEvent.c */; };
-		F9FD31680CC1AD070073837D /* tkFileFilter.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BACC08F27A39005CB29B /* tkFileFilter.c */; };
-		F9FD31690CC1AD070073837D /* tkFocus.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BACE08F27A39005CB29B /* tkFocus.c */; };
-		F9FD316A0CC1AD070073837D /* tkFont.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BACF08F27A39005CB29B /* tkFont.c */; };
-		F9FD316B0CC1AD070073837D /* tkFrame.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD108F27A39005CB29B /* tkFrame.c */; };
-		F9FD316C0CC1AD070073837D /* tkGC.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD208F27A39005CB29B /* tkGC.c */; };
-		F9FD316D0CC1AD070073837D /* tkGeometry.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD308F27A39005CB29B /* tkGeometry.c */; };
-		F9FD316E0CC1AD070073837D /* tkGet.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD408F27A39005CB29B /* tkGet.c */; };
-		F9FD316F0CC1AD070073837D /* tkGrab.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD508F27A39005CB29B /* tkGrab.c */; };
-		F9FD31700CC1AD070073837D /* tkGrid.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD608F27A39005CB29B /* tkGrid.c */; };
-		F9FD31710CC1AD070073837D /* tkImage.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD708F27A39005CB29B /* tkImage.c */; };
-		F9FD31720CC1AD070073837D /* tkImgBmap.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD808F27A39005CB29B /* tkImgBmap.c */; };
-		F9FD31730CC1AD070073837D /* tkImgGIF.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAD908F27A39005CB29B /* tkImgGIF.c */; };
-		F9FD31740CC1AD070073837D /* tkImgPhoto.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BADA08F27A39005CB29B /* tkImgPhoto.c */; };
-		F9FD31750CC1AD070073837D /* tkImgPPM.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BADB08F27A39005CB29B /* tkImgPPM.c */; };
-		F9FD31760CC1AD070073837D /* tkListbox.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAE408F27A39005CB29B /* tkListbox.c */; };
-		F9FD31770CC1AD070073837D /* tkMacWinMenu.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAE508F27A39005CB29B /* tkMacWinMenu.c */; };
-		F9FD31780CC1AD070073837D /* tkMain.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAE608F27A39005CB29B /* tkMain.c */; };
-		F9FD31790CC1AD070073837D /* tkMenu.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAE708F27A39005CB29B /* tkMenu.c */; };
-		F9FD317A0CC1AD070073837D /* tkMenubutton.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAE908F27A39005CB29B /* tkMenubutton.c */; };
-		F9FD317B0CC1AD070073837D /* tkMenuDraw.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAEB08F27A39005CB29B /* tkMenuDraw.c */; };
-		F9FD317C0CC1AD070073837D /* tkMessage.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAEC08F27A39005CB29B /* tkMessage.c */; };
-		F9FD317D0CC1AD070073837D /* tkObj.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAED08F27A39005CB29B /* tkObj.c */; };
-		F9FD317E0CC1AD070073837D /* tkOldConfig.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAEE08F27A39005CB29B /* tkOldConfig.c */; };
-		F9FD317F0CC1AD070073837D /* tkOldTest.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAFE08F27A39005CB29B /* tkOldTest.c */; };
-		F9FD31800CC1AD070073837D /* tkOption.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAEF08F27A39005CB29B /* tkOption.c */; };
-		F9FD31810CC1AD070073837D /* tkPack.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAF008F27A39005CB29B /* tkPack.c */; };
-		F9FD31820CC1AD070073837D /* tkPanedWindow.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAF108F27A39005CB29B /* tkPanedWindow.c */; };
-		F9FD31830CC1AD070073837D /* tkPlace.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAF208F27A39005CB29B /* tkPlace.c */; };
-		F9FD31850CC1AD070073837D /* tkRectOval.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAF608F27A39005CB29B /* tkRectOval.c */; };
-		F9FD31860CC1AD070073837D /* tkScale.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAF708F27A39005CB29B /* tkScale.c */; };
-		F9FD31870CC1AD070073837D /* tkScrollbar.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAF908F27A39005CB29B /* tkScrollbar.c */; };
-		F9FD31880CC1AD070073837D /* tkSelect.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAFB08F27A39005CB29B /* tkSelect.c */; };
-		F9FD31890CC1AD070073837D /* tkSquare.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAFD08F27A39005CB29B /* tkSquare.c */; };
-		F9FD318A0CC1AD070073837D /* tkStubInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BAFF08F27A39005CB29B /* tkStubInit.c */; };
-		F9FD318B0CC1AD070073837D /* tkStubLib.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0008F27A39005CB29B /* tkStubLib.c */; };
-		F9FD318C0CC1AD070073837D /* tkStyle.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0108F27A39005CB29B /* tkStyle.c */; };
-		F9FD318D0CC1AD070073837D /* tkTest.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0208F27A39005CB29B /* tkTest.c */; };
-		F9FD318E0CC1AD070073837D /* tkText.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0308F27A39005CB29B /* tkText.c */; };
-		F9FD318F0CC1AD070073837D /* tkTextBTree.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0508F27A39005CB29B /* tkTextBTree.c */; };
-		F9FD31900CC1AD070073837D /* tkTextDisp.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0608F27A39005CB29B /* tkTextDisp.c */; };
-		F9FD31910CC1AD070073837D /* tkTextImage.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0808F27A39005CB29B /* tkTextImage.c */; };
-		F9FD31920CC1AD070073837D /* tkTextIndex.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0908F27A39005CB29B /* tkTextIndex.c */; };
-		F9FD31930CC1AD070073837D /* tkTextMark.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0A08F27A39005CB29B /* tkTextMark.c */; };
-		F9FD31940CC1AD070073837D /* tkTextTag.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0B08F27A39005CB29B /* tkTextTag.c */; };
-		F9FD31950CC1AD070073837D /* tkTextWind.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0C08F27A39005CB29B /* tkTextWind.c */; };
-		F9FD31960CC1AD070073837D /* tkTrig.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0D08F27A39005CB29B /* tkTrig.c */; };
-		F9FD31970CC1AD070073837D /* tkUndo.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB0E08F27A39005CB29B /* tkUndo.c */; };
-		F9FD31980CC1AD070073837D /* tkUtil.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB1008F27A39005CB29B /* tkUtil.c */; };
-		F9FD31990CC1AD070073837D /* tkVisual.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB1108F27A39005CB29B /* tkVisual.c */; };
-		F9FD319A0CC1AD070073837D /* tkWindow.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BB1208F27A39005CB29B /* tkWindow.c */; };
-		F9FD319B0CC1AD070073837D /* ttkBlink.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E10AF786D5000797B5 /* ttkBlink.c */; };
-		F9FD319C0CC1AD070073837D /* ttkButton.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E20AF786D5000797B5 /* ttkButton.c */; };
-		F9FD319D0CC1AD070073837D /* ttkCache.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E30AF786D5000797B5 /* ttkCache.c */; };
-		F9FD319E0CC1AD070073837D /* ttkClamTheme.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E40AF786D5000797B5 /* ttkClamTheme.c */; };
-		F9FD319F0CC1AD070073837D /* ttkClassicTheme.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E50AF786D5000797B5 /* ttkClassicTheme.c */; };
-		F9FD31A00CC1AD070073837D /* ttkDefaultTheme.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E70AF786D5000797B5 /* ttkDefaultTheme.c */; };
-		F9FD31A10CC1AD070073837D /* ttkElements.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E80AF786D5000797B5 /* ttkElements.c */; };
-		F9FD31A20CC1AD070073837D /* ttkEntry.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887E90AF786D5000797B5 /* ttkEntry.c */; };
-		F9FD31A30CC1AD070073837D /* ttkFrame.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887EA0AF786D5000797B5 /* ttkFrame.c */; };
-		F9FD31A40CC1AD070073837D /* ttkImage.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887EB0AF786D5000797B5 /* ttkImage.c */; };
-		F9FD31A50CC1AD070073837D /* ttkInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887EC0AF786D5000797B5 /* ttkInit.c */; };
-		F9FD31A60CC1AD070073837D /* ttkLabel.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887ED0AF786D5000797B5 /* ttkLabel.c */; };
-		F9FD31A70CC1AD070073837D /* ttkLayout.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887EE0AF786D5000797B5 /* ttkLayout.c */; };
-		F9FD31A80CC1AD070073837D /* ttkManager.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887EF0AF786D5000797B5 /* ttkManager.c */; };
-		F9FD31A90CC1AD070073837D /* ttkNotebook.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F10AF786D5000797B5 /* ttkNotebook.c */; };
-		F9FD31AA0CC1AD070073837D /* ttkPanedwindow.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F20AF786D5000797B5 /* ttkPanedwindow.c */; };
-		F9FD31AB0CC1AD070073837D /* ttkProgress.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F30AF786D5000797B5 /* ttkProgress.c */; };
-		F9FD31AC0CC1AD070073837D /* ttkScale.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F40AF786D5000797B5 /* ttkScale.c */; };
-		F9FD31AD0CC1AD070073837D /* ttkScroll.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F50AF786D5000797B5 /* ttkScroll.c */; };
-		F9FD31AE0CC1AD070073837D /* ttkScrollbar.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F60AF786D5000797B5 /* ttkScrollbar.c */; };
-		F9FD31AF0CC1AD070073837D /* ttkSeparator.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F70AF786D5000797B5 /* ttkSeparator.c */; };
-		F9FD31B00CC1AD070073837D /* ttkSquare.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F80AF786D5000797B5 /* ttkSquare.c */; };
-		F9FD31B10CC1AD070073837D /* ttkState.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887F90AF786D5000797B5 /* ttkState.c */; };
-		F9FD31B20CC1AD070073837D /* ttkStubInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887FA0AF786D5000797B5 /* ttkStubInit.c */; };
-		F9FD31B30CC1AD070073837D /* ttkStubLib.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887FB0AF786D5000797B5 /* ttkStubLib.c */; };
-		F9FD31B40CC1AD070073837D /* ttkTagSet.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887FC0AF786D5000797B5 /* ttkTagSet.c */; };
-		F9FD31B50CC1AD070073837D /* ttkTheme.c in Sources */ = {isa = PBXBuildFile; fileRef = F96887FD0AF786D5000797B5 /* ttkTheme.c */; };
-		F9FD31B60CC1AD070073837D /* ttkTrace.c in Sources */ = {isa = PBXBuildFile; fileRef = F96888000AF786D5000797B5 /* ttkTrace.c */; };
-		F9FD31B70CC1AD070073837D /* ttkTrack.c in Sources */ = {isa = PBXBuildFile; fileRef = F96888010AF786D5000797B5 /* ttkTrack.c */; };
-		F9FD31B80CC1AD070073837D /* ttkTreeview.c in Sources */ = {isa = PBXBuildFile; fileRef = F96888020AF786D5000797B5 /* ttkTreeview.c */; };
-		F9FD31B90CC1AD070073837D /* ttkWidget.c in Sources */ = {isa = PBXBuildFile; fileRef = F96888030AF786D5000797B5 /* ttkWidget.c */; };
-		F9FD31DA0CC1AD070073837D /* tkAppInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC7508F27A3D005CB29B /* tkAppInit.c */; settings = {COMPILER_FLAGS = "-DTK_TEST"; }; };
-		F9FD31DB0CC1AD070073837D /* tkUnix3d.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC7908F27A3D005CB29B /* tkUnix3d.c */; };
-		F9FD31DC0CC1AD070073837D /* tkUnixScale.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8C08F27A3D005CB29B /* tkUnixScale.c */; };
-		F9FD31E20CC1AD070073837D /* tclDTrace.d in Sources */ = {isa = PBXBuildFile; fileRef = F9F4415D0C8BAE6F00BCCD67 /* tclDTrace.d */; };
-		F9FD31E40CC1AD070073837D /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F966C07408F2820D005CB29B /* CoreFoundation.framework */; };
-		F9FD31F80CC1ADB70073837D /* tkUnixCursor.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC7D08F27A3D005CB29B /* tkUnixCursor.c */; };
-		F9FD31FA0CC1ADB70073837D /* tkUnixKey.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8708F27A3D005CB29B /* tkUnixKey.c */; };
-		F9FD31FB0CC1ADB70073837D /* tkUnixXId.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC9108F27A3D005CB29B /* tkUnixXId.c */; };
-		F9FD31FC0CC1ADB70073837D /* tkUnixInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8508F27A3D005CB29B /* tkUnixInit.c */; };
-		F9FD31FD0CC1ADB70073837D /* tkUnixEmbed.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8108F27A3D005CB29B /* tkUnixEmbed.c */; };
-		F9FD31FE0CC1ADB70073837D /* tkUnixSend.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8F08F27A3D005CB29B /* tkUnixSend.c */; };
-		F9FD31FF0CC1ADB70073837D /* tkUnixFocus.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8308F27A3D005CB29B /* tkUnixFocus.c */; };
-		F9FD32000CC1ADB70073837D /* tkUnixWm.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC9008F27A3D005CB29B /* tkUnixWm.c */; };
-		F9FD32010CC1ADB70073837D /* tkUnixRFont.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8B08F27A3D005CB29B /* tkUnixRFont.c */; };
-		F9FD32020CC1ADB70073837D /* tkUnix.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC7808F27A3D005CB29B /* tkUnix.c */; };
-		F9FD32030CC1ADB70073837D /* tkUnixMenu.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8808F27A3D005CB29B /* tkUnixMenu.c */; };
-		F9FD32040CC1ADB70073837D /* tkUnixConfig.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC7C08F27A3D005CB29B /* tkUnixConfig.c */; };
-		F9FD32050CC1ADB70073837D /* tkUnixDraw.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8008F27A3D005CB29B /* tkUnixDraw.c */; };
-		F9FD32060CC1ADB70073837D /* tkUnixDialog.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC7F08F27A3D005CB29B /* tkUnixDialog.c */; };
-		F9FD32070CC1ADB70073837D /* tkUnixSelect.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8E08F27A3D005CB29B /* tkUnixSelect.c */; };
-		F9FD32080CC1ADB70073837D /* tkUnixEvent.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8208F27A3D005CB29B /* tkUnixEvent.c */; };
-		F9FD32090CC1ADB70073837D /* tkUnixColor.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC7B08F27A3D005CB29B /* tkUnixColor.c */; };
-		F9FD320A0CC1ADB70073837D /* tkUnixButton.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC7A08F27A3D005CB29B /* tkUnixButton.c */; };
-		F9FD320B0CC1ADB70073837D /* tkUnixMenubu.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8908F27A3D005CB29B /* tkUnixMenubu.c */; };
-		F9FD320C0CC1ADB70073837D /* tkUnixScrlbr.c in Sources */ = {isa = PBXBuildFile; fileRef = F966BC8D08F27A3D005CB29B /* tkUnixScrlbr.c */; };
-		F9FD32170CC1AF170073837D /* libX11.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F9FD32140CC1AF170073837D /* libX11.dylib */; };
-		F9FD32180CC1AF170073837D /* libXext.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F9FD32150CC1AF170073837D /* libXext.dylib */; };
-		F9FD32190CC1AF170073837D /* libXss.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F9FD32160CC1AF170073837D /* libXss.dylib */; };
-		F9FD349B0CC1BB0D0073837D /* libfreetype.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F9FD34990CC1BB0D0073837D /* libfreetype.dylib */; };
-		F9FD349C0CC1BB0D0073837D /* libXft.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F9FD349A0CC1BB0D0073837D /* libXft.dylib */; };
-		F9FD34C40CC1BBD70073837D /* libfontconfig.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F9FD34C30CC1BBD70073837D /* libfontconfig.dylib */; };
-		F9FFAF1D0DFDDB26007F8A6A /* tclIORTrans.c in Sources */ = {isa = PBXBuildFile; fileRef = F95D77E90DFD820D00A8BF6F /* tclIORTrans.c */; };
-		F9FFAF1F0DFDDB2F007F8A6A /* tclOO.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599B20DF1F75400E04F67 /* tclOO.c */; };
-		F9FFAF200DFDDB32007F8A6A /* tclOOBasic.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599B60DF1F76100E04F67 /* tclOOBasic.c */; };
-		F9FFAF210DFDDB32007F8A6A /* tclOOCall.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599B80DF1F76600E04F67 /* tclOOCall.c */; };
-		F9FFAF220DFDDB34007F8A6A /* tclOODefineCmds.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599BB0DF1F77000E04F67 /* tclOODefineCmds.c */; };
-		F9FFAF230DFDDB35007F8A6A /* tclOOInfo.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599BD0DF1F77400E04F67 /* tclOOInfo.c */; };
-		F9FFAF240DFDDB36007F8A6A /* tclOOMethod.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599C10DF1F78300E04F67 /* tclOOMethod.c */; };
-		F9FFAF250DFDDB37007F8A6A /* tclOOStubInit.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599C30DF1F78800E04F67 /* tclOOStubInit.c */; };
-		F9FFAF260DFDDB38007F8A6A /* tclOOStubLib.c in Sources */ = {isa = PBXBuildFile; fileRef = F93599C50DF1F78D00E04F67 /* tclOOStubLib.c */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXFileReference section */
-		8DD76FB20486AB0100D96B5E /* tktest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = tktest; sourceTree = BUILT_PRODUCTS_DIR; };
-		F9099B8A0CC67D30005A9580 /* textpeer.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = textpeer.tcl; sourceTree = "<group>"; };
-		F9099B8B0CC67D3E005A9580 /* ttkbut.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = ttkbut.tcl; sourceTree = "<group>"; };
-		F9152B080EAF8A5000CD5C7B /* tkBusy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkBusy.c; sourceTree = "<group>"; };
-		F91543270EF201A90032D1E8 /* fontchoose.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = fontchoose.tcl; sourceTree = "<group>"; };
-		F915432A0EF201CF0032D1E8 /* zlib.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = zlib.test; sourceTree = "<group>"; };
-		F915432D0EF201EE0032D1E8 /* zlib.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = zlib.n; sourceTree = "<group>"; };
-		F9183E640EFC80CD0030B814 /* throw.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = throw.n; sourceTree = "<group>"; };
-		F9183E650EFC80D70030B814 /* try.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = try.n; sourceTree = "<group>"; };
-		F9183E6A0EFC81560030B814 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F9183E8F0EFC817B0030B814 /* tdbc */ = {isa = PBXFileReference; lastKnownFileType = folder; path = tdbc; sourceTree = "<group>"; };
-		F91DC23C0E44C51B002CB8D1 /* nre.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = nre.test; sourceTree = "<group>"; };
-		F91E62260C1AE686006C9D96 /* Tclsh-Info.plist.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "Tclsh-Info.plist.in"; sourceTree = "<group>"; };
-		F92240290D7C620F005EC715 /* knightstour.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = knightstour.tcl; sourceTree = "<group>"; };
-		F92D7F100DE777240033A13A /* tsdPerf.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tsdPerf.tcl; sourceTree = "<group>"; };
-		F92EE8BE0E62F846001A6E80 /* tkImgPhInstance.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkImgPhInstance.c; sourceTree = "<group>"; };
-		F93599B20DF1F75400E04F67 /* tclOO.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclOO.c; sourceTree = "<group>"; };
-		F93599B40DF1F75900E04F67 /* tclOO.decls */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tclOO.decls; sourceTree = "<group>"; };
-		F93599B50DF1F75D00E04F67 /* tclOO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclOO.h; sourceTree = "<group>"; };
-		F93599B60DF1F76100E04F67 /* tclOOBasic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclOOBasic.c; sourceTree = "<group>"; };
-		F93599B80DF1F76600E04F67 /* tclOOCall.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclOOCall.c; sourceTree = "<group>"; };
-		F93599BA0DF1F76A00E04F67 /* tclOODecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclOODecls.h; sourceTree = "<group>"; };
-		F93599BB0DF1F77000E04F67 /* tclOODefineCmds.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclOODefineCmds.c; sourceTree = "<group>"; };
-		F93599BD0DF1F77400E04F67 /* tclOOInfo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclOOInfo.c; sourceTree = "<group>"; };
-		F93599BF0DF1F77900E04F67 /* tclOOInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclOOInt.h; sourceTree = "<group>"; };
-		F93599C00DF1F77D00E04F67 /* tclOOIntDecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclOOIntDecls.h; sourceTree = "<group>"; };
-		F93599C10DF1F78300E04F67 /* tclOOMethod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclOOMethod.c; sourceTree = "<group>"; };
-		F93599C30DF1F78800E04F67 /* tclOOStubInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclOOStubInit.c; sourceTree = "<group>"; };
-		F93599C50DF1F78D00E04F67 /* tclOOStubLib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclOOStubLib.c; sourceTree = "<group>"; };
-		F93599C80DF1F81900E04F67 /* oo.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = oo.test; sourceTree = "<group>"; };
-		F93599CF0DF1F87F00E04F67 /* Class.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Class.3; sourceTree = "<group>"; };
-		F93599D00DF1F89E00E04F67 /* class.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = class.n; sourceTree = "<group>"; };
-		F93599D20DF1F8DF00E04F67 /* copy.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = copy.n; sourceTree = "<group>"; };
-		F93599D30DF1F8F500E04F67 /* define.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = define.n; sourceTree = "<group>"; };
-		F93599D40DF1F91900E04F67 /* Method.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Method.3; sourceTree = "<group>"; };
-		F93599D50DF1F93700E04F67 /* my.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = my.n; sourceTree = "<group>"; };
-		F93599D60DF1F95000E04F67 /* next.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = next.n; sourceTree = "<group>"; };
-		F93599D70DF1F96800E04F67 /* object.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = object.n; sourceTree = "<group>"; };
-		F93599D80DF1F98300E04F67 /* self.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = self.n; sourceTree = "<group>"; };
-		F936FCD70CCD984500716967 /* ttkprogress.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = ttkprogress.tcl; sourceTree = "<group>"; };
-		F936FCD80CCD984600716967 /* tree.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tree.tcl; sourceTree = "<group>"; };
-		F936FCD90CCD984600716967 /* toolbar.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = toolbar.tcl; sourceTree = "<group>"; };
-		F936FCDA0CCD984600716967 /* ttknote.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = ttknote.tcl; sourceTree = "<group>"; };
-		F936FCDB0CCD984600716967 /* combo.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = combo.tcl; sourceTree = "<group>"; };
-		F93E5EFD09CF8711008FA367 /* tkMacOSXFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXFont.h; sourceTree = "<group>"; };
-		F94523A10E6FC2AC00C1D987 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
-		F946FB8B0FBE3AED00CD6495 /* itcl */ = {isa = PBXFileReference; lastKnownFileType = folder; path = itcl; sourceTree = "<group>"; };
-		F95D77E90DFD820D00A8BF6F /* tclIORTrans.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclIORTrans.c; sourceTree = "<group>"; };
-		F95D8D4B0F1715610006B020 /* Tk.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Tk.icns; sourceTree = "<group>"; };
-		F95D8D4C0F1715610006B020 /* Tk.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Tk.tiff; sourceTree = "<group>"; };
-		F95FAFF90B34F1130072E431 /* macOSXLoad.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = macOSXLoad.test; sourceTree = "<group>"; };
-		F962F7C60DADC26200648DB8 /* vsapi.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = vsapi.test; sourceTree = "<group>"; };
-		F96437C90EF0D4B2003F468E /* tclZlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclZlib.c; sourceTree = "<group>"; };
-		F96437E60EF0D652003F468E /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = "<absolute>"; };
-		F966BA0408F27A37005CB29B /* error.xbm */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = error.xbm; sourceTree = "<group>"; };
-		F966BA0508F27A37005CB29B /* gray12.xbm */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = gray12.xbm; sourceTree = "<group>"; };
-		F966BA0608F27A37005CB29B /* gray25.xbm */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = gray25.xbm; sourceTree = "<group>"; };
-		F966BA0708F27A37005CB29B /* gray50.xbm */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = gray50.xbm; sourceTree = "<group>"; };
-		F966BA0808F27A37005CB29B /* gray75.xbm */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = gray75.xbm; sourceTree = "<group>"; };
-		F966BA0908F27A37005CB29B /* hourglass.xbm */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = hourglass.xbm; sourceTree = "<group>"; };
-		F966BA0A08F27A37005CB29B /* info.xbm */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = info.xbm; sourceTree = "<group>"; };
-		F966BA0B08F27A37005CB29B /* questhead.xbm */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = questhead.xbm; sourceTree = "<group>"; };
-		F966BA0C08F27A37005CB29B /* question.xbm */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = question.xbm; sourceTree = "<group>"; };
-		F966BA0D08F27A37005CB29B /* warning.xbm */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = warning.xbm; sourceTree = "<group>"; };
-		F966BA0E08F27A37005CB29B /* ChangeLog */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = ChangeLog; sourceTree = "<group>"; };
-		F966BA0F08F27A37005CB29B /* changes */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = changes; sourceTree = "<group>"; };
-		F966BA1108F27A37005CB29B /* 3DBorder.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = 3DBorder.3; sourceTree = "<group>"; };
-		F966BA1208F27A37005CB29B /* AddOption.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = AddOption.3; sourceTree = "<group>"; };
-		F966BA1308F27A37005CB29B /* bell.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = bell.n; sourceTree = "<group>"; };
-		F966BA1408F27A37005CB29B /* bind.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = bind.n; sourceTree = "<group>"; };
-		F966BA1508F27A37005CB29B /* BindTable.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = BindTable.3; sourceTree = "<group>"; };
-		F966BA1608F27A37005CB29B /* bindtags.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = bindtags.n; sourceTree = "<group>"; };
-		F966BA1708F27A37005CB29B /* bitmap.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = bitmap.n; sourceTree = "<group>"; };
-		F966BA1808F27A37005CB29B /* button.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = button.n; sourceTree = "<group>"; };
-		F966BA1908F27A37005CB29B /* canvas.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = canvas.n; sourceTree = "<group>"; };
-		F966BA1A08F27A37005CB29B /* CanvPsY.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CanvPsY.3; sourceTree = "<group>"; };
-		F966BA1B08F27A37005CB29B /* CanvTkwin.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CanvTkwin.3; sourceTree = "<group>"; };
-		F966BA1C08F27A37005CB29B /* CanvTxtInfo.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CanvTxtInfo.3; sourceTree = "<group>"; };
-		F966BA1D08F27A37005CB29B /* checkbutton.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = checkbutton.n; sourceTree = "<group>"; };
-		F966BA1E08F27A37005CB29B /* chooseColor.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = chooseColor.n; sourceTree = "<group>"; };
-		F966BA1F08F27A37005CB29B /* chooseDirectory.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = chooseDirectory.n; sourceTree = "<group>"; };
-		F966BA2008F27A37005CB29B /* Clipboard.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Clipboard.3; sourceTree = "<group>"; };
-		F966BA2108F27A37005CB29B /* clipboard.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = clipboard.n; sourceTree = "<group>"; };
-		F966BA2208F27A37005CB29B /* ClrSelect.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ClrSelect.3; sourceTree = "<group>"; };
-		F966BA2308F27A37005CB29B /* colors.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = colors.n; sourceTree = "<group>"; };
-		F966BA2408F27A37005CB29B /* ConfigWidg.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ConfigWidg.3; sourceTree = "<group>"; };
-		F966BA2508F27A37005CB29B /* ConfigWind.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ConfigWind.3; sourceTree = "<group>"; };
-		F966BA2608F27A37005CB29B /* console.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = console.n; sourceTree = "<group>"; };
-		F966BA2708F27A37005CB29B /* CoordToWin.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CoordToWin.3; sourceTree = "<group>"; };
-		F966BA2808F27A37005CB29B /* CrtCmHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtCmHdlr.3; sourceTree = "<group>"; };
-		F966BA2908F27A37005CB29B /* CrtErrHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtErrHdlr.3; sourceTree = "<group>"; };
-		F966BA2A08F27A37005CB29B /* CrtGenHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtGenHdlr.3; sourceTree = "<group>"; };
-		F966BA2B08F27A37005CB29B /* CrtImgType.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtImgType.3; sourceTree = "<group>"; };
-		F966BA2C08F27A37005CB29B /* CrtItemType.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtItemType.3; sourceTree = "<group>"; };
-		F966BA2D08F27A37005CB29B /* CrtPhImgFmt.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtPhImgFmt.3; sourceTree = "<group>"; };
-		F966BA2E08F27A37005CB29B /* CrtSelHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtSelHdlr.3; sourceTree = "<group>"; };
-		F966BA2F08F27A37005CB29B /* CrtWindow.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtWindow.3; sourceTree = "<group>"; };
-		F966BA3008F27A37005CB29B /* cursors.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = cursors.n; sourceTree = "<group>"; };
-		F966BA3108F27A37005CB29B /* DeleteImg.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = DeleteImg.3; sourceTree = "<group>"; };
-		F966BA3208F27A37005CB29B /* destroy.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = destroy.n; sourceTree = "<group>"; };
-		F966BA3308F27A37005CB29B /* dialog.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = dialog.n; sourceTree = "<group>"; };
-		F966BA3408F27A37005CB29B /* DrawFocHlt.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = DrawFocHlt.3; sourceTree = "<group>"; };
-		F966BA3508F27A37005CB29B /* entry.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = entry.n; sourceTree = "<group>"; };
-		F966BA3608F27A37005CB29B /* event.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = event.n; sourceTree = "<group>"; };
-		F966BA3708F27A37005CB29B /* EventHndlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = EventHndlr.3; sourceTree = "<group>"; };
-		F966BA3808F27A37005CB29B /* FindPhoto.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = FindPhoto.3; sourceTree = "<group>"; };
-		F966BA3908F27A37005CB29B /* focus.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = focus.n; sourceTree = "<group>"; };
-		F966BA3A08F27A37005CB29B /* focusNext.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = focusNext.n; sourceTree = "<group>"; };
-		F966BA3B08F27A37005CB29B /* font.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = font.n; sourceTree = "<group>"; };
-		F966BA3C08F27A37005CB29B /* FontId.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = FontId.3; sourceTree = "<group>"; };
-		F966BA3D08F27A37005CB29B /* frame.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = frame.n; sourceTree = "<group>"; };
-		F966BA3E08F27A37005CB29B /* FreeXId.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = FreeXId.3; sourceTree = "<group>"; };
-		F966BA3F08F27A37005CB29B /* GeomReq.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GeomReq.3; sourceTree = "<group>"; };
-		F966BA4008F27A37005CB29B /* GetAnchor.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetAnchor.3; sourceTree = "<group>"; };
-		F966BA4108F27A37005CB29B /* GetBitmap.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetBitmap.3; sourceTree = "<group>"; };
-		F966BA4208F27A37005CB29B /* GetCapStyl.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetCapStyl.3; sourceTree = "<group>"; };
-		F966BA4308F27A37005CB29B /* GetClrmap.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetClrmap.3; sourceTree = "<group>"; };
-		F966BA4408F27A37005CB29B /* GetColor.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetColor.3; sourceTree = "<group>"; };
-		F966BA4508F27A37005CB29B /* GetCursor.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetCursor.3; sourceTree = "<group>"; };
-		F966BA4608F27A37005CB29B /* GetDash.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetDash.3; sourceTree = "<group>"; };
-		F966BA4708F27A37005CB29B /* GetFont.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetFont.3; sourceTree = "<group>"; };
-		F966BA4808F27A37005CB29B /* GetGC.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetGC.3; sourceTree = "<group>"; };
-		F966BA4908F27A37005CB29B /* GetHINSTANCE.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetHINSTANCE.3; sourceTree = "<group>"; };
-		F966BA4A08F27A37005CB29B /* GetHWND.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetHWND.3; sourceTree = "<group>"; };
-		F966BA4B08F27A37005CB29B /* GetImage.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetImage.3; sourceTree = "<group>"; };
-		F966BA4C08F27A37005CB29B /* GetJoinStl.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetJoinStl.3; sourceTree = "<group>"; };
-		F966BA4D08F27A37005CB29B /* GetJustify.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetJustify.3; sourceTree = "<group>"; };
-		F966BA4E08F27A37005CB29B /* getOpenFile.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = getOpenFile.n; sourceTree = "<group>"; };
-		F966BA4F08F27A37005CB29B /* GetOption.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetOption.3; sourceTree = "<group>"; };
-		F966BA5008F27A38005CB29B /* GetPixels.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetPixels.3; sourceTree = "<group>"; };
-		F966BA5108F27A38005CB29B /* GetPixmap.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetPixmap.3; sourceTree = "<group>"; };
-		F966BA5208F27A38005CB29B /* GetRelief.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetRelief.3; sourceTree = "<group>"; };
-		F966BA5308F27A38005CB29B /* GetRootCrd.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetRootCrd.3; sourceTree = "<group>"; };
-		F966BA5408F27A38005CB29B /* GetScroll.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetScroll.3; sourceTree = "<group>"; };
-		F966BA5508F27A38005CB29B /* GetSelect.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetSelect.3; sourceTree = "<group>"; };
-		F966BA5608F27A38005CB29B /* GetUid.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetUid.3; sourceTree = "<group>"; };
-		F966BA5708F27A38005CB29B /* GetVisual.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetVisual.3; sourceTree = "<group>"; };
-		F966BA5808F27A38005CB29B /* GetVRoot.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetVRoot.3; sourceTree = "<group>"; };
-		F966BA5908F27A38005CB29B /* Grab.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Grab.3; sourceTree = "<group>"; };
-		F966BA5A08F27A38005CB29B /* grab.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = grab.n; sourceTree = "<group>"; };
-		F966BA5B08F27A38005CB29B /* grid.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = grid.n; sourceTree = "<group>"; };
-		F966BA5C08F27A38005CB29B /* HandleEvent.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = HandleEvent.3; sourceTree = "<group>"; };
-		F966BA5D08F27A38005CB29B /* HWNDToWindow.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = HWNDToWindow.3; sourceTree = "<group>"; };
-		F966BA5E08F27A38005CB29B /* IdToWindow.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = IdToWindow.3; sourceTree = "<group>"; };
-		F966BA5F08F27A38005CB29B /* image.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = image.n; sourceTree = "<group>"; };
-		F966BA6008F27A38005CB29B /* ImgChanged.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ImgChanged.3; sourceTree = "<group>"; };
-		F966BA6108F27A38005CB29B /* Inactive.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Inactive.3; sourceTree = "<group>"; };
-		F966BA6208F27A38005CB29B /* InternAtom.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = InternAtom.3; sourceTree = "<group>"; };
-		F966BA6308F27A38005CB29B /* keysyms.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = keysyms.n; sourceTree = "<group>"; };
-		F966BA6408F27A38005CB29B /* label.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = label.n; sourceTree = "<group>"; };
-		F966BA6508F27A38005CB29B /* labelframe.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = labelframe.n; sourceTree = "<group>"; };
-		F966BA6608F27A38005CB29B /* listbox.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = listbox.n; sourceTree = "<group>"; };
-		F966BA6708F27A38005CB29B /* loadTk.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = loadTk.n; sourceTree = "<group>"; };
-		F966BA6808F27A38005CB29B /* lower.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = lower.n; sourceTree = "<group>"; };
-		F966BA6908F27A38005CB29B /* MainLoop.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = MainLoop.3; sourceTree = "<group>"; };
-		F966BA6A08F27A38005CB29B /* MaintGeom.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = MaintGeom.3; sourceTree = "<group>"; };
-		F966BA6B08F27A38005CB29B /* MainWin.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = MainWin.3; sourceTree = "<group>"; };
-		F966BA6D08F27A38005CB29B /* ManageGeom.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ManageGeom.3; sourceTree = "<group>"; };
-		F966BA6E08F27A38005CB29B /* MapWindow.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = MapWindow.3; sourceTree = "<group>"; };
-		F966BA6F08F27A38005CB29B /* MeasureChar.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = MeasureChar.3; sourceTree = "<group>"; };
-		F966BA7008F27A38005CB29B /* menu.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = menu.n; sourceTree = "<group>"; };
-		F966BA7108F27A38005CB29B /* menubar.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = menubar.n; sourceTree = "<group>"; };
-		F966BA7208F27A38005CB29B /* menubutton.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = menubutton.n; sourceTree = "<group>"; };
-		F966BA7308F27A38005CB29B /* message.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = message.n; sourceTree = "<group>"; };
-		F966BA7408F27A38005CB29B /* messageBox.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = messageBox.n; sourceTree = "<group>"; };
-		F966BA7508F27A38005CB29B /* MoveToplev.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = MoveToplev.3; sourceTree = "<group>"; };
-		F966BA7608F27A38005CB29B /* Name.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Name.3; sourceTree = "<group>"; };
-		F966BA7708F27A38005CB29B /* NameOfImg.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = NameOfImg.3; sourceTree = "<group>"; };
-		F966BA7808F27A38005CB29B /* option.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = option.n; sourceTree = "<group>"; };
-		F966BA7908F27A38005CB29B /* optionMenu.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = optionMenu.n; sourceTree = "<group>"; };
-		F966BA7A08F27A38005CB29B /* options.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = options.n; sourceTree = "<group>"; };
-		F966BA7B08F27A38005CB29B /* OwnSelect.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = OwnSelect.3; sourceTree = "<group>"; };
-		F966BA7C08F27A38005CB29B /* pack-old.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = "pack-old.n"; sourceTree = "<group>"; };
-		F966BA7D08F27A38005CB29B /* pack.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = pack.n; sourceTree = "<group>"; };
-		F966BA7E08F27A38005CB29B /* palette.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = palette.n; sourceTree = "<group>"; };
-		F966BA7F08F27A38005CB29B /* panedwindow.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = panedwindow.n; sourceTree = "<group>"; };
-		F966BA8008F27A38005CB29B /* ParseArgv.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ParseArgv.3; sourceTree = "<group>"; };
-		F966BA8108F27A38005CB29B /* photo.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = photo.n; sourceTree = "<group>"; };
-		F966BA8208F27A38005CB29B /* place.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = place.n; sourceTree = "<group>"; };
-		F966BA8308F27A38005CB29B /* popup.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = popup.n; sourceTree = "<group>"; };
-		F966BA8408F27A38005CB29B /* QWinEvent.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = QWinEvent.3; sourceTree = "<group>"; };
-		F966BA8508F27A38005CB29B /* radiobutton.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = radiobutton.n; sourceTree = "<group>"; };
-		F966BA8608F27A38005CB29B /* raise.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = raise.n; sourceTree = "<group>"; };
-		F966BA8708F27A38005CB29B /* Restack.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Restack.3; sourceTree = "<group>"; };
-		F966BA8808F27A38005CB29B /* RestrictEv.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = RestrictEv.3; sourceTree = "<group>"; };
-		F966BA8908F27A38005CB29B /* scale.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = scale.n; sourceTree = "<group>"; };
-		F966BA8A08F27A38005CB29B /* scrollbar.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = scrollbar.n; sourceTree = "<group>"; };
-		F966BA8B08F27A38005CB29B /* selection.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = selection.n; sourceTree = "<group>"; };
-		F966BA8C08F27A38005CB29B /* send.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = send.n; sourceTree = "<group>"; };
-		F966BA8D08F27A38005CB29B /* SetAppName.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SetAppName.3; sourceTree = "<group>"; };
-		F966BA8E08F27A38005CB29B /* SetCaret.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SetCaret.3; sourceTree = "<group>"; };
-		F966BA8F08F27A38005CB29B /* SetClass.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SetClass.3; sourceTree = "<group>"; };
-		F966BA9008F27A38005CB29B /* SetClassProcs.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SetClassProcs.3; sourceTree = "<group>"; };
-		F966BA9108F27A38005CB29B /* SetGrid.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SetGrid.3; sourceTree = "<group>"; };
-		F966BA9208F27A38005CB29B /* SetOptions.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SetOptions.3; sourceTree = "<group>"; };
-		F966BA9308F27A38005CB29B /* SetVisual.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SetVisual.3; sourceTree = "<group>"; };
-		F966BA9408F27A38005CB29B /* spinbox.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = spinbox.n; sourceTree = "<group>"; };
-		F966BA9508F27A38005CB29B /* StrictMotif.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = StrictMotif.3; sourceTree = "<group>"; };
-		F966BA9608F27A38005CB29B /* text.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = text.n; sourceTree = "<group>"; };
-		F966BA9708F27A38005CB29B /* TextLayout.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = TextLayout.3; sourceTree = "<group>"; };
-		F966BA9808F27A38005CB29B /* tk.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = tk.n; sourceTree = "<group>"; };
-		F966BA9A08F27A38005CB29B /* Tk_Init.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Tk_Init.3; sourceTree = "<group>"; };
-		F966BA9B08F27A38005CB29B /* Tk_Main.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Tk_Main.3; sourceTree = "<group>"; };
-		F966BA9C08F27A38005CB29B /* tkerror.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = tkerror.n; sourceTree = "<group>"; };
-		F966BA9D08F27A38005CB29B /* TkInitStubs.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = TkInitStubs.3; sourceTree = "<group>"; };
-		F966BA9E08F27A38005CB29B /* tkvars.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = tkvars.n; sourceTree = "<group>"; };
-		F966BA9F08F27A38005CB29B /* tkwait.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = tkwait.n; sourceTree = "<group>"; };
-		F966BAA008F27A38005CB29B /* toplevel.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = toplevel.n; sourceTree = "<group>"; };
-		F966BAA108F27A38005CB29B /* WindowId.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = WindowId.3; sourceTree = "<group>"; };
-		F966BAA208F27A38005CB29B /* winfo.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = winfo.n; sourceTree = "<group>"; };
-		F966BAA308F27A38005CB29B /* wish.1 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = wish.1; sourceTree = "<group>"; };
-		F966BAA408F27A38005CB29B /* wm.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = wm.n; sourceTree = "<group>"; };
-		F966BAA608F27A38005CB29B /* default.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = default.h; sourceTree = "<group>"; };
-		F966BAA708F27A38005CB29B /* ks_names.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ks_names.h; sourceTree = "<group>"; };
-		F966BAA908F27A39005CB29B /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F966BAAA08F27A39005CB29B /* tk.decls */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tk.decls; sourceTree = "<group>"; };
-		F966BAAB08F27A39005CB29B /* tk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tk.h; sourceTree = "<group>"; };
-		F966BAAC08F27A39005CB29B /* tk3d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tk3d.c; sourceTree = "<group>"; };
-		F966BAAD08F27A39005CB29B /* tk3d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tk3d.h; sourceTree = "<group>"; };
-		F966BAAE08F27A39005CB29B /* tkArgv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkArgv.c; sourceTree = "<group>"; };
-		F966BAAF08F27A39005CB29B /* tkAtom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkAtom.c; sourceTree = "<group>"; };
-		F966BAB008F27A39005CB29B /* tkBind.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkBind.c; sourceTree = "<group>"; };
-		F966BAB108F27A39005CB29B /* tkBitmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkBitmap.c; sourceTree = "<group>"; };
-		F966BAB208F27A39005CB29B /* tkButton.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkButton.c; sourceTree = "<group>"; };
-		F966BAB308F27A39005CB29B /* tkButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkButton.h; sourceTree = "<group>"; };
-		F966BAB408F27A39005CB29B /* tkCanvArc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkCanvArc.c; sourceTree = "<group>"; };
-		F966BAB508F27A39005CB29B /* tkCanvas.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkCanvas.c; sourceTree = "<group>"; };
-		F966BAB608F27A39005CB29B /* tkCanvas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkCanvas.h; sourceTree = "<group>"; };
-		F966BAB708F27A39005CB29B /* tkCanvBmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkCanvBmap.c; sourceTree = "<group>"; };
-		F966BAB808F27A39005CB29B /* tkCanvImg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkCanvImg.c; sourceTree = "<group>"; };
-		F966BAB908F27A39005CB29B /* tkCanvLine.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkCanvLine.c; sourceTree = "<group>"; };
-		F966BABA08F27A39005CB29B /* tkCanvPoly.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkCanvPoly.c; sourceTree = "<group>"; };
-		F966BABB08F27A39005CB29B /* tkCanvPs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkCanvPs.c; sourceTree = "<group>"; };
-		F966BABD08F27A39005CB29B /* tkCanvText.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkCanvText.c; sourceTree = "<group>"; };
-		F966BABE08F27A39005CB29B /* tkCanvUtil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkCanvUtil.c; sourceTree = "<group>"; };
-		F966BABF08F27A39005CB29B /* tkCanvWind.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkCanvWind.c; sourceTree = "<group>"; };
-		F966BAC008F27A39005CB29B /* tkClipboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkClipboard.c; sourceTree = "<group>"; };
-		F966BAC108F27A39005CB29B /* tkCmds.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkCmds.c; sourceTree = "<group>"; };
-		F966BAC208F27A39005CB29B /* tkColor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkColor.c; sourceTree = "<group>"; };
-		F966BAC308F27A39005CB29B /* tkColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkColor.h; sourceTree = "<group>"; };
-		F966BAC408F27A39005CB29B /* tkConfig.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkConfig.c; sourceTree = "<group>"; };
-		F966BAC508F27A39005CB29B /* tkConsole.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkConsole.c; sourceTree = "<group>"; };
-		F966BAC608F27A39005CB29B /* tkCursor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkCursor.c; sourceTree = "<group>"; };
-		F966BAC708F27A39005CB29B /* tkDecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkDecls.h; sourceTree = "<group>"; };
-		F966BAC808F27A39005CB29B /* tkEntry.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkEntry.c; sourceTree = "<group>"; };
-		F966BAC908F27A39005CB29B /* tkEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkEntry.h; sourceTree = "<group>"; };
-		F966BACA08F27A39005CB29B /* tkError.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkError.c; sourceTree = "<group>"; };
-		F966BACB08F27A39005CB29B /* tkEvent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkEvent.c; sourceTree = "<group>"; };
-		F966BACC08F27A39005CB29B /* tkFileFilter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkFileFilter.c; sourceTree = "<group>"; };
-		F966BACD08F27A39005CB29B /* tkFileFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkFileFilter.h; sourceTree = "<group>"; };
-		F966BACE08F27A39005CB29B /* tkFocus.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkFocus.c; sourceTree = "<group>"; };
-		F966BACF08F27A39005CB29B /* tkFont.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkFont.c; sourceTree = "<group>"; };
-		F966BAD008F27A39005CB29B /* tkFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkFont.h; sourceTree = "<group>"; };
-		F966BAD108F27A39005CB29B /* tkFrame.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkFrame.c; sourceTree = "<group>"; };
-		F966BAD208F27A39005CB29B /* tkGC.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkGC.c; sourceTree = "<group>"; };
-		F966BAD308F27A39005CB29B /* tkGeometry.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkGeometry.c; sourceTree = "<group>"; };
-		F966BAD408F27A39005CB29B /* tkGet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkGet.c; sourceTree = "<group>"; };
-		F966BAD508F27A39005CB29B /* tkGrab.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkGrab.c; sourceTree = "<group>"; };
-		F966BAD608F27A39005CB29B /* tkGrid.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkGrid.c; sourceTree = "<group>"; };
-		F966BAD708F27A39005CB29B /* tkImage.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkImage.c; sourceTree = "<group>"; };
-		F966BAD808F27A39005CB29B /* tkImgBmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkImgBmap.c; sourceTree = "<group>"; };
-		F966BAD908F27A39005CB29B /* tkImgGIF.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkImgGIF.c; sourceTree = "<group>"; };
-		F966BADA08F27A39005CB29B /* tkImgPhoto.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkImgPhoto.c; sourceTree = "<group>"; };
-		F966BADB08F27A39005CB29B /* tkImgPPM.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkImgPPM.c; sourceTree = "<group>"; };
-		F966BADC08F27A39005CB29B /* tkImgUtil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkImgUtil.c; sourceTree = "<group>"; };
-		F966BADE08F27A39005CB29B /* tkInt.decls */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tkInt.decls; sourceTree = "<group>"; };
-		F966BADF08F27A39005CB29B /* tkInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkInt.h; sourceTree = "<group>"; };
-		F966BAE108F27A39005CB29B /* tkIntDecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkIntDecls.h; sourceTree = "<group>"; };
-		F966BAE208F27A39005CB29B /* tkIntPlatDecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkIntPlatDecls.h; sourceTree = "<group>"; };
-		F966BAE308F27A39005CB29B /* tkIntXlibDecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkIntXlibDecls.h; sourceTree = "<group>"; };
-		F966BAE408F27A39005CB29B /* tkListbox.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkListbox.c; sourceTree = "<group>"; };
-		F966BAE508F27A39005CB29B /* tkMacWinMenu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMacWinMenu.c; sourceTree = "<group>"; };
-		F966BAE608F27A39005CB29B /* tkMain.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMain.c; sourceTree = "<group>"; };
-		F966BAE708F27A39005CB29B /* tkMenu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMenu.c; sourceTree = "<group>"; };
-		F966BAE808F27A39005CB29B /* tkMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMenu.h; sourceTree = "<group>"; };
-		F966BAE908F27A39005CB29B /* tkMenubutton.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMenubutton.c; sourceTree = "<group>"; };
-		F966BAEA08F27A39005CB29B /* tkMenubutton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMenubutton.h; sourceTree = "<group>"; };
-		F966BAEB08F27A39005CB29B /* tkMenuDraw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMenuDraw.c; sourceTree = "<group>"; };
-		F966BAEC08F27A39005CB29B /* tkMessage.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkMessage.c; sourceTree = "<group>"; };
-		F966BAED08F27A39005CB29B /* tkObj.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkObj.c; sourceTree = "<group>"; };
-		F966BAEE08F27A39005CB29B /* tkOldConfig.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkOldConfig.c; sourceTree = "<group>"; };
-		F966BAEF08F27A39005CB29B /* tkOption.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkOption.c; sourceTree = "<group>"; };
-		F966BAF008F27A39005CB29B /* tkPack.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkPack.c; sourceTree = "<group>"; };
-		F966BAF108F27A39005CB29B /* tkPanedWindow.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkPanedWindow.c; sourceTree = "<group>"; };
-		F966BAF208F27A39005CB29B /* tkPlace.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkPlace.c; sourceTree = "<group>"; };
-		F966BAF308F27A39005CB29B /* tkPlatDecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkPlatDecls.h; sourceTree = "<group>"; };
-		F966BAF408F27A39005CB29B /* tkPointer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkPointer.c; sourceTree = "<group>"; };
-		F966BAF508F27A39005CB29B /* tkPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkPort.h; sourceTree = "<group>"; };
-		F966BAF608F27A39005CB29B /* tkRectOval.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkRectOval.c; sourceTree = "<group>"; };
-		F966BAF708F27A39005CB29B /* tkScale.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkScale.c; sourceTree = "<group>"; };
-		F966BAF808F27A39005CB29B /* tkScale.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkScale.h; sourceTree = "<group>"; };
-		F966BAF908F27A39005CB29B /* tkScrollbar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkScrollbar.c; sourceTree = "<group>"; };
-		F966BAFA08F27A39005CB29B /* tkScrollbar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkScrollbar.h; sourceTree = "<group>"; };
-		F966BAFB08F27A39005CB29B /* tkSelect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkSelect.c; sourceTree = "<group>"; };
-		F966BAFC08F27A39005CB29B /* tkSelect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkSelect.h; sourceTree = "<group>"; };
-		F966BAFD08F27A39005CB29B /* tkSquare.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkSquare.c; sourceTree = "<group>"; };
-		F966BAFE08F27A39005CB29B /* tkOldTest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkOldTest.c; sourceTree = "<group>"; };
-		F966BAFF08F27A39005CB29B /* tkStubInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkStubInit.c; sourceTree = "<group>"; };
-		F966BB0008F27A39005CB29B /* tkStubLib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkStubLib.c; sourceTree = "<group>"; };
-		F966BB0108F27A39005CB29B /* tkStyle.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkStyle.c; sourceTree = "<group>"; };
-		F966BB0208F27A39005CB29B /* tkTest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkTest.c; sourceTree = "<group>"; };
-		F966BB0308F27A39005CB29B /* tkText.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkText.c; sourceTree = "<group>"; };
-		F966BB0408F27A39005CB29B /* tkText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkText.h; sourceTree = "<group>"; };
-		F966BB0508F27A39005CB29B /* tkTextBTree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkTextBTree.c; sourceTree = "<group>"; };
-		F966BB0608F27A39005CB29B /* tkTextDisp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkTextDisp.c; sourceTree = "<group>"; };
-		F966BB0808F27A39005CB29B /* tkTextImage.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkTextImage.c; sourceTree = "<group>"; };
-		F966BB0908F27A39005CB29B /* tkTextIndex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkTextIndex.c; sourceTree = "<group>"; };
-		F966BB0A08F27A39005CB29B /* tkTextMark.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkTextMark.c; sourceTree = "<group>"; };
-		F966BB0B08F27A39005CB29B /* tkTextTag.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkTextTag.c; sourceTree = "<group>"; };
-		F966BB0C08F27A39005CB29B /* tkTextWind.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkTextWind.c; sourceTree = "<group>"; };
-		F966BB0D08F27A39005CB29B /* tkTrig.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkTrig.c; sourceTree = "<group>"; };
-		F966BB0E08F27A39005CB29B /* tkUndo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUndo.c; sourceTree = "<group>"; };
-		F966BB0F08F27A39005CB29B /* tkUndo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkUndo.h; sourceTree = "<group>"; };
-		F966BB1008F27A39005CB29B /* tkUtil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUtil.c; sourceTree = "<group>"; };
-		F966BB1108F27A39005CB29B /* tkVisual.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkVisual.c; sourceTree = "<group>"; };
-		F966BB1208F27A39005CB29B /* tkWindow.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWindow.c; sourceTree = "<group>"; };
-		F966BB1408F27A39005CB29B /* bgerror.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = bgerror.tcl; sourceTree = "<group>"; };
-		F966BB1508F27A39005CB29B /* button.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = button.tcl; sourceTree = "<group>"; };
-		F966BB1608F27A39005CB29B /* choosedir.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = choosedir.tcl; sourceTree = "<group>"; };
-		F966BB1708F27A39005CB29B /* clrpick.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = clrpick.tcl; sourceTree = "<group>"; };
-		F966BB1808F27A39005CB29B /* comdlg.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = comdlg.tcl; sourceTree = "<group>"; };
-		F966BB1908F27A39005CB29B /* console.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = console.tcl; sourceTree = "<group>"; };
-		F966BB1B08F27A39005CB29B /* anilabel.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = anilabel.tcl; sourceTree = "<group>"; };
-		F966BB1C08F27A39005CB29B /* aniwave.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = aniwave.tcl; sourceTree = "<group>"; };
-		F966BB1D08F27A39005CB29B /* arrow.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = arrow.tcl; sourceTree = "<group>"; };
-		F966BB1E08F27A39005CB29B /* bind.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = bind.tcl; sourceTree = "<group>"; };
-		F966BB1F08F27A39005CB29B /* bitmap.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = bitmap.tcl; sourceTree = "<group>"; };
-		F966BB2008F27A39005CB29B /* browse */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = browse; sourceTree = "<group>"; };
-		F966BB2108F27A39005CB29B /* button.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = button.tcl; sourceTree = "<group>"; };
-		F966BB2208F27A39005CB29B /* check.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = check.tcl; sourceTree = "<group>"; };
-		F966BB2308F27A39005CB29B /* clrpick.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = clrpick.tcl; sourceTree = "<group>"; };
-		F966BB2408F27A39005CB29B /* colors.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = colors.tcl; sourceTree = "<group>"; };
-		F966BB2508F27A39005CB29B /* cscroll.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = cscroll.tcl; sourceTree = "<group>"; };
-		F966BB2608F27A39005CB29B /* ctext.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = ctext.tcl; sourceTree = "<group>"; };
-		F966BB2708F27A39005CB29B /* dialog1.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = dialog1.tcl; sourceTree = "<group>"; };
-		F966BB2808F27A39005CB29B /* dialog2.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = dialog2.tcl; sourceTree = "<group>"; };
-		F966BB2A08F27A39005CB29B /* entry1.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = entry1.tcl; sourceTree = "<group>"; };
-		F966BB2B08F27A39005CB29B /* entry2.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = entry2.tcl; sourceTree = "<group>"; };
-		F966BB2C08F27A39005CB29B /* entry3.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = entry3.tcl; sourceTree = "<group>"; };
-		F966BB2D08F27A39005CB29B /* filebox.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = filebox.tcl; sourceTree = "<group>"; };
-		F966BB2E08F27A39005CB29B /* floor.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = floor.tcl; sourceTree = "<group>"; };
-		F966BB2F08F27A39005CB29B /* form.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = form.tcl; sourceTree = "<group>"; };
-		F966BB3008F27A39005CB29B /* goldberg.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = goldberg.tcl; sourceTree = "<group>"; };
-		F966BB3108F27A39005CB29B /* hello */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = hello; sourceTree = "<group>"; };
-		F966BB3208F27A39005CB29B /* hscale.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = hscale.tcl; sourceTree = "<group>"; };
-		F966BB3308F27A39005CB29B /* icon.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = icon.tcl; sourceTree = "<group>"; };
-		F966BB3408F27A39005CB29B /* image1.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = image1.tcl; sourceTree = "<group>"; };
-		F966BB3508F27A39005CB29B /* image2.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = image2.tcl; sourceTree = "<group>"; };
-		F966BB4208F27A3A005CB29B /* items.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = items.tcl; sourceTree = "<group>"; };
-		F966BB4308F27A3A005CB29B /* ixset */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = ixset; sourceTree = "<group>"; };
-		F966BB4408F27A3A005CB29B /* label.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = label.tcl; sourceTree = "<group>"; };
-		F966BB4508F27A3A005CB29B /* labelframe.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = labelframe.tcl; sourceTree = "<group>"; };
-		F966BB4608F27A3A005CB29B /* menu.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = menu.tcl; sourceTree = "<group>"; };
-		F966BB4708F27A3A005CB29B /* menubu.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = menubu.tcl; sourceTree = "<group>"; };
-		F966BB4808F27A3A005CB29B /* msgbox.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = msgbox.tcl; sourceTree = "<group>"; };
-		F966BB4A08F27A3A005CB29B /* paned1.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = paned1.tcl; sourceTree = "<group>"; };
-		F966BB4B08F27A3A005CB29B /* paned2.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = paned2.tcl; sourceTree = "<group>"; };
-		F966BB4C08F27A3A005CB29B /* pendulum.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pendulum.tcl; sourceTree = "<group>"; };
-		F966BB4D08F27A3A005CB29B /* plot.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = plot.tcl; sourceTree = "<group>"; };
-		F966BB4E08F27A3A005CB29B /* puzzle.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = puzzle.tcl; sourceTree = "<group>"; };
-		F966BB4F08F27A3A005CB29B /* radio.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = radio.tcl; sourceTree = "<group>"; };
-		F966BB5008F27A3A005CB29B /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F966BB5108F27A3A005CB29B /* rmt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = rmt; sourceTree = "<group>"; };
-		F966BB5208F27A3A005CB29B /* rolodex */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = rolodex; sourceTree = "<group>"; };
-		F966BB5308F27A3A005CB29B /* ruler.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = ruler.tcl; sourceTree = "<group>"; };
-		F966BB5408F27A3A005CB29B /* sayings.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = sayings.tcl; sourceTree = "<group>"; };
-		F966BB5508F27A3A005CB29B /* search.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = search.tcl; sourceTree = "<group>"; };
-		F966BB5608F27A3A005CB29B /* spin.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = spin.tcl; sourceTree = "<group>"; };
-		F966BB5708F27A3A005CB29B /* square */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = square; sourceTree = "<group>"; };
-		F966BB5808F27A3A005CB29B /* states.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = states.tcl; sourceTree = "<group>"; };
-		F966BB5908F27A3A005CB29B /* style.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = style.tcl; sourceTree = "<group>"; };
-		F966BB5A08F27A3A005CB29B /* tclIndex */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tclIndex; sourceTree = "<group>"; };
-		F966BB5B08F27A3A005CB29B /* tcolor */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = tcolor; sourceTree = "<group>"; };
-		F966BB5C08F27A3A005CB29B /* text.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = text.tcl; sourceTree = "<group>"; };
-		F966BB5D08F27A3A005CB29B /* timer */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = timer; sourceTree = "<group>"; };
-		F966BB5E08F27A3A005CB29B /* twind.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = twind.tcl; sourceTree = "<group>"; };
-		F966BB5F08F27A3A005CB29B /* unicodeout.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unicodeout.tcl; sourceTree = "<group>"; };
-		F966BB6008F27A3A005CB29B /* vscale.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = vscale.tcl; sourceTree = "<group>"; };
-		F966BB6108F27A3A005CB29B /* widget */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = widget; sourceTree = "<group>"; };
-		F966BB6208F27A3A005CB29B /* dialog.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = dialog.tcl; sourceTree = "<group>"; };
-		F966BB6308F27A3A005CB29B /* entry.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = entry.tcl; sourceTree = "<group>"; };
-		F966BB6408F27A3A005CB29B /* focus.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = focus.tcl; sourceTree = "<group>"; };
-		F966BB7308F27A3A005CB29B /* listbox.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = listbox.tcl; sourceTree = "<group>"; };
-		F966BB7408F27A3A005CB29B /* menu.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = menu.tcl; sourceTree = "<group>"; };
-		F966BB7508F27A3A005CB29B /* mkpsenc.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = mkpsenc.tcl; sourceTree = "<group>"; };
-		F966BB7608F27A3A005CB29B /* msgbox.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = msgbox.tcl; sourceTree = "<group>"; };
-		F966BB8608F27A3A005CB29B /* obsolete.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = obsolete.tcl; sourceTree = "<group>"; };
-		F966BB8708F27A3A005CB29B /* optMenu.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = optMenu.tcl; sourceTree = "<group>"; };
-		F966BB8808F27A3A005CB29B /* palette.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = palette.tcl; sourceTree = "<group>"; };
-		F966BB8908F27A3B005CB29B /* panedwindow.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = panedwindow.tcl; sourceTree = "<group>"; };
-		F966BB8B08F27A3B005CB29B /* safetk.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = safetk.tcl; sourceTree = "<group>"; };
-		F966BB8C08F27A3B005CB29B /* scale.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = scale.tcl; sourceTree = "<group>"; };
-		F966BB8D08F27A3B005CB29B /* scrlbar.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = scrlbar.tcl; sourceTree = "<group>"; };
-		F966BB8E08F27A3B005CB29B /* spinbox.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = spinbox.tcl; sourceTree = "<group>"; };
-		F966BB8F08F27A3B005CB29B /* tclIndex */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tclIndex; sourceTree = "<group>"; };
-		F966BB9008F27A3B005CB29B /* tearoff.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tearoff.tcl; sourceTree = "<group>"; };
-		F966BB9108F27A3B005CB29B /* text.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = text.tcl; sourceTree = "<group>"; };
-		F966BB9208F27A3B005CB29B /* tk.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tk.tcl; sourceTree = "<group>"; };
-		F966BB9308F27A3B005CB29B /* tkfbox.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tkfbox.tcl; sourceTree = "<group>"; };
-		F966BB9408F27A3B005CB29B /* unsupported.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unsupported.tcl; sourceTree = "<group>"; };
-		F966BB9508F27A3B005CB29B /* xmfbox.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = xmfbox.tcl; sourceTree = "<group>"; };
-		F966BB9608F27A3B005CB29B /* license.terms */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = license.terms; sourceTree = "<group>"; };
-		F966BBBA08F27A3B005CB29B /* configure.ac */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = configure.ac; sourceTree = "<group>"; };
-		F966BBBB08F27A3B005CB29B /* GNUmakefile */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = GNUmakefile; sourceTree = "<group>"; };
-		F966BBBE08F27A3B005CB29B /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F966BBC008F27A3B005CB29B /* Tk-Info.plist.in */ = {isa = PBXFileReference; explicitFileType = text.plist; fileEncoding = 4; path = "Tk-Info.plist.in"; sourceTree = "<group>"; };
-		F966BBC208F27A3B005CB29B /* tkMacOSX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSX.h; sourceTree = "<group>"; };
-		F966BBC508F27A3B005CB29B /* tkMacOSXBitmap.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXBitmap.c; sourceTree = "<group>"; };
-		F966BBC608F27A3B005CB29B /* tkMacOSXButton.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXButton.c; sourceTree = "<group>"; };
-		F966BBC808F27A3B005CB29B /* tkMacOSXClipboard.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXClipboard.c; sourceTree = "<group>"; };
-		F966BBC908F27A3B005CB29B /* tkMacOSXColor.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXColor.c; sourceTree = "<group>"; };
-		F966BBCA08F27A3B005CB29B /* tkMacOSXConfig.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXConfig.c; sourceTree = "<group>"; };
-		F966BBCB08F27A3B005CB29B /* tkMacOSXCursor.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXCursor.c; sourceTree = "<group>"; };
-		F966BBCC08F27A3B005CB29B /* tkMacOSXCursors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXCursors.h; sourceTree = "<group>"; };
-		F966BBCD08F27A3B005CB29B /* tkMacOSXDebug.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXDebug.c; sourceTree = "<group>"; };
-		F966BBCE08F27A3B005CB29B /* tkMacOSXDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXDebug.h; sourceTree = "<group>"; };
-		F966BBCF08F27A3B005CB29B /* tkMacOSXDefault.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXDefault.h; sourceTree = "<group>"; };
-		F966BBD008F27A3B005CB29B /* tkMacOSXDialog.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXDialog.c; sourceTree = "<group>"; };
-		F966BBD108F27A3B005CB29B /* tkMacOSXDraw.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXDraw.c; sourceTree = "<group>"; };
-		F966BBD208F27A3B005CB29B /* tkMacOSXEmbed.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEmbed.c; sourceTree = "<group>"; };
-		F966BBD308F27A3B005CB29B /* tkMacOSXEntry.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEntry.c; sourceTree = "<group>"; };
-		F966BBD408F27A3B005CB29B /* tkMacOSXEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEvent.c; sourceTree = "<group>"; };
-		F966BBD608F27A3B005CB29B /* tkMacOSXFont.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXFont.c; sourceTree = "<group>"; };
-		F966BBD708F27A3B005CB29B /* tkMacOSXHLEvents.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXHLEvents.c; sourceTree = "<group>"; };
-		F966BBD808F27A3B005CB29B /* tkMacOSXInit.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXInit.c; sourceTree = "<group>"; };
-		F966BBDA08F27A3B005CB29B /* tkMacOSXInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXInt.h; sourceTree = "<group>"; };
-		F966BBDB08F27A3B005CB29B /* tkMacOSXKeyboard.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXKeyboard.c; sourceTree = "<group>"; };
-		F966BBDC08F27A3B005CB29B /* tkMacOSXKeyEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXKeyEvent.c; sourceTree = "<group>"; };
-		F966BBDD08F27A3B005CB29B /* tkMacOSXMenu.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXMenu.c; sourceTree = "<group>"; };
-		F966BBE008F27A3B005CB29B /* tkMacOSXMenubutton.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXMenubutton.c; sourceTree = "<group>"; };
-		F966BBE108F27A3B005CB29B /* tkMacOSXMenus.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXMenus.c; sourceTree = "<group>"; };
-		F966BBE208F27A3B005CB29B /* tkMacOSXMouseEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXMouseEvent.c; sourceTree = "<group>"; };
-		F966BBE308F27A3B005CB29B /* tkMacOSXNotify.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXNotify.c; sourceTree = "<group>"; };
-		F966BBEA08F27A3C005CB29B /* tkMacOSXPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXPort.h; sourceTree = "<group>"; };
-		F966BBEB08F27A3C005CB29B /* tkMacOSXRegion.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXRegion.c; sourceTree = "<group>"; };
-		F966BBEC08F27A3C005CB29B /* tkMacOSXScale.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXScale.c; sourceTree = "<group>"; };
-		F966BBED08F27A3C005CB29B /* tkMacOSXScrlbr.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXScrlbr.c; sourceTree = "<group>"; };
-		F966BBEE08F27A3C005CB29B /* tkMacOSXSend.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXSend.c; sourceTree = "<group>"; };
-		F966BBEF08F27A3C005CB29B /* tkMacOSXSubwindows.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXSubwindows.c; sourceTree = "<group>"; };
-		F966BBF008F27A3C005CB29B /* tkMacOSXTest.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXTest.c; sourceTree = "<group>"; };
-		F966BBF108F27A3C005CB29B /* tkMacOSXWindowEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXWindowEvent.c; sourceTree = "<group>"; };
-		F966BBF208F27A3C005CB29B /* tkMacOSXWm.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXWm.c; sourceTree = "<group>"; };
-		F966BBF308F27A3C005CB29B /* tkMacOSXWm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXWm.h; sourceTree = "<group>"; };
-		F966BBF408F27A3C005CB29B /* tkMacOSXXCursors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXXCursors.h; sourceTree = "<group>"; };
-		F966BBF508F27A3C005CB29B /* tkMacOSXXStubs.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXXStubs.c; sourceTree = "<group>"; };
-		F966BBF708F27A3C005CB29B /* Wish-Info.plist.in */ = {isa = PBXFileReference; explicitFileType = text.plist; fileEncoding = 4; path = "Wish-Info.plist.in"; sourceTree = "<group>"; };
-		F966BC0308F27A3C005CB29B /* README */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = README; sourceTree = "<group>"; };
-		F966BC0508F27A3C005CB29B /* all.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = all.tcl; sourceTree = "<group>"; };
-		F966BC0608F27A3C005CB29B /* arc.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = arc.tcl; sourceTree = "<group>"; };
-		F966BC0708F27A3C005CB29B /* bell.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = bell.test; sourceTree = "<group>"; };
-		F966BC0808F27A3C005CB29B /* bevel.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = bevel.tcl; sourceTree = "<group>"; };
-		F966BC0908F27A3C005CB29B /* bgerror.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = bgerror.test; sourceTree = "<group>"; };
-		F966BC0A08F27A3C005CB29B /* bind.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = bind.test; sourceTree = "<group>"; };
-		F966BC0B08F27A3C005CB29B /* bitmap.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = bitmap.test; sourceTree = "<group>"; };
-		F966BC0C08F27A3C005CB29B /* border.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = border.test; sourceTree = "<group>"; };
-		F966BC0D08F27A3C005CB29B /* bugs.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = bugs.tcl; sourceTree = "<group>"; };
-		F966BC0E08F27A3C005CB29B /* butGeom.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = butGeom.tcl; sourceTree = "<group>"; };
-		F966BC0F08F27A3C005CB29B /* butGeom2.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = butGeom2.tcl; sourceTree = "<group>"; };
-		F966BC1008F27A3C005CB29B /* button.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = button.test; sourceTree = "<group>"; };
-		F966BC1108F27A3C005CB29B /* canvas.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = canvas.test; sourceTree = "<group>"; };
-		F966BC1208F27A3C005CB29B /* canvImg.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = canvImg.test; sourceTree = "<group>"; };
-		F966BC1308F27A3C005CB29B /* canvPs.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = canvPs.test; sourceTree = "<group>"; };
-		F966BC1408F27A3C005CB29B /* canvPsArc.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = canvPsArc.tcl; sourceTree = "<group>"; };
-		F966BC1508F27A3C005CB29B /* canvPsBmap.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = canvPsBmap.tcl; sourceTree = "<group>"; };
-		F966BC1608F27A3C005CB29B /* canvPsGrph.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = canvPsGrph.tcl; sourceTree = "<group>"; };
-		F966BC1708F27A3C005CB29B /* canvPsImg.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = canvPsImg.tcl; sourceTree = "<group>"; };
-		F966BC1808F27A3C005CB29B /* canvPsText.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = canvPsText.tcl; sourceTree = "<group>"; };
-		F966BC1908F27A3C005CB29B /* canvRect.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = canvRect.test; sourceTree = "<group>"; };
-		F966BC1A08F27A3C005CB29B /* canvText.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = canvText.test; sourceTree = "<group>"; };
-		F966BC1B08F27A3C005CB29B /* canvWind.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = canvWind.test; sourceTree = "<group>"; };
-		F966BC1C08F27A3C005CB29B /* choosedir.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = choosedir.test; sourceTree = "<group>"; };
-		F966BC1D08F27A3C005CB29B /* clipboard.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = clipboard.test; sourceTree = "<group>"; };
-		F966BC1E08F27A3C005CB29B /* clrpick.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = clrpick.test; sourceTree = "<group>"; };
-		F966BC1F08F27A3C005CB29B /* cmap.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = cmap.tcl; sourceTree = "<group>"; };
-		F966BC2008F27A3C005CB29B /* cmds.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = cmds.test; sourceTree = "<group>"; };
-		F966BC2108F27A3C005CB29B /* color.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = color.test; sourceTree = "<group>"; };
-		F966BC2208F27A3C005CB29B /* config.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = config.test; sourceTree = "<group>"; };
-		F966BC2308F27A3C005CB29B /* constraints.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = constraints.tcl; sourceTree = "<group>"; };
-		F966BC2408F27A3C005CB29B /* cursor.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = cursor.test; sourceTree = "<group>"; };
-		F966BC2508F27A3C005CB29B /* dialog.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = dialog.test; sourceTree = "<group>"; };
-		F966BC2608F27A3C005CB29B /* embed.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = embed.test; sourceTree = "<group>"; };
-		F966BC2708F27A3C005CB29B /* entry.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = entry.test; sourceTree = "<group>"; };
-		F966BC2808F27A3C005CB29B /* event.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = event.test; sourceTree = "<group>"; };
-		F966BC2908F27A3C005CB29B /* filebox.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = filebox.test; sourceTree = "<group>"; };
-		F966BC2A08F27A3C005CB29B /* focus.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = focus.test; sourceTree = "<group>"; };
-		F966BC2B08F27A3C005CB29B /* focusTcl.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = focusTcl.test; sourceTree = "<group>"; };
-		F966BC2C08F27A3C005CB29B /* font.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = font.test; sourceTree = "<group>"; };
-		F966BC2D08F27A3C005CB29B /* frame.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = frame.test; sourceTree = "<group>"; };
-		F966BC2E08F27A3C005CB29B /* geometry.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = geometry.test; sourceTree = "<group>"; };
-		F966BC2F08F27A3C005CB29B /* get.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = get.test; sourceTree = "<group>"; };
-		F966BC3008F27A3C005CB29B /* grab.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = grab.test; sourceTree = "<group>"; };
-		F966BC3108F27A3C005CB29B /* grid.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = grid.test; sourceTree = "<group>"; };
-		F966BC3308F27A3C005CB29B /* image.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = image.test; sourceTree = "<group>"; };
-		F966BC3408F27A3C005CB29B /* imgBmap.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = imgBmap.test; sourceTree = "<group>"; };
-		F966BC3508F27A3C005CB29B /* imgPhoto.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = imgPhoto.test; sourceTree = "<group>"; };
-		F966BC3608F27A3C005CB29B /* imgPPM.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = imgPPM.test; sourceTree = "<group>"; };
-		F966BC3708F27A3C005CB29B /* listbox.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = listbox.test; sourceTree = "<group>"; };
-		F966BC3808F27A3C005CB29B /* main.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = main.test; sourceTree = "<group>"; };
-		F966BC3908F27A3C005CB29B /* menu.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = menu.test; sourceTree = "<group>"; };
-		F966BC3A08F27A3C005CB29B /* menubut.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = menubut.test; sourceTree = "<group>"; };
-		F966BC3B08F27A3C005CB29B /* menuDraw.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = menuDraw.test; sourceTree = "<group>"; };
-		F966BC3C08F27A3C005CB29B /* message.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = message.test; sourceTree = "<group>"; };
-		F966BC3D08F27A3C005CB29B /* msgbox.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = msgbox.test; sourceTree = "<group>"; };
-		F966BC3E08F27A3C005CB29B /* obj.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = obj.test; sourceTree = "<group>"; };
-		F966BC3F08F27A3C005CB29B /* oldpack.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = oldpack.test; sourceTree = "<group>"; };
-		F966BC4008F27A3C005CB29B /* option.file1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = option.file1; sourceTree = "<group>"; };
-		F966BC4108F27A3C005CB29B /* option.file2 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = option.file2; sourceTree = "<group>"; };
-		F966BC4208F27A3C005CB29B /* option.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = option.test; sourceTree = "<group>"; };
-		F966BC4308F27A3C005CB29B /* pack.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pack.test; sourceTree = "<group>"; };
-		F966BC4408F27A3C005CB29B /* panedwindow.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = panedwindow.test; sourceTree = "<group>"; };
-		F966BC4508F27A3D005CB29B /* place.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = place.test; sourceTree = "<group>"; };
-		F966BC4608F27A3D005CB29B /* raise.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = raise.test; sourceTree = "<group>"; };
-		F966BC4708F27A3D005CB29B /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F966BC4808F27A3D005CB29B /* safe.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = safe.test; sourceTree = "<group>"; };
-		F966BC4908F27A3D005CB29B /* scale.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = scale.test; sourceTree = "<group>"; };
-		F966BC4A08F27A3D005CB29B /* scrollbar.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = scrollbar.test; sourceTree = "<group>"; };
-		F966BC4B08F27A3D005CB29B /* select.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = select.test; sourceTree = "<group>"; };
-		F966BC4C08F27A3D005CB29B /* send.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = send.test; sourceTree = "<group>"; };
-		F966BC4D08F27A3D005CB29B /* spinbox.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = spinbox.test; sourceTree = "<group>"; };
-		F966BC4E08F27A3D005CB29B /* text.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = text.test; sourceTree = "<group>"; };
-		F966BC4F08F27A3D005CB29B /* textBTree.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = textBTree.test; sourceTree = "<group>"; };
-		F966BC5008F27A3D005CB29B /* textDisp.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = textDisp.test; sourceTree = "<group>"; };
-		F966BC5108F27A3D005CB29B /* textImage.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = textImage.test; sourceTree = "<group>"; };
-		F966BC5208F27A3D005CB29B /* textIndex.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = textIndex.test; sourceTree = "<group>"; };
-		F966BC5308F27A3D005CB29B /* textMark.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = textMark.test; sourceTree = "<group>"; };
-		F966BC5408F27A3D005CB29B /* textTag.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = textTag.test; sourceTree = "<group>"; };
-		F966BC5508F27A3D005CB29B /* textWind.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = textWind.test; sourceTree = "<group>"; };
-		F966BC5608F27A3D005CB29B /* tk.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tk.test; sourceTree = "<group>"; };
-		F966BC5708F27A3D005CB29B /* unixButton.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unixButton.test; sourceTree = "<group>"; };
-		F966BC5808F27A3D005CB29B /* unixEmbed.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unixEmbed.test; sourceTree = "<group>"; };
-		F966BC5908F27A3D005CB29B /* unixFont.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unixFont.test; sourceTree = "<group>"; };
-		F966BC5A08F27A3D005CB29B /* unixMenu.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unixMenu.test; sourceTree = "<group>"; };
-		F966BC5B08F27A3D005CB29B /* unixSelect.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unixSelect.test; sourceTree = "<group>"; };
-		F966BC5C08F27A3D005CB29B /* unixWm.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unixWm.test; sourceTree = "<group>"; };
-		F966BC5D08F27A3D005CB29B /* util.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = util.test; sourceTree = "<group>"; };
-		F966BC5E08F27A3D005CB29B /* visual.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = visual.test; sourceTree = "<group>"; };
-		F966BC5F08F27A3D005CB29B /* visual_bb.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = visual_bb.test; sourceTree = "<group>"; };
-		F966BC6008F27A3D005CB29B /* winButton.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winButton.test; sourceTree = "<group>"; };
-		F966BC6108F27A3D005CB29B /* winClipboard.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winClipboard.test; sourceTree = "<group>"; };
-		F966BC6208F27A3D005CB29B /* winDialog.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winDialog.test; sourceTree = "<group>"; };
-		F966BC6308F27A3D005CB29B /* window.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = window.test; sourceTree = "<group>"; };
-		F966BC6408F27A3D005CB29B /* winfo.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winfo.test; sourceTree = "<group>"; };
-		F966BC6508F27A3D005CB29B /* winFont.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winFont.test; sourceTree = "<group>"; };
-		F966BC6608F27A3D005CB29B /* winMenu.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winMenu.test; sourceTree = "<group>"; };
-		F966BC6708F27A3D005CB29B /* winSend.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winSend.test; sourceTree = "<group>"; };
-		F966BC6808F27A3D005CB29B /* winWm.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winWm.test; sourceTree = "<group>"; };
-		F966BC6908F27A3D005CB29B /* wm.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = wm.test; sourceTree = "<group>"; };
-		F966BC6A08F27A3D005CB29B /* xmfbox.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = xmfbox.test; sourceTree = "<group>"; };
-		F966BC6C08F27A3D005CB29B /* aclocal.m4 */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = aclocal.m4; sourceTree = "<group>"; };
-		F966BC6D08F27A3D005CB29B /* configure */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = configure; sourceTree = "<group>"; };
-		F966BC6E08F27A3D005CB29B /* configure.ac */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = configure.ac; sourceTree = "<group>"; };
-		F966BC6F08F27A3D005CB29B /* install-sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "install-sh"; sourceTree = "<group>"; };
-		F966BC7008F27A3D005CB29B /* installManPage */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = installManPage; sourceTree = "<group>"; };
-		F966BC7108F27A3D005CB29B /* Makefile.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = Makefile.in; sourceTree = "<group>"; };
-		F966BC7208F27A3D005CB29B /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F966BC7308F27A3D005CB29B /* tcl.m4 */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = tcl.m4; sourceTree = "<group>"; };
-		F966BC7408F27A3D005CB29B /* tk.spec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tk.spec; sourceTree = "<group>"; };
-		F966BC7508F27A3D005CB29B /* tkAppInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkAppInit.c; sourceTree = "<group>"; };
-		F966BC7608F27A3D005CB29B /* tkConfig.h.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = tkConfig.h.in; sourceTree = "<group>"; };
-		F966BC7708F27A3D005CB29B /* tkConfig.sh.in */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = tkConfig.sh.in; sourceTree = "<group>"; };
-		F966BC7808F27A3D005CB29B /* tkUnix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnix.c; sourceTree = "<group>"; };
-		F966BC7908F27A3D005CB29B /* tkUnix3d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnix3d.c; sourceTree = "<group>"; };
-		F966BC7A08F27A3D005CB29B /* tkUnixButton.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixButton.c; sourceTree = "<group>"; };
-		F966BC7B08F27A3D005CB29B /* tkUnixColor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixColor.c; sourceTree = "<group>"; };
-		F966BC7C08F27A3D005CB29B /* tkUnixConfig.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixConfig.c; sourceTree = "<group>"; };
-		F966BC7D08F27A3D005CB29B /* tkUnixCursor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixCursor.c; sourceTree = "<group>"; };
-		F966BC7E08F27A3D005CB29B /* tkUnixDefault.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkUnixDefault.h; sourceTree = "<group>"; };
-		F966BC7F08F27A3D005CB29B /* tkUnixDialog.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixDialog.c; sourceTree = "<group>"; };
-		F966BC8008F27A3D005CB29B /* tkUnixDraw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixDraw.c; sourceTree = "<group>"; };
-		F966BC8108F27A3D005CB29B /* tkUnixEmbed.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixEmbed.c; sourceTree = "<group>"; };
-		F966BC8208F27A3D005CB29B /* tkUnixEvent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixEvent.c; sourceTree = "<group>"; };
-		F966BC8308F27A3D005CB29B /* tkUnixFocus.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixFocus.c; sourceTree = "<group>"; };
-		F966BC8408F27A3D005CB29B /* tkUnixFont.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixFont.c; sourceTree = "<group>"; };
-		F966BC8508F27A3D005CB29B /* tkUnixInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixInit.c; sourceTree = "<group>"; };
-		F966BC8608F27A3D005CB29B /* tkUnixInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkUnixInt.h; sourceTree = "<group>"; };
-		F966BC8708F27A3D005CB29B /* tkUnixKey.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixKey.c; sourceTree = "<group>"; };
-		F966BC8808F27A3D005CB29B /* tkUnixMenu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixMenu.c; sourceTree = "<group>"; };
-		F966BC8908F27A3D005CB29B /* tkUnixMenubu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixMenubu.c; sourceTree = "<group>"; };
-		F966BC8A08F27A3D005CB29B /* tkUnixPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkUnixPort.h; sourceTree = "<group>"; };
-		F966BC8B08F27A3D005CB29B /* tkUnixRFont.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixRFont.c; sourceTree = "<group>"; };
-		F966BC8C08F27A3D005CB29B /* tkUnixScale.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixScale.c; sourceTree = "<group>"; };
-		F966BC8D08F27A3D005CB29B /* tkUnixScrlbr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixScrlbr.c; sourceTree = "<group>"; };
-		F966BC8E08F27A3D005CB29B /* tkUnixSelect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixSelect.c; sourceTree = "<group>"; };
-		F966BC8F08F27A3D005CB29B /* tkUnixSend.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixSend.c; sourceTree = "<group>"; };
-		F966BC9008F27A3D005CB29B /* tkUnixWm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixWm.c; sourceTree = "<group>"; };
-		F966BC9108F27A3D005CB29B /* tkUnixXId.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkUnixXId.c; sourceTree = "<group>"; };
-		F966BC9408F27A3D005CB29B /* aclocal.m4 */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = aclocal.m4; sourceTree = "<group>"; };
-		F966BC9508F27A3D005CB29B /* buildall.vc.bat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = buildall.vc.bat; sourceTree = "<group>"; };
-		F966BC9608F27A3E005CB29B /* configure */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = configure; sourceTree = "<group>"; };
-		F966BC9708F27A3E005CB29B /* configure.ac */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = configure.ac; sourceTree = "<group>"; };
-		F966BC9908F27A3E005CB29B /* Makefile.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = Makefile.in; sourceTree = "<group>"; };
-		F966BC9A08F27A3E005CB29B /* makefile.vc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.vc; sourceTree = "<group>"; };
-		F966BC9C08F27A3E005CB29B /* nmakehlp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nmakehlp.c; sourceTree = "<group>"; };
-		F966BCEE08F27A3E005CB29B /* tk.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tk.rc; sourceTree = "<group>"; };
-		F966BCEF08F27A3E005CB29B /* tk_base.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tk_base.rc; sourceTree = "<group>"; };
-		F966BCF208F27A3E005CB29B /* wish.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = wish.rc; sourceTree = "<group>"; };
-		F966BCF308F27A3E005CB29B /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F966BCF508F27A3F005CB29B /* rules.vc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rules.vc; sourceTree = "<group>"; };
-		F966BCF608F27A3F005CB29B /* stubs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stubs.c; sourceTree = "<group>"; };
-		F966BCF708F27A3F005CB29B /* tcl.m4 */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = tcl.m4; sourceTree = "<group>"; };
-		F966BCF808F27A3F005CB29B /* tkConfig.sh.in */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = tkConfig.sh.in; sourceTree = "<group>"; };
-		F966BCF908F27A3F005CB29B /* tkWin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkWin.h; sourceTree = "<group>"; };
-		F966BCFA08F27A3F005CB29B /* tkWin32Dll.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWin32Dll.c; sourceTree = "<group>"; };
-		F966BCFB08F27A3F005CB29B /* tkWin3d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWin3d.c; sourceTree = "<group>"; };
-		F966BCFC08F27A3F005CB29B /* tkWinButton.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinButton.c; sourceTree = "<group>"; };
-		F966BCFD08F27A3F005CB29B /* tkWinClipboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinClipboard.c; sourceTree = "<group>"; };
-		F966BCFE08F27A3F005CB29B /* tkWinColor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinColor.c; sourceTree = "<group>"; };
-		F966BCFF08F27A3F005CB29B /* tkWinConfig.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinConfig.c; sourceTree = "<group>"; };
-		F966BD0008F27A3F005CB29B /* tkWinCursor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinCursor.c; sourceTree = "<group>"; };
-		F966BD0108F27A3F005CB29B /* tkWinDefault.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkWinDefault.h; sourceTree = "<group>"; };
-		F966BD0208F27A3F005CB29B /* tkWinDialog.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinDialog.c; sourceTree = "<group>"; };
-		F966BD0308F27A3F005CB29B /* tkWinDraw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinDraw.c; sourceTree = "<group>"; };
-		F966BD0408F27A3F005CB29B /* tkWinEmbed.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinEmbed.c; sourceTree = "<group>"; };
-		F966BD0508F27A3F005CB29B /* tkWinFont.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinFont.c; sourceTree = "<group>"; };
-		F966BD0708F27A3F005CB29B /* tkWinImage.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinImage.c; sourceTree = "<group>"; };
-		F966BD0808F27A3F005CB29B /* tkWinInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinInit.c; sourceTree = "<group>"; };
-		F966BD0908F27A3F005CB29B /* tkWinInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkWinInt.h; sourceTree = "<group>"; };
-		F966BD0A08F27A3F005CB29B /* tkWinKey.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinKey.c; sourceTree = "<group>"; };
-		F966BD0B08F27A3F005CB29B /* tkWinMenu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinMenu.c; sourceTree = "<group>"; };
-		F966BD0C08F27A3F005CB29B /* tkWinPixmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinPixmap.c; sourceTree = "<group>"; };
-		F966BD0D08F27A3F005CB29B /* tkWinPointer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinPointer.c; sourceTree = "<group>"; };
-		F966BD0E08F27A3F005CB29B /* tkWinPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkWinPort.h; sourceTree = "<group>"; };
-		F966BD0F08F27A3F005CB29B /* tkWinRegion.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinRegion.c; sourceTree = "<group>"; };
-		F966BD1008F27A3F005CB29B /* tkWinScrlbr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinScrlbr.c; sourceTree = "<group>"; };
-		F966BD1108F27A3F005CB29B /* tkWinSend.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinSend.c; sourceTree = "<group>"; };
-		F966BD1208F27A3F005CB29B /* tkWinSendCom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinSendCom.c; sourceTree = "<group>"; };
-		F966BD1308F27A3F005CB29B /* tkWinSendCom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkWinSendCom.h; sourceTree = "<group>"; };
-		F966BD1408F27A3F005CB29B /* tkWinTest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinTest.c; sourceTree = "<group>"; };
-		F966BD1508F27A3F005CB29B /* tkWinWindow.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinWindow.c; sourceTree = "<group>"; };
-		F966BD1608F27A3F005CB29B /* tkWinWm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinWm.c; sourceTree = "<group>"; };
-		F966BD1708F27A3F005CB29B /* tkWinX.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkWinX.c; sourceTree = "<group>"; };
-		F966BD1808F27A3F005CB29B /* winMain.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = winMain.c; sourceTree = "<group>"; };
-		F966BD1B08F27A3F005CB29B /* cursorfont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cursorfont.h; sourceTree = "<group>"; };
-		F966BD1C08F27A3F005CB29B /* keysym.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keysym.h; sourceTree = "<group>"; };
-		F966BD1D08F27A3F005CB29B /* keysymdef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keysymdef.h; sourceTree = "<group>"; };
-		F966BD1E08F27A3F005CB29B /* X.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = X.h; sourceTree = "<group>"; };
-		F966BD1F08F27A3F005CB29B /* Xatom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Xatom.h; sourceTree = "<group>"; };
-		F966BD2008F27A3F005CB29B /* Xfuncproto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Xfuncproto.h; sourceTree = "<group>"; };
-		F966BD2108F27A3F005CB29B /* Xlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Xlib.h; sourceTree = "<group>"; };
-		F966BD2208F27A3F005CB29B /* Xutil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Xutil.h; sourceTree = "<group>"; };
-		F966BD2308F27A3F005CB29B /* xbytes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xbytes.h; sourceTree = "<group>"; };
-		F966BD2408F27A3F005CB29B /* xcolors.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xcolors.c; sourceTree = "<group>"; };
-		F966BD2508F27A3F005CB29B /* xdraw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xdraw.c; sourceTree = "<group>"; };
-		F966BD2608F27A3F005CB29B /* xgc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xgc.c; sourceTree = "<group>"; };
-		F966BD2708F27A3F005CB29B /* ximage.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ximage.c; sourceTree = "<group>"; };
-		F966BD2808F27A3F005CB29B /* xutil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xutil.c; sourceTree = "<group>"; };
-		F966C07408F2820D005CB29B /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
-		F966C07608F2821B005CB29B /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
-		F966C07808F28233005CB29B /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = "<absolute>"; };
-		F96887E00AF786D5000797B5 /* ttk.decls */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = ttk.decls; sourceTree = "<group>"; };
-		F96887E10AF786D5000797B5 /* ttkBlink.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkBlink.c; sourceTree = "<group>"; };
-		F96887E20AF786D5000797B5 /* ttkButton.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkButton.c; sourceTree = "<group>"; };
-		F96887E30AF786D5000797B5 /* ttkCache.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkCache.c; sourceTree = "<group>"; };
-		F96887E40AF786D5000797B5 /* ttkClamTheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkClamTheme.c; sourceTree = "<group>"; };
-		F96887E50AF786D5000797B5 /* ttkClassicTheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkClassicTheme.c; sourceTree = "<group>"; };
-		F96887E60AF786D5000797B5 /* ttkDecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttkDecls.h; sourceTree = "<group>"; };
-		F96887E70AF786D5000797B5 /* ttkDefaultTheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkDefaultTheme.c; sourceTree = "<group>"; };
-		F96887E80AF786D5000797B5 /* ttkElements.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkElements.c; sourceTree = "<group>"; };
-		F96887E90AF786D5000797B5 /* ttkEntry.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkEntry.c; sourceTree = "<group>"; };
-		F96887EA0AF786D5000797B5 /* ttkFrame.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkFrame.c; sourceTree = "<group>"; };
-		F96887EB0AF786D5000797B5 /* ttkImage.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkImage.c; sourceTree = "<group>"; };
-		F96887EC0AF786D5000797B5 /* ttkInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkInit.c; sourceTree = "<group>"; };
-		F96887ED0AF786D5000797B5 /* ttkLabel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkLabel.c; sourceTree = "<group>"; };
-		F96887EE0AF786D5000797B5 /* ttkLayout.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkLayout.c; sourceTree = "<group>"; };
-		F96887EF0AF786D5000797B5 /* ttkManager.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkManager.c; sourceTree = "<group>"; };
-		F96887F00AF786D5000797B5 /* ttkManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttkManager.h; sourceTree = "<group>"; };
-		F96887F10AF786D5000797B5 /* ttkNotebook.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkNotebook.c; sourceTree = "<group>"; };
-		F96887F20AF786D5000797B5 /* ttkPanedwindow.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkPanedwindow.c; sourceTree = "<group>"; };
-		F96887F30AF786D5000797B5 /* ttkProgress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkProgress.c; sourceTree = "<group>"; };
-		F96887F40AF786D5000797B5 /* ttkScale.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkScale.c; sourceTree = "<group>"; };
-		F96887F50AF786D5000797B5 /* ttkScroll.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkScroll.c; sourceTree = "<group>"; };
-		F96887F60AF786D5000797B5 /* ttkScrollbar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkScrollbar.c; sourceTree = "<group>"; };
-		F96887F70AF786D5000797B5 /* ttkSeparator.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkSeparator.c; sourceTree = "<group>"; };
-		F96887F80AF786D5000797B5 /* ttkSquare.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkSquare.c; sourceTree = "<group>"; };
-		F96887F90AF786D5000797B5 /* ttkState.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkState.c; sourceTree = "<group>"; };
-		F96887FA0AF786D5000797B5 /* ttkStubInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkStubInit.c; sourceTree = "<group>"; };
-		F96887FB0AF786D5000797B5 /* ttkStubLib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkStubLib.c; sourceTree = "<group>"; };
-		F96887FC0AF786D5000797B5 /* ttkTagSet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkTagSet.c; sourceTree = "<group>"; };
-		F96887FD0AF786D5000797B5 /* ttkTheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkTheme.c; sourceTree = "<group>"; };
-		F96887FE0AF786D5000797B5 /* ttkTheme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttkTheme.h; sourceTree = "<group>"; };
-		F96887FF0AF786D5000797B5 /* ttkThemeInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttkThemeInt.h; sourceTree = "<group>"; };
-		F96888000AF786D5000797B5 /* ttkTrace.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkTrace.c; sourceTree = "<group>"; };
-		F96888010AF786D5000797B5 /* ttkTrack.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkTrack.c; sourceTree = "<group>"; };
-		F96888020AF786D5000797B5 /* ttkTreeview.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkTreeview.c; sourceTree = "<group>"; };
-		F96888030AF786D5000797B5 /* ttkWidget.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkWidget.c; sourceTree = "<group>"; };
-		F96888040AF786D5000797B5 /* ttkWidget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttkWidget.h; sourceTree = "<group>"; };
-		F96888370AF787B3000797B5 /* altTheme.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = altTheme.tcl; sourceTree = "<group>"; };
-		F96888380AF787B3000797B5 /* aquaTheme.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = aquaTheme.tcl; sourceTree = "<group>"; };
-		F96888390AF787B3000797B5 /* button.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = button.tcl; sourceTree = "<group>"; };
-		F968883A0AF787B3000797B5 /* clamTheme.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = clamTheme.tcl; sourceTree = "<group>"; };
-		F968883B0AF787B3000797B5 /* classicTheme.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = classicTheme.tcl; sourceTree = "<group>"; };
-		F968883C0AF787B3000797B5 /* combobox.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = combobox.tcl; sourceTree = "<group>"; };
-		F968883D0AF787B3000797B5 /* cursors.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = cursors.tcl; sourceTree = "<group>"; };
-		F968883E0AF787B3000797B5 /* defaults.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = defaults.tcl; sourceTree = "<group>"; };
-		F96888400AF787B3000797B5 /* entry.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = entry.tcl; sourceTree = "<group>"; };
-		F96888410AF787B3000797B5 /* fonts.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = fonts.tcl; sourceTree = "<group>"; };
-		F96888440AF787B3000797B5 /* menubutton.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = menubutton.tcl; sourceTree = "<group>"; };
-		F96888450AF787B3000797B5 /* notebook.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = notebook.tcl; sourceTree = "<group>"; };
-		F96888460AF787B3000797B5 /* panedwindow.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = panedwindow.tcl; sourceTree = "<group>"; };
-		F96888470AF787B3000797B5 /* progress.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = progress.tcl; sourceTree = "<group>"; };
-		F96888480AF787B3000797B5 /* scale.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = scale.tcl; sourceTree = "<group>"; };
-		F96888490AF787B3000797B5 /* scrollbar.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = scrollbar.tcl; sourceTree = "<group>"; };
-		F968884A0AF787B3000797B5 /* sizegrip.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = sizegrip.tcl; sourceTree = "<group>"; };
-		F968884B0AF787B3000797B5 /* treeview.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = treeview.tcl; sourceTree = "<group>"; };
-		F968884C0AF787B3000797B5 /* ttk.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = ttk.tcl; sourceTree = "<group>"; };
-		F968884D0AF787B3000797B5 /* utils.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = utils.tcl; sourceTree = "<group>"; };
-		F968884E0AF787B3000797B5 /* winTheme.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winTheme.tcl; sourceTree = "<group>"; };
-		F968884F0AF787B3000797B5 /* xpTheme.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = xpTheme.tcl; sourceTree = "<group>"; };
-		F96888540AF7880C000797B5 /* all.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = all.tcl; sourceTree = "<group>"; };
-		F96888560AF7880C000797B5 /* combobox.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = combobox.test; sourceTree = "<group>"; };
-		F96888570AF7880C000797B5 /* entry.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = entry.test; sourceTree = "<group>"; };
-		F96888580AF7880C000797B5 /* image.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = image.test; sourceTree = "<group>"; };
-		F96888590AF7880C000797B5 /* labelframe.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = labelframe.test; sourceTree = "<group>"; };
-		F968885A0AF7880C000797B5 /* layout.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = layout.test; sourceTree = "<group>"; };
-		F968885C0AF7880C000797B5 /* notebook.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = notebook.test; sourceTree = "<group>"; };
-		F968885D0AF7880C000797B5 /* panedwindow.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = panedwindow.test; sourceTree = "<group>"; };
-		F968885E0AF7880C000797B5 /* progressbar.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = progressbar.test; sourceTree = "<group>"; };
-		F968885F0AF7880C000797B5 /* scrollbar.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = scrollbar.test; sourceTree = "<group>"; };
-		F96888600AF7880C000797B5 /* treetags.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = treetags.test; sourceTree = "<group>"; };
-		F96888610AF7880C000797B5 /* treeview.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = treeview.test; sourceTree = "<group>"; };
-		F96888620AF7880C000797B5 /* ttk.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = ttk.test; sourceTree = "<group>"; };
-		F96888630AF7880C000797B5 /* validate.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = validate.test; sourceTree = "<group>"; };
-		F968886B0AF788F6000797B5 /* ttk_button.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_button.n; sourceTree = "<group>"; };
-		F968886C0AF788F6000797B5 /* ttk_checkbutton.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_checkbutton.n; sourceTree = "<group>"; };
-		F968886D0AF788F6000797B5 /* ttk_combobox.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_combobox.n; sourceTree = "<group>"; };
-		F968886F0AF788F6000797B5 /* ttk_entry.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_entry.n; sourceTree = "<group>"; };
-		F96888700AF788F6000797B5 /* ttk_frame.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_frame.n; sourceTree = "<group>"; };
-		F96888710AF788F6000797B5 /* ttk_Geometry.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_Geometry.3; sourceTree = "<group>"; };
-		F96888720AF788F6000797B5 /* ttk_image.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_image.n; sourceTree = "<group>"; };
-		F96888730AF788F6000797B5 /* ttk_intro.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_intro.n; sourceTree = "<group>"; };
-		F96888740AF788F6000797B5 /* ttk_label.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_label.n; sourceTree = "<group>"; };
-		F96888750AF788F6000797B5 /* ttk_labelframe.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_labelframe.n; sourceTree = "<group>"; };
-		F96888760AF788F6000797B5 /* ttk_menubutton.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_menubutton.n; sourceTree = "<group>"; };
-		F96888770AF788F6000797B5 /* ttk_notebook.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_notebook.n; sourceTree = "<group>"; };
-		F96888780AF788F6000797B5 /* ttk_panedwindow.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_panedwindow.n; sourceTree = "<group>"; };
-		F96888790AF788F6000797B5 /* ttk_progressbar.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_progressbar.n; sourceTree = "<group>"; };
-		F968887A0AF788F6000797B5 /* ttk_radiobutton.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_radiobutton.n; sourceTree = "<group>"; };
-		F968887B0AF788F6000797B5 /* ttk_scrollbar.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_scrollbar.n; sourceTree = "<group>"; };
-		F968887C0AF788F6000797B5 /* ttk_separator.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_separator.n; sourceTree = "<group>"; };
-		F968887D0AF788F6000797B5 /* ttk_sizegrip.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_sizegrip.n; sourceTree = "<group>"; };
-		F968887E0AF788F6000797B5 /* ttk_style.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_style.n; sourceTree = "<group>"; };
-		F968887F0AF788F6000797B5 /* ttk_Theme.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_Theme.3; sourceTree = "<group>"; };
-		F96888800AF788F6000797B5 /* ttk_treeview.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_treeview.n; sourceTree = "<group>"; };
-		F96888810AF788F6000797B5 /* ttk_widget.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ttk_widget.n; sourceTree = "<group>"; };
-		F96888840AF78938000797B5 /* ttkMacOSXTheme.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = ttkMacOSXTheme.c; sourceTree = "<group>"; };
-		F96888860AF78953000797B5 /* ttkWinMonitor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkWinMonitor.c; sourceTree = "<group>"; };
-		F96888870AF78953000797B5 /* ttkWinTheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkWinTheme.c; sourceTree = "<group>"; };
-		F96888880AF78953000797B5 /* ttkWinXPTheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkWinXPTheme.c; sourceTree = "<group>"; };
-		F96D3DFA08F272A4004A47F5 /* ChangeLog */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = ChangeLog; sourceTree = "<group>"; };
-		F96D3DFB08F272A4004A47F5 /* changes */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = changes; sourceTree = "<group>"; };
-		F96D3DFD08F272A4004A47F5 /* Access.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Access.3; sourceTree = "<group>"; };
-		F96D3DFE08F272A4004A47F5 /* AddErrInfo.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = AddErrInfo.3; sourceTree = "<group>"; };
-		F96D3DFF08F272A4004A47F5 /* after.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = after.n; sourceTree = "<group>"; };
-		F96D3E0008F272A4004A47F5 /* Alloc.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Alloc.3; sourceTree = "<group>"; };
-		F96D3E0108F272A4004A47F5 /* AllowExc.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = AllowExc.3; sourceTree = "<group>"; };
-		F96D3E0208F272A4004A47F5 /* append.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = append.n; sourceTree = "<group>"; };
-		F96D3E0308F272A4004A47F5 /* AppInit.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = AppInit.3; sourceTree = "<group>"; };
-		F96D3E0408F272A5004A47F5 /* array.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = array.n; sourceTree = "<group>"; };
-		F96D3E0508F272A5004A47F5 /* AssocData.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = AssocData.3; sourceTree = "<group>"; };
-		F96D3E0608F272A5004A47F5 /* Async.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Async.3; sourceTree = "<group>"; };
-		F96D3E0708F272A5004A47F5 /* BackgdErr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = BackgdErr.3; sourceTree = "<group>"; };
-		F96D3E0808F272A5004A47F5 /* Backslash.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Backslash.3; sourceTree = "<group>"; };
-		F96D3E0908F272A5004A47F5 /* bgerror.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = bgerror.n; sourceTree = "<group>"; };
-		F96D3E0A08F272A5004A47F5 /* binary.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = binary.n; sourceTree = "<group>"; };
-		F96D3E0B08F272A5004A47F5 /* BoolObj.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = BoolObj.3; sourceTree = "<group>"; };
-		F96D3E0C08F272A5004A47F5 /* break.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = break.n; sourceTree = "<group>"; };
-		F96D3E0D08F272A5004A47F5 /* ByteArrObj.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ByteArrObj.3; sourceTree = "<group>"; };
-		F96D3E0E08F272A5004A47F5 /* CallDel.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CallDel.3; sourceTree = "<group>"; };
-		F96D3E0F08F272A5004A47F5 /* case.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = case.n; sourceTree = "<group>"; };
-		F96D3E1008F272A5004A47F5 /* catch.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = catch.n; sourceTree = "<group>"; };
-		F96D3E1108F272A5004A47F5 /* cd.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = cd.n; sourceTree = "<group>"; };
-		F96D3E1208F272A5004A47F5 /* chan.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = chan.n; sourceTree = "<group>"; };
-		F96D3E1308F272A5004A47F5 /* ChnlStack.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ChnlStack.3; sourceTree = "<group>"; };
-		F96D3E1408F272A5004A47F5 /* clock.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = clock.n; sourceTree = "<group>"; };
-		F96D3E1508F272A5004A47F5 /* close.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = close.n; sourceTree = "<group>"; };
-		F96D3E1608F272A5004A47F5 /* CmdCmplt.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CmdCmplt.3; sourceTree = "<group>"; };
-		F96D3E1708F272A5004A47F5 /* Concat.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Concat.3; sourceTree = "<group>"; };
-		F96D3E1808F272A5004A47F5 /* concat.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = concat.n; sourceTree = "<group>"; };
-		F96D3E1908F272A5004A47F5 /* continue.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = continue.n; sourceTree = "<group>"; };
-		F96D3E1A08F272A5004A47F5 /* CrtChannel.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtChannel.3; sourceTree = "<group>"; };
-		F96D3E1B08F272A5004A47F5 /* CrtChnlHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtChnlHdlr.3; sourceTree = "<group>"; };
-		F96D3E1C08F272A5004A47F5 /* CrtCloseHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtCloseHdlr.3; sourceTree = "<group>"; };
-		F96D3E1D08F272A5004A47F5 /* CrtCommand.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtCommand.3; sourceTree = "<group>"; };
-		F96D3E1E08F272A5004A47F5 /* CrtFileHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtFileHdlr.3; sourceTree = "<group>"; };
-		F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtInterp.3; sourceTree = "<group>"; };
-		F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtMathFnc.3; sourceTree = "<group>"; };
-		F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtObjCmd.3; sourceTree = "<group>"; };
-		F96D3E2208F272A5004A47F5 /* CrtAlias.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtAlias.3; sourceTree = "<group>"; };
-		F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTimerHdlr.3; sourceTree = "<group>"; };
-		F96D3E2408F272A5004A47F5 /* CrtTrace.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTrace.3; sourceTree = "<group>"; };
-		F96D3E2508F272A5004A47F5 /* dde.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = dde.n; sourceTree = "<group>"; };
-		F96D3E2608F272A5004A47F5 /* DetachPids.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = DetachPids.3; sourceTree = "<group>"; };
-		F96D3E2708F272A5004A47F5 /* dict.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = dict.n; sourceTree = "<group>"; };
-		F96D3E2808F272A5004A47F5 /* DictObj.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = DictObj.3; sourceTree = "<group>"; };
-		F96D3E2908F272A5004A47F5 /* DoOneEvent.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = DoOneEvent.3; sourceTree = "<group>"; };
-		F96D3E2A08F272A5004A47F5 /* DoubleObj.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = DoubleObj.3; sourceTree = "<group>"; };
-		F96D3E2B08F272A5004A47F5 /* DoWhenIdle.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = DoWhenIdle.3; sourceTree = "<group>"; };
-		F96D3E2C08F272A5004A47F5 /* DString.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = DString.3; sourceTree = "<group>"; };
-		F96D3E2D08F272A5004A47F5 /* DumpActiveMemory.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = DumpActiveMemory.3; sourceTree = "<group>"; };
-		F96D3E2E08F272A5004A47F5 /* Encoding.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Encoding.3; sourceTree = "<group>"; };
-		F96D3E2F08F272A5004A47F5 /* encoding.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = encoding.n; sourceTree = "<group>"; };
-		F96D3E3008F272A5004A47F5 /* Ensemble.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Ensemble.3; sourceTree = "<group>"; };
-		F96D3E3108F272A5004A47F5 /* Environment.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Environment.3; sourceTree = "<group>"; };
-		F96D3E3208F272A5004A47F5 /* eof.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = eof.n; sourceTree = "<group>"; };
-		F96D3E3308F272A5004A47F5 /* error.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = error.n; sourceTree = "<group>"; };
-		F96D3E3408F272A5004A47F5 /* Eval.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Eval.3; sourceTree = "<group>"; };
-		F96D3E3508F272A5004A47F5 /* eval.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = eval.n; sourceTree = "<group>"; };
-		F96D3E3608F272A5004A47F5 /* exec.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = exec.n; sourceTree = "<group>"; };
-		F96D3E3708F272A5004A47F5 /* Exit.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Exit.3; sourceTree = "<group>"; };
-		F96D3E3808F272A5004A47F5 /* exit.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = exit.n; sourceTree = "<group>"; };
-		F96D3E3908F272A5004A47F5 /* expr.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = expr.n; sourceTree = "<group>"; };
-		F96D3E3A08F272A5004A47F5 /* ExprLong.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ExprLong.3; sourceTree = "<group>"; };
-		F96D3E3B08F272A5004A47F5 /* ExprLongObj.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ExprLongObj.3; sourceTree = "<group>"; };
-		F96D3E3C08F272A5004A47F5 /* fblocked.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = fblocked.n; sourceTree = "<group>"; };
-		F96D3E3D08F272A5004A47F5 /* fconfigure.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = fconfigure.n; sourceTree = "<group>"; };
-		F96D3E3E08F272A5004A47F5 /* fcopy.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = fcopy.n; sourceTree = "<group>"; };
-		F96D3E3F08F272A5004A47F5 /* file.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = file.n; sourceTree = "<group>"; };
-		F96D3E4008F272A5004A47F5 /* fileevent.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = fileevent.n; sourceTree = "<group>"; };
-		F96D3E4108F272A5004A47F5 /* filename.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = filename.n; sourceTree = "<group>"; };
-		F96D3E4208F272A5004A47F5 /* FileSystem.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = FileSystem.3; sourceTree = "<group>"; };
-		F96D3E4308F272A5004A47F5 /* FindExec.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = FindExec.3; sourceTree = "<group>"; };
-		F96D3E4408F272A5004A47F5 /* flush.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = flush.n; sourceTree = "<group>"; };
-		F96D3E4508F272A5004A47F5 /* for.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = for.n; sourceTree = "<group>"; };
-		F96D3E4608F272A5004A47F5 /* foreach.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = foreach.n; sourceTree = "<group>"; };
-		F96D3E4708F272A5004A47F5 /* format.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = format.n; sourceTree = "<group>"; };
-		F96D3E4808F272A5004A47F5 /* GetCwd.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetCwd.3; sourceTree = "<group>"; };
-		F96D3E4908F272A5004A47F5 /* GetHostName.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetHostName.3; sourceTree = "<group>"; };
-		F96D3E4A08F272A5004A47F5 /* GetIndex.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetIndex.3; sourceTree = "<group>"; };
-		F96D3E4B08F272A5004A47F5 /* GetInt.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetInt.3; sourceTree = "<group>"; };
-		F96D3E4C08F272A5004A47F5 /* GetOpnFl.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetOpnFl.3; sourceTree = "<group>"; };
-		F96D3E4D08F272A5004A47F5 /* gets.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = gets.n; sourceTree = "<group>"; };
-		F96D3E4E08F272A5004A47F5 /* GetStdChan.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetStdChan.3; sourceTree = "<group>"; };
-		F96D3E4F08F272A5004A47F5 /* GetTime.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetTime.3; sourceTree = "<group>"; };
-		F96D3E5008F272A5004A47F5 /* GetVersion.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = GetVersion.3; sourceTree = "<group>"; };
-		F96D3E5108F272A5004A47F5 /* glob.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = glob.n; sourceTree = "<group>"; };
-		F96D3E5208F272A6004A47F5 /* global.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = global.n; sourceTree = "<group>"; };
-		F96D3E5308F272A6004A47F5 /* Hash.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Hash.3; sourceTree = "<group>"; };
-		F96D3E5408F272A6004A47F5 /* history.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = history.n; sourceTree = "<group>"; };
-		F96D3E5508F272A6004A47F5 /* http.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = http.n; sourceTree = "<group>"; };
-		F96D3E5608F272A6004A47F5 /* if.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = if.n; sourceTree = "<group>"; };
-		F96D3E5708F272A6004A47F5 /* incr.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = incr.n; sourceTree = "<group>"; };
-		F96D3E5808F272A6004A47F5 /* info.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = info.n; sourceTree = "<group>"; };
-		F96D3E5908F272A6004A47F5 /* Init.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Init.3; sourceTree = "<group>"; };
-		F96D3E5A08F272A6004A47F5 /* InitStubs.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = InitStubs.3; sourceTree = "<group>"; };
-		F96D3E5B08F272A6004A47F5 /* Interp.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Interp.3; sourceTree = "<group>"; };
-		F96D3E5C08F272A6004A47F5 /* interp.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = interp.n; sourceTree = "<group>"; };
-		F96D3E5D08F272A6004A47F5 /* IntObj.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = IntObj.3; sourceTree = "<group>"; };
-		F96D3E5E08F272A6004A47F5 /* join.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = join.n; sourceTree = "<group>"; };
-		F96D3E5F08F272A6004A47F5 /* lappend.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = lappend.n; sourceTree = "<group>"; };
-		F96D3E6008F272A6004A47F5 /* lassign.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = lassign.n; sourceTree = "<group>"; };
-		F96D3E6108F272A6004A47F5 /* library.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = library.n; sourceTree = "<group>"; };
-		F96D3E6208F272A6004A47F5 /* Limit.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Limit.3; sourceTree = "<group>"; };
-		F96D3E6308F272A6004A47F5 /* lindex.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = lindex.n; sourceTree = "<group>"; };
-		F96D3E6408F272A6004A47F5 /* LinkVar.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = LinkVar.3; sourceTree = "<group>"; };
-		F96D3E6508F272A6004A47F5 /* linsert.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = linsert.n; sourceTree = "<group>"; };
-		F96D3E6608F272A6004A47F5 /* list.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = list.n; sourceTree = "<group>"; };
-		F96D3E6708F272A6004A47F5 /* ListObj.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ListObj.3; sourceTree = "<group>"; };
-		F96D3E6808F272A6004A47F5 /* llength.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = llength.n; sourceTree = "<group>"; };
-		F96D3E6908F272A6004A47F5 /* load.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = load.n; sourceTree = "<group>"; };
-		F96D3E6A08F272A6004A47F5 /* lrange.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = lrange.n; sourceTree = "<group>"; };
-		F96D3E6B08F272A6004A47F5 /* lrepeat.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = lrepeat.n; sourceTree = "<group>"; };
-		F96D3E6C08F272A6004A47F5 /* lreplace.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = lreplace.n; sourceTree = "<group>"; };
-		F96D3E6D08F272A6004A47F5 /* lsearch.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = lsearch.n; sourceTree = "<group>"; };
-		F96D3E6E08F272A6004A47F5 /* lset.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = lset.n; sourceTree = "<group>"; };
-		F96D3E6F08F272A6004A47F5 /* lsort.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = lsort.n; sourceTree = "<group>"; };
-		F96D3E7008F272A6004A47F5 /* man.macros */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = man.macros; sourceTree = "<group>"; };
-		F96D3E7108F272A6004A47F5 /* mathfunc.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = mathfunc.n; sourceTree = "<group>"; };
-		F96D3E7208F272A6004A47F5 /* memory.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = memory.n; sourceTree = "<group>"; };
-		F96D3E7308F272A6004A47F5 /* msgcat.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = msgcat.n; sourceTree = "<group>"; };
-		F96D3E7408F272A6004A47F5 /* Namespace.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Namespace.3; sourceTree = "<group>"; };
-		F96D3E7508F272A6004A47F5 /* namespace.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = namespace.n; sourceTree = "<group>"; };
-		F96D3E7608F272A6004A47F5 /* Notifier.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Notifier.3; sourceTree = "<group>"; };
-		F96D3E7708F272A6004A47F5 /* Object.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Object.3; sourceTree = "<group>"; };
-		F96D3E7808F272A6004A47F5 /* ObjectType.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ObjectType.3; sourceTree = "<group>"; };
-		F96D3E7908F272A6004A47F5 /* open.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = open.n; sourceTree = "<group>"; };
-		F96D3E7A08F272A6004A47F5 /* OpenFileChnl.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = OpenFileChnl.3; sourceTree = "<group>"; };
-		F96D3E7B08F272A6004A47F5 /* OpenTcp.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = OpenTcp.3; sourceTree = "<group>"; };
-		F96D3E7C08F272A6004A47F5 /* package.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = package.n; sourceTree = "<group>"; };
-		F96D3E7D08F272A6004A47F5 /* packagens.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = packagens.n; sourceTree = "<group>"; };
-		F96D3E7E08F272A6004A47F5 /* Panic.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Panic.3; sourceTree = "<group>"; };
-		F96D3E7F08F272A6004A47F5 /* ParseCmd.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ParseCmd.3; sourceTree = "<group>"; };
-		F96D3E8008F272A6004A47F5 /* pid.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = pid.n; sourceTree = "<group>"; };
-		F96D3E8108F272A6004A47F5 /* pkgMkIndex.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = pkgMkIndex.n; sourceTree = "<group>"; };
-		F96D3E8208F272A6004A47F5 /* PkgRequire.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = PkgRequire.3; sourceTree = "<group>"; };
-		F96D3E8308F272A6004A47F5 /* Preserve.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Preserve.3; sourceTree = "<group>"; };
-		F96D3E8408F272A6004A47F5 /* PrintDbl.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = PrintDbl.3; sourceTree = "<group>"; };
-		F96D3E8508F272A6004A47F5 /* proc.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = proc.n; sourceTree = "<group>"; };
-		F96D3E8608F272A6004A47F5 /* puts.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = puts.n; sourceTree = "<group>"; };
-		F96D3E8708F272A6004A47F5 /* pwd.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = pwd.n; sourceTree = "<group>"; };
-		F96D3E8808F272A6004A47F5 /* re_syntax.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = re_syntax.n; sourceTree = "<group>"; };
-		F96D3E8908F272A6004A47F5 /* read.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = read.n; sourceTree = "<group>"; };
-		F96D3E8A08F272A6004A47F5 /* RecEvalObj.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = RecEvalObj.3; sourceTree = "<group>"; };
-		F96D3E8B08F272A6004A47F5 /* RecordEval.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = RecordEval.3; sourceTree = "<group>"; };
-		F96D3E8C08F272A6004A47F5 /* RegConfig.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = RegConfig.3; sourceTree = "<group>"; };
-		F96D3E8D08F272A6004A47F5 /* RegExp.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = RegExp.3; sourceTree = "<group>"; };
-		F96D3E8E08F272A6004A47F5 /* regexp.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = regexp.n; sourceTree = "<group>"; };
-		F96D3E8F08F272A6004A47F5 /* registry.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = registry.n; sourceTree = "<group>"; };
-		F96D3E9008F272A6004A47F5 /* regsub.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = regsub.n; sourceTree = "<group>"; };
-		F96D3E9108F272A6004A47F5 /* rename.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = rename.n; sourceTree = "<group>"; };
-		F96D3E9208F272A6004A47F5 /* return.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = return.n; sourceTree = "<group>"; };
-		F96D3E9308F272A6004A47F5 /* safe.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = safe.n; sourceTree = "<group>"; };
-		F96D3E9408F272A6004A47F5 /* SaveResult.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SaveResult.3; sourceTree = "<group>"; };
-		F96D3E9508F272A6004A47F5 /* scan.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = scan.n; sourceTree = "<group>"; };
-		F96D3E9608F272A6004A47F5 /* seek.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = seek.n; sourceTree = "<group>"; };
-		F96D3E9708F272A6004A47F5 /* set.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = set.n; sourceTree = "<group>"; };
-		F96D3E9808F272A6004A47F5 /* SetChanErr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SetChanErr.3; sourceTree = "<group>"; };
-		F96D3E9908F272A6004A47F5 /* SetErrno.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SetErrno.3; sourceTree = "<group>"; };
-		F96D3E9A08F272A6004A47F5 /* SetRecLmt.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SetRecLmt.3; sourceTree = "<group>"; };
-		F96D3E9B08F272A7004A47F5 /* SetResult.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SetResult.3; sourceTree = "<group>"; };
-		F96D3E9C08F272A7004A47F5 /* SetVar.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SetVar.3; sourceTree = "<group>"; };
-		F96D3E9D08F272A7004A47F5 /* Signal.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Signal.3; sourceTree = "<group>"; };
-		F96D3E9E08F272A7004A47F5 /* Sleep.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Sleep.3; sourceTree = "<group>"; };
-		F96D3E9F08F272A7004A47F5 /* socket.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = socket.n; sourceTree = "<group>"; };
-		F96D3EA008F272A7004A47F5 /* source.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = source.n; sourceTree = "<group>"; };
-		F96D3EA108F272A7004A47F5 /* SourceRCFile.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SourceRCFile.3; sourceTree = "<group>"; };
-		F96D3EA208F272A7004A47F5 /* split.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = split.n; sourceTree = "<group>"; };
-		F96D3EA308F272A7004A47F5 /* SplitList.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SplitList.3; sourceTree = "<group>"; };
-		F96D3EA408F272A7004A47F5 /* SplitPath.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SplitPath.3; sourceTree = "<group>"; };
-		F96D3EA508F272A7004A47F5 /* StaticPkg.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = StaticPkg.3; sourceTree = "<group>"; };
-		F96D3EA608F272A7004A47F5 /* StdChannels.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = StdChannels.3; sourceTree = "<group>"; };
-		F96D3EA708F272A7004A47F5 /* string.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = string.n; sourceTree = "<group>"; };
-		F96D3EA808F272A7004A47F5 /* StringObj.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = StringObj.3; sourceTree = "<group>"; };
-		F96D3EA908F272A7004A47F5 /* StrMatch.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = StrMatch.3; sourceTree = "<group>"; };
-		F96D3EAA08F272A7004A47F5 /* subst.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = subst.n; sourceTree = "<group>"; };
-		F96D3EAB08F272A7004A47F5 /* SubstObj.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = SubstObj.3; sourceTree = "<group>"; };
-		F96D3EAC08F272A7004A47F5 /* switch.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = switch.n; sourceTree = "<group>"; };
-		F96D3EAD08F272A7004A47F5 /* Tcl.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Tcl.n; sourceTree = "<group>"; };
-		F96D3EAE08F272A7004A47F5 /* Tcl_Main.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Tcl_Main.3; sourceTree = "<group>"; };
-		F96D3EAF08F272A7004A47F5 /* TCL_MEM_DEBUG.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = TCL_MEM_DEBUG.3; sourceTree = "<group>"; };
-		F96D3EB008F272A7004A47F5 /* tclsh.1 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = tclsh.1; sourceTree = "<group>"; };
-		F96D3EB108F272A7004A47F5 /* tcltest.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = tcltest.n; sourceTree = "<group>"; };
-		F96D3EB208F272A7004A47F5 /* tclvars.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = tclvars.n; sourceTree = "<group>"; };
-		F96D3EB308F272A7004A47F5 /* tell.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = tell.n; sourceTree = "<group>"; };
-		F96D3EB408F272A7004A47F5 /* Thread.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Thread.3; sourceTree = "<group>"; };
-		F96D3EB508F272A7004A47F5 /* time.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = time.n; sourceTree = "<group>"; };
-		F96D3EB608F272A7004A47F5 /* tm.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = tm.n; sourceTree = "<group>"; };
-		F96D3EB708F272A7004A47F5 /* ToUpper.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = ToUpper.3; sourceTree = "<group>"; };
-		F96D3EB808F272A7004A47F5 /* trace.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = trace.n; sourceTree = "<group>"; };
-		F96D3EB908F272A7004A47F5 /* TraceCmd.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = TraceCmd.3; sourceTree = "<group>"; };
-		F96D3EBA08F272A7004A47F5 /* TraceVar.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = TraceVar.3; sourceTree = "<group>"; };
-		F96D3EBB08F272A7004A47F5 /* Translate.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Translate.3; sourceTree = "<group>"; };
-		F96D3EBC08F272A7004A47F5 /* UniCharIsAlpha.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = UniCharIsAlpha.3; sourceTree = "<group>"; };
-		F96D3EBD08F272A7004A47F5 /* unknown.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = unknown.n; sourceTree = "<group>"; };
-		F96D3EBE08F272A7004A47F5 /* unload.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = unload.n; sourceTree = "<group>"; };
-		F96D3EBF08F272A7004A47F5 /* unset.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = unset.n; sourceTree = "<group>"; };
-		F96D3EC008F272A7004A47F5 /* update.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = update.n; sourceTree = "<group>"; };
-		F96D3EC108F272A7004A47F5 /* uplevel.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = uplevel.n; sourceTree = "<group>"; };
-		F96D3EC208F272A7004A47F5 /* UpVar.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = UpVar.3; sourceTree = "<group>"; };
-		F96D3EC308F272A7004A47F5 /* upvar.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = upvar.n; sourceTree = "<group>"; };
-		F96D3EC408F272A7004A47F5 /* Utf.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = Utf.3; sourceTree = "<group>"; };
-		F96D3EC508F272A7004A47F5 /* variable.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = variable.n; sourceTree = "<group>"; };
-		F96D3EC608F272A7004A47F5 /* vwait.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = vwait.n; sourceTree = "<group>"; };
-		F96D3EC708F272A7004A47F5 /* while.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = while.n; sourceTree = "<group>"; };
-		F96D3EC808F272A7004A47F5 /* WrongNumArgs.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = WrongNumArgs.3; sourceTree = "<group>"; };
-		F96D3ECA08F272A7004A47F5 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F96D3ECB08F272A7004A47F5 /* regc_color.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = regc_color.c; sourceTree = "<group>"; };
-		F96D3ECC08F272A7004A47F5 /* regc_cvec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = regc_cvec.c; sourceTree = "<group>"; };
-		F96D3ECD08F272A7004A47F5 /* regc_lex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = regc_lex.c; sourceTree = "<group>"; };
-		F96D3ECE08F272A7004A47F5 /* regc_locale.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = regc_locale.c; sourceTree = "<group>"; };
-		F96D3ECF08F272A7004A47F5 /* regc_nfa.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = regc_nfa.c; sourceTree = "<group>"; };
-		F96D3ED008F272A7004A47F5 /* regcomp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = regcomp.c; sourceTree = "<group>"; };
-		F96D3ED108F272A7004A47F5 /* regcustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = regcustom.h; sourceTree = "<group>"; };
-		F96D3ED208F272A7004A47F5 /* rege_dfa.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rege_dfa.c; sourceTree = "<group>"; };
-		F96D3ED308F272A7004A47F5 /* regerror.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = regerror.c; sourceTree = "<group>"; };
-		F96D3ED408F272A7004A47F5 /* regerrs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = regerrs.h; sourceTree = "<group>"; };
-		F96D3ED508F272A7004A47F5 /* regex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = regex.h; sourceTree = "<group>"; };
-		F96D3ED608F272A7004A47F5 /* regexec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = regexec.c; sourceTree = "<group>"; };
-		F96D3ED708F272A7004A47F5 /* regfree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = regfree.c; sourceTree = "<group>"; };
-		F96D3ED808F272A7004A47F5 /* regfronts.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = regfronts.c; sourceTree = "<group>"; };
-		F96D3ED908F272A7004A47F5 /* regguts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = regguts.h; sourceTree = "<group>"; };
-		F96D3EDA08F272A7004A47F5 /* tcl.decls */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tcl.decls; sourceTree = "<group>"; };
-		F96D3EDB08F272A7004A47F5 /* tcl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tcl.h; sourceTree = "<group>"; };
-		F96D3EDC08F272A7004A47F5 /* tclAlloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclAlloc.c; sourceTree = "<group>"; };
-		F96D3EDD08F272A7004A47F5 /* tclAsync.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclAsync.c; sourceTree = "<group>"; };
-		F96D3EDE08F272A7004A47F5 /* tclBasic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclBasic.c; sourceTree = "<group>"; };
-		F96D3EDF08F272A7004A47F5 /* tclBinary.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclBinary.c; sourceTree = "<group>"; };
-		F96D3EE008F272A7004A47F5 /* tclCkalloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclCkalloc.c; sourceTree = "<group>"; };
-		F96D3EE108F272A7004A47F5 /* tclClock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclClock.c; sourceTree = "<group>"; };
-		F96D3EE208F272A7004A47F5 /* tclCmdAH.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclCmdAH.c; sourceTree = "<group>"; };
-		F96D3EE308F272A7004A47F5 /* tclCmdIL.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclCmdIL.c; sourceTree = "<group>"; };
-		F96D3EE408F272A7004A47F5 /* tclCmdMZ.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclCmdMZ.c; sourceTree = "<group>"; };
-		F96D3EE508F272A7004A47F5 /* tclCompCmds.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclCompCmds.c; sourceTree = "<group>"; };
-		F96D3EE608F272A7004A47F5 /* tclCompExpr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclCompExpr.c; sourceTree = "<group>"; };
-		F96D3EE708F272A7004A47F5 /* tclCompile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclCompile.c; sourceTree = "<group>"; };
-		F96D3EE808F272A7004A47F5 /* tclCompile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclCompile.h; sourceTree = "<group>"; };
-		F96D3EE908F272A7004A47F5 /* tclConfig.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclConfig.c; sourceTree = "<group>"; };
-		F96D3EEA08F272A7004A47F5 /* tclDate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclDate.c; sourceTree = "<group>"; };
-		F96D3EEB08F272A7004A47F5 /* tclDecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclDecls.h; sourceTree = "<group>"; };
-		F96D3EEC08F272A7004A47F5 /* tclDictObj.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclDictObj.c; sourceTree = "<group>"; };
-		F96D3EED08F272A7004A47F5 /* tclEncoding.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclEncoding.c; sourceTree = "<group>"; };
-		F96D3EEE08F272A7004A47F5 /* tclEnv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclEnv.c; sourceTree = "<group>"; };
-		F96D3EEF08F272A7004A47F5 /* tclEvent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclEvent.c; sourceTree = "<group>"; };
-		F96D3EF008F272A7004A47F5 /* tclExecute.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclExecute.c; sourceTree = "<group>"; };
-		F96D3EF108F272A7004A47F5 /* tclFCmd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclFCmd.c; sourceTree = "<group>"; };
-		F96D3EF208F272A7004A47F5 /* tclFileName.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclFileName.c; sourceTree = "<group>"; };
-		F96D3EF308F272A7004A47F5 /* tclFileSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclFileSystem.h; sourceTree = "<group>"; };
-		F96D3EF408F272A7004A47F5 /* tclGet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclGet.c; sourceTree = "<group>"; };
-		F96D3EF508F272A7004A47F5 /* tclGetDate.y */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.yacc; path = tclGetDate.y; sourceTree = "<group>"; };
-		F96D3EF608F272A7004A47F5 /* tclHash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclHash.c; sourceTree = "<group>"; };
-		F96D3EF708F272A7004A47F5 /* tclHistory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclHistory.c; sourceTree = "<group>"; };
-		F96D3EF808F272A7004A47F5 /* tclIndexObj.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclIndexObj.c; sourceTree = "<group>"; };
-		F96D3EF908F272A7004A47F5 /* tclInt.decls */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tclInt.decls; sourceTree = "<group>"; };
-		F96D3EFA08F272A7004A47F5 /* tclInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclInt.h; sourceTree = "<group>"; };
-		F96D3EFB08F272A7004A47F5 /* tclIntDecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclIntDecls.h; sourceTree = "<group>"; };
-		F96D3EFC08F272A7004A47F5 /* tclInterp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclInterp.c; sourceTree = "<group>"; };
-		F96D3EFD08F272A7004A47F5 /* tclIntPlatDecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclIntPlatDecls.h; sourceTree = "<group>"; };
-		F96D3EFE08F272A7004A47F5 /* tclIO.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclIO.c; sourceTree = "<group>"; };
-		F96D3EFF08F272A7004A47F5 /* tclIO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclIO.h; sourceTree = "<group>"; };
-		F96D3F0008F272A7004A47F5 /* tclIOCmd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclIOCmd.c; sourceTree = "<group>"; };
-		F96D3F0108F272A7004A47F5 /* tclIOGT.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclIOGT.c; sourceTree = "<group>"; };
-		F96D3F0208F272A7004A47F5 /* tclIORChan.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclIORChan.c; sourceTree = "<group>"; };
-		F96D3F0308F272A7004A47F5 /* tclIOSock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclIOSock.c; sourceTree = "<group>"; };
-		F96D3F0408F272A7004A47F5 /* tclIOUtil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclIOUtil.c; sourceTree = "<group>"; };
-		F96D3F0508F272A7004A47F5 /* tclLink.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclLink.c; sourceTree = "<group>"; };
-		F96D3F0608F272A7004A47F5 /* tclListObj.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclListObj.c; sourceTree = "<group>"; };
-		F96D3F0708F272A7004A47F5 /* tclLiteral.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclLiteral.c; sourceTree = "<group>"; };
-		F96D3F0808F272A7004A47F5 /* tclLoad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclLoad.c; sourceTree = "<group>"; };
-		F96D3F0908F272A7004A47F5 /* tclLoadNone.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclLoadNone.c; sourceTree = "<group>"; };
-		F96D3F0A08F272A7004A47F5 /* tclMain.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclMain.c; sourceTree = "<group>"; };
-		F96D3F0B08F272A7004A47F5 /* tclNamesp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclNamesp.c; sourceTree = "<group>"; };
-		F96D3F0C08F272A7004A47F5 /* tclNotify.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclNotify.c; sourceTree = "<group>"; };
-		F96D3F0D08F272A7004A47F5 /* tclObj.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclObj.c; sourceTree = "<group>"; };
-		F96D3F0E08F272A7004A47F5 /* tclPanic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclPanic.c; sourceTree = "<group>"; };
-		F96D3F0F08F272A7004A47F5 /* tclParse.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclParse.c; sourceTree = "<group>"; };
-		F96D3F1108F272A7004A47F5 /* tclPathObj.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclPathObj.c; sourceTree = "<group>"; };
-		F96D3F1208F272A7004A47F5 /* tclPipe.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclPipe.c; sourceTree = "<group>"; };
-		F96D3F1308F272A7004A47F5 /* tclPkg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclPkg.c; sourceTree = "<group>"; };
-		F96D3F1408F272A7004A47F5 /* tclPkgConfig.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclPkgConfig.c; sourceTree = "<group>"; };
-		F96D3F1508F272A7004A47F5 /* tclPlatDecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclPlatDecls.h; sourceTree = "<group>"; };
-		F96D3F1608F272A7004A47F5 /* tclPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclPort.h; sourceTree = "<group>"; };
-		F96D3F1708F272A7004A47F5 /* tclPosixStr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclPosixStr.c; sourceTree = "<group>"; };
-		F96D3F1808F272A7004A47F5 /* tclPreserve.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclPreserve.c; sourceTree = "<group>"; };
-		F96D3F1908F272A7004A47F5 /* tclProc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclProc.c; sourceTree = "<group>"; };
-		F96D3F1A08F272A7004A47F5 /* tclRegexp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclRegexp.c; sourceTree = "<group>"; };
-		F96D3F1B08F272A7004A47F5 /* tclRegexp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclRegexp.h; sourceTree = "<group>"; };
-		F96D3F1C08F272A7004A47F5 /* tclResolve.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclResolve.c; sourceTree = "<group>"; };
-		F96D3F1D08F272A7004A47F5 /* tclResult.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclResult.c; sourceTree = "<group>"; };
-		F96D3F1E08F272A7004A47F5 /* tclScan.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclScan.c; sourceTree = "<group>"; };
-		F96D3F1F08F272A7004A47F5 /* tclStringObj.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclStringObj.c; sourceTree = "<group>"; };
-		F96D3F2408F272A7004A47F5 /* tclStrToD.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclStrToD.c; sourceTree = "<group>"; };
-		F96D3F2508F272A7004A47F5 /* tclStubInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclStubInit.c; sourceTree = "<group>"; };
-		F96D3F2608F272A7004A47F5 /* tclStubLib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclStubLib.c; sourceTree = "<group>"; };
-		F96D3F2708F272A7004A47F5 /* tclTest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclTest.c; sourceTree = "<group>"; };
-		F96D3F2808F272A7004A47F5 /* tclTestObj.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclTestObj.c; sourceTree = "<group>"; };
-		F96D3F2908F272A7004A47F5 /* tclTestProcBodyObj.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclTestProcBodyObj.c; sourceTree = "<group>"; };
-		F96D3F2A08F272A7004A47F5 /* tclThread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclThread.c; sourceTree = "<group>"; };
-		F96D3F2B08F272A7004A47F5 /* tclThreadAlloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclThreadAlloc.c; sourceTree = "<group>"; };
-		F96D3F2C08F272A7004A47F5 /* tclThreadJoin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclThreadJoin.c; sourceTree = "<group>"; };
-		F96D3F2D08F272A7004A47F5 /* tclThreadStorage.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclThreadStorage.c; sourceTree = "<group>"; };
-		F96D3F2E08F272A7004A47F5 /* tclThreadTest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclThreadTest.c; sourceTree = "<group>"; };
-		F96D3F2F08F272A7004A47F5 /* tclTimer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclTimer.c; sourceTree = "<group>"; };
-		F96D3F3008F272A7004A47F5 /* tclTomMath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclTomMath.h; sourceTree = "<group>"; };
-		F96D3F3108F272A7004A47F5 /* tclTomMathInterface.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclTomMathInterface.c; sourceTree = "<group>"; };
-		F96D3F3208F272A7004A47F5 /* tclTrace.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclTrace.c; sourceTree = "<group>"; };
-		F96D3F3308F272A7004A47F5 /* tclUniData.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUniData.c; sourceTree = "<group>"; };
-		F96D3F3408F272A7004A47F5 /* tclUtf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUtf.c; sourceTree = "<group>"; };
-		F96D3F3508F272A7004A47F5 /* tclUtil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUtil.c; sourceTree = "<group>"; };
-		F96D3F3608F272A7004A47F5 /* tclVar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclVar.c; sourceTree = "<group>"; };
-		F96D3F3708F272A7004A47F5 /* tommath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tommath.h; sourceTree = "<group>"; };
-		F96D3F3908F272A8004A47F5 /* auto.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = auto.tcl; sourceTree = "<group>"; };
-		F96D3F3A08F272A8004A47F5 /* clock.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = clock.tcl; sourceTree = "<group>"; };
-		F96D3F3C08F272A8004A47F5 /* pkgIndex.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pkgIndex.tcl; sourceTree = "<group>"; };
-		F96D3F8C08F272A8004A47F5 /* history.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = history.tcl; sourceTree = "<group>"; };
-		F96D3F8E08F272A8004A47F5 /* http.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = http.tcl; sourceTree = "<group>"; };
-		F96D3F8F08F272A8004A47F5 /* pkgIndex.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pkgIndex.tcl; sourceTree = "<group>"; };
-		F96D3F9108F272A8004A47F5 /* http.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = http.tcl; sourceTree = "<group>"; };
-		F96D3F9208F272A8004A47F5 /* pkgIndex.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pkgIndex.tcl; sourceTree = "<group>"; };
-		F96D3F9308F272A8004A47F5 /* init.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = init.tcl; sourceTree = "<group>"; };
-		F96D3F9508F272A8004A47F5 /* msgcat.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = msgcat.tcl; sourceTree = "<group>"; };
-		F96D3F9608F272A8004A47F5 /* pkgIndex.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pkgIndex.tcl; sourceTree = "<group>"; };
-		F96D401808F272AA004A47F5 /* optparse.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = optparse.tcl; sourceTree = "<group>"; };
-		F96D401908F272AA004A47F5 /* pkgIndex.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pkgIndex.tcl; sourceTree = "<group>"; };
-		F96D401A08F272AA004A47F5 /* package.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = package.tcl; sourceTree = "<group>"; };
-		F96D401B08F272AA004A47F5 /* parray.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = parray.tcl; sourceTree = "<group>"; };
-		F96D401D08F272AA004A47F5 /* pkgIndex.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pkgIndex.tcl; sourceTree = "<group>"; };
-		F96D401E08F272AA004A47F5 /* safe.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = safe.tcl; sourceTree = "<group>"; };
-		F96D401F08F272AA004A47F5 /* tclIndex */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tclIndex; sourceTree = "<group>"; };
-		F96D402108F272AA004A47F5 /* pkgIndex.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pkgIndex.tcl; sourceTree = "<group>"; };
-		F96D402208F272AA004A47F5 /* tcltest.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tcltest.tcl; sourceTree = "<group>"; };
-		F96D402308F272AA004A47F5 /* tm.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tm.tcl; sourceTree = "<group>"; };
-		F96D425B08F272B2004A47F5 /* word.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = word.tcl; sourceTree = "<group>"; };
-		F96D426408F272B3004A47F5 /* bn_fast_s_mp_mul_digs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_fast_s_mp_mul_digs.c; sourceTree = "<group>"; };
-		F96D426608F272B3004A47F5 /* bn_fast_s_mp_sqr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_fast_s_mp_sqr.c; sourceTree = "<group>"; };
-		F96D426908F272B3004A47F5 /* bn_mp_add.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_add.c; sourceTree = "<group>"; };
-		F96D426A08F272B3004A47F5 /* bn_mp_add_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_add_d.c; sourceTree = "<group>"; };
-		F96D426C08F272B3004A47F5 /* bn_mp_and.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_and.c; sourceTree = "<group>"; };
-		F96D426D08F272B3004A47F5 /* bn_mp_clamp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_clamp.c; sourceTree = "<group>"; };
-		F96D426E08F272B3004A47F5 /* bn_mp_clear.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_clear.c; sourceTree = "<group>"; };
-		F96D426F08F272B3004A47F5 /* bn_mp_clear_multi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_clear_multi.c; sourceTree = "<group>"; };
-		F96D427008F272B3004A47F5 /* bn_mp_cmp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_cmp.c; sourceTree = "<group>"; };
-		F96D427108F272B3004A47F5 /* bn_mp_cmp_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_cmp_d.c; sourceTree = "<group>"; };
-		F96D427208F272B3004A47F5 /* bn_mp_cmp_mag.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_cmp_mag.c; sourceTree = "<group>"; };
-		F96D427408F272B3004A47F5 /* bn_mp_copy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_copy.c; sourceTree = "<group>"; };
-		F96D427508F272B3004A47F5 /* bn_mp_count_bits.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_count_bits.c; sourceTree = "<group>"; };
-		F96D427608F272B3004A47F5 /* bn_mp_div.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_div.c; sourceTree = "<group>"; };
-		F96D427708F272B3004A47F5 /* bn_mp_div_2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_div_2.c; sourceTree = "<group>"; };
-		F96D427808F272B3004A47F5 /* bn_mp_div_2d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_div_2d.c; sourceTree = "<group>"; };
-		F96D427908F272B3004A47F5 /* bn_mp_div_3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_div_3.c; sourceTree = "<group>"; };
-		F96D427A08F272B3004A47F5 /* bn_mp_div_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_div_d.c; sourceTree = "<group>"; };
-		F96D427E08F272B3004A47F5 /* bn_mp_exch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_exch.c; sourceTree = "<group>"; };
-		F96D427F08F272B3004A47F5 /* bn_mp_expt_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_expt_d.c; sourceTree = "<group>"; };
-		F96D428708F272B3004A47F5 /* bn_mp_grow.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_grow.c; sourceTree = "<group>"; };
-		F96D428808F272B3004A47F5 /* bn_mp_init.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_init.c; sourceTree = "<group>"; };
-		F96D428908F272B3004A47F5 /* bn_mp_init_copy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_init_copy.c; sourceTree = "<group>"; };
-		F96D428A08F272B3004A47F5 /* bn_mp_init_multi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_init_multi.c; sourceTree = "<group>"; };
-		F96D428B08F272B3004A47F5 /* bn_mp_init_set.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_init_set.c; sourceTree = "<group>"; };
-		F96D428D08F272B3004A47F5 /* bn_mp_init_size.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_init_size.c; sourceTree = "<group>"; };
-		F96D429208F272B3004A47F5 /* bn_mp_karatsuba_mul.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_karatsuba_mul.c; sourceTree = "<group>"; };
-		F96D429308F272B3004A47F5 /* bn_mp_karatsuba_sqr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_karatsuba_sqr.c; sourceTree = "<group>"; };
-		F96D429508F272B3004A47F5 /* bn_mp_lshd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_lshd.c; sourceTree = "<group>"; };
-		F96D429608F272B3004A47F5 /* bn_mp_mod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mod.c; sourceTree = "<group>"; };
-		F96D429708F272B3004A47F5 /* bn_mp_mod_2d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mod_2d.c; sourceTree = "<group>"; };
-		F96D429C08F272B3004A47F5 /* bn_mp_mul.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mul.c; sourceTree = "<group>"; };
-		F96D429D08F272B3004A47F5 /* bn_mp_mul_2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mul_2.c; sourceTree = "<group>"; };
-		F96D429E08F272B3004A47F5 /* bn_mp_mul_2d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mul_2d.c; sourceTree = "<group>"; };
-		F96D429F08F272B3004A47F5 /* bn_mp_mul_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_mul_d.c; sourceTree = "<group>"; };
-		F96D42A208F272B3004A47F5 /* bn_mp_neg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_neg.c; sourceTree = "<group>"; };
-		F96D42A308F272B3004A47F5 /* bn_mp_or.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_or.c; sourceTree = "<group>"; };
-		F96D42AB08F272B3004A47F5 /* bn_mp_radix_size.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_radix_size.c; sourceTree = "<group>"; };
-		F96D42AC08F272B3004A47F5 /* bn_mp_radix_smap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_radix_smap.c; sourceTree = "<group>"; };
-		F96D42AE08F272B3004A47F5 /* bn_mp_read_radix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_read_radix.c; sourceTree = "<group>"; };
-		F96D42B908F272B3004A47F5 /* bn_mp_rshd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_rshd.c; sourceTree = "<group>"; };
-		F96D42BA08F272B3004A47F5 /* bn_mp_set.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_set.c; sourceTree = "<group>"; };
-		F96D42BC08F272B3004A47F5 /* bn_mp_shrink.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_shrink.c; sourceTree = "<group>"; };
-		F96D42BE08F272B3004A47F5 /* bn_mp_sqr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_sqr.c; sourceTree = "<group>"; };
-		F96D42C008F272B3004A47F5 /* bn_mp_sqrt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_sqrt.c; sourceTree = "<group>"; };
-		F96D42C108F272B3004A47F5 /* bn_mp_sub.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_sub.c; sourceTree = "<group>"; };
-		F96D42C208F272B3004A47F5 /* bn_mp_sub_d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_sub_d.c; sourceTree = "<group>"; };
-		F96D42C608F272B3004A47F5 /* bn_mp_to_unsigned_bin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_to_unsigned_bin.c; sourceTree = "<group>"; };
-		F96D42C708F272B3004A47F5 /* bn_mp_to_unsigned_bin_n.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_to_unsigned_bin_n.c; sourceTree = "<group>"; };
-		F96D42C808F272B3004A47F5 /* bn_mp_toom_mul.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_toom_mul.c; sourceTree = "<group>"; };
-		F96D42C908F272B3004A47F5 /* bn_mp_toom_sqr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_toom_sqr.c; sourceTree = "<group>"; };
-		F96D42CB08F272B3004A47F5 /* bn_mp_toradix_n.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_toradix_n.c; sourceTree = "<group>"; };
-		F96D42CC08F272B3004A47F5 /* bn_mp_unsigned_bin_size.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_unsigned_bin_size.c; sourceTree = "<group>"; };
-		F96D42CD08F272B3004A47F5 /* bn_mp_xor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_xor.c; sourceTree = "<group>"; };
-		F96D42CE08F272B3004A47F5 /* bn_mp_zero.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_mp_zero.c; sourceTree = "<group>"; };
-		F96D42D008F272B3004A47F5 /* bn_reverse.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_reverse.c; sourceTree = "<group>"; };
-		F96D42D108F272B3004A47F5 /* bn_s_mp_add.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_add.c; sourceTree = "<group>"; };
-		F96D42D308F272B3004A47F5 /* bn_s_mp_mul_digs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_mul_digs.c; sourceTree = "<group>"; };
-		F96D42D508F272B3004A47F5 /* bn_s_mp_sqr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_sqr.c; sourceTree = "<group>"; };
-		F96D42D608F272B3004A47F5 /* bn_s_mp_sub.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bn_s_mp_sub.c; sourceTree = "<group>"; };
-		F96D42D708F272B3004A47F5 /* bncore.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bncore.c; sourceTree = "<group>"; };
-		F96D432908F272B4004A47F5 /* tommath_class.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tommath_class.h; sourceTree = "<group>"; };
-		F96D432A08F272B4004A47F5 /* tommath_superclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tommath_superclass.h; sourceTree = "<group>"; };
-		F96D432B08F272B4004A47F5 /* license.terms */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = license.terms; sourceTree = "<group>"; };
-		F96D432E08F272B5004A47F5 /* configure.ac */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = configure.ac; sourceTree = "<group>"; };
-		F96D432F08F272B5004A47F5 /* GNUmakefile */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = GNUmakefile; sourceTree = "<group>"; };
-		F96D433108F272B5004A47F5 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F96D433208F272B5004A47F5 /* Tcl-Info.plist.in */ = {isa = PBXFileReference; explicitFileType = text.plist; fileEncoding = 4; path = "Tcl-Info.plist.in"; sourceTree = "<group>"; };
-		F96D433908F272B5004A47F5 /* tclMacOSXBundle.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclMacOSXBundle.c; sourceTree = "<group>"; };
-		F96D433D08F272B5004A47F5 /* tclMacOSXFCmd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclMacOSXFCmd.c; sourceTree = "<group>"; };
-		F96D433E08F272B5004A47F5 /* tclMacOSXNotify.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclMacOSXNotify.c; sourceTree = "<group>"; };
-		F96D434308F272B5004A47F5 /* README */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = README; sourceTree = "<group>"; };
-		F96D434508F272B5004A47F5 /* all.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = all.tcl; sourceTree = "<group>"; };
-		F96D434608F272B5004A47F5 /* append.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = append.test; sourceTree = "<group>"; };
-		F96D434708F272B5004A47F5 /* appendComp.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = appendComp.test; sourceTree = "<group>"; };
-		F96D434808F272B5004A47F5 /* assocd.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = assocd.test; sourceTree = "<group>"; };
-		F96D434908F272B5004A47F5 /* async.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = async.test; sourceTree = "<group>"; };
-		F96D434A08F272B5004A47F5 /* autoMkindex.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = autoMkindex.test; sourceTree = "<group>"; };
-		F96D434B08F272B5004A47F5 /* basic.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = basic.test; sourceTree = "<group>"; };
-		F96D434C08F272B5004A47F5 /* binary.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = binary.test; sourceTree = "<group>"; };
-		F96D434D08F272B5004A47F5 /* case.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = case.test; sourceTree = "<group>"; };
-		F96D434E08F272B5004A47F5 /* chan.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = chan.test; sourceTree = "<group>"; };
-		F96D434F08F272B5004A47F5 /* clock.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = clock.test; sourceTree = "<group>"; };
-		F96D435008F272B5004A47F5 /* cmdAH.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = cmdAH.test; sourceTree = "<group>"; };
-		F96D435108F272B5004A47F5 /* cmdIL.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = cmdIL.test; sourceTree = "<group>"; };
-		F96D435208F272B5004A47F5 /* cmdInfo.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = cmdInfo.test; sourceTree = "<group>"; };
-		F96D435308F272B5004A47F5 /* cmdMZ.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = cmdMZ.test; sourceTree = "<group>"; };
-		F96D435408F272B5004A47F5 /* compExpr-old.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = "compExpr-old.test"; sourceTree = "<group>"; };
-		F96D435508F272B5004A47F5 /* compExpr.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = compExpr.test; sourceTree = "<group>"; };
-		F96D435608F272B5004A47F5 /* compile.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = compile.test; sourceTree = "<group>"; };
-		F96D435708F272B5004A47F5 /* concat.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = concat.test; sourceTree = "<group>"; };
-		F96D435808F272B5004A47F5 /* config.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = config.test; sourceTree = "<group>"; };
-		F96D435908F272B5004A47F5 /* dcall.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = dcall.test; sourceTree = "<group>"; };
-		F96D435A08F272B5004A47F5 /* dict.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = dict.test; sourceTree = "<group>"; };
-		F96D435C08F272B5004A47F5 /* dstring.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = dstring.test; sourceTree = "<group>"; };
-		F96D435E08F272B5004A47F5 /* encoding.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = encoding.test; sourceTree = "<group>"; };
-		F96D435F08F272B5004A47F5 /* env.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = env.test; sourceTree = "<group>"; };
-		F96D436008F272B5004A47F5 /* error.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = error.test; sourceTree = "<group>"; };
-		F96D436108F272B5004A47F5 /* eval.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = eval.test; sourceTree = "<group>"; };
-		F96D436208F272B5004A47F5 /* event.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = event.test; sourceTree = "<group>"; };
-		F96D436308F272B5004A47F5 /* exec.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = exec.test; sourceTree = "<group>"; };
-		F96D436408F272B5004A47F5 /* execute.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = execute.test; sourceTree = "<group>"; };
-		F96D436508F272B5004A47F5 /* expr-old.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = "expr-old.test"; sourceTree = "<group>"; };
-		F96D436608F272B5004A47F5 /* expr.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = expr.test; sourceTree = "<group>"; };
-		F96D436708F272B6004A47F5 /* fCmd.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = fCmd.test; sourceTree = "<group>"; };
-		F96D436808F272B6004A47F5 /* fileName.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = fileName.test; sourceTree = "<group>"; };
-		F96D436908F272B6004A47F5 /* fileSystem.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = fileSystem.test; sourceTree = "<group>"; };
-		F96D436A08F272B6004A47F5 /* for-old.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = "for-old.test"; sourceTree = "<group>"; };
-		F96D436B08F272B6004A47F5 /* for.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = for.test; sourceTree = "<group>"; };
-		F96D436C08F272B6004A47F5 /* foreach.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = foreach.test; sourceTree = "<group>"; };
-		F96D436D08F272B6004A47F5 /* format.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = format.test; sourceTree = "<group>"; };
-		F96D436E08F272B6004A47F5 /* get.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = get.test; sourceTree = "<group>"; };
-		F96D436F08F272B6004A47F5 /* history.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = history.test; sourceTree = "<group>"; };
-		F96D437008F272B6004A47F5 /* http.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = http.test; sourceTree = "<group>"; };
-		F96D437108F272B6004A47F5 /* httpd */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = httpd; sourceTree = "<group>"; };
-		F96D437208F272B6004A47F5 /* httpold.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = httpold.test; sourceTree = "<group>"; };
-		F96D437308F272B6004A47F5 /* if-old.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = "if-old.test"; sourceTree = "<group>"; };
-		F96D437408F272B6004A47F5 /* if.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = if.test; sourceTree = "<group>"; };
-		F96D437508F272B6004A47F5 /* incr-old.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = "incr-old.test"; sourceTree = "<group>"; };
-		F96D437608F272B6004A47F5 /* incr.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = incr.test; sourceTree = "<group>"; };
-		F96D437708F272B6004A47F5 /* indexObj.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = indexObj.test; sourceTree = "<group>"; };
-		F96D437808F272B6004A47F5 /* info.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = info.test; sourceTree = "<group>"; };
-		F96D437908F272B6004A47F5 /* init.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = init.test; sourceTree = "<group>"; };
-		F96D437A08F272B6004A47F5 /* interp.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = interp.test; sourceTree = "<group>"; };
-		F96D437B08F272B6004A47F5 /* io.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = io.test; sourceTree = "<group>"; };
-		F96D437C08F272B6004A47F5 /* ioCmd.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = ioCmd.test; sourceTree = "<group>"; };
-		F96D437D08F272B6004A47F5 /* iogt.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = iogt.test; sourceTree = "<group>"; };
-		F96D437F08F272B6004A47F5 /* join.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = join.test; sourceTree = "<group>"; };
-		F96D438008F272B6004A47F5 /* lindex.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = lindex.test; sourceTree = "<group>"; };
-		F96D438108F272B6004A47F5 /* link.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = link.test; sourceTree = "<group>"; };
-		F96D438208F272B6004A47F5 /* linsert.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = linsert.test; sourceTree = "<group>"; };
-		F96D438308F272B6004A47F5 /* list.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = list.test; sourceTree = "<group>"; };
-		F96D438408F272B6004A47F5 /* listObj.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = listObj.test; sourceTree = "<group>"; };
-		F96D438508F272B6004A47F5 /* llength.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = llength.test; sourceTree = "<group>"; };
-		F96D438608F272B6004A47F5 /* load.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = load.test; sourceTree = "<group>"; };
-		F96D438708F272B6004A47F5 /* lrange.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = lrange.test; sourceTree = "<group>"; };
-		F96D438808F272B6004A47F5 /* lrepeat.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = lrepeat.test; sourceTree = "<group>"; };
-		F96D438908F272B6004A47F5 /* lreplace.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = lreplace.test; sourceTree = "<group>"; };
-		F96D438A08F272B6004A47F5 /* lsearch.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = lsearch.test; sourceTree = "<group>"; };
-		F96D438B08F272B6004A47F5 /* lset.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = lset.test; sourceTree = "<group>"; };
-		F96D438C08F272B6004A47F5 /* lsetComp.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = lsetComp.test; sourceTree = "<group>"; };
-		F96D438D08F272B6004A47F5 /* macOSXFCmd.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = macOSXFCmd.test; sourceTree = "<group>"; };
-		F96D438E08F272B6004A47F5 /* main.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = main.test; sourceTree = "<group>"; };
-		F96D438F08F272B6004A47F5 /* misc.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = misc.test; sourceTree = "<group>"; };
-		F96D439008F272B6004A47F5 /* msgcat.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = msgcat.test; sourceTree = "<group>"; };
-		F96D439108F272B6004A47F5 /* namespace-old.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = "namespace-old.test"; sourceTree = "<group>"; };
-		F96D439208F272B7004A47F5 /* namespace.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = namespace.test; sourceTree = "<group>"; };
-		F96D439308F272B7004A47F5 /* notify.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = notify.test; sourceTree = "<group>"; };
-		F96D439408F272B7004A47F5 /* obj.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = obj.test; sourceTree = "<group>"; };
-		F96D439508F272B7004A47F5 /* opt.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = opt.test; sourceTree = "<group>"; };
-		F96D439608F272B7004A47F5 /* package.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = package.test; sourceTree = "<group>"; };
-		F96D439708F272B7004A47F5 /* parse.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = parse.test; sourceTree = "<group>"; };
-		F96D439808F272B7004A47F5 /* parseExpr.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = parseExpr.test; sourceTree = "<group>"; };
-		F96D439908F272B7004A47F5 /* parseOld.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = parseOld.test; sourceTree = "<group>"; };
-		F96D439A08F272B7004A47F5 /* pid.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pid.test; sourceTree = "<group>"; };
-		F96D439B08F272B7004A47F5 /* pkg.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pkg.test; sourceTree = "<group>"; };
-		F96D439C08F272B7004A47F5 /* pkgMkIndex.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pkgMkIndex.test; sourceTree = "<group>"; };
-		F96D439D08F272B7004A47F5 /* platform.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = platform.test; sourceTree = "<group>"; };
-		F96D439E08F272B7004A47F5 /* proc-old.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = "proc-old.test"; sourceTree = "<group>"; };
-		F96D439F08F272B7004A47F5 /* proc.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = proc.test; sourceTree = "<group>"; };
-		F96D43A008F272B7004A47F5 /* pwd.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pwd.test; sourceTree = "<group>"; };
-		F96D43A108F272B7004A47F5 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F96D43A208F272B7004A47F5 /* reg.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = reg.test; sourceTree = "<group>"; };
-		F96D43A308F272B7004A47F5 /* regexp.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = regexp.test; sourceTree = "<group>"; };
-		F96D43A408F272B7004A47F5 /* regexpComp.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = regexpComp.test; sourceTree = "<group>"; };
-		F96D43A508F272B7004A47F5 /* registry.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = registry.test; sourceTree = "<group>"; };
-		F96D43A608F272B7004A47F5 /* remote.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = remote.tcl; sourceTree = "<group>"; };
-		F96D43A708F272B7004A47F5 /* rename.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = rename.test; sourceTree = "<group>"; };
-		F96D43A808F272B7004A47F5 /* result.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = result.test; sourceTree = "<group>"; };
-		F96D43A908F272B7004A47F5 /* safe.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = safe.test; sourceTree = "<group>"; };
-		F96D43AA08F272B7004A47F5 /* scan.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = scan.test; sourceTree = "<group>"; };
-		F96D43AB08F272B7004A47F5 /* security.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = security.test; sourceTree = "<group>"; };
-		F96D43AC08F272B7004A47F5 /* set-old.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = "set-old.test"; sourceTree = "<group>"; };
-		F96D43AD08F272B7004A47F5 /* set.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = set.test; sourceTree = "<group>"; };
-		F96D43AE08F272B7004A47F5 /* socket.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = socket.test; sourceTree = "<group>"; };
-		F96D43AF08F272B7004A47F5 /* source.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = source.test; sourceTree = "<group>"; };
-		F96D43B008F272B7004A47F5 /* split.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = split.test; sourceTree = "<group>"; };
-		F96D43B108F272B7004A47F5 /* stack.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = stack.test; sourceTree = "<group>"; };
-		F96D43B208F272B7004A47F5 /* string.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = string.test; sourceTree = "<group>"; };
-		F96D43B308F272B7004A47F5 /* stringComp.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = stringComp.test; sourceTree = "<group>"; };
-		F96D43B408F272B7004A47F5 /* stringObj.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = stringObj.test; sourceTree = "<group>"; };
-		F96D43B508F272B7004A47F5 /* subst.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = subst.test; sourceTree = "<group>"; };
-		F96D43B608F272B7004A47F5 /* switch.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = switch.test; sourceTree = "<group>"; };
-		F96D43B708F272B7004A47F5 /* tcltest.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tcltest.test; sourceTree = "<group>"; };
-		F96D43B808F272B7004A47F5 /* thread.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = thread.test; sourceTree = "<group>"; };
-		F96D43B908F272B7004A47F5 /* timer.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = timer.test; sourceTree = "<group>"; };
-		F96D43BA08F272B7004A47F5 /* tm.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tm.test; sourceTree = "<group>"; };
-		F96D43BB08F272B7004A47F5 /* trace.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = trace.test; sourceTree = "<group>"; };
-		F96D43BC08F272B7004A47F5 /* unixFCmd.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unixFCmd.test; sourceTree = "<group>"; };
-		F96D43BD08F272B7004A47F5 /* unixFile.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unixFile.test; sourceTree = "<group>"; };
-		F96D43BE08F272B7004A47F5 /* unixInit.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unixInit.test; sourceTree = "<group>"; };
-		F96D43BF08F272B7004A47F5 /* unixNotfy.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unixNotfy.test; sourceTree = "<group>"; };
-		F96D43C008F272B7004A47F5 /* unknown.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unknown.test; sourceTree = "<group>"; };
-		F96D43C108F272B7004A47F5 /* unload.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = unload.test; sourceTree = "<group>"; };
-		F96D43C208F272B7004A47F5 /* uplevel.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = uplevel.test; sourceTree = "<group>"; };
-		F96D43C308F272B7004A47F5 /* upvar.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = upvar.test; sourceTree = "<group>"; };
-		F96D43C408F272B7004A47F5 /* utf.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = utf.test; sourceTree = "<group>"; };
-		F96D43C508F272B7004A47F5 /* util.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = util.test; sourceTree = "<group>"; };
-		F96D43C608F272B7004A47F5 /* var.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = var.test; sourceTree = "<group>"; };
-		F96D43C708F272B7004A47F5 /* while-old.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = "while-old.test"; sourceTree = "<group>"; };
-		F96D43C808F272B7004A47F5 /* while.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = while.test; sourceTree = "<group>"; };
-		F96D43C908F272B7004A47F5 /* winConsole.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winConsole.test; sourceTree = "<group>"; };
-		F96D43CA08F272B7004A47F5 /* winDde.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winDde.test; sourceTree = "<group>"; };
-		F96D43CB08F272B7004A47F5 /* winFCmd.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winFCmd.test; sourceTree = "<group>"; };
-		F96D43CC08F272B7004A47F5 /* winFile.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winFile.test; sourceTree = "<group>"; };
-		F96D43CD08F272B7004A47F5 /* winNotify.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winNotify.test; sourceTree = "<group>"; };
-		F96D43CE08F272B7004A47F5 /* winPipe.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winPipe.test; sourceTree = "<group>"; };
-		F96D43CF08F272B7004A47F5 /* winTime.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = winTime.test; sourceTree = "<group>"; };
-		F96D43D108F272B8004A47F5 /* checkLibraryDoc.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = checkLibraryDoc.tcl; sourceTree = "<group>"; };
-		F96D43D208F272B8004A47F5 /* configure */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = configure; sourceTree = "<group>"; };
-		F96D43D308F272B8004A47F5 /* configure.ac */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = configure.ac; sourceTree = "<group>"; };
-		F96D442208F272B8004A47F5 /* eolFix.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = eolFix.tcl; sourceTree = "<group>"; };
-		F96D442408F272B8004A47F5 /* fix_tommath_h.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = fix_tommath_h.tcl; sourceTree = "<group>"; };
-		F96D442508F272B8004A47F5 /* genStubs.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = genStubs.tcl; sourceTree = "<group>"; };
-		F96D442708F272B8004A47F5 /* index.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = index.tcl; sourceTree = "<group>"; };
-		F96D442808F272B8004A47F5 /* installData.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = installData.tcl; sourceTree = "<group>"; };
-		F96D442908F272B8004A47F5 /* loadICU.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = loadICU.tcl; sourceTree = "<group>"; };
-		F96D442A08F272B8004A47F5 /* Makefile.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = Makefile.in; sourceTree = "<group>"; };
-		F96D442B08F272B8004A47F5 /* makeTestCases.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = makeTestCases.tcl; sourceTree = "<group>"; };
-		F96D442C08F272B8004A47F5 /* man2help.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = man2help.tcl; sourceTree = "<group>"; };
-		F96D442D08F272B8004A47F5 /* man2help2.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = man2help2.tcl; sourceTree = "<group>"; };
-		F96D442E08F272B8004A47F5 /* man2html.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = man2html.tcl; sourceTree = "<group>"; };
-		F96D442F08F272B8004A47F5 /* man2html1.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = man2html1.tcl; sourceTree = "<group>"; };
-		F96D443008F272B8004A47F5 /* man2html2.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = man2html2.tcl; sourceTree = "<group>"; };
-		F96D443108F272B8004A47F5 /* man2tcl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = man2tcl.c; sourceTree = "<group>"; };
-		F96D443208F272B8004A47F5 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F96D443308F272B8004A47F5 /* regexpTestLib.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = regexpTestLib.tcl; sourceTree = "<group>"; };
-		F96D443508F272B8004A47F5 /* tcl.hpj.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tcl.hpj.in; sourceTree = "<group>"; };
-		F96D443608F272B8004A47F5 /* tcl.wse.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tcl.wse.in; sourceTree = "<group>"; };
-		F96D443908F272B9004A47F5 /* tcltk-man2html.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = "tcltk-man2html.tcl"; sourceTree = "<group>"; };
-		F96D443A08F272B9004A47F5 /* tclZIC.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tclZIC.tcl; sourceTree = "<group>"; };
-		F96D443B08F272B9004A47F5 /* uniClass.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = uniClass.tcl; sourceTree = "<group>"; };
-		F96D443C08F272B9004A47F5 /* uniParse.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = uniParse.tcl; sourceTree = "<group>"; };
-		F96D444008F272B9004A47F5 /* aclocal.m4 */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = aclocal.m4; sourceTree = "<group>"; };
-		F96D444108F272B9004A47F5 /* configure */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = configure; sourceTree = "<group>"; };
-		F96D444208F272B9004A47F5 /* configure.ac */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = configure.ac; sourceTree = "<group>"; };
-		F96D444408F272B9004A47F5 /* Makefile.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = Makefile.in; sourceTree = "<group>"; };
-		F96D444508F272B9004A47F5 /* pkga.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pkga.c; sourceTree = "<group>"; };
-		F96D444608F272B9004A47F5 /* pkgb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pkgb.c; sourceTree = "<group>"; };
-		F96D444708F272B9004A47F5 /* pkgc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pkgc.c; sourceTree = "<group>"; };
-		F96D444808F272B9004A47F5 /* pkgd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pkgd.c; sourceTree = "<group>"; };
-		F96D444908F272B9004A47F5 /* pkge.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pkge.c; sourceTree = "<group>"; };
-		F96D444B08F272B9004A47F5 /* pkgua.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pkgua.c; sourceTree = "<group>"; };
-		F96D444C08F272B9004A47F5 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F96D444D08F272B9004A47F5 /* install-sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "install-sh"; sourceTree = "<group>"; };
-		F96D444E08F272B9004A47F5 /* installManPage */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = installManPage; sourceTree = "<group>"; };
-		F96D444F08F272B9004A47F5 /* ldAix */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = ldAix; sourceTree = "<group>"; };
-		F96D445008F272B9004A47F5 /* Makefile.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = Makefile.in; sourceTree = "<group>"; };
-		F96D445208F272B9004A47F5 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F96D445308F272B9004A47F5 /* tcl.m4 */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = tcl.m4; sourceTree = "<group>"; };
-		F96D445408F272B9004A47F5 /* tcl.spec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tcl.spec; sourceTree = "<group>"; };
-		F96D445508F272B9004A47F5 /* tclAppInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclAppInit.c; sourceTree = "<group>"; };
-		F96D445608F272B9004A47F5 /* tclConfig.h.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = tclConfig.h.in; sourceTree = "<group>"; };
-		F96D445708F272B9004A47F5 /* tclConfig.sh.in */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = tclConfig.sh.in; sourceTree = "<group>"; };
-		F96D445808F272B9004A47F5 /* tclLoadAix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclLoadAix.c; sourceTree = "<group>"; };
-		F96D445908F272B9004A47F5 /* tclLoadDl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclLoadDl.c; sourceTree = "<group>"; };
-		F96D445B08F272B9004A47F5 /* tclLoadDyld.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclLoadDyld.c; sourceTree = "<group>"; };
-		F96D445C08F272B9004A47F5 /* tclLoadNext.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclLoadNext.c; sourceTree = "<group>"; };
-		F96D445D08F272B9004A47F5 /* tclLoadOSF.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclLoadOSF.c; sourceTree = "<group>"; };
-		F96D445E08F272B9004A47F5 /* tclLoadShl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclLoadShl.c; sourceTree = "<group>"; };
-		F96D445F08F272B9004A47F5 /* tclUnixChan.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUnixChan.c; sourceTree = "<group>"; };
-		F96D446008F272B9004A47F5 /* tclUnixEvent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUnixEvent.c; sourceTree = "<group>"; };
-		F96D446108F272B9004A47F5 /* tclUnixFCmd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUnixFCmd.c; sourceTree = "<group>"; };
-		F96D446208F272B9004A47F5 /* tclUnixFile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUnixFile.c; sourceTree = "<group>"; };
-		F96D446308F272B9004A47F5 /* tclUnixInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUnixInit.c; sourceTree = "<group>"; };
-		F96D446408F272B9004A47F5 /* tclUnixNotfy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUnixNotfy.c; sourceTree = "<group>"; };
-		F96D446508F272B9004A47F5 /* tclUnixPipe.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUnixPipe.c; sourceTree = "<group>"; };
-		F96D446608F272B9004A47F5 /* tclUnixPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclUnixPort.h; sourceTree = "<group>"; };
-		F96D446708F272B9004A47F5 /* tclUnixSock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUnixSock.c; sourceTree = "<group>"; };
-		F96D446808F272B9004A47F5 /* tclUnixTest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUnixTest.c; sourceTree = "<group>"; };
-		F96D446908F272B9004A47F5 /* tclUnixThrd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUnixThrd.c; sourceTree = "<group>"; };
-		F96D446A08F272B9004A47F5 /* tclUnixThrd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclUnixThrd.h; sourceTree = "<group>"; };
-		F96D446B08F272B9004A47F5 /* tclUnixTime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUnixTime.c; sourceTree = "<group>"; };
-		F96D446C08F272B9004A47F5 /* tclXtNotify.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclXtNotify.c; sourceTree = "<group>"; };
-		F96D446D08F272B9004A47F5 /* tclXtTest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclXtTest.c; sourceTree = "<group>"; };
-		F96D447008F272BA004A47F5 /* aclocal.m4 */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = aclocal.m4; sourceTree = "<group>"; };
-		F96D447108F272BA004A47F5 /* buildall.vc.bat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = buildall.vc.bat; sourceTree = "<group>"; };
-		F96D447208F272BA004A47F5 /* cat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cat.c; sourceTree = "<group>"; };
-		F96D447408F272BA004A47F5 /* configure */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = configure; sourceTree = "<group>"; };
-		F96D447508F272BA004A47F5 /* configure.ac */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = configure.ac; sourceTree = "<group>"; };
-		F96D447708F272BA004A47F5 /* Makefile.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = Makefile.in; sourceTree = "<group>"; };
-		F96D447808F272BA004A47F5 /* makefile.vc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.vc; sourceTree = "<group>"; };
-		F96D447908F272BA004A47F5 /* nmakehlp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nmakehlp.c; sourceTree = "<group>"; };
-		F96D447A08F272BA004A47F5 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
-		F96D447C08F272BA004A47F5 /* rules.vc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rules.vc; sourceTree = "<group>"; };
-		F96D447D08F272BA004A47F5 /* stub16.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stub16.c; sourceTree = "<group>"; };
-		F96D447E08F272BA004A47F5 /* tcl.dsp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tcl.dsp; sourceTree = "<group>"; };
-		F96D447F08F272BA004A47F5 /* tcl.dsw */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tcl.dsw; sourceTree = "<group>"; };
-		F96D448008F272BA004A47F5 /* tcl.hpj.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tcl.hpj.in; sourceTree = "<group>"; };
-		F96D448108F272BA004A47F5 /* tcl.m4 */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = tcl.m4; sourceTree = "<group>"; };
-		F96D448208F272BA004A47F5 /* tcl.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tcl.rc; sourceTree = "<group>"; };
-		F96D448308F272BA004A47F5 /* tclAppInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclAppInit.c; sourceTree = "<group>"; };
-		F96D448408F272BA004A47F5 /* tclConfig.sh.in */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = tclConfig.sh.in; sourceTree = "<group>"; };
-		F96D448608F272BA004A47F5 /* tclsh.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tclsh.rc; sourceTree = "<group>"; };
-		F96D448708F272BA004A47F5 /* tclWin32Dll.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWin32Dll.c; sourceTree = "<group>"; };
-		F96D448808F272BA004A47F5 /* tclWinChan.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinChan.c; sourceTree = "<group>"; };
-		F96D448908F272BA004A47F5 /* tclWinConsole.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinConsole.c; sourceTree = "<group>"; };
-		F96D448A08F272BA004A47F5 /* tclWinDde.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinDde.c; sourceTree = "<group>"; };
-		F96D448B08F272BA004A47F5 /* tclWinError.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinError.c; sourceTree = "<group>"; };
-		F96D448C08F272BA004A47F5 /* tclWinFCmd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinFCmd.c; sourceTree = "<group>"; };
-		F96D448D08F272BA004A47F5 /* tclWinFile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinFile.c; sourceTree = "<group>"; };
-		F96D448E08F272BA004A47F5 /* tclWinInit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinInit.c; sourceTree = "<group>"; };
-		F96D448F08F272BA004A47F5 /* tclWinInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclWinInt.h; sourceTree = "<group>"; };
-		F96D449008F272BA004A47F5 /* tclWinLoad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinLoad.c; sourceTree = "<group>"; };
-		F96D449108F272BA004A47F5 /* tclWinNotify.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinNotify.c; sourceTree = "<group>"; };
-		F96D449208F272BA004A47F5 /* tclWinPipe.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinPipe.c; sourceTree = "<group>"; };
-		F96D449308F272BA004A47F5 /* tclWinPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclWinPort.h; sourceTree = "<group>"; };
-		F96D449408F272BA004A47F5 /* tclWinReg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinReg.c; sourceTree = "<group>"; };
-		F96D449508F272BA004A47F5 /* tclWinSerial.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinSerial.c; sourceTree = "<group>"; };
-		F96D449608F272BA004A47F5 /* tclWinSock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinSock.c; sourceTree = "<group>"; };
-		F96D449708F272BA004A47F5 /* tclWinTest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinTest.c; sourceTree = "<group>"; };
-		F96D449808F272BA004A47F5 /* tclWinThrd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinThrd.c; sourceTree = "<group>"; };
-		F96D449908F272BA004A47F5 /* tclWinThrd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclWinThrd.h; sourceTree = "<group>"; };
-		F96D449A08F272BA004A47F5 /* tclWinTime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclWinTime.c; sourceTree = "<group>"; };
-		F973E5960EE99384001A648E /* vistaTheme.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = vistaTheme.tcl; sourceTree = "<group>"; };
-		F974D56C0FBE7D6300BF728B /* http11.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = http11.test; sourceTree = "<group>"; };
-		F974D56D0FBE7D6300BF728B /* httpd11.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = httpd11.tcl; sourceTree = "<group>"; };
-		F974D5720FBE7DC600BF728B /* coroutine.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = coroutine.n; sourceTree = "<group>"; };
-		F974D5760FBE7E1900BF728B /* tailcall.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = tailcall.n; sourceTree = "<group>"; };
-		F974D5770FBE7E6100BF728B /* coroutine.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = coroutine.test; sourceTree = "<group>"; };
-		F974D5780FBE7E6100BF728B /* tailcall.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tailcall.test; sourceTree = "<group>"; };
-		F974D5790FBE7E9C00BF728B /* tcl.pc.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tcl.pc.in; sourceTree = "<group>"; };
-		F974D57B0FBE7EC000BF728B /* tk.pc.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tk.pc.in; sourceTree = "<group>"; };
-		F974D57C0FBE7EFF00BF728B /* iconlist.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = iconlist.tcl; sourceTree = "<group>"; };
-		F974D57D0FBE7EFF00BF728B /* icons.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = icons.tcl; sourceTree = "<group>"; };
-		F97590AE1039A96200558A9A /* Wish.sdef */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.sdef; path = Wish.sdef; sourceTree = "<group>"; };
-		F976F6A70C325FB6005066D9 /* tkMacOSXPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXPrivate.h; sourceTree = "<group>"; };
-		F97AE7F10B65C1E900310EA2 /* Tk-Common.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Tk-Common.xcconfig"; sourceTree = "<group>"; };
-		F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Tk-Release.xcconfig"; sourceTree = "<group>"; };
-		F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Tk-Debug.xcconfig"; sourceTree = "<group>"; };
-		F98383650F0FA43900171CA6 /* checkbutton.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = checkbutton.test; sourceTree = "<group>"; };
-		F98383680F0FA44700171CA6 /* radiobutton.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = radiobutton.test; sourceTree = "<group>"; };
-		F9903CAF094FAADA004613E9 /* tclTomMath.decls */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = tclTomMath.decls; sourceTree = "<group>"; };
-		F9903CB0094FAADA004613E9 /* tclTomMathDecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tclTomMathDecls.h; sourceTree = "<group>"; };
-		F99388380EE0114B0065FE6B /* fontchooser.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = fontchooser.tcl; sourceTree = "<group>"; };
-		F99388950EE02D980065FE6B /* fontchooser.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = fontchooser.test; sourceTree = "<group>"; };
-		F99D61180EF5573A00BBFE01 /* TclZlib.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = TclZlib.3; sourceTree = "<group>"; };
-		F9A3082D08F2D4AB00BAE1AB /* Tk.framework */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.framework; path = Tk.framework; sourceTree = BUILT_PRODUCTS_DIR; };
-		F9A3084B08F2D4CE00BAE1AB /* Wish.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Wish.app; sourceTree = BUILT_PRODUCTS_DIR; };
-		F9A3084E08F2D4F400BAE1AB /* Tcl.framework */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.framework; path = Tcl.framework; sourceTree = BUILT_PRODUCTS_DIR; };
-		F9A493240CEBF38300B78AE2 /* chanio.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = chanio.test; sourceTree = "<group>"; };
-		F9C888C20EEF6571003F63AD /* fontchooser.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = fontchooser.n; sourceTree = "<group>"; };
-		F9C9CBFF0E84059800E00935 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
-		F9D1360A0CDC252C00DBE0B5 /* mclist.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = mclist.tcl; sourceTree = "<group>"; };
-		F9DD99BC0F07DF850018B2E4 /* tkImgPNG.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tkImgPNG.c; sourceTree = "<group>"; };
-		F9DD99BF0F07DFCD0018B2E4 /* imgPNG.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = imgPNG.test; sourceTree = "<group>"; };
-		F9ECB1120B26521500A28025 /* pkgIndex.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = pkgIndex.tcl; sourceTree = "<group>"; };
-		F9ECB1130B26521500A28025 /* platform.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = platform.tcl; sourceTree = "<group>"; };
-		F9ECB1140B26521500A28025 /* shell.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = shell.tcl; sourceTree = "<group>"; };
-		F9ECB1CA0B2652D300A28025 /* apply.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = apply.test; sourceTree = "<group>"; };
-		F9ECB1CB0B26534C00A28025 /* mathop.test */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; path = mathop.test; sourceTree = "<group>"; };
-		F9ECB1E10B26543C00A28025 /* platform_shell.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = platform_shell.n; sourceTree = "<group>"; };
-		F9ECB1E20B26543C00A28025 /* platform.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = platform.n; sourceTree = "<group>"; };
-		F9F4415D0C8BAE6F00BCCD67 /* tclDTrace.d */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.dtrace; path = tclDTrace.d; sourceTree = "<group>"; };
-		F9F4EFDC0CC7B3CA00378A27 /* ttkpane.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; languageSpecificationIdentifier = shell; path = ttkpane.tcl; sourceTree = "<group>"; };
-		F9F4EFDD0CC7B3CB00378A27 /* ttkmenu.tcl */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; languageSpecificationIdentifier = shell; path = ttkmenu.tcl; sourceTree = "<group>"; };
-		F9FC77B70AB29E9100B7077D /* tclUnixCompat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tclUnixCompat.c; sourceTree = "<group>"; };
-		F9FD31F40CC1AD070073837D /* tktest-X11 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "tktest-X11"; sourceTree = BUILT_PRODUCTS_DIR; };
-		F9FD32140CC1AF170073837D /* libX11.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libX11.dylib; path = /usr/X11R6/lib/libX11.dylib; sourceTree = "<absolute>"; };
-		F9FD32150CC1AF170073837D /* libXext.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libXext.dylib; path = /usr/X11R6/lib/libXext.dylib; sourceTree = "<absolute>"; };
-		F9FD32160CC1AF170073837D /* libXss.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libXss.dylib; path = /usr/X11R6/lib/libXss.dylib; sourceTree = "<absolute>"; };
-		F9FD34990CC1BB0D0073837D /* libfreetype.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfreetype.dylib; path = /usr/X11R6/lib/libfreetype.dylib; sourceTree = "<absolute>"; };
-		F9FD349A0CC1BB0D0073837D /* libXft.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libXft.dylib; path = /usr/X11R6/lib/libXft.dylib; sourceTree = "<absolute>"; };
-		F9FD34C30CC1BBD70073837D /* libfontconfig.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfontconfig.dylib; path = /usr/X11R6/lib/libfontconfig.dylib; sourceTree = "<absolute>"; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
-		8DD76FAD0486AB0100D96B5E /* Frameworks */ = {
-			isa = PBXFrameworksBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				F966C07508F2820D005CB29B /* CoreFoundation.framework in Frameworks */,
-				F96437E70EF0D652003F468E /* libz.dylib in Frameworks */,
-				F966C07708F2821B005CB29B /* Carbon.framework in Frameworks */,
-				F966C07908F28233005CB29B /* IOKit.framework in Frameworks */,
-				F94523A20E6FC2AC00C1D987 /* Cocoa.framework in Frameworks */,
-				F9C9CC000E84059800E00935 /* ApplicationServices.framework in Frameworks */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		F9FD31E30CC1AD070073837D /* Frameworks */ = {
-			isa = PBXFrameworksBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				F9FD31E40CC1AD070073837D /* CoreFoundation.framework in Frameworks */,
-				F96437E80EF0D652003F468E /* libz.dylib in Frameworks */,
-				F9FD32170CC1AF170073837D /* libX11.dylib in Frameworks */,
-				F9FD32180CC1AF170073837D /* libXext.dylib in Frameworks */,
-				F9FD32190CC1AF170073837D /* libXss.dylib in Frameworks */,
-				F9FD349C0CC1BB0D0073837D /* libXft.dylib in Frameworks */,
-				F9FD349B0CC1BB0D0073837D /* libfreetype.dylib in Frameworks */,
-				F9FD34C40CC1BBD70073837D /* libfontconfig.dylib in Frameworks */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
-		08FB7794FE84155DC02AAC07 /* Tk */ = {
-			isa = PBXGroup;
-			children = (
-				F96D3DF708F271BE004A47F5 /* Tk Sources */,
-				F96D3DF608F27169004A47F5 /* Tcl Sources */,
-				F966C06F08F281DC005CB29B /* Frameworks */,
-				1AB674ADFE9D54B511CA2CBB /* Products */,
-			);
-			comments = "Copyright (c) 2004-2009 Daniel A. Steffen <das@users.sourceforge.net>\nCopyright 2008-2009, Apple Inc.\n\nSee the file \"license.terms\" for information on usage and redistribution of\nthis file, and for a DISCLAIMER OF ALL WARRANTIES.\n";
-			name = Tk;
-			path = .;
-			sourceTree = SOURCE_ROOT;
-		};
-		1AB674ADFE9D54B511CA2CBB /* Products */ = {
-			isa = PBXGroup;
-			children = (
-				F9A3084B08F2D4CE00BAE1AB /* Wish.app */,
-				F9A3082D08F2D4AB00BAE1AB /* Tk.framework */,
-				F9A3084E08F2D4F400BAE1AB /* Tcl.framework */,
-				8DD76FB20486AB0100D96B5E /* tktest */,
-				F9FD31F40CC1AD070073837D /* tktest-X11 */,
-			);
-			includeInIndex = 0;
-			name = Products;
-			sourceTree = "<group>";
-		};
-		F9183E690EFC81560030B814 /* pkgs */ = {
-			isa = PBXGroup;
-			children = (
-				F9183E6A0EFC81560030B814 /* README */,
-				F946FB8B0FBE3AED00CD6495 /* itcl */,
-				F9183E8F0EFC817B0030B814 /* tdbc */,
-			);
-			path = pkgs;
-			sourceTree = "<group>";
-		};
-		F966BA0308F27A37005CB29B /* bitmaps */ = {
-			isa = PBXGroup;
-			children = (
-				F966BA0408F27A37005CB29B /* error.xbm */,
-				F966BA0508F27A37005CB29B /* gray12.xbm */,
-				F966BA0608F27A37005CB29B /* gray25.xbm */,
-				F966BA0708F27A37005CB29B /* gray50.xbm */,
-				F966BA0808F27A37005CB29B /* gray75.xbm */,
-				F966BA0908F27A37005CB29B /* hourglass.xbm */,
-				F966BA0A08F27A37005CB29B /* info.xbm */,
-				F966BA0B08F27A37005CB29B /* questhead.xbm */,
-				F966BA0C08F27A37005CB29B /* question.xbm */,
-				F966BA0D08F27A37005CB29B /* warning.xbm */,
-			);
-			path = bitmaps;
-			sourceTree = "<group>";
-		};
-		F966BA1008F27A37005CB29B /* doc */ = {
-			isa = PBXGroup;
-			children = (
-				F966BA1108F27A37005CB29B /* 3DBorder.3 */,
-				F966BA1208F27A37005CB29B /* AddOption.3 */,
-				F966BA1308F27A37005CB29B /* bell.n */,
-				F966BA1408F27A37005CB29B /* bind.n */,
-				F966BA1508F27A37005CB29B /* BindTable.3 */,
-				F966BA1608F27A37005CB29B /* bindtags.n */,
-				F966BA1708F27A37005CB29B /* bitmap.n */,
-				F966BA1808F27A37005CB29B /* button.n */,
-				F966BA1908F27A37005CB29B /* canvas.n */,
-				F966BA1A08F27A37005CB29B /* CanvPsY.3 */,
-				F966BA1B08F27A37005CB29B /* CanvTkwin.3 */,
-				F966BA1C08F27A37005CB29B /* CanvTxtInfo.3 */,
-				F966BA1D08F27A37005CB29B /* checkbutton.n */,
-				F966BA1E08F27A37005CB29B /* chooseColor.n */,
-				F966BA1F08F27A37005CB29B /* chooseDirectory.n */,
-				F966BA2008F27A37005CB29B /* Clipboard.3 */,
-				F966BA2108F27A37005CB29B /* clipboard.n */,
-				F966BA2208F27A37005CB29B /* ClrSelect.3 */,
-				F966BA2308F27A37005CB29B /* colors.n */,
-				F966BA2408F27A37005CB29B /* ConfigWidg.3 */,
-				F966BA2508F27A37005CB29B /* ConfigWind.3 */,
-				F966BA2608F27A37005CB29B /* console.n */,
-				F966BA2708F27A37005CB29B /* CoordToWin.3 */,
-				F966BA2808F27A37005CB29B /* CrtCmHdlr.3 */,
-				F966BA2908F27A37005CB29B /* CrtErrHdlr.3 */,
-				F966BA2A08F27A37005CB29B /* CrtGenHdlr.3 */,
-				F966BA2B08F27A37005CB29B /* CrtImgType.3 */,
-				F966BA2C08F27A37005CB29B /* CrtItemType.3 */,
-				F966BA2D08F27A37005CB29B /* CrtPhImgFmt.3 */,
-				F966BA2E08F27A37005CB29B /* CrtSelHdlr.3 */,
-				F966BA2F08F27A37005CB29B /* CrtWindow.3 */,
-				F966BA3008F27A37005CB29B /* cursors.n */,
-				F966BA3108F27A37005CB29B /* DeleteImg.3 */,
-				F966BA3208F27A37005CB29B /* destroy.n */,
-				F966BA3308F27A37005CB29B /* dialog.n */,
-				F966BA3408F27A37005CB29B /* DrawFocHlt.3 */,
-				F966BA3508F27A37005CB29B /* entry.n */,
-				F966BA3608F27A37005CB29B /* event.n */,
-				F966BA3708F27A37005CB29B /* EventHndlr.3 */,
-				F966BA3808F27A37005CB29B /* FindPhoto.3 */,
-				F966BA3908F27A37005CB29B /* focus.n */,
-				F966BA3A08F27A37005CB29B /* focusNext.n */,
-				F966BA3B08F27A37005CB29B /* font.n */,
-				F9C888C20EEF6571003F63AD /* fontchooser.n */,
-				F966BA3C08F27A37005CB29B /* FontId.3 */,
-				F966BA3D08F27A37005CB29B /* frame.n */,
-				F966BA3E08F27A37005CB29B /* FreeXId.3 */,
-				F966BA3F08F27A37005CB29B /* GeomReq.3 */,
-				F966BA4008F27A37005CB29B /* GetAnchor.3 */,
-				F966BA4108F27A37005CB29B /* GetBitmap.3 */,
-				F966BA4208F27A37005CB29B /* GetCapStyl.3 */,
-				F966BA4308F27A37005CB29B /* GetClrmap.3 */,
-				F966BA4408F27A37005CB29B /* GetColor.3 */,
-				F966BA4508F27A37005CB29B /* GetCursor.3 */,
-				F966BA4608F27A37005CB29B /* GetDash.3 */,
-				F966BA4708F27A37005CB29B /* GetFont.3 */,
-				F966BA4808F27A37005CB29B /* GetGC.3 */,
-				F966BA4908F27A37005CB29B /* GetHINSTANCE.3 */,
-				F966BA4A08F27A37005CB29B /* GetHWND.3 */,
-				F966BA4B08F27A37005CB29B /* GetImage.3 */,
-				F966BA4C08F27A37005CB29B /* GetJoinStl.3 */,
-				F966BA4D08F27A37005CB29B /* GetJustify.3 */,
-				F966BA4E08F27A37005CB29B /* getOpenFile.n */,
-				F966BA4F08F27A37005CB29B /* GetOption.3 */,
-				F966BA5008F27A38005CB29B /* GetPixels.3 */,
-				F966BA5108F27A38005CB29B /* GetPixmap.3 */,
-				F966BA5208F27A38005CB29B /* GetRelief.3 */,
-				F966BA5308F27A38005CB29B /* GetRootCrd.3 */,
-				F966BA5408F27A38005CB29B /* GetScroll.3 */,
-				F966BA5508F27A38005CB29B /* GetSelect.3 */,
-				F966BA5608F27A38005CB29B /* GetUid.3 */,
-				F966BA5708F27A38005CB29B /* GetVisual.3 */,
-				F966BA5808F27A38005CB29B /* GetVRoot.3 */,
-				F966BA5908F27A38005CB29B /* Grab.3 */,
-				F966BA5A08F27A38005CB29B /* grab.n */,
-				F966BA5B08F27A38005CB29B /* grid.n */,
-				F966BA5C08F27A38005CB29B /* HandleEvent.3 */,
-				F966BA5D08F27A38005CB29B /* HWNDToWindow.3 */,
-				F966BA5E08F27A38005CB29B /* IdToWindow.3 */,
-				F966BA5F08F27A38005CB29B /* image.n */,
-				F966BA6008F27A38005CB29B /* ImgChanged.3 */,
-				F966BA6108F27A38005CB29B /* Inactive.3 */,
-				F966BA6208F27A38005CB29B /* InternAtom.3 */,
-				F966BA6308F27A38005CB29B /* keysyms.n */,
-				F966BA6408F27A38005CB29B /* label.n */,
-				F966BA6508F27A38005CB29B /* labelframe.n */,
-				F966BA6608F27A38005CB29B /* listbox.n */,
-				F966BA6708F27A38005CB29B /* loadTk.n */,
-				F966BA6808F27A38005CB29B /* lower.n */,
-				F966BA6908F27A38005CB29B /* MainLoop.3 */,
-				F966BA6A08F27A38005CB29B /* MaintGeom.3 */,
-				F966BA6B08F27A38005CB29B /* MainWin.3 */,
-				F966BA6D08F27A38005CB29B /* ManageGeom.3 */,
-				F966BA6E08F27A38005CB29B /* MapWindow.3 */,
-				F966BA6F08F27A38005CB29B /* MeasureChar.3 */,
-				F966BA7008F27A38005CB29B /* menu.n */,
-				F966BA7108F27A38005CB29B /* menubar.n */,
-				F966BA7208F27A38005CB29B /* menubutton.n */,
-				F966BA7308F27A38005CB29B /* message.n */,
-				F966BA7408F27A38005CB29B /* messageBox.n */,
-				F966BA7508F27A38005CB29B /* MoveToplev.3 */,
-				F966BA7608F27A38005CB29B /* Name.3 */,
-				F966BA7708F27A38005CB29B /* NameOfImg.3 */,
-				F966BA7808F27A38005CB29B /* option.n */,
-				F966BA7908F27A38005CB29B /* optionMenu.n */,
-				F966BA7A08F27A38005CB29B /* options.n */,
-				F966BA7B08F27A38005CB29B /* OwnSelect.3 */,
-				F966BA7C08F27A38005CB29B /* pack-old.n */,
-				F966BA7D08F27A38005CB29B /* pack.n */,
-				F966BA7E08F27A38005CB29B /* palette.n */,
-				F966BA7F08F27A38005CB29B /* panedwindow.n */,
-				F966BA8008F27A38005CB29B /* ParseArgv.3 */,
-				F966BA8108F27A38005CB29B /* photo.n */,
-				F966BA8208F27A38005CB29B /* place.n */,
-				F966BA8308F27A38005CB29B /* popup.n */,
-				F966BA8408F27A38005CB29B /* QWinEvent.3 */,
-				F966BA8508F27A38005CB29B /* radiobutton.n */,
-				F966BA8608F27A38005CB29B /* raise.n */,
-				F966BA8708F27A38005CB29B /* Restack.3 */,
-				F966BA8808F27A38005CB29B /* RestrictEv.3 */,
-				F966BA8908F27A38005CB29B /* scale.n */,
-				F966BA8A08F27A38005CB29B /* scrollbar.n */,
-				F966BA8B08F27A38005CB29B /* selection.n */,
-				F966BA8C08F27A38005CB29B /* send.n */,
-				F966BA8D08F27A38005CB29B /* SetAppName.3 */,
-				F966BA8E08F27A38005CB29B /* SetCaret.3 */,
-				F966BA8F08F27A38005CB29B /* SetClass.3 */,
-				F966BA9008F27A38005CB29B /* SetClassProcs.3 */,
-				F966BA9108F27A38005CB29B /* SetGrid.3 */,
-				F966BA9208F27A38005CB29B /* SetOptions.3 */,
-				F966BA9308F27A38005CB29B /* SetVisual.3 */,
-				F966BA9408F27A38005CB29B /* spinbox.n */,
-				F966BA9508F27A38005CB29B /* StrictMotif.3 */,
-				F966BA9608F27A38005CB29B /* text.n */,
-				F966BA9708F27A38005CB29B /* TextLayout.3 */,
-				F966BA9808F27A38005CB29B /* tk.n */,
-				F966BA9A08F27A38005CB29B /* Tk_Init.3 */,
-				F966BA9B08F27A38005CB29B /* Tk_Main.3 */,
-				F966BA9C08F27A38005CB29B /* tkerror.n */,
-				F966BA9D08F27A38005CB29B /* TkInitStubs.3 */,
-				F966BA9E08F27A38005CB29B /* tkvars.n */,
-				F966BA9F08F27A38005CB29B /* tkwait.n */,
-				F966BAA008F27A38005CB29B /* toplevel.n */,
-				F968886B0AF788F6000797B5 /* ttk_button.n */,
-				F968886C0AF788F6000797B5 /* ttk_checkbutton.n */,
-				F968886D0AF788F6000797B5 /* ttk_combobox.n */,
-				F968886F0AF788F6000797B5 /* ttk_entry.n */,
-				F96888700AF788F6000797B5 /* ttk_frame.n */,
-				F96888710AF788F6000797B5 /* ttk_Geometry.3 */,
-				F96888720AF788F6000797B5 /* ttk_image.n */,
-				F96888730AF788F6000797B5 /* ttk_intro.n */,
-				F96888740AF788F6000797B5 /* ttk_label.n */,
-				F96888750AF788F6000797B5 /* ttk_labelframe.n */,
-				F96888760AF788F6000797B5 /* ttk_menubutton.n */,
-				F96888770AF788F6000797B5 /* ttk_notebook.n */,
-				F96888780AF788F6000797B5 /* ttk_panedwindow.n */,
-				F96888790AF788F6000797B5 /* ttk_progressbar.n */,
-				F968887A0AF788F6000797B5 /* ttk_radiobutton.n */,
-				F968887B0AF788F6000797B5 /* ttk_scrollbar.n */,
-				F968887C0AF788F6000797B5 /* ttk_separator.n */,
-				F968887D0AF788F6000797B5 /* ttk_sizegrip.n */,
-				F968887E0AF788F6000797B5 /* ttk_style.n */,
-				F968887F0AF788F6000797B5 /* ttk_Theme.3 */,
-				F96888800AF788F6000797B5 /* ttk_treeview.n */,
-				F96888810AF788F6000797B5 /* ttk_widget.n */,
-				F966BAA108F27A38005CB29B /* WindowId.3 */,
-				F966BAA208F27A38005CB29B /* winfo.n */,
-				F966BAA308F27A38005CB29B /* wish.1 */,
-				F966BAA408F27A38005CB29B /* wm.n */,
-			);
-			path = doc;
-			sourceTree = "<group>";
-		};
-		F966BAA508F27A38005CB29B /* generic */ = {
-			isa = PBXGroup;
-			children = (
-				F966BAA608F27A38005CB29B /* default.h */,
-				F966BAA708F27A38005CB29B /* ks_names.h */,
-				F966BAA908F27A39005CB29B /* README */,
-				F966BAAA08F27A39005CB29B /* tk.decls */,
-				F966BAAB08F27A39005CB29B /* tk.h */,
-				F966BAAC08F27A39005CB29B /* tk3d.c */,
-				F966BAAD08F27A39005CB29B /* tk3d.h */,
-				F966BAAE08F27A39005CB29B /* tkArgv.c */,
-				F966BAAF08F27A39005CB29B /* tkAtom.c */,
-				F966BAB008F27A39005CB29B /* tkBind.c */,
-				F966BAB108F27A39005CB29B /* tkBitmap.c */,
-				F9152B080EAF8A5000CD5C7B /* tkBusy.c */,
-				F966BAB208F27A39005CB29B /* tkButton.c */,
-				F966BAB308F27A39005CB29B /* tkButton.h */,
-				F966BAB408F27A39005CB29B /* tkCanvArc.c */,
-				F966BAB508F27A39005CB29B /* tkCanvas.c */,
-				F966BAB608F27A39005CB29B /* tkCanvas.h */,
-				F966BAB708F27A39005CB29B /* tkCanvBmap.c */,
-				F966BAB808F27A39005CB29B /* tkCanvImg.c */,
-				F966BAB908F27A39005CB29B /* tkCanvLine.c */,
-				F966BABA08F27A39005CB29B /* tkCanvPoly.c */,
-				F966BABB08F27A39005CB29B /* tkCanvPs.c */,
-				F966BABD08F27A39005CB29B /* tkCanvText.c */,
-				F966BABE08F27A39005CB29B /* tkCanvUtil.c */,
-				F966BABF08F27A39005CB29B /* tkCanvWind.c */,
-				F966BAC008F27A39005CB29B /* tkClipboard.c */,
-				F966BAC108F27A39005CB29B /* tkCmds.c */,
-				F966BAC208F27A39005CB29B /* tkColor.c */,
-				F966BAC308F27A39005CB29B /* tkColor.h */,
-				F966BAC408F27A39005CB29B /* tkConfig.c */,
-				F966BAC508F27A39005CB29B /* tkConsole.c */,
-				F966BAC608F27A39005CB29B /* tkCursor.c */,
-				F966BAC708F27A39005CB29B /* tkDecls.h */,
-				F966BAC808F27A39005CB29B /* tkEntry.c */,
-				F966BAC908F27A39005CB29B /* tkEntry.h */,
-				F966BACA08F27A39005CB29B /* tkError.c */,
-				F966BACB08F27A39005CB29B /* tkEvent.c */,
-				F966BACC08F27A39005CB29B /* tkFileFilter.c */,
-				F966BACD08F27A39005CB29B /* tkFileFilter.h */,
-				F966BACE08F27A39005CB29B /* tkFocus.c */,
-				F966BACF08F27A39005CB29B /* tkFont.c */,
-				F966BAD008F27A39005CB29B /* tkFont.h */,
-				F966BAD108F27A39005CB29B /* tkFrame.c */,
-				F966BAD208F27A39005CB29B /* tkGC.c */,
-				F966BAD308F27A39005CB29B /* tkGeometry.c */,
-				F966BAD408F27A39005CB29B /* tkGet.c */,
-				F966BAD508F27A39005CB29B /* tkGrab.c */,
-				F966BAD608F27A39005CB29B /* tkGrid.c */,
-				F966BAD708F27A39005CB29B /* tkImage.c */,
-				F966BAD808F27A39005CB29B /* tkImgBmap.c */,
-				F966BAD908F27A39005CB29B /* tkImgGIF.c */,
-				F92EE8BE0E62F846001A6E80 /* tkImgPhInstance.c */,
-				F966BADA08F27A39005CB29B /* tkImgPhoto.c */,
-				F9DD99BC0F07DF850018B2E4 /* tkImgPNG.c */,
-				F966BADB08F27A39005CB29B /* tkImgPPM.c */,
-				F966BADC08F27A39005CB29B /* tkImgUtil.c */,
-				F966BADE08F27A39005CB29B /* tkInt.decls */,
-				F966BADF08F27A39005CB29B /* tkInt.h */,
-				F966BAE108F27A39005CB29B /* tkIntDecls.h */,
-				F966BAE208F27A39005CB29B /* tkIntPlatDecls.h */,
-				F966BAE308F27A39005CB29B /* tkIntXlibDecls.h */,
-				F966BAE408F27A39005CB29B /* tkListbox.c */,
-				F966BAE508F27A39005CB29B /* tkMacWinMenu.c */,
-				F966BAE608F27A39005CB29B /* tkMain.c */,
-				F966BAE708F27A39005CB29B /* tkMenu.c */,
-				F966BAE808F27A39005CB29B /* tkMenu.h */,
-				F966BAE908F27A39005CB29B /* tkMenubutton.c */,
-				F966BAEA08F27A39005CB29B /* tkMenubutton.h */,
-				F966BAEB08F27A39005CB29B /* tkMenuDraw.c */,
-				F966BAEC08F27A39005CB29B /* tkMessage.c */,
-				F966BAED08F27A39005CB29B /* tkObj.c */,
-				F966BAEE08F27A39005CB29B /* tkOldConfig.c */,
-				F966BAEF08F27A39005CB29B /* tkOption.c */,
-				F966BAF008F27A39005CB29B /* tkPack.c */,
-				F966BAF108F27A39005CB29B /* tkPanedWindow.c */,
-				F966BAF208F27A39005CB29B /* tkPlace.c */,
-				F966BAF308F27A39005CB29B /* tkPlatDecls.h */,
-				F966BAF408F27A39005CB29B /* tkPointer.c */,
-				F966BAF508F27A39005CB29B /* tkPort.h */,
-				F966BAF608F27A39005CB29B /* tkRectOval.c */,
-				F966BAF708F27A39005CB29B /* tkScale.c */,
-				F966BAF808F27A39005CB29B /* tkScale.h */,
-				F966BAF908F27A39005CB29B /* tkScrollbar.c */,
-				F966BAFA08F27A39005CB29B /* tkScrollbar.h */,
-				F966BAFB08F27A39005CB29B /* tkSelect.c */,
-				F966BAFC08F27A39005CB29B /* tkSelect.h */,
-				F966BAFD08F27A39005CB29B /* tkSquare.c */,
-				F966BAFE08F27A39005CB29B /* tkOldTest.c */,
-				F966BAFF08F27A39005CB29B /* tkStubInit.c */,
-				F966BB0008F27A39005CB29B /* tkStubLib.c */,
-				F966BB0108F27A39005CB29B /* tkStyle.c */,
-				F966BB0208F27A39005CB29B /* tkTest.c */,
-				F966BB0308F27A39005CB29B /* tkText.c */,
-				F966BB0408F27A39005CB29B /* tkText.h */,
-				F966BB0508F27A39005CB29B /* tkTextBTree.c */,
-				F966BB0608F27A39005CB29B /* tkTextDisp.c */,
-				F966BB0808F27A39005CB29B /* tkTextImage.c */,
-				F966BB0908F27A39005CB29B /* tkTextIndex.c */,
-				F966BB0A08F27A39005CB29B /* tkTextMark.c */,
-				F966BB0B08F27A39005CB29B /* tkTextTag.c */,
-				F966BB0C08F27A39005CB29B /* tkTextWind.c */,
-				F966BB0D08F27A39005CB29B /* tkTrig.c */,
-				F966BB0E08F27A39005CB29B /* tkUndo.c */,
-				F966BB0F08F27A39005CB29B /* tkUndo.h */,
-				F966BB1008F27A39005CB29B /* tkUtil.c */,
-				F966BB1108F27A39005CB29B /* tkVisual.c */,
-				F966BB1208F27A39005CB29B /* tkWindow.c */,
-				F96887DF0AF786D5000797B5 /* ttk */,
-			);
-			path = generic;
-			sourceTree = "<group>";
-		};
-		F966BB1308F27A39005CB29B /* library */ = {
-			isa = PBXGroup;
-			children = (
-				F966BB1408F27A39005CB29B /* bgerror.tcl */,
-				F966BB1508F27A39005CB29B /* button.tcl */,
-				F966BB1608F27A39005CB29B /* choosedir.tcl */,
-				F966BB1708F27A39005CB29B /* clrpick.tcl */,
-				F966BB1808F27A39005CB29B /* comdlg.tcl */,
-				F966BB1908F27A39005CB29B /* console.tcl */,
-				F966BB1A08F27A39005CB29B /* demos */,
-				F966BB6208F27A3A005CB29B /* dialog.tcl */,
-				F966BB6308F27A3A005CB29B /* entry.tcl */,
-				F966BB6408F27A3A005CB29B /* focus.tcl */,
-				F99388380EE0114B0065FE6B /* fontchooser.tcl */,
-				F974D57C0FBE7EFF00BF728B /* iconlist.tcl */,
-				F974D57D0FBE7EFF00BF728B /* icons.tcl */,
-				F966BB7308F27A3A005CB29B /* listbox.tcl */,
-				F966BB7408F27A3A005CB29B /* menu.tcl */,
-				F966BB7508F27A3A005CB29B /* mkpsenc.tcl */,
-				F966BB7608F27A3A005CB29B /* msgbox.tcl */,
-				F966BB8608F27A3A005CB29B /* obsolete.tcl */,
-				F966BB8708F27A3A005CB29B /* optMenu.tcl */,
-				F966BB8808F27A3A005CB29B /* palette.tcl */,
-				F966BB8908F27A3B005CB29B /* panedwindow.tcl */,
-				F966BB8B08F27A3B005CB29B /* safetk.tcl */,
-				F966BB8C08F27A3B005CB29B /* scale.tcl */,
-				F966BB8D08F27A3B005CB29B /* scrlbar.tcl */,
-				F966BB8E08F27A3B005CB29B /* spinbox.tcl */,
-				F966BB8F08F27A3B005CB29B /* tclIndex */,
-				F966BB9008F27A3B005CB29B /* tearoff.tcl */,
-				F966BB9108F27A3B005CB29B /* text.tcl */,
-				F966BB9208F27A3B005CB29B /* tk.tcl */,
-				F966BB9308F27A3B005CB29B /* tkfbox.tcl */,
-				F96888360AF787B3000797B5 /* ttk */,
-				F966BB9408F27A3B005CB29B /* unsupported.tcl */,
-				F966BB9508F27A3B005CB29B /* xmfbox.tcl */,
-			);
-			path = library;
-			sourceTree = "<group>";
-		};
-		F966BB1A08F27A39005CB29B /* demos */ = {
-			isa = PBXGroup;
-			children = (
-				F966BB1B08F27A39005CB29B /* anilabel.tcl */,
-				F966BB1C08F27A39005CB29B /* aniwave.tcl */,
-				F966BB1D08F27A39005CB29B /* arrow.tcl */,
-				F966BB1E08F27A39005CB29B /* bind.tcl */,
-				F966BB1F08F27A39005CB29B /* bitmap.tcl */,
-				F966BB2008F27A39005CB29B /* browse */,
-				F966BB2108F27A39005CB29B /* button.tcl */,
-				F966BB2208F27A39005CB29B /* check.tcl */,
-				F966BB2308F27A39005CB29B /* clrpick.tcl */,
-				F966BB2408F27A39005CB29B /* colors.tcl */,
-				F936FCDB0CCD984600716967 /* combo.tcl */,
-				F966BB2508F27A39005CB29B /* cscroll.tcl */,
-				F966BB2608F27A39005CB29B /* ctext.tcl */,
-				F966BB2708F27A39005CB29B /* dialog1.tcl */,
-				F966BB2808F27A39005CB29B /* dialog2.tcl */,
-				F966BB2A08F27A39005CB29B /* entry1.tcl */,
-				F966BB2B08F27A39005CB29B /* entry2.tcl */,
-				F966BB2C08F27A39005CB29B /* entry3.tcl */,
-				F966BB2D08F27A39005CB29B /* filebox.tcl */,
-				F966BB2E08F27A39005CB29B /* floor.tcl */,
-				F91543270EF201A90032D1E8 /* fontchoose.tcl */,
-				F966BB2F08F27A39005CB29B /* form.tcl */,
-				F966BB3008F27A39005CB29B /* goldberg.tcl */,
-				F966BB3108F27A39005CB29B /* hello */,
-				F966BB3208F27A39005CB29B /* hscale.tcl */,
-				F966BB3308F27A39005CB29B /* icon.tcl */,
-				F966BB3408F27A39005CB29B /* image1.tcl */,
-				F966BB3508F27A39005CB29B /* image2.tcl */,
-				F966BB4208F27A3A005CB29B /* items.tcl */,
-				F966BB4308F27A3A005CB29B /* ixset */,
-				F92240290D7C620F005EC715 /* knightstour.tcl */,
-				F966BB4408F27A3A005CB29B /* label.tcl */,
-				F966BB4508F27A3A005CB29B /* labelframe.tcl */,
-				F9D1360A0CDC252C00DBE0B5 /* mclist.tcl */,
-				F966BB4608F27A3A005CB29B /* menu.tcl */,
-				F966BB4708F27A3A005CB29B /* menubu.tcl */,
-				F966BB4808F27A3A005CB29B /* msgbox.tcl */,
-				F966BB4A08F27A3A005CB29B /* paned1.tcl */,
-				F966BB4B08F27A3A005CB29B /* paned2.tcl */,
-				F966BB4C08F27A3A005CB29B /* pendulum.tcl */,
-				F966BB4D08F27A3A005CB29B /* plot.tcl */,
-				F966BB4E08F27A3A005CB29B /* puzzle.tcl */,
-				F966BB4F08F27A3A005CB29B /* radio.tcl */,
-				F966BB5008F27A3A005CB29B /* README */,
-				F966BB5108F27A3A005CB29B /* rmt */,
-				F966BB5208F27A3A005CB29B /* rolodex */,
-				F966BB5308F27A3A005CB29B /* ruler.tcl */,
-				F966BB5408F27A3A005CB29B /* sayings.tcl */,
-				F966BB5508F27A3A005CB29B /* search.tcl */,
-				F966BB5608F27A3A005CB29B /* spin.tcl */,
-				F966BB5708F27A3A005CB29B /* square */,
-				F966BB5808F27A3A005CB29B /* states.tcl */,
-				F966BB5908F27A3A005CB29B /* style.tcl */,
-				F966BB5A08F27A3A005CB29B /* tclIndex */,
-				F966BB5B08F27A3A005CB29B /* tcolor */,
-				F966BB5C08F27A3A005CB29B /* text.tcl */,
-				F9099B8A0CC67D30005A9580 /* textpeer.tcl */,
-				F966BB5D08F27A3A005CB29B /* timer */,
-				F936FCD90CCD984600716967 /* toolbar.tcl */,
-				F936FCD80CCD984600716967 /* tree.tcl */,
-				F9099B8B0CC67D3E005A9580 /* ttkbut.tcl */,
-				F9F4EFDD0CC7B3CB00378A27 /* ttkmenu.tcl */,
-				F936FCDA0CCD984600716967 /* ttknote.tcl */,
-				F9F4EFDC0CC7B3CA00378A27 /* ttkpane.tcl */,
-				F936FCD70CCD984500716967 /* ttkprogress.tcl */,
-				F966BB5E08F27A3A005CB29B /* twind.tcl */,
-				F966BB5F08F27A3A005CB29B /* unicodeout.tcl */,
-				F966BB6008F27A3A005CB29B /* vscale.tcl */,
-				F966BB6108F27A3A005CB29B /* widget */,
-			);
-			path = demos;
-			sourceTree = "<group>";
-		};
-		F966BB9708F27A3B005CB29B /* macosx */ = {
-			isa = PBXGroup;
-			children = (
-				F966BBBA08F27A3B005CB29B /* configure.ac */,
-				F966BBBB08F27A3B005CB29B /* GNUmakefile */,
-				F966BBBE08F27A3B005CB29B /* README */,
-				F966BBC008F27A3B005CB29B /* Tk-Info.plist.in */,
-				F966BBC208F27A3B005CB29B /* tkMacOSX.h */,
-				F966BBC508F27A3B005CB29B /* tkMacOSXBitmap.c */,
-				F966BBC608F27A3B005CB29B /* tkMacOSXButton.c */,
-				F966BBC808F27A3B005CB29B /* tkMacOSXClipboard.c */,
-				F966BBC908F27A3B005CB29B /* tkMacOSXColor.c */,
-				F966BBCA08F27A3B005CB29B /* tkMacOSXConfig.c */,
-				F966BBCB08F27A3B005CB29B /* tkMacOSXCursor.c */,
-				F966BBCC08F27A3B005CB29B /* tkMacOSXCursors.h */,
-				F966BBCD08F27A3B005CB29B /* tkMacOSXDebug.c */,
-				F966BBCE08F27A3B005CB29B /* tkMacOSXDebug.h */,
-				F966BBCF08F27A3B005CB29B /* tkMacOSXDefault.h */,
-				F966BBD008F27A3B005CB29B /* tkMacOSXDialog.c */,
-				F966BBD108F27A3B005CB29B /* tkMacOSXDraw.c */,
-				F966BBD208F27A3B005CB29B /* tkMacOSXEmbed.c */,
-				F966BBD308F27A3B005CB29B /* tkMacOSXEntry.c */,
-				F966BBD408F27A3B005CB29B /* tkMacOSXEvent.c */,
-				F966BBD608F27A3B005CB29B /* tkMacOSXFont.c */,
-				F93E5EFD09CF8711008FA367 /* tkMacOSXFont.h */,
-				F966BBD708F27A3B005CB29B /* tkMacOSXHLEvents.c */,
-				F966BBD808F27A3B005CB29B /* tkMacOSXInit.c */,
-				F966BBDA08F27A3B005CB29B /* tkMacOSXInt.h */,
-				F966BBDB08F27A3B005CB29B /* tkMacOSXKeyboard.c */,
-				F966BBDC08F27A3B005CB29B /* tkMacOSXKeyEvent.c */,
-				F966BBDD08F27A3B005CB29B /* tkMacOSXMenu.c */,
-				F966BBE008F27A3B005CB29B /* tkMacOSXMenubutton.c */,
-				F966BBE108F27A3B005CB29B /* tkMacOSXMenus.c */,
-				F966BBE208F27A3B005CB29B /* tkMacOSXMouseEvent.c */,
-				F966BBE308F27A3B005CB29B /* tkMacOSXNotify.c */,
-				F966BBEA08F27A3C005CB29B /* tkMacOSXPort.h */,
-				F976F6A70C325FB6005066D9 /* tkMacOSXPrivate.h */,
-				F966BBEB08F27A3C005CB29B /* tkMacOSXRegion.c */,
-				F966BBEC08F27A3C005CB29B /* tkMacOSXScale.c */,
-				F966BBED08F27A3C005CB29B /* tkMacOSXScrlbr.c */,
-				F966BBEE08F27A3C005CB29B /* tkMacOSXSend.c */,
-				F966BBEF08F27A3C005CB29B /* tkMacOSXSubwindows.c */,
-				F966BBF008F27A3C005CB29B /* tkMacOSXTest.c */,
-				F966BBF108F27A3C005CB29B /* tkMacOSXWindowEvent.c */,
-				F966BBF208F27A3C005CB29B /* tkMacOSXWm.c */,
-				F966BBF308F27A3C005CB29B /* tkMacOSXWm.h */,
-				F966BBF408F27A3C005CB29B /* tkMacOSXXCursors.h */,
-				F966BBF508F27A3C005CB29B /* tkMacOSXXStubs.c */,
-				F96888840AF78938000797B5 /* ttkMacOSXTheme.c */,
-				F95D8D4B0F1715610006B020 /* Tk.icns */,
-				F95D8D4C0F1715610006B020 /* Tk.tiff */,
-				F966BBF708F27A3C005CB29B /* Wish-Info.plist.in */,
-				F97590AE1039A96200558A9A /* Wish.sdef */,
-				F97AE7F10B65C1E900310EA2 /* Tk-Common.xcconfig */,
-				F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */,
-				F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */,
-			);
-			path = macosx;
-			sourceTree = "<group>";
-		};
-		F966BC0408F27A3C005CB29B /* tests */ = {
-			isa = PBXGroup;
-			children = (
-				F966BC0508F27A3C005CB29B /* all.tcl */,
-				F966BC0608F27A3C005CB29B /* arc.tcl */,
-				F966BC0708F27A3C005CB29B /* bell.test */,
-				F966BC0808F27A3C005CB29B /* bevel.tcl */,
-				F966BC0908F27A3C005CB29B /* bgerror.test */,
-				F966BC0A08F27A3C005CB29B /* bind.test */,
-				F966BC0B08F27A3C005CB29B /* bitmap.test */,
-				F966BC0C08F27A3C005CB29B /* border.test */,
-				F966BC0D08F27A3C005CB29B /* bugs.tcl */,
-				F966BC0E08F27A3C005CB29B /* butGeom.tcl */,
-				F966BC0F08F27A3C005CB29B /* butGeom2.tcl */,
-				F966BC1008F27A3C005CB29B /* button.test */,
-				F966BC1108F27A3C005CB29B /* canvas.test */,
-				F966BC1208F27A3C005CB29B /* canvImg.test */,
-				F966BC1308F27A3C005CB29B /* canvPs.test */,
-				F966BC1408F27A3C005CB29B /* canvPsArc.tcl */,
-				F966BC1508F27A3C005CB29B /* canvPsBmap.tcl */,
-				F966BC1608F27A3C005CB29B /* canvPsGrph.tcl */,
-				F966BC1708F27A3C005CB29B /* canvPsImg.tcl */,
-				F966BC1808F27A3C005CB29B /* canvPsText.tcl */,
-				F966BC1908F27A3C005CB29B /* canvRect.test */,
-				F966BC1A08F27A3C005CB29B /* canvText.test */,
-				F966BC1B08F27A3C005CB29B /* canvWind.test */,
-				F966BC1C08F27A3C005CB29B /* choosedir.test */,
-				F966BC1D08F27A3C005CB29B /* clipboard.test */,
-				F966BC1E08F27A3C005CB29B /* clrpick.test */,
-				F966BC1F08F27A3C005CB29B /* cmap.tcl */,
-				F966BC2008F27A3C005CB29B /* cmds.test */,
-				F966BC2108F27A3C005CB29B /* color.test */,
-				F966BC2208F27A3C005CB29B /* config.test */,
-				F966BC2308F27A3C005CB29B /* constraints.tcl */,
-				F966BC2408F27A3C005CB29B /* cursor.test */,
-				F966BC2508F27A3C005CB29B /* dialog.test */,
-				F966BC2608F27A3C005CB29B /* embed.test */,
-				F966BC2708F27A3C005CB29B /* entry.test */,
-				F966BC2808F27A3C005CB29B /* event.test */,
-				F966BC2908F27A3C005CB29B /* filebox.test */,
-				F966BC2A08F27A3C005CB29B /* focus.test */,
-				F966BC2B08F27A3C005CB29B /* focusTcl.test */,
-				F966BC2C08F27A3C005CB29B /* font.test */,
-				F99388950EE02D980065FE6B /* fontchooser.test */,
-				F966BC2D08F27A3C005CB29B /* frame.test */,
-				F966BC2E08F27A3C005CB29B /* geometry.test */,
-				F966BC2F08F27A3C005CB29B /* get.test */,
-				F966BC3008F27A3C005CB29B /* grab.test */,
-				F966BC3108F27A3C005CB29B /* grid.test */,
-				F966BC3308F27A3C005CB29B /* image.test */,
-				F966BC3408F27A3C005CB29B /* imgBmap.test */,
-				F966BC3508F27A3C005CB29B /* imgPhoto.test */,
-				F9DD99BF0F07DFCD0018B2E4 /* imgPNG.test */,
-				F966BC3608F27A3C005CB29B /* imgPPM.test */,
-				F966BC3708F27A3C005CB29B /* listbox.test */,
-				F966BC3808F27A3C005CB29B /* main.test */,
-				F966BC3908F27A3C005CB29B /* menu.test */,
-				F966BC3A08F27A3C005CB29B /* menubut.test */,
-				F966BC3B08F27A3C005CB29B /* menuDraw.test */,
-				F966BC3C08F27A3C005CB29B /* message.test */,
-				F966BC3D08F27A3C005CB29B /* msgbox.test */,
-				F966BC3E08F27A3C005CB29B /* obj.test */,
-				F966BC3F08F27A3C005CB29B /* oldpack.test */,
-				F966BC4008F27A3C005CB29B /* option.file1 */,
-				F966BC4108F27A3C005CB29B /* option.file2 */,
-				F966BC4208F27A3C005CB29B /* option.test */,
-				F966BC4308F27A3C005CB29B /* pack.test */,
-				F966BC4408F27A3C005CB29B /* panedwindow.test */,
-				F966BC4508F27A3D005CB29B /* place.test */,
-				F966BC4608F27A3D005CB29B /* raise.test */,
-				F966BC4708F27A3D005CB29B /* README */,
-				F966BC4808F27A3D005CB29B /* safe.test */,
-				F966BC4908F27A3D005CB29B /* scale.test */,
-				F966BC4A08F27A3D005CB29B /* scrollbar.test */,
-				F966BC4B08F27A3D005CB29B /* select.test */,
-				F966BC4C08F27A3D005CB29B /* send.test */,
-				F966BC4D08F27A3D005CB29B /* spinbox.test */,
-				F966BC4E08F27A3D005CB29B /* text.test */,
-				F966BC4F08F27A3D005CB29B /* textBTree.test */,
-				F966BC5008F27A3D005CB29B /* textDisp.test */,
-				F966BC5108F27A3D005CB29B /* textImage.test */,
-				F966BC5208F27A3D005CB29B /* textIndex.test */,
-				F966BC5308F27A3D005CB29B /* textMark.test */,
-				F966BC5408F27A3D005CB29B /* textTag.test */,
-				F966BC5508F27A3D005CB29B /* textWind.test */,
-				F966BC5608F27A3D005CB29B /* tk.test */,
-				F96888530AF7880C000797B5 /* ttk */,
-				F966BC5708F27A3D005CB29B /* unixButton.test */,
-				F966BC5808F27A3D005CB29B /* unixEmbed.test */,
-				F966BC5908F27A3D005CB29B /* unixFont.test */,
-				F966BC5A08F27A3D005CB29B /* unixMenu.test */,
-				F966BC5B08F27A3D005CB29B /* unixSelect.test */,
-				F966BC5C08F27A3D005CB29B /* unixWm.test */,
-				F966BC5D08F27A3D005CB29B /* util.test */,
-				F966BC5E08F27A3D005CB29B /* visual.test */,
-				F966BC5F08F27A3D005CB29B /* visual_bb.test */,
-				F966BC6008F27A3D005CB29B /* winButton.test */,
-				F966BC6108F27A3D005CB29B /* winClipboard.test */,
-				F966BC6208F27A3D005CB29B /* winDialog.test */,
-				F966BC6308F27A3D005CB29B /* window.test */,
-				F966BC6408F27A3D005CB29B /* winfo.test */,
-				F966BC6508F27A3D005CB29B /* winFont.test */,
-				F966BC6608F27A3D005CB29B /* winMenu.test */,
-				F966BC6708F27A3D005CB29B /* winSend.test */,
-				F966BC6808F27A3D005CB29B /* winWm.test */,
-				F966BC6908F27A3D005CB29B /* wm.test */,
-				F966BC6A08F27A3D005CB29B /* xmfbox.test */,
-			);
-			path = tests;
-			sourceTree = "<group>";
-		};
-		F966BC6B08F27A3D005CB29B /* unix */ = {
-			isa = PBXGroup;
-			children = (
-				F966BC6C08F27A3D005CB29B /* aclocal.m4 */,
-				F966BC6D08F27A3D005CB29B /* configure */,
-				F966BC6E08F27A3D005CB29B /* configure.ac */,
-				F966BC6F08F27A3D005CB29B /* install-sh */,
-				F966BC7008F27A3D005CB29B /* installManPage */,
-				F966BC7108F27A3D005CB29B /* Makefile.in */,
-				F966BC7208F27A3D005CB29B /* README */,
-				F966BC7308F27A3D005CB29B /* tcl.m4 */,
-				F974D57B0FBE7EC000BF728B /* tk.pc.in */,
-				F966BC7408F27A3D005CB29B /* tk.spec */,
-				F966BC7508F27A3D005CB29B /* tkAppInit.c */,
-				F966BC7608F27A3D005CB29B /* tkConfig.h.in */,
-				F966BC7708F27A3D005CB29B /* tkConfig.sh.in */,
-				F966BC7808F27A3D005CB29B /* tkUnix.c */,
-				F966BC7908F27A3D005CB29B /* tkUnix3d.c */,
-				F966BC7A08F27A3D005CB29B /* tkUnixButton.c */,
-				F966BC7B08F27A3D005CB29B /* tkUnixColor.c */,
-				F966BC7C08F27A3D005CB29B /* tkUnixConfig.c */,
-				F966BC7D08F27A3D005CB29B /* tkUnixCursor.c */,
-				F966BC7E08F27A3D005CB29B /* tkUnixDefault.h */,
-				F966BC7F08F27A3D005CB29B /* tkUnixDialog.c */,
-				F966BC8008F27A3D005CB29B /* tkUnixDraw.c */,
-				F966BC8108F27A3D005CB29B /* tkUnixEmbed.c */,
-				F966BC8208F27A3D005CB29B /* tkUnixEvent.c */,
-				F966BC8308F27A3D005CB29B /* tkUnixFocus.c */,
-				F966BC8408F27A3D005CB29B /* tkUnixFont.c */,
-				F966BC8508F27A3D005CB29B /* tkUnixInit.c */,
-				F966BC8608F27A3D005CB29B /* tkUnixInt.h */,
-				F966BC8708F27A3D005CB29B /* tkUnixKey.c */,
-				F966BC8808F27A3D005CB29B /* tkUnixMenu.c */,
-				F966BC8908F27A3D005CB29B /* tkUnixMenubu.c */,
-				F966BC8A08F27A3D005CB29B /* tkUnixPort.h */,
-				F966BC8B08F27A3D005CB29B /* tkUnixRFont.c */,
-				F966BC8C08F27A3D005CB29B /* tkUnixScale.c */,
-				F966BC8D08F27A3D005CB29B /* tkUnixScrlbr.c */,
-				F966BC8E08F27A3D005CB29B /* tkUnixSelect.c */,
-				F966BC8F08F27A3D005CB29B /* tkUnixSend.c */,
-				F966BC9008F27A3D005CB29B /* tkUnixWm.c */,
-				F966BC9108F27A3D005CB29B /* tkUnixXId.c */,
-			);
-			path = unix;
-			sourceTree = "<group>";
-		};
-		F966BC9208F27A3D005CB29B /* win */ = {
-			isa = PBXGroup;
-			children = (
-				F966BC9408F27A3D005CB29B /* aclocal.m4 */,
-				F966BC9508F27A3D005CB29B /* buildall.vc.bat */,
-				F966BC9608F27A3E005CB29B /* configure */,
-				F966BC9708F27A3E005CB29B /* configure.ac */,
-				F966BC9908F27A3E005CB29B /* Makefile.in */,
-				F966BC9A08F27A3E005CB29B /* makefile.vc */,
-				F966BC9C08F27A3E005CB29B /* nmakehlp.c */,
-				F966BC9D08F27A3E005CB29B /* rc */,
-				F966BCF308F27A3E005CB29B /* README */,
-				F966BCF408F27A3E005CB29B /* rmd.bat */,
-				F966BCF508F27A3F005CB29B /* rules.vc */,
-				F966BCF608F27A3F005CB29B /* stubs.c */,
-				F966BCF708F27A3F005CB29B /* tcl.m4 */,
-				F966BCF808F27A3F005CB29B /* tkConfig.sh.in */,
-				F966BCF908F27A3F005CB29B /* tkWin.h */,
-				F966BCFA08F27A3F005CB29B /* tkWin32Dll.c */,
-				F966BCFB08F27A3F005CB29B /* tkWin3d.c */,
-				F966BCFC08F27A3F005CB29B /* tkWinButton.c */,
-				F966BCFD08F27A3F005CB29B /* tkWinClipboard.c */,
-				F966BCFE08F27A3F005CB29B /* tkWinColor.c */,
-				F966BCFF08F27A3F005CB29B /* tkWinConfig.c */,
-				F966BD0008F27A3F005CB29B /* tkWinCursor.c */,
-				F966BD0108F27A3F005CB29B /* tkWinDefault.h */,
-				F966BD0208F27A3F005CB29B /* tkWinDialog.c */,
-				F966BD0308F27A3F005CB29B /* tkWinDraw.c */,
-				F966BD0408F27A3F005CB29B /* tkWinEmbed.c */,
-				F966BD0508F27A3F005CB29B /* tkWinFont.c */,
-				F966BD0708F27A3F005CB29B /* tkWinImage.c */,
-				F966BD0808F27A3F005CB29B /* tkWinInit.c */,
-				F966BD0908F27A3F005CB29B /* tkWinInt.h */,
-				F966BD0A08F27A3F005CB29B /* tkWinKey.c */,
-				F966BD0B08F27A3F005CB29B /* tkWinMenu.c */,
-				F966BD0C08F27A3F005CB29B /* tkWinPixmap.c */,
-				F966BD0D08F27A3F005CB29B /* tkWinPointer.c */,
-				F966BD0E08F27A3F005CB29B /* tkWinPort.h */,
-				F966BD0F08F27A3F005CB29B /* tkWinRegion.c */,
-				F966BD1008F27A3F005CB29B /* tkWinScrlbr.c */,
-				F966BD1108F27A3F005CB29B /* tkWinSend.c */,
-				F966BD1208F27A3F005CB29B /* tkWinSendCom.c */,
-				F966BD1308F27A3F005CB29B /* tkWinSendCom.h */,
-				F966BD1408F27A3F005CB29B /* tkWinTest.c */,
-				F966BD1508F27A3F005CB29B /* tkWinWindow.c */,
-				F966BD1608F27A3F005CB29B /* tkWinWm.c */,
-				F966BD1708F27A3F005CB29B /* tkWinX.c */,
-				F96888860AF78953000797B5 /* ttkWinMonitor.c */,
-				F96888870AF78953000797B5 /* ttkWinTheme.c */,
-				F96888880AF78953000797B5 /* ttkWinXPTheme.c */,
-				F966BD1808F27A3F005CB29B /* winMain.c */,
-			);
-			path = win;
-			sourceTree = "<group>";
-		};
-		F966BC9D08F27A3E005CB29B /* rc */ = {
-			isa = PBXGroup;
-			children = (
-				F966BCEE08F27A3E005CB29B /* tk.rc */,
-				F966BCEF08F27A3E005CB29B /* tk_base.rc */,
-				F966BCF208F27A3E005CB29B /* wish.rc */,
-			);
-			path = rc;
-			sourceTree = "<group>";
-		};
-		F966BD1908F27A3F005CB29B /* xlib */ = {
-			isa = PBXGroup;
-			children = (
-				F966BD1A08F27A3F005CB29B /* X11 */,
-				F966BD2308F27A3F005CB29B /* xbytes.h */,
-				F966BD2408F27A3F005CB29B /* xcolors.c */,
-				F966BD2508F27A3F005CB29B /* xdraw.c */,
-				F966BD2608F27A3F005CB29B /* xgc.c */,
-				F966BD2708F27A3F005CB29B /* ximage.c */,
-				F966BD2808F27A3F005CB29B /* xutil.c */,
-			);
-			path = xlib;
-			sourceTree = "<group>";
-		};
-		F966BD1A08F27A3F005CB29B /* X11 */ = {
-			isa = PBXGroup;
-			children = (
-				F966BD1B08F27A3F005CB29B /* cursorfont.h */,
-				F966BD1C08F27A3F005CB29B /* keysym.h */,
-				F966BD1D08F27A3F005CB29B /* keysymdef.h */,
-				F966BD1E08F27A3F005CB29B /* X.h */,
-				F966BD1F08F27A3F005CB29B /* Xatom.h */,
-				F966BD2008F27A3F005CB29B /* Xfuncproto.h */,
-				F966BD2108F27A3F005CB29B /* Xlib.h */,
-				F966BD2208F27A3F005CB29B /* Xutil.h */,
-			);
-			path = X11;
-			sourceTree = "<group>";
-		};
-		F966C06F08F281DC005CB29B /* Frameworks */ = {
-			isa = PBXGroup;
-			children = (
-				F9C9CBFF0E84059800E00935 /* ApplicationServices.framework */,
-				F966C07408F2820D005CB29B /* CoreFoundation.framework */,
-				F96437E60EF0D652003F468E /* libz.dylib */,
-				F966C07608F2821B005CB29B /* Carbon.framework */,
-				F94523A10E6FC2AC00C1D987 /* Cocoa.framework */,
-				F966C07808F28233005CB29B /* IOKit.framework */,
-				F9FD32140CC1AF170073837D /* libX11.dylib */,
-				F9FD32150CC1AF170073837D /* libXext.dylib */,
-				F9FD32160CC1AF170073837D /* libXss.dylib */,
-				F9FD349A0CC1BB0D0073837D /* libXft.dylib */,
-				F9FD34990CC1BB0D0073837D /* libfreetype.dylib */,
-				F9FD34C30CC1BBD70073837D /* libfontconfig.dylib */,
-			);
-			name = Frameworks;
-			sourceTree = "<group>";
-		};
-		F96887DF0AF786D5000797B5 /* ttk */ = {
-			isa = PBXGroup;
-			children = (
-				F96887E00AF786D5000797B5 /* ttk.decls */,
-				F96887E10AF786D5000797B5 /* ttkBlink.c */,
-				F96887E20AF786D5000797B5 /* ttkButton.c */,
-				F96887E30AF786D5000797B5 /* ttkCache.c */,
-				F96887E40AF786D5000797B5 /* ttkClamTheme.c */,
-				F96887E50AF786D5000797B5 /* ttkClassicTheme.c */,
-				F96887E60AF786D5000797B5 /* ttkDecls.h */,
-				F96887E70AF786D5000797B5 /* ttkDefaultTheme.c */,
-				F96887E80AF786D5000797B5 /* ttkElements.c */,
-				F96887E90AF786D5000797B5 /* ttkEntry.c */,
-				F96887EA0AF786D5000797B5 /* ttkFrame.c */,
-				F96887EB0AF786D5000797B5 /* ttkImage.c */,
-				F96887EC0AF786D5000797B5 /* ttkInit.c */,
-				F96887ED0AF786D5000797B5 /* ttkLabel.c */,
-				F96887EE0AF786D5000797B5 /* ttkLayout.c */,
-				F96887EF0AF786D5000797B5 /* ttkManager.c */,
-				F96887F00AF786D5000797B5 /* ttkManager.h */,
-				F96887F10AF786D5000797B5 /* ttkNotebook.c */,
-				F96887F20AF786D5000797B5 /* ttkPanedwindow.c */,
-				F96887F30AF786D5000797B5 /* ttkProgress.c */,
-				F96887F40AF786D5000797B5 /* ttkScale.c */,
-				F96887F50AF786D5000797B5 /* ttkScroll.c */,
-				F96887F60AF786D5000797B5 /* ttkScrollbar.c */,
-				F96887F70AF786D5000797B5 /* ttkSeparator.c */,
-				F96887F80AF786D5000797B5 /* ttkSquare.c */,
-				F96887F90AF786D5000797B5 /* ttkState.c */,
-				F96887FA0AF786D5000797B5 /* ttkStubInit.c */,
-				F96887FB0AF786D5000797B5 /* ttkStubLib.c */,
-				F96887FC0AF786D5000797B5 /* ttkTagSet.c */,
-				F96887FD0AF786D5000797B5 /* ttkTheme.c */,
-				F96887FE0AF786D5000797B5 /* ttkTheme.h */,
-				F96887FF0AF786D5000797B5 /* ttkThemeInt.h */,
-				F96888000AF786D5000797B5 /* ttkTrace.c */,
-				F96888010AF786D5000797B5 /* ttkTrack.c */,
-				F96888020AF786D5000797B5 /* ttkTreeview.c */,
-				F96888030AF786D5000797B5 /* ttkWidget.c */,
-				F96888040AF786D5000797B5 /* ttkWidget.h */,
-			);
-			path = ttk;
-			sourceTree = "<group>";
-		};
-		F96888360AF787B3000797B5 /* ttk */ = {
-			isa = PBXGroup;
-			children = (
-				F96888370AF787B3000797B5 /* altTheme.tcl */,
-				F96888380AF787B3000797B5 /* aquaTheme.tcl */,
-				F96888390AF787B3000797B5 /* button.tcl */,
-				F968883A0AF787B3000797B5 /* clamTheme.tcl */,
-				F968883B0AF787B3000797B5 /* classicTheme.tcl */,
-				F968883C0AF787B3000797B5 /* combobox.tcl */,
-				F968883D0AF787B3000797B5 /* cursors.tcl */,
-				F968883E0AF787B3000797B5 /* defaults.tcl */,
-				F96888400AF787B3000797B5 /* entry.tcl */,
-				F96888410AF787B3000797B5 /* fonts.tcl */,
-				F96888440AF787B3000797B5 /* menubutton.tcl */,
-				F96888450AF787B3000797B5 /* notebook.tcl */,
-				F96888460AF787B3000797B5 /* panedwindow.tcl */,
-				F96888470AF787B3000797B5 /* progress.tcl */,
-				F96888480AF787B3000797B5 /* scale.tcl */,
-				F96888490AF787B3000797B5 /* scrollbar.tcl */,
-				F968884A0AF787B3000797B5 /* sizegrip.tcl */,
-				F968884B0AF787B3000797B5 /* treeview.tcl */,
-				F968884C0AF787B3000797B5 /* ttk.tcl */,
-				F968884D0AF787B3000797B5 /* utils.tcl */,
-				F968884E0AF787B3000797B5 /* winTheme.tcl */,
-				F973E5960EE99384001A648E /* vistaTheme.tcl */,
-				F968884F0AF787B3000797B5 /* xpTheme.tcl */,
-			);
-			path = ttk;
-			sourceTree = "<group>";
-		};
-		F96888530AF7880C000797B5 /* ttk */ = {
-			isa = PBXGroup;
-			children = (
-				F96888540AF7880C000797B5 /* all.tcl */,
-				F98383650F0FA43900171CA6 /* checkbutton.test */,
-				F96888560AF7880C000797B5 /* combobox.test */,
-				F96888570AF7880C000797B5 /* entry.test */,
-				F96888580AF7880C000797B5 /* image.test */,
-				F96888590AF7880C000797B5 /* labelframe.test */,
-				F968885A0AF7880C000797B5 /* layout.test */,
-				F968885C0AF7880C000797B5 /* notebook.test */,
-				F968885D0AF7880C000797B5 /* panedwindow.test */,
-				F968885E0AF7880C000797B5 /* progressbar.test */,
-				F98383680F0FA44700171CA6 /* radiobutton.test */,
-				F968885F0AF7880C000797B5 /* scrollbar.test */,
-				F96888600AF7880C000797B5 /* treetags.test */,
-				F96888610AF7880C000797B5 /* treeview.test */,
-				F96888620AF7880C000797B5 /* ttk.test */,
-				F96888630AF7880C000797B5 /* validate.test */,
-				F962F7C60DADC26200648DB8 /* vsapi.test */,
-			);
-			path = ttk;
-			sourceTree = "<group>";
-		};
-		F96D3DF608F27169004A47F5 /* Tcl Sources */ = {
-			isa = PBXGroup;
-			children = (
-				F96D3EC908F272A7004A47F5 /* generic */,
-				F96D432C08F272B4004A47F5 /* macosx */,
-				F96D443E08F272B9004A47F5 /* unix */,
-				F96D425C08F272B2004A47F5 /* libtommath */,
-				F96D446E08F272B9004A47F5 /* win */,
-				F96D3F3808F272A7004A47F5 /* library */,
-				F96D434408F272B5004A47F5 /* tests */,
-				F96D3DFC08F272A4004A47F5 /* doc */,
-				F96D43D008F272B8004A47F5 /* tools */,
-				F9183E690EFC81560030B814 /* pkgs */,
-				F96D3DFA08F272A4004A47F5 /* ChangeLog */,
-				F96D3DFB08F272A4004A47F5 /* changes */,
-				F96D434308F272B5004A47F5 /* README */,
-				F96D432B08F272B4004A47F5 /* license.terms */,
-			);
-			name = "Tcl Sources";
-			sourceTree = TCL_SRCROOT;
-		};
-		F96D3DF708F271BE004A47F5 /* Tk Sources */ = {
-			isa = PBXGroup;
-			children = (
-				F966BAA508F27A38005CB29B /* generic */,
-				F966BB9708F27A3B005CB29B /* macosx */,
-				F966BC6B08F27A3D005CB29B /* unix */,
-				F966BD1908F27A3F005CB29B /* xlib */,
-				F966BA0308F27A37005CB29B /* bitmaps */,
-				F966BC9208F27A3D005CB29B /* win */,
-				F966BB1308F27A39005CB29B /* library */,
-				F966BC0408F27A3C005CB29B /* tests */,
-				F966BA1008F27A37005CB29B /* doc */,
-				F966BA0E08F27A37005CB29B /* ChangeLog */,
-				F966BA0F08F27A37005CB29B /* changes */,
-				F966BC0308F27A3C005CB29B /* README */,
-				F966BB9608F27A3B005CB29B /* license.terms */,
-			);
-			name = "Tk Sources";
-			sourceTree = TK_SRCROOT;
-		};
-		F96D3DFC08F272A4004A47F5 /* doc */ = {
-			isa = PBXGroup;
-			children = (
-				F96D3DFD08F272A4004A47F5 /* Access.3 */,
-				F96D3DFE08F272A4004A47F5 /* AddErrInfo.3 */,
-				F96D3DFF08F272A4004A47F5 /* after.n */,
-				F96D3E0008F272A4004A47F5 /* Alloc.3 */,
-				F96D3E0108F272A4004A47F5 /* AllowExc.3 */,
-				F96D3E0208F272A4004A47F5 /* append.n */,
-				F96D3E0308F272A4004A47F5 /* AppInit.3 */,
-				F96D3E0408F272A5004A47F5 /* array.n */,
-				F96D3E0508F272A5004A47F5 /* AssocData.3 */,
-				F96D3E0608F272A5004A47F5 /* Async.3 */,
-				F96D3E0708F272A5004A47F5 /* BackgdErr.3 */,
-				F96D3E0808F272A5004A47F5 /* Backslash.3 */,
-				F96D3E0908F272A5004A47F5 /* bgerror.n */,
-				F96D3E0A08F272A5004A47F5 /* binary.n */,
-				F96D3E0B08F272A5004A47F5 /* BoolObj.3 */,
-				F96D3E0C08F272A5004A47F5 /* break.n */,
-				F96D3E0D08F272A5004A47F5 /* ByteArrObj.3 */,
-				F96D3E0E08F272A5004A47F5 /* CallDel.3 */,
-				F96D3E0F08F272A5004A47F5 /* case.n */,
-				F96D3E1008F272A5004A47F5 /* catch.n */,
-				F96D3E1108F272A5004A47F5 /* cd.n */,
-				F96D3E1208F272A5004A47F5 /* chan.n */,
-				F96D3E1308F272A5004A47F5 /* ChnlStack.3 */,
-				F93599CF0DF1F87F00E04F67 /* Class.3 */,
-				F93599D00DF1F89E00E04F67 /* class.n */,
-				F96D3E1408F272A5004A47F5 /* clock.n */,
-				F96D3E1508F272A5004A47F5 /* close.n */,
-				F96D3E1608F272A5004A47F5 /* CmdCmplt.3 */,
-				F96D3E1708F272A5004A47F5 /* Concat.3 */,
-				F96D3E1808F272A5004A47F5 /* concat.n */,
-				F96D3E1908F272A5004A47F5 /* continue.n */,
-				F93599D20DF1F8DF00E04F67 /* copy.n */,
-				F974D5720FBE7DC600BF728B /* coroutine.n */,
-				F96D3E1A08F272A5004A47F5 /* CrtChannel.3 */,
-				F96D3E1B08F272A5004A47F5 /* CrtChnlHdlr.3 */,
-				F96D3E1C08F272A5004A47F5 /* CrtCloseHdlr.3 */,
-				F96D3E1D08F272A5004A47F5 /* CrtCommand.3 */,
-				F96D3E1E08F272A5004A47F5 /* CrtFileHdlr.3 */,
-				F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */,
-				F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */,
-				F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */,
-				F96D3E2208F272A5004A47F5 /* CrtAlias.3 */,
-				F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */,
-				F96D3E2408F272A5004A47F5 /* CrtTrace.3 */,
-				F96D3E2508F272A5004A47F5 /* dde.n */,
-				F93599D30DF1F8F500E04F67 /* define.n */,
-				F96D3E2608F272A5004A47F5 /* DetachPids.3 */,
-				F96D3E2708F272A5004A47F5 /* dict.n */,
-				F96D3E2808F272A5004A47F5 /* DictObj.3 */,
-				F96D3E2908F272A5004A47F5 /* DoOneEvent.3 */,
-				F96D3E2A08F272A5004A47F5 /* DoubleObj.3 */,
-				F96D3E2B08F272A5004A47F5 /* DoWhenIdle.3 */,
-				F96D3E2C08F272A5004A47F5 /* DString.3 */,
-				F96D3E2D08F272A5004A47F5 /* DumpActiveMemory.3 */,
-				F96D3E2E08F272A5004A47F5 /* Encoding.3 */,
-				F96D3E2F08F272A5004A47F5 /* encoding.n */,
-				F96D3E3008F272A5004A47F5 /* Ensemble.3 */,
-				F96D3E3108F272A5004A47F5 /* Environment.3 */,
-				F96D3E3208F272A5004A47F5 /* eof.n */,
-				F96D3E3308F272A5004A47F5 /* error.n */,
-				F96D3E3408F272A5004A47F5 /* Eval.3 */,
-				F96D3E3508F272A5004A47F5 /* eval.n */,
-				F96D3E3608F272A5004A47F5 /* exec.n */,
-				F96D3E3708F272A5004A47F5 /* Exit.3 */,
-				F96D3E3808F272A5004A47F5 /* exit.n */,
-				F96D3E3908F272A5004A47F5 /* expr.n */,
-				F96D3E3A08F272A5004A47F5 /* ExprLong.3 */,
-				F96D3E3B08F272A5004A47F5 /* ExprLongObj.3 */,
-				F96D3E3C08F272A5004A47F5 /* fblocked.n */,
-				F96D3E3D08F272A5004A47F5 /* fconfigure.n */,
-				F96D3E3E08F272A5004A47F5 /* fcopy.n */,
-				F96D3E3F08F272A5004A47F5 /* file.n */,
-				F96D3E4008F272A5004A47F5 /* fileevent.n */,
-				F96D3E4108F272A5004A47F5 /* filename.n */,
-				F96D3E4208F272A5004A47F5 /* FileSystem.3 */,
-				F96D3E4308F272A5004A47F5 /* FindExec.3 */,
-				F96D3E4408F272A5004A47F5 /* flush.n */,
-				F96D3E4508F272A5004A47F5 /* for.n */,
-				F96D3E4608F272A5004A47F5 /* foreach.n */,
-				F96D3E4708F272A5004A47F5 /* format.n */,
-				F96D3E4808F272A5004A47F5 /* GetCwd.3 */,
-				F96D3E4908F272A5004A47F5 /* GetHostName.3 */,
-				F96D3E4A08F272A5004A47F5 /* GetIndex.3 */,
-				F96D3E4B08F272A5004A47F5 /* GetInt.3 */,
-				F96D3E4C08F272A5004A47F5 /* GetOpnFl.3 */,
-				F96D3E4D08F272A5004A47F5 /* gets.n */,
-				F96D3E4E08F272A5004A47F5 /* GetStdChan.3 */,
-				F96D3E4F08F272A5004A47F5 /* GetTime.3 */,
-				F96D3E5008F272A5004A47F5 /* GetVersion.3 */,
-				F96D3E5108F272A5004A47F5 /* glob.n */,
-				F96D3E5208F272A6004A47F5 /* global.n */,
-				F96D3E5308F272A6004A47F5 /* Hash.3 */,
-				F96D3E5408F272A6004A47F5 /* history.n */,
-				F96D3E5508F272A6004A47F5 /* http.n */,
-				F96D3E5608F272A6004A47F5 /* if.n */,
-				F96D3E5708F272A6004A47F5 /* incr.n */,
-				F96D3E5808F272A6004A47F5 /* info.n */,
-				F96D3E5908F272A6004A47F5 /* Init.3 */,
-				F96D3E5A08F272A6004A47F5 /* InitStubs.3 */,
-				F96D3E5B08F272A6004A47F5 /* Interp.3 */,
-				F96D3E5C08F272A6004A47F5 /* interp.n */,
-				F96D3E5D08F272A6004A47F5 /* IntObj.3 */,
-				F96D3E5E08F272A6004A47F5 /* join.n */,
-				F96D3E5F08F272A6004A47F5 /* lappend.n */,
-				F96D3E6008F272A6004A47F5 /* lassign.n */,
-				F96D3E6108F272A6004A47F5 /* library.n */,
-				F96D3E6208F272A6004A47F5 /* Limit.3 */,
-				F96D3E6308F272A6004A47F5 /* lindex.n */,
-				F96D3E6408F272A6004A47F5 /* LinkVar.3 */,
-				F96D3E6508F272A6004A47F5 /* linsert.n */,
-				F96D3E6608F272A6004A47F5 /* list.n */,
-				F96D3E6708F272A6004A47F5 /* ListObj.3 */,
-				F96D3E6808F272A6004A47F5 /* llength.n */,
-				F96D3E6908F272A6004A47F5 /* load.n */,
-				F96D3E6A08F272A6004A47F5 /* lrange.n */,
-				F96D3E6B08F272A6004A47F5 /* lrepeat.n */,
-				F96D3E6C08F272A6004A47F5 /* lreplace.n */,
-				F96D3E6D08F272A6004A47F5 /* lsearch.n */,
-				F96D3E6E08F272A6004A47F5 /* lset.n */,
-				F96D3E6F08F272A6004A47F5 /* lsort.n */,
-				F96D3E7008F272A6004A47F5 /* man.macros */,
-				F96D3E7108F272A6004A47F5 /* mathfunc.n */,
-				F96D3E7208F272A6004A47F5 /* memory.n */,
-				F93599D40DF1F91900E04F67 /* Method.3 */,
-				F96D3E7308F272A6004A47F5 /* msgcat.n */,
-				F93599D50DF1F93700E04F67 /* my.n */,
-				F96D3E7408F272A6004A47F5 /* Namespace.3 */,
-				F96D3E7508F272A6004A47F5 /* namespace.n */,
-				F93599D60DF1F95000E04F67 /* next.n */,
-				F96D3E7608F272A6004A47F5 /* Notifier.3 */,
-				F96D3E7708F272A6004A47F5 /* Object.3 */,
-				F93599D70DF1F96800E04F67 /* object.n */,
-				F96D3E7808F272A6004A47F5 /* ObjectType.3 */,
-				F96D3E7908F272A6004A47F5 /* open.n */,
-				F96D3E7A08F272A6004A47F5 /* OpenFileChnl.3 */,
-				F96D3E7B08F272A6004A47F5 /* OpenTcp.3 */,
-				F96D3E7C08F272A6004A47F5 /* package.n */,
-				F96D3E7D08F272A6004A47F5 /* packagens.n */,
-				F96D3E7E08F272A6004A47F5 /* Panic.3 */,
-				F96D3E7F08F272A6004A47F5 /* ParseCmd.3 */,
-				F96D3E8008F272A6004A47F5 /* pid.n */,
-				F96D3E8108F272A6004A47F5 /* pkgMkIndex.n */,
-				F96D3E8208F272A6004A47F5 /* PkgRequire.3 */,
-				F9ECB1E10B26543C00A28025 /* platform_shell.n */,
-				F9ECB1E20B26543C00A28025 /* platform.n */,
-				F96D3E8308F272A6004A47F5 /* Preserve.3 */,
-				F96D3E8408F272A6004A47F5 /* PrintDbl.3 */,
-				F96D3E8508F272A6004A47F5 /* proc.n */,
-				F96D3E8608F272A6004A47F5 /* puts.n */,
-				F96D3E8708F272A6004A47F5 /* pwd.n */,
-				F96D3E8808F272A6004A47F5 /* re_syntax.n */,
-				F96D3E8908F272A6004A47F5 /* read.n */,
-				F96D3E8A08F272A6004A47F5 /* RecEvalObj.3 */,
-				F96D3E8B08F272A6004A47F5 /* RecordEval.3 */,
-				F96D3E8C08F272A6004A47F5 /* RegConfig.3 */,
-				F96D3E8D08F272A6004A47F5 /* RegExp.3 */,
-				F96D3E8E08F272A6004A47F5 /* regexp.n */,
-				F96D3E8F08F272A6004A47F5 /* registry.n */,
-				F96D3E9008F272A6004A47F5 /* regsub.n */,
-				F96D3E9108F272A6004A47F5 /* rename.n */,
-				F96D3E9208F272A6004A47F5 /* return.n */,
-				F96D3E9308F272A6004A47F5 /* safe.n */,
-				F96D3E9408F272A6004A47F5 /* SaveResult.3 */,
-				F96D3E9508F272A6004A47F5 /* scan.n */,
-				F96D3E9608F272A6004A47F5 /* seek.n */,
-				F93599D80DF1F98300E04F67 /* self.n */,
-				F96D3E9708F272A6004A47F5 /* set.n */,
-				F96D3E9808F272A6004A47F5 /* SetChanErr.3 */,
-				F96D3E9908F272A6004A47F5 /* SetErrno.3 */,
-				F96D3E9A08F272A6004A47F5 /* SetRecLmt.3 */,
-				F96D3E9B08F272A7004A47F5 /* SetResult.3 */,
-				F96D3E9C08F272A7004A47F5 /* SetVar.3 */,
-				F96D3E9D08F272A7004A47F5 /* Signal.3 */,
-				F96D3E9E08F272A7004A47F5 /* Sleep.3 */,
-				F96D3E9F08F272A7004A47F5 /* socket.n */,
-				F96D3EA008F272A7004A47F5 /* source.n */,
-				F96D3EA108F272A7004A47F5 /* SourceRCFile.3 */,
-				F96D3EA208F272A7004A47F5 /* split.n */,
-				F96D3EA308F272A7004A47F5 /* SplitList.3 */,
-				F96D3EA408F272A7004A47F5 /* SplitPath.3 */,
-				F96D3EA508F272A7004A47F5 /* StaticPkg.3 */,
-				F96D3EA608F272A7004A47F5 /* StdChannels.3 */,
-				F96D3EA708F272A7004A47F5 /* string.n */,
-				F96D3EA808F272A7004A47F5 /* StringObj.3 */,
-				F96D3EA908F272A7004A47F5 /* StrMatch.3 */,
-				F96D3EAA08F272A7004A47F5 /* subst.n */,
-				F96D3EAB08F272A7004A47F5 /* SubstObj.3 */,
-				F96D3EAC08F272A7004A47F5 /* switch.n */,
-				F974D5760FBE7E1900BF728B /* tailcall.n */,
-				F96D3EAD08F272A7004A47F5 /* Tcl.n */,
-				F99D61180EF5573A00BBFE01 /* TclZlib.3 */,
-				F96D3EAE08F272A7004A47F5 /* Tcl_Main.3 */,
-				F96D3EAF08F272A7004A47F5 /* TCL_MEM_DEBUG.3 */,
-				F96D3EB008F272A7004A47F5 /* tclsh.1 */,
-				F96D3EB108F272A7004A47F5 /* tcltest.n */,
-				F96D3EB208F272A7004A47F5 /* tclvars.n */,
-				F96D3EB308F272A7004A47F5 /* tell.n */,
-				F96D3EB408F272A7004A47F5 /* Thread.3 */,
-				F9183E640EFC80CD0030B814 /* throw.n */,
-				F96D3EB508F272A7004A47F5 /* time.n */,
-				F96D3EB608F272A7004A47F5 /* tm.n */,
-				F96D3EB708F272A7004A47F5 /* ToUpper.3 */,
-				F96D3EB808F272A7004A47F5 /* trace.n */,
-				F96D3EB908F272A7004A47F5 /* TraceCmd.3 */,
-				F96D3EBA08F272A7004A47F5 /* TraceVar.3 */,
-				F96D3EBB08F272A7004A47F5 /* Translate.3 */,
-				F9183E650EFC80D70030B814 /* try.n */,
-				F96D3EBC08F272A7004A47F5 /* UniCharIsAlpha.3 */,
-				F96D3EBD08F272A7004A47F5 /* unknown.n */,
-				F96D3EBE08F272A7004A47F5 /* unload.n */,
-				F96D3EBF08F272A7004A47F5 /* unset.n */,
-				F96D3EC008F272A7004A47F5 /* update.n */,
-				F96D3EC108F272A7004A47F5 /* uplevel.n */,
-				F96D3EC208F272A7004A47F5 /* UpVar.3 */,
-				F96D3EC308F272A7004A47F5 /* upvar.n */,
-				F96D3EC408F272A7004A47F5 /* Utf.3 */,
-				F96D3EC508F272A7004A47F5 /* variable.n */,
-				F96D3EC608F272A7004A47F5 /* vwait.n */,
-				F96D3EC708F272A7004A47F5 /* while.n */,
-				F96D3EC808F272A7004A47F5 /* WrongNumArgs.3 */,
-				F915432D0EF201EE0032D1E8 /* zlib.n */,
-			);
-			path = doc;
-			sourceTree = "<group>";
-		};
-		F96D3EC908F272A7004A47F5 /* generic */ = {
-			isa = PBXGroup;
-			children = (
-				F96D3ECA08F272A7004A47F5 /* README */,
-				F96D3ECB08F272A7004A47F5 /* regc_color.c */,
-				F96D3ECC08F272A7004A47F5 /* regc_cvec.c */,
-				F96D3ECD08F272A7004A47F5 /* regc_lex.c */,
-				F96D3ECE08F272A7004A47F5 /* regc_locale.c */,
-				F96D3ECF08F272A7004A47F5 /* regc_nfa.c */,
-				F96D3ED008F272A7004A47F5 /* regcomp.c */,
-				F96D3ED108F272A7004A47F5 /* regcustom.h */,
-				F96D3ED208F272A7004A47F5 /* rege_dfa.c */,
-				F96D3ED308F272A7004A47F5 /* regerror.c */,
-				F96D3ED408F272A7004A47F5 /* regerrs.h */,
-				F96D3ED508F272A7004A47F5 /* regex.h */,
-				F96D3ED608F272A7004A47F5 /* regexec.c */,
-				F96D3ED708F272A7004A47F5 /* regfree.c */,
-				F96D3ED808F272A7004A47F5 /* regfronts.c */,
-				F96D3ED908F272A7004A47F5 /* regguts.h */,
-				F96D3EDA08F272A7004A47F5 /* tcl.decls */,
-				F96D3EDB08F272A7004A47F5 /* tcl.h */,
-				F96D3EDC08F272A7004A47F5 /* tclAlloc.c */,
-				F96D3EDD08F272A7004A47F5 /* tclAsync.c */,
-				F96D3EDE08F272A7004A47F5 /* tclBasic.c */,
-				F96D3EDF08F272A7004A47F5 /* tclBinary.c */,
-				F96D3EE008F272A7004A47F5 /* tclCkalloc.c */,
-				F96D3EE108F272A7004A47F5 /* tclClock.c */,
-				F96D3EE208F272A7004A47F5 /* tclCmdAH.c */,
-				F96D3EE308F272A7004A47F5 /* tclCmdIL.c */,
-				F96D3EE408F272A7004A47F5 /* tclCmdMZ.c */,
-				F96D3EE508F272A7004A47F5 /* tclCompCmds.c */,
-				F96D3EE608F272A7004A47F5 /* tclCompExpr.c */,
-				F96D3EE708F272A7004A47F5 /* tclCompile.c */,
-				F96D3EE808F272A7004A47F5 /* tclCompile.h */,
-				F96D3EE908F272A7004A47F5 /* tclConfig.c */,
-				F96D3EEA08F272A7004A47F5 /* tclDate.c */,
-				F96D3EEB08F272A7004A47F5 /* tclDecls.h */,
-				F96D3EEC08F272A7004A47F5 /* tclDictObj.c */,
-				F9F4415D0C8BAE6F00BCCD67 /* tclDTrace.d */,
-				F96D3EED08F272A7004A47F5 /* tclEncoding.c */,
-				F96D3EEE08F272A7004A47F5 /* tclEnv.c */,
-				F96D3EEF08F272A7004A47F5 /* tclEvent.c */,
-				F96D3EF008F272A7004A47F5 /* tclExecute.c */,
-				F96D3EF108F272A7004A47F5 /* tclFCmd.c */,
-				F96D3EF208F272A7004A47F5 /* tclFileName.c */,
-				F96D3EF308F272A7004A47F5 /* tclFileSystem.h */,
-				F96D3EF408F272A7004A47F5 /* tclGet.c */,
-				F96D3EF508F272A7004A47F5 /* tclGetDate.y */,
-				F96D3EF608F272A7004A47F5 /* tclHash.c */,
-				F96D3EF708F272A7004A47F5 /* tclHistory.c */,
-				F96D3EF808F272A7004A47F5 /* tclIndexObj.c */,
-				F96D3EF908F272A7004A47F5 /* tclInt.decls */,
-				F96D3EFA08F272A7004A47F5 /* tclInt.h */,
-				F96D3EFB08F272A7004A47F5 /* tclIntDecls.h */,
-				F96D3EFC08F272A7004A47F5 /* tclInterp.c */,
-				F96D3EFD08F272A7004A47F5 /* tclIntPlatDecls.h */,
-				F96D3EFE08F272A7004A47F5 /* tclIO.c */,
-				F96D3EFF08F272A7004A47F5 /* tclIO.h */,
-				F96D3F0008F272A7004A47F5 /* tclIOCmd.c */,
-				F96D3F0108F272A7004A47F5 /* tclIOGT.c */,
-				F96D3F0208F272A7004A47F5 /* tclIORChan.c */,
-				F95D77E90DFD820D00A8BF6F /* tclIORTrans.c */,
-				F96D3F0308F272A7004A47F5 /* tclIOSock.c */,
-				F96D3F0408F272A7004A47F5 /* tclIOUtil.c */,
-				F96D3F0508F272A7004A47F5 /* tclLink.c */,
-				F96D3F0608F272A7004A47F5 /* tclListObj.c */,
-				F96D3F0708F272A7004A47F5 /* tclLiteral.c */,
-				F96D3F0808F272A7004A47F5 /* tclLoad.c */,
-				F96D3F0908F272A7004A47F5 /* tclLoadNone.c */,
-				F96D3F0A08F272A7004A47F5 /* tclMain.c */,
-				F96D3F0B08F272A7004A47F5 /* tclNamesp.c */,
-				F96D3F0C08F272A7004A47F5 /* tclNotify.c */,
-				F96D3F0D08F272A7004A47F5 /* tclObj.c */,
-				F93599B20DF1F75400E04F67 /* tclOO.c */,
-				F93599B40DF1F75900E04F67 /* tclOO.decls */,
-				F93599B50DF1F75D00E04F67 /* tclOO.h */,
-				F93599B60DF1F76100E04F67 /* tclOOBasic.c */,
-				F93599B80DF1F76600E04F67 /* tclOOCall.c */,
-				F93599BA0DF1F76A00E04F67 /* tclOODecls.h */,
-				F93599BB0DF1F77000E04F67 /* tclOODefineCmds.c */,
-				F93599BD0DF1F77400E04F67 /* tclOOInfo.c */,
-				F93599BF0DF1F77900E04F67 /* tclOOInt.h */,
-				F93599C00DF1F77D00E04F67 /* tclOOIntDecls.h */,
-				F93599C10DF1F78300E04F67 /* tclOOMethod.c */,
-				F93599C30DF1F78800E04F67 /* tclOOStubInit.c */,
-				F93599C50DF1F78D00E04F67 /* tclOOStubLib.c */,
-				F96D3F0E08F272A7004A47F5 /* tclPanic.c */,
-				F96D3F0F08F272A7004A47F5 /* tclParse.c */,
-				F96D3F1108F272A7004A47F5 /* tclPathObj.c */,
-				F96D3F1208F272A7004A47F5 /* tclPipe.c */,
-				F96D3F1308F272A7004A47F5 /* tclPkg.c */,
-				F96D3F1408F272A7004A47F5 /* tclPkgConfig.c */,
-				F96D3F1508F272A7004A47F5 /* tclPlatDecls.h */,
-				F96D3F1608F272A7004A47F5 /* tclPort.h */,
-				F96D3F1708F272A7004A47F5 /* tclPosixStr.c */,
-				F96D3F1808F272A7004A47F5 /* tclPreserve.c */,
-				F96D3F1908F272A7004A47F5 /* tclProc.c */,
-				F96D3F1A08F272A7004A47F5 /* tclRegexp.c */,
-				F96D3F1B08F272A7004A47F5 /* tclRegexp.h */,
-				F96D3F1C08F272A7004A47F5 /* tclResolve.c */,
-				F96D3F1D08F272A7004A47F5 /* tclResult.c */,
-				F96D3F1E08F272A7004A47F5 /* tclScan.c */,
-				F96D3F1F08F272A7004A47F5 /* tclStringObj.c */,
-				F96D3F2408F272A7004A47F5 /* tclStrToD.c */,
-				F96D3F2508F272A7004A47F5 /* tclStubInit.c */,
-				F96D3F2608F272A7004A47F5 /* tclStubLib.c */,
-				F96D3F2708F272A7004A47F5 /* tclTest.c */,
-				F96D3F2808F272A7004A47F5 /* tclTestObj.c */,
-				F96D3F2908F272A7004A47F5 /* tclTestProcBodyObj.c */,
-				F96D3F2A08F272A7004A47F5 /* tclThread.c */,
-				F96D3F2B08F272A7004A47F5 /* tclThreadAlloc.c */,
-				F96D3F2C08F272A7004A47F5 /* tclThreadJoin.c */,
-				F96D3F2D08F272A7004A47F5 /* tclThreadStorage.c */,
-				F96D3F2E08F272A7004A47F5 /* tclThreadTest.c */,
-				F96D3F2F08F272A7004A47F5 /* tclTimer.c */,
-				F9903CAF094FAADA004613E9 /* tclTomMath.decls */,
-				F96D3F3008F272A7004A47F5 /* tclTomMath.h */,
-				F9903CB0094FAADA004613E9 /* tclTomMathDecls.h */,
-				F96D3F3108F272A7004A47F5 /* tclTomMathInterface.c */,
-				F96D3F3208F272A7004A47F5 /* tclTrace.c */,
-				F96D3F3308F272A7004A47F5 /* tclUniData.c */,
-				F96D3F3408F272A7004A47F5 /* tclUtf.c */,
-				F96D3F3508F272A7004A47F5 /* tclUtil.c */,
-				F96D3F3608F272A7004A47F5 /* tclVar.c */,
-				F96437C90EF0D4B2003F468E /* tclZlib.c */,
-				F96D3F3708F272A7004A47F5 /* tommath.h */,
-			);
-			path = generic;
-			sourceTree = "<group>";
-		};
-		F96D3F3808F272A7004A47F5 /* library */ = {
-			isa = PBXGroup;
-			children = (
-				F96D3F3908F272A8004A47F5 /* auto.tcl */,
-				F96D3F3A08F272A8004A47F5 /* clock.tcl */,
-				F96D3F3B08F272A8004A47F5 /* dde */,
-				F96D3F8C08F272A8004A47F5 /* history.tcl */,
-				F96D3F8D08F272A8004A47F5 /* http */,
-				F96D3F9008F272A8004A47F5 /* http1.0 */,
-				F96D3F9308F272A8004A47F5 /* init.tcl */,
-				F96D3F9408F272A8004A47F5 /* msgcat */,
-				F96D401708F272AA004A47F5 /* opt */,
-				F96D401A08F272AA004A47F5 /* package.tcl */,
-				F96D401B08F272AA004A47F5 /* parray.tcl */,
-				F9ECB1110B26521500A28025 /* platform */,
-				F96D401C08F272AA004A47F5 /* reg */,
-				F96D401E08F272AA004A47F5 /* safe.tcl */,
-				F96D401F08F272AA004A47F5 /* tclIndex */,
-				F96D402008F272AA004A47F5 /* tcltest */,
-				F96D402308F272AA004A47F5 /* tm.tcl */,
-				F96D425B08F272B2004A47F5 /* word.tcl */,
-			);
-			path = library;
-			sourceTree = "<group>";
-		};
-		F96D3F3B08F272A8004A47F5 /* dde */ = {
-			isa = PBXGroup;
-			children = (
-				F96D3F3C08F272A8004A47F5 /* pkgIndex.tcl */,
-			);
-			path = dde;
-			sourceTree = "<group>";
-		};
-		F96D3F8D08F272A8004A47F5 /* http */ = {
-			isa = PBXGroup;
-			children = (
-				F96D3F8E08F272A8004A47F5 /* http.tcl */,
-				F96D3F8F08F272A8004A47F5 /* pkgIndex.tcl */,
-			);
-			path = http;
-			sourceTree = "<group>";
-		};
-		F96D3F9008F272A8004A47F5 /* http1.0 */ = {
-			isa = PBXGroup;
-			children = (
-				F96D3F9108F272A8004A47F5 /* http.tcl */,
-				F96D3F9208F272A8004A47F5 /* pkgIndex.tcl */,
-			);
-			path = http1.0;
-			sourceTree = "<group>";
-		};
-		F96D3F9408F272A8004A47F5 /* msgcat */ = {
-			isa = PBXGroup;
-			children = (
-				F96D3F9508F272A8004A47F5 /* msgcat.tcl */,
-				F96D3F9608F272A8004A47F5 /* pkgIndex.tcl */,
-			);
-			path = msgcat;
-			sourceTree = "<group>";
-		};
-		F96D401708F272AA004A47F5 /* opt */ = {
-			isa = PBXGroup;
-			children = (
-				F96D401808F272AA004A47F5 /* optparse.tcl */,
-				F96D401908F272AA004A47F5 /* pkgIndex.tcl */,
-			);
-			path = opt;
-			sourceTree = "<group>";
-		};
-		F96D401C08F272AA004A47F5 /* reg */ = {
-			isa = PBXGroup;
-			children = (
-				F96D401D08F272AA004A47F5 /* pkgIndex.tcl */,
-			);
-			path = reg;
-			sourceTree = "<group>";
-		};
-		F96D402008F272AA004A47F5 /* tcltest */ = {
-			isa = PBXGroup;
-			children = (
-				F96D402108F272AA004A47F5 /* pkgIndex.tcl */,
-				F96D402208F272AA004A47F5 /* tcltest.tcl */,
-			);
-			path = tcltest;
-			sourceTree = "<group>";
-		};
-		F96D425C08F272B2004A47F5 /* libtommath */ = {
-			isa = PBXGroup;
-			children = (
-				F96D426408F272B3004A47F5 /* bn_fast_s_mp_mul_digs.c */,
-				F96D426608F272B3004A47F5 /* bn_fast_s_mp_sqr.c */,
-				F96D426908F272B3004A47F5 /* bn_mp_add.c */,
-				F96D426A08F272B3004A47F5 /* bn_mp_add_d.c */,
-				F96D426C08F272B3004A47F5 /* bn_mp_and.c */,
-				F96D426D08F272B3004A47F5 /* bn_mp_clamp.c */,
-				F96D426E08F272B3004A47F5 /* bn_mp_clear.c */,
-				F96D426F08F272B3004A47F5 /* bn_mp_clear_multi.c */,
-				F96D427008F272B3004A47F5 /* bn_mp_cmp.c */,
-				F96D427108F272B3004A47F5 /* bn_mp_cmp_d.c */,
-				F96D427208F272B3004A47F5 /* bn_mp_cmp_mag.c */,
-				F96D427408F272B3004A47F5 /* bn_mp_copy.c */,
-				F96D427508F272B3004A47F5 /* bn_mp_count_bits.c */,
-				F96D427608F272B3004A47F5 /* bn_mp_div.c */,
-				F96D427708F272B3004A47F5 /* bn_mp_div_2.c */,
-				F96D427808F272B3004A47F5 /* bn_mp_div_2d.c */,
-				F96D427908F272B3004A47F5 /* bn_mp_div_3.c */,
-				F96D427A08F272B3004A47F5 /* bn_mp_div_d.c */,
-				F96D427E08F272B3004A47F5 /* bn_mp_exch.c */,
-				F96D427F08F272B3004A47F5 /* bn_mp_expt_d.c */,
-				F96D428708F272B3004A47F5 /* bn_mp_grow.c */,
-				F96D428808F272B3004A47F5 /* bn_mp_init.c */,
-				F96D428908F272B3004A47F5 /* bn_mp_init_copy.c */,
-				F96D428A08F272B3004A47F5 /* bn_mp_init_multi.c */,
-				F96D428B08F272B3004A47F5 /* bn_mp_init_set.c */,
-				F96D428D08F272B3004A47F5 /* bn_mp_init_size.c */,
-				F96D429208F272B3004A47F5 /* bn_mp_karatsuba_mul.c */,
-				F96D429308F272B3004A47F5 /* bn_mp_karatsuba_sqr.c */,
-				F96D429508F272B3004A47F5 /* bn_mp_lshd.c */,
-				F96D429608F272B3004A47F5 /* bn_mp_mod.c */,
-				F96D429708F272B3004A47F5 /* bn_mp_mod_2d.c */,
-				F96D429C08F272B3004A47F5 /* bn_mp_mul.c */,
-				F96D429D08F272B3004A47F5 /* bn_mp_mul_2.c */,
-				F96D429E08F272B3004A47F5 /* bn_mp_mul_2d.c */,
-				F96D429F08F272B3004A47F5 /* bn_mp_mul_d.c */,
-				F96D42A208F272B3004A47F5 /* bn_mp_neg.c */,
-				F96D42A308F272B3004A47F5 /* bn_mp_or.c */,
-				F96D42AB08F272B3004A47F5 /* bn_mp_radix_size.c */,
-				F96D42AC08F272B3004A47F5 /* bn_mp_radix_smap.c */,
-				F96D42AE08F272B3004A47F5 /* bn_mp_read_radix.c */,
-				F96D42B908F272B3004A47F5 /* bn_mp_rshd.c */,
-				F96D42BA08F272B3004A47F5 /* bn_mp_set.c */,
-				F96D42BC08F272B3004A47F5 /* bn_mp_shrink.c */,
-				F96D42BE08F272B3004A47F5 /* bn_mp_sqr.c */,
-				F96D42C008F272B3004A47F5 /* bn_mp_sqrt.c */,
-				F96D42C108F272B3004A47F5 /* bn_mp_sub.c */,
-				F96D42C208F272B3004A47F5 /* bn_mp_sub_d.c */,
-				F96D42C608F272B3004A47F5 /* bn_mp_to_unsigned_bin.c */,
-				F96D42C708F272B3004A47F5 /* bn_mp_to_unsigned_bin_n.c */,
-				F96D42C808F272B3004A47F5 /* bn_mp_toom_mul.c */,
-				F96D42C908F272B3004A47F5 /* bn_mp_toom_sqr.c */,
-				F96D42CB08F272B3004A47F5 /* bn_mp_toradix_n.c */,
-				F96D42CC08F272B3004A47F5 /* bn_mp_unsigned_bin_size.c */,
-				F96D42CD08F272B3004A47F5 /* bn_mp_xor.c */,
-				F96D42CE08F272B3004A47F5 /* bn_mp_zero.c */,
-				F96D42D008F272B3004A47F5 /* bn_reverse.c */,
-				F96D42D108F272B3004A47F5 /* bn_s_mp_add.c */,
-				F96D42D308F272B3004A47F5 /* bn_s_mp_mul_digs.c */,
-				F96D42D508F272B3004A47F5 /* bn_s_mp_sqr.c */,
-				F96D42D608F272B3004A47F5 /* bn_s_mp_sub.c */,
-				F96D42D708F272B3004A47F5 /* bncore.c */,
-				F96D432908F272B4004A47F5 /* tommath_class.h */,
-				F96D432A08F272B4004A47F5 /* tommath_superclass.h */,
-			);
-			path = libtommath;
-			sourceTree = "<group>";
-		};
-		F96D432C08F272B4004A47F5 /* macosx */ = {
-			isa = PBXGroup;
-			children = (
-				F96D432E08F272B5004A47F5 /* configure.ac */,
-				F96D432F08F272B5004A47F5 /* GNUmakefile */,
-				F96D433108F272B5004A47F5 /* README */,
-				F96D433908F272B5004A47F5 /* tclMacOSXBundle.c */,
-				F96D433D08F272B5004A47F5 /* tclMacOSXFCmd.c */,
-				F96D433E08F272B5004A47F5 /* tclMacOSXNotify.c */,
-				F96D433208F272B5004A47F5 /* Tcl-Info.plist.in */,
-				F91E62260C1AE686006C9D96 /* Tclsh-Info.plist.in */,
-			);
-			path = macosx;
-			sourceTree = "<group>";
-		};
-		F96D434408F272B5004A47F5 /* tests */ = {
-			isa = PBXGroup;
-			children = (
-				F96D434508F272B5004A47F5 /* all.tcl */,
-				F96D434608F272B5004A47F5 /* append.test */,
-				F96D434708F272B5004A47F5 /* appendComp.test */,
-				F9ECB1CA0B2652D300A28025 /* apply.test */,
-				F96D434808F272B5004A47F5 /* assocd.test */,
-				F96D434908F272B5004A47F5 /* async.test */,
-				F96D434A08F272B5004A47F5 /* autoMkindex.test */,
-				F96D434B08F272B5004A47F5 /* basic.test */,
-				F96D434C08F272B5004A47F5 /* binary.test */,
-				F96D434D08F272B5004A47F5 /* case.test */,
-				F96D434E08F272B5004A47F5 /* chan.test */,
-				F9A493240CEBF38300B78AE2 /* chanio.test */,
-				F96D434F08F272B5004A47F5 /* clock.test */,
-				F96D435008F272B5004A47F5 /* cmdAH.test */,
-				F96D435108F272B5004A47F5 /* cmdIL.test */,
-				F96D435208F272B5004A47F5 /* cmdInfo.test */,
-				F96D435308F272B5004A47F5 /* cmdMZ.test */,
-				F96D435408F272B5004A47F5 /* compExpr-old.test */,
-				F96D435508F272B5004A47F5 /* compExpr.test */,
-				F96D435608F272B5004A47F5 /* compile.test */,
-				F96D435708F272B5004A47F5 /* concat.test */,
-				F96D435808F272B5004A47F5 /* config.test */,
-				F974D5770FBE7E6100BF728B /* coroutine.test */,
-				F96D435908F272B5004A47F5 /* dcall.test */,
-				F96D435A08F272B5004A47F5 /* dict.test */,
-				F96D435C08F272B5004A47F5 /* dstring.test */,
-				F96D435E08F272B5004A47F5 /* encoding.test */,
-				F96D435F08F272B5004A47F5 /* env.test */,
-				F96D436008F272B5004A47F5 /* error.test */,
-				F96D436108F272B5004A47F5 /* eval.test */,
-				F96D436208F272B5004A47F5 /* event.test */,
-				F96D436308F272B5004A47F5 /* exec.test */,
-				F96D436408F272B5004A47F5 /* execute.test */,
-				F96D436508F272B5004A47F5 /* expr-old.test */,
-				F96D436608F272B5004A47F5 /* expr.test */,
-				F96D436708F272B6004A47F5 /* fCmd.test */,
-				F96D436808F272B6004A47F5 /* fileName.test */,
-				F96D436908F272B6004A47F5 /* fileSystem.test */,
-				F96D436A08F272B6004A47F5 /* for-old.test */,
-				F96D436B08F272B6004A47F5 /* for.test */,
-				F96D436C08F272B6004A47F5 /* foreach.test */,
-				F96D436D08F272B6004A47F5 /* format.test */,
-				F96D436E08F272B6004A47F5 /* get.test */,
-				F96D436F08F272B6004A47F5 /* history.test */,
-				F96D437008F272B6004A47F5 /* http.test */,
-				F974D56C0FBE7D6300BF728B /* http11.test */,
-				F96D437108F272B6004A47F5 /* httpd */,
-				F974D56D0FBE7D6300BF728B /* httpd11.tcl */,
-				F96D437208F272B6004A47F5 /* httpold.test */,
-				F96D437308F272B6004A47F5 /* if-old.test */,
-				F96D437408F272B6004A47F5 /* if.test */,
-				F96D437508F272B6004A47F5 /* incr-old.test */,
-				F96D437608F272B6004A47F5 /* incr.test */,
-				F96D437708F272B6004A47F5 /* indexObj.test */,
-				F96D437808F272B6004A47F5 /* info.test */,
-				F96D437908F272B6004A47F5 /* init.test */,
-				F96D437A08F272B6004A47F5 /* interp.test */,
-				F96D437B08F272B6004A47F5 /* io.test */,
-				F96D437C08F272B6004A47F5 /* ioCmd.test */,
-				F96D437D08F272B6004A47F5 /* iogt.test */,
-				F96D437F08F272B6004A47F5 /* join.test */,
-				F96D438008F272B6004A47F5 /* lindex.test */,
-				F96D438108F272B6004A47F5 /* link.test */,
-				F96D438208F272B6004A47F5 /* linsert.test */,
-				F96D438308F272B6004A47F5 /* list.test */,
-				F96D438408F272B6004A47F5 /* listObj.test */,
-				F96D438508F272B6004A47F5 /* llength.test */,
-				F96D438608F272B6004A47F5 /* load.test */,
-				F96D438708F272B6004A47F5 /* lrange.test */,
-				F96D438808F272B6004A47F5 /* lrepeat.test */,
-				F96D438908F272B6004A47F5 /* lreplace.test */,
-				F96D438A08F272B6004A47F5 /* lsearch.test */,
-				F96D438B08F272B6004A47F5 /* lset.test */,
-				F96D438C08F272B6004A47F5 /* lsetComp.test */,
-				F96D438D08F272B6004A47F5 /* macOSXFCmd.test */,
-				F95FAFF90B34F1130072E431 /* macOSXLoad.test */,
-				F96D438E08F272B6004A47F5 /* main.test */,
-				F9ECB1CB0B26534C00A28025 /* mathop.test */,
-				F96D438F08F272B6004A47F5 /* misc.test */,
-				F96D439008F272B6004A47F5 /* msgcat.test */,
-				F96D439108F272B6004A47F5 /* namespace-old.test */,
-				F96D439208F272B7004A47F5 /* namespace.test */,
-				F96D439308F272B7004A47F5 /* notify.test */,
-				F91DC23C0E44C51B002CB8D1 /* nre.test */,
-				F96D439408F272B7004A47F5 /* obj.test */,
-				F93599C80DF1F81900E04F67 /* oo.test */,
-				F96D439508F272B7004A47F5 /* opt.test */,
-				F96D439608F272B7004A47F5 /* package.test */,
-				F96D439708F272B7004A47F5 /* parse.test */,
-				F96D439808F272B7004A47F5 /* parseExpr.test */,
-				F96D439908F272B7004A47F5 /* parseOld.test */,
-				F96D439A08F272B7004A47F5 /* pid.test */,
-				F96D439B08F272B7004A47F5 /* pkg.test */,
-				F96D439C08F272B7004A47F5 /* pkgMkIndex.test */,
-				F96D439D08F272B7004A47F5 /* platform.test */,
-				F96D439E08F272B7004A47F5 /* proc-old.test */,
-				F96D439F08F272B7004A47F5 /* proc.test */,
-				F96D43A008F272B7004A47F5 /* pwd.test */,
-				F96D43A108F272B7004A47F5 /* README */,
-				F96D43A208F272B7004A47F5 /* reg.test */,
-				F96D43A308F272B7004A47F5 /* regexp.test */,
-				F96D43A408F272B7004A47F5 /* regexpComp.test */,
-				F96D43A508F272B7004A47F5 /* registry.test */,
-				F96D43A608F272B7004A47F5 /* remote.tcl */,
-				F96D43A708F272B7004A47F5 /* rename.test */,
-				F96D43A808F272B7004A47F5 /* result.test */,
-				F96D43A908F272B7004A47F5 /* safe.test */,
-				F96D43AA08F272B7004A47F5 /* scan.test */,
-				F96D43AB08F272B7004A47F5 /* security.test */,
-				F96D43AC08F272B7004A47F5 /* set-old.test */,
-				F96D43AD08F272B7004A47F5 /* set.test */,
-				F96D43AE08F272B7004A47F5 /* socket.test */,
-				F96D43AF08F272B7004A47F5 /* source.test */,
-				F96D43B008F272B7004A47F5 /* split.test */,
-				F96D43B108F272B7004A47F5 /* stack.test */,
-				F96D43B208F272B7004A47F5 /* string.test */,
-				F96D43B308F272B7004A47F5 /* stringComp.test */,
-				F96D43B408F272B7004A47F5 /* stringObj.test */,
-				F96D43B508F272B7004A47F5 /* subst.test */,
-				F96D43B608F272B7004A47F5 /* switch.test */,
-				F974D5780FBE7E6100BF728B /* tailcall.test */,
-				F96D43B708F272B7004A47F5 /* tcltest.test */,
-				F96D43B808F272B7004A47F5 /* thread.test */,
-				F96D43B908F272B7004A47F5 /* timer.test */,
-				F96D43BA08F272B7004A47F5 /* tm.test */,
-				F96D43BB08F272B7004A47F5 /* trace.test */,
-				F96D43BC08F272B7004A47F5 /* unixFCmd.test */,
-				F96D43BD08F272B7004A47F5 /* unixFile.test */,
-				F96D43BE08F272B7004A47F5 /* unixInit.test */,
-				F96D43BF08F272B7004A47F5 /* unixNotfy.test */,
-				F96D43C008F272B7004A47F5 /* unknown.test */,
-				F96D43C108F272B7004A47F5 /* unload.test */,
-				F96D43C208F272B7004A47F5 /* uplevel.test */,
-				F96D43C308F272B7004A47F5 /* upvar.test */,
-				F96D43C408F272B7004A47F5 /* utf.test */,
-				F96D43C508F272B7004A47F5 /* util.test */,
-				F96D43C608F272B7004A47F5 /* var.test */,
-				F96D43C708F272B7004A47F5 /* while-old.test */,
-				F96D43C808F272B7004A47F5 /* while.test */,
-				F96D43C908F272B7004A47F5 /* winConsole.test */,
-				F96D43CA08F272B7004A47F5 /* winDde.test */,
-				F96D43CB08F272B7004A47F5 /* winFCmd.test */,
-				F96D43CC08F272B7004A47F5 /* winFile.test */,
-				F96D43CD08F272B7004A47F5 /* winNotify.test */,
-				F96D43CE08F272B7004A47F5 /* winPipe.test */,
-				F96D43CF08F272B7004A47F5 /* winTime.test */,
-				F915432A0EF201CF0032D1E8 /* zlib.test */,
-			);
-			path = tests;
-			sourceTree = "<group>";
-		};
-		F96D43D008F272B8004A47F5 /* tools */ = {
-			isa = PBXGroup;
-			children = (
-				F96D43D108F272B8004A47F5 /* checkLibraryDoc.tcl */,
-				F96D43D208F272B8004A47F5 /* configure */,
-				F96D43D308F272B8004A47F5 /* configure.ac */,
-				F96D442208F272B8004A47F5 /* eolFix.tcl */,
-				F96D442408F272B8004A47F5 /* fix_tommath_h.tcl */,
-				F96D442508F272B8004A47F5 /* genStubs.tcl */,
-				F96D442708F272B8004A47F5 /* index.tcl */,
-				F96D442808F272B8004A47F5 /* installData.tcl */,
-				F96D442908F272B8004A47F5 /* loadICU.tcl */,
-				F96D442A08F272B8004A47F5 /* Makefile.in */,
-				F96D442B08F272B8004A47F5 /* makeTestCases.tcl */,
-				F96D442C08F272B8004A47F5 /* man2help.tcl */,
-				F96D442D08F272B8004A47F5 /* man2help2.tcl */,
-				F96D442E08F272B8004A47F5 /* man2html.tcl */,
-				F96D442F08F272B8004A47F5 /* man2html1.tcl */,
-				F96D443008F272B8004A47F5 /* man2html2.tcl */,
-				F96D443108F272B8004A47F5 /* man2tcl.c */,
-				F96D443208F272B8004A47F5 /* README */,
-				F96D443308F272B8004A47F5 /* regexpTestLib.tcl */,
-				F96D443508F272B8004A47F5 /* tcl.hpj.in */,
-				F96D443608F272B8004A47F5 /* tcl.wse.in */,
-				F96D443908F272B9004A47F5 /* tcltk-man2html.tcl */,
-				F96D443A08F272B9004A47F5 /* tclZIC.tcl */,
-				F92D7F100DE777240033A13A /* tsdPerf.tcl */,
-				F96D443B08F272B9004A47F5 /* uniClass.tcl */,
-				F96D443C08F272B9004A47F5 /* uniParse.tcl */,
-			);
-			path = tools;
-			sourceTree = "<group>";
-		};
-		F96D443E08F272B9004A47F5 /* unix */ = {
-			isa = PBXGroup;
-			children = (
-				F96D444008F272B9004A47F5 /* aclocal.m4 */,
-				F96D444108F272B9004A47F5 /* configure */,
-				F96D444208F272B9004A47F5 /* configure.ac */,
-				F96D444308F272B9004A47F5 /* dltest */,
-				F96D444D08F272B9004A47F5 /* install-sh */,
-				F96D444E08F272B9004A47F5 /* installManPage */,
-				F96D444F08F272B9004A47F5 /* ldAix */,
-				F96D445008F272B9004A47F5 /* Makefile.in */,
-				F96D445208F272B9004A47F5 /* README */,
-				F96D445308F272B9004A47F5 /* tcl.m4 */,
-				F974D5790FBE7E9C00BF728B /* tcl.pc.in */,
-				F96D445408F272B9004A47F5 /* tcl.spec */,
-				F96D445508F272B9004A47F5 /* tclAppInit.c */,
-				F96D445608F272B9004A47F5 /* tclConfig.h.in */,
-				F96D445708F272B9004A47F5 /* tclConfig.sh.in */,
-				F96D445808F272B9004A47F5 /* tclLoadAix.c */,
-				F96D445908F272B9004A47F5 /* tclLoadDl.c */,
-				F96D445B08F272B9004A47F5 /* tclLoadDyld.c */,
-				F96D445C08F272B9004A47F5 /* tclLoadNext.c */,
-				F96D445D08F272B9004A47F5 /* tclLoadOSF.c */,
-				F96D445E08F272B9004A47F5 /* tclLoadShl.c */,
-				F96D445F08F272B9004A47F5 /* tclUnixChan.c */,
-				F9FC77B70AB29E9100B7077D /* tclUnixCompat.c */,
-				F96D446008F272B9004A47F5 /* tclUnixEvent.c */,
-				F96D446108F272B9004A47F5 /* tclUnixFCmd.c */,
-				F96D446208F272B9004A47F5 /* tclUnixFile.c */,
-				F96D446308F272B9004A47F5 /* tclUnixInit.c */,
-				F96D446408F272B9004A47F5 /* tclUnixNotfy.c */,
-				F96D446508F272B9004A47F5 /* tclUnixPipe.c */,
-				F96D446608F272B9004A47F5 /* tclUnixPort.h */,
-				F96D446708F272B9004A47F5 /* tclUnixSock.c */,
-				F96D446808F272B9004A47F5 /* tclUnixTest.c */,
-				F96D446908F272B9004A47F5 /* tclUnixThrd.c */,
-				F96D446A08F272B9004A47F5 /* tclUnixThrd.h */,
-				F96D446B08F272B9004A47F5 /* tclUnixTime.c */,
-				F96D446C08F272B9004A47F5 /* tclXtNotify.c */,
-				F96D446D08F272B9004A47F5 /* tclXtTest.c */,
-			);
-			path = unix;
-			sourceTree = "<group>";
-		};
-		F96D444308F272B9004A47F5 /* dltest */ = {
-			isa = PBXGroup;
-			children = (
-				F96D444408F272B9004A47F5 /* Makefile.in */,
-				F96D444508F272B9004A47F5 /* pkga.c */,
-				F96D444608F272B9004A47F5 /* pkgb.c */,
-				F96D444708F272B9004A47F5 /* pkgc.c */,
-				F96D444808F272B9004A47F5 /* pkgd.c */,
-				F96D444908F272B9004A47F5 /* pkge.c */,
-				F96D444B08F272B9004A47F5 /* pkgua.c */,
-				F96D444C08F272B9004A47F5 /* README */,
-			);
-			path = dltest;
-			sourceTree = "<group>";
-		};
-		F96D446E08F272B9004A47F5 /* win */ = {
-			isa = PBXGroup;
-			children = (
-				F96D447008F272BA004A47F5 /* aclocal.m4 */,
-				F96D447108F272BA004A47F5 /* buildall.vc.bat */,
-				F96D447208F272BA004A47F5 /* cat.c */,
-				F96D447408F272BA004A47F5 /* configure */,
-				F96D447508F272BA004A47F5 /* configure.ac */,
-				F96D447708F272BA004A47F5 /* Makefile.in */,
-				F96D447808F272BA004A47F5 /* makefile.vc */,
-				F96D447908F272BA004A47F5 /* nmakehlp.c */,
-				F96D447A08F272BA004A47F5 /* README */,
-				F96D447C08F272BA004A47F5 /* rules.vc */,
-				F96D447D08F272BA004A47F5 /* stub16.c */,
-				F96D447E08F272BA004A47F5 /* tcl.dsp */,
-				F96D447F08F272BA004A47F5 /* tcl.dsw */,
-				F96D448008F272BA004A47F5 /* tcl.hpj.in */,
-				F96D448108F272BA004A47F5 /* tcl.m4 */,
-				F96D448208F272BA004A47F5 /* tcl.rc */,
-				F96D448308F272BA004A47F5 /* tclAppInit.c */,
-				F96D448408F272BA004A47F5 /* tclConfig.sh.in */,
-				F96D448608F272BA004A47F5 /* tclsh.rc */,
-				F96D448708F272BA004A47F5 /* tclWin32Dll.c */,
-				F96D448808F272BA004A47F5 /* tclWinChan.c */,
-				F96D448908F272BA004A47F5 /* tclWinConsole.c */,
-				F96D448A08F272BA004A47F5 /* tclWinDde.c */,
-				F96D448B08F272BA004A47F5 /* tclWinError.c */,
-				F96D448C08F272BA004A47F5 /* tclWinFCmd.c */,
-				F96D448D08F272BA004A47F5 /* tclWinFile.c */,
-				F96D448E08F272BA004A47F5 /* tclWinInit.c */,
-				F96D448F08F272BA004A47F5 /* tclWinInt.h */,
-				F96D449008F272BA004A47F5 /* tclWinLoad.c */,
-				F96D449108F272BA004A47F5 /* tclWinNotify.c */,
-				F96D449208F272BA004A47F5 /* tclWinPipe.c */,
-				F96D449308F272BA004A47F5 /* tclWinPort.h */,
-				F96D449408F272BA004A47F5 /* tclWinReg.c */,
-				F96D449508F272BA004A47F5 /* tclWinSerial.c */,
-				F96D449608F272BA004A47F5 /* tclWinSock.c */,
-				F96D449708F272BA004A47F5 /* tclWinTest.c */,
-				F96D449808F272BA004A47F5 /* tclWinThrd.c */,
-				F96D449908F272BA004A47F5 /* tclWinThrd.h */,
-				F96D449A08F272BA004A47F5 /* tclWinTime.c */,
-			);
-			path = win;
-			sourceTree = "<group>";
-		};
-		F9ECB1110B26521500A28025 /* platform */ = {
-			isa = PBXGroup;
-			children = (
-				F9ECB1120B26521500A28025 /* pkgIndex.tcl */,
-				F9ECB1130B26521500A28025 /* platform.tcl */,
-				F9ECB1140B26521500A28025 /* shell.tcl */,
-			);
-			path = platform;
-			sourceTree = "<group>";
-		};
-/* End PBXGroup section */
-
-/* Begin PBXNativeTarget section */
-		8DD76FA90486AB0100D96B5E /* tktest */ = {
-			isa = PBXNativeTarget;
-			buildConfigurationList = F95CC8B009158F3100EA5ACE /* Build configuration list for PBXNativeTarget "tktest" */;
-			buildPhases = (
-				F9A5C5F508F651A2008AE941 /* Configure Tcl */,
-				F9A5C5F608F651AB008AE941 /* Configure Tk */,
-				8DD76FAB0486AB0100D96B5E /* Sources */,
-				8DD76FAD0486AB0100D96B5E /* Frameworks */,
-			);
-			buildRules = (
-			);
-			dependencies = (
-			);
-			name = tktest;
-			productInstallPath = "$(BINDIR)";
-			productName = tktest;
-			productReference = 8DD76FB20486AB0100D96B5E /* tktest */;
-			productType = "com.apple.product-type.tool";
-		};
-		F97258A50A86873C00096C78 /* tktest-X11 */ = {
-			isa = PBXNativeTarget;
-			buildConfigurationList = F97258A80A86873D00096C78 /* Build configuration list for PBXNativeTarget "tktest-X11" */;
-			buildPhases = (
-				F9FD30B40CC1AD070073837D /* Configure Tcl */,
-				F9FD30B50CC1AD070073837D /* Configure Tk */,
-				F9FD30BB0CC1AD070073837D /* Sources */,
-				F9FD31E30CC1AD070073837D /* Frameworks */,
-			);
-			buildRules = (
-			);
-			dependencies = (
-			);
-			name = "tktest-X11";
-			productInstallPath = "$(BINDIR)";
-			productName = tktest;
-			productReference = F9FD31F40CC1AD070073837D /* tktest-X11 */;
-			productType = "com.apple.product-type.tool";
-		};
-		F9E61D16090A3E94002B3151 /* Tk */ = {
-			isa = PBXNativeTarget;
-			buildConfigurationList = F95CC8AB09158F3100EA5ACE /* Build configuration list for PBXNativeTarget "Tk" */;
-			buildPhases = (
-				F97AF02F0B665DA900310EA2 /* Build Tk */,
-			);
-			buildRules = (
-			);
-			dependencies = (
-			);
-			name = Tk;
-			productName = Wish;
-			productReference = F9A3084B08F2D4CE00BAE1AB /* Wish.app */;
-			productType = "com.apple.product-type.application";
-		};
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
-		08FB7793FE84155DC02AAC07 /* Project object */ = {
-			isa = PBXProject;
-			attributes = {
-				BuildIndependentTargetsInParallel = YES;
-			};
-			buildConfigurationList = F95CC8B509158F3100EA5ACE /* Build configuration list for PBXProject "Tk" */;
-			compatibilityVersion = "Xcode 3.1";
-			hasScannedForEncodings = 1;
-			mainGroup = 08FB7794FE84155DC02AAC07 /* Tk */;
-			projectDirPath = "";
-			projectRoot = ..;
-			targets = (
-				F9E61D16090A3E94002B3151 /* Tk */,
-				8DD76FA90486AB0100D96B5E /* tktest */,
-				F97258A50A86873C00096C78 /* tktest-X11 */,
-			);
-		};
-/* End PBXProject section */
-
-/* Begin PBXShellScriptBuildPhase section */
-		F97AF02F0B665DA900310EA2 /* Build Tk */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputPaths = (
-				"${TARGET_TEMP_DIR}/.none",
-			);
-			name = "Build Tk";
-			outputPaths = (
-				"${TARGET_BUILD_DIR}/${WRAPPER_NAME}",
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/bash;
-			shellScript = "export CC=$(xcrun -find ${GCC} || echo ${GCC}); export LD=${CC}\ngnumake -C \"${TK_SRCROOT}/macosx\"  -j \"$(sysctl -n hw.activecpu)\" \"$(echo \"${ACTION}\" | sed -e s/build// -e s/clean/distclean/ -e s/..\\*/\\&-/)${MAKE_TARGET}\" CFLAGS_WARNING=\"${WARNING_CFLAGS}\" CFLAGS_OPTIMIZE=\"-O${GCC_OPTIMIZATION_LEVEL}\" SYMROOT=\"${BUILT_PRODUCTS_DIR}\" OBJ_DIR=\"${OBJECT_FILE_DIR}\" INSTALL_ROOT=\"${DSTROOT}\" PREFIX=\"${PREFIX}\" BINDIR=\"${BINDIR}\" LIBDIR=\"${FRAMEWORK_INSTALL_PATH}\" MANDIR=\"${MANDIR}\" EXTRA_CONFIGURE_ARGS=\"${CONFIGURE_ARGS}\" APPLICATION_INSTALL_PATH=\"${APPLICATION_INSTALL_PATH}\" TCL_BUILD_DIR=\"${TCL_BUILD_DIR}\" TCL_FRAMEWORK_DIR=\"${TCL_FRAMEWORK_DIR}\" ${EXTRA_MAKE_FLAGS}\nresult=$?\nif [ -e \"${BUILT_PRODUCTS_DIR}/tktest\" ]; then\n\trm -f \"${BUILT_PRODUCTS_DIR}/tktest\"\nfi\necho \"Done\"\nrm -f \"${SCRIPT_INPUT_FILE_0}\"\nexit ${result}\n";
-			showEnvVarsInLog = 0;
-		};
-		F9A5C5F508F651A2008AE941 /* Configure Tcl */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputPaths = (
-				"$(TCL_SRCROOT)/macosx/configure.ac",
-				"$(TCL_SRCROOT)/unix/configure.ac",
-				"$(TCL_SRCROOT)/unix/tcl.m4",
-				"$(TCL_SRCROOT)/unix/aclocal.m4",
-				"$(TCL_SRCROOT)/unix/tclConfig.sh.in",
-				"$(TCL_SRCROOT)/unix/Makefile.in",
-				"$(TCL_SRCROOT)/unix/dltest/Makefile.in",
-			);
-			name = "Configure Tcl";
-			outputPaths = (
-				"$(DERIVED_FILE_DIR)/tcl/tclConfig.sh",
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/bash;
-			shellScript = "## tcl configure shell script phase\n\ncd \"${TCL_SRCROOT}\"/macosx &&\nif [ configure.ac -nt configure -o ../unix/configure.ac -nt configure -o ../unix/tcl.m4 -nt configure -o ../unix/aclocal.m4 -nt configure ]; then\n    echo \"Running autoconf & autoheader in tcl/macosx\"\n    rm -rf autom4te.cache\n    ${AUTOCONF:-${DEVELOPER_DIR}/usr/bin/autoconf} && ${AUTOHEADER:-${DEVELOPER_DIR}/usr/bin/autoheader} || exit $?\n    rm -rf autom4te.cache\nfi\n\ncd \"${DERIVED_FILE_DIR}\" && mkdir -p tcl && cd tcl &&\nif [ \"${TCL_SRCROOT}\"/macosx/configure -nt config.status ]; then\n    echo \"Configuring Tcl\"\n    CC=$(xcrun -find ${GCC} || echo ${GCC})\n    \"${TCL_SRCROOT}\"/macosx/configure --cache-file=../config.cache --prefix=${PREFIX} --bindir=${BINDIR} --libdir=${LIBDIR} --mandir=${MANDIR} --includedir=${INCLUDEDIR} --disable-shared CC=${CC} LD=${CC} ${CONFIGURE_ARGS}\nelse\n    ./config.status\nfi\n";
-			showEnvVarsInLog = 0;
-		};
-		F9A5C5F608F651AB008AE941 /* Configure Tk */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputPaths = (
-				"$(TK_SRCROOT)/macosx/configure.ac",
-				"$(TK_SRCROOT)/unix/configure.ac",
-				"$(TK_SRCROOT)/unix/tcl.m4",
-				"$(TK_SRCROOT)/unix/aclocal.m4",
-				"$(TK_SRCROOT)/unix/tkConfig.sh.in",
-			);
-			name = "Configure Tk";
-			outputPaths = (
-				"$(DERIVED_FILE_DIR)/tk/tkConfig.sh",
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/bash;
-			shellScript = "## tk configure shell script phase\n\ncd \"${TK_SRCROOT}\"/macosx &&\nif [ configure.ac -nt configure -o ../unix/configure.ac -nt configure -o ../unix/tcl.m4 -nt configure -o ../unix/aclocal.m4 -nt configure ]; then\n    echo \"Running autoconf & autoheader in tk/macosx\"\n    rm -rf autom4te.cache\n    ${AUTOCONF:-${DEVELOPER_DIR}/usr/bin/autoconf} && ${AUTOHEADER:-${DEVELOPER_DIR}/usr/bin/autoheader} || exit $?\n    rm -rf autom4te.cache\nfi\n\ncd \"${DERIVED_FILE_DIR}\" && mkdir -p tk && cd tk &&\nif [ \"${TK_SRCROOT}\"/macosx/configure -nt config.status ]; then\n    echo \"Configuring Tk\"\n    CC=$(xcrun -find ${GCC} || echo ${GCC})\n    \"${TK_SRCROOT}\"/macosx/configure --cache-file=../config.cache --prefix=${PREFIX} --bindir=${BINDIR} --libdir=${LIBDIR} --mandir=${MANDIR} --includedir=${INCLUDEDIR} --disable-shared --enable-aqua --with-tcl=../tcl CC=${CC} LD=${CC} ${CONFIGURE_ARGS}\nelse\n    ./config.status\nfi\n";
-			showEnvVarsInLog = 0;
-		};
-		F9FD30B40CC1AD070073837D /* Configure Tcl */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputPaths = (
-				"$(TCL_SRCROOT)/macosx/configure.ac",
-				"$(TCL_SRCROOT)/unix/configure.ac",
-				"$(TCL_SRCROOT)/unix/tcl.m4",
-				"$(TCL_SRCROOT)/unix/aclocal.m4",
-				"$(TCL_SRCROOT)/unix/tclConfig.sh.in",
-				"$(TCL_SRCROOT)/unix/Makefile.in",
-				"$(TCL_SRCROOT)/unix/dltest/Makefile.in",
-			);
-			name = "Configure Tcl";
-			outputPaths = (
-				"$(DERIVED_FILE_DIR)/tcl/tclConfig.sh",
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/bash;
-			shellScript = "## tcl configure shell script phase\n\ncd \"${TCL_SRCROOT}\"/macosx &&\nif [ configure.ac -nt configure -o ../unix/configure.ac -nt configure -o ../unix/tcl.m4 -nt configure -o ../unix/aclocal.m4 -nt configure ]; then\n    echo \"Running autoconf & autoheader in tcl/macosx\"\n    rm -rf autom4te.cache\n    ${AUTOCONF:-${DEVELOPER_DIR}/usr/bin/autoconf} && ${AUTOHEADER:-${DEVELOPER_DIR}/usr/bin/autoheader} || exit $?\n    rm -rf autom4te.cache\nfi\n\ncd \"${DERIVED_FILE_DIR}\" && mkdir -p tcl && cd tcl &&\nif [ \"${TCL_SRCROOT}\"/macosx/configure -nt config.status ]; then\n    echo \"Configuring Tcl\"\n    CC=$(xcrun -find ${GCC} || echo ${GCC})\n    \"${TCL_SRCROOT}\"/macosx/configure --cache-file=../config.cache --prefix=${PREFIX} --bindir=${BINDIR} --libdir=${LIBDIR} --mandir=${MANDIR} --includedir=${INCLUDEDIR} --disable-shared CC=${CC} LD=${CC} ${CONFIGURE_ARGS}\nelse\n    ./config.status\nfi\n";
-			showEnvVarsInLog = 0;
-		};
-		F9FD30B50CC1AD070073837D /* Configure Tk */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputPaths = (
-				"$(TK_SRCROOT)/macosx/configure.ac",
-				"$(TK_SRCROOT)/unix/configure.ac",
-				"$(TK_SRCROOT)/unix/tcl.m4",
-				"$(TK_SRCROOT)/unix/aclocal.m4",
-				"$(TK_SRCROOT)/unix/tkConfig.sh.in",
-			);
-			name = "Configure Tk";
-			outputPaths = (
-				"$(DERIVED_FILE_DIR)/tk/tkConfig.sh",
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/bash;
-			shellScript = "## tk configure shell script phase\n\ncd \"${TK_SRCROOT}\"/macosx &&\nif [ configure.ac -nt configure -o ../unix/configure.ac -nt configure -o ../unix/tcl.m4 -nt configure -o ../unix/aclocal.m4 -nt configure ]; then\n    echo \"Running autoconf & autoheader in tk/macosx\"\n    rm -rf autom4te.cache\n    ${AUTOCONF:-${DEVELOPER_DIR}/usr/bin/autoconf} && ${AUTOHEADER:-${DEVELOPER_DIR}/usr/bin/autoheader} || exit $?\n    rm -rf autom4te.cache\nfi\n\ncd \"${DERIVED_FILE_DIR}\" && mkdir -p tk && cd tk &&\nif [ \"${TK_SRCROOT}\"/macosx/configure -nt config.status ]; then\n    echo \"Configuring Tk\"\n    CC=$(xcrun -find ${GCC} || echo ${GCC})\n    PATH=\"${PATH}:/usr/X11R6/bin\" \"${TK_SRCROOT}\"/macosx/configure --cache-file=../config.cache --prefix=${PREFIX} --bindir=${BINDIR} --libdir=${LIBDIR} --mandir=${MANDIR} --includedir=${INCLUDEDIR} --disable-shared --enable-xft --with-tcl=../tcl CC=${CC} LD=${CC} ${CONFIGURE_ARGS}\nelse\n    ./config.status\nfi";
-			showEnvVarsInLog = 0;
-		};
-/* End PBXShellScriptBuildPhase section */
-
-/* Begin PBXSourcesBuildPhase section */
-		8DD76FAB0486AB0100D96B5E /* Sources */ = {
-			isa = PBXSourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				F96D456F08F272BB004A47F5 /* regcomp.c in Sources */,
-				F96D457208F272BB004A47F5 /* regerror.c in Sources */,
-				F96D457508F272BB004A47F5 /* regexec.c in Sources */,
-				F96D457608F272BB004A47F5 /* regfree.c in Sources */,
-				F96D457B08F272BB004A47F5 /* tclAlloc.c in Sources */,
-				F96D457C08F272BB004A47F5 /* tclAsync.c in Sources */,
-				F96D457D08F272BB004A47F5 /* tclBasic.c in Sources */,
-				F96D457E08F272BC004A47F5 /* tclBinary.c in Sources */,
-				F96D457F08F272BC004A47F5 /* tclCkalloc.c in Sources */,
-				F96D458008F272BC004A47F5 /* tclClock.c in Sources */,
-				F96D458108F272BC004A47F5 /* tclCmdAH.c in Sources */,
-				F96D458208F272BC004A47F5 /* tclCmdIL.c in Sources */,
-				F96D458308F272BC004A47F5 /* tclCmdMZ.c in Sources */,
-				F96D458408F272BC004A47F5 /* tclCompCmds.c in Sources */,
-				F96D458508F272BC004A47F5 /* tclCompExpr.c in Sources */,
-				F96D458608F272BC004A47F5 /* tclCompile.c in Sources */,
-				F96D458808F272BC004A47F5 /* tclConfig.c in Sources */,
-				F96D458908F272BC004A47F5 /* tclDate.c in Sources */,
-				F96D458B08F272BC004A47F5 /* tclDictObj.c in Sources */,
-				F96D458C08F272BC004A47F5 /* tclEncoding.c in Sources */,
-				F96D458D08F272BC004A47F5 /* tclEnv.c in Sources */,
-				F96D458E08F272BC004A47F5 /* tclEvent.c in Sources */,
-				F96D458F08F272BC004A47F5 /* tclExecute.c in Sources */,
-				F96D459008F272BC004A47F5 /* tclFCmd.c in Sources */,
-				F96D459108F272BC004A47F5 /* tclFileName.c in Sources */,
-				F96D459308F272BC004A47F5 /* tclGet.c in Sources */,
-				F96D459508F272BC004A47F5 /* tclHash.c in Sources */,
-				F96D459608F272BC004A47F5 /* tclHistory.c in Sources */,
-				F96D459708F272BC004A47F5 /* tclIndexObj.c in Sources */,
-				F96D459B08F272BC004A47F5 /* tclInterp.c in Sources */,
-				F96D459D08F272BC004A47F5 /* tclIO.c in Sources */,
-				F96D459F08F272BC004A47F5 /* tclIOCmd.c in Sources */,
-				F96D45A008F272BC004A47F5 /* tclIOGT.c in Sources */,
-				F96D45A108F272BC004A47F5 /* tclIORChan.c in Sources */,
-				F95D77EA0DFD820D00A8BF6F /* tclIORTrans.c in Sources */,
-				F96D45A208F272BC004A47F5 /* tclIOSock.c in Sources */,
-				F96D45A308F272BC004A47F5 /* tclIOUtil.c in Sources */,
-				F96D45A408F272BC004A47F5 /* tclLink.c in Sources */,
-				F96D45A508F272BC004A47F5 /* tclListObj.c in Sources */,
-				F96D45A608F272BC004A47F5 /* tclLiteral.c in Sources */,
-				F96D45A708F272BC004A47F5 /* tclLoad.c in Sources */,
-				F96D45A908F272BC004A47F5 /* tclMain.c in Sources */,
-				F96D45AA08F272BC004A47F5 /* tclNamesp.c in Sources */,
-				F96D45AB08F272BC004A47F5 /* tclNotify.c in Sources */,
-				F96D45AC08F272BC004A47F5 /* tclObj.c in Sources */,
-				F93599B30DF1F75400E04F67 /* tclOO.c in Sources */,
-				F93599B70DF1F76100E04F67 /* tclOOBasic.c in Sources */,
-				F93599B90DF1F76600E04F67 /* tclOOCall.c in Sources */,
-				F93599BC0DF1F77000E04F67 /* tclOODefineCmds.c in Sources */,
-				F93599BE0DF1F77400E04F67 /* tclOOInfo.c in Sources */,
-				F93599C20DF1F78300E04F67 /* tclOOMethod.c in Sources */,
-				F93599C40DF1F78800E04F67 /* tclOOStubInit.c in Sources */,
-				F93599C60DF1F78D00E04F67 /* tclOOStubLib.c in Sources */,
-				F96D45AD08F272BC004A47F5 /* tclPanic.c in Sources */,
-				F96D45AE08F272BC004A47F5 /* tclParse.c in Sources */,
-				F96D45B008F272BC004A47F5 /* tclPathObj.c in Sources */,
-				F96D45B108F272BC004A47F5 /* tclPipe.c in Sources */,
-				F96D45B208F272BC004A47F5 /* tclPkg.c in Sources */,
-				F96D45B308F272BC004A47F5 /* tclPkgConfig.c in Sources */,
-				F96D45B608F272BC004A47F5 /* tclPosixStr.c in Sources */,
-				F96D45B708F272BC004A47F5 /* tclPreserve.c in Sources */,
-				F96D45B808F272BC004A47F5 /* tclProc.c in Sources */,
-				F96D45B908F272BC004A47F5 /* tclRegexp.c in Sources */,
-				F96D45BB08F272BC004A47F5 /* tclResolve.c in Sources */,
-				F96D45BC08F272BC004A47F5 /* tclResult.c in Sources */,
-				F96D45BD08F272BC004A47F5 /* tclScan.c in Sources */,
-				F96D45BE08F272BC004A47F5 /* tclStringObj.c in Sources */,
-				F96D45C308F272BC004A47F5 /* tclStrToD.c in Sources */,
-				F96D45C408F272BC004A47F5 /* tclStubInit.c in Sources */,
-				F96D45C508F272BC004A47F5 /* tclStubLib.c in Sources */,
-				F96D45C908F272BC004A47F5 /* tclThread.c in Sources */,
-				F96D45CA08F272BC004A47F5 /* tclThreadAlloc.c in Sources */,
-				F96D45CB08F272BC004A47F5 /* tclThreadJoin.c in Sources */,
-				F96D45CC08F272BC004A47F5 /* tclThreadStorage.c in Sources */,
-				F96D45CE08F272BC004A47F5 /* tclTimer.c in Sources */,
-				F96D45D008F272BC004A47F5 /* tclTomMathInterface.c in Sources */,
-				F96D45D108F272BC004A47F5 /* tclTrace.c in Sources */,
-				F96D45D308F272BC004A47F5 /* tclUtf.c in Sources */,
-				F96D45D408F272BC004A47F5 /* tclUtil.c in Sources */,
-				F96D45D508F272BC004A47F5 /* tclVar.c in Sources */,
-				F96437CA0EF0D4B2003F468E /* tclZlib.c in Sources */,
-				F96D48E208F272C3004A47F5 /* bn_fast_s_mp_mul_digs.c in Sources */,
-				F96D48E408F272C3004A47F5 /* bn_fast_s_mp_sqr.c in Sources */,
-				F96D48E708F272C3004A47F5 /* bn_mp_add.c in Sources */,
-				F96D48E808F272C3004A47F5 /* bn_mp_add_d.c in Sources */,
-				F9E61D2B090A48A4002B3151 /* bn_mp_and.c in Sources */,
-				F96D48EB08F272C3004A47F5 /* bn_mp_clamp.c in Sources */,
-				F96D48EC08F272C3004A47F5 /* bn_mp_clear.c in Sources */,
-				F96D48ED08F272C3004A47F5 /* bn_mp_clear_multi.c in Sources */,
-				F96D48EE08F272C3004A47F5 /* bn_mp_cmp.c in Sources */,
-				F9E61D28090A481F002B3151 /* bn_mp_cmp_d.c in Sources */,
-				F96D48F008F272C3004A47F5 /* bn_mp_cmp_mag.c in Sources */,
-				F96D48F208F272C3004A47F5 /* bn_mp_copy.c in Sources */,
-				F96D48F308F272C3004A47F5 /* bn_mp_count_bits.c in Sources */,
-				F96D48F408F272C3004A47F5 /* bn_mp_div.c in Sources */,
-				F96D48F508F272C3004A47F5 /* bn_mp_div_2.c in Sources */,
-				F96D48F608F272C3004A47F5 /* bn_mp_div_2d.c in Sources */,
-				F96D48F708F272C3004A47F5 /* bn_mp_div_3.c in Sources */,
-				F96D48F808F272C3004A47F5 /* bn_mp_div_d.c in Sources */,
-				F96D48FC08F272C3004A47F5 /* bn_mp_exch.c in Sources */,
-				F9E61D2C090A48AC002B3151 /* bn_mp_expt_d.c in Sources */,
-				F96D490508F272C3004A47F5 /* bn_mp_grow.c in Sources */,
-				F96D490608F272C3004A47F5 /* bn_mp_init.c in Sources */,
-				F96D490708F272C3004A47F5 /* bn_mp_init_copy.c in Sources */,
-				F96D490808F272C3004A47F5 /* bn_mp_init_multi.c in Sources */,
-				F96D490908F272C3004A47F5 /* bn_mp_init_set.c in Sources */,
-				F96D490B08F272C3004A47F5 /* bn_mp_init_size.c in Sources */,
-				F96D491008F272C3004A47F5 /* bn_mp_karatsuba_mul.c in Sources */,
-				F96D491108F272C3004A47F5 /* bn_mp_karatsuba_sqr.c in Sources */,
-				F96D491308F272C3004A47F5 /* bn_mp_lshd.c in Sources */,
-				F96D491408F272C3004A47F5 /* bn_mp_mod.c in Sources */,
-				F96D491508F272C3004A47F5 /* bn_mp_mod_2d.c in Sources */,
-				F96D491A08F272C3004A47F5 /* bn_mp_mul.c in Sources */,
-				F96D491B08F272C3004A47F5 /* bn_mp_mul_2.c in Sources */,
-				F96D491C08F272C3004A47F5 /* bn_mp_mul_2d.c in Sources */,
-				F96D491D08F272C3004A47F5 /* bn_mp_mul_d.c in Sources */,
-				F9E61D29090A486C002B3151 /* bn_mp_neg.c in Sources */,
-				F9E61D2E090A48BF002B3151 /* bn_mp_or.c in Sources */,
-				F96D492908F272C3004A47F5 /* bn_mp_radix_size.c in Sources */,
-				F96D492A08F272C3004A47F5 /* bn_mp_radix_smap.c in Sources */,
-				F96D492C08F272C3004A47F5 /* bn_mp_read_radix.c in Sources */,
-				F96D493708F272C3004A47F5 /* bn_mp_rshd.c in Sources */,
-				F96D493808F272C3004A47F5 /* bn_mp_set.c in Sources */,
-				F9E61D2F090A48C7002B3151 /* bn_mp_shrink.c in Sources */,
-				F96D493C08F272C3004A47F5 /* bn_mp_sqr.c in Sources */,
-				F9E61D2A090A4891002B3151 /* bn_mp_sqrt.c in Sources */,
-				F96D493F08F272C3004A47F5 /* bn_mp_sub.c in Sources */,
-				F96D494008F272C3004A47F5 /* bn_mp_sub_d.c in Sources */,
-				F9E61D30090A48E2002B3151 /* bn_mp_to_unsigned_bin_n.c in Sources */,
-				F9E61D31090A48F9002B3151 /* bn_mp_to_unsigned_bin.c in Sources */,
-				F96D494608F272C3004A47F5 /* bn_mp_toom_mul.c in Sources */,
-				F96D494708F272C3004A47F5 /* bn_mp_toom_sqr.c in Sources */,
-				F96D494908F272C3004A47F5 /* bn_mp_toradix_n.c in Sources */,
-				F9E61D32090A48FA002B3151 /* bn_mp_unsigned_bin_size.c in Sources */,
-				F9E61D2D090A48BB002B3151 /* bn_mp_xor.c in Sources */,
-				F96D494C08F272C3004A47F5 /* bn_mp_zero.c in Sources */,
-				F96D494E08F272C3004A47F5 /* bn_reverse.c in Sources */,
-				F96D494F08F272C3004A47F5 /* bn_s_mp_add.c in Sources */,
-				F96D495108F272C3004A47F5 /* bn_s_mp_mul_digs.c in Sources */,
-				F96D495308F272C3004A47F5 /* bn_s_mp_sqr.c in Sources */,
-				F96D495408F272C3004A47F5 /* bn_s_mp_sub.c in Sources */,
-				F96D495508F272C3004A47F5 /* bncore.c in Sources */,
-				F96D49A908F272C4004A47F5 /* tclMacOSXBundle.c in Sources */,
-				F96D49AD08F272C4004A47F5 /* tclMacOSXFCmd.c in Sources */,
-				F96D49AE08F272C4004A47F5 /* tclMacOSXNotify.c in Sources */,
-				F96D4AC608F272C9004A47F5 /* tclLoadDyld.c in Sources */,
-				F96D4ACA08F272C9004A47F5 /* tclUnixChan.c in Sources */,
-				F9FC77B80AB29E9100B7077D /* tclUnixCompat.c in Sources */,
-				F96D4ACB08F272C9004A47F5 /* tclUnixEvent.c in Sources */,
-				F96D4ACC08F272C9004A47F5 /* tclUnixFCmd.c in Sources */,
-				F96D4ACD08F272C9004A47F5 /* tclUnixFile.c in Sources */,
-				F96D4ACE08F272C9004A47F5 /* tclUnixInit.c in Sources */,
-				F96D4ACF08F272C9004A47F5 /* tclUnixNotfy.c in Sources */,
-				F96D4AD008F272C9004A47F5 /* tclUnixPipe.c in Sources */,
-				F96D4AD208F272CA004A47F5 /* tclUnixSock.c in Sources */,
-				F96D4AD408F272CA004A47F5 /* tclUnixThrd.c in Sources */,
-				F96D4AD608F272CA004A47F5 /* tclUnixTime.c in Sources */,
-				F9F4415E0C8BAE6F00BCCD67 /* tclDTrace.d in Sources */,
-				F966BDCF08F27A3F005CB29B /* tk3d.c in Sources */,
-				F966BDD108F27A3F005CB29B /* tkArgv.c in Sources */,
-				F966BDD208F27A3F005CB29B /* tkAtom.c in Sources */,
-				F966BDD308F27A3F005CB29B /* tkBind.c in Sources */,
-				F966BDD408F27A3F005CB29B /* tkBitmap.c in Sources */,
-				F9152B090EAF8A5000CD5C7B /* tkBusy.c in Sources */,
-				F966BDD508F27A3F005CB29B /* tkButton.c in Sources */,
-				F966BDD708F27A3F005CB29B /* tkCanvArc.c in Sources */,
-				F966BDD808F27A3F005CB29B /* tkCanvas.c in Sources */,
-				F966BDDA08F27A3F005CB29B /* tkCanvBmap.c in Sources */,
-				F966BDDB08F27A3F005CB29B /* tkCanvImg.c in Sources */,
-				F966BDDC08F27A3F005CB29B /* tkCanvLine.c in Sources */,
-				F966BDDD08F27A3F005CB29B /* tkCanvPoly.c in Sources */,
-				F966BDDE08F27A3F005CB29B /* tkCanvPs.c in Sources */,
-				F966BDE008F27A3F005CB29B /* tkCanvText.c in Sources */,
-				F966BDE108F27A3F005CB29B /* tkCanvUtil.c in Sources */,
-				F966BDE208F27A3F005CB29B /* tkCanvWind.c in Sources */,
-				F966BDE308F27A3F005CB29B /* tkClipboard.c in Sources */,
-				F966BDE408F27A3F005CB29B /* tkCmds.c in Sources */,
-				F966BDE508F27A3F005CB29B /* tkColor.c in Sources */,
-				F966BDE708F27A3F005CB29B /* tkConfig.c in Sources */,
-				F966BDE808F27A3F005CB29B /* tkConsole.c in Sources */,
-				F966BDE908F27A3F005CB29B /* tkCursor.c in Sources */,
-				F966BDEB08F27A3F005CB29B /* tkEntry.c in Sources */,
-				F966BDED08F27A3F005CB29B /* tkError.c in Sources */,
-				F966BDEE08F27A3F005CB29B /* tkEvent.c in Sources */,
-				F966BDEF08F27A3F005CB29B /* tkFileFilter.c in Sources */,
-				F966BDF108F27A3F005CB29B /* tkFocus.c in Sources */,
-				F966BDF208F27A3F005CB29B /* tkFont.c in Sources */,
-				F966BDF408F27A3F005CB29B /* tkFrame.c in Sources */,
-				F966BDF508F27A3F005CB29B /* tkGC.c in Sources */,
-				F966BDF608F27A3F005CB29B /* tkGeometry.c in Sources */,
-				F966BDF708F27A3F005CB29B /* tkGet.c in Sources */,
-				F966BDF808F27A3F005CB29B /* tkGrab.c in Sources */,
-				F966BDF908F27A3F005CB29B /* tkGrid.c in Sources */,
-				F966BDFA08F27A3F005CB29B /* tkImage.c in Sources */,
-				F966BDFB08F27A3F005CB29B /* tkImgBmap.c in Sources */,
-				F966BDFC08F27A3F005CB29B /* tkImgGIF.c in Sources */,
-				F92EE8BF0E62F846001A6E80 /* tkImgPhInstance.c in Sources */,
-				F966BDFD08F27A3F005CB29B /* tkImgPhoto.c in Sources */,
-				F9DD99BD0F07DF850018B2E4 /* tkImgPNG.c in Sources */,
-				F966BDFE08F27A3F005CB29B /* tkImgPPM.c in Sources */,
-				F966BE0708F27A3F005CB29B /* tkListbox.c in Sources */,
-				F966BE0808F27A3F005CB29B /* tkMacWinMenu.c in Sources */,
-				F966BE0908F27A3F005CB29B /* tkMain.c in Sources */,
-				F966BE0A08F27A3F005CB29B /* tkMenu.c in Sources */,
-				F966BE0C08F27A3F005CB29B /* tkMenubutton.c in Sources */,
-				F966BE0E08F27A3F005CB29B /* tkMenuDraw.c in Sources */,
-				F966BE0F08F27A3F005CB29B /* tkMessage.c in Sources */,
-				F966BE1008F27A3F005CB29B /* tkObj.c in Sources */,
-				F966BE1108F27A3F005CB29B /* tkOldConfig.c in Sources */,
-				F9067BCD0BFBA2900074F726 /* tkOldTest.c in Sources */,
-				F966BE1208F27A3F005CB29B /* tkOption.c in Sources */,
-				F966BE1308F27A3F005CB29B /* tkPack.c in Sources */,
-				F966BE1408F27A3F005CB29B /* tkPanedWindow.c in Sources */,
-				F966BE1508F27A3F005CB29B /* tkPlace.c in Sources */,
-				F966BE1708F27A3F005CB29B /* tkPointer.c in Sources */,
-				F966BE1908F27A3F005CB29B /* tkRectOval.c in Sources */,
-				F966BE1A08F27A3F005CB29B /* tkScale.c in Sources */,
-				F966BE1C08F27A40005CB29B /* tkScrollbar.c in Sources */,
-				F966BE1E08F27A40005CB29B /* tkSelect.c in Sources */,
-				F966BE2008F27A40005CB29B /* tkSquare.c in Sources */,
-				F966BE2208F27A40005CB29B /* tkStubInit.c in Sources */,
-				F966BE2308F27A40005CB29B /* tkStubLib.c in Sources */,
-				F966BE2408F27A40005CB29B /* tkStyle.c in Sources */,
-				F966BE2508F27A40005CB29B /* tkTest.c in Sources */,
-				F966BE2608F27A40005CB29B /* tkText.c in Sources */,
-				F966BE2808F27A40005CB29B /* tkTextBTree.c in Sources */,
-				F966BE2908F27A40005CB29B /* tkTextDisp.c in Sources */,
-				F966BE2B08F27A40005CB29B /* tkTextImage.c in Sources */,
-				F966BE2C08F27A40005CB29B /* tkTextIndex.c in Sources */,
-				F966BE2D08F27A40005CB29B /* tkTextMark.c in Sources */,
-				F966BE2E08F27A40005CB29B /* tkTextTag.c in Sources */,
-				F966BE2F08F27A40005CB29B /* tkTextWind.c in Sources */,
-				F966BE3008F27A40005CB29B /* tkTrig.c in Sources */,
-				F966BE3108F27A40005CB29B /* tkUndo.c in Sources */,
-				F966BE3308F27A40005CB29B /* tkUtil.c in Sources */,
-				F966BE3408F27A40005CB29B /* tkVisual.c in Sources */,
-				F966BE3508F27A40005CB29B /* tkWindow.c in Sources */,
-				F96888050AF786D5000797B5 /* ttkBlink.c in Sources */,
-				F96888060AF786D5000797B5 /* ttkButton.c in Sources */,
-				F96888070AF786D5000797B5 /* ttkCache.c in Sources */,
-				F96888080AF786D5000797B5 /* ttkClamTheme.c in Sources */,
-				F96888090AF786D5000797B5 /* ttkClassicTheme.c in Sources */,
-				F968880A0AF786D5000797B5 /* ttkDefaultTheme.c in Sources */,
-				F968880B0AF786D5000797B5 /* ttkElements.c in Sources */,
-				F968880C0AF786D5000797B5 /* ttkEntry.c in Sources */,
-				F968880D0AF786D5000797B5 /* ttkFrame.c in Sources */,
-				F968880E0AF786D5000797B5 /* ttkImage.c in Sources */,
-				F968880F0AF786D5000797B5 /* ttkInit.c in Sources */,
-				F96888100AF786D5000797B5 /* ttkLabel.c in Sources */,
-				F96888110AF786D5000797B5 /* ttkLayout.c in Sources */,
-				F96888120AF786D5000797B5 /* ttkManager.c in Sources */,
-				F96888130AF786D5000797B5 /* ttkNotebook.c in Sources */,
-				F96888140AF786D5000797B5 /* ttkPanedwindow.c in Sources */,
-				F96888150AF786D5000797B5 /* ttkProgress.c in Sources */,
-				F96888160AF786D5000797B5 /* ttkScale.c in Sources */,
-				F96888170AF786D5000797B5 /* ttkScroll.c in Sources */,
-				F96888180AF786D5000797B5 /* ttkScrollbar.c in Sources */,
-				F96888190AF786D5000797B5 /* ttkSeparator.c in Sources */,
-				F968881A0AF786D5000797B5 /* ttkSquare.c in Sources */,
-				F968881B0AF786D5000797B5 /* ttkState.c in Sources */,
-				F968881C0AF786D5000797B5 /* ttkStubInit.c in Sources */,
-				F968881D0AF786D5000797B5 /* ttkStubLib.c in Sources */,
-				F968881E0AF786D5000797B5 /* ttkTagSet.c in Sources */,
-				F968881F0AF786D5000797B5 /* ttkTheme.c in Sources */,
-				F96888200AF786D5000797B5 /* ttkTrace.c in Sources */,
-				F96888210AF786D5000797B5 /* ttkTrack.c in Sources */,
-				F96888220AF786D5000797B5 /* ttkTreeview.c in Sources */,
-				F96888230AF786D5000797B5 /* ttkWidget.c in Sources */,
-				F966BEDB08F27A40005CB29B /* tkMacOSXBitmap.c in Sources */,
-				F966BEDC08F27A40005CB29B /* tkMacOSXButton.c in Sources */,
-				F966BEDE08F27A40005CB29B /* tkMacOSXClipboard.c in Sources */,
-				F966BEDF08F27A40005CB29B /* tkMacOSXColor.c in Sources */,
-				F966BEE008F27A40005CB29B /* tkMacOSXConfig.c in Sources */,
-				F966BEE108F27A40005CB29B /* tkMacOSXCursor.c in Sources */,
-				F966BEE308F27A40005CB29B /* tkMacOSXDebug.c in Sources */,
-				F966BEE608F27A40005CB29B /* tkMacOSXDialog.c in Sources */,
-				F966BEE708F27A40005CB29B /* tkMacOSXDraw.c in Sources */,
-				F966BEE808F27A40005CB29B /* tkMacOSXEmbed.c in Sources */,
-				F966BEE908F27A40005CB29B /* tkMacOSXEntry.c in Sources */,
-				F966BEEA08F27A40005CB29B /* tkMacOSXEvent.c in Sources */,
-				F966BEEC08F27A40005CB29B /* tkMacOSXFont.c in Sources */,
-				F966BEED08F27A40005CB29B /* tkMacOSXHLEvents.c in Sources */,
-				F966BEEE08F27A40005CB29B /* tkMacOSXInit.c in Sources */,
-				F966BEF108F27A40005CB29B /* tkMacOSXKeyboard.c in Sources */,
-				F966BEF208F27A40005CB29B /* tkMacOSXKeyEvent.c in Sources */,
-				F966BEF308F27A40005CB29B /* tkMacOSXMenu.c in Sources */,
-				F966BEF608F27A40005CB29B /* tkMacOSXMenubutton.c in Sources */,
-				F966BEF708F27A40005CB29B /* tkMacOSXMenus.c in Sources */,
-				F966BEF808F27A40005CB29B /* tkMacOSXMouseEvent.c in Sources */,
-				F966BEF908F27A40005CB29B /* tkMacOSXNotify.c in Sources */,
-				F966BF0108F27A40005CB29B /* tkMacOSXRegion.c in Sources */,
-				F966BF0308F27A40005CB29B /* tkMacOSXScrlbr.c in Sources */,
-				F966BF0408F27A40005CB29B /* tkMacOSXSend.c in Sources */,
-				F966BF0508F27A40005CB29B /* tkMacOSXSubwindows.c in Sources */,
-				F966BF0608F27A40005CB29B /* tkMacOSXTest.c in Sources */,
-				F966BF0708F27A40005CB29B /* tkMacOSXWindowEvent.c in Sources */,
-				F966BF0808F27A40005CB29B /* tkMacOSXWm.c in Sources */,
-				F966BF0B08F27A40005CB29B /* tkMacOSXXStubs.c in Sources */,
-				F96888850AF78938000797B5 /* ttkMacOSXTheme.c in Sources */,
-				F966BF7F08F27A41005CB29B /* tkAppInit.c in Sources */,
-				F966BF8308F27A41005CB29B /* tkUnix3d.c in Sources */,
-				F966BF9608F27A41005CB29B /* tkUnixScale.c in Sources */,
-				F966C02A08F27A42005CB29B /* xcolors.c in Sources */,
-				F966C02B08F27A42005CB29B /* xdraw.c in Sources */,
-				F966C02C08F27A42005CB29B /* xgc.c in Sources */,
-				F966C02D08F27A42005CB29B /* ximage.c in Sources */,
-				F966C02E08F27A42005CB29B /* xutil.c in Sources */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		F9FD30BB0CC1AD070073837D /* Sources */ = {
-			isa = PBXSourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				F9FD30BC0CC1AD070073837D /* regcomp.c in Sources */,
-				F9FD30BD0CC1AD070073837D /* regerror.c in Sources */,
-				F9FD30BE0CC1AD070073837D /* regexec.c in Sources */,
-				F9FD30BF0CC1AD070073837D /* regfree.c in Sources */,
-				F9FD30C00CC1AD070073837D /* tclAlloc.c in Sources */,
-				F9FD30C10CC1AD070073837D /* tclAsync.c in Sources */,
-				F9FD30C20CC1AD070073837D /* tclBasic.c in Sources */,
-				F9FD30C30CC1AD070073837D /* tclBinary.c in Sources */,
-				F9FD30C40CC1AD070073837D /* tclCkalloc.c in Sources */,
-				F9FD30C50CC1AD070073837D /* tclClock.c in Sources */,
-				F9FD30C60CC1AD070073837D /* tclCmdAH.c in Sources */,
-				F9FD30C70CC1AD070073837D /* tclCmdIL.c in Sources */,
-				F9FD30C80CC1AD070073837D /* tclCmdMZ.c in Sources */,
-				F9FD30C90CC1AD070073837D /* tclCompCmds.c in Sources */,
-				F9FD30CA0CC1AD070073837D /* tclCompExpr.c in Sources */,
-				F9FD30CB0CC1AD070073837D /* tclCompile.c in Sources */,
-				F9FD30CC0CC1AD070073837D /* tclConfig.c in Sources */,
-				F9FD30CD0CC1AD070073837D /* tclDate.c in Sources */,
-				F9FD30CE0CC1AD070073837D /* tclDictObj.c in Sources */,
-				F9FD30CF0CC1AD070073837D /* tclEncoding.c in Sources */,
-				F9FD30D00CC1AD070073837D /* tclEnv.c in Sources */,
-				F9FD30D10CC1AD070073837D /* tclEvent.c in Sources */,
-				F9FD30D20CC1AD070073837D /* tclExecute.c in Sources */,
-				F9FD30D30CC1AD070073837D /* tclFCmd.c in Sources */,
-				F9FD30D40CC1AD070073837D /* tclFileName.c in Sources */,
-				F9FD30D50CC1AD070073837D /* tclGet.c in Sources */,
-				F9FD30D60CC1AD070073837D /* tclHash.c in Sources */,
-				F9FD30D70CC1AD070073837D /* tclHistory.c in Sources */,
-				F9FD30D80CC1AD070073837D /* tclIndexObj.c in Sources */,
-				F9FD30D90CC1AD070073837D /* tclInterp.c in Sources */,
-				F9FD30DA0CC1AD070073837D /* tclIO.c in Sources */,
-				F9FD30DB0CC1AD070073837D /* tclIOCmd.c in Sources */,
-				F9FD30DC0CC1AD070073837D /* tclIOGT.c in Sources */,
-				F9FD30DD0CC1AD070073837D /* tclIORChan.c in Sources */,
-				F9FFAF1D0DFDDB26007F8A6A /* tclIORTrans.c in Sources */,
-				F9FD30DE0CC1AD070073837D /* tclIOSock.c in Sources */,
-				F9FD30DF0CC1AD070073837D /* tclIOUtil.c in Sources */,
-				F9FD30E00CC1AD070073837D /* tclLink.c in Sources */,
-				F9FD30E10CC1AD070073837D /* tclListObj.c in Sources */,
-				F9FD30E20CC1AD070073837D /* tclLiteral.c in Sources */,
-				F9FD30E30CC1AD070073837D /* tclLoad.c in Sources */,
-				F9FD30E40CC1AD070073837D /* tclMain.c in Sources */,
-				F9FD30E50CC1AD070073837D /* tclNamesp.c in Sources */,
-				F9FD30E60CC1AD070073837D /* tclNotify.c in Sources */,
-				F9FD30E70CC1AD070073837D /* tclObj.c in Sources */,
-				F9FFAF1F0DFDDB2F007F8A6A /* tclOO.c in Sources */,
-				F9FFAF200DFDDB32007F8A6A /* tclOOBasic.c in Sources */,
-				F9FFAF210DFDDB32007F8A6A /* tclOOCall.c in Sources */,
-				F9FFAF220DFDDB34007F8A6A /* tclOODefineCmds.c in Sources */,
-				F9FFAF230DFDDB35007F8A6A /* tclOOInfo.c in Sources */,
-				F9FFAF240DFDDB36007F8A6A /* tclOOMethod.c in Sources */,
-				F9FFAF250DFDDB37007F8A6A /* tclOOStubInit.c in Sources */,
-				F9FFAF260DFDDB38007F8A6A /* tclOOStubLib.c in Sources */,
-				F9FD30E80CC1AD070073837D /* tclPanic.c in Sources */,
-				F9FD30E90CC1AD070073837D /* tclParse.c in Sources */,
-				F9FD30EA0CC1AD070073837D /* tclPathObj.c in Sources */,
-				F9FD30EB0CC1AD070073837D /* tclPipe.c in Sources */,
-				F9FD30EC0CC1AD070073837D /* tclPkg.c in Sources */,
-				F9FD30ED0CC1AD070073837D /* tclPkgConfig.c in Sources */,
-				F9FD30EE0CC1AD070073837D /* tclPosixStr.c in Sources */,
-				F9FD30EF0CC1AD070073837D /* tclPreserve.c in Sources */,
-				F9FD30F00CC1AD070073837D /* tclProc.c in Sources */,
-				F9FD30F10CC1AD070073837D /* tclRegexp.c in Sources */,
-				F9FD30F20CC1AD070073837D /* tclResolve.c in Sources */,
-				F9FD30F30CC1AD070073837D /* tclResult.c in Sources */,
-				F9FD30F40CC1AD070073837D /* tclScan.c in Sources */,
-				F9FD30F50CC1AD070073837D /* tclStringObj.c in Sources */,
-				F9FD30F60CC1AD070073837D /* tclStrToD.c in Sources */,
-				F9FD30F70CC1AD070073837D /* tclStubInit.c in Sources */,
-				F9FD30F80CC1AD070073837D /* tclStubLib.c in Sources */,
-				F9FD30F90CC1AD070073837D /* tclThread.c in Sources */,
-				F9FD30FA0CC1AD070073837D /* tclThreadAlloc.c in Sources */,
-				F9FD30FB0CC1AD070073837D /* tclThreadJoin.c in Sources */,
-				F9FD30FC0CC1AD070073837D /* tclThreadStorage.c in Sources */,
-				F9FD30FD0CC1AD070073837D /* tclTimer.c in Sources */,
-				F9FD30FE0CC1AD070073837D /* tclTomMathInterface.c in Sources */,
-				F9FD30FF0CC1AD070073837D /* tclTrace.c in Sources */,
-				F9FD31000CC1AD070073837D /* tclUtf.c in Sources */,
-				F9FD31010CC1AD070073837D /* tclUtil.c in Sources */,
-				F9FD31020CC1AD070073837D /* tclVar.c in Sources */,
-				F96437CB0EF0D4B2003F468E /* tclZlib.c in Sources */,
-				F9FD31030CC1AD070073837D /* bn_fast_s_mp_mul_digs.c in Sources */,
-				F9FD31040CC1AD070073837D /* bn_fast_s_mp_sqr.c in Sources */,
-				F9FD31050CC1AD070073837D /* bn_mp_add.c in Sources */,
-				F9FD31060CC1AD070073837D /* bn_mp_add_d.c in Sources */,
-				F9FD31070CC1AD070073837D /* bn_mp_and.c in Sources */,
-				F9FD31080CC1AD070073837D /* bn_mp_clamp.c in Sources */,
-				F9FD31090CC1AD070073837D /* bn_mp_clear.c in Sources */,
-				F9FD310A0CC1AD070073837D /* bn_mp_clear_multi.c in Sources */,
-				F9FD310B0CC1AD070073837D /* bn_mp_cmp.c in Sources */,
-				F9FD310C0CC1AD070073837D /* bn_mp_cmp_d.c in Sources */,
-				F9FD310D0CC1AD070073837D /* bn_mp_cmp_mag.c in Sources */,
-				F9FD310E0CC1AD070073837D /* bn_mp_copy.c in Sources */,
-				F9FD310F0CC1AD070073837D /* bn_mp_count_bits.c in Sources */,
-				F9FD31100CC1AD070073837D /* bn_mp_div.c in Sources */,
-				F9FD31110CC1AD070073837D /* bn_mp_div_2.c in Sources */,
-				F9FD31120CC1AD070073837D /* bn_mp_div_2d.c in Sources */,
-				F9FD31130CC1AD070073837D /* bn_mp_div_3.c in Sources */,
-				F9FD31140CC1AD070073837D /* bn_mp_div_d.c in Sources */,
-				F9FD31150CC1AD070073837D /* bn_mp_exch.c in Sources */,
-				F9FD31160CC1AD070073837D /* bn_mp_expt_d.c in Sources */,
-				F9FD31170CC1AD070073837D /* bn_mp_grow.c in Sources */,
-				F9FD31180CC1AD070073837D /* bn_mp_init.c in Sources */,
-				F9FD31190CC1AD070073837D /* bn_mp_init_copy.c in Sources */,
-				F9FD311A0CC1AD070073837D /* bn_mp_init_multi.c in Sources */,
-				F9FD311B0CC1AD070073837D /* bn_mp_init_set.c in Sources */,
-				F9FD311C0CC1AD070073837D /* bn_mp_init_size.c in Sources */,
-				F9FD311D0CC1AD070073837D /* bn_mp_karatsuba_mul.c in Sources */,
-				F9FD311E0CC1AD070073837D /* bn_mp_karatsuba_sqr.c in Sources */,
-				F9FD311F0CC1AD070073837D /* bn_mp_lshd.c in Sources */,
-				F9FD31200CC1AD070073837D /* bn_mp_mod.c in Sources */,
-				F9FD31210CC1AD070073837D /* bn_mp_mod_2d.c in Sources */,
-				F9FD31220CC1AD070073837D /* bn_mp_mul.c in Sources */,
-				F9FD31230CC1AD070073837D /* bn_mp_mul_2.c in Sources */,
-				F9FD31240CC1AD070073837D /* bn_mp_mul_2d.c in Sources */,
-				F9FD31250CC1AD070073837D /* bn_mp_mul_d.c in Sources */,
-				F9FD31260CC1AD070073837D /* bn_mp_neg.c in Sources */,
-				F9FD31270CC1AD070073837D /* bn_mp_or.c in Sources */,
-				F9FD31280CC1AD070073837D /* bn_mp_radix_size.c in Sources */,
-				F9FD31290CC1AD070073837D /* bn_mp_radix_smap.c in Sources */,
-				F9FD312A0CC1AD070073837D /* bn_mp_read_radix.c in Sources */,
-				F9FD312B0CC1AD070073837D /* bn_mp_rshd.c in Sources */,
-				F9FD312C0CC1AD070073837D /* bn_mp_set.c in Sources */,
-				F9FD312D0CC1AD070073837D /* bn_mp_shrink.c in Sources */,
-				F9FD312E0CC1AD070073837D /* bn_mp_sqr.c in Sources */,
-				F9FD312F0CC1AD070073837D /* bn_mp_sqrt.c in Sources */,
-				F9FD31300CC1AD070073837D /* bn_mp_sub.c in Sources */,
-				F9FD31310CC1AD070073837D /* bn_mp_sub_d.c in Sources */,
-				F9FD31320CC1AD070073837D /* bn_mp_to_unsigned_bin_n.c in Sources */,
-				F9FD31330CC1AD070073837D /* bn_mp_to_unsigned_bin.c in Sources */,
-				F9FD31340CC1AD070073837D /* bn_mp_toom_mul.c in Sources */,
-				F9FD31350CC1AD070073837D /* bn_mp_toom_sqr.c in Sources */,
-				F9FD31360CC1AD070073837D /* bn_mp_toradix_n.c in Sources */,
-				F9FD31370CC1AD070073837D /* bn_mp_unsigned_bin_size.c in Sources */,
-				F9FD31380CC1AD070073837D /* bn_mp_xor.c in Sources */,
-				F9FD31390CC1AD070073837D /* bn_mp_zero.c in Sources */,
-				F9FD313A0CC1AD070073837D /* bn_reverse.c in Sources */,
-				F9FD313B0CC1AD070073837D /* bn_s_mp_add.c in Sources */,
-				F9FD313C0CC1AD070073837D /* bn_s_mp_mul_digs.c in Sources */,
-				F9FD313D0CC1AD070073837D /* bn_s_mp_sqr.c in Sources */,
-				F9FD313E0CC1AD070073837D /* bn_s_mp_sub.c in Sources */,
-				F9FD313F0CC1AD070073837D /* bncore.c in Sources */,
-				F9FD31400CC1AD070073837D /* tclMacOSXBundle.c in Sources */,
-				F9FD31410CC1AD070073837D /* tclMacOSXFCmd.c in Sources */,
-				F9FD31420CC1AD070073837D /* tclMacOSXNotify.c in Sources */,
-				F9FD31430CC1AD070073837D /* tclLoadDyld.c in Sources */,
-				F9FD31440CC1AD070073837D /* tclUnixChan.c in Sources */,
-				F9FD31450CC1AD070073837D /* tclUnixCompat.c in Sources */,
-				F9FD31460CC1AD070073837D /* tclUnixEvent.c in Sources */,
-				F9FD31470CC1AD070073837D /* tclUnixFCmd.c in Sources */,
-				F9FD31480CC1AD070073837D /* tclUnixFile.c in Sources */,
-				F9FD31490CC1AD070073837D /* tclUnixInit.c in Sources */,
-				F9FD314A0CC1AD070073837D /* tclUnixNotfy.c in Sources */,
-				F9FD314B0CC1AD070073837D /* tclUnixPipe.c in Sources */,
-				F9FD314C0CC1AD070073837D /* tclUnixSock.c in Sources */,
-				F9FD314D0CC1AD070073837D /* tclUnixThrd.c in Sources */,
-				F9FD314E0CC1AD070073837D /* tclUnixTime.c in Sources */,
-				F9FD31E20CC1AD070073837D /* tclDTrace.d in Sources */,
-				F9FD314F0CC1AD070073837D /* tk3d.c in Sources */,
-				F9FD31500CC1AD070073837D /* tkArgv.c in Sources */,
-				F9FD31510CC1AD070073837D /* tkAtom.c in Sources */,
-				F9FD31520CC1AD070073837D /* tkBind.c in Sources */,
-				F9FD31530CC1AD070073837D /* tkBitmap.c in Sources */,
-				F9152B0A0EAF8A5700CD5C7B /* tkBusy.c in Sources */,
-				F9FD31540CC1AD070073837D /* tkButton.c in Sources */,
-				F9FD31550CC1AD070073837D /* tkCanvArc.c in Sources */,
-				F9FD31560CC1AD070073837D /* tkCanvas.c in Sources */,
-				F9FD31570CC1AD070073837D /* tkCanvBmap.c in Sources */,
-				F9FD31580CC1AD070073837D /* tkCanvImg.c in Sources */,
-				F9FD31590CC1AD070073837D /* tkCanvLine.c in Sources */,
-				F9FD315A0CC1AD070073837D /* tkCanvPoly.c in Sources */,
-				F9FD315B0CC1AD070073837D /* tkCanvPs.c in Sources */,
-				F9FD315C0CC1AD070073837D /* tkCanvText.c in Sources */,
-				F9FD315D0CC1AD070073837D /* tkCanvUtil.c in Sources */,
-				F9FD315E0CC1AD070073837D /* tkCanvWind.c in Sources */,
-				F9FD315F0CC1AD070073837D /* tkClipboard.c in Sources */,
-				F9FD31600CC1AD070073837D /* tkCmds.c in Sources */,
-				F9FD31610CC1AD070073837D /* tkColor.c in Sources */,
-				F9FD31620CC1AD070073837D /* tkConfig.c in Sources */,
-				F9FD31630CC1AD070073837D /* tkConsole.c in Sources */,
-				F9FD31640CC1AD070073837D /* tkCursor.c in Sources */,
-				F9FD31650CC1AD070073837D /* tkEntry.c in Sources */,
-				F9FD31660CC1AD070073837D /* tkError.c in Sources */,
-				F9FD31670CC1AD070073837D /* tkEvent.c in Sources */,
-				F9FD31680CC1AD070073837D /* tkFileFilter.c in Sources */,
-				F9FD31690CC1AD070073837D /* tkFocus.c in Sources */,
-				F9FD316A0CC1AD070073837D /* tkFont.c in Sources */,
-				F9FD316B0CC1AD070073837D /* tkFrame.c in Sources */,
-				F9FD316C0CC1AD070073837D /* tkGC.c in Sources */,
-				F9FD316D0CC1AD070073837D /* tkGeometry.c in Sources */,
-				F9FD316E0CC1AD070073837D /* tkGet.c in Sources */,
-				F9FD316F0CC1AD070073837D /* tkGrab.c in Sources */,
-				F9FD31700CC1AD070073837D /* tkGrid.c in Sources */,
-				F9FD31710CC1AD070073837D /* tkImage.c in Sources */,
-				F9FD31720CC1AD070073837D /* tkImgBmap.c in Sources */,
-				F9FD31730CC1AD070073837D /* tkImgGIF.c in Sources */,
-				F92EE8D30E62F939001A6E80 /* tkImgPhInstance.c in Sources */,
-				F9FD31740CC1AD070073837D /* tkImgPhoto.c in Sources */,
-				F9DD99BE0F07DF850018B2E4 /* tkImgPNG.c in Sources */,
-				F9FD31750CC1AD070073837D /* tkImgPPM.c in Sources */,
-				F9FD31760CC1AD070073837D /* tkListbox.c in Sources */,
-				F9FD31770CC1AD070073837D /* tkMacWinMenu.c in Sources */,
-				F9FD31780CC1AD070073837D /* tkMain.c in Sources */,
-				F9FD31790CC1AD070073837D /* tkMenu.c in Sources */,
-				F9FD317A0CC1AD070073837D /* tkMenubutton.c in Sources */,
-				F9FD317B0CC1AD070073837D /* tkMenuDraw.c in Sources */,
-				F9FD317C0CC1AD070073837D /* tkMessage.c in Sources */,
-				F9FD317D0CC1AD070073837D /* tkObj.c in Sources */,
-				F9FD317E0CC1AD070073837D /* tkOldConfig.c in Sources */,
-				F9FD317F0CC1AD070073837D /* tkOldTest.c in Sources */,
-				F9FD31800CC1AD070073837D /* tkOption.c in Sources */,
-				F9FD31810CC1AD070073837D /* tkPack.c in Sources */,
-				F9FD31820CC1AD070073837D /* tkPanedWindow.c in Sources */,
-				F9FD31830CC1AD070073837D /* tkPlace.c in Sources */,
-				F9FD31850CC1AD070073837D /* tkRectOval.c in Sources */,
-				F9FD31860CC1AD070073837D /* tkScale.c in Sources */,
-				F9FD31870CC1AD070073837D /* tkScrollbar.c in Sources */,
-				F9FD31880CC1AD070073837D /* tkSelect.c in Sources */,
-				F9FD31890CC1AD070073837D /* tkSquare.c in Sources */,
-				F9FD318A0CC1AD070073837D /* tkStubInit.c in Sources */,
-				F9FD318B0CC1AD070073837D /* tkStubLib.c in Sources */,
-				F9FD318C0CC1AD070073837D /* tkStyle.c in Sources */,
-				F9FD318D0CC1AD070073837D /* tkTest.c in Sources */,
-				F9FD318E0CC1AD070073837D /* tkText.c in Sources */,
-				F9FD318F0CC1AD070073837D /* tkTextBTree.c in Sources */,
-				F9FD31900CC1AD070073837D /* tkTextDisp.c in Sources */,
-				F9FD31910CC1AD070073837D /* tkTextImage.c in Sources */,
-				F9FD31920CC1AD070073837D /* tkTextIndex.c in Sources */,
-				F9FD31930CC1AD070073837D /* tkTextMark.c in Sources */,
-				F9FD31940CC1AD070073837D /* tkTextTag.c in Sources */,
-				F9FD31950CC1AD070073837D /* tkTextWind.c in Sources */,
-				F9FD31960CC1AD070073837D /* tkTrig.c in Sources */,
-				F9FD31970CC1AD070073837D /* tkUndo.c in Sources */,
-				F9FD31980CC1AD070073837D /* tkUtil.c in Sources */,
-				F9FD31990CC1AD070073837D /* tkVisual.c in Sources */,
-				F9FD319A0CC1AD070073837D /* tkWindow.c in Sources */,
-				F9FD319B0CC1AD070073837D /* ttkBlink.c in Sources */,
-				F9FD319C0CC1AD070073837D /* ttkButton.c in Sources */,
-				F9FD319D0CC1AD070073837D /* ttkCache.c in Sources */,
-				F9FD319E0CC1AD070073837D /* ttkClamTheme.c in Sources */,
-				F9FD319F0CC1AD070073837D /* ttkClassicTheme.c in Sources */,
-				F9FD31A00CC1AD070073837D /* ttkDefaultTheme.c in Sources */,
-				F9FD31A10CC1AD070073837D /* ttkElements.c in Sources */,
-				F9FD31A20CC1AD070073837D /* ttkEntry.c in Sources */,
-				F9FD31A30CC1AD070073837D /* ttkFrame.c in Sources */,
-				F9FD31A40CC1AD070073837D /* ttkImage.c in Sources */,
-				F9FD31A50CC1AD070073837D /* ttkInit.c in Sources */,
-				F9FD31A60CC1AD070073837D /* ttkLabel.c in Sources */,
-				F9FD31A70CC1AD070073837D /* ttkLayout.c in Sources */,
-				F9FD31A80CC1AD070073837D /* ttkManager.c in Sources */,
-				F9FD31A90CC1AD070073837D /* ttkNotebook.c in Sources */,
-				F9FD31AA0CC1AD070073837D /* ttkPanedwindow.c in Sources */,
-				F9FD31AB0CC1AD070073837D /* ttkProgress.c in Sources */,
-				F9FD31AC0CC1AD070073837D /* ttkScale.c in Sources */,
-				F9FD31AD0CC1AD070073837D /* ttkScroll.c in Sources */,
-				F9FD31AE0CC1AD070073837D /* ttkScrollbar.c in Sources */,
-				F9FD31AF0CC1AD070073837D /* ttkSeparator.c in Sources */,
-				F9FD31B00CC1AD070073837D /* ttkSquare.c in Sources */,
-				F9FD31B10CC1AD070073837D /* ttkState.c in Sources */,
-				F9FD31B20CC1AD070073837D /* ttkStubInit.c in Sources */,
-				F9FD31B30CC1AD070073837D /* ttkStubLib.c in Sources */,
-				F9FD31B40CC1AD070073837D /* ttkTagSet.c in Sources */,
-				F9FD31B50CC1AD070073837D /* ttkTheme.c in Sources */,
-				F9FD31B60CC1AD070073837D /* ttkTrace.c in Sources */,
-				F9FD31B70CC1AD070073837D /* ttkTrack.c in Sources */,
-				F9FD31B80CC1AD070073837D /* ttkTreeview.c in Sources */,
-				F9FD31B90CC1AD070073837D /* ttkWidget.c in Sources */,
-				F9FD31DA0CC1AD070073837D /* tkAppInit.c in Sources */,
-				F9FD32020CC1ADB70073837D /* tkUnix.c in Sources */,
-				F9FD31DB0CC1AD070073837D /* tkUnix3d.c in Sources */,
-				F9FD320A0CC1ADB70073837D /* tkUnixButton.c in Sources */,
-				F9FD32090CC1ADB70073837D /* tkUnixColor.c in Sources */,
-				F9FD32040CC1ADB70073837D /* tkUnixConfig.c in Sources */,
-				F9FD31F80CC1ADB70073837D /* tkUnixCursor.c in Sources */,
-				F9FD32060CC1ADB70073837D /* tkUnixDialog.c in Sources */,
-				F9FD32050CC1ADB70073837D /* tkUnixDraw.c in Sources */,
-				F9FD31FD0CC1ADB70073837D /* tkUnixEmbed.c in Sources */,
-				F9FD32080CC1ADB70073837D /* tkUnixEvent.c in Sources */,
-				F9FD31FF0CC1ADB70073837D /* tkUnixFocus.c in Sources */,
-				F9FD31FC0CC1ADB70073837D /* tkUnixInit.c in Sources */,
-				F9FD31FA0CC1ADB70073837D /* tkUnixKey.c in Sources */,
-				F9FD32030CC1ADB70073837D /* tkUnixMenu.c in Sources */,
-				F9FD320B0CC1ADB70073837D /* tkUnixMenubu.c in Sources */,
-				F9FD32010CC1ADB70073837D /* tkUnixRFont.c in Sources */,
-				F9FD31DC0CC1AD070073837D /* tkUnixScale.c in Sources */,
-				F9FD320C0CC1ADB70073837D /* tkUnixScrlbr.c in Sources */,
-				F9FD32070CC1ADB70073837D /* tkUnixSelect.c in Sources */,
-				F9FD31FE0CC1ADB70073837D /* tkUnixSend.c in Sources */,
-				F9FD32000CC1ADB70073837D /* tkUnixWm.c in Sources */,
-				F9FD31FB0CC1ADB70073837D /* tkUnixXId.c in Sources */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXSourcesBuildPhase section */
-
-/* Begin XCBuildConfiguration section */
-		F90E36D50F3B5C8400810A10 /* DebugNoGC */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = unsupported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				ONLY_ACTIVE_ARCH = YES;
-				PREBINDING = NO;
-			};
-			name = DebugNoGC;
-		};
-		F90E36D60F3B5C8400810A10 /* DebugNoGC */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = DebugNoGC;
-		};
-		F90E36D70F3B5C8400810A10 /* DebugNoGC */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = DebugNoGC;
-		};
-		F90E36D80F3B5C8400810A10 /* DebugNoGC */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
-				GCC_DYNAMIC_NO_PIC = NO;
-				GCC_ENABLE_FIX_AND_CONTINUE = YES;
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				GCC_PREPROCESSOR_DEFINITIONS = (
-					"__private_extern__=extern",
-					"$(GCC_PREPROCESSOR_DEFINITIONS)",
-				);
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = DebugNoGC;
-		};
-		F91BCC4F093152310042A6BF /* ReleaseUniversal */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = ReleaseUniversal;
-		};
-		F91BCC50093152310042A6BF /* ReleaseUniversal */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = ReleaseUniversal;
-		};
-		F91BCC51093152310042A6BF /* ReleaseUniversal */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */;
-			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				PREBINDING = NO;
-			};
-			name = ReleaseUniversal;
-		};
-		F93084370BB93D2800CD0B9E /* DebugMemCompile */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = DebugMemCompile;
-		};
-		F93084380BB93D2800CD0B9E /* DebugMemCompile */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = DebugMemCompile;
-		};
-		F93084390BB93D2800CD0B9E /* DebugMemCompile */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = DebugMemCompile;
-		};
-		F930843A0BB93D2800CD0B9E /* DebugMemCompile */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --enable-symbols=all";
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				ONLY_ACTIVE_ARCH = YES;
-				PREBINDING = NO;
-			};
-			name = DebugMemCompile;
-		};
-		F9359B250DF212DA00E04F67 /* DebugGCov */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_GENERATE_TEST_COVERAGE_FILES = YES;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				ONLY_ACTIVE_ARCH = YES;
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS)",
-					"-lgcov",
-				);
-				PREBINDING = NO;
-			};
-			name = DebugGCov;
-		};
-		F9359B260DF212DA00E04F67 /* DebugGCov */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = DebugGCov;
-		};
-		F9359B270DF212DA00E04F67 /* DebugGCov */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = DebugGCov;
-		};
-		F9359B280DF212DA00E04F67 /* DebugGCov */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = DebugGCov;
-		};
-		F95CC8AC09158F3100EA5ACE /* Debug */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = Debug;
-		};
-		F95CC8AD09158F3100EA5ACE /* Release */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = Release;
-		};
-		F95CC8AE09158F3100EA5ACE /* DebugNoFixAndContinue */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = DebugNoFixAndContinue;
-		};
-		F95CC8B109158F3100EA5ACE /* Debug */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
-				GCC_DYNAMIC_NO_PIC = NO;
-				GCC_ENABLE_FIX_AND_CONTINUE = YES;
-				GCC_PREPROCESSOR_DEFINITIONS = (
-					"__private_extern__=extern",
-					"$(GCC_PREPROCESSOR_DEFINITIONS)",
-				);
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = Debug;
-		};
-		F95CC8B209158F3100EA5ACE /* Release */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = Release;
-		};
-		F95CC8B309158F3100EA5ACE /* DebugNoFixAndContinue */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = DebugNoFixAndContinue;
-		};
-		F95CC8B609158F3100EA5ACE /* Debug */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				ONLY_ACTIVE_ARCH = YES;
-				PREBINDING = NO;
-			};
-			name = Debug;
-		};
-		F95CC8B709158F3100EA5ACE /* Release */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				ONLY_ACTIVE_ARCH = YES;
-				PREBINDING = NO;
-			};
-			name = Release;
-		};
-		F95CC8B809158F3100EA5ACE /* DebugNoFixAndContinue */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				ONLY_ACTIVE_ARCH = YES;
-				PREBINDING = NO;
-			};
-			name = DebugNoFixAndContinue;
-		};
-		F97258A90A86873D00096C78 /* Debug */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
-				GCC_DYNAMIC_NO_PIC = NO;
-				GCC_ENABLE_FIX_AND_CONTINUE = YES;
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				GCC_PREPROCESSOR_DEFINITIONS = (
-					"__private_extern__=extern",
-					"$(GCC_PREPROCESSOR_DEFINITIONS)",
-				);
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = Debug;
-		};
-		F97258AA0A86873D00096C78 /* Release */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = Release;
-		};
-		F97258AB0A86873D00096C78 /* DebugNoFixAndContinue */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = DebugNoFixAndContinue;
-		};
-		F97258AC0A86873D00096C78 /* ReleaseUniversal */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = ReleaseUniversal;
-		};
-		F97AED1B0B660B2100310EA2 /* Debug64bit */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = Debug64bit;
-		};
-		F97AED1C0B660B2100310EA2 /* Debug64bit */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = Debug64bit;
-		};
-		F97AED1D0B660B2100310EA2 /* Debug64bit */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = Debug64bit;
-		};
-		F97AED1E0B660B2100310EA2 /* Debug64bit */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH_64_BIT)";
-				CONFIGURE_ARGS = "--enable-64bit $(CONFIGURE_ARGS)";
-				CPPFLAGS = "-arch $(NATIVE_ARCH_64_BIT) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				PREBINDING = NO;
-			};
-			name = Debug64bit;
-		};
-		F987512F0DE7B57E00B1C9EC /* DebugNoCF */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --disable-corefoundation";
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				ONLY_ACTIVE_ARCH = YES;
-				PREBINDING = NO;
-			};
-			name = DebugNoCF;
-		};
-		F98751300DE7B57E00B1C9EC /* DebugNoCF */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --enable-corefoundation";
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = DebugNoCF;
-		};
-		F98751310DE7B57E00B1C9EC /* DebugNoCF */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --enable-corefoundation";
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = DebugNoCF;
-		};
-		F98751320DE7B57E00B1C9EC /* DebugNoCF */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = DebugNoCF;
-		};
-		F98751330DE7B5A200B1C9EC /* DebugNoCFUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --disable-threads --disable-corefoundation";
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				ONLY_ACTIVE_ARCH = YES;
-				PREBINDING = NO;
-			};
-			name = DebugNoCFUnthreaded;
-		};
-		F98751340DE7B5A200B1C9EC /* DebugNoCFUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --enable-corefoundation";
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = DebugNoCFUnthreaded;
-		};
-		F98751350DE7B5A200B1C9EC /* DebugNoCFUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --enable-corefoundation";
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = DebugNoCFUnthreaded;
-		};
-		F98751360DE7B5A200B1C9EC /* DebugNoCFUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = DebugNoCFUnthreaded;
-		};
-		F9988AB10D814C6500B6B03B /* Debug gcc40 */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				GCC_VERSION = 4.0;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				ONLY_ACTIVE_ARCH = YES;
-				PREBINDING = NO;
-			};
-			name = "Debug gcc40";
-		};
-		F9988AB20D814C6500B6B03B /* Debug gcc40 */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = "Debug gcc40";
-		};
-		F9988AB30D814C6500B6B03B /* Debug gcc40 */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
-				GCC_DYNAMIC_NO_PIC = NO;
-				GCC_ENABLE_FIX_AND_CONTINUE = YES;
-				GCC_PREPROCESSOR_DEFINITIONS = (
-					"__private_extern__=extern",
-					"$(GCC_PREPROCESSOR_DEFINITIONS)",
-				);
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = "Debug gcc40";
-		};
-		F9988AB40D814C6500B6B03B /* Debug gcc40 */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
-				GCC_DYNAMIC_NO_PIC = NO;
-				GCC_ENABLE_FIX_AND_CONTINUE = YES;
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				GCC_PREPROCESSOR_DEFINITIONS = (
-					"__private_extern__=extern",
-					"$(GCC_PREPROCESSOR_DEFINITIONS)",
-				);
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = "Debug gcc40";
-		};
-		F9988AB50D814C7500B6B03B /* Debug llvm-gcc */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC = "llvm-gcc";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				GCC_VERSION = com.apple.compilers.llvmgcc42;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				ONLY_ACTIVE_ARCH = YES;
-				PREBINDING = NO;
-			};
-			name = "Debug llvm-gcc";
-		};
-		F9988AB60D814C7500B6B03B /* Debug llvm-gcc */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = "Debug llvm-gcc";
-		};
-		F9988AB70D814C7500B6B03B /* Debug llvm-gcc */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
-				GCC_DYNAMIC_NO_PIC = NO;
-				GCC_ENABLE_FIX_AND_CONTINUE = YES;
-				GCC_PREPROCESSOR_DEFINITIONS = (
-					"__private_extern__=extern",
-					"$(GCC_PREPROCESSOR_DEFINITIONS)",
-				);
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = "Debug llvm-gcc";
-		};
-		F9988AB80D814C7500B6B03B /* Debug llvm-gcc */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)";
-				GCC_DYNAMIC_NO_PIC = NO;
-				GCC_ENABLE_FIX_AND_CONTINUE = YES;
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				GCC_PREPROCESSOR_DEFINITIONS = (
-					"__private_extern__=extern",
-					"$(GCC_PREPROCESSOR_DEFINITIONS)",
-				);
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = "Debug llvm-gcc";
-		};
-		F9988BB10D81586D00B6B03B /* ReleaseUniversal gcc40 */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */;
-			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				GCC_VERSION = 4.0;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				PREBINDING = NO;
-			};
-			name = "ReleaseUniversal gcc40";
-		};
-		F9988BB20D81586D00B6B03B /* ReleaseUniversal gcc40 */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = "ReleaseUniversal gcc40";
-		};
-		F9988BB30D81586D00B6B03B /* ReleaseUniversal gcc40 */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = "ReleaseUniversal gcc40";
-		};
-		F9988BB40D81586D00B6B03B /* ReleaseUniversal gcc40 */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = "ReleaseUniversal gcc40";
-		};
-		F9988BB50D81587400B6B03B /* ReleaseUniversal llvm-gcc */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */;
-			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
-				DEBUG_INFORMATION_FORMAT = dwarf;
-				GCC = "llvm-gcc";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				GCC_OPTIMIZATION_LEVEL = 4;
-				GCC_VERSION = com.apple.compilers.llvmgcc42;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				PREBINDING = NO;
-			};
-			name = "ReleaseUniversal llvm-gcc";
-		};
-		F9988BB60D81587400B6B03B /* ReleaseUniversal llvm-gcc */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = "ReleaseUniversal llvm-gcc";
-		};
-		F9988BB70D81587400B6B03B /* ReleaseUniversal llvm-gcc */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = "ReleaseUniversal llvm-gcc";
-		};
-		F9988BB80D81587400B6B03B /* ReleaseUniversal llvm-gcc */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = "ReleaseUniversal llvm-gcc";
-		};
-		F99EE73B0BE835310060D4AF /* DebugUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = DebugUnthreaded;
-		};
-		F99EE73C0BE835310060D4AF /* DebugLeaks */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = DebugLeaks;
-		};
-		F99EE73D0BE835310060D4AF /* DebugUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = DebugUnthreaded;
-		};
-		F99EE73E0BE835310060D4AF /* DebugLeaks */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = DebugLeaks;
-		};
-		F99EE73F0BE835310060D4AF /* DebugUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = DebugUnthreaded;
-		};
-		F99EE7400BE835310060D4AF /* DebugLeaks */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = DebugLeaks;
-		};
-		F99EE7410BE835310060D4AF /* DebugUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --disable-threads";
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				ONLY_ACTIVE_ARCH = YES;
-				PREBINDING = NO;
-			};
-			name = DebugUnthreaded;
-		};
-		F99EE7420BE835310060D4AF /* DebugLeaks */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = unsupported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				GCC_PREPROCESSOR_DEFINITIONS = (
-					PURIFY,
-					"$(GCC_PREPROCESSOR_DEFINITIONS)",
-				);
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				ONLY_ACTIVE_ARCH = YES;
-				PREBINDING = NO;
-			};
-			name = DebugLeaks;
-		};
-		F9EEED960C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = ReleaseUniversal10.5SDK;
-		};
-		F9EEED970C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = ReleaseUniversal10.5SDK;
-		};
-		F9EEED980C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = ReleaseUniversal10.5SDK;
-		};
-		F9EEED990C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */;
-			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
-				CPPFLAGS = "-isysroot $(SDKROOT) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.5;
-				PREBINDING = NO;
-				SDKROOT = macosx10.5;
-			};
-			name = ReleaseUniversal10.5SDK;
-		};
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
-		F95CC8AB09158F3100EA5ACE /* Build configuration list for PBXNativeTarget "Tk" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				F95CC8AC09158F3100EA5ACE /* Debug */,
-				F9988AB60D814C7500B6B03B /* Debug llvm-gcc */,
-				F9988AB20D814C6500B6B03B /* Debug gcc40 */,
-				F90E36D60F3B5C8400810A10 /* DebugNoGC */,
-				F95CC8AE09158F3100EA5ACE /* DebugNoFixAndContinue */,
-				F99EE73B0BE835310060D4AF /* DebugUnthreaded */,
-				F98751300DE7B57E00B1C9EC /* DebugNoCF */,
-				F98751340DE7B5A200B1C9EC /* DebugNoCFUnthreaded */,
-				F93084370BB93D2800CD0B9E /* DebugMemCompile */,
-				F99EE73C0BE835310060D4AF /* DebugLeaks */,
-				F9359B260DF212DA00E04F67 /* DebugGCov */,
-				F97AED1B0B660B2100310EA2 /* Debug64bit */,
-				F95CC8AD09158F3100EA5ACE /* Release */,
-				F91BCC4F093152310042A6BF /* ReleaseUniversal */,
-				F9988BB60D81587400B6B03B /* ReleaseUniversal llvm-gcc */,
-				F9988BB20D81586D00B6B03B /* ReleaseUniversal gcc40 */,
-				F9EEED960C2FEFD300396116 /* ReleaseUniversal10.5SDK */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Debug;
-		};
-		F95CC8B009158F3100EA5ACE /* Build configuration list for PBXNativeTarget "tktest" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				F95CC8B109158F3100EA5ACE /* Debug */,
-				F9988AB70D814C7500B6B03B /* Debug llvm-gcc */,
-				F9988AB30D814C6500B6B03B /* Debug gcc40 */,
-				F90E36D70F3B5C8400810A10 /* DebugNoGC */,
-				F95CC8B309158F3100EA5ACE /* DebugNoFixAndContinue */,
-				F99EE73D0BE835310060D4AF /* DebugUnthreaded */,
-				F98751310DE7B57E00B1C9EC /* DebugNoCF */,
-				F98751350DE7B5A200B1C9EC /* DebugNoCFUnthreaded */,
-				F93084380BB93D2800CD0B9E /* DebugMemCompile */,
-				F99EE73E0BE835310060D4AF /* DebugLeaks */,
-				F9359B270DF212DA00E04F67 /* DebugGCov */,
-				F97AED1C0B660B2100310EA2 /* Debug64bit */,
-				F95CC8B209158F3100EA5ACE /* Release */,
-				F91BCC50093152310042A6BF /* ReleaseUniversal */,
-				F9988BB70D81587400B6B03B /* ReleaseUniversal llvm-gcc */,
-				F9988BB30D81586D00B6B03B /* ReleaseUniversal gcc40 */,
-				F9EEED970C2FEFD300396116 /* ReleaseUniversal10.5SDK */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Debug;
-		};
-		F95CC8B509158F3100EA5ACE /* Build configuration list for PBXProject "Tk" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				F95CC8B609158F3100EA5ACE /* Debug */,
-				F9988AB50D814C7500B6B03B /* Debug llvm-gcc */,
-				F9988AB10D814C6500B6B03B /* Debug gcc40 */,
-				F90E36D50F3B5C8400810A10 /* DebugNoGC */,
-				F95CC8B809158F3100EA5ACE /* DebugNoFixAndContinue */,
-				F99EE7410BE835310060D4AF /* DebugUnthreaded */,
-				F987512F0DE7B57E00B1C9EC /* DebugNoCF */,
-				F98751330DE7B5A200B1C9EC /* DebugNoCFUnthreaded */,
-				F930843A0BB93D2800CD0B9E /* DebugMemCompile */,
-				F99EE7420BE835310060D4AF /* DebugLeaks */,
-				F9359B250DF212DA00E04F67 /* DebugGCov */,
-				F97AED1E0B660B2100310EA2 /* Debug64bit */,
-				F95CC8B709158F3100EA5ACE /* Release */,
-				F91BCC51093152310042A6BF /* ReleaseUniversal */,
-				F9988BB50D81587400B6B03B /* ReleaseUniversal llvm-gcc */,
-				F9988BB10D81586D00B6B03B /* ReleaseUniversal gcc40 */,
-				F9EEED990C2FEFD300396116 /* ReleaseUniversal10.5SDK */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Debug;
-		};
-		F97258A80A86873D00096C78 /* Build configuration list for PBXNativeTarget "tktest-X11" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				F97258A90A86873D00096C78 /* Debug */,
-				F9988AB80D814C7500B6B03B /* Debug llvm-gcc */,
-				F9988AB40D814C6500B6B03B /* Debug gcc40 */,
-				F90E36D80F3B5C8400810A10 /* DebugNoGC */,
-				F97258AB0A86873D00096C78 /* DebugNoFixAndContinue */,
-				F99EE73F0BE835310060D4AF /* DebugUnthreaded */,
-				F98751320DE7B57E00B1C9EC /* DebugNoCF */,
-				F98751360DE7B5A200B1C9EC /* DebugNoCFUnthreaded */,
-				F93084390BB93D2800CD0B9E /* DebugMemCompile */,
-				F99EE7400BE835310060D4AF /* DebugLeaks */,
-				F9359B280DF212DA00E04F67 /* DebugGCov */,
-				F97AED1D0B660B2100310EA2 /* Debug64bit */,
-				F97258AA0A86873D00096C78 /* Release */,
-				F97258AC0A86873D00096C78 /* ReleaseUniversal */,
-				F9988BB80D81587400B6B03B /* ReleaseUniversal llvm-gcc */,
-				F9988BB40D81586D00B6B03B /* ReleaseUniversal gcc40 */,
-				F9EEED980C2FEFD300396116 /* ReleaseUniversal10.5SDK */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Debug;
-		};
-/* End XCConfigurationList section */
-	};
-	rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
-}

Index: macosx/Tk.xcodeproj/project.pbxproj
==================================================================
--- macosx/Tk.xcodeproj/project.pbxproj
+++ macosx/Tk.xcodeproj/project.pbxproj
@@ -4747,12 +4747,12 @@
 		};
 		F91BCC51093152310042A6BF /* ReleaseUniversal */ = {
 			isa = XCBuildConfiguration;
 			baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */;
 			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)";
 				GCC_C_LANGUAGE_STANDARD = gnu99;
 				GCC_ENABLE_OBJC_GC = supported;
 				GCC_ENABLE_PASCAL_STRINGS = NO;
 				GCC_INPUT_FILETYPE = sourcecode.c.objc;
 				MACOSX_DEPLOYMENT_TARGET = 10.6;
@@ -5059,12 +5059,12 @@
 			name = DebugNoFixAndContinue;
 		};
 		F97258AC0A86873D00096C78 /* ReleaseUniversal */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)";
 				GCC_INPUT_FILETYPE = sourcecode.c.c;
 				HEADER_SEARCH_PATHS = (
 					/usr/X11R6/include,
 					/usr/X11R6/include/freetype2,
 					"$(HEADER_SEARCH_PATHS)",
@@ -5075,62 +5075,10 @@
 				);
 				PRODUCT_NAME = "tktest-X11";
 			};
 			name = ReleaseUniversal;
 		};
-		F97AED1B0B660B2100310EA2 /* Debug64bit */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = Debug64bit;
-		};
-		F97AED1C0B660B2100310EA2 /* Debug64bit */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = Debug64bit;
-		};
-		F97AED1D0B660B2100310EA2 /* Debug64bit */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = Debug64bit;
-		};
-		F97AED1E0B660B2100310EA2 /* Debug64bit */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH_64_BIT)";
-				CONFIGURE_ARGS = "--enable-64bit $(CONFIGURE_ARGS)";
-				CPPFLAGS = "-arch $(NATIVE_ARCH_64_BIT) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.6;
-				PREBINDING = NO;
-			};
-			name = Debug64bit;
-		};
 		F987512F0DE7B57E00B1C9EC /* DebugNoCF */ = {
 			isa = XCBuildConfiguration;
 			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
 			buildSettings = {
 				ARCHS = (
@@ -5185,68 +5133,10 @@
 				);
 				PRODUCT_NAME = "tktest-X11";
 			};
 			name = DebugNoCF;
 		};
-		F98751330DE7B5A200B1C9EC /* DebugNoCFUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --disable-threads --disable-corefoundation";
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.6;
-				ONLY_ACTIVE_ARCH = YES;
-				PREBINDING = NO;
-			};
-			name = DebugNoCFUnthreaded;
-		};
-		F98751340DE7B5A200B1C9EC /* DebugNoCFUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --enable-corefoundation";
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = DebugNoCFUnthreaded;
-		};
-		F98751350DE7B5A200B1C9EC /* DebugNoCFUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --enable-corefoundation";
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = DebugNoCFUnthreaded;
-		};
-		F98751360DE7B5A200B1C9EC /* DebugNoCFUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = DebugNoCFUnthreaded;
-		};
 		F9988AB10D814C6500B6B03B /* Debug gcc40 */ = {
 			isa = XCBuildConfiguration;
 			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
 			buildSettings = {
 				ARCHS = (
@@ -5392,12 +5282,12 @@
 		};
 		F9988BB10D81586D00B6B03B /* ReleaseUniversal gcc40 */ = {
 			isa = XCBuildConfiguration;
 			baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */;
 			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)";
 				GCC_C_LANGUAGE_STANDARD = gnu99;
 				GCC_ENABLE_OBJC_GC = supported;
 				GCC_ENABLE_PASCAL_STRINGS = NO;
 				GCC_INPUT_FILETYPE = sourcecode.c.objc;
 				GCC_VERSION = 4.0;
@@ -5426,12 +5316,12 @@
 			name = "ReleaseUniversal gcc40";
 		};
 		F9988BB40D81586D00B6B03B /* ReleaseUniversal gcc40 */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)";
 				GCC_INPUT_FILETYPE = sourcecode.c.c;
 				HEADER_SEARCH_PATHS = (
 					/usr/X11R6/include,
 					/usr/X11R6/include/freetype2,
 					"$(HEADER_SEARCH_PATHS)",
@@ -5446,12 +5336,12 @@
 		};
 		F9988BB50D81587400B6B03B /* ReleaseUniversal llvm-gcc */ = {
 			isa = XCBuildConfiguration;
 			baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */;
 			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)";
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				GCC = "llvm-gcc";
 				GCC_C_LANGUAGE_STANDARD = gnu99;
 				GCC_ENABLE_OBJC_GC = supported;
 				GCC_ENABLE_PASCAL_STRINGS = NO;
@@ -5484,12 +5374,12 @@
 			name = "ReleaseUniversal llvm-gcc";
 		};
 		F9988BB80D81587400B6B03B /* ReleaseUniversal llvm-gcc */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)";
 				GCC_INPUT_FILETYPE = sourcecode.c.c;
 				HEADER_SEARCH_PATHS = (
 					/usr/X11R6/include,
 					/usr/X11R6/include/freetype2,
 					"$(HEADER_SEARCH_PATHS)",
@@ -5500,37 +5390,18 @@
 				);
 				PRODUCT_NAME = "tktest-X11";
 			};
 			name = "ReleaseUniversal llvm-gcc";
 		};
-		F99EE73B0BE835310060D4AF /* DebugUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				PRODUCT_NAME = Wish;
-				SKIP_INSTALL = NO;
-			};
-			name = DebugUnthreaded;
-		};
 		F99EE73C0BE835310060D4AF /* DebugLeaks */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				PRODUCT_NAME = Wish;
 				SKIP_INSTALL = NO;
 			};
 			name = DebugLeaks;
 		};
-		F99EE73D0BE835310060D4AF /* DebugUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				OTHER_LDFLAGS = (
-					"$(OTHER_LDFLAGS_AQUA)",
-					"$(OTHER_LDFLAGS)",
-				);
-				PRODUCT_NAME = tktest;
-			};
-			name = DebugUnthreaded;
-		};
 		F99EE73E0BE835310060D4AF /* DebugLeaks */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				OTHER_LDFLAGS = (
 					"$(OTHER_LDFLAGS_AQUA)",
@@ -5538,27 +5409,10 @@
 				);
 				PRODUCT_NAME = tktest;
 			};
 			name = DebugLeaks;
 		};
-		F99EE73F0BE835310060D4AF /* DebugUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_INPUT_FILETYPE = sourcecode.c.c;
-				HEADER_SEARCH_PATHS = (
-					/usr/X11R6/include,
-					/usr/X11R6/include/freetype2,
-					"$(HEADER_SEARCH_PATHS)",
-				);
-				LIBRARY_SEARCH_PATHS = (
-					/usr/X11R6/lib,
-					"$(LIBRARY_SEARCH_PATHS)",
-				);
-				PRODUCT_NAME = "tktest-X11";
-			};
-			name = DebugUnthreaded;
-		};
 		F99EE7400BE835310060D4AF /* DebugLeaks */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				GCC_INPUT_FILETYPE = sourcecode.c.c;
 				HEADER_SEARCH_PATHS = (
@@ -5572,37 +5426,16 @@
 				);
 				PRODUCT_NAME = "tktest-X11";
 			};
 			name = DebugLeaks;
 		};
-		F99EE7410BE835310060D4AF /* DebugUnthreaded */ = {
-			isa = XCBuildConfiguration;
-			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
-			buildSettings = {
-				ARCHS = (
-					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
-				);
-				CONFIGURE_ARGS = "$(CONFIGURE_ARGS) --disable-threads";
-				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_ENABLE_OBJC_GC = supported;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_INPUT_FILETYPE = sourcecode.c.objc;
-				MACOSX_DEPLOYMENT_TARGET = 10.6;
-				ONLY_ACTIVE_ARCH = YES;
-				PREBINDING = NO;
-			};
-			name = DebugUnthreaded;
-		};
 		F99EE7420BE835310060D4AF /* DebugLeaks */ = {
 			isa = XCBuildConfiguration;
 			baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */;
 			buildSettings = {
 				ARCHS = (
 					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
 				);
 				CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)";
 				GCC_C_LANGUAGE_STANDARD = gnu99;
 				GCC_ENABLE_OBJC_GC = unsupported;
 				GCC_ENABLE_PASCAL_STRINGS = NO;
@@ -5694,13 +5527,12 @@
 			isa = XCBuildConfiguration;
 			baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */;
 			buildSettings = {
 				ARCHS = (
 					"$(NATIVE_ARCH_64_BIT)",
-					"$(NATIVE_ARCH_32_BIT)",
 				);
-				CFLAGS = "-arch i386 -arch x86_64 $(CFLAGS)";
+				CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)";
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				GCC = clang;
 				GCC_C_LANGUAGE_STANDARD = gnu99;
 				GCC_ENABLE_OBJC_GC = supported;
 				GCC_ENABLE_PASCAL_STRINGS = NO;
@@ -5732,12 +5564,12 @@
 			name = "ReleaseUniversal clang";
 		};
 		F9A9D1F60FC77799002A2BE3 /* ReleaseUniversal clang */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)";
 				HEADER_SEARCH_PATHS = (
 					/usr/X11R6/include,
 					/usr/X11R6/include/freetype2,
 					"$(HEADER_SEARCH_PATHS)",
 				);
@@ -5769,12 +5601,12 @@
 			name = ReleaseUniversal10.5SDK;
 		};
 		F9EEED980C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)";
 				GCC_INPUT_FILETYPE = sourcecode.c.c;
 				HEADER_SEARCH_PATHS = (
 					/usr/X11R6/include,
 					/usr/X11R6/include/freetype2,
 					"$(HEADER_SEARCH_PATHS)",
@@ -5789,12 +5621,12 @@
 		};
 		F9EEED990C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = {
 			isa = XCBuildConfiguration;
 			baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */;
 			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
-				CFLAGS = "-arch i386 -arch x86_64 -arch ppc $(CFLAGS)";
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)";
 				CPPFLAGS = "-isysroot $(SDKROOT) $(CPPFLAGS)";
 				GCC_C_LANGUAGE_STANDARD = gnu99;
 				GCC_ENABLE_OBJC_GC = supported;
 				GCC_ENABLE_PASCAL_STRINGS = NO;
 				GCC_INPUT_FILETYPE = sourcecode.c.objc;
@@ -5814,17 +5646,14 @@
 				F9A9D1F00FC77787002A2BE3 /* Debug clang */,
 				F9988AB60D814C7500B6B03B /* Debug llvm-gcc */,
 				F9988AB20D814C6500B6B03B /* Debug gcc40 */,
 				F90E36D60F3B5C8400810A10 /* DebugNoGC */,
 				F95CC8AE09158F3100EA5ACE /* DebugNoFixAndContinue */,
-				F99EE73B0BE835310060D4AF /* DebugUnthreaded */,
 				F98751300DE7B57E00B1C9EC /* DebugNoCF */,
-				F98751340DE7B5A200B1C9EC /* DebugNoCFUnthreaded */,
 				F93084370BB93D2800CD0B9E /* DebugMemCompile */,
 				F99EE73C0BE835310060D4AF /* DebugLeaks */,
 				F9359B260DF212DA00E04F67 /* DebugGCov */,
-				F97AED1B0B660B2100310EA2 /* Debug64bit */,
 				F95CC8AD09158F3100EA5ACE /* Release */,
 				F91BCC4F093152310042A6BF /* ReleaseUniversal */,
 				F9A9D1F40FC77799002A2BE3 /* ReleaseUniversal clang */,
 				F9988BB60D81587400B6B03B /* ReleaseUniversal llvm-gcc */,
 				F9988BB20D81586D00B6B03B /* ReleaseUniversal gcc40 */,
@@ -5840,17 +5669,14 @@
 				F9A9D1F10FC77787002A2BE3 /* Debug clang */,
 				F9988AB70D814C7500B6B03B /* Debug llvm-gcc */,
 				F9988AB30D814C6500B6B03B /* Debug gcc40 */,
 				F90E36D70F3B5C8400810A10 /* DebugNoGC */,
 				F95CC8B309158F3100EA5ACE /* DebugNoFixAndContinue */,
-				F99EE73D0BE835310060D4AF /* DebugUnthreaded */,
 				F98751310DE7B57E00B1C9EC /* DebugNoCF */,
-				F98751350DE7B5A200B1C9EC /* DebugNoCFUnthreaded */,
 				F93084380BB93D2800CD0B9E /* DebugMemCompile */,
 				F99EE73E0BE835310060D4AF /* DebugLeaks */,
 				F9359B270DF212DA00E04F67 /* DebugGCov */,
-				F97AED1C0B660B2100310EA2 /* Debug64bit */,
 				F95CC8B209158F3100EA5ACE /* Release */,
 				F91BCC50093152310042A6BF /* ReleaseUniversal */,
 				F9A9D1F50FC77799002A2BE3 /* ReleaseUniversal clang */,
 				F9988BB70D81587400B6B03B /* ReleaseUniversal llvm-gcc */,
 				F9988BB30D81586D00B6B03B /* ReleaseUniversal gcc40 */,
@@ -5866,17 +5692,14 @@
 				F9A9D1EF0FC77787002A2BE3 /* Debug clang */,
 				F9988AB50D814C7500B6B03B /* Debug llvm-gcc */,
 				F9988AB10D814C6500B6B03B /* Debug gcc40 */,
 				F90E36D50F3B5C8400810A10 /* DebugNoGC */,
 				F95CC8B809158F3100EA5ACE /* DebugNoFixAndContinue */,
-				F99EE7410BE835310060D4AF /* DebugUnthreaded */,
 				F987512F0DE7B57E00B1C9EC /* DebugNoCF */,
-				F98751330DE7B5A200B1C9EC /* DebugNoCFUnthreaded */,
 				F930843A0BB93D2800CD0B9E /* DebugMemCompile */,
 				F99EE7420BE835310060D4AF /* DebugLeaks */,
 				F9359B250DF212DA00E04F67 /* DebugGCov */,
-				F97AED1E0B660B2100310EA2 /* Debug64bit */,
 				F95CC8B709158F3100EA5ACE /* Release */,
 				F91BCC51093152310042A6BF /* ReleaseUniversal */,
 				F9A9D1F30FC77799002A2BE3 /* ReleaseUniversal clang */,
 				F9988BB50D81587400B6B03B /* ReleaseUniversal llvm-gcc */,
 				F9988BB10D81586D00B6B03B /* ReleaseUniversal gcc40 */,
@@ -5892,17 +5715,14 @@
 				F9A9D1F20FC77787002A2BE3 /* Debug clang */,
 				F9988AB80D814C7500B6B03B /* Debug llvm-gcc */,
 				F9988AB40D814C6500B6B03B /* Debug gcc40 */,
 				F90E36D80F3B5C8400810A10 /* DebugNoGC */,
 				F97258AB0A86873D00096C78 /* DebugNoFixAndContinue */,
-				F99EE73F0BE835310060D4AF /* DebugUnthreaded */,
 				F98751320DE7B57E00B1C9EC /* DebugNoCF */,
-				F98751360DE7B5A200B1C9EC /* DebugNoCFUnthreaded */,
 				F93084390BB93D2800CD0B9E /* DebugMemCompile */,
 				F99EE7400BE835310060D4AF /* DebugLeaks */,
 				F9359B280DF212DA00E04F67 /* DebugGCov */,
-				F97AED1D0B660B2100310EA2 /* Debug64bit */,
 				F97258AA0A86873D00096C78 /* Release */,
 				F97258AC0A86873D00096C78 /* ReleaseUniversal */,
 				F9A9D1F60FC77799002A2BE3 /* ReleaseUniversal clang */,
 				F9988BB80D81587400B6B03B /* ReleaseUniversal llvm-gcc */,
 				F9988BB40D81586D00B6B03B /* ReleaseUniversal gcc40 */,

Index: macosx/tkMacOSXBitmap.c
==================================================================
--- macosx/tkMacOSXBitmap.c
+++ macosx/tkMacOSXBitmap.c
@@ -1,20 +1,21 @@
 /*
  * tkMacOSXBitmap.c --
  *
  *	This file handles the implementation of native bitmaps.
  *
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
 #include "tkMacOSXPrivate.h"
 #include "tkMacOSXConstants.h"
+
 /*
  * This structure holds information about native bitmaps.
  */
 
 typedef struct {
@@ -47,26 +48,26 @@
     {NULL,			0}
 };
 
 #define builtInIconSize 32
 
-#define OSTYPE_TO_UTI(x) (NSString *)UTTypeCreatePreferredIdentifierForTag( \
-     kUTTagClassOSType, UTCreateStringForOSType(x), nil)
+#define OSTYPE_TO_UTI(x) ((NSString *)UTTypeCreatePreferredIdentifierForTag( \
+     kUTTagClassOSType, UTCreateStringForOSType(x), nil))
 
 static Tcl_HashTable iconBitmapTable = {};
 typedef struct {
     int kind, width, height;
     char *value;
 } IconBitmap;
 
 static const char *const iconBitmapOptionStrings[] = {
-    "-file", "-fileType", "-osType", "-systemType", "-namedImage",
-    "-imageFile", NULL
+    "-file", "-fileType", "-imageFile", "-namedImage", "-osType",
+    "-systemType", NULL
 };
 enum iconBitmapOptions {
-    ICON_FILE, ICON_FILETYPE, ICON_OSTYPE, ICON_SYSTEMTYPE, ICON_NAMEDIMAGE,
-    ICON_IMAGEFILE,
+    ICON_FILE, ICON_FILETYPE, ICON_IMAGEFILE, ICON_NAMEDIMAGE, ICON_OSTYPE,
+    ICON_SYSTEMTYPE
 };
 
 
 /*
  *----------------------------------------------------------------------
@@ -172,15 +173,14 @@
 Pixmap
 TkpCreateNativeBitmap(
     Display *display,
     const void *source)		/* Info about the icon to build. */
 {
-    NSString *iconUTI = OSTYPE_TO_UTI(PTR2UINT(source));
-    NSImage *iconImage = [[NSWorkspace sharedWorkspace]
-			     iconForFileType: iconUTI];
+    NSString *filetype = [NSString stringWithUTF8String:(char *)source];
+    NSImage *iconImage = TkMacOSXIconForFileType(filetype);
     CGSize size = CGSizeMake(builtInIconSize, builtInIconSize);
-    Pixmap pixmap = PixmapFromImage(display, iconImage, NSSizeToCGSize(size));
+    Pixmap pixmap = PixmapFromImage(display, iconImage, size);
     return pixmap;
 }
 
 
 /*
@@ -203,11 +203,11 @@
 OSTypeFromString(const char *s, OSType *t) {
     int result = TCL_ERROR;
     Tcl_DString ds;
     Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman");
 
-    Tcl_UtfToExternalDString(encoding, s, -1, &ds);
+    (void)Tcl_UtfToExternalDStringEx(encoding, s, -1, TCL_ENCODING_NOCOMPLAIN, &ds);
     if (Tcl_DStringLength(&ds) <= 4) {
 	char string[4] = {};
 	memcpy(string, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
 	*t = (OSType) string[0] << 24 | (OSType) string[1] << 16 |
 	     (OSType) string[2] <<  8 | (OSType) string[3];
@@ -251,15 +251,14 @@
     Tcl_HashEntry *hPtr;
     Pixmap pixmap = None;
     NSString *string;
     NSImage *image = nil;
     NSSize size = { .width = builtInIconSize, .height = builtInIconSize };
-
     if (iconBitmapTable.buckets &&
 	    (hPtr = Tcl_FindHashEntry(&iconBitmapTable, name))) {
 	OSType type;
-	IconBitmap *iconBitmap = Tcl_GetHashValue(hPtr);
+	IconBitmap *iconBitmap = (IconBitmap *)Tcl_GetHashValue(hPtr);
 	name = NULL;
 	size = NSMakeSize(iconBitmap->width, iconBitmap->height);
 	switch (iconBitmap->kind) {
 	case ICON_FILE:
 	    string = [[NSString stringWithUTF8String:iconBitmap->value]
@@ -266,16 +265,16 @@
 		    stringByExpandingTildeInPath];
 	    image = [[NSWorkspace sharedWorkspace] iconForFile:string];
 	    break;
 	case ICON_FILETYPE:
 	    string = [NSString stringWithUTF8String:iconBitmap->value];
-	    image = [[NSWorkspace sharedWorkspace] iconForFileType:string];
+	    image = TkMacOSXIconForFileType(string);
 	    break;
 	case ICON_OSTYPE:
 	    if (OSTypeFromString(iconBitmap->value, &type) == TCL_OK) {
-		string = NSFileTypeForHFSTypeCode(type);
-		image = [[NSWorkspace sharedWorkspace] iconForFileType:string];
+		string = [NSString stringWithUTF8String:iconBitmap->value];
+		image = TkMacOSXIconForFileType(string);
 	    }
 	    break;
 	case ICON_SYSTEMTYPE:
 	    name = iconBitmap->value;
 	    break;
@@ -310,15 +309,19 @@
     if (image) {
 	*width = size.width;
 	*height = size.height;
 	pixmap = PixmapFromImage(display, image, NSSizeToCGSize(size));
     } else if (name) {
+	/*
+	 * As a last resort, try to interpret the name as an OSType.
+	 * It would probably be better to just return None at this
+	 * point.
+	 */
 	OSType iconType;
 	if (OSTypeFromString(name, &iconType) == TCL_OK) {
-	    NSString *iconUTI = OSTYPE_TO_UTI(iconType);
-	    NSImage *iconImage = [[NSWorkspace sharedWorkspace]
-				     iconForFileType: iconUTI];
+	    NSString *iconUTI = TkMacOSXOSTypeToUTI(iconType);
+	    NSImage *iconImage = TkMacOSXIconForFileType(iconUTI);
 	    pixmap = PixmapFromImage(display, iconImage, NSSizeToCGSize(size));
 	}
     }
     return pixmap;
 }
@@ -382,11 +385,11 @@
 #if 0
     if ((kind == ICON_TYPE || kind == ICON_SYSTEM)) {
 	Tcl_DString ds;
  	Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman");
 
-	Tcl_UtfToExternalDString(encoding, value, -1, &ds);
+	(void)Tcl_UtfToExternalDStringEx(encoding, value, -1, TCL_ENCODING_NOCOMPLAIN, &ds);
 	len = Tcl_DStringLength(&ds);
 	Tcl_DStringFree(&ds);
 	Tcl_FreeEncoding(encoding);
 	if (len > 4) {
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
@@ -401,11 +404,11 @@
     if (!iconBitmapTable.buckets) {
 	Tcl_InitHashTable(&iconBitmapTable, TCL_STRING_KEYS);
     }
     hPtr = Tcl_CreateHashEntry(&iconBitmapTable, name, &isNew);
     if (!isNew) {
-	iconBitmap = Tcl_GetHashValue(hPtr);
+	iconBitmap = (IconBitmap *)Tcl_GetHashValue(hPtr);
 	ckfree(iconBitmap->value);
     } else {
 	iconBitmap = (IconBitmap *)ckalloc(sizeof(IconBitmap));
 	Tcl_SetHashValue(hPtr, iconBitmap);
     }

Index: macosx/tkMacOSXButton.c
==================================================================
--- macosx/tkMacOSXButton.c
+++ macosx/tkMacOSXButton.c
@@ -2,16 +2,16 @@
  * tkMacOSXButton.c --
  *
  *	This file implements the Macintosh specific portion of the button
  *	widgets.
  *
- * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright 2007 Revar Desmera.
- * Copyright 2015 Kevin Walzer/WordTech Communications LLC.
- * Copyright 2015 Marc Culler.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 2001 Apple Computer, Inc.
+ * Copyright © 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2007 Revar Desmera.
+ * Copyright © 2015 Kevin Walzer/WordTech Communications LLC.
+ * Copyright © 2015 Marc Culler.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
  */
@@ -179,12 +179,12 @@
 
 void
 TkpDisplayButton(
     ClientData clientData)	/* Information about widget. */
 {
-    MacButton *macButtonPtr = clientData;
-    TkButton *butPtr = clientData;
+    MacButton *macButtonPtr = (MacButton *)clientData;
+    TkButton *butPtr = (TkButton *)clientData;
     Tk_Window tkwin = butPtr->tkwin;
     Pixmap pixmap;
     DrawParams* dpPtr = &macButtonPtr->drawParams;
     int needhighlight = 0;
 
@@ -763,14 +763,16 @@
 	 * state to inactive in Dark Mode unless the button is pressed or is a
 	 * -default active button.  This isn't perfect but it is mostly usable.
 	 * Using a ttk::button would be a much better choice, however.
 	 */
 
-	if (TkMacOSXInDarkMode(butPtr->tkwin) &&
-	    mbPtr->drawinfo.state != kThemeStatePressed &&
-	    !(mbPtr->drawinfo.adornment & kThemeAdornmentDefault)) {
-	    hiinfo.state = kThemeStateInactive;
+	if ([NSApp macOSVersion] < 101500) {
+	    if (TkMacOSXInDarkMode(butPtr->tkwin) &&
+		mbPtr->drawinfo.state != kThemeStatePressed &&
+		!(mbPtr->drawinfo.adornment & kThemeAdornmentDefault)) {
+		hiinfo.state = kThemeStateInactive;
+	    }
 	}
 	HIThemeDrawButton(&cntrRect, &hiinfo, dc.context,
 		kHIThemeOrientationNormal, &contHIRec);
 
 	TkMacOSXRestoreDrawingContext(&dc);
@@ -899,12 +901,12 @@
 static void
 ButtonEventProc(
     ClientData clientData,	/* Information about window. */
     XEvent *eventPtr)		/* Information about event. */
 {
-    TkButton *buttonPtr = clientData;
-    MacButton *mbPtr = clientData;
+    TkButton *buttonPtr = (TkButton *)clientData;
+    MacButton *mbPtr = (MacButton *)clientData;
 
     if (eventPtr->type == ActivateNotify
 	    || eventPtr->type == DeactivateNotify) {
 	if ((buttonPtr->tkwin == NULL) || (!Tk_IsMapped(buttonPtr->tkwin))) {
 	    return;
@@ -955,11 +957,11 @@
         *btnkind = kThemeRoundedBevelButton;
     } else {
         *btnkind = kThemePushButton;
     }
 
-    if ((butPtr->image == None) && (butPtr->bitmap == None)) {
+    if ((butPtr->image == NULL) && (butPtr->bitmap == None)) {
         switch (butPtr->type) {
 	case TYPE_BUTTON:
 	    *btnkind = kThemePushButton;
 	    break;
 	case TYPE_RADIO_BUTTON:
@@ -1172,11 +1174,11 @@
  */
 
 static void
 PulseDefaultButtonProc(ClientData clientData)
 {
-    MacButton *mbPtr = clientData;
+    MacButton *mbPtr = (MacButton *)clientData;
 
     TkpDisplayButton(clientData);
     /*
      * Fix 40ada90762: any idle calls to TkpDisplayButton need to be canceled
      * in case the button is destroyed and has its data freed before the idle

Index: macosx/tkMacOSXClipboard.c
==================================================================
--- macosx/tkMacOSXClipboard.c
+++ macosx/tkMacOSXClipboard.c
@@ -1,13 +1,13 @@
 /*
  * tkMacOSXClipboard.c --
  *
  *	This file manages the clipboard for the Tk toolkit.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -135,17 +135,11 @@
 
 	if (type) {
 	    string = [pb stringForType:type];
 	}
 	if (string) {
-	    if (target == dispPtr->utf8Atom) {
-		result = proc(clientData, interp, string.UTF8String);
-	    } else if (target == XA_STRING) {
-		const char *latin1 = [string
-		    cStringUsingEncoding:NSISOLatin1StringEncoding];
-		result = proc(clientData, interp, latin1);
-	    }
+	    result = proc(clientData, interp, string.UTF8String);
 	}
     } else {
 	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 	     "%s selection doesn't exist or form \"%s\" not defined",
 	     Tk_GetAtomName(tkwin, selection),

Index: macosx/tkMacOSXColor.c
==================================================================
--- macosx/tkMacOSXColor.c
+++ macosx/tkMacOSXColor.c
@@ -3,15 +3,15 @@
  *
  *	This file maintains a database of color values for the Tk
  *	toolkit, in order to avoid round-trips to the server to
  *	map color names to pixel values.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1996 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2020 Marc Culler
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1996 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2020 Marc Culler
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -22,16 +22,18 @@
 static Tcl_HashTable systemColors;
 static int numSystemColors;
 static int rgbColorIndex;
 static int controlAccentIndex;
 static int selectedTabTextIndex;
+static int pressedButtonTextIndex;
 static Bool useFakeAccentColor = NO;
 static SystemColorDatum **systemColorIndex;
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
 static NSAppearance *lightAqua = nil;
 static NSAppearance *darkAqua = nil;
 #endif
+
 static NSColorSpace* sRGB = NULL;
 static const CGFloat WINDOWBACKGROUND[4] =
     {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0};
 
 void initColorTable()
@@ -65,11 +67,12 @@
 					  encoding:NSUTF8StringEncoding];
 	    SEL colorSelector = NSSelectorFromString(colorName);
 	    if (![NSColor respondsToSelector:colorSelector]) {
 		if ([colorName isEqualToString:@"controlAccentColor"]) {
 		    useFakeAccentColor = YES;
-		} else if (![colorName isEqualToString:@"selectedTabTextColor"]) {
+		} else if (   ![colorName isEqualToString:@"selectedTabTextColor"]
+			   && ![colorName isEqualToString:@"pressedButtonTextColor"]) {
 		    /* Uncomment to print all unsupported colors:              */
 		    /* printf("Unsupported color %s\n", colorName.UTF8String); */
 		    continue;
 		}
 	    }
@@ -145,10 +148,13 @@
     entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
     controlAccentIndex = entry->index;
     hPtr = Tcl_FindHashEntry(&systemColors, "SelectedTabTextColor");
     entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
     selectedTabTextIndex = entry->index;
+    hPtr = Tcl_FindHashEntry(&systemColors, "PressedButtonTextColor");
+    entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
+    pressedButtonTextIndex = entry->index;
     [pool drain];
 }
 
 /*
  *----------------------------------------------------------------------
@@ -175,11 +181,11 @@
 TkMacOSXRGBPixel(
     unsigned long red,
     unsigned long green,
     unsigned long blue)
 {
-    MacPixel p;
+    MacPixel p = {0};
     p.pixel.colortype = rgbColor;
     p.pixel.value = ((red & 0xff) << 16)  |
 	            ((green & 0xff) << 8) |
 	            (blue & 0xff);
     return p.ulong;
@@ -205,11 +211,11 @@
  */
 MODULE_SCOPE
 unsigned long TkMacOSXClearPixel(
     void)
 {
-    MacPixel p;
+    MacPixel p = {0};
     p.pixel.value = 0;
     p.pixel.colortype = clearColor;
     return p.ulong;
 }
 
@@ -234,11 +240,11 @@
 
 SystemColorDatum*
 GetEntryFromPixel(
     unsigned long pixel)
 {
-    MacPixel p;
+    MacPixel p = {0};
     int index = rgbColorIndex;
 
     p.ulong = pixel;
     if (p.pixel.colortype != rgbColor) {
 	index = p.pixel.value;
@@ -276,14 +282,16 @@
     SystemColorDatum *entry,
     unsigned long pixel,
     CGFloat *rgba)
 {
     NSColor *bgColor, *color = nil;
+    int OSVersion = [NSApp macOSVersion];
 
     if (!sRGB) {
 	sRGB = [NSColorSpace sRGBColorSpace];
     }
+
     switch (entry->type) {
     case rgbColor:
 	rgba[0] = ((pixel >> 16) & 0xff) / 255.0;
 	rgba[1] = ((pixel >>  8) & 0xff) / 255.0;
 	rgba[2] = ((pixel      ) & 0xff) / 255.0;
@@ -290,11 +298,11 @@
 	break;
     case ttkBackground:
 
 	/*
 	 * Prior to OSX 10.14, getComponents returns black when applied to
-	 * windowBackGroundColor.
+	 * windowBackgroundColor.
 	 */
 
 	if ([NSApp macOSVersion] < 101400) {
 	    for (int i = 0; i < 3; i++) {
 		rgba[i] = WINDOWBACKGROUND[i];
@@ -310,29 +318,38 @@
 	} else {
 	    for (int i=0; i<3; i++) {
 		rgba[i] -= entry->value*8.0 / 255.0;
 	    }
 	}
+	break;
+    case clearColor:
+	rgba[0] = rgba[1] = rgba[2] = 1.0;
+	rgba[3] = 0;
 	break;
     case semantic:
 	if (entry->index == controlAccentIndex && useFakeAccentColor) {
 #if MAC_OS_X_VERSION_MIN_REQUIRED < 101400
 	    color = [[NSColor colorForControlTint: [NSColor currentControlTint]]
 			      colorUsingColorSpace:sRGB];
 #endif
 	} else if (entry->index == selectedTabTextIndex) {
-	    int OSVersion = [NSApp macOSVersion];
 	    if (OSVersion > 100600 && OSVersion < 110000) {
 		color = [[NSColor whiteColor] colorUsingColorSpace:sRGB];
+	    } else {
+		color = [[NSColor textColor] colorUsingColorSpace:sRGB];
+	    }
+	} else if (entry->index == pressedButtonTextIndex) {
+	    if (OSVersion < 120000) {
+		color = [[NSColor whiteColor] colorUsingColorSpace:sRGB];
+	    } else {
+		color = [[NSColor blackColor] colorUsingColorSpace:sRGB];
 	    }
 	} else {
 	    color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB];
 	}
 	[color getComponents: rgba];
 	break;
-    case clearColor:
-	rgba[3] = 0;
     default:
 	break;
     }
 }
 
@@ -371,10 +388,11 @@
 
     NSAutoreleasePool *pool = [NSAutoreleasePool new];
 
     if (entry->type == HIBrush) {
      	OSStatus err = ChkErr(HIThemeBrushCreateCGColor, entry->value, c);
+	[pool drain];
      	return err == noErr;
     }
     GetRGBA(entry, pixel, rgba);
     *c = CGColorCreate(sRGB.CGColorSpace, rgba);
     [pool drain];
@@ -410,14 +428,16 @@
 	    view = TkMacOSXGetNSViewForDrawable((Drawable)winPtr->privatePtr);
 	}
 	if (view) {
 	    name = [[view effectiveAppearance] name];
 	} else {
-	    name = [[NSAppearance currentAppearance] name];
+	    name = [[NSApp effectiveAppearance] name];
 	}
 	return (name == NSAppearanceNameDarkAqua);
     }
+#else
+    (void) tkwin;
 #endif
     return false;
 }
 
 /*
@@ -426,26 +446,25 @@
  * TkSetMacColor --
  *
  *	Sets the components of a CGColorRef from an XColor pixel value.  The
  *      pixel value is used to look up the color in the system color table, and
  *      then SetCGColorComponents is called with the table entry and the pixel
- *      value.
+ *      value.  The parameter macColor should be a pointer to a CGColorRef.
  *
  * Results:
  *      Returns false if the color is not found, true otherwise.
  *
  * Side effects:
- *	The variable macColor is set to a new CGColorRef, the caller is
- *	responsible for releasing it!
+ *	The CGColorRef referenced by the variable macColor may be modified.
  *
  *----------------------------------------------------------------------
  */
 
 int
 TkSetMacColor(
-    unsigned long pixel,		/* Pixel value to convert. */
-    void *macColor)			/* CGColorRef to modify. */
+    unsigned long pixel,	/* Pixel value to convert. */
+    void *macColor)		/* CGColorRef to modify. */
 {
     CGColorRef *color = (CGColorRef*)macColor;
     SystemColorDatum *entry = GetEntryFromPixel(pixel);
 
     if (entry) {
@@ -452,122 +471,10 @@
 	return SetCGColorComponents(entry, pixel, color);
     } else {
 	return false;
     }
 }
-
-/*
- *----------------------------------------------------------------------
- *
- * TkpInitGCCache, TkpFreeGCCache, CopyCachedColor, SetCachedColor --
- *
- *	Maintain a per-GC cache of previously converted CGColorRefs
- *
- * Results:
- *	None resp. retained CGColorRef for CopyCachedColor()
- *
- * Side effects:
- *	None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkpInitGCCache(
-    GC gc)
-{
-    bzero(TkpGetGCCache(gc), sizeof(TkpGCCache));
-}
-
-void
-TkpFreeGCCache(
-    GC gc)
-{
-    TkpGCCache *gcCache = TkpGetGCCache(gc);
-
-    if (gcCache->cachedForegroundColor) {
-	CFRelease(gcCache->cachedForegroundColor);
-    }
-    if (gcCache->cachedBackgroundColor) {
-	CFRelease(gcCache->cachedBackgroundColor);
-    }
-}
-
-static CGColorRef
-CopyCachedColor(
-    GC gc,
-    unsigned long pixel)
-{
-    TkpGCCache *gcCache = TkpGetGCCache(gc);
-    CGColorRef cgColor = NULL;
-
-    if (gcCache) {
-	if (gcCache->cachedForeground == pixel) {
-	    cgColor = gcCache->cachedForegroundColor;
-	} else if (gcCache->cachedBackground == pixel) {
-	    cgColor = gcCache->cachedBackgroundColor;
-	}
-	if (cgColor) {
-	    CFRetain(cgColor);
-	}
-    }
-    return cgColor;
-}
-
-static void
-SetCachedColor(
-    GC gc,
-    unsigned long pixel,
-    CGColorRef cgColor)
-{
-    TkpGCCache *gcCache = TkpGetGCCache(gc);
-
-    if (gcCache && cgColor) {
-	if (gc->foreground == pixel) {
-	    if (gcCache->cachedForegroundColor) {
-		CFRelease(gcCache->cachedForegroundColor);
-	    }
-	    gcCache->cachedForegroundColor = (CGColorRef) CFRetain(cgColor);
-	    gcCache->cachedForeground = pixel;
-	} else if (gc->background == pixel) {
-	    if (gcCache->cachedBackgroundColor) {
-		CFRelease(gcCache->cachedBackgroundColor);
-	    }
-	    gcCache->cachedBackgroundColor = (CGColorRef) CFRetain(cgColor);
-	    gcCache->cachedBackground = pixel;
-	}
-    }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXCreateCGColor --
- *
- *	Creates a CGColorRef from a X style pixel value.
- *
- * Results:
- *	Returns NULL if not a real pixel, CGColorRef otherwise.
- *
- * Side effects:
- *	None
- *
- *----------------------------------------------------------------------
- */
-
-CGColorRef
-TkMacOSXCreateCGColor(
-    GC gc,
-    unsigned long pixel)		/* Pixel value to convert. */
-{
-    CGColorRef cgColor = CopyCachedColor(gc, pixel);
-
-    if (!cgColor && TkSetMacColor(pixel, &cgColor)) {
-	SetCachedColor(gc, pixel, cgColor);
-    }
-    return cgColor;
-}
 
 /*
  *----------------------------------------------------------------------
  *
  * TkMacOSXGetNSColor --
@@ -584,25 +491,22 @@
  *----------------------------------------------------------------------
  */
 
 NSColor*
 TkMacOSXGetNSColor(
-    GC gc,
+    TCL_UNUSED(GC),
     unsigned long pixel)		/* Pixel value to convert. */
 {
-    CGColorRef cgColor = TkMacOSXCreateCGColor(gc, pixel);
+    CGColorRef cgColor = NULL;
     NSColor *nsColor = nil;
 
+    TkSetMacColor(pixel, &cgColor);
     if (cgColor) {
-	NSColorSpace *colorSpace = [[NSColorSpace alloc]
-		initWithCGColorSpace:CGColorGetColorSpace(cgColor)];
-
-	nsColor = [NSColor colorWithColorSpace:colorSpace
-		components:CGColorGetComponents(cgColor)
-		count:CGColorGetNumberOfComponents(cgColor)];
-	[colorSpace release];
-	CFRelease(cgColor);
+	nsColor = [NSColor colorWithColorSpace:sRGB
+			components:CGColorGetComponents(cgColor)
+			count:CGColorGetNumberOfComponents(cgColor)];
+	CGColorRelease(cgColor);
     }
     return nsColor;
 }
 
 /*
@@ -623,16 +527,16 @@
  *----------------------------------------------------------------------
  */
 
 void
 TkMacOSXSetColorInContext(
-    GC gc,
+    TCL_UNUSED(GC),
     unsigned long pixel,
     CGContextRef context)
 {
     OSStatus err = noErr;
-    CGColorRef cgColor = nil;
+    CGColorRef cgColor = NULL;
     SystemColorDatum *entry = GetEntryFromPixel(pixel);
 
     if (entry) {
 	switch (entry->type) {
 	case HIBrush:
@@ -642,13 +546,11 @@
 		err = ChkErr(HIThemeSetStroke, entry->value, NULL, context,
 			kHIThemeOrientationNormal);
 	    }
 	    break;
 	default:
-	    if (SetCGColorComponents(entry, pixel, &cgColor)){
-		SetCachedColor(gc, pixel, cgColor);
-	    }
+	    SetCGColorComponents(entry, pixel, &cgColor);
 	    break;
 	}
     }
     if (cgColor) {
 	CGContextSetFillColorWithColor(context, cgColor);
@@ -693,15 +595,13 @@
     TkColor *tkColPtr;
     XColor color;
     Colormap colormap = tkwin ? Tk_Colormap(tkwin) : noColormap;
     NSView *view = nil;
     static Bool initialized = NO;
-    static NSColorSpace* sRGB = NULL;
 
     if (!initialized) {
 	initialized = YES;
-	sRGB = [NSColorSpace sRGBColorSpace];
 	initColorTable();
     }
     if (tkwin) {
 	display = Tk_Display(tkwin);
 	Drawable d = Tk_WindowId(tkwin);
@@ -712,36 +612,47 @@
      * Check to see if this is a system color. If not, just call XParseColor.
      */
 
     if (strncasecmp(name, "system", 6) == 0) {
 	Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&systemColors, name + 6);
-	MacPixel p;
+	MacPixel p = {0};
 
 	if (hPtr != NULL) {
 	    SystemColorDatum *entry = (SystemColorDatum *)Tcl_GetHashValue(hPtr);
-	    CGColorRef c;
+	    CGColorRef c = NULL;
 
 	    p.pixel.colortype = entry->type;
 	    p.pixel.value = entry->index;
 	    color.pixel = p.ulong;
 	    if (entry->type == semantic) {
 		CGFloat rgba[4];
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
 		if (@available(macOS 10.14, *)) {
-		    NSAppearance *savedAppearance = [NSAppearance currentAppearance];
-		    NSAppearance *windowAppearance = savedAppearance;
+		    NSAppearance *windowAppearance;
 		    if (view) {
 			windowAppearance = [view effectiveAppearance];
+		    } else {
+			windowAppearance = [NSApp effectiveAppearance];
 		    }
 		    if ([windowAppearance name] == NSAppearanceNameDarkAqua) {
 			colormap = darkColormap;
 		    } else {
 			colormap = lightColormap;
 		    }
-		    [NSAppearance setCurrentAppearance:windowAppearance];
-		    GetRGBA(entry, p.ulong, rgba);
-		    [NSAppearance setCurrentAppearance:savedAppearance];
+		    if (@available(macOS 11.0, *)) {
+			CGFloat *rgbaPtr = rgba;
+			[windowAppearance performAsCurrentDrawingAppearance:^{
+				GetRGBA(entry, p.ulong, rgbaPtr);
+			    }];
+		    } else {
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 110000
+			NSAppearance *savedAppearance = [NSAppearance currentAppearance];
+			[NSAppearance setCurrentAppearance:windowAppearance];
+			GetRGBA(entry, p.ulong, rgba);
+			[NSAppearance setCurrentAppearance:savedAppearance];
+#endif
+		    }
 		} else {
 		    GetRGBA(entry, p.ulong, rgba);
 		}
 #else
 		GetRGBA(entry, p.ulong, rgba);

Index: macosx/tkMacOSXColor.h
==================================================================
--- macosx/tkMacOSXColor.h
+++ macosx/tkMacOSXColor.h
@@ -85,11 +85,11 @@
  * constructed.  Failing to ensure this will result in a Tcl_Panic abort.
  */
 
 static SystemColorDatum systemColorData[] = {
 {"Pixel",				rgbColor, 0, NULL, 0, NULL },
-{"Transparent",				clearColor,   0, NULL, 0, NULL },
+{"Transparent",			       	clearColor,   0, NULL, 0, NULL },
 
 {"Highlight",				HIBrush,  kThemeBrushPrimaryHighlightColor, NULL, 0, NULL },
 {"HighlightSecondary",		    	HIBrush,  kThemeBrushSecondaryHighlightColor, NULL, 0, NULL },
 {"HighlightText",			HIBrush,  kThemeBrushBlack, NULL, 0, NULL },
 {"HighlightAlternate",			HIBrush,  kThemeBrushAlternatePrimaryHighlightColor, NULL, 0, NULL },
@@ -173,20 +173,23 @@
 {"WindowBackgroundColor5",	    ttkBackground, 5, NULL, 0, NULL },
 {"WindowBackgroundColor6",	    ttkBackground, 6, NULL, 0, NULL },
 {"WindowBackgroundColor7",	    ttkBackground, 7, NULL, 0, NULL },
 /* Apple's SecondaryLabelColor is the same as their LabelColor so we roll our own. */
 {"SecondaryLabelColor",		    ttkBackground, 14, NULL, 0, NULL },
-/* Color to use for notebook tab labels -- depends on OS version. */
+/* Color to use for notebook tab label text -- depends on OS version. */
 {"SelectedTabTextColor",	    semantic, 0, "textColor", 0, NULL },
+/* Color to use for selected button labels -- depends on OS version. */
+{"PressedButtonTextColor",	    semantic, 0, "textColor", 0, NULL },
 /* Semantic colors that we simulate on older systems which don't supoort them. */
 {"SelectedMenuItemTextColor",       semantic, 0, "selectedMenuItemTextColor", 0, NULL },
 {"ControlAccentColor",		    semantic, 0, "controlAccentColor", 0, NULL },
 {"LabelColor",                      semantic, 0, "blackColor", 0, NULL },
 {"LinkColor",			    semantic, 0, "blueColor", 0, NULL },
 {"PlaceholderTextColor",	    semantic, 0, "grayColor", 0, NULL },
 {"SeparatorColor",		    semantic, 0, "grayColor", 0, NULL },
-{NULL,				    0, 0, NULL, 0, NULL }
+{"UnemphasizedSelectedTextBackgroundColor", semantic, 0, "grayColor", 0, NULL },
+{NULL,				    rgbColor, 0, NULL, 0, NULL }
 };
 
 #endif
 /*
  * Local Variables:

Index: macosx/tkMacOSXConfig.c
==================================================================
--- macosx/tkMacOSXConfig.c
+++ macosx/tkMacOSXConfig.c
@@ -2,12 +2,12 @@
  * tkMacOSXConfig.c --
  *
  *	This module implements the Macintosh system defaults for
  *	the configuration package.
  *
- * Copyright (c) 1997 by Sun Microsystems, Inc.
- * Copyright 2001, Apple Inc.
+ * Copyright © 1997 Sun Microsystems, Inc.
+ * Copyright © 2001, Apple Inc.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -15,11 +15,11 @@
 
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpGetSystemDefault --
+ * Tk_GetSystemDefault --
  *
  *	Given a dbName and className for a configuration option,
  *	return a string representation of the option.
  *
  * Results:
@@ -32,11 +32,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 Tcl_Obj *
-TkpGetSystemDefault(
+Tk_GetSystemDefault(
     Tk_Window tkwin,			/* A window to use. */
     const char *dbName,			/* The option database name. */
     const char *className)		/* The name of the option class. */
 {
     (void)tkwin;

Index: macosx/tkMacOSXConstants.h
==================================================================
--- macosx/tkMacOSXConstants.h
+++ macosx/tkMacOSXConstants.h
@@ -4,11 +4,11 @@
  *	Macros which map the names of NS constants used in the Tk code to
  *      the new name that Apple came up with for subsequent versions of the
  *      operating system.  (Each new OS release seems to come with a new
  *      naming convention for the same old constants.)
  *
- * Copyright (c) 2017 Marc Culler
+ * Copyright © 2017 Marc Culler
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -77,15 +77,17 @@
 #define NSNumericPadKeyMask NSEventModifierFlagNumericPad
 #define NSFunctionKeyMask NSEventModifierFlagFunction
 #define NSCursorUpdate NSEventTypeCursorUpdate
 #define NSTexturedBackgroundWindowMask NSWindowStyleMaskTexturedBackground
 #define NSCompositeCopy NSCompositingOperationCopy
+#define NSCompositeSourceOver NSCompositingOperationSourceOver
+#define NSCompositeSourceAtop NSCompositingOperationSourceAtop
+#define NSCompositeDestinationIn NSCompositingOperationDestinationIn
 #define NSWarningAlertStyle NSAlertStyleWarning
 #define NSInformationalAlertStyle NSAlertStyleInformational
 #define NSCriticalAlertStyle NSAlertStyleCritical
 #define NSCenterTextAlignment NSTextAlignmentCenter
-#define NSAnyEventMask NSEventMaskAny
 #define NSApplicationDefinedMask NSEventMaskApplicationDefined
 #define NSUtilityWindowMask NSWindowStyleMaskUtilityWindow
 #define NSNonactivatingPanelMask NSWindowStyleMaskNonactivatingPanel
 #define NSDocModalWindowMask NSWindowStyleMaskDocModalWindow
 #define NSHUDWindowMask NSWindowStyleMaskHUDWindow
@@ -94,10 +96,15 @@
 #define NSResizableWindowMask NSWindowStyleMaskResizable
 #define NSUnifiedTitleAndToolbarWindowMask NSWindowStyleMaskUnifiedTitleAndToolbar
 #define NSMiniaturizableWindowMask NSWindowStyleMaskMiniaturizable
 #define NSBorderlessWindowMask NSWindowStyleMaskBorderless
 #define NSFullScreenWindowMask NSWindowStyleMaskFullScreen
+#define NSAlphaFirstBitmapFormat NSBitmapFormatAlphaFirst
+#define NSAnyEventMask NSEventMaskAny
+#define NSLeftMouseDownMask NSEventMaskLeftMouseDown
+#define NSMouseMovedMask NSEventMaskMouseMoved
+#define NSLeftMouseDraggedMask NSEventMaskLeftMouseDragged
 #endif
 
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
 #define NSStringPboardType NSPasteboardTypeString
 #define NSOnState NSControlStateValueOn

Index: macosx/tkMacOSXCursor.c
==================================================================
--- macosx/tkMacOSXCursor.c
+++ macosx/tkMacOSXCursor.c
@@ -1,13 +1,13 @@
 /*
  * tkMacOSXCursor.c --
  *
  *	This file contains Macintosh specific cursor related routines.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -260,11 +260,11 @@
 	    case IMAGEPATH:
 		path = [NSApp tkFrameworkImagePath:cursorNames[idx].id1];
 		break;
 	    case IMAGEBITMAP: {
 		unsigned char *bitmap = (unsigned char *)(cursorNames[idx].id1);
-		NSBitmapImageRep *bitmapImageRep = NULL;
+		NSBitmapImageRep *bitmapImageRep = nil;
 		CGImageRef img = NULL, mask = NULL, maskedImg = NULL;
 		static const CGFloat decodeWB[] = {1, 0};
 		CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(
 			kCGColorSpaceGenericGray);
 		CGDataProviderRef provider = CGDataProviderCreateWithData(NULL,
@@ -370,11 +370,11 @@
     Tk_Uid string)		/* Description of cursor. See manual entry
 				 * for details on legal syntax. */
 {
     TkMacOSXCursor *macCursorPtr = NULL;
     const char **argv = NULL;
-    int argc;
+    TkSizeT argc;
 
     /*
      * All cursor names are valid lists of one element (for
      * TkX11-compatibility), even unadorned system cursor names.
      */
@@ -455,11 +455,11 @@
     TkCursor *cursorPtr)
 {
     TkMacOSXCursor *macCursorPtr = (TkMacOSXCursor *) cursorPtr;
 
     [macCursorPtr->macCursor release];
-    macCursorPtr->macCursor = NULL;
+    macCursorPtr->macCursor = nil;
     if (macCursorPtr == gCurrentCursor) {
 	gCurrentCursor = NULL;
     }
 }
 
@@ -534,11 +534,11 @@
 TkpSetCursor(
     TkpCursor cursor)
 {
     int cursorChanged = 1;
 
-    if (cursor == None) {
+    if (cursor == NULL) {
 	/*
 	 * This is a little tricky. We can't really tell whether
 	 * gCurrentCursor is NULL because it was NULL last time around or
 	 * because we just freed the current cursor. So if the input cursor is
 	 * NULL, we always need to reset it, we can't trust the cursorChanged

Index: macosx/tkMacOSXCursors.h
==================================================================
--- macosx/tkMacOSXCursors.h
+++ macosx/tkMacOSXCursors.h
@@ -2,13 +2,13 @@
  * tkMacOSXCursors.h --
  *
  *	This file defines a set of Macintosh cursor resources that
  *	are only available on the Macintosh platform.
  *
- * Copyright (c) 1995-1996 Sun Microsystems, Inc.
- * Copyright 2008-2009, Apple Inc.
- * Copyright (c) 2008-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 1995-1996 Sun Microsystems, Inc.
+ * Copyright © 2008-2009 Apple Inc.
+ * Copyright © 2008-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: macosx/tkMacOSXDebug.c
==================================================================
--- macosx/tkMacOSXDebug.c
+++ macosx/tkMacOSXDebug.c
@@ -2,12 +2,12 @@
  * tkMacOSXDebug.c --
  *
  *	Implementation of Macintosh specific functions for debugging MacOS
  *	events, regions, etc...
  *
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2001-2009, Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: macosx/tkMacOSXDebug.h
==================================================================
--- macosx/tkMacOSXDebug.h
+++ macosx/tkMacOSXDebug.h
@@ -2,12 +2,12 @@
  * tkMacOSXDebug.h --
  *
  *	Declarations of Macintosh specific functions for debugging MacOS events,
  *	regions, etc...
  *
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2001-2009, Apple Inc.
+ * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: macosx/tkMacOSXDefault.h
==================================================================
--- macosx/tkMacOSXDefault.h
+++ macosx/tkMacOSXDefault.h
@@ -40,23 +40,24 @@
 #define NORMAL_FG		"systemTextColor"
 #define ACTIVE_BG		"systemWindowBackgroundColor"
 #define ACTIVE_FG		"systemTextColor"
 #define SELECT_BG		"systemSelectedTextBackgroundColor"
 #define SELECT_FG		"systemSelectedTextColor"
-#define INACTIVE_SELECT_BG	"systemSelectedTextBackgroundColor"
+#define INACTIVE_SELECT_BG	"systemUnemphasizedSelectedTextBackgroundColor"
 #define TROUGH			"#c3c3c3"
 #define INDICATOR		"#b03060"
 #define DISABLED		"systemDisabledControlTextColor"
+#define IGNORED                 "#abcdef"
 
 /*
  * Defaults for labels, buttons, checkbuttons, and radiobuttons:
  */
 
 #define DEF_BUTTON_ANCHOR		"center"
 #define DEF_BUTTON_ACTIVE_BG_COLOR	ACTIVE_BG
 #define DEF_BUTTON_ACTIVE_BG_MONO	BLACK
-#define DEF_BUTTON_ACTIVE_FG_COLOR	WHITE
+#define DEF_BUTTON_ACTIVE_FG_COLOR	"systemPressedButtonTextColor"
 #define DEF_CHKRAD_ACTIVE_FG_COLOR	ACTIVE_FG
 #define DEF_BUTTON_ACTIVE_FG_MONO	WHITE
 #define DEF_BUTTON_BG_COLOR		NORMAL_BG
 #define DEF_BUTTON_BG_MONO		WHITE
 #define DEF_BUTTON_BITMAP		""
@@ -65,17 +66,18 @@
 #define DEF_BUTTON_COMMAND		""
 #define DEF_BUTTON_COMPOUND		"none"
 #define DEF_BUTTON_DEFAULT		"disabled"
 #define DEF_BUTTON_DISABLED_FG_COLOR	DISABLED
 #define DEF_BUTTON_DISABLED_FG_MONO	""
-#define DEF_BUTTON_FG			NORMAL_FG
-#define DEF_CHKRAD_FG			DEF_BUTTON_FG
+#define DEF_BUTTON_FG			BLACK
+#define DEF_LABEL_FG			NORMAL_FG
+#define DEF_CHKRAD_FG			DEF_LABEL_FG
 #define DEF_BUTTON_FONT			"TkDefaultFont"
 #define DEF_BUTTON_HEIGHT		"0"
 #define DEF_BUTTON_HIGHLIGHT_BG_COLOR	DEF_BUTTON_BG_COLOR
 #define DEF_BUTTON_HIGHLIGHT_BG_MONO	DEF_BUTTON_BG_MONO
-#define DEF_BUTTON_HIGHLIGHT		"systemButtonFrame"
+#define DEF_BUTTON_HIGHLIGHT		NORMAL_FG
 #define DEF_LABEL_HIGHLIGHT_WIDTH	"0"
 //#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
 //#define DEF_BUTTON_HIGHLIGHT_WIDTH	"4"
 //#define DEF_BUTTON_HIGHLIGHT_WIDTH_NOCM	"1"
 //#else
@@ -86,23 +88,13 @@
 #define DEF_BUTTON_JUSTIFY		"center"
 #define DEF_BUTTON_OFF_VALUE		"0"
 #define DEF_BUTTON_ON_VALUE		"1"
 #define DEF_BUTTON_TRISTATE_VALUE	""
 #define DEF_BUTTON_OVER_RELIEF		""
-//#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
-//#define DEF_BUTTON_PADX			"12"
-//#define DEF_BUTTON_PADX_NOCM		"1"
-//#else
 #define DEF_BUTTON_PADX			"1"
-//#endif
 #define DEF_LABCHKRAD_PADX		"1"
-//#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS
-//#define DEF_BUTTON_PADY			"3"
-//#define DEF_BUTTON_PADY_NOCM		"1"
-//#else
 #define DEF_BUTTON_PADY			"1"
-//#endif
 #define DEF_LABCHKRAD_PADY		"1"
 #define DEF_BUTTON_RELIEF		"flat"
 #define DEF_LABCHKRAD_RELIEF		"flat"
 #define DEF_BUTTON_REPEAT_DELAY		"0"
 #define DEF_BUTTON_REPEAT_INTERVAL	"0"
@@ -112,11 +104,10 @@
 #define DEF_BUTTON_STATE		"normal"
 #define DEF_LABEL_TAKE_FOCUS		"0"
 #define DEF_BUTTON_TAKE_FOCUS		NULL
 #define DEF_BUTTON_TEXT			""
 #define DEF_BUTTON_TEXT_VARIABLE	""
-#define DEF_BUTTON_UNDERLINE		"-1"
 #define DEF_BUTTON_VALUE		""
 #define DEF_BUTTON_WIDTH		"0"
 #define DEF_BUTTON_WRAP_LENGTH		"0"
 #define DEF_RADIOBUTTON_VARIABLE	"selectedButton"
 #define DEF_CHECKBUTTON_VARIABLE	""
@@ -131,11 +122,11 @@
 #define DEF_CANVAS_CLOSE_ENOUGH		"1"
 #define DEF_CANVAS_CONFINE		"1"
 #define DEF_CANVAS_CURSOR		""
 #define DEF_CANVAS_HEIGHT		"7c"
 #define DEF_CANVAS_HIGHLIGHT_BG		NORMAL_BG
-#define DEF_CANVAS_HIGHLIGHT		BLACK
+#define DEF_CANVAS_HIGHLIGHT		NORMAL_FG
 #define DEF_CANVAS_HIGHLIGHT_WIDTH	"3"
 #define DEF_CANVAS_INSERT_BG		BLACK
 #define DEF_CANVAS_INSERT_BD_COLOR	"0"
 #define DEF_CANVAS_INSERT_BD_MONO	"0"
 #define DEF_CANVAS_INSERT_OFF_TIME	"300"
@@ -181,11 +172,11 @@
 #define DEF_ENTRY_DISABLED_FG		DISABLED
 #define DEF_ENTRY_EXPORT_SELECTION	"1"
 #define DEF_ENTRY_FONT			"TkTextFont"
 #define DEF_ENTRY_FG			NORMAL_FG
 #define DEF_ENTRY_HIGHLIGHT_BG		NORMAL_BG
-#define DEF_ENTRY_HIGHLIGHT		BLACK
+#define DEF_ENTRY_HIGHLIGHT		NORMAL_FG
 #define DEF_ENTRY_HIGHLIGHT_WIDTH	"3"
 #define DEF_ENTRY_INSERT_BG		NORMAL_FG
 #define DEF_ENTRY_INSERT_BD_COLOR	"0"
 #define DEF_ENTRY_INSERT_BD_MONO	"0"
 #define DEF_ENTRY_INSERT_OFF_TIME	"300"
@@ -223,11 +214,11 @@
 #define DEF_FRAME_COLORMAP		""
 #define DEF_FRAME_CONTAINER		"0"
 #define DEF_FRAME_CURSOR		""
 #define DEF_FRAME_HEIGHT		"0"
 #define DEF_FRAME_HIGHLIGHT_BG		NORMAL_BG
-#define DEF_FRAME_HIGHLIGHT		BLACK
+#define DEF_FRAME_HIGHLIGHT		NORMAL_FG
 #define DEF_FRAME_HIGHLIGHT_WIDTH	"0"
 #define DEF_FRAME_PADX			"0"
 #define DEF_FRAME_PADY			"0"
 #define DEF_FRAME_RELIEF		"flat"
 #define DEF_FRAME_TAKE_FOCUS		"0"
@@ -259,11 +250,11 @@
 #define DEF_LISTBOX_EXPORT_SELECTION	"1"
 #define DEF_LISTBOX_FONT		"TkTextFont"
 #define DEF_LISTBOX_FG			NORMAL_FG
 #define DEF_LISTBOX_HEIGHT		"10"
 #define DEF_LISTBOX_HIGHLIGHT_BG	NORMAL_BG
-#define DEF_LISTBOX_HIGHLIGHT		BLACK
+#define DEF_LISTBOX_HIGHLIGHT		NORMAL_FG
 #define DEF_LISTBOX_HIGHLIGHT_WIDTH	"0"
 #define DEF_LISTBOX_JUSTIFY		"left"
 #define DEF_LISTBOX_RELIEF		"solid"
 #define DEF_LISTBOX_SCROLL_COMMAND	""
 #define DEF_LISTBOX_LIST_VARIABLE	""
@@ -303,34 +294,33 @@
 #define DEF_MENU_ENTRY_STATE		"normal"
 #define DEF_MENU_ENTRY_VALUE		NULL
 #define DEF_MENU_ENTRY_CHECK_VARIABLE	NULL
 #define DEF_MENU_ENTRY_RADIO_VARIABLE	"selectedButton"
 #define DEF_MENU_ENTRY_SELECT		NULL
-#define DEF_MENU_ENTRY_UNDERLINE	"-1"
 
 /*
  * Defaults for menus overall:
  */
 
-#define DEF_MENU_ACTIVE_BG_COLOR	NORMAL_BG /*ignored*/
-#define DEF_MENU_ACTIVE_BG_MONO		NORMAL_BG /*ignored*/
+#define DEF_MENU_ACTIVE_BG_COLOR	IGNORED
+#define DEF_MENU_ACTIVE_BG_MONO		IGNORED
 #define DEF_MENU_ACTIVE_BORDER_WIDTH	"0"
-#define DEF_MENU_ACTIVE_FG_COLOR	NORMAL_FG
-#define DEF_MENU_ACTIVE_FG_MONO		NORMAL_FG
+#define DEF_MENU_ACTIVE_FG_COLOR	IGNORED
+#define DEF_MENU_ACTIVE_FG_MONO		IGNORED
 #define DEF_MENU_ACTIVE_RELIEF		"flat"
-#define DEF_MENU_BG_COLOR		NORMAL_BG /*ignored*/
-#define DEF_MENU_BG_MONO		NORMAL_BG /*ignored*/
+#define DEF_MENU_BG_COLOR		"#000001" /* Detects custom bg. */
+#define DEF_MENU_BG_MONO		IGNORED
 #define DEF_MENU_BORDER_WIDTH		"0"
 #define DEF_MENU_CURSOR			"arrow"
-#define DEF_MENU_DISABLED_FG_COLOR	DISABLED
-#define DEF_MENU_DISABLED_FG_MONO	DISABLED
+#define DEF_MENU_DISABLED_FG_COLOR	IGNORED
+#define DEF_MENU_DISABLED_FG_MONO	""
 #define DEF_MENU_FONT			"menu" /* special: see tkMacOSXMenu.c */
-#define DEF_MENU_FG			NORMAL_FG
+#define DEF_MENU_FG			"#010000"  /* Detects custom fg. */
 #define DEF_MENU_POST_COMMAND		""
 #define DEF_MENU_RELIEF			"flat"
-#define DEF_MENU_SELECT_COLOR		"systemSelectedMenuItemTextColor"
-#define DEF_MENU_SELECT_MONO		"systemSelectedMenuItemTextColor"
+#define DEF_MENU_SELECT_COLOR		IGNORED
+#define DEF_MENU_SELECT_MONO		IGNORED
 #define DEF_MENU_TAKE_FOCUS		"0"
 #define DEF_MENU_TEAROFF		"0"
 #define DEF_MENU_TEAROFF_CMD		NULL
 #define DEF_MENU_TITLE			""
 #define DEF_MENU_TYPE			"normal"
@@ -355,11 +345,11 @@
 #define DEF_MENUBUTTON_FONT		"TkDefaultFont"
 #define DEF_MENUBUTTON_FG		NORMAL_FG
 #define DEF_MENUBUTTON_HEIGHT		"0"
 #define DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR DEF_MENUBUTTON_BG_COLOR
 #define DEF_MENUBUTTON_HIGHLIGHT_BG_MONO  DEF_MENUBUTTON_BG_MONO
-#define DEF_MENUBUTTON_HIGHLIGHT	NORMAL_BG
+#define DEF_MENUBUTTON_HIGHLIGHT	NORMAL_FG
 #define DEF_MENUBUTTON_HIGHLIGHT_WIDTH	"0"
 #define DEF_MENUBUTTON_IMAGE		NULL
 #define DEF_MENUBUTTON_INDICATOR	"1"
 #define DEF_MENUBUTTON_JUSTIFY		"left"
 #define DEF_MENUBUTTON_MENU		""
@@ -368,11 +358,10 @@
 #define DEF_MENUBUTTON_RELIEF		"flat"
 #define DEF_MENUBUTTON_STATE		"normal"
 #define DEF_MENUBUTTON_TAKE_FOCUS	"0"
 #define DEF_MENUBUTTON_TEXT		""
 #define DEF_MENUBUTTON_TEXT_VARIABLE	""
-#define DEF_MENUBUTTON_UNDERLINE	"-1"
 #define DEF_MENUBUTTON_WIDTH		"0"
 #define DEF_MENUBUTTON_WRAP_LENGTH	"0"
 
 /*
  * Defaults for messages:
@@ -385,11 +374,11 @@
 #define DEF_MESSAGE_BORDER_WIDTH	"1"
 #define DEF_MESSAGE_CURSOR		""
 #define DEF_MESSAGE_FG			NORMAL_FG
 #define DEF_MESSAGE_FONT		"TkDefaultFont"
 #define DEF_MESSAGE_HIGHLIGHT_BG	NORMAL_BG
-#define DEF_MESSAGE_HIGHLIGHT		BLACK
+#define DEF_MESSAGE_HIGHLIGHT		NORMAL_FG
 #define DEF_MESSAGE_HIGHLIGHT_WIDTH	"0"
 #define DEF_MESSAGE_JUSTIFY		"left"
 #define DEF_MESSAGE_PADX		"-1"
 #define DEF_MESSAGE_PADY		"-1"
 #define DEF_MESSAGE_RELIEF		"flat"
@@ -451,11 +440,11 @@
 #define DEF_SCALE_FG_COLOR		NORMAL_FG
 #define DEF_SCALE_FG_MONO		BLACK
 #define DEF_SCALE_FROM			"0"
 #define DEF_SCALE_HIGHLIGHT_BG_COLOR	DEF_SCALE_BG_COLOR
 #define DEF_SCALE_HIGHLIGHT_BG_MONO	DEF_SCALE_BG_MONO
-#define DEF_SCALE_HIGHLIGHT		BLACK
+#define DEF_SCALE_HIGHLIGHT		NORMAL_FG
 #define DEF_SCALE_HIGHLIGHT_WIDTH	"0"
 #define DEF_SCALE_LABEL			""
 #define DEF_SCALE_LENGTH		"100"
 #define DEF_SCALE_ORIENT		"vertical"
 #define DEF_SCALE_RELIEF		"flat"
@@ -486,11 +475,11 @@
 #define DEF_SCROLLBAR_BORDER_WIDTH	"0"
 #define DEF_SCROLLBAR_COMMAND		""
 #define DEF_SCROLLBAR_CURSOR		""
 #define DEF_SCROLLBAR_EL_BORDER_WIDTH	"-1"
 #define DEF_SCROLLBAR_HIGHLIGHT_BG	NORMAL_BG
-#define DEF_SCROLLBAR_HIGHLIGHT		BLACK
+#define DEF_SCROLLBAR_HIGHLIGHT		NORMAL_FG
 #define DEF_SCROLLBAR_HIGHLIGHT_WIDTH	"0"
 #define DEF_SCROLLBAR_JUMP		"0"
 #define DEF_SCROLLBAR_ORIENT		"vertical"
 #define DEF_SCROLLBAR_RELIEF		"flat"
 #define DEF_SCROLLBAR_REPEAT_DELAY	"300"
@@ -513,11 +502,11 @@
 #define DEF_TEXT_FG			NORMAL_FG
 #define DEF_TEXT_EXPORT_SELECTION	"1"
 #define DEF_TEXT_FONT			"TkFixedFont"
 #define DEF_TEXT_HEIGHT			"24"
 #define DEF_TEXT_HIGHLIGHT_BG		NORMAL_BG
-#define DEF_TEXT_HIGHLIGHT		BLACK
+#define DEF_TEXT_HIGHLIGHT		NORMAL_FG
 #define DEF_TEXT_HIGHLIGHT_WIDTH	"3"
 #define DEF_TEXT_INSERT_BG		NORMAL_FG
 #define DEF_TEXT_INSERT_BD_COLOR	"0"
 #define DEF_TEXT_INSERT_BD_MONO		"0"
 #define DEF_TEXT_INSERT_OFF_TIME	"300"

Index: macosx/tkMacOSXDialog.c
==================================================================
--- macosx/tkMacOSXDialog.c
+++ macosx/tkMacOSXDialog.c
@@ -2,13 +2,14 @@
  * tkMacOSXDialog.c --
  *
  *	Contains the Mac implementation of the common dialog boxes.
  *
  * Copyright (c) 1996-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2001-2009, Apple Inc.
  * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2017 Christian Gollwitzer.
+ * Copyright (c) 2017 Christian Gollwitzer
+ * Copyright (c) 2022 Marc Culler
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -21,12 +22,36 @@
 #define modalCancel NSCancelButton
 #else
 #define modalOK     NSModalResponseOK
 #define modalCancel NSModalResponseCancel
 #endif // MAC_OS_X_VERSION_MIN_REQUIRED < 1090
-#define modalOther  -1 // indicates that the -command option was used. 
+#define modalOther  -1 // indicates that the -command option was used.
 #define modalError  -2
+
+static void setAllowedFileTypes(
+    NSSavePanel *panel,
+    NSMutableArray *extensions)
+{
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
+/* UTType exists in the SDK */
+    if (@available(macOS 11.0, *)) {
+	NSMutableArray<UTType *> *allowedTypes = [NSMutableArray array];
+	for (NSString *ext in extensions) {
+	    UTType *uttype = [UTType typeWithFilenameExtension: ext];
+	    [allowedTypes addObject:uttype];
+	}
+	[panel setAllowedContentTypes:allowedTypes];
+    } else {
+# if MAC_OS_X_VERSION_MIN_REQUIRED < 110000
+/* setAllowedFileTypes is not deprecated */
+	[panel setAllowedFileTypes:extensions];
+#endif
+    }
+#else
+    [panel setAllowedFileTypes:extensions];
+#endif
+}
 
 /*
  * Vars for filtering in "open file" and "save file" dialogs.
  */
 
@@ -66,36 +91,36 @@
 enum colorOptions {
     COLOR_INITIAL, COLOR_PARENT, COLOR_TITLE
 };
 
 static const char *const openOptionStrings[] = {
-    "-defaultextension", "-filetypes", "-initialdir", "-initialfile",
-    "-message", "-multiple", "-parent", "-title", "-typevariable",
-    "-command", NULL
+    "-command", "-defaultextension", "-filetypes", "-initialdir",
+    "-initialfile", "-message", "-multiple", "-parent", "-title",
+    "-typevariable", NULL
 };
 enum openOptions {
-    OPEN_DEFAULT, OPEN_FILETYPES, OPEN_INITDIR, OPEN_INITFILE,
-    OPEN_MESSAGE, OPEN_MULTIPLE, OPEN_PARENT, OPEN_TITLE,
-    OPEN_TYPEVARIABLE, OPEN_COMMAND,
+    OPEN_COMMAND, OPEN_DEFAULT, OPEN_FILETYPES, OPEN_INITDIR,
+    OPEN_INITFILE, OPEN_MESSAGE, OPEN_MULTIPLE, OPEN_PARENT, OPEN_TITLE,
+    OPEN_TYPEVARIABLE
 };
 static const char *const saveOptionStrings[] = {
-    "-defaultextension", "-filetypes", "-initialdir", "-initialfile",
-    "-message", "-parent", "-title", "-typevariable", "-command",
-    "-confirmoverwrite", NULL
+    "-command", "-confirmoverwrite", "-defaultextension", "-filetypes",
+    "-initialdir", "-initialfile", "-message", "-parent", "-title",
+    "-typevariable", NULL
 };
 enum saveOptions {
-    SAVE_DEFAULT, SAVE_FILETYPES, SAVE_INITDIR, SAVE_INITFILE,
-    SAVE_MESSAGE, SAVE_PARENT, SAVE_TITLE, SAVE_TYPEVARIABLE, SAVE_COMMAND,
-    SAVE_CONFIRMOW
+    SAVE_COMMAND, SAVE_CONFIRMOW, SAVE_DEFAULT, SAVE_FILETYPES,
+    SAVE_INITDIR, SAVE_INITFILE, SAVE_MESSAGE, SAVE_PARENT, SAVE_TITLE,
+    SAVE_TYPEVARIABLE
 };
 static const char *const chooseOptionStrings[] = {
-    "-initialdir", "-message", "-mustexist", "-parent", "-title", "-command",
+    "-command", "-initialdir", "-message", "-mustexist", "-parent", "-title",
     NULL
 };
 enum chooseOptions {
-    CHOOSE_INITDIR, CHOOSE_MESSAGE, CHOOSE_MUSTEXIST, CHOOSE_PARENT,
-    CHOOSE_TITLE, CHOOSE_COMMAND,
+    CHOOSE_COMMAND, CHOOSE_INITDIR, CHOOSE_MESSAGE, CHOOSE_MUSTEXIST,
+    CHOOSE_PARENT, CHOOSE_TITLE
 };
 typedef struct {
     Tcl_Interp *interp;
     Tcl_Obj *cmdObj;
     int multiple;
@@ -105,11 +130,11 @@
     "-default", "-detail", "-icon", "-message", "-parent", "-title",
     "-type", "-command", NULL
 };
 enum alertOptions {
     ALERT_DEFAULT, ALERT_DETAIL, ALERT_ICON, ALERT_MESSAGE, ALERT_PARENT,
-    ALERT_TITLE, ALERT_TYPE, ALERT_COMMAND,
+    ALERT_TITLE, ALERT_TYPE, ALERT_COMMAND
 };
 typedef struct {
     Tcl_Interp *interp;
     Tcl_Obj *cmdObj;
     int typeIndex;
@@ -217,13 +242,13 @@
     return YES;
 }
 
 - (void) tkFilePanelDidEnd: (NSSavePanel *) panel
 		returnCode: (NSModalResponse) returnCode
-	       contextInfo: (void *) contextInfo
+	       contextInfo: (const void *) contextInfo
 {
-    FilePanelCallbackInfo *callbackInfo = contextInfo;
+    const FilePanelCallbackInfo *callbackInfo = (const FilePanelCallbackInfo *)contextInfo;
 
     if (returnCode == modalOK) {
 	Tcl_Obj *resultObj;
 
 	if (callbackInfo->multiple) {
@@ -252,23 +277,17 @@
 	    Tcl_SetObjResult(callbackInfo->interp, resultObj);
 	}
     } else if (returnCode == modalCancel) {
 	Tcl_ResetResult(callbackInfo->interp);
     }
-    if (callbackInfo->cmdObj) {
-	Tcl_DecrRefCount(callbackInfo->cmdObj);
-    }
-    if (callbackInfo) {
-	ckfree(callbackInfo);
-    }
     [NSApp stopModalWithCode:returnCode];
 }
 
 - (void) tkAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode
-	contextInfo: (void *) contextInfo
+	contextInfo: (const void *) contextInfo
 {
-    AlertCallbackInfo *callbackInfo = contextInfo;
+    AlertCallbackInfo *callbackInfo = (AlertCallbackInfo *)contextInfo;
 
     if (returnCode >= NSAlertFirstButtonReturn) {
 	Tcl_Obj *resultObj = Tcl_NewStringObj(alertButtonStrings[
 		alertNativeButtonIndexAndTypeToButtonIndex[callbackInfo->
 		typeIndex][returnCode - NSAlertFirstButtonReturn]], -1);
@@ -291,20 +310,15 @@
 	}
     }
     if ([alert window] == [NSApp modalWindow]) {
 	[NSApp stopModalWithCode:returnCode];
     }
-    if (callbackInfo->cmdObj) {
-	Tcl_DecrRefCount(callbackInfo->cmdObj);
-	ckfree(callbackInfo);
-    }
 }
 
 - (void)selectFormat:(id)sender  {
     NSPopUpButton *button      = (NSPopUpButton *)sender;
     filterInfo.fileTypeIndex   = [button indexOfSelectedItem];
-
     if ([[filterInfo.fileTypeAllowsAll objectAtIndex:filterInfo.fileTypeIndex] boolValue]) {
 	[openpanel setAllowsOtherFileTypes:YES];
 
 	/*
 	 * setAllowsOtherFileTypes might have no effect; it's inherited from
@@ -311,15 +325,15 @@
 	 * the NSSavePanel, where it has the effect that it does not append an
 	 * extension. Setting the allowed file types to nil allows selecting
 	 * any file.
 	 */
 
-	[openpanel setAllowedFileTypes:nil];
+	setAllowedFileTypes(openpanel, nil);
     } else {
 	NSMutableArray *allowedtypes =
 		[filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex];
-	[openpanel setAllowedFileTypes:allowedtypes];
+	setAllowedFileTypes(openpanel, allowedtypes);
 	[openpanel setAllowsOtherFileTypes:NO];
     }
 
     filterInfo.userHasSelectedFilter = true;
 }
@@ -328,15 +342,15 @@
     NSPopUpButton *button     = (NSPopUpButton *)sender;
     filterInfo.fileTypeIndex  = [button indexOfSelectedItem];
 
     if ([[filterInfo.fileTypeAllowsAll objectAtIndex:filterInfo.fileTypeIndex] boolValue]) {
 	[savepanel setAllowsOtherFileTypes:YES];
-	[savepanel setAllowedFileTypes:nil];
+	setAllowedFileTypes(savepanel, nil);
     } else {
 	NSMutableArray *allowedtypes =
 		[filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex];
-	[savepanel setAllowedFileTypes:allowedtypes];
+	setAllowedFileTypes(savepanel, allowedtypes);
 	[savepanel setAllowsOtherFileTypes:NO];
     }
 
     filterInfo.userHasSelectedFilter = true;
 }
@@ -346,58 +360,54 @@
 #pragma mark -
 
 static NSInteger showOpenSavePanel(
     NSSavePanel *panel,
     NSWindow *parent,
-    FilePanelCallbackInfo *callbackInfo)
+    Tcl_Interp *interp,
+    Tcl_Obj *cmdObj,
+    int multiple)
 {
     NSInteger modalReturnCode;
+    int OSVersion = [NSApp macOSVersion];
+    const FilePanelCallbackInfo callbackInfo = {interp, cmdObj, multiple};
+
+    /*
+     * Use a sheet if -parent is specified (unless there is already a sheet).
+     */
 
     if (parent && ![parent attachedSheet]) {
-	[panel beginSheetModalForWindow:parent
-	       completionHandler:^(NSModalResponse returnCode) {
-	    [NSApp tkFilePanelDidEnd:panel
-		       returnCode:returnCode
-		       contextInfo:callbackInfo ];
-	    }];
-
-	/*
-	 * The sheet has been prepared, so now we have to run it as a modal
-	 * window.  Using [NSApp runModalForWindow:] on macOS 10.15 or later
-	 * generates warnings on stderr.  But using [NSOpenPanel runModal] or
-	 * [NSSavePanel runModal] on 10.14 or earler does not cause the
-	 * completion handler to run when the panel is closed.
-	 */
-
-	if ([NSApp macOSVersion] > 101400) {
-	    modalReturnCode = [panel runModal];
-	} else {
-	    modalReturnCode = [NSApp runModalForWindow:panel];
-	}
-    } else {
-
-	/* 
-	 * For the standalone file dialog, completion handlers do not work
-	 * at all on macOS 10.14 and earlier.
-	 */
-
-	if ([NSApp macOSVersion] > 101400) {
-	    [panel beginWithCompletionHandler:^(NSModalResponse returnCode) {
-		    [NSApp tkFilePanelDidEnd:panel
-			          returnCode:returnCode
-			         contextInfo:callbackInfo ];
-	    }];
-	    modalReturnCode = [panel runModal];
-	} else {
-	    modalReturnCode = [panel runModal];
-	    [NSApp tkFilePanelDidEnd:panel
-		   	  returnCode:modalReturnCode
-		         contextInfo:callbackInfo ];
-	    [panel close];
-	}
-    }
-    return callbackInfo->cmdObj ? modalOther : modalReturnCode;
+	if (OSVersion < 101500) {
+	    [panel beginSheetModalForWindow:parent
+			  completionHandler:^(NSModalResponse returnCode) {
+		    [NSApp tkFilePanelDidEnd:panel
+				  returnCode:returnCode
+				 contextInfo:&callbackInfo ];
+		}];
+	    modalReturnCode = [NSApp runModalForWindow:panel];
+	} else if (OSVersion < 110000) {
+	    [panel beginSheetModalForWindow:parent
+			  completionHandler:^(NSModalResponse returnCode) {
+		    [NSApp tkFilePanelDidEnd:panel
+				  returnCode:returnCode
+				 contextInfo:&callbackInfo ];
+		}];
+	    modalReturnCode = [panel runModal];
+	} else {
+	    [parent beginSheet: panel completionHandler:nil];
+	    modalReturnCode = [panel runModal];
+	    [NSApp tkFilePanelDidEnd:panel
+			  returnCode:modalReturnCode
+			 contextInfo:&callbackInfo ];
+	    [parent endSheet:panel];
+	}
+    } else {
+	modalReturnCode = [panel runModal];
+	[NSApp tkFilePanelDidEnd:panel
+		      returnCode:modalReturnCode
+		     contextInfo:&callbackInfo ];
+    }
+    return cmdObj ? modalOther : modalReturnCode;
 }
 
 /*
  *----------------------------------------------------------------------
  *
@@ -421,11 +431,11 @@
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     int result = TCL_ERROR;
-    Tk_Window parent, tkwin = clientData;
+    Tk_Window parent, tkwin = (Tk_Window)clientData;
     const char *title = NULL;
     int i;
     NSColor *color = nil, *initialColor = nil;
     NSColorPanel *colorPanel;
     NSInteger returnCode, numberOfComponents = 0;
@@ -474,11 +484,11 @@
     [colorPanel setContinuous:NO];
     [colorPanel setBecomesKeyOnlyIfNeeded:NO];
     [colorPanel setShowsAlpha: NO];
     [colorPanel _setUseModalAppearance:YES];
     if (title) {
-	NSString *s = [[NSString alloc] initWithUTF8String:title];
+	NSString *s = [[TKNSString alloc] initWithTclUtfBytes:title length:-1];
 
 	[colorPanel setTitle:s];
 	[s release];
     }
     if (initialColor) {
@@ -546,11 +556,11 @@
     filterInfo.allowedExtensionsAllowAll = NO;
 
     if (filterInfo.doFileTypes) {
 	for (FileFilter *filterPtr = fl.filters; filterPtr;
 		filterPtr = filterPtr->next) {
-	    NSString *name = [[NSString alloc] initWithUTF8String: filterPtr->name];
+	    NSString *name = [[TKNSString alloc] initWithTclUtfBytes: filterPtr->name length:-1];
 
 	    [filterInfo.fileTypeNames addObject:name];
 	    [name release];
 	    NSMutableArray *clauseextensions = [NSMutableArray array];
 	    NSMutableArray *displayextensions = [NSMutableArray array];
@@ -564,11 +574,11 @@
 		    const char *str = globPtr->pattern;
 		    while (*str && (*str == '*' || *str == '.')) {
 		    	str++;
 		    }
 		    if (*str) {
-			NSString *extension = [[NSString alloc] initWithUTF8String:str];
+			NSString *extension = [[TKNSString alloc] initWithTclUtfBytes:str length:-1];
 			if (![filterInfo.allowedExtensions containsObject:extension]) {
 			    [filterInfo.allowedExtensions addObject:extension];
 			}
 
 			[clauseextensions addObject:extension];
@@ -617,11 +627,11 @@
 
 	    if (selectedFileTypeObj != NULL) {
 		const char *selectedFileType =
 			Tcl_GetString(selectedFileTypeObj);
 		NSString *selectedFileTypeStr =
-			[[NSString alloc] initWithUTF8String:selectedFileType];
+			[[TKNSString alloc] initWithTclUtfBytes:selectedFileType length:-1];
 		NSUInteger index =
 			[filterInfo.fileTypeNames indexOfObject:selectedFileTypeStr];
 
 		if (index != NSNotFound) {
 		    filterInfo.fileTypeIndex = index;
@@ -676,17 +686,15 @@
     ClientData clientData,	/* Main window associated with interpreter. */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
-    Tk_Window tkwin = clientData;
+    Tk_Window tkwin = (Tk_Window)clientData;
     char *str;
     int i, result = TCL_ERROR, haveParentOption = 0;
     int index, len, multiple = 0;
     Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL, *fileTypesPtr = NULL;
-    FilePanelCallbackInfo callbackInfoStruct;
-    FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct;
     NSString *directory = nil, *filename = nil;
     NSString *message = nil, *title = nil;
     NSWindow *parent;
     openpanel =  [NSOpenPanel openPanel];
     NSInteger modalReturnCode = modalError;
@@ -710,24 +718,25 @@
 	    fileTypesPtr = objv[i + 1];
 	    break;
 	case OPEN_INITDIR:
 	    str = Tcl_GetStringFromObj(objv[i + 1], &len);
 	    if (len) {
-		directory = [[[NSString alloc] initWithUTF8String:str]
+		directory = [[[TKNSString alloc] initWithTclUtfBytes:str length:len]
 			autorelease];
 	    }
 	    break;
 	case OPEN_INITFILE:
 	    str = Tcl_GetStringFromObj(objv[i + 1], &len);
 	    if (len) {
-		filename = [[[NSString alloc] initWithUTF8String:str]
+		filename = [[[TKNSString alloc] initWithTclUtfBytes:str length:len]
 			autorelease];
 	    }
 	    break;
 	case OPEN_MESSAGE:
-	    message = [[NSString alloc] initWithUTF8String:
-		    Tcl_GetString(objv[i + 1])];
+	    str = Tcl_GetStringFromObj(objv[i + 1], &len);
+	    message = [[TKNSString alloc] initWithTclUtfBytes:
+		    str length:len];
 	    break;
 	case OPEN_MULTIPLE:
 	    if (Tcl_GetBooleanFromObj(interp, objv[i + 1],
 		    &multiple) != TCL_OK) {
 		goto end;
@@ -740,12 +749,13 @@
 		goto end;
 	    }
 	    haveParentOption = 1;
 	    break;
 	case OPEN_TITLE:
-	    title = [[NSString alloc] initWithUTF8String:
-		    Tcl_GetString(objv[i + 1])];
+	    str = Tcl_GetStringFromObj(objv[i + 1], &len);
+	    title = [[TKNSString alloc] initWithTclUtfBytes:
+		    str length:len];
 	    break;
 	case OPEN_TYPEVARIABLE:
 	    typeVariablePtr = objv[i + 1];
 	    break;
 	case OPEN_COMMAND:
@@ -797,10 +807,11 @@
 	[label setStringValue:@"Filter:"];
 	[label setBordered:NO];
 	[label setBezeled:NO];
 	[label setDrawsBackground:NO];
 	[popupButton addItemsWithTitles:filterInfo.fileTypeLabels];
+	[popupButton setTarget:NSApp];
 	[popupButton setAction:@selector(selectFormat:)];
 	[accessoryView addSubview:label];
 	[accessoryView addSubview:popupButton];
 	if (filterInfo.preselectFilter) {
 
@@ -815,13 +826,13 @@
 	     * On OSX > 10.11, the options are not visible by default. Ergo
 	     * allow all file types
 	    [openpanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]];
 	    */
 
-	    [openpanel setAllowedFileTypes:filterInfo.allowedExtensions];
+	    setAllowedFileTypes(openpanel, filterInfo.allowedExtensions);
 	} else {
-	    [openpanel setAllowedFileTypes:filterInfo.allowedExtensions];
+	    setAllowedFileTypes(openpanel, filterInfo.allowedExtensions);
 	}
 	if (filterInfo.allowedExtensionsAllowAll) {
 	    [openpanel setAllowsOtherFileTypes:YES];
 	} else {
 	    [openpanel setAllowsOtherFileTypes:NO];
@@ -838,14 +849,10 @@
 	if (Tcl_IsShared(cmdObj)) {
 	    cmdObj = Tcl_DuplicateObj(cmdObj);
 	}
 	Tcl_IncrRefCount(cmdObj);
     }
-    callbackInfo = (FilePanelCallbackInfo *)ckalloc(sizeof(FilePanelCallbackInfo));
-    callbackInfo->cmdObj = cmdObj;
-    callbackInfo->interp = interp;
-    callbackInfo->multiple = multiple;
     if (directory || filename) {
 	NSURL *fileURL = getFileURL(directory, filename);
 
 	[openpanel setDirectoryURL:fileURL];
     }
@@ -854,11 +861,14 @@
 	parentIsKey = parent && [parent isKeyWindow];
     } else {
 	parent = nil;
 	parentIsKey = False;
     }
-    modalReturnCode = showOpenSavePanel(openpanel, parent, callbackInfo);
+    modalReturnCode = showOpenSavePanel(openpanel, parent, interp, cmdObj, multiple);
+    if (cmdObj) {
+	Tcl_DecrRefCount(cmdObj);
+    }
     result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
     if (parentIsKey) {
 	[parent makeKeyWindow];
     }
     if ((typeVariablePtr && (modalReturnCode == NSOKButton))
@@ -953,12 +963,10 @@
     char *str;
     int i, result = TCL_ERROR, haveParentOption = 0;
     int confirmOverwrite = 1;
     int index, len;
     Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL, *fileTypesPtr = NULL;
-    FilePanelCallbackInfo callbackInfoStruct;
-    FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct;
     NSString *directory = nil, *filename = nil, *defaultType = nil;
     NSString *message = nil, *title = nil;
     NSWindow *parent;
     savepanel = [NSSavePanel savePanel];
     NSInteger modalReturnCode = modalError;
@@ -977,38 +985,39 @@
 	}
 	switch (index) {
 	    case SAVE_DEFAULT:
 		str = Tcl_GetStringFromObj(objv[i + 1], &len);
 		while (*str && (*str == '*' || *str == '.')) {
-		    str++;
+		    str++; len--;
 		}
 		if (*str) {
-		    defaultType = [[[NSString alloc] initWithUTF8String:str]
+		    defaultType = [[[TKNSString alloc] initWithTclUtfBytes:str length:len]
 			    autorelease];
 		}
 		break;
 	    case SAVE_FILETYPES:
 		fileTypesPtr = objv[i + 1];
 		break;
 	    case SAVE_INITDIR:
 		str = Tcl_GetStringFromObj(objv[i + 1], &len);
 		if (len) {
-		    directory = [[[NSString alloc] initWithUTF8String:str]
+		    directory = [[[TKNSString alloc] initWithTclUtfBytes:str length:len]
 			    autorelease];
 		}
 		break;
 	    case SAVE_INITFILE:
 		str = Tcl_GetStringFromObj(objv[i + 1], &len);
 		if (len) {
-		    filename = [[[NSString alloc] initWithUTF8String:str]
+		    filename = [[[TKNSString alloc] initWithTclUtfBytes:str length:len]
 			    autorelease];
 		    [savepanel setNameFieldStringValue:filename];
 		}
 		break;
 	    case SAVE_MESSAGE:
-		message = [[NSString alloc] initWithUTF8String:
-			Tcl_GetString(objv[i + 1])];
+		str = Tcl_GetStringFromObj(objv[i + 1], &len);
+		message = [[TKNSString alloc] initWithTclUtfBytes:
+			str length:len];
 		break;
 	    case SAVE_PARENT:
 		str = Tcl_GetStringFromObj(objv[i + 1], &len);
 		tkwin = Tk_NameToWindow(interp, str, tkwin);
 		if (!tkwin) {
@@ -1015,12 +1024,13 @@
 		    goto end;
 		}
 		haveParentOption = 1;
 		break;
 	    case SAVE_TITLE:
-		title = [[NSString alloc] initWithUTF8String:
-			Tcl_GetString(objv[i + 1])];
+		str = Tcl_GetStringFromObj(objv[i + 1], &len);
+		title = [[TKNSString alloc] initWithTclUtfBytes:
+			str length:len];
 		break;
 	    case SAVE_TYPEVARIABLE:
 		typeVariablePtr = objv[i + 1];
 		break;
 	    case SAVE_COMMAND:
@@ -1082,18 +1092,19 @@
 	NSPopUpButton *popupButton = [[NSPopUpButton alloc]
 		initWithFrame:NSMakeRect(50.0, 2, 340, 22.0) pullsDown:NO];
 
 	[popupButton addItemsWithTitles:filterInfo.fileTypeLabels];
 	[popupButton selectItemAtIndex:filterInfo.fileTypeIndex];
+	[popupButton setTarget:NSApp];
 	[popupButton setAction:@selector(saveFormat:)];
-
 	[accessoryView addSubview:label];
 	[accessoryView addSubview:popupButton];
 
 	[savepanel setAccessoryView:accessoryView];
 
-	[savepanel setAllowedFileTypes:[filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex]];
+	setAllowedFileTypes(savepanel,
+	    [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex]);
 	[savepanel setAllowsOtherFileTypes:filterInfo.allowedExtensionsAllowAll];
     } else if (defaultType) {
 	/*
 	 * If no filetypes are given, defaultextension is an alternative way to
 	 * specify the attached extension. Just propose this extension, but
@@ -1101,11 +1112,11 @@
 	 */
 
 	NSMutableArray *AllowedFileTypes = [NSMutableArray array];
 
 	[AllowedFileTypes addObject:defaultType];
-	[savepanel setAllowedFileTypes:AllowedFileTypes];
+	setAllowedFileTypes(savepanel, AllowedFileTypes);
 	[savepanel setAllowsOtherFileTypes:YES];
     }
 
     [savepanel setCanSelectHiddenExtension:YES];
     [savepanel setExtensionHidden:NO];
@@ -1114,14 +1125,10 @@
 	if (Tcl_IsShared(cmdObj)) {
 	    cmdObj = Tcl_DuplicateObj(cmdObj);
 	}
 	Tcl_IncrRefCount(cmdObj);
     }
-    callbackInfo = (FilePanelCallbackInfo *)ckalloc(sizeof(FilePanelCallbackInfo));
-    callbackInfo->cmdObj = cmdObj;
-    callbackInfo->interp = interp;
-    callbackInfo->multiple = 0;
 
     if (directory) {
 	[savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
     }
 
@@ -1140,11 +1147,14 @@
 	parentIsKey = parent && [parent isKeyWindow];
     } else {
 	parent = nil;
 	parentIsKey = False;
     }
-    modalReturnCode = showOpenSavePanel(savepanel, parent, callbackInfo);
+    modalReturnCode = showOpenSavePanel(savepanel, parent, interp, cmdObj, 0);
+    if (cmdObj) {
+	Tcl_DecrRefCount(cmdObj);
+    }
     result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
     if (parentIsKey) {
 	[parent makeKeyWindow];
     }
 
@@ -1194,12 +1204,10 @@
     Tk_Window tkwin = (Tk_Window)clientData;
     char *str;
     int i, result = TCL_ERROR, haveParentOption = 0;
     int index, len, mustexist = 0;
     Tcl_Obj *cmdObj = NULL;
-    FilePanelCallbackInfo callbackInfoStruct;
-    FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct;
     NSString *directory = nil;
     NSString *message, *title;
     NSWindow *parent;
     NSOpenPanel *panel = [NSOpenPanel openPanel];
     NSInteger modalReturnCode = modalError;
@@ -1218,17 +1226,18 @@
 	}
 	switch (index) {
 	case CHOOSE_INITDIR:
 	    str = Tcl_GetStringFromObj(objv[i + 1], &len);
 	    if (len) {
-		directory = [[[NSString alloc] initWithUTF8String:str]
+		directory = [[[TKNSString alloc] initWithTclUtfBytes:str length:len]
 			autorelease];
 	    }
 	    break;
 	case CHOOSE_MESSAGE:
-	    message = [[NSString alloc] initWithUTF8String:
-		    Tcl_GetString(objv[i + 1])];
+	    str = Tcl_GetStringFromObj(objv[i + 1], &len);
+	    message = [[TKNSString alloc] initWithTclUtfBytes:
+		    str length:len];
 	    [panel setMessage:message];
 	    [message release];
 	    break;
 	case CHOOSE_MUSTEXIST:
 	    if (Tcl_GetBooleanFromObj(interp, objv[i + 1],
@@ -1243,12 +1252,13 @@
 		goto end;
 	    }
 	    haveParentOption = 1;
 	    break;
 	case CHOOSE_TITLE:
-	    title = [[NSString alloc] initWithUTF8String:
-		    Tcl_GetString(objv[i + 1])];
+	    str = Tcl_GetStringFromObj(objv[i + 1], &len);
+	    title = [[TKNSString alloc] initWithTclUtfBytes:
+		    str length:len];
 	    [panel setTitle:title];
 	    [title release];
 	    break;
 	case CHOOSE_COMMAND:
 	    cmdObj = objv[i+1];
@@ -1263,14 +1273,10 @@
 	if (Tcl_IsShared(cmdObj)) {
 	    cmdObj = Tcl_DuplicateObj(cmdObj);
 	}
 	Tcl_IncrRefCount(cmdObj);
     }
-    callbackInfo = (FilePanelCallbackInfo *)ckalloc(sizeof(FilePanelCallbackInfo));
-    callbackInfo->cmdObj = cmdObj;
-    callbackInfo->interp = interp;
-    callbackInfo->multiple = 0;
 
     /*
      * Check for directory value, set to root if not specified; otherwise
      * crashes with exception because of nil string parameter.
      */
@@ -1285,11 +1291,14 @@
 	parentIsKey = parent && [parent isKeyWindow];
     } else {
 	parent = nil;
 	parentIsKey = False;
     }
-    modalReturnCode = showOpenSavePanel(panel, parent, callbackInfo);
+    modalReturnCode = showOpenSavePanel(panel, parent, interp, cmdObj, 0);
+    if (cmdObj) {
+	Tcl_DecrRefCount(cmdObj);
+    }
     result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
     if (parentIsKey) {
 	[parent makeKeyWindow];
     }
   end:
@@ -1313,68 +1322,13 @@
  */
 
 void
 TkAboutDlg(void)
 {
-    NSImage *image;
-    NSString *path = [NSApp tkFrameworkImagePath: @"Tk.tiff"];
-
-    if (path) {
-	image = [[[NSImage alloc] initWithContentsOfFile:path] autorelease];
-    } else {
-	image = [NSApp applicationIconImage];
-    }
-
-    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
-
-    [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
-    [dateFormatter setDateFormat:@"Y"];
-
-    NSString *year = [dateFormatter stringFromDate:[NSDate date]];
-
-    [dateFormatter release];
-
-    /*
-     * This replaces the old about dialog with a standard alert that displays
-     * correctly on 10.14.
-     */
-
-    NSString *version =  @"Tcl " TCL_PATCH_LEVEL " & Tk " TCL_PATCH_LEVEL;
-    NSString *url = @"www.tcl-lang.org";
-    NSTextView *credits = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,300,300)];
-    NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
-    NSDictionary *textAttributes = [NSDictionary dictionaryWithObject:font
-					        forKey:NSFontAttributeName];
-
-    [credits insertText: [[NSAttributedString alloc]
-		 initWithString:[NSString stringWithFormat: @"\n"
-		"Tcl and Tk are distributed under a modified BSD license: "
-		"www.tcl.tk/software/tcltk/license.html\n\n"
-		"%1$C 1987-%2$@ Tcl Core Team and Contributers.\n\n"
-		"%1$C 2011-%2$@ Kevin Walzer/WordTech Communications LLC.\n\n"
-		"%1$C 2014-%2$@ Marc Culler.\n\n"
-		"%1$C 2002-2012 Daniel A. Steffen.\n\n"
-		"%1$C 2001-2009 Apple Inc.\n\n"
-		"%1$C 2001-2002 Jim Ingham & Ian Reid\n\n"
-		"%1$C 1998-2000 Jim Ingham & Ray Johnson\n\n"
-		"%1$C 1998-2000 Scriptics Inc.\n\n"
-		"%1$C 1996-1997 Sun Microsystems Inc.", 0xA9, year]
-	    attributes:textAttributes]
-            replacementRange:NSMakeRange(0,0)];
-    [credits setDrawsBackground:NO];
-    [credits setEditable:NO];
-
-    NSAlert *about = [[NSAlert alloc] init];
-
-    [[about window] setTitle:@"About Tcl & Tk"];
-    [about setMessageText: version];
-    [about setInformativeText:url];
-    about.accessoryView = credits;
-    [about runModal];
-    [about release];
-}
-
+    [NSApp orderFrontStandardAboutPanel:nil];
+}
+
 /*
  *----------------------------------------------------------------------
  *
  * TkMacOSXStandardAboutPanelObjCmd --
  *
@@ -1398,11 +1352,11 @@
 {
     if (objc > 1) {
 	Tcl_WrongNumArgs(interp, 1, objv, NULL);
 	return TCL_ERROR;
     }
-    TkAboutDlg();
+    [NSApp orderFrontStandardAboutPanel:nil];
     return TCL_OK;
 }
 
 /*
  *----------------------------------------------------------------------
@@ -1431,11 +1385,11 @@
     char *str;
     int i, result = TCL_ERROR, haveParentOption = 0;
     int index, typeIndex, iconIndex, indexDefaultOption = 0;
     int defaultNativeButtonIndex = 1; /* 1, 2, 3: right to left */
     Tcl_Obj *cmdObj = NULL;
-    AlertCallbackInfo callbackInfoStruct, *callbackInfo = &callbackInfoStruct;
+    AlertCallbackInfo callbackInfo;
     NSString *message, *title;
     NSWindow *parent;
     NSArray *buttons;
     NSAlert *alert = [NSAlert new];
     NSInteger modalReturnCode = 1;
@@ -1463,12 +1417,13 @@
 
 	    indexDefaultOption = i;
 	    break;
 
 	case ALERT_DETAIL:
-	    message = [[NSString alloc] initWithUTF8String:
-		    Tcl_GetString(objv[i + 1])];
+	    str = Tcl_GetString(objv[i + 1]);
+	    message = [[TKNSString alloc] initWithTclUtfBytes:
+		    str length:-1];
 	    [alert setInformativeText:message];
 	    [message release];
 	    break;
 
 	case ALERT_ICON:
@@ -1477,12 +1432,13 @@
 		goto end;
 	    }
 	    break;
 
 	case ALERT_MESSAGE:
-	    message = [[NSString alloc] initWithUTF8String:
-		    Tcl_GetString(objv[i + 1])];
+	    str = Tcl_GetString(objv[i + 1]);
+	    message = [[TKNSString alloc] initWithTclUtfBytes:
+		    str length:-1];
 	    [alert setMessageText:message];
 	    [message release];
 	    break;
 
 	case ALERT_PARENT:
@@ -1493,12 +1449,13 @@
 	    }
 	    haveParentOption = 1;
 	    break;
 
 	case ALERT_TITLE:
-	    title = [[NSString alloc] initWithUTF8String:
-		    Tcl_GetString(objv[i + 1])];
+	    str = Tcl_GetString(objv[i + 1]);
+	    title = [[TKNSString alloc] initWithTclUtfBytes:
+		    str length:-1];
 	    [[alert window] setTitle:title];
 	    [title release];
 	    break;
 
 	case ALERT_TYPE:
@@ -1559,36 +1516,38 @@
 	if (Tcl_IsShared(cmdObj)) {
 	    cmdObj = Tcl_DuplicateObj(cmdObj);
 	}
 	Tcl_IncrRefCount(cmdObj);
     }
-    callbackInfo = (AlertCallbackInfo *)ckalloc(sizeof(AlertCallbackInfo));
-    callbackInfo->cmdObj = cmdObj;
-    callbackInfo->interp = interp;
-    callbackInfo->typeIndex = typeIndex;
+    callbackInfo.cmdObj = cmdObj;
+    callbackInfo.interp = interp;
+    callbackInfo.typeIndex = typeIndex;
     parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window);
     if (haveParentOption && parent && ![parent attachedSheet]) {
 	parentIsKey = [parent isKeyWindow];
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
  	[alert beginSheetModalForWindow:parent
 	       completionHandler:^(NSModalResponse returnCode) {
 	    [NSApp tkAlertDidEnd:alert
 		    returnCode:returnCode
-		    contextInfo:callbackInfo];
+		    contextInfo:&callbackInfo];
 	}];
 #else
 	[alert beginSheetModalForWindow:parent
 	       modalDelegate:NSApp
 	       didEndSelector:@selector(tkAlertDidEnd:returnCode:contextInfo:)
-	       contextInfo:callbackInfo];
+	       contextInfo:&callbackInfo];
 #endif
 	modalReturnCode = cmdObj ? 0 :
 	    [alert runModal];
     } else {
 	modalReturnCode = [alert runModal];
 	[NSApp tkAlertDidEnd:alert returnCode:modalReturnCode
-		contextInfo:callbackInfo];
+		contextInfo:&callbackInfo];
+    }
+    if (cmdObj) {
+	Tcl_DecrRefCount(cmdObj);
     }
     result = (modalReturnCode >= NSAlertFirstButtonReturn) ? TCL_OK : TCL_ERROR;
   end:
     [alert release];
     if (parentIsKey) {
@@ -1647,15 +1606,15 @@
 static Tcl_Interp *fontchooserInterp = NULL;
 static NSFont *fontPanelFont = nil;
 static NSMutableDictionary *fontPanelFontAttributes = nil;
 
 static const char *const fontchooserOptionStrings[] = {
-    "-parent", "-title", "-font", "-command",
+    "-command", "-font", "-parent", "-title",
     "-visible", NULL
 };
 enum FontchooserOption {
-    FontchooserParent, FontchooserTitle, FontchooserFont, FontchooserCmd,
+    FontchooserCmd, FontchooserFont, FontchooserParent, FontchooserTitle,
     FontchooserVisible
 };
 
 @implementation TKApplication(TKFontPanel)
 
@@ -1732,14 +1691,14 @@
     Tcl_Obj *fontObj;
 
     if (!fontchooserInterp) {
 	return;
     }
-    fcdPtr = Tcl_GetAssocData(fontchooserInterp, "::tk::fontchooser", NULL);
+    fcdPtr = (FontchooserData *)Tcl_GetAssocData(fontchooserInterp, "::tk::fontchooser", NULL);
     switch (kind) {
     case FontchooserClosed:
-	if (fcdPtr->parent != None) {
+	if (fcdPtr->parent != NULL) {
 	    Tk_SendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility", NULL);
 	    fontchooserInterp = NULL;
 	}
 	break;
     case FontchooserSelection:
@@ -1791,11 +1750,11 @@
 {
     Tcl_Obj *resObj = NULL;
 
     switch(optionIndex) {
     case FontchooserParent:
-	if (fcdPtr->parent != None) {
+	if (fcdPtr->parent != NULL) {
 	    resObj = Tcl_NewStringObj(
 		    ((TkWindow *)fcdPtr->parent)->pathName, -1);
 	} else {
 	    resObj = Tcl_NewStringObj(".", 1);
 	}
@@ -1820,12 +1779,12 @@
 	} else {
 	    resObj = Tcl_NewObj();
 	}
 	break;
     case FontchooserVisible:
-	resObj = Tcl_NewWideIntObj([[[NSFontManager sharedFontManager]
-		fontPanel:NO] isVisible] != 0);
+	resObj = Tcl_NewBooleanObj([[[NSFontManager sharedFontManager]
+		fontPanel:NO] isVisible]);
 	break;
     default:
 	resObj = Tcl_NewObj();
     }
     return resObj;
@@ -1854,11 +1813,11 @@
     Tcl_Interp *interp,
     int objc,
     Tcl_Obj *const objv[])
 {
     Tk_Window tkwin = (Tk_Window)clientData;
-    FontchooserData *fcdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser",
+    FontchooserData *fcdPtr = (FontchooserData *)Tcl_GetAssocData(interp, "::tk::fontchooser",
 	    NULL);
     int i, r = TCL_OK;
 
     /*
      * With no arguments we return all the options in a dict
@@ -1911,11 +1870,11 @@
 	}
 	case FontchooserParent: {
 	    Tk_Window parent = Tk_NameToWindow(interp,
 		    Tcl_GetString(objv[i+1]), tkwin);
 
-	    if (parent == None) {
+	    if (parent == NULL) {
 		return TCL_ERROR;
 	    }
 	    if (fcdPtr->parent) {
 		Tk_DeleteEventHandler(fcdPtr->parent, StructureNotifyMask,
 			FontchooserParentEventHandler, fcdPtr);
@@ -1938,11 +1897,11 @@
 		Tcl_IncrRefCount(fcdPtr->titleObj);
 	    } else {
 		fcdPtr->titleObj = NULL;
 	    }
 	    break;
-	case FontchooserFont:
+	case FontchooserFont: {
 	    Tcl_GetStringFromObj(objv[i+1], &len);
 	    if (len) {
 		Tk_Font f = Tk_AllocFontFromObj(interp, tkwin, objv[i+1]);
 
 		if (!f) {
@@ -1972,10 +1931,11 @@
 	    if ([fp isVisible]) {
 		Tk_SendVirtualEvent(fcdPtr->parent,
 			"TkFontchooserFontChanged", NULL);
 	    }
 	    break;
+	}
 	case FontchooserCmd:
 	    if (fcdPtr->cmdObj) {
 		Tcl_DecrRefCount(fcdPtr->cmdObj);
 	    }
 	    Tcl_GetStringFromObj(objv[i+1], &len);
@@ -2017,14 +1977,14 @@
     ClientData clientData,	/* Main window */
     Tcl_Interp *interp,
     TCL_UNUSED(int),
     TCL_UNUSED(Tcl_Obj *const *))
 {
-    FontchooserData *fcdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser",
+    FontchooserData *fcdPtr = (FontchooserData *)Tcl_GetAssocData(interp, "::tk::fontchooser",
 	    NULL);
 
-    if (fcdPtr->parent == None) {
+    if (fcdPtr->parent == NULL) {
 	fcdPtr->parent = (Tk_Window)clientData;
 	Tk_CreateEventHandler(fcdPtr->parent, StructureNotifyMask,
 		FontchooserParentEventHandler, fcdPtr);
     }
 
@@ -2095,11 +2055,11 @@
 static void
 FontchooserParentEventHandler(
     ClientData clientData,
     XEvent *eventPtr)
 {
-    FontchooserData *fcdPtr = clientData;
+    FontchooserData *fcdPtr = (FontchooserData *)clientData;
 
     if (eventPtr->type == DestroyNotify) {
 	Tk_DeleteEventHandler(fcdPtr->parent, StructureNotifyMask,
 		FontchooserParentEventHandler, fcdPtr);
 	fcdPtr->parent = NULL;
@@ -2127,11 +2087,11 @@
 static void
 DeleteFontchooserData(
     ClientData clientData,
     Tcl_Interp *interp)
 {
-    FontchooserData *fcdPtr = clientData;
+    FontchooserData *fcdPtr = (FontchooserData *)clientData;
 
     if (fcdPtr->titleObj) {
 	Tcl_DecrRefCount(fcdPtr->titleObj);
     }
     if (fcdPtr->cmdObj) {

Index: macosx/tkMacOSXDraw.c
==================================================================
--- macosx/tkMacOSXDraw.c
+++ macosx/tkMacOSXDraw.c
@@ -2,14 +2,14 @@
  * tkMacOSXDraw.c --
  *
  *	This file contains functions that draw to windows. Many of thees
  *	functions emulate Xlib functions.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright (c) 2001-2009 Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2014-2020 Marc Culler.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2014-2020 Marc Culler.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -25,10 +25,11 @@
 
 /*
 #ifdef TK_MAC_DEBUG
 #define TK_MAC_DEBUG_DRAWING
 #define TK_MAC_DEBUG_IMAGE_DRAWING
+#define TK_MAC_DEBUG_CG
 #endif
 */
 
 #define radians(d)	((d) * (M_PI/180.0))
 
@@ -130,11 +131,11 @@
     int width,
     int height)
 {
     Pixmap pixmap;
     NSImage *nsImage;
-    if (width == 0 || height == 0) {
+    if (width <= 0 || height <= 0) {
 	return nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0,0)];
     }
     pixmap = Tk_GetPixmap(display, None, width, height, 0);
     Tk_RedrawImage(image, 0, 0, width, height, pixmap, 0, 0);
     nsImage = CreateNSImageFromPixmap(pixmap, width, height);
@@ -529,11 +530,11 @@
     Display *display,		/* Display. */
     Drawable d,			/* Draw on this. */
     GC gc,			/* Use this GC. */
     XPoint *points,		/* Array of points. */
     int npoints,		/* Number of points. */
-    TCL_UNUSED(int),	/* Shape to draw. */
+    TCL_UNUSED(int),		/* Shape to draw. */
     int mode)			/* Drawing mode. */
 {
     MacDrawable *macWin = (MacDrawable *)d;
     TkMacOSXDrawingContext dc;
     int i;
@@ -559,11 +560,13 @@
 		prevx += points[i].x;
 		prevy += points[i].y;
 		CGContextAddLineToPoint(dc.context, prevx, prevy);
 	    }
 	}
-	CGContextEOFillPath(dc.context);
+	(gc->fill_rule == EvenOddRule)
+		? CGContextEOFillPath(dc.context)
+		: CGContextFillPath(dc.context);
     }
     TkMacOSXRestoreDrawingContext(&dc);
     return Success;
 }
 
@@ -1116,76 +1119,56 @@
     Region damageRgn)		/* Region to accumulate damage in. */
 {
     Drawable drawable = Tk_WindowId(tkwin);
     MacDrawable *macDraw = (MacDrawable *)drawable;
     TKContentView *view = (TKContentView *)TkMacOSXGetNSViewForDrawable(macDraw);
-    CGRect srcRect, dstRect;
-    HIShapeRef dmgRgn = NULL, extraRgn = NULL;
-    NSRect bounds, visRect, scrollSrc, scrollDst;
+    HIShapeRef srcRgn, dstRgn;
+    HIMutableShapeRef dmgRgn = HIShapeCreateMutable();
+    NSRect bounds, viewSrcRect, srcRect, dstRect;
     int result = 0;
 
     if (view) {
+
   	/*
 	 * Get the scroll area in NSView coordinates (origin at bottom left).
 	 */
 
   	bounds = [view bounds];
- 	scrollSrc = NSMakeRect(macDraw->xOff + x,
-		bounds.size.height - height - (macDraw->yOff + y),
-		width, height);
- 	scrollDst = NSOffsetRect(scrollSrc, dx, -dy);
-
-  	/*
-	 * Limit scrolling to the window content area.
-	 */
-
- 	visRect = [view visibleRect];
- 	scrollSrc = NSIntersectionRect(scrollSrc, visRect);
- 	scrollDst = NSIntersectionRect(scrollDst, visRect);
- 	if (!NSIsEmptyRect(scrollSrc) && !NSIsEmptyRect(scrollDst)) {
-  	    /*
-  	     * Mark the difference between source and destination as damaged.
-	     * This region is described in NSView coordinates (y=0 at the
-	     * bottom) and converted to Tk coordinates later.
-  	     */
-
-	    srcRect = CGRectMake(x, y, width, height);
-	    dstRect = CGRectOffset(srcRect, dx, dy);
-
-	    /*
-	     * Compute the damage.
-	     */
-
-  	    dmgRgn = HIShapeCreateMutableWithRect(&srcRect);
- 	    extraRgn = HIShapeCreateWithRect(&dstRect);
- 	    ChkErr(HIShapeDifference, dmgRgn, extraRgn,
-		    (HIMutableShapeRef) dmgRgn);
-	    result = HIShapeIsEmpty(dmgRgn) ? 0 : 1;
-
-	    /*
-	     * Convert to Tk coordinates, offset by the window origin.
-	     */
-
-	    TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn);
-	    if (extraRgn) {
-		CFRelease(extraRgn);
-	    }
-
- 	    /*
-	     * Scroll the rectangle.
-	     */
-
- 	    [view scrollRect:scrollSrc by:NSMakeSize(dx, -dy)];
-  	}
-    } else {
-	dmgRgn = HIShapeCreateEmpty();
-	TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn);
-    }
-
-    if (dmgRgn) {
-	CFRelease(dmgRgn);
-    }
+ 	viewSrcRect = NSMakeRect(macDraw->xOff + x,
+		bounds.size.height - height - (macDraw->yOff + y),
+		width, height);
+
+	/*
+	 * Scroll the rectangle.
+	 */
+
+	[view scrollRect:viewSrcRect by:NSMakeSize(dx, -dy)];
+
+	/*
+	 * Compute the damage region, using Tk coordinates (origin at top left).
+	 */
+
+	srcRect = CGRectMake(x, y, width, height);
+	dstRect = CGRectOffset(srcRect, dx, dy);
+	srcRgn = HIShapeCreateWithRect(&srcRect);
+	dstRgn = HIShapeCreateWithRect(&dstRect);
+	ChkErr(HIShapeDifference, srcRgn, dstRgn, dmgRgn);
+	result = HIShapeIsEmpty(dmgRgn) ? 0 : 1;
+
+    }
+
+    /*
+     * Convert the HIShape dmgRgn into a TkRegion and store it.
+     */
+
+    TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn);
+
+    /*
+     * Mutable shapes are not reference counted, and must be released.
+     */
+
+    CFRelease(dmgRgn);
     return result;
 }
 
 /*
  *----------------------------------------------------------------------
@@ -1240,10 +1223,16 @@
 {
     MacDrawable *macDraw = (MacDrawable *)d;
     Bool canDraw = true;
     TKContentView *view = nil;
     TkMacOSXDrawingContext dc = {};
+    CGFloat drawingHeight;
+
+#ifdef TK_MAC_DEBUG_CG
+    fprintf(stderr, "TkMacOSXSetupDrawingContext: %s\n",
+	    macDraw->winPtr ? Tk_PathName(macDraw->winPtr) : "None");
+#endif
 
     /*
      * If the drawable is not a pixmap, get the associated NSView.
      */
 
@@ -1271,18 +1260,14 @@
      * If the drawable already has a CGContext, use it.  Otherwise, we must be
      * drawing to a window and we use the current context of its ContentView.
      */
 
     dc.context = TkMacOSXGetCGContextForDrawable(d);
-    if (dc.context) {
-	dc.portBounds = CGContextGetClipBoundingBox(dc.context);
-    } else {
+    if (!dc.context) {
 	NSRect drawingBounds, currentBounds;
-
 	dc.view = view;
 	dc.context = GET_CGCONTEXT;
-	dc.portBounds = NSRectToCGRect([view bounds]);
 	if (dc.clipRgn) {
 	    CGRect clipBounds;
 	    CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0,
 				    .ty = [view bounds].size.height};
 	    HIShapeGetBounds(dc.clipRgn, &clipBounds);
@@ -1320,32 +1305,38 @@
 	 * the drawing bounds will be clipped then we draw whatever we can, but
 	 * we also add the drawing bounds to the view's dirty rectangle so it
 	 * will get redrawn in the next call to its drawRect method.
 	 */
 
-	currentBounds = CGContextGetClipBoundingBox(dc.context);
+	currentBounds = NSRectFromCGRect(CGContextGetClipBoundingBox(dc.context));
 	if (!NSContainsRect(currentBounds, drawingBounds)) {
 	    [view addTkDirtyRect:drawingBounds];
 	}
     }
 
     /*
      * Finish configuring the drawing context.
      */
 
-    CGAffineTransform t = {
-	.a = 1, .b = 0,
-	.c = 0, .d = -1,
-	.tx = 0,
-	.ty = dc.portBounds.size.height
-    };
-
-    dc.portBounds.origin.x += macDraw->xOff;
-    dc.portBounds.origin.y += macDraw->yOff;
+#ifdef TK_MAC_DEBUG_CG
+    fprintf(stderr, "TkMacOSXSetupDrawingContext: pushing GState for %s\n",
+	    macDraw->winPtr ? Tk_PathName(macDraw->winPtr) : "None");
+#endif
+
     CGContextSaveGState(dc.context);
     CGContextSetTextDrawingMode(dc.context, kCGTextFill);
-    CGContextConcatCTM(dc.context, t);
+    { /* Restricted scope for t needed for C++ */
+	drawingHeight = view ? [view bounds].size.height :
+	    CGContextGetClipBoundingBox(dc.context).size.height;
+	CGAffineTransform t = {
+	    .a = 1, .b = 0,
+	    .c = 0, .d = -1,
+	    .tx = 0,
+	    .ty = drawingHeight
+	};
+	CGContextConcatCTM(dc.context, t);
+    }
     if (dc.clipRgn) {
 
 #ifdef TK_MAC_DEBUG_DRAWING
 	CGContextSaveGState(dc.context);
 	ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context);
@@ -1352,17 +1343,43 @@
 	CGContextSetRGBFillColor(dc.context, 1.0, 0.0, 0.0, 0.1);
 	CGContextEOFillPath(dc.context);
 	CGContextRestoreGState(dc.context);
 #endif /* TK_MAC_DEBUG_DRAWING */
 
-	CGRect r;
-	CGRect b = CGRectApplyAffineTransform(
-	    CGContextGetClipBoundingBox(dc.context), t);
-	if (!HIShapeIsRectangular(dc.clipRgn) ||
-	    !CGRectContainsRect(*HIShapeGetBounds(dc.clipRgn, &r), b)) {
+	if (!HIShapeIsRectangular(dc.clipRgn)) {
+
+	    /*
+	     * We expect the clipping path dc.clipRgn to consist of the
+	     * bounding rectangle of the drawable window, together with
+	     * disjoint smaller rectangles inside of it which bound its
+	     * geometric children.  In that case the even-odd rule will
+	     * clip to the region inside the large rectangle and outside
+	     * of the smaller rectangles.
+	     */
+
 	    ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context);
+
+#ifdef TK_MAC_DEBUG_CG
+	    fprintf(stderr, "Setting complex clip for %s to:\n",
+		    macDraw->winPtr ? Tk_PathName(macDraw->winPtr) : "None");
+	    TkMacOSXPrintRectsInRegion(dc.clipRgn);
+#endif
+
 	    CGContextEOClip(dc.context);
+	} else {
+	    CGRect r;
+	    HIShapeGetBounds(dc.clipRgn, &r);
+
+#ifdef TK_MAC_DEBUG_CG
+	    fprintf(stderr, "Current clip BBox is %s\n",
+		    NSStringFromRect(CGContextGetClipBoundingBox(GET_CGCONTEXT)).UTF8String);
+	    fprintf(stderr, "Setting clip for %s to rect %s:\n",
+		    macDraw->winPtr ? Tk_PathName(macDraw->winPtr) : "None",
+		    NSStringFromRect(r).UTF8String);
+#endif
+
+	    CGContextClipToRect(dc.context, r);
 	}
     }
     if (gc) {
 	static const CGLineCap cgCap[] = {
 	    [CapNotLast] = kCGLineCapButt,
@@ -1378,12 +1395,12 @@
 	bool shouldAntialias = !notAA(gc->line_width);
 	double w = gc->line_width;
 
 	TkMacOSXSetColorInContext(gc, gc->foreground, dc.context);
 	if (view) {
-	    CGContextSetPatternPhase(dc.context, CGSizeMake(
-	        dc.portBounds.size.width, dc.portBounds.size.height));
+	    CGSize size = NSSizeToCGSize([view bounds].size);
+	    CGContextSetPatternPhase(dc.context, size);
 	}
 	if (gc->function != GXcopy) {
 	    TkMacOSXDbgMsg("Logical functions other than GXcopy are "
 			   "not supported for CG drawing!");
 	}
@@ -1419,17 +1436,13 @@
     }
 
 end:
 
 #ifdef TK_MAC_DEBUG_DRAWING
-    if (!canDraw && win != NULL) {
-	TkWindow *winPtr = TkMacOSXGetTkWindow(win);
-
-	if (winPtr) {
-	    fprintf(stderr, "Cannot draw in %s - postponing.\n",
-		    Tk_PathName(winPtr));
-	}
+    if (!canDraw && macDraw->winPtr != NULL) {
+	fprintf(stderr, "Cannot draw in %s - postponing.\n",
+		Tk_PathName(macDraw->winPtr));
     }
 #endif
 
     if (!canDraw && dc.clipRgn) {
 	CFRelease(dc.clipRgn);
@@ -1460,17 +1473,25 @@
     TkMacOSXDrawingContext *dcPtr)
 {
     if (dcPtr->context) {
 	CGContextSynchronize(dcPtr->context);
 	CGContextRestoreGState(dcPtr->context);
+
+#ifdef TK_MAC_DEBUG_CG
+	fprintf(stderr, "TkMacOSXRestoreDrawingContext: popped GState\n");
+#endif
+
     }
     if (dcPtr->clipRgn) {
 	CFRelease(dcPtr->clipRgn);
+	dcPtr->clipRgn = NULL;
     }
+
 #ifdef TK_MAC_DEBUG
     bzero(dcPtr, sizeof(TkMacOSXDrawingContext));
-#endif /* TK_MAC_DEBUG */
+#endif
+
 }
 
 /*
  *----------------------------------------------------------------------
  *
@@ -1522,11 +1543,11 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpClipDrawableToRect --
+ * Tk_ClipDrawableToRect --
  *
  *	Clip all drawing into the drawable d to the given rectangle. If width
  *	or height are negative, reset to no clipping.
  *
  * Results:
@@ -1537,11 +1558,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 void
-TkpClipDrawableToRect(
+Tk_ClipDrawableToRect(
     TCL_UNUSED(Display *),
     Drawable d,
     int x, int y,
     int width, int height)
 {
@@ -1638,11 +1659,11 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpDrawHighlightBorder --
+ * Tk_DrawHighlightBorder --
  *
  *	This procedure draws a rectangular ring around the outside of a widget
  *	to indicate that it has received the input focus.
  *
  *	On the Macintosh, this puts a 1 pixel border in the bgGC color between
@@ -1660,11 +1681,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 void
-TkpDrawHighlightBorder (
+Tk_DrawHighlightBorder (
     Tk_Window tkwin,
     GC fgGC,
     GC bgGC,
     int highlightWidth,
     Drawable drawable)

Index: macosx/tkMacOSXEmbed.c
==================================================================
--- macosx/tkMacOSXEmbed.c
+++ macosx/tkMacOSXEmbed.c
@@ -5,13 +5,13 @@
  *	basic operations needed for application embedding (where one
  *	application can use as its main window an internal window from some
  *	other application). Currently only Toplevel embedding within the same
  *	Tk application is allowed on the Macintosh.
  *
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -73,20 +73,21 @@
  *
  *----------------------------------------------------------------------
  */
 
 Window
-TkpMakeWindow(
-    TkWindow *winPtr,
+Tk_MakeWindow(
+    Tk_Window tkwin,
     Window parent)
 {
     MacDrawable *macWin;
+    TkWindow *winPtr = (TkWindow *)tkwin;
     (void)parent;
 
     /*
      * If this window is marked as embedded then the window structure should
-     * have already been created in the TkpUseWindow function.
+     * have already been created in the Tk_UseWindow function.
      */
 
     if (Tk_IsEmbedded(winPtr)) {
 	macWin = winPtr->privatePtr;
     } else {
@@ -176,11 +177,11 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpUseWindow --
+ * Tk_UseWindow --
  *
  *	This procedure causes a Tk window to use a given X window as its
  *	parent window, rather than the root window for the screen. It is
  *	invoked by an embedded application to specify the window in which it
  *	is embedded.
@@ -196,11 +197,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 int
-TkpUseWindow(
+Tk_UseWindow(
     Tcl_Interp *interp,		/* If not NULL, used for error reporting if
 				 * string is bogus. */
     Tk_Window tkwin,		/* Tk window that does not yet have an
 				 * associated X window. */
     const char *string)		/* String identifying an X window to use for
@@ -320,11 +321,11 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpMakeContainer --
+ * Tk_MakeContainer --
  *
  *	This procedure is called to indicate that a particular window will be
  *	a container for an embedded application. This changes certain aspects
  *	of the window's behavior, such as whether it will receive events
  *	anymore.
@@ -337,11 +338,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 void
-TkpMakeContainer(
+Tk_MakeContainer(
     Tk_Window tkwin)		/* Token for a window that is about to become
 				 * a container. */
 {
     TkWindow *winPtr = (TkWindow *) tkwin;
     Container *containerPtr;
@@ -438,11 +439,11 @@
 
     topWinPtr = winPtr->privatePtr->toplevel->winPtr;
     if (!Tk_IsEmbedded(topWinPtr)) {
 	return winPtr->privatePtr->toplevel;
     }
-    contWinPtr = TkpGetOtherWindow(topWinPtr);
+    contWinPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)topWinPtr);
 
     /*
      * TODO: Here we should handle out of process embedding.
      */
 
@@ -635,48 +636,48 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpGetOtherWindow --
+ * Tk_GetOtherWindow --
  *
  *	If both the container and embedded window are in the same process,
  *	this procedure will return either one, given the other.
  *
  * Results:
- *	If winPtr is a container, the return value is the token for the
+ *	If tkwin is a container, the return value is the token for the
  *	embedded window, and vice versa. If the "other" window isn't in this
  *	process, NULL is returned.
  *
  * Side effects:
  *	None.
  *
  *----------------------------------------------------------------------
  */
 
-TkWindow *
-TkpGetOtherWindow(
-    TkWindow *winPtr)		/* Tk's structure for a container or embedded
+Tk_Window
+Tk_GetOtherWindow(
+    Tk_Window tkwin)		/* Tk's structure for a container or embedded
 				 * window. */
 {
     Container *containerPtr;
 
     /*
-     * TkpGetOtherWindow returns NULL if both windows are not in the same
+     * Tk_GetOtherWindow returns NULL if both windows are not in the same
      * process...
      */
 
-    if (!(winPtr->flags & TK_BOTH_HALVES)) {
+    if (!(((TkWindow *)tkwin)->flags & TK_BOTH_HALVES)) {
 	return NULL;
     }
 
     for (containerPtr = firstContainerPtr; containerPtr != NULL;
 	    containerPtr = containerPtr->nextPtr) {
-	if (containerPtr->embeddedPtr == winPtr) {
-	    return containerPtr->parentPtr;
-	} else if (containerPtr->parentPtr == winPtr) {
-	    return containerPtr->embeddedPtr;
+	if ((Tk_Window)containerPtr->embeddedPtr == tkwin) {
+	    return (Tk_Window)containerPtr->parentPtr;
+	} else if ((Tk_Window)containerPtr->parentPtr == tkwin) {
+	    return (Tk_Window)containerPtr->embeddedPtr;
 	}
     }
     return NULL;
 }
 
@@ -702,11 +703,11 @@
 static void
 EmbeddedEventProc(
     ClientData clientData,	/* Token for container window. */
     XEvent *eventPtr)		/* ResizeRequest event. */
 {
-    TkWindow *winPtr = clientData;
+    TkWindow *winPtr = (TkWindow *)clientData;
 
     if (eventPtr->type == DestroyNotify) {
 	EmbedWindowDeleted(winPtr);
     }
 }
@@ -737,11 +738,11 @@
 static void
 ContainerEventProc(
     ClientData clientData,	/* Token for container window. */
     XEvent *eventPtr)		/* ResizeRequest event. */
 {
-    TkWindow *winPtr = clientData;
+    TkWindow *winPtr = (TkWindow *)clientData;
     Container *containerPtr;
     Tk_ErrorHandler errHandler;
 
     if (!firstContainerPtr) {
 	/*
@@ -845,20 +846,20 @@
 static void
 EmbedStructureProc(
     ClientData clientData,	/* Token for container window. */
     XEvent *eventPtr)		/* ResizeRequest event. */
 {
-    Container *containerPtr = clientData;
+    Container *containerPtr = (Container *)clientData;
     Tk_ErrorHandler errHandler;
 
     if (eventPtr->type == ConfigureNotify) {
 
 	/*
          * Send a ConfigureNotify  to the embedded application.
          */
 
-        if (containerPtr->embeddedPtr != None) {
+        if (containerPtr->embeddedPtr != NULL) {
             TkDoConfigureNotify(containerPtr->embeddedPtr);
         }
 	if (containerPtr->embedded != None) {
 	    /*
 	     * Ignore errors, since the embedded application could have
@@ -899,11 +900,11 @@
 static void
 EmbedActivateProc(
     ClientData clientData,	/* Token for container window. */
     XEvent *eventPtr)		/* ResizeRequest event. */
 {
-    Container *containerPtr = clientData;
+    Container *containerPtr = (Container *)clientData;
 
     if (containerPtr->embeddedPtr != NULL) {
 	if (eventPtr->type == ActivateNotify) {
 	    TkGenerateActivateEvents(containerPtr->embeddedPtr,1);
 	} else if (eventPtr->type == DeactivateNotify) {
@@ -934,11 +935,11 @@
 static void
 EmbedFocusProc(
     ClientData clientData,	/* Token for container window. */
     XEvent *eventPtr)		/* ResizeRequest event. */
 {
-    Container *containerPtr = clientData;
+    Container *containerPtr = (Container *)clientData;
     Display *display;
     XEvent event;
 
     if (containerPtr->embeddedPtr != NULL) {
 	display = Tk_Display(containerPtr->parentPtr);
@@ -1080,10 +1081,13 @@
      */
 
     prevPtr = NULL;
     containerPtr = firstContainerPtr;
     while (1) {
+	if (containerPtr == NULL) {
+	    return;
+	}
 	if (containerPtr->embeddedPtr == winPtr) {
 	    /*
 	     * We also have to destroy our parent, to clean up the container.
 	     * Fabricate an event to do this.
 	     */

Index: macosx/tkMacOSXEntry.c
==================================================================
--- macosx/tkMacOSXEntry.c
+++ macosx/tkMacOSXEntry.c
@@ -1,13 +1,13 @@
 /*
  * tkMacOSXEntry.c --
  *
  *	This file implements the native aqua entry widget.
  *
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright 2008-2009, Apple Inc.
+ * Copyright © 2001 Apple Computer, Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2008-2009 Apple Inc.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: macosx/tkMacOSXEvent.c
==================================================================
--- macosx/tkMacOSXEvent.c
+++ macosx/tkMacOSXEvent.c
@@ -1,13 +1,13 @@
 /*
  * tkMacOSXEvent.c --
  *
  *	This file contains the basic Mac OS X Event handling routines.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009, Apple Inc.
+ * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -103,27 +103,30 @@
     }
     return processedEvent;
 }
 @end
 #pragma mark -
+
 int
 XSync(
     Display *display,
     TCL_UNUSED(Bool))
 {
     /*
      *  The main use of XSync is by the update command, which alternates
      *  between running an event loop to process all events without waiting and
-     *  calling XSync on all displays until no events are left.  There is
-     *  nothing for the mac to do with respect to syncing its one display but
-     *  it can (and, during regression testing, frequently does) happen that
-     *  timer events fire during the event loop. Processing those here seems
-     *  to make the update command work in a way that is more consistent with
-     *  its behavior on other platforms.
+     *  calling XSync on all displays until no events are left.  On X11 the
+     *  call to XSync might cause the window manager to generate more events
+     *  which would then get processed. Apparently this process stabilizes on
+     *  X11, leaving the window manager in a state where all events have been
+     *  generated and no additional events can be genereated by updating widgets.
+     *
+     *  It is not clear what the Aqua port should do when XSync is called, but
+     *  currently the best option seems to be to do nothing.  (See ticket
+     *  [da5f2266df].)
      */
 
-    while (Tcl_DoOneEvent(TCL_TIMER_EVENTS|TCL_DONT_WAIT)){}
     display->request++;
     return 0;
 }
 
 /*

ADDED   macosx/tkMacOSXFileTypes.c
Index: macosx/tkMacOSXFileTypes.c
==================================================================
--- /dev/null
+++ macosx/tkMacOSXFileTypes.c
@@ -0,0 +1,122 @@
+/*
+There are situations where a graphical user interface needs to know the file
+type (i.e. data format) of a file.  The two main ones are when generating an
+icon to represent a file, and when filtering the choice of files in a file
+open or save dialog.
+
+Early Macintosh systems used OSTypes as identifiers for file types.  An OSType
+is a FourCC datatype - four bytes which can be packed into a 32 bit integer.  In
+the HFS filesystem they were included in the file metadata.  The metadata also
+included another OSType (the Creator Code) which identified the application
+which created the file.
+
+In OSX 10.4 the Uniform Type Identifier was introduced as an alternative way to
+describe file types.  These are strings (NSStrings, actually) in a reverse DNS
+format, such as "com.apple.application-bundle".  Apple provided a tool for
+converting OSType codes to Uniform Type Identifiers, which they deprecated in
+macOS 12.0 after introducing the UTType class in macOS 11.0.  An instance of the
+UTType class has properties which give the Uniform Type Identifier as well as
+the preferred file name extension for a given file type.
+
+This module provides tools for working with file types which are meant to abstract
+the many variants that Apple has used over the years, and which can be used
+without generating deprecation warnings.
+*/
+
+#include "tkMacOSXPrivate.h"
+#include "tkMacOSXFileTypes.h"
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
+#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
+#endif
+
+#define CHARS_TO_OSTYPE(string) (OSType) string[0] << 24 | \
+                                (OSType) string[1] << 16 | \
+                                (OSType) string[2] <<  8 | \
+                                (OSType) string[3]
+
+static BOOL initialized = false;
+static Tcl_HashTable ostype2identifier;
+static void initOSTypeTable(void) {
+    int newPtr;
+    Tcl_HashEntry *hPtr;
+    const IdentifierForOSType *entry;
+    Tcl_InitHashTable(&ostype2identifier, TCL_ONE_WORD_KEYS);
+    for (entry = OSTypeDB; entry->ostype != NULL; entry++) {
+	const char *key = INT2PTR(CHARS_TO_OSTYPE(entry->ostype));
+        hPtr = Tcl_CreateHashEntry(&ostype2identifier, key, &newPtr);
+	if (newPtr) {
+	    Tcl_SetHashValue(hPtr, entry->identifier);
+	}
+    }
+    initialized = true;
+}
+
+MODULE_SCOPE NSString *TkMacOSXOSTypeToUTI(OSType ostype) {
+    if (!initialized) {
+	initOSTypeTable();
+    }
+    Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&ostype2identifier, INT2PTR(ostype));
+    if (hPtr) {
+	char *UTI = Tcl_GetHashValue(hPtr);
+	return [[NSString alloc] initWithCString:UTI
+					encoding:NSASCIIStringEncoding];
+    }
+    return nil;
+}
+
+/*
+ * The NSWorkspace method iconForFileType, which was deprecated in macOS 12.0, would
+ * accept an NSString which could be an encoding of an OSType, or a file extension,
+ * or a Uniform Type Idenfier.  This function can serve as a replacement.
+ */
+MODULE_SCOPE NSImage *TkMacOSXIconForFileType(NSString *filetype) {
+    if (!initialized) {
+	initOSTypeTable();
+    }
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 110000
+// We don't have UTType but iconForFileType is not deprecated, so use it.
+    return [[NSWorkspace sharedWorkspace] iconForFileType:filetype];
+#else
+// We might have UTType but iconForFileType might be deprecated.
+    if (@available(macOS 11.0, *)) {
+	/* Yes, we do have UTType */
+	UTType *uttype = [UTType typeWithIdentifier: filetype];
+	if (uttype == nil || !uttype.isDeclared) {
+	    uttype = [UTType typeWithFilenameExtension: filetype];
+	}
+	if (uttype == nil || (!uttype.isDeclared && filetype.length == 4)) {
+	    OSType ostype = CHARS_TO_OSTYPE(filetype.UTF8String);
+	    NSString *UTI = TkMacOSXOSTypeToUTI(ostype);
+	    if (UTI) {
+		uttype = [UTType typeWithIdentifier:UTI];
+	    }
+	}
+	if (uttype == nil || !uttype.isDeclared) {
+	    return nil;
+	}
+	return [[NSWorkspace sharedWorkspace] iconForContentType:uttype];
+    } else {
+	/* No, we don't have UTType. */
+ #if MAC_OS_X_VERSION_MIN_REQUIRED < 110000
+	/* but iconForFileType is not deprecated, so we can use it. */
+    return [[NSWorkspace sharedWorkspace] iconForFileType:filetype];
+ #else
+    /*
+     * Cannot be reached: MIN_REQUIRED >= 110000 yet 11.0 is not available.
+     * But the compiler can't figure that out, so it will warn about an
+     * execution path with no return value unless we put a return here.
+     */
+    return nil;
+ #endif
+    }
+#endif
+}
+
+/*
+ * Local Variables:
+ * mode: objc
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */

ADDED   macosx/tkMacOSXFileTypes.h
Index: macosx/tkMacOSXFileTypes.h
==================================================================
--- /dev/null
+++ macosx/tkMacOSXFileTypes.h
@@ -0,0 +1,144 @@
+/*
+Apple never published a database of OSType codes for File Types.  However,
+a database of known OSType codes representing Creators and File Types used on
+Apple systems prior to 2003 is available at:
+
+   http://www.lacikam.co.il/tcdb/download/TCDBdata.zip
+
+Among the 12034 distinct OSType codes for File Types that are listed in the TCDB
+database, there are 121 for which the UTTypeCreatePreferredIdentifierForTag
+function (deprecated in macOS 12.0) was able to generate a Uniform Type
+Identifier on macOS 12.5.1.  The mapping from those OSTypes to Uniform Type
+identifiers is given by the following array, in which OSTypes are represented as
+strings of length 4.
+*/
+
+typedef struct {
+  const char *ostype;
+  const char *identifier;
+} IdentifierForOSType;
+
+static const IdentifierForOSType OSTypeDB[] = {
+    {".SGI", "com.sgi.sgi-image"},
+    {".WAV", "com.microsoft.waveform-audio"},
+    {"8BPS", "com.adobe.photoshop-image"},
+    {"ABPR", "com.apple.addressbook.person"},
+    {"AIFC", "public.aifc-audio"},
+    {"AIFF", "public.aiff-audio"},
+    {"APPC", "com.apple.deprecated-application-file"},
+    {"APPD", "com.apple.deprecated-application-file"},
+    {"APPL", "com.apple.application-bundle"},
+    {"ASF_", "com.microsoft.advanced-systems-format"},
+    {"ASX_", "com.microsoft.advanced-stream-redirector"},
+    {"BMP ", "com.microsoft.bmp"},
+    {"BMPf", "com.microsoft.bmp"},
+    {"BNDL", "com.apple.generic-bundle"},
+    {"DDim", "com.apple.disk-image-raw"},
+    {"DICM", "org.nema.dicom"},
+    {"DOTM", "org.openxmlformats.wordprocessingml.template.macro-enabled"},
+    {"EM3F", "com.apple.logic-song"},
+    {"EPSF", "com.adobe.encapsulated-postscript"},
+    {"FFIL", "com.apple.font-suitcase"},
+    {"FLI ", "public.flc-animation"},
+    {"FNDR", "com.apple.legacy.finder-icon"},
+    {"GIFf", "com.compuserve.gif"},
+    {"HTML", "public.html"},
+    {"JPEG", "public.jpeg"},
+    {"LWFN", "com.adobe.postscript-lwfn-font"},
+    {"MP3 ", "public.mp3"},
+    {"MP3!", "public.mp3"},
+    {"MP3U", "com.apple.tv.m3u-playlist"},
+    {"MPEG", "public.mpeg"},
+    {"MPG ", "public.mpeg"},
+    {"MPG2", "com.apple.music.mp2"},
+    {"MPG3", "public.mp3"},
+    {"Midi", "public.midi-audio"},
+    {"MooV", "com.apple.quicktime-movie"},
+    {"Mp3 ", "public.mp3"},
+    {"PAT ", "org.gimp.pat"},
+    {"PDF ", "com.adobe.pdf"},
+    {"PICT", "com.apple.pict"},
+    {"PNGf", "public.png"},
+    {"PNRA", "com.real.realaudio"},
+    {"PNRM", "com.real.realmedia"},
+    {"PNTG", "com.apple.macpaint-image"},
+    {"PPOT", "com.microsoft.powerpoint.pot"},
+    {"PPSS", "com.microsoft.powerpoint.pps"},
+    {"RTF ", "public.rtf"},
+    {"SDP ", "public.sdp"},
+    {"SIT5", "com.stuffit.archive.sit"},
+    {"SLD8", "com.microsoft.powerpoint.ppt"},
+    {"Sd2f", "com.digidesign.sd2-audio"},
+    {"TEXT", "com.apple.traditional-mac-plain-text"},
+    {"TIFF", "public.tiff"},
+    {"TPIC", "com.truevision.tga-image"},
+    {"ULAW", "public.ulaw-audio"},
+    {"VfW ", "public.avi"},
+    {"W8BN", "com.microsoft.word.doc"},
+    {"W8TN", "com.microsoft.word.dot"},
+    {"WAVE", "com.microsoft.waveform-audio"},
+    {"XLA5", "com.microsoft.excel.xla"},
+    {"XLS8", "com.microsoft.excel.xls"},
+    {"XLW8", "com.microsoft.excel.xlw"},
+    {"alis", "com.apple.alias-record"},
+    {"appe", "com.apple.deprecated-application-file"},
+    {"cdev", "com.apple.deprecated-application-file"},
+    {"clpp", "com.apple.finder.pictclipping"},
+    {"clps", "com.apple.finder.sound-clipping"},
+    {"clpt", "com.apple.finder.textclipping"},
+    {"clpu", "com.apple.finder.clipping"},
+    {"ctrl", "com.apple.legacy.finder-icon"},
+    {"dfil", "com.apple.deprecated-application-file"},
+    {"dict", "com.apple.document-type.dictionary"},
+    {"disk", "public.volume"},
+    {"docs", "com.apple.documents-folder"},
+    {"dvc!", "public.dv-movie"},
+    {"ffil", "com.apple.font-suitcase"},
+    {"flpy", "com.apple.storage-removable"},
+    {"fold", "public.folder"},
+    {"font", "com.apple.legacy.finder-icon"},
+    {"grup", "com.apple.user-group"},
+    {"hdrv", "com.apple.disk-image-raw"},
+    {"hdsk", "com.apple.storage-internal"},
+    {"help", "com.apple.help-document"},
+    {"hkdb", "com.apple.itunes.db"},
+    {"hvpl", "com.apple.music.visual"},
+    {"ilaf", "com.apple.afp-internet-location"},
+    {"ilfi", "com.apple.file-internet-location"},
+    {"ilft", "com.apple.ftp-internet-location"},
+    {"ilge", "com.apple.generic-internet-location"},
+    {"ilht", "com.apple.web-internet-location"},
+    {"ilma", "com.apple.mail-internet-location"},
+    {"ilnw", "com.apple.news-internet-location"},
+    {"macD", "com.apple.legacy.finder-icon"},
+    {"mp3!", "public.mp3"},
+    {"mpg3", "public.mp3"},
+    {"note", "com.apple.alert-note"},
+    {"osas", "com.apple.applescript.script"},
+    {"plug", "com.apple.plugin"},
+    {"pref", "com.apple.legacy.finder-icon"},
+    {"prfb", "com.apple.icon-overlay.private-folder-badge"},
+    {"prof", "com.apple.colorsync-profile"},
+    {"qtif", "com.apple.quicktime-image"},
+    {"sLS8", "com.microsoft.excel.xlt"},
+    {"sM3F", "com.apple.logic-song"},
+    {"sbBF", "com.apple.finder.burn-folder"},
+    {"scrp", "com.apple.legacy.finder-icon"},
+    {"sdoc", "com.apple.generic-stationery"},
+    {"sfnt", "com.apple.font-suitcase"},
+    {"shlb", "com.apple.legacy.finder-icon"},
+    {"srvr", "com.apple.file-server"},
+    {"svg ", "public.svg-image"},
+    {"svgz", "public.svg-image"},
+    {"tDoc", "com.apple.documents-folder"},
+    {"tfil", "com.apple.font-suitcase"},
+    {"trsh", "com.apple.trash-empty"},
+    {"ttcf", "public.truetype-collection-font"},
+    {"ttro", "com.apple.traditional-mac-plain-text"},
+    {"txtn", "com.apple.txn.text-multimedia-data"},
+    {"url ", "public.url"},
+    {"user", "com.apple.user"},
+    {"utxt", "public.utf16-plain-text"},
+    {"vCrd", "public.vcard"},
+    {NULL, NULL}
+};

Index: macosx/tkMacOSXFont.c
==================================================================
--- macosx/tkMacOSXFont.c
+++ macosx/tkMacOSXFont.c
@@ -2,13 +2,13 @@
  * tkMacOSXFont.c --
  *
  *	Contains the Macintosh implementation of the platform-independent font
  *	package interface.
  *
- * Copyright 2002-2004 Benjamin Riefenstahl, Benjamin.Riefenstahl@epost.de
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright 2008-2009, Apple Inc.
+ * Copyright © 2002-2004 Benjamin Riefenstahl, Benjamin.Riefenstahl@epost.de
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2008-2009 Apple Inc.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -110,11 +110,11 @@
 		       length:(NSUInteger)len
 {
     self = [self init];
     if (self) {
 	Tcl_DStringInit(&_ds);
-	Tcl_UtfToChar16DString(bytes, len, &_ds);
+	Tcl_UtfToChar16DString((const char *)bytes, len, &_ds);
 	_string = [[NSString alloc]
 	     initWithCharactersNoCopy:(unichar *)Tcl_DStringValue(&_ds)
 			       length:Tcl_DStringLength(&_ds)>>1
 			 freeWhenDone:NO];
 	self.UTF8String = _string.UTF8String;
@@ -125,11 +125,11 @@
 - (instancetype)initWithString:(NSString *)aString
 {
     self = [self init];
     if (self) {
 	_string = [[NSString alloc] initWithString:aString];
-	self.UTF8String = _string.UTF8String;
+	_UTF8String = _string.UTF8String;
     }
     return self;
 }
 
 - (void)dealloc
@@ -147,14 +147,10 @@
 - (unichar)characterAtIndex:(NSUInteger)index
 {
     return [_string characterAtIndex:index];
 }
 
-# ifndef __clang__
-@synthesize DString = _ds;
-#endif
-
 - (Tcl_DString)DString
 {
     if ( _ds.string == NULL) {
 
 	/*
@@ -175,10 +171,11 @@
     return _ds;
 }
 
 #ifndef __clang__
 @synthesize UTF8String = _UTF8String;
+@synthesize DString = _ds;
 #endif
 @end
 
 #define GetNSFontTraitsFromTkFontAttributes(faPtr) \
 	((faPtr)->weight == TK_FW_BOLD ? NSBoldFontMask : NSUnboldFontMask) | \
@@ -245,11 +242,11 @@
     NSFont *nsFont, *dflt = nil;
     #define defaultFont (dflt ? dflt : (dflt = [NSFont systemFontOfSize:0]))
     NSString *family;
 
     if (familyName) {
-	family = [[[NSString alloc] initWithUTF8String:familyName] autorelease];
+	family = [[[TKNSString alloc] initWithTclUtfBytes:familyName length:-1] autorelease];
     } else {
 	family = [defaultFont familyName];
     }
     if (size == 0.0) {
 	size = [defaultFont pointSize];
@@ -421,10 +418,109 @@
     TkFontAttributes *faPtr)
 {
     TkDeleteNamedFont(NULL, tkwin, name);
     return TkCreateNamedFont(interp, tkwin, name, faPtr);
 }
+
+#pragma mark -
+
+#pragma mark Grapheme Cluster indexing
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * startOfClusterObjCmd --
+ *
+ *      This function is invoked to process the startOfCluster command.
+ *
+ * Results:
+ *      A standard Tcl result.
+ *
+ * Side effects:
+ *      None
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+startOfClusterObjCmd(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,         /* Current interpreter. */
+    int objc,                   /* Number of arguments. */
+    Tcl_Obj *const objv[])      /* Argument objects. */
+{
+    TKNSString *S;
+    const char *stringArg;
+    int numBytes;
+    TkSizeT index;
+    if ((unsigned)(objc - 3) > 1) {
+	Tcl_WrongNumArgs(interp, 1 , objv, "str start ?locale?");
+	return TCL_ERROR;
+    }
+    stringArg = Tcl_GetStringFromObj(objv[1], &numBytes);
+    if (stringArg == NULL) {
+	return TCL_ERROR;
+    }
+    S = [[TKNSString alloc] initWithTclUtfBytes:stringArg length:numBytes];
+    if (TkGetIntForIndex(objv[2], [S length] - 1, 0, &index) != TCL_OK) {
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"bad index \"%s\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"",
+		Tcl_GetString(objv[2])));
+	Tcl_SetErrorCode(interp, "TK", "VALUE", "INDEX", NULL);
+	return TCL_ERROR;
+    }
+    if (index != TCL_INDEX_NONE) {
+	if ((size_t)index >= [S length]) {
+	    index = (TkSizeT)[S length];
+	} else {
+	    NSRange range = [S rangeOfComposedCharacterSequenceAtIndex:index];
+	    index = range.location;
+	}
+	Tcl_SetObjResult(interp, TkNewIndexObj(index));
+    }
+    return TCL_OK;
+}
+
+static int
+endOfClusterObjCmd(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,         /* Current interpreter. */
+    int objc,                   /* Number of arguments. */
+    Tcl_Obj *const objv[])      /* Argument objects. */
+{
+    TKNSString *S;
+    char *stringArg;
+    int numBytes;
+    TkSizeT index;
+
+    if ((unsigned)(objc - 3) > 1) {
+	Tcl_WrongNumArgs(interp, 1 , objv, "str start ?locale?");
+	return TCL_ERROR;
+    }
+    stringArg = Tcl_GetStringFromObj(objv[1], &numBytes);
+    if (stringArg == NULL) {
+	return TCL_ERROR;
+    }
+    S = [[TKNSString alloc] initWithTclUtfBytes:stringArg length:numBytes];
+    if (TkGetIntForIndex(objv[2], [S length] - 1, 0, &index) != TCL_OK) {
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"bad index \"%s\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"",
+		Tcl_GetString(objv[2])));
+	Tcl_SetErrorCode(interp, "TK", "VALUE", "INDEX", NULL);
+	return TCL_ERROR;
+    }
+    if ((size_t)index + 1 <= [S length]) {
+	if (index == TCL_INDEX_NONE) {
+		index = 0;
+	} else {
+	    NSRange range = [S rangeOfComposedCharacterSequenceAtIndex:index];
+	    index = range.location + range.length;
+	}
+	Tcl_SetObjResult(interp, TkNewIndexObj(index));
+    }
+    return TCL_OK;
+}
 
 #pragma mark -
 #pragma mark Font handling:
 
 /*
@@ -518,10 +614,12 @@
 	[cs removeCharactersInString:@" "];
 	lineendingCharacterSet = [cs copy];
 	[cs release];
     }
     [pool drain];
+    Tcl_CreateObjCommand(interp, "::tk::startOfCluster", startOfClusterObjCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "::tk::endOfCluster", endOfClusterObjCmd, NULL, NULL);
 }
 
 /*
  *---------------------------------------------------------------------------
  *
@@ -1154,11 +1252,10 @@
     int rangeLength,		/* Length of range to draw in bytes. */
     int x, int y)		/* Coordinates at which to place origin of the
 				 * whole (not just the range) string when
 				 * drawing. */
 {
-    (void)display;
     TkpDrawAngledCharsInContext(display, drawable, gc, tkfont, source, numBytes,
 	    rangeStart, rangeLength, x, y, 0.0);
 }
 
 void
@@ -1191,11 +1288,11 @@
     CFIndex start, length;
     CTLineRef line, full=nil;
     MacDrawable *macWin = (MacDrawable *)drawable;
     TkMacOSXDrawingContext drawingContext;
     CGContextRef context;
-    CGColorRef fg;
+    CGColorRef fg = NULL;
     NSFont *nsFont;
     CGAffineTransform t;
     CGFloat width, height, textX = (CGFloat) x, textY = (CGFloat) y;
 
     if (rangeStart < 0 || rangeLength <= 0  ||
@@ -1207,24 +1304,27 @@
     if (!string) {
 	return;
     }
 
     context = drawingContext.context;
-    fg = TkMacOSXCreateCGColor(gc, gc->foreground);
+    TkSetMacColor(gc->foreground, &fg);
     attributes = [fontPtr->nsAttributes mutableCopy];
-    [attributes setObject:(id)fg forKey:(id)kCTForegroundColorAttributeName];
-    CFRelease(fg);
+    if (fg) {
+	[attributes setObject:(id)fg forKey:(id)kCTForegroundColorAttributeName];
+	CGColorRelease(fg);
+    }
     nsFont = [attributes objectForKey:NSFontAttributeName];
     [nsFont setInContext:GET_NSCONTEXT(context, NO)];
     CGContextSetTextMatrix(context, CGAffineTransformIdentity);
     attributedString = [[NSAttributedString alloc] initWithString:string
 	    attributes:attributes];
+    [string release];
     typesetter = CTTypesetterCreateWithAttributedString(
 	    (CFAttributedStringRef)attributedString);
     textX += (CGFloat) macWin->xOff;
     textY += (CGFloat) macWin->yOff;
-    height = drawingContext.portBounds.size.height;
+    height = [drawingContext.view bounds].size.height;
     textY = height - textY;
     t = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, height);
     if (angle != 0.0) {
 	t = CGAffineTransformTranslate(
              CGAffineTransformRotate(
@@ -1252,11 +1352,10 @@
     CGContextSetTextPosition(context, textX, textY);
     CTLineDraw(line, context);
     CFRelease(line);
     CFRelease(typesetter);
     [attributedString release];
-    [string release];
     [attributes release];
     TkMacOSXRestoreDrawingContext(&drawingContext);
 }
 
 #pragma mark -

Index: macosx/tkMacOSXFont.h
==================================================================
--- macosx/tkMacOSXFont.h
+++ macosx/tkMacOSXFont.h
@@ -2,14 +2,14 @@
  * tkMacOSXFont.h --
  *
  *	Contains the Macintosh implementation of the platform-independent
  *	font package interface.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009, Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: macosx/tkMacOSXHLEvents.c
==================================================================
--- macosx/tkMacOSXHLEvents.c
+++ macosx/tkMacOSXHLEvents.c
@@ -1,15 +1,15 @@
 /*
  * tkMacOSXHLEvents.c --
  *
  *	Implements high level event support for the Macintosh.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright (c) 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2015-2019 Marc Culler
- * Copyright (c) 2019 Kevin Walzer/WordTech Communications LLC.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2015-2019 Marc Culler
+ * Copyright © 2019 Kevin Walzer/WordTech Communications LLC.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -57,10 +57,11 @@
 static const char openDocumentProc[] = "::tk::mac::OpenDocument";
 static const char launchURLProc[] = "::tk::mac::LaunchURL";
 static const char printDocProc[] = "::tk::mac::PrintDocument";
 static const char scriptFileProc[] = "::tk::mac::DoScriptFile";
 static const char scriptTextProc[] = "::tk::mac::DoScriptText";
+static const char getSdefProc[] = "::tk::mac::GetDynamicSdef";
 
 #pragma mark TKApplication(TKHLEvents)
 
 @implementation TKApplication(TKHLEvents)
 - (void) terminate: (id) sender
@@ -69,10 +70,11 @@
     [self handleQuitApplicationEvent:Nil withReplyEvent:Nil];
 }
 
 - (void) superTerminate: (id) sender
 {
+    (void) sender;
     [super terminate:nil];
 }
 
 - (void) preferences: (id) sender
 {
@@ -223,23 +225,22 @@
 	URLString[actual] = '\0';
 	fileURL = [NSURL URLWithString:[NSString stringWithUTF8String:(char*)URLString]];
 	if (fileURL == nil) {
 	    continue;
 	}
-	Tcl_ExternalToUtfDString(utf8, [[fileURL path] UTF8String], -1, &pathName);
+	(void)Tcl_ExternalToUtfDStringEx(utf8, [[fileURL path] UTF8String], -1,
+		TCL_ENCODING_NOCOMPLAIN, &pathName);
 	Tcl_DStringAppendElement(openCommand, Tcl_DStringValue(&pathName));
 	Tcl_DStringFree(&pathName);
     }
 
     Tcl_FreeEncoding(utf8);
     AEDisposeDesc(&contents);
     AEInfo->interp = _eventInterp;
     AEInfo->procedure = openDocumentProc;
     AEInfo->replyEvent = nil;
-    Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
     AEInfo->retryCount = 0;
-
     if (Tcl_FindCommand(_eventInterp, "::tk::mac::OpenDocuments", NULL, 0)){
 	ProcessAppleEvent((ClientData)AEInfo);
     } else {
 	Tcl_CreateTimerHandler(500, ProcessAppleEvent, (ClientData)AEInfo);
     }
@@ -259,11 +260,10 @@
     Tcl_DStringAppend(printCommand, printDocProc, -1);
     Tcl_DStringAppendElement(printCommand, printFile);
     AEInfo->interp = _eventInterp;
     AEInfo->procedure = printDocProc;
     AEInfo->replyEvent = nil;
-    Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
     AEInfo->retryCount = 0;
     ProcessAppleEvent((ClientData)AEInfo);
 }
 
 - (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event
@@ -322,11 +322,10 @@
                 Tcl_DStringAppend(scriptFileCommand, scriptFileProc, -1);
                 Tcl_DStringAppendElement(scriptFileCommand, [[fileURL path] UTF8String]);
                 AEInfo->interp = _eventInterp;
                 AEInfo->procedure = scriptFileProc;
                 AEInfo->replyEvent = nil;
-                Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
 		AEInfo->retryCount = 0;
                 ProcessAppleEvent((ClientData)AEInfo);
             }
         }
     } else if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeUTF8Text, &type,
@@ -354,11 +353,10 @@
                 if (Tcl_FindCommand(AEInfo->interp, AEInfo->procedure, NULL, 0)) {
                     AEInfo->replyEvent = replyEvent;
                     ProcessAppleEvent(AEInfo);
                 } else {
                     AEInfo->replyEvent = nil;
-                    Tcl_DoWhenIdle(ProcessAppleEvent, AEInfo);
                     ProcessAppleEvent(AEInfo);
                 }
 	    }
 	}
     }
@@ -378,13 +376,28 @@
     Tcl_DStringAppend(launchCommand, launchURLProc, -1);
     Tcl_DStringAppendElement(launchCommand, cURL);
     AEInfo->interp = _eventInterp;
     AEInfo->procedure = launchURLProc;
     AEInfo->replyEvent = nil;
-    Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
+    AEInfo->retryCount = 0;
+    ProcessAppleEvent((ClientData)AEInfo);
+}
+
+- (void)handleGetSDEFEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
+     AppleEventInfo *AEInfo = (AppleEventInfo *)ckalloc(sizeof(AppleEventInfo));
+    Tcl_DString *sdefCommand = &AEInfo->command;
+    (void)event;
+    (void)replyEvent;
+
+    Tcl_DStringInit(sdefCommand);
+    Tcl_DStringAppend(sdefCommand, getSdefProc, -1);
+    AEInfo->interp = _eventInterp;
+    AEInfo->procedure =  getSdefProc;
+    AEInfo->replyEvent = nil;
     AEInfo->retryCount = 0;
     ProcessAppleEvent((ClientData)AEInfo);
+
 }
 
 @end
 
 #pragma mark -
@@ -520,10 +533,19 @@
 
 	[aeManager setEventHandler:NSApp
 	    andSelector:@selector(handleURLEvent:withReplyEvent:)
 	    forEventClass:kInternetEventClass andEventID:kAEGetURL];
 
+	/*
+	 * We do not load our sdef dynamically but this event handler
+         * is required to silence error messages from inline execution
+         * of AppleScript at the Objective-C level.
+	 */
+	[aeManager setEventHandler:NSApp
+	    andSelector:@selector(handleGetSDEFEvent:withReplyEvent:)
+	    forEventClass:'ascr' andEventID:'gsdf'];
+
     }
 }
 
 /*
  *----------------------------------------------------------------------

Index: macosx/tkMacOSXImage.c
==================================================================
--- macosx/tkMacOSXImage.c
+++ macosx/tkMacOSXImage.c
@@ -1,25 +1,93 @@
 /*
  * tkMacOSXImage.c --
  *
- *	The code in this file provides an interface for XImages,
+ *	The code in this file provides an interface for XImages, and
+ *      implements the nsimage image type.
  *
  * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2001-2009, Apple Inc.
  * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2017-2020 Marc Culler.
+ * Copyright (c) 2017-2021 Marc Culler.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
 #include "tkMacOSXPrivate.h"
+#include "tkMacOSXConstants.h"
+#include "tkColor.h"
 #include "xbytes.h"
 
 static CGImageRef CreateCGImageFromPixmap(Drawable pixmap);
 static CGImageRef CreateCGImageFromDrawableRect( Drawable drawable,
 	   int x, int y, unsigned int width, unsigned int height);
+
+/* Pixel formats
+ *
+ * Tk uses the XImage structure defined in Xlib.h for storing images.  The
+ * image data in an XImage is a 32-bit aligned array of bytes.  Interpretation
+ * of that data is not specified, but the structure includes parameters which
+ * provide interpretation hints so that an application can use a family of
+ * different data structures.
+ *
+ * The possible values for the XImage format field are XYBitmap, XYPixmap and
+ * ZPixmap.  The macOS port does not support the XYPixmap format.  This means
+ * that bitmap images are stored as a single bit plane (XYBitmap) and that
+ * color images are stored as a sequence of pixel values (ZPixmap).
+ *
+ * For a ZPixmap, the number of bits allocated to each pixel is specified by
+ * the bits_per_pixel field of the XImage structure.  The functions in this
+ * module which convert between XImage and native CGImage or NSImage structures
+ * only support XImages with 32 bits per pixel.  The ImageGetPixel and PutPixel
+ * implementations in this file allow 1, 4, 8, 16 or 32 bits per pixel, however.
+ *
+ * In tkImgPhInstance.c the layout used for pixels is determined by the values
+ * of the red_mask, blue_mask and green_mask fields in the XImage structure.
+ * The Aqua port always sets red_mask = 0xFF0000, green_mask = 0xFF00, and
+ * blue_mask = 0xFF. This means that a 32bpp ZPixmap XImage uses ARGB32 pixels,
+ * with small-endian byte order BGRA. The data array for such an XImage can be
+ * passed directly to construct a CGBitmapImageRep if one specifies the
+ * bitmapInfo as kCGBitmapByteOrder32Big | kCGImageAlphaLast.
+ *
+ * The structures below describe the bitfields in two common 32 bpp pixel
+ * layouts.  Note that bit field layouts are compiler dependent. The layouts
+ * shown in the comments are those produced by clang and gcc.  Also note
+ * that kCGBitmapByteOrder32Big is consistently set when creating CGImages or
+ * CGImageBitmapReps.
+ */
+
+/* RGBA32 0xRRGGBBAA (Byte order is RGBA on big-endian systems.)
+ * This is used by NSBitmapImageRep when the bitmapFormat property is 0,
+ * the default value.
+ */
+
+typedef struct RGBA32pixel_t {
+    unsigned red: 8;
+    unsigned green: 8;
+    unsigned blue: 8;
+    unsigned alpha: 8;
+} RGBA32pixel;
+
+/*
+ * ARGB32 0xAARRGGBB (Byte order is ARGB on big-endian systems.)
+ * This is used by Aqua Tk for XImages and by NSBitmapImageReps whose
+ * bitmapFormat property is NSAlphaFirstBitmapFormat.
+ */
+
+typedef struct ARGB32pixel_t {
+    unsigned blue: 8;
+    unsigned green: 8;
+    unsigned red: 8;
+    unsigned alpha: 8;
+} ARGB32pixel;
+
+typedef union pixel32_t {
+    unsigned int uint;
+    RGBA32pixel rgba;
+    ARGB32pixel argb;
+} pixel32;
 
 #pragma mark XImage handling
 
 int
 _XInitImageFuncPtrs(
@@ -46,18 +114,19 @@
  */
 
 static void ReleaseData(
     void *info,
     TCL_UNUSED(const void *), /* data */
-    TCL_UNUSED(size_t))       /* size */
+    TCL_UNUSED(size_t))        /* size */
 {
     ckfree(info);
 }
 
 CGImageRef
 TkMacOSXCreateCGImageWithXImage(
-    XImage *image)
+    XImage *image,
+    uint32_t alphaInfo)
 {
     CGImageRef img = NULL;
     size_t bitsPerComponent, bitsPerPixel;
     size_t len = image->bytes_per_line * image->height;
     const CGFloat *decode = NULL;
@@ -75,59 +144,63 @@
 	static const CGFloat decodeWB[2] = {1, 0};
 	decode = decodeWB;
 
 	bitsPerComponent = 1;
 	bitsPerPixel = 1;
-	if (image->bitmap_bit_order != MSBFirst) {
-	    char *srcPtr = image->data + image->xoffset;
-	    char *endPtr = srcPtr + len;
-	    char *destPtr = (data = (char *)ckalloc(len));
-
-	    while (srcPtr < endPtr) {
-		*destPtr++ = xBitReverseTable[(unsigned char)(*(srcPtr++))];
-	    }
-	} else {
-	    data = memcpy(ckalloc(len), image->data + image->xoffset, len);
-	}
+	data = (char *)ckalloc(len);
 	if (data) {
+	    if (image->bitmap_bit_order != MSBFirst) {
+		char *srcPtr = image->data + image->xoffset;
+		char *endPtr = srcPtr + len;
+		char *destPtr = data;
+
+		while (srcPtr < endPtr) {
+		    *destPtr++ = xBitReverseTable[(unsigned char)(*(srcPtr++))];
+		}
+	    } else {
+		memcpy(data, image->data + image->xoffset, len);
+	    }
 	    provider = CGDataProviderCreateWithData(data, data, len,
 		    releaseData);
-	}
-	if (provider) {
+	    if (!provider) {
+		ckfree(data);
+	    }
 	    img = CGImageMaskCreate(image->width, image->height,
 		    bitsPerComponent, bitsPerPixel, image->bytes_per_line,
 		    provider, decode, 0);
+	    CGDataProviderRelease(provider);
 	}
     } else if ((image->format == ZPixmap) && (image->bits_per_pixel == 32)) {
+
 	/*
 	 * Color image
 	 */
 
-	CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
-
 	if (image->width == 0 && image->height == 0) {
+
 	    /*
 	     * CGCreateImage complains on early macOS releases.
 	     */
 
 	    return NULL;
 	}
+	CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
 	bitsPerComponent = 8;
 	bitsPerPixel = 32;
-	bitmapInfo = (image->byte_order == MSBFirst ?
-		kCGBitmapByteOrder32Little : kCGBitmapByteOrder32Big);
-	bitmapInfo |= kCGImageAlphaLast;
-	data = memcpy(ckalloc(len), image->data + image->xoffset, len);
+	bitmapInfo = kCGBitmapByteOrder32Big | alphaInfo;
+	data = (char *)ckalloc(len);
 	if (data) {
+	    memcpy(data, image->data + image->xoffset, len);
 	    provider = CGDataProviderCreateWithData(data, data, len,
 		    releaseData);
-	}
-	if (provider) {
+	    if (!provider) {
+		ckfree(data);
+	    }
 	    img = CGImageCreate(image->width, image->height, bitsPerComponent,
 		    bitsPerPixel, image->bytes_per_line, colorspace, bitmapInfo,
 		    provider, decode, 0, kCGRenderingIntentDefault);
-	    CFRelease(provider);
+	    CGDataProviderRelease(provider);
 	}
 	if (colorspace) {
 	    CFRelease(colorspace);
 	}
     } else {
@@ -203,18 +276,16 @@
 		+ (y * image->bytes_per_line)
 		+ (((image->xoffset + x) * image->bits_per_pixel) / NBBY);
 
 	switch (image->bits_per_pixel) {
 	case 32: /* 8 bits per channel */
-	    r = (*((unsigned int*) srcPtr) >> 16) & 0xff;
-	    g = (*((unsigned int*) srcPtr) >>  8) & 0xff;
-	    b = (*((unsigned int*) srcPtr)      ) & 0xff;
-	    /*if (image->byte_order == LSBFirst) {
-		r = srcPtr[2]; g = srcPtr[1]; b = srcPtr[0];
-	    } else {
-		r = srcPtr[1]; g = srcPtr[2]; b = srcPtr[3];
-	    }*/
+	    {
+		ARGB32pixel *pixel = (ARGB32pixel *)srcPtr;
+		r = pixel->red;
+		g = pixel->green;
+		b = pixel->blue;
+	    }
 	    break;
 	case 16: /* 5 bits per channel */
 	    r = (*((unsigned short*) srcPtr) >> 7) & 0xf8;
 	    g = (*((unsigned short*) srcPtr) >> 2) & 0xf8;
 	    b = (*((unsigned short*) srcPtr) << 3) & 0xf8;
@@ -247,11 +318,14 @@
 /*
  *----------------------------------------------------------------------
  *
  * ImagePutPixel --
  *
- *	Set a single pixel in an image.
+ *	Set a single pixel in an image.  The pixel is provided as an unsigned
+ *      32-bit integer.  The value of that integer is interpreted by assuming
+ *      that its low-order N bits have the format specified by the XImage,
+ *      where N is equal to the bits_per_pixel field of the XImage.
  *
  * Results:
  *	None.
  *
  * Side effects:
@@ -273,31 +347,24 @@
 		+ (((image->xoffset + x) * image->bits_per_pixel) / NBBY);
 
 	if (image->bits_per_pixel == 32) {
 	    *((unsigned int*) dstPtr) = pixel;
 	} else {
-	    unsigned char r = ((pixel & image->red_mask)   >> 16) & 0xff;
-	    unsigned char g = ((pixel & image->green_mask) >>  8) & 0xff;
-	    unsigned char b = ((pixel & image->blue_mask)       ) & 0xff;
 	    switch (image->bits_per_pixel) {
 	    case 16:
-		*((unsigned short*) dstPtr) = ((r & 0xf8) << 7) |
-			((g & 0xf8) << 2) | ((b & 0xf8) >> 3);
+		*((unsigned short*) dstPtr) = pixel & 0xffff;
 		break;
 	    case 8:
-		*dstPtr = ((r & 0xc0) >> 2) | ((g & 0xc0) >> 4) |
-			((b & 0xc0) >> 6);
+		*dstPtr = pixel & 0xff;
 		break;
 	    case 4: {
-		unsigned char c = ((r & 0x80) >> 5) | ((g & 0x80) >> 6) |
-			((b & 0x80) >> 7);
-		*dstPtr = (x % 2) ? ((*dstPtr & 0xf0) | (c & 0x0f)) :
-			((*dstPtr & 0x0f) | ((c << 4) & 0xf0));
+		*dstPtr = (x % 2) ? ((*dstPtr & 0xf0) | (pixel & 0x0f)) :
+			((*dstPtr & 0x0f) | ((pixel << 4) & 0xf0));
 		break;
 		}
 	    case 1:
-		*dstPtr = ((r|g|b) & 0x80) ? (*dstPtr | (0x80 >> (x % 8))) :
+		*dstPtr = pixel ? (*dstPtr | (0x80 >> (x % 8))) :
 			(*dstPtr & ~(0x80 >> (x % 8)));
 		break;
 	    }
 	}
     }
@@ -321,11 +388,11 @@
  */
 
 XImage *
 XCreateImage(
     Display* display,
-    TCL_UNUSED(Visual*),  /* visual */
+    TCL_UNUSED(Visual*), /* visual */
     unsigned int depth,
     int format,
     int offset,
     char* data,
     unsigned int width,
@@ -334,11 +401,11 @@
     int bytes_per_line)
 {
     XImage *ximage;
 
     display->request++;
-    ximage = ckalloc(sizeof(XImage));
+    ximage = (XImage *)ckalloc(sizeof(XImage));
 
     ximage->height = height;
     ximage->width = width;
     ximage->depth = depth;
     ximage->xoffset = offset;
@@ -390,107 +457,163 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * XPutImage --
+ * TkPutImage, XPutImage, TkpPutRGBAImage --
  *
- *	Copies a rectangular subimage of an XImage into a drawable.  Currently
- *      this is only called by TkImgPhotoDisplay, using a Window as the
- *      drawable.
+ *	These functions, which all have the same signature, copy a rectangular
+ *      subimage of an XImage into a drawable.  TkPutImage is an alias for
+ *      XPutImage, which assumes that the XImage data has the structure of a
+ *      32bpp ZPixmap in which the image data is an array of 32bit integers
+ *      packed with 8 bit values for the Red Green and Blue channels.  The
+ *      fourth byte is ignored.  The function TkpPutRGBAImage assumes that the
+ *      XImage data has been extended by using the fourth byte to store an
+ *      8-bit Alpha value.  (The Alpha data is assumed not to pre-multiplied).
+ *      The image is then drawn into the drawable using standard Porter-Duff
+ *      Source Atop Composition (kCGBlendModeSourceAtop in Apple's Core
+ *      Graphics).
+ *
+ *      The TkpPutRGBAImage function is used by TkImgPhotoDisplay to render photo
+ *      images if the compile-time variable TK_CAN_RENDER_RGBA is defined in
+ *      a platform's tkXXXXPort.h header, as is the case for the macOS Aqua port.
  *
  * Results:
- *	None.
+ *	These functions return either BadDrawable or Success.
  *
  * Side effects:
  *	Draws the image on the specified drawable.
  *
  *----------------------------------------------------------------------
  */
 
-int
-XPutImage(
+#define USE_ALPHA kCGImageAlphaLast
+#define IGNORE_ALPHA kCGImageAlphaNoneSkipLast
+
+static int
+TkMacOSXPutImage(
+    uint32_t pixelFormat,
     Display* display,		/* Display. */
     Drawable drawable,		/* Drawable to place image on. */
     GC gc,			/* GC to use. */
     XImage* image,		/* Image to place. */
     int src_x,			/* Source X & Y. */
     int src_y,
     int dest_x,			/* Destination X & Y. */
     int dest_y,
     unsigned int width,	        /* Same width & height for both */
-    unsigned int height)	/* distination and source. */
+    unsigned int height)	/* destination and source. */
 {
     TkMacOSXDrawingContext dc;
     MacDrawable *macDraw = (MacDrawable *)drawable;
+    int result = Success;
 
     display->request++;
     if (!TkMacOSXSetupDrawingContext(drawable, gc, &dc)) {
 	return BadDrawable;
     }
     if (dc.context) {
 	CGRect bounds, srcRect, dstRect;
-	CGImageRef img = TkMacOSXCreateCGImageWithXImage(image);
+	CGImageRef img = TkMacOSXCreateCGImageWithXImage(image, pixelFormat);
 
 	/*
 	 * The CGContext for a pixmap is RGB only, with A = 0.
 	 */
 
 	if (!(macDraw->flags & TK_IS_PIXMAP)) {
 	    CGContextSetBlendMode(dc.context, kCGBlendModeSourceAtop);
 	}
 	if (img) {
-
 	    bounds = CGRectMake(0, 0, image->width, image->height);
 	    srcRect = CGRectMake(src_x, src_y, width, height);
 	    dstRect = CGRectMake(dest_x, dest_y, width, height);
 	    TkMacOSXDrawCGImage(drawable, gc, dc.context,
 				img, gc->foreground, gc->background,
 				bounds, srcRect, dstRect);
 	    CFRelease(img);
 	} else {
 	    TkMacOSXDbgMsg("Invalid source drawable");
+	    result = BadDrawable;
 	}
     } else {
 	TkMacOSXDbgMsg("Invalid destination drawable");
+	result = BadDrawable;
     }
     TkMacOSXRestoreDrawingContext(&dc);
-    return Success;
+    return result;
 }
+
+int XPutImage(
+    Display* display,
+    Drawable drawable,
+    GC gc,
+    XImage* image,
+    int src_x,
+    int src_y,
+    int dest_x,
+    int dest_y,
+    unsigned int width,
+    unsigned int height) {
+    return TkMacOSXPutImage(IGNORE_ALPHA, display, drawable, gc, image,
+			    src_x, src_y, dest_x, dest_y, width, height);
+}
+
+int TkpPutRGBAImage(
+    Display* display,
+    Drawable drawable,
+    GC gc,
+    XImage* image,
+    int src_x,
+    int src_y,
+    int dest_x,
+    int dest_y,
+    unsigned int width,
+    unsigned int height) {
+    return TkMacOSXPutImage(USE_ALPHA, display, drawable, gc, image,
+		     src_x, src_y, dest_x, dest_y, width, height);
+}
+
 
 /*
  *----------------------------------------------------------------------
  *
  * CreateCGImageFromDrawableRect
  *
- *	Extract image data from a MacOSX drawable as a CGImage.
- *
- *      This is only called by XGetImage and XCopyArea.  The Tk core uses
- *      these functions on some platforms, but on macOS the core does not
- *      call them with a source drawable which is a window.  Such calls are
- *      used only for double-buffered drawing.  Since macOS defines the
- *      macro TK_NO_DOUBLE_BUFFERING, the generic code never calls XGetImage
- *      or XCopyArea on macOS.  Nonetheless, these function are in the stubs
- *      table and therefore could be used by extensions.
- *
- *      This implementation does not work correctly.  Originally it relied on
+ *	Extract image data from a MacOSX drawable as a CGImage.  The drawable
+ *      may be either a pixmap or a window, but there issues in the case of
+ *      a window.
+ *
+ *      CreateCGImageFromDrawableRect is called by XGetImage and XCopyArea.
+ *      The Tk core uses these two functions on some platforms in order to
+ *      implement explicit double-buffered drawing -- a pixmap is copied from a
+ *      window, modified using CPU-based graphics composition, and then copied
+ *      back to the window.  Platforms, such as macOS, on which the system
+ *      provides double-buffered drawing and GPU-based composition operations
+ *      can avoid calls to XGetImage and XCopyArea from the core by defining
+ *      the compile-time variable TK_NO_DOUBLE_BUFFERING.  Nonetheless, these
+ *      two functions are in the stubs table and therefore could be used by
+ *      extensions.
+ *
+ *      The implementation here does not always work correctly when the source
+ *      is a window.  The original version of this function relied on
  *      [NSBitmapImageRep initWithFocusedViewRect:view_rect] which was
  *      deprecated by Apple in OSX 10.14 and also required the use of other
  *      deprecated functions such as [NSView lockFocus]. Apple's suggested
  *      replacement is [NSView cacheDisplayInRect: toBitmapImageRep:] and that
- *      is what is being used here.  However, that method only works when the
- *      view has a valid CGContext, and a view is only guaranteed to have a
- *      valid context during a call to [NSView drawRect]. To further complicate
- *      matters, cacheDisplayInRect calls [NSView drawRect]. Essentially it is
- *      asking the view to draw a subrectangle of itself using a special
- *      graphics context which is linked to the BitmapImageRep. But our
- *      implementation of [NSView drawRect] does not allow recursive calls. If
- *      called recursively it returns immediately without doing any drawing.
- *      So the bottom line is that this function either returns a NULL pointer
- *      or a black image. To make it useful would require a significant amount
- *      of rewriting of the drawRect method. Perhaps the next release of OSX
- *      will include some more helpful ways of doing this.
+ *      is being used here.  However, cacheDisplayInRect works by calling
+ *      [NSView drawRect] after setting the current graphics context to be one
+ *      which draws to a bitmap.  There are situations in which this can be
+ *      used, e.g. when taking a screenshot of a window.  But it cannot be used
+ *      as part of a normal display procedure, using the copy-modify-paste
+ *      paradigm that is the basis of the explicit double-buffering.  Since the
+ *      copy operation will call the same display procedure that is calling
+ *      this function via XGetImage or XCopyArea, this would create an infinite
+ *      recursion.
+ *
+ *      An alternative to the copy-modify-paste paradigm is to use GPU-based
+ *      graphics composition, clipping to the specified rectangle.  That is
+ *      the approach that must be followed by display procedures on macOS.
  *
  * Results:
  *	Returns an NSBitmapRep representing the image of the given rectangle of
  *      the given drawable. This object is retained. The caller is responsible
  *      for releasing it.
@@ -514,53 +637,41 @@
     unsigned int height)
 {
     MacDrawable *mac_drawable = (MacDrawable *)drawable;
     CGContextRef cg_context = NULL;
     CGImageRef cg_image = NULL, result = NULL;
-    NSBitmapImageRep *bitmapRep = NULL;
-    NSView *view = NULL;
     if (mac_drawable->flags & TK_IS_PIXMAP) {
-	/*
-	 * This MacDrawable is a bitmap, so its view is NULL.
-	 */
-
-	CGRect image_rect = CGRectMake(x, y, width, height);
-
 	cg_context = TkMacOSXGetCGContextForDrawable(drawable);
-	cg_image = CGBitmapContextCreateImage((CGContextRef) cg_context);
-	if (cg_image) {
-	    result = CGImageCreateWithImageInRect(cg_image, image_rect);
-	    CGImageRelease(cg_image);
-	}
-    } else if (TkMacOSXGetNSViewForDrawable(mac_drawable) != NULL) {
-
-	/*
-	 * Convert Tk top-left to NSView bottom-left coordinates.
-	 */
-
-	int view_height = [view bounds].size.height;
-	NSRect view_rect = NSMakeRect(x + mac_drawable->xOff,
-		view_height - height - y - mac_drawable->yOff,
-		width, height);
-
-	/*
-	 * Attempt to copy from the view to a bitmapImageRep.  If the view does
-	 * not have a valid CGContext, doing this will silently corrupt memory
-	 * and make a big mess. So, in that case, we just return NULL.
-	 */
-
-	if (view == [NSView focusView]) {
-	    bitmapRep = [view bitmapImageRepForCachingDisplayInRect: view_rect];
-	    [view cacheDisplayInRect:view_rect toBitmapImageRep:bitmapRep];
-	    result = [bitmapRep CGImage];
-	    CFRelease(bitmapRep);
-	} else {
-	    TkMacOSXDbgMsg("No CGContext - cannot copy from screen to bitmap.");
-	    result = NULL;
-	}
-    } else {
-	TkMacOSXDbgMsg("Invalid source drawable");
+	CGContextRetain(cg_context);
+    } else {
+	NSView *view = TkMacOSXGetNSViewForDrawable(mac_drawable);
+	if (view == nil) {
+	    TkMacOSXDbgMsg("Invalid source drawable");
+	    return NULL;
+	}
+	NSSize size = view.frame.size;
+	NSUInteger view_width = size.width, view_height = size.height;
+        NSUInteger bytesPerPixel = 4,
+	    bytesPerRow = bytesPerPixel * view_width,
+	    bitsPerComponent = 8;
+	CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+	cg_context = CGBitmapContextCreate(NULL, view_width, view_height,
+			 bitsPerComponent, bytesPerRow, colorSpace,
+			 kCGImageAlphaPremultipliedLast |
+			 kCGBitmapByteOrder32Big);
+	CFRelease(colorSpace);
+	[view.layer renderInContext:cg_context];
+    }
+    if (cg_context) {
+	cg_image = CGBitmapContextCreateImage(cg_context);
+	CGContextRelease(cg_context);
+    }
+    if (cg_image) {
+	CGRect rect = CGRectMake(x + mac_drawable->xOff, y + mac_drawable->yOff,
+				 width, height);
+	result = CGImageCreateWithImageInRect(cg_image, rect);
+	CGImageRelease(cg_image);
     }
     return result;
 }
 
 /*
@@ -612,30 +723,26 @@
  * Side effects:
  *	None.
  *
  *----------------------------------------------------------------------
  */
-struct pixel_fmt {int r; int g; int b; int a;};
-static struct pixel_fmt bgra = {2, 1, 0, 3};
-static struct pixel_fmt abgr = {3, 2, 1, 0};
 
 XImage *
 XGetImage(
     Display *display,
     Drawable drawable,
     int x,
     int y,
     unsigned int width,
     unsigned int height,
-    TCL_UNUSED(unsigned long), /* plane_mask */
+    TCL_UNUSED(unsigned long),  /* plane_mask */
     int format)
 {
-    NSBitmapImageRep* bitmapRep = NULL;
+    NSBitmapImageRep* bitmapRep = nil;
     NSUInteger bitmap_fmt = 0;
     XImage* imagePtr = NULL;
-    char* bitmap = NULL;
-    char R, G, B, A;
+    char *bitmap = NULL;
     int depth = 32, offset = 0, bitmap_pad = 0;
     unsigned int bytes_per_row, size, row, n, m;
 
     if (format == ZPixmap) {
 	CGImageRef cgImage;
@@ -653,53 +760,54 @@
 	    return NULL;
 	}
 	bitmap_fmt = [bitmapRep bitmapFormat];
 	size = [bitmapRep bytesPerPlane];
 	bytes_per_row = [bitmapRep bytesPerRow];
-	bitmap = ckalloc(size);
-	if (!bitmap
-		|| (bitmap_fmt != 0 && bitmap_fmt != 1)
-		|| [bitmapRep samplesPerPixel] != 4
-		|| [bitmapRep isPlanar] != 0
-		|| bytes_per_row < 4 * width
-		|| size != bytes_per_row * height) {
+	bitmap = (char *)ckalloc(size);
+	if ((bitmap_fmt != 0 && bitmap_fmt != NSAlphaFirstBitmapFormat)
+	    || [bitmapRep samplesPerPixel] != 4
+	    || [bitmapRep isPlanar] != 0
+	    || bytes_per_row < 4 * width
+	    || size != bytes_per_row * height) {
 	    TkMacOSXDbgMsg("XGetImage: Unrecognized bitmap format");
-	    CFRelease(bitmapRep);
+	    [bitmapRep release];
 	    return NULL;
 	}
 	memcpy(bitmap, (char *)[bitmapRep bitmapData], size);
-	CFRelease(bitmapRep);
-
-	/*
-	 * When Apple extracts a bitmap from an NSView, it may be in either
-	 * BGRA or ABGR format.  For an XImage we need RGBA.
-	 */
-
-	struct pixel_fmt pixel = bitmap_fmt == 0 ? bgra : abgr;
+	[bitmapRep release];
 
 	for (row = 0, n = 0; row < height; row++, n += bytes_per_row) {
 	    for (m = n; m < n + 4*width; m += 4) {
-		R = *(bitmap + m + pixel.r);
-		G = *(bitmap + m + pixel.g);
-		B = *(bitmap + m + pixel.b);
-		A = *(bitmap + m + pixel.a);
-
-		*(bitmap + m)     = R;
-		*(bitmap + m + 1) = G;
-		*(bitmap + m + 2) = B;
-		*(bitmap + m + 3) = A;
+		pixel32 pixel = *((pixel32 *)(bitmap + m));
+		if (bitmap_fmt == 0) { // default format
+
+		    /*
+		     * This pixel is in ARGB32 format.  We need RGBA32.
+		     */
+
+		    pixel32 flipped;
+		    flipped.rgba.red = pixel.argb.red;
+		    flipped.rgba.green = pixel.argb.green;
+		    flipped.rgba.blue = pixel.argb.blue;
+		    flipped.rgba.alpha = pixel.argb.alpha;
+		    *((pixel32 *)(bitmap + m)) = flipped;
+		} else { // bitmap_fmt = NSAlphaFirstBitmapFormat
+		    *((pixel32 *)(bitmap + m)) = pixel;
+		}
 	    }
 	}
 	imagePtr = XCreateImage(display, NULL, depth, format, offset,
 		(char*) bitmap, width, height,
 		bitmap_pad, bytes_per_row);
     } else {
+
 	/*
 	 * There are some calls to XGetImage in the generic Tk code which pass
 	 * an XYPixmap rather than a ZPixmap.  XYPixmaps should be handled
 	 * here.
 	 */
+
 	TkMacOSXDbgMsg("XGetImage does not handle XYPixmaps at the moment.");
     }
     return imagePtr;
 }
 
@@ -902,14 +1010,720 @@
 
 	return XCopyArea(display, src, dst, gc, src_x, src_y, width, height,
 		dest_x, dest_y);
     }
 }
+
+/* ---------------------------------------------------------------------------*/
+
+/*
+ * Implementation of a Tk image type which provide access to NSImages
+ * for use in buttons etc.
+ */
+
+/*
+ * Forward declarations.
+ */
+
+typedef struct TkMacOSXNSImageInstance TkMacOSXNSImageInstance;
+typedef struct TkMacOSXNSImageModel TkMacOSXNSImageModel;
+
+/*
+ * The following data structure represents a particular use of an nsimage
+ * in a widget.
+ */
+
+struct TkMacOSXNSImageInstance {
+    TkMacOSXNSImageModel *modelPtr;   /* Pointer to the model for the image. */
+    NSImage *image;		  /* Pointer to an NSImage.*/
+    TkMacOSXNSImageInstance *nextPtr;   /* First in the list of instances associated
+				   * with this model. */
+};
+
+/*
+ * The following data structure represents the model for an nsimage:
+ */
+
+struct TkMacOSXNSImageModel {
+    Tk_ImageModel tkModel;	      /* Tk's token for image model. */
+    Tcl_Interp *interp;		      /* Interpreter for application. */
+    int width, height;		      /* Dimensions of the image. */
+    int radius;                       /* Radius for rounded corners. */
+    int ring;                         /* Thickness of the focus ring. */
+    double alpha;                     /* Transparency, between 0.0 and 1.0*/
+    bool pressed;                     /* Image is for use in a pressed button.*/
+    bool template;                    /* Image is for use as a template.*/
+    char *imageName ;                 /* Malloc'ed image name. */
+    char *source;       	      /* Malloc'ed string describing the image. */
+    char *as;                         /* Malloc'ed interpretation of source */
+    int	flags;			      /* Sundry flags, defined below. */
+    TkMacOSXNSImageInstance *instancePtr;   /* Start of list of instances associated
+				       * with this model. */
+    NSImage *image;                   /* The underlying NSImage object. */
+    NSImage *darkModeImage;           /* A modified image to use in Dark Mode. */
+};
+
+/*
+ * Bit definitions for the flags field of a TkMacOSXNSImageModel.
+ * IMAGE_CHANGED:		1 means that the instances of this image need
+ *				to be redisplayed.
+ */
+
+#define IMAGE_CHANGED		1
+
+/*
+ * The type record for nsimage images:
+ */
+
+static int		TkMacOSXNSImageCreate(Tcl_Interp *interp,
+			    const char *name, int argc, Tcl_Obj *const objv[],
+			    const Tk_ImageType *typePtr, Tk_ImageModel model,
+			    ClientData *clientDataPtr);
+static ClientData	TkMacOSXNSImageGet(Tk_Window tkwin, ClientData clientData);
+static void		TkMacOSXNSImageDisplay(ClientData clientData,
+			    Display *display, Drawable drawable,
+			    int imageX, int imageY, int width,
+			    int height, int drawableX,
+			    int drawableY);
+static void		TkMacOSXNSImageFree(ClientData clientData, Display *display);
+static void		TkMacOSXNSImageDelete(ClientData clientData);
+
+static Tk_ImageType TkMacOSXNSImageType = {
+    "nsimage",			/* name of image type */
+    TkMacOSXNSImageCreate,		/* createProc */
+    TkMacOSXNSImageGet,		/* getProc */
+    TkMacOSXNSImageDisplay,		/* displayProc */
+    TkMacOSXNSImageFree,		/* freeProc */
+    TkMacOSXNSImageDelete,		/* deleteProc */
+    NULL,			/* postscriptPtr */
+    NULL,			/* nextPtr */
+    NULL
+};
+
+/*
+ * Default values used for parsing configuration specifications:
+ */
+#define DEF_SOURCE   ""
+#define DEF_AS       "name"
+#define DEF_HEIGHT   "0"
+#define DEF_WIDTH    "0"
+#define DEF_RADIUS   "0"
+#define DEF_RING     "0"
+#define DEF_ALPHA    "1.0"
+#define DEF_PRESSED  "0"
+#define DEF_TEMPLATE "0"
+
+static const Tk_OptionSpec systemImageOptions[] = {
+    {TK_OPTION_STRING, "-source", NULL, NULL, DEF_SOURCE,
+     -1, Tk_Offset(TkMacOSXNSImageModel, source), 0, NULL, 0},
+    {TK_OPTION_STRING, "-as", NULL, NULL, DEF_AS,
+     -1, Tk_Offset(TkMacOSXNSImageModel, as), 0, NULL, 0},
+    {TK_OPTION_INT, "-width", NULL, NULL, DEF_WIDTH,
+     -1, Tk_Offset(TkMacOSXNSImageModel, width), 0, NULL, 0},
+    {TK_OPTION_INT, "-height", NULL, NULL, DEF_HEIGHT,
+     -1, Tk_Offset(TkMacOSXNSImageModel, height), 0, NULL, 0},
+    {TK_OPTION_INT, "-radius", NULL, NULL, DEF_RADIUS,
+     -1, Tk_Offset(TkMacOSXNSImageModel, radius), 0, NULL, 0},
+    {TK_OPTION_INT, "-ring", NULL, NULL, DEF_RING,
+     -1, Tk_Offset(TkMacOSXNSImageModel, ring), 0, NULL, 0},
+    {TK_OPTION_DOUBLE, "-alpha", NULL, NULL, DEF_ALPHA,
+     -1, Tk_Offset(TkMacOSXNSImageModel, alpha), 0, NULL, 0},
+    {TK_OPTION_BOOLEAN, "-pressed", NULL, NULL, DEF_PRESSED,
+     -1, Tk_Offset(TkMacOSXNSImageModel, pressed), 0, NULL, 0},
+    {TK_OPTION_BOOLEAN, "-template", NULL, NULL, DEF_TEMPLATE,
+     -1, Tk_Offset(TkMacOSXNSImageModel, pressed), 0, NULL, 0},
+    {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, NULL, 0}
+};
+
+/*
+ * The -as option specifies how the string provided in the -source
+ * option should be interpreted as a description of an NSImage.
+ * Below are the possible values and their meanings.  (The last two
+ * provide the macOS icon for a particular file type.)
+ */
+
+static const char *sourceInterpretations[] = {
+    "name",       /* A name for a named NSImage. */
+    "file",       /* A path to an image file. */
+    "path",       /* A path to a file whose type should be examined. */
+    "filetype",   /* A file extension or 4-byte OSCode. */
+};
+
+enum {NAME_SOURCE, FILE_SOURCE, PATH_SOURCE, FILETYPE_SOURCE};
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TintImage --
+ *
+ *      Modify an NSImage by blending it with a color.  The transparent part of
+ *      the image remains transparent.  The opaque part of the image is painted
+ *      with the color, using the specified alpha value for the transparency of
+ *      the color.
+ *
+ * Results:
+ *	None.
+ *
+ * Side effects:
+ *	The appearance of the NSImage changes.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void TintImage(
+    NSImage *image,
+    NSColor *color,
+    double alpha)
+{
+    NSSize size = [image size];
+    NSRect rect = {NSZeroPoint, size};
+    NSImage *mask = [[[NSImage alloc] initWithSize:size] retain];
+    [mask lockFocus];
+    [color set];
+    NSRectFillUsingOperation(rect, NSCompositeCopy);
+    [image drawInRect:rect
+	     fromRect:rect
+	    operation:NSCompositeDestinationIn
+	     fraction:1.0];
+    [mask unlockFocus];
+    [image lockFocus];
+    [mask drawInRect:rect
+	    fromRect:rect
+	   operation:NSCompositeSourceOver
+	    fraction:alpha];
+    [image unlockFocus];
+    [mask release];
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXNSImageConfigureModel --
+ *
+ *	This function is called when an nsimage image is created or
+ *	reconfigured.  It processes configuration options and resets any
+ *	instances of the image.
+ *
+ * Results:
+ *	A standard Tcl return value. If TCL_ERROR is returned then an error
+ *	message is left in the modelPtr->interp's result.
+ *
+ * Side effects:
+ *	Existing instances of the image will be redisplayed to match the new
+ *	configuration options.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TkMacOSXNSImageConfigureModel(
+    Tcl_Interp *interp,		   /* Interpreter to use for reporting errors. */
+    TkMacOSXNSImageModel *modelPtr,    /* Pointer to data structure describing
+				    * overall photo image to (re)configure. */
+    int objc,			   /* Number of entries in objv. */
+    Tcl_Obj *const objv[])	   /* Pairs of configuration options for image. */
+{
+    Tk_OptionTable optionTable = Tk_CreateOptionTable(interp, systemImageOptions);
+    NSImage *newImage;
+    Tcl_Obj *objPtr;
+    static Tcl_Obj *asOption = NULL;
+    int sourceInterpretation;
+    NSString *source;
+    int oldWidth = modelPtr->width, oldHeight = modelPtr->height;
+
+    if (asOption == NULL) {
+	asOption = Tcl_NewStringObj("-as", -1);
+	Tcl_IncrRefCount(asOption);
+    }
+
+    modelPtr->width = 0;
+    modelPtr->height = 0;
+    if (Tk_SetOptions(interp, (char *) modelPtr, optionTable, objc, objv,
+		      NULL, NULL, NULL) != TCL_OK){
+	goto errorExit;
+    }
+    if (modelPtr->width == 0 && modelPtr->height == 0) {
+	modelPtr->width = oldWidth;
+	modelPtr->height = oldHeight;
+    }
+
+    if (modelPtr->source == NULL || modelPtr->source[0] == '0') {
+	Tcl_SetObjResult(interp, Tcl_NewStringObj("-source is required.", -1));
+	Tcl_SetErrorCode(interp, "TK", "IMAGE", "SYSTEM", "BAD_VALUE", NULL);
+	goto errorExit;
+    }
+
+    objPtr = Tk_GetOptionValue(interp, (char *) modelPtr, optionTable,
+				asOption, NULL);
+    if (Tcl_GetIndexFromObj(interp, objPtr, sourceInterpretations, "option",
+			    0, &sourceInterpretation) != TCL_OK) {
+	Tcl_SetObjResult(interp, Tcl_NewStringObj(
+	    "Unknown interpretation for source in -as option.  "
+	    "Should be name, file, path, or filetype.", -1));
+	Tcl_SetErrorCode(interp, "TK", "IMAGE", "SYSTEM", "BAD_VALUE", NULL);
+	goto errorExit;
+    }
+
+    source = [[NSString alloc] initWithUTF8String: modelPtr->source];
+    switch (sourceInterpretation) {
+    case NAME_SOURCE:
+	newImage = [[NSImage imageNamed:source] copy];
+	break;
+    case FILE_SOURCE:
+	newImage = [[NSImage alloc] initWithContentsOfFile:source];
+	break;
+    case PATH_SOURCE:
+	newImage = [[NSWorkspace sharedWorkspace] iconForFile:source];
+	break;
+    case FILETYPE_SOURCE:
+	newImage = TkMacOSXIconForFileType(source);
+	break;
+    default:
+	newImage = NULL;
+	break;
+    }
+    [source release];
+    if (newImage) {
+	NSSize size = NSMakeSize(modelPtr->width - 2*modelPtr->ring,
+				 modelPtr->height - 2*modelPtr->ring);
+	[modelPtr->image release];
+	[modelPtr->darkModeImage release];
+	newImage.size = size;
+	modelPtr->image = [newImage retain];
+	if (modelPtr->template) {
+	    newImage.template = YES;
+	}
+	modelPtr->darkModeImage = [[newImage copy] retain];
+	if ([modelPtr->darkModeImage isTemplate]) {
+
+	    /*
+	     * For a template image the Dark Mode version should be white.
+	     */
+
+	    NSRect rect = {NSZeroPoint, size};
+	    [modelPtr->darkModeImage lockFocus];
+	    [[NSColor whiteColor] set];
+	    NSRectFillUsingOperation(rect, NSCompositeSourceAtop);
+	    [modelPtr->darkModeImage unlockFocus];
+	} else if (modelPtr->pressed) {
+
+	    /*
+	     * Non-template pressed images are darker in Light Mode and lighter
+	     * in Dark Mode.
+	     */
+
+	    TintImage(modelPtr->image, [NSColor blackColor], 0.2);
+	    TintImage(modelPtr->darkModeImage, [NSColor whiteColor], 0.5);
+	}
+    } else {
+	switch(sourceInterpretation) {
+	case NAME_SOURCE:
+	    Tcl_SetObjResult(interp, Tcl_NewStringObj("Unknown named NSImage.\n"
+		"Try omitting ImageName, "
+	        "e.g. use NSCaution for NSImageNameCaution.", -1));
+	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "SYSTEM", "BAD_VALUE", NULL);
+	    goto errorExit;
+	case FILE_SOURCE:
+	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
+		"Failed to load image file.\n", -1));
+	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "SYSTEM", "BAD_VALUE", NULL);
+	    goto errorExit;
+	default:
+	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
+		"Unrecognized file type.\n"
+		"If using a filename extension, do not include the dot.\n", -1));
+	    Tcl_SetErrorCode(interp, "TK", "IMAGE", "SYSTEM", "BAD_VALUE", NULL);
+	    goto errorExit;
+	}
+    }
+
+    /*
+     * Set the width and height.  If only one is specified, set the other one
+     * so as to preserve the aspect ratio.  If neither is specified, match the
+     * size of the image.
+     */
+
+    if (modelPtr->width == 0 && modelPtr->height == 0) {
+	CGSize size = [modelPtr->image size];
+	modelPtr->width = (int) size.width;
+	modelPtr->height = (int) size.height;
+    } else {
+	CGSize size = [modelPtr->image size], newsize;
+	CGFloat aspect = size.width && size.height ?
+	     size.height / size.width : 1;
+	if (modelPtr->width == 0) {
+	    modelPtr->width = (int) ((CGFloat)(modelPtr->height) / aspect);
+	} else if (modelPtr->height == 0) {
+	    modelPtr->height = (int) ((CGFloat)(modelPtr->width) * aspect);
+	}
+	newsize = NSMakeSize(modelPtr->width, modelPtr->height);
+	modelPtr->image.size = newsize;
+	modelPtr->darkModeImage.size = newsize;
+    }
+    
+    /*
+     * Inform the generic image code that the image has (potentially) changed.
+     */
+
+    Tk_ImageChanged(modelPtr->tkModel, 0, 0, modelPtr->width,
+	    modelPtr->height, modelPtr->width, modelPtr->height);
+    modelPtr->flags &= ~IMAGE_CHANGED;
+
+    return TCL_OK;
+
+  errorExit:
+    return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXNSImageObjCmd --
+ *
+ *	This function implements the configure and cget commands for an
+ *	nsimage instance.
+ *
+ * Results:
+ *	A standard Tcl result.
+ *
+ * Side effects:
+ *	The image may be reconfigured.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TkMacOSXNSImageObjCmd(
+    ClientData clientData,	/* Information about the image model. */
+    Tcl_Interp *interp,		/* Current interpreter. */
+    int objc,			/* Number of arguments. */
+    Tcl_Obj *const objv[])	/* Argument objects. */
+{
+    TkMacOSXNSImageModel *modelPtr = (TkMacOSXNSImageModel *)clientData;
+    Tk_OptionTable optionTable = Tk_CreateOptionTable(interp, systemImageOptions);
+    static const char *const options[] = {"cget", "configure", NULL};
+    enum {CGET, CONFIGURE};
+    Tcl_Obj *objPtr;
+    int index;
+
+    if (objc < 2) {
+	Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
+	return TCL_ERROR;
+    }
+    if (Tcl_GetIndexFromObjStruct(interp, objv[1], options,
+	    sizeof(char *), "option", 0, &index) != TCL_OK) {
+	return TCL_ERROR;
+    }
+    Tcl_Preserve(modelPtr);
+    switch (index) {
+    case CGET:
+	if (objc != 3) {
+	    Tcl_WrongNumArgs(interp, 2, objv, "option");
+	    return TCL_ERROR;
+	}
+	objPtr = Tk_GetOptionValue(interp, (char *)modelPtr, optionTable,
+		objv[2], NULL);
+	if (objPtr == NULL) {
+            goto error;
+        }
+        Tcl_SetObjResult(interp, objPtr);
+	break;
+    case CONFIGURE:
+	if (objc == 2) {
+	    objPtr = Tk_GetOptionInfo(interp, (char *)modelPtr, optionTable,
+				     NULL, NULL);
+	    if (objPtr == NULL) {
+		goto error;
+	    }
+	    Tcl_SetObjResult(interp, objPtr);
+	    break;
+	} else if (objc == 3) {
+	    objPtr = Tk_GetOptionInfo(interp, (char *)modelPtr, optionTable,
+				     objv[2], NULL);
+	    if (objPtr == NULL) {
+		goto error;
+	    }
+	    Tcl_SetObjResult(interp, objPtr);
+	    break;
+	} else {
+	    TkMacOSXNSImageConfigureModel(interp, modelPtr, objc - 2, objv + 2);
+	    break;
+	}
+    default:
+	break;
+    }
+
+    Tcl_Release(modelPtr);
+    return TCL_OK;
+
+ error:
+    Tcl_Release(modelPtr);
+    return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXNSImageCreate --
+ *
+ *	Allocate and initialize an nsimage model.
+ *
+ * Results:
+ *	A standard Tcl result.
+ *
+ * Side effects:
+ *	The data structure for a new image is allocated.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TkMacOSXNSImageCreate(
+    Tcl_Interp *interp,		 /* Interpreter for application using image. */
+    const char *name,		 /* Name to use for image. */
+    int objc,			 /* Number of arguments. */
+    Tcl_Obj *const objv[],	 /* Argument strings for options (not
+				  * including image name or type). */
+    TCL_UNUSED(const Tk_ImageType *), /* typePtr */
+    Tk_ImageModel model,	 /* Token for image, to be used in callbacks. */
+    ClientData *clientDataPtr)	 /* Store manager's token for image here; it
+				  * will be returned in later callbacks. */
+{
+    TkMacOSXNSImageModel *modelPtr;
+    Tk_OptionTable optionTable = Tk_CreateOptionTable(interp, systemImageOptions);
+
+    modelPtr = (TkMacOSXNSImageModel *)ckalloc(sizeof(TkMacOSXNSImageModel));
+    modelPtr->tkModel = model;
+    modelPtr->interp = interp;
+    modelPtr->imageName = (char *)ckalloc(strlen(name) + 1);
+    strcpy(modelPtr->imageName, name);
+    modelPtr->flags = 0;
+    modelPtr->instancePtr = NULL;
+    modelPtr->image = NULL;
+    modelPtr->darkModeImage = NULL;
+    modelPtr->source = NULL;
+    modelPtr->as = NULL;
+
+    /*
+     * Process configuration options given in the image create command.
+     */
+
+    if (Tk_InitOptions(interp, (char *) modelPtr, optionTable, NULL) != TCL_OK
+	|| TkMacOSXNSImageConfigureModel(interp, modelPtr, objc, objv) != TCL_OK) {
+	TkMacOSXNSImageDelete(modelPtr);
+	return TCL_ERROR;
+    }
+    Tcl_CreateObjCommand(interp, name, TkMacOSXNSImageObjCmd, modelPtr, NULL);
+    *clientDataPtr = modelPtr;
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXNSImageGet --
+ *
+ *	Allocate and initialize an nsimage instance.
+ *
+ * Results:
+ *	The return value is a token for the image instance, which is used in
+ *	future callbacks to ImageDisplay and ImageFree.
+ *
+ * Side effects:
+ *	A new new nsimage instance is created.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static ClientData
+TkMacOSXNSImageGet(
+    TCL_UNUSED(Tk_Window),      /* tkwin */
+    ClientData clientData)	/* Pointer to TkMacOSXNSImageModel for image. */
+{
+    TkMacOSXNSImageModel *modelPtr = (TkMacOSXNSImageModel *) clientData;
+    TkMacOSXNSImageInstance *instPtr;
+
+    instPtr = (TkMacOSXNSImageInstance *)ckalloc(sizeof(TkMacOSXNSImageInstance));
+    instPtr->modelPtr = modelPtr;
+    return instPtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXNSImageDisplay --
+ *
+ *	Display or redisplay an nsimage in the given drawable.
+ *
+ * Results:
+ *	None.
+ *
+ * Side effects:
+ *	The image gets drawn.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+TkMacOSXNSImageDisplay(
+    ClientData clientData,	/* Pointer to TkMacOSXNSImageInstance for image. */
+    TCL_UNUSED(Display *),      /* display */
+    Drawable drawable,		/* Where to draw or redraw image. */
+    int imageX, int imageY,	/* Origin of area to redraw, relative to
+				 * origin of image. */
+    int width, int height,	/* Dimensions of area to redraw. */
+    int drawableX, int drawableY)
+				/* Coordinates in drawable corresponding to
+				 * imageX and imageY. */
+{
+    MacDrawable *macWin = (MacDrawable *) drawable;
+    Tk_Window tkwin = (Tk_Window) macWin->winPtr;
+    TkMacOSXNSImageInstance *instPtr = (TkMacOSXNSImageInstance *) clientData;
+    TkMacOSXNSImageModel *modelPtr = instPtr->modelPtr;
+    TkMacOSXDrawingContext dc;
+    NSRect dstRect = NSMakeRect(macWin->xOff + drawableX,
+				 macWin->yOff + drawableY, width, height);
+    NSRect srcRect = NSMakeRect(imageX, imageY, width, height);
+    NSImage *image = TkMacOSXInDarkMode(tkwin) ? modelPtr->darkModeImage :
+	modelPtr->image;
+    int ring = modelPtr->ring;
+    int radius = modelPtr->radius;
+
+    if (TkMacOSXSetupDrawingContext(drawable, NULL, &dc)) {
+	if (dc.context) {
+	    CGRect clipRect = CGRectMake(
+		dstRect.origin.x - srcRect.origin.x + ring,
+		dstRect.origin.y - srcRect.origin.y + ring,
+		modelPtr->width - 2*ring,
+		modelPtr->height - 2*ring);
+	    CGPathRef path = CGPathCreateWithRoundedRect(clipRect, radius, radius, NULL);
+	    CGContextSaveGState(dc.context);
+	    CGContextBeginPath(dc.context);
+	    CGContextAddPath(dc.context, path);
+	    CGContextClip(dc.context);
+	    NSGraphicsContext *savedContext = NSGraphicsContext.currentContext;
+	    NSGraphicsContext.currentContext = [NSGraphicsContext
+		graphicsContextWithCGContext:dc.context flipped:YES];
+	    [image drawInRect:clipRect
+		     fromRect:srcRect
+		    operation:NSCompositeSourceOver
+		     fraction:modelPtr->alpha
+	       respectFlipped:YES
+			hints:nil];
+	    CGContextRestoreGState(dc.context);
+
+	    /*
+	     * Draw the focus ring.
+	     */
+
+	    if (ring) {
+		CGRect ringRect = CGRectInset(clipRect, -ring, -ring);
+		CGPathRef ringPath = CGPathCreateWithRoundedRect(ringRect,
+		    radius + ring, radius + ring, NULL);
+		CGContextSaveGState(dc.context);
+		CGContextAddPath(dc.context, path);
+		CGContextAddPath(dc.context, ringPath);
+		CGContextSetFillColorWithColor(dc.context,
+					       controlAccentColor().CGColor);
+		CGContextEOFillPath(dc.context);
+		CGContextRestoreGState(dc.context);
+		CFRelease(ringPath);
+	    }
+	    CFRelease(path);
+	    NSGraphicsContext.currentContext = savedContext;
+	}
+	TkMacOSXRestoreDrawingContext(&dc);
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXNSImageFree --
+ *
+ *	Deallocate an instance of an nsimage.
+ *
+ * Results:
+ *	None.
+ *
+ * Side effects:
+ *	Information related to the instance is freed.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+TkMacOSXNSImageFree(
+    ClientData clientData,	/* Pointer to TkMacOSXNSImageInstance for instance. */
+    TCL_UNUSED(Display *))	/* display */
+{
+    TkMacOSXNSImageInstance *instPtr = (TkMacOSXNSImageInstance *) clientData;
+    ckfree(instPtr);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXNSImageDelete --
+ *
+ *	Deallocate an nsimage model.
+ *
+ * Results:
+ *	None.
+ *
+ * Side effects:
+ *	 NSImages are released and memory is freed.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+TkMacOSXNSImageDelete(
+    ClientData clientData)	/* Pointer to TkMacOSXNSImageModel for image. When
+				 * this function is called, no more instances
+				 * exist. */
+{
+    TkMacOSXNSImageModel *modelPtr = (TkMacOSXNSImageModel *) clientData;
+
+    Tcl_DeleteCommand(modelPtr->interp, modelPtr->imageName);
+    ckfree(modelPtr->imageName);
+    ckfree(modelPtr->source);
+    ckfree(modelPtr->as);
+    [modelPtr->image release];
+    [modelPtr->darkModeImage release];
+    ckfree(modelPtr);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXNSImage_Init --
+ *
+ *	Adds the TkMacOSXNSImage type to Tk.
+ *
+ * Results:
+ *	Returns a standard Tcl completion code, and leaves an error message in
+ *	the interp's result if an error occurs.
+ *
+ * Side effects:
+ *	Creates the image create nsrect ...  command.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TkMacOSXNSImage_Init(
+    TCL_UNUSED(Tcl_Interp *))	 /* interp */
+{
+    Tk_CreateImageType(&TkMacOSXNSImageType);
+    return 1;
+}
 
 /*
  * Local Variables:
  * mode: objc
  * c-basic-offset: 4
  * fill-column: 79
  * coding: utf-8
  * End:
  */

Index: macosx/tkMacOSXInit.c
==================================================================
--- macosx/tkMacOSXInit.c
+++ macosx/tkMacOSXInit.c
@@ -2,23 +2,25 @@
  * tkMacOSXInit.c --
  *
  *	This file contains Mac OS X -specific interpreter initialization
  *	functions.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2017 Marc Culler
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2017 Marc Culler
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
 #include "tkMacOSXPrivate.h"
+#include "tkMacOSXConstants.h"
 #include <dlfcn.h>
 #include <objc/objc-auto.h>
 #include <sys/stat.h>
+#include <sys/utsname.h>
 
 static char tkLibPath[PATH_MAX + 1] = "";
 
 /*
  * If the App is in an App package, then we want to add the Scripts directory
@@ -29,20 +31,60 @@
 
 /*
  * Forward declarations...
  */
 
-static int		TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
+static int		TkMacOSXGetAppPathObjCmd(TCL_UNUSED(void *), Tcl_Interp *ip,
+			    int objc, Tcl_Obj *const objv[]);
+static int		TkMacOSVersionObjCmd(ClientData cd, Tcl_Interp *ip,
 			    int objc, Tcl_Obj *const objv[]);
 
 #pragma mark TKApplication(TKInit)
 
 @implementation TKApplication
 @synthesize poolLock = _poolLock;
 @synthesize macOSVersion = _macOSVersion;
 @synthesize isDrawing = _isDrawing;
-@synthesize needsToDraw = _needsToDraw;
+@synthesize isSigned = _isSigned;
+@synthesize tkLiveResizeEnded = _tkLiveResizeEnded;
+@synthesize tkPointerWindow = _tkPointerWindow;
+- (void) setTkPointerWindow: (TkWindow *)winPtr
+{
+    if (_tkPointerWindow) {
+	Tcl_Release(_tkPointerWindow);
+    }
+    if (winPtr) {
+	Tcl_Preserve(winPtr);
+    }
+    _tkPointerWindow = winPtr;
+    return;
+}
+@synthesize tkEventTarget = _tkEventTarget;
+- (void) setTkEventTarget: (TkWindow *)winPtr
+{
+    if (_tkEventTarget) {
+	Tcl_Release(_tkEventTarget);
+    }
+    if (winPtr) {
+	Tcl_Preserve(winPtr);
+    }
+    _tkEventTarget = winPtr;
+    return;
+}
+@synthesize tkDragTarget = _tkDragTarget;
+- (void) setTkDragTarget: (TkWindow *)winPtr
+{
+    if (_tkDragTarget) {
+	Tcl_Release(_tkDragTarget);
+    }
+    if (winPtr) {
+	Tcl_Preserve(winPtr);
+    }
+    _tkDragTarget = winPtr;
+    return;
+}
+@synthesize tkButtonState = _tkButtonState;
 @end
 
 /*
  * #define this to see a message on stderr whenever _resetAutoreleasePool is
  * called while the pool is locked.
@@ -102,32 +144,60 @@
 	    selector:@selector(_postedNotification:) name:nil object:nil];
 #endif
     [self _setupWindowNotifications];
     [self _setupApplicationNotifications];
 
-    /*
-     * Construct the menu bar.
-     */
-    _defaultMainMenu = nil;
-    [self _setupMenus];
-
-    /*
-     * Initialize event processing.
-     */
+    if ([NSApp macOSVersion] >= 110000) {
+
+   /*
+    * Initialize Apple Event processing. Apple's docs (see
+    * https://developer.apple.com/documentation/appkit/nsapplication)
+    * recommend doing this here, although historically we have
+    * done this in applicationWillFinishLaunching. In response to
+    * bug 7bb246b072.
+    */
 
     TkMacOSXInitAppleEvents(_eventInterp);
 
-    /*
-     * Initialize the graphics context.
-     */
-    TkMacOSXUseAntialiasedText(_eventInterp, -1);
-    TkMacOSXInitCGDrawing(_eventInterp, TRUE, 0);
+    }
 }
 
 -(void)applicationDidFinishLaunching:(NSNotification *)notification
 {
     (void)notification;
+
+   if ([NSApp macOSVersion] < 110000) {
+
+   /*
+    * Initialize Apple Event processing on macOS versions
+    * older than Big Sur (11).
+    */
+
+    TkMacOSXInitAppleEvents(_eventInterp);
+
+    }
+
+
+    /*
+     * Initialize the graphics context.
+     */
+
+    TkMacOSXUseAntialiasedText(_eventInterp, -1);
+    TkMacOSXInitCGDrawing(_eventInterp, TRUE, 0);
+
+    /*
+     * Construct the menu bar.
+     */
+
+    _defaultMainMenu = nil;
+    [self _setupMenus];
+
+    /*
+     * Run initialization routines that depend on the OS version.
+     */
+
+    Ttk_MacOSXInit();
 
     /*
      * It is not safe to force activation of the NSApp until this method is
      * called. Activating too early can cause the menu bar to be unresponsive.
      * The call to activateIgnoringOtherApps was moved here to avoid this.
@@ -136,10 +206,24 @@
      * needed to be moved into this function as well.
      */
 
     [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
     [NSApp activateIgnoringOtherApps: YES];
+
+    /*
+     * Add an event monitor so we continue to receive NSMouseMoved and
+     * NSMouseDragged events when the mouse moves outside of the key
+     * window. The handler simply returns the events it receives, so
+     * they can be processed in the same way as for other events.
+     */
+
+    [NSEvent addLocalMonitorForEventsMatchingMask:(NSMouseMovedMask |
+						   NSLeftMouseDraggedMask)
+	 handler:^NSEvent *(NSEvent *event)
+	 {
+	     return event;
+	 }];
 
     /*
      * Process events to ensure that the root window is fully initialized. See
      * ticket 56a1823c73.
      */
@@ -165,19 +249,38 @@
     /*
      * Record the OS version we are running on.
      */
 
     int minorVersion, majorVersion;
+
 #if MAC_OS_X_VERSION_MAX_ALLOWED < 101000
     Gestalt(gestaltSystemVersionMinor, (SInt32*)&minorVersion);
     majorVersion = 10;
 #else
     NSOperatingSystemVersion systemVersion;
     systemVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
     majorVersion = systemVersion.majorVersion;
     minorVersion = systemVersion.minorVersion;
 #endif
+
+    if (majorVersion == 10 && minorVersion == 16) {
+
+	/*
+	 * If a program compiled with a macOS 10.XX SDK is run on macOS 11.0 or
+	 * later then it will report majorVersion 10 and minorVersion 16, no
+	 * matter what the actual OS version of the host may be. And of course
+	 * Apple never released macOS 10.16. To work around this we guess the
+	 * OS version from the kernel release number, as reported by uname.
+	 */
+
+	struct utsname name;
+	char *endptr;
+	if (uname(&name) == 0) {
+	    majorVersion = strtol(name.release, &endptr, 10) - 9;
+	    minorVersion = 0;
+	}
+    }
     [NSApp setMacOSVersion: 10000*majorVersion + 100*minorVersion];
 
     /*
      * We are not drawing right now.
      */
@@ -200,10 +303,11 @@
     if (!iconFile) {
 	NSString *path = [NSApp tkFrameworkImagePath:@"Tk.icns"];
 	if (path) {
 	    NSImage *image = [[NSImage alloc] initWithContentsOfFile:path];
 	    if (image) {
+		[image setName:@"NSApplicationIcon"];
 		[NSApp setApplicationIconImage:image];
 		[image release];
 	    }
 	}
     }
@@ -351,11 +455,11 @@
 {
     static int initialized = 0;
 
     /*
      * TkpInit can be called multiple times with different interpreters. But
-     * The application initialization should only be done onece.
+     * The application initialization should only be done once.
      */
 
     if (!initialized) {
 	struct stat st;
 	Bool shouldOpenConsole = NO;
@@ -412,11 +516,11 @@
          * with the root window (see below).  If the NSApplication wins then an
          * AppleEvent created during launch, e.g. by dropping a file icon on
          * the application icon, will be delivered before the procedure meant
          * to to handle the AppleEvent has been defined.  This is handled in
          * tkMacOSXHLEvents.c by scheduling a timer event to handle the
-         * ApplEvent later, after the required procedure has been defined.
+         * AppleEvent later, after the required procedure has been defined.
          */
 
 	[NSApp _setup:interp];
 	[NSApp finishLaunching];
 
@@ -499,16 +603,17 @@
 	    close(0);
 	    close(1);
 	}
 
 	/*
-	 * Initialize the NSServices object here. Apple's docs say to do this
-	 * in applicationDidFinishLaunching, but the Tcl interpreter is not
-	 * initialized until this function call.
+	 * Now we can run initialization routines which require that both the
+	 * NSApplication and the Tcl interpreter have been created and
+	 * initialized.
 	 */
 
 	TkMacOSXServices_Init(interp);
+	TkMacOSXNSImage_Init(interp);
 
 	/*
 	 * The root window has been created and mapped, but XMapWindow deferred its
 	 * call to makeKeyAndOrderFront because the first call to XMapWindow
 	 * occurs too early in the initialization process for that.  Process idle
@@ -540,30 +645,82 @@
 
 	signal(SIGINT, TkMacOSXSignalHandler);
 	signal(SIGHUP, TkMacOSXSignalHandler);
 	signal(SIGTERM, TkMacOSXSignalHandler);
     }
-
     /*
      * Initialization steps that are needed for all interpreters.
      */
 
     if (tkLibPath[0] != '\0') {
 	Tcl_SetVar2(interp, "tk_library", NULL, tkLibPath, TCL_GLOBAL_ONLY);
     }
-
     if (scriptPath[0] != '\0') {
 	Tcl_SetVar2(interp, "auto_path", NULL, scriptPath,
 		TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
     }
-
+    Tcl_CreateObjCommand(interp, "nsimage",
+	    TkMacOSXNSImageObjCmd, NULL, NULL);
     Tcl_CreateObjCommand(interp, "::tk::mac::standardAboutPanel",
 	    TkMacOSXStandardAboutPanelObjCmd, NULL, NULL);
     Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap",
 	    TkMacOSXIconBitmapObjCmd, NULL, NULL);
     Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath",
-	    TkMacOSXGetAppPathCmd, NULL, NULL);
+	    TkMacOSXGetAppPathObjCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "::tk::mac::macOSVersion",
+           TkMacOSVersionObjCmd, NULL, NULL);
+    MacSystrayInit(interp);
+    MacPrint_Init(interp);
+
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXGetAppPathObjCmd --
+ *
+ *	Returns the path of the Wish application bundle.
+ *
+ * Results:
+ *	Returns the application path.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TkMacOSXGetAppPathObjCmd(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    int objc,
+    Tcl_Obj *const objv[])
+{
+    if (objc != 1) {
+	Tcl_WrongNumArgs(interp, 1, objv, NULL);
+	return TCL_ERROR;
+    }
+
+    /*
+     * Get the application path URL and convert it to a string path reference.
+     */
+
+    CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());
+    CFStringRef appPath =
+	    CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
+
+    /*
+     * Convert (and copy) the string reference into a Tcl result.
+     */
+
+    Tcl_SetObjResult(interp, Tcl_NewStringObj(
+	    CFStringGetCStringPtr(appPath, CFStringGetSystemEncoding()), -1));
+
+    CFRelease(mainBundleURL);
+    CFRelease(appPath);
 
     return TCL_OK;
 }
 
 /*
@@ -604,52 +761,41 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkMacOSXGetAppPathCmd --
+ * TkMacOSVersionObjCmd --
  *
- *	Returns the path of the Wish application bundle.
+ *	Tcl command which returns an integer encoding the major and minor
+ *	version numbers of the currently running operating system in the
+ *	form 10000*majorVersion + 100*minorVersion.
  *
  * Results:
- *	Returns the application path.
+ *	Returns the OS version.
  *
  * Side effects:
  *	None.
  *
  *----------------------------------------------------------------------
  */
-
+
 static int
-TkMacOSXGetAppPathCmd(
-    TCL_UNUSED(void *),
+TkMacOSVersionObjCmd(
+    TCL_UNUSED(void *), /* ClientData */
     Tcl_Interp *interp,
     int objc,
     Tcl_Obj *const objv[])
 {
-    if (objc != 1) {
+    static char version[16] = "";
+    if (objc > 1) {
 	Tcl_WrongNumArgs(interp, 1, objv, NULL);
 	return TCL_ERROR;
     }
-
-    /*
-     * Get the application path URL and convert it to a string path reference.
-     */
-
-    CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());
-    CFStringRef appPath =
-	    CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
-
-    /*
-     * Convert (and copy) the string reference into a Tcl result.
-     */
-
-    Tcl_SetObjResult(interp, Tcl_NewStringObj(
-	    CFStringGetCStringPtr(appPath, CFStringGetSystemEncoding()), -1));
-
-    CFRelease(mainBundleURL);
-    CFRelease(appPath);
+    if (version[0] == '\0') {
+	snprintf(version, 16, "%d", [NSApp macOSVersion]);
+    }
+    Tcl_SetResult(interp, version, NULL);
     return TCL_OK;
 }
 
 /*
  *----------------------------------------------------------------------
@@ -752,14 +898,15 @@
  *----------------------------------------------------------------------
  */
 
 MODULE_SCOPE void*
 TkMacOSXGetNamedSymbol(
-    TCL_UNUSED(const char *),
-    const char *symbol)
+    const char* module,
+    const char* symbol)
 {
     void *addr = dlsym(RTLD_NEXT, symbol);
+    (void)module;
 
     if (!addr) {
 	(void) dlerror(); /* Clear dlfcn error state */
     }
     return addr;

Index: macosx/tkMacOSXInt.h
==================================================================
--- macosx/tkMacOSXInt.h
+++ macosx/tkMacOSXInt.h
@@ -22,11 +22,13 @@
  * Include platform specific public interfaces.
  */
 
 #ifndef _TKMAC
 #include "tkMacOSX.h"
+#define Cursor QDCursor
 #import <Cocoa/Cocoa.h>
+#undef Cursor
 #endif
 
 /*
  * Define compatibility platform types used in the structures below so that
  * this header can be included without pulling in the platform headers.
@@ -96,25 +98,10 @@
  * still tell what the correct port is after the TKWindow structure has been
  * freed. This actually happens when you bind destroy of a toplevel to
  * Destroy of a child.
  */
 
-/*
- * GC CGColorRef cache for tkMacOSXColor.c
- */
-
-typedef struct {
-    unsigned long cachedForeground;
-    CGColorRef cachedForegroundColor;
-    unsigned long cachedBackground;
-    CGColorRef cachedBackgroundColor;
-} TkpGCCache;
-
-MODULE_SCOPE TkpGCCache *TkpGetGCCache(GC gc);
-MODULE_SCOPE void TkpInitGCCache(GC gc);
-MODULE_SCOPE void TkpFreeGCCache(GC gc);
-
 /*
  * Undef compatibility platform types defined above.
  */
 
 #ifndef _TKMACPRIV
@@ -171,12 +158,10 @@
 /*
  * Prototypes of internal procs not in the stubs table.
  */
 
 MODULE_SCOPE void TkMacOSXDefaultStartupScript(void);
-MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x,
-	int y, int width, int height);
 MODULE_SCOPE void TkpRetainRegion(Region r);
 MODULE_SCOPE void TkpReleaseRegion(Region r);
 MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta);
 MODULE_SCOPE Bool TkTestLogDisplay(Drawable drawable);
 

Index: macosx/tkMacOSXKeyEvent.c
==================================================================
--- macosx/tkMacOSXKeyEvent.c
+++ macosx/tkMacOSXKeyEvent.c
@@ -2,14 +2,14 @@
  * tkMacOSXKeyEvent.c --
  *
  *	This file implements functions that decode & handle keyboard events on
  *	MacOS X.
  *
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2012 Adrian Robert.
- * Copyright 2015-2020 Marc Culler.
+ * Copyright © 2001-2009, Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2012 Adrian Robert.
+ * Copyright © 2015-2020 Marc Culler.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -51,11 +51,11 @@
 #endif
     NSWindow *w = [theEvent window];
     TkWindow *winPtr = TkMacOSXGetTkWindow(w), *grabWinPtr, *focusWinPtr;
     Tk_Window tkwin = (Tk_Window)winPtr;
     NSEventType type = [theEvent type];
-    NSUInteger virtual = [theEvent keyCode];
+    NSUInteger virt = [theEvent keyCode];
     NSUInteger modifiers = ([theEvent modifierFlags] &
 			    NSDeviceIndependentModifierFlagsMask);
     XEvent xEvent;
     MacKeycode macKC;
     UniChar keychar = 0;
@@ -68,10 +68,22 @@
         processingCompose = NO;
     }
     if (!winPtr) {
 	return theEvent;
     }
+
+    /*
+     * Discard repeating KeyDown events if the repeat speed has been set to
+     * "off" in System Preferences.  It is unclear why we get these, but we do.
+     * See ticket [2ecb09d118].
+     */
+
+    if ([theEvent type] ==  NSKeyDown &&
+	[theEvent isARepeat] &&
+	[NSEvent keyRepeatDelay] < 0) {
+            return theEvent;
+	}
 
     /*
      * If a local grab is in effect, key events for windows in the
      * grabber's application are redirected to the grabber.  Key events
      * for other applications are delivered normally.  If a global
@@ -80,40 +92,50 @@
 
     grabWinPtr = winPtr->dispPtr->grabWinPtr;
     if (grabWinPtr) {
 	if (winPtr->dispPtr->grabFlags ||  /* global grab */
 	    grabWinPtr->mainPtr == winPtr->mainPtr){ /* same application */
-	    winPtr =winPtr->dispPtr->focusPtr;
+	    winPtr = winPtr->dispPtr->focusPtr;
+	    if (!winPtr) {
+		return theEvent;
+	    }
 	    tkwin = (Tk_Window)winPtr;
 	}
     }
 
     /*
      * Extract the unicode character from KeyUp and KeyDown events.
      */
 
     if (type == NSKeyUp || type == NSKeyDown) {
-	if ([[theEvent characters] length] > 0) {
-	    keychar = [[theEvent characters] characterAtIndex:0];
+	NSString *characters = [theEvent characters];
+	if (characters.length > 0) {
+	    keychar = [characters characterAtIndex:0];
 
 	    /*
 	     * Currently, real keys always send BMP characters, but who knows?
 	     */
 
 	    if (CFStringIsSurrogateHighCharacter(keychar)) {
-		UniChar lowChar = [[theEvent characters] characterAtIndex:1];
+		UniChar lowChar = [characters characterAtIndex:1];
 		keychar = CFStringGetLongCharacterForSurrogatePair(
 		    keychar, lowChar);
 	    }
 	} else {
 
 	    /*
-	     * This is a dead key, such as Option-e, so it should go to the
-	     * TextInputClient.
+	     * This is a dead key, such as Option-e, so it usually should get
+	     * passed to the TextInputClient.  But if it has a Command modifier
+	     * then it is not functioning as a dead key and should not be
+	     * handled by the TextInputClient.  See ticket [1626ed65b8] and the
+	     * method performKeyEquivalent which is implemented in
+	     * tkMacOSXMenu.c.
 	     */
 
-	    use_text_input = YES;
+	    if (!(modifiers & NSCommandKeyMask)) {
+		use_text_input = YES;
+	    }
 	}
 
 	/*
 	 * Apple uses 0x10 for unrecognized keys.
 	 */
@@ -124,11 +146,11 @@
 
 #if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1
 	TKLog(@"-[%@(%p) %s] repeat=%d mods=%x char=%x code=%lu c=%d type=%d",
 	      [self class], self, _cmd,
 	      (type == NSKeyDown) && [theEvent isARepeat], modifiers, keychar,
-	      virtual, w, type);
+	      virt, w, type);
 #endif
 
     }
 
     /*
@@ -213,11 +235,11 @@
      * finish constructing the XEvent and queue it.
      */
 
     macKC.v.o_s =  ((modifiers & NSShiftKeyMask ? INDEX_SHIFT : 0) |
 		    (modifiers & NSAlternateKeyMask ? INDEX_OPTION : 0));
-    macKC.v.virtual = virtual;
+    macKC.v.virt = virt;
     switch (type) {
     case NSFlagsChanged:
 
 	/*
 	 * This XEvent is a simulated KeyPress or KeyRelease event for a
@@ -253,11 +275,10 @@
      * Finally we can queue the XEvent, inserting a KeyRelease before a
      * repeated KeyPress.
      */
 
     if (type == NSKeyDown && [theEvent isARepeat]) {
-
 	xEvent.xany.type = KeyRelease;
 	Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
 	xEvent.xany.type = KeyPress;
     }
     Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
@@ -266,11 +287,11 @@
 @end
 
 
 @implementation TKContentView
 @synthesize tkDirtyRect = _tkDirtyRect;
-@synthesize tkNeedsDisplay = _tkNeedsDisplay;;
+@synthesize tkNeedsDisplay = _tkNeedsDisplay;
 
 /*
  * Implementation of the NSTextInputClient protocol.
  */
 
@@ -347,13 +368,13 @@
 	macKC.v.keychar = keychar;
 	if (CFStringIsSurrogateHighCharacter(keychar)) {
 	    UniChar lowChar = [str characterAtIndex:++i];
 	    macKC.v.keychar = CFStringGetLongCharacterForSurrogatePair(
 				  (UniChar)keychar, lowChar);
-	    macKC.v.virtual = NON_BMP_VIRTUAL;
+	    macKC.v.virt = NON_BMP_VIRTUAL;
 	} else if (repRange.location == 0 || sendingIMEText) {
-	    macKC.v.virtual = REPLACEMENT_VIRTUAL;
+	    macKC.v.virt = REPLACEMENT_VIRTUAL;
 	} else {
 	    macKC.uint = TkMacOSXAddVirtual(macKC.uint);
 	    xEvent.xkey.state |= INDEX2STATE(macKC.x.xvirtual);
 	}
 	keystr = [[NSString alloc] initWithCharacters:&keychar length:1];
@@ -602,15 +623,16 @@
 
 static void
 setupXEvent(XEvent *xEvent, Tk_Window tkwin, NSUInteger modifiers)
 {
     unsigned int state = 0;
-    Display *display = Tk_Display(tkwin);
+    Display *display;
 
     if (tkwin == NULL) {
 	return;
     }
+    display = Tk_Display(tkwin);
     if (modifiers) {
 	state = (modifiers & NSAlphaShiftKeyMask ? LockMask    : 0) |
 	        (modifiers & NSShiftKeyMask      ? ShiftMask   : 0) |
 	        (modifiers & NSControlKeyMask    ? ControlMask : 0) |
 	        (modifiers & NSCommandKeyMask    ? Mod1Mask    : 0) |
@@ -641,11 +663,11 @@
     NSPoint local = [w  mouseLocationOutsideOfEventStream];
     NSPoint global = [w tkConvertPointToScreen: local];
     int win_x, win_y;
 
     if (Tk_IsEmbedded(winPtr)) {
-	TkWindow *contPtr = TkpGetOtherWindow(winPtr);
+	TkWindow *contPtr = (TkWindow *)Tk_GetOtherWindow(tkwin);
 	if (Tk_IsTopLevel(contPtr)) {
 	    local.x -= contPtr->wmInfoPtr->xInParent;
 	    local.y -= contPtr->wmInfoPtr->yInParent;
 	} else {
 	    TkWindow *topPtr = TkMacOSXGetHostToplevel(winPtr)->winPtr;
@@ -703,12 +725,16 @@
     if (keyboardGrabWinPtr && captureWinPtr) {
 	NSWindow *w = TkMacOSXGetNSWindowForDrawable(grab_window);
 	MacDrawable *macWin = (MacDrawable *)grab_window;
 
 	if (w && macWin->toplevel->winPtr == (TkWindow *) captureWinPtr) {
-	    if (modalSession) {
-		Tcl_Panic("XGrabKeyboard: already grabbed");
+	    if (modalSession ) {
+		if (keyboardGrabNSWindow == w) {
+		    return GrabSuccess;
+		} else {
+		    Tcl_Panic("XGrabKeyboard: already grabbed");
+		}
 	    }
 	    keyboardGrabNSWindow = w;
 	    [w retain];
 	    modalSession = [NSApp beginModalSessionForWindow:w];
 	}

Index: macosx/tkMacOSXKeyboard.c
==================================================================
--- macosx/tkMacOSXKeyboard.c
+++ macosx/tkMacOSXKeyboard.c
@@ -1,14 +1,14 @@
 /*
  * tkMacOSXKeyboard.c --
  *
  *	Routines to support keyboard events on the Macintosh.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2020 Marc Culler
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009, Apple Inc.
+ * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2020 Marc Culler
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -141,11 +141,11 @@
  */
 
 static void	InitHashTables(void);
 static void     UpdateKeymaps(void);
 static int	KeyDataToUnicode(UniChar *uniChars, int maxChars,
-			UInt16 keyaction, UInt32 virtual, UInt32 modifiers,
+			UInt16 keyaction, UInt32 virt, UInt32 modifiers,
 			UInt32 * deadKeyStatePtr);
 
 #pragma mark TKApplication(TKKeyboard)
 
 @implementation TKApplication(TKKeyboard)
@@ -186,19 +186,19 @@
     const KeysymInfo *ksPtr;
     int dummy, index;
 
     Tcl_InitHashTable(&special2keysym, TCL_ONE_WORD_KEYS);
     Tcl_InitHashTable(&keysym2keycode, TCL_ONE_WORD_KEYS);
-    for (kPtr = keyArray; kPtr->virtual != 0; kPtr++) {
+    for (kPtr = keyArray; kPtr->virt != 0; kPtr++) {
 	MacKeycode macKC;
 	macKC.v.o_s = 0;
-	hPtr = Tcl_CreateHashEntry(&special2keysym, INT2PTR(kPtr->virtual),
+	hPtr = Tcl_CreateHashEntry(&special2keysym, INT2PTR(kPtr->virt),
 				   &dummy);
 	Tcl_SetHashValue(hPtr, INT2PTR(kPtr->keysym));
 	hPtr = Tcl_CreateHashEntry(&keysym2keycode, INT2PTR(kPtr->keysym),
 				   &dummy);
-	macKC.v.virtual = kPtr->virtual;
+	macKC.v.virt = kPtr->virt;
 	macKC.v.keychar = kPtr->keychar;
 	Tcl_SetHashValue(hPtr, INT2PTR(macKC.uint));
 
 	/*
 	 * The Carbon framework does not work for finding the unicode character
@@ -250,11 +250,11 @@
 static void
 UpdateKeymaps()
 {
     static Bool keymapInitialized = false;
     Tcl_HashEntry *hPtr;
-    int virtual, index, dummy;
+    int virt, index, dummy;
 
     if (!keymapInitialized) {
 	Tcl_InitHashTable(&unichar2xvirtual, TCL_ONE_WORD_KEYS);
 	keymapInitialized = true;
     } else {
@@ -266,16 +266,16 @@
      * minimal modifier mask.  Simpler combinations will overwrite more complex
      * ones when constructing the table.
      */
 
     for (index = 3; index >= 0; index--) {
-        for (virtual = 0; virtual < 128; virtual++) {
+        for (virt = 0; virt < 128; virt++) {
 	    MacKeycode macKC;
-	    macKC.v = (keycode_v) {.virtual = virtual, .o_s = index, .keychar = 0};
-	    int modifiers = INDEX2CARBON(index), result;
+	    macKC.v = (keycode_v) {.virt = virt, .o_s = index, .keychar = 0};
+	    int modifiers = INDEX2CARBON(index);
 	    UniChar keychar = 0;
-	    result = KeyDataToUnicode(&keychar, 1, kUCKeyActionDown, virtual,
+	    KeyDataToUnicode(&keychar, 1, kUCKeyActionDown, virt,
 				      modifiers, NULL);
 	    if (keychar == 0x10) {
 
 		/*
 		 * This is a special key, handled in InitHashTables.
@@ -282,11 +282,11 @@
 		 */
 
 		continue;
 	    }
 	    macKC.v.keychar = keychar;
-	    if (! ON_KEYPAD(virtual)) {
+	    if (! ON_KEYPAD(virt)) {
 		hPtr = Tcl_CreateHashEntry(&unichar2xvirtual,
 					   INT2PTR(macKC.x.keychar), &dummy);
 		Tcl_SetHashValue(hPtr, INT2PTR(macKC.x.xvirtual));
             }
 	    xvirtual2unichar[macKC.x.xvirtual] = macKC.x.keychar;
@@ -324,11 +324,11 @@
 static int
 KeyDataToUnicode(
     UniChar *uniChars,
     int maxChars,
     UInt16 keyaction,
-    UInt32 virtual,
+    UInt32 virt,
     UInt32 modifiers,
     UInt32 *deadKeyStatePtr)
 {
     static const void *layoutData = NULL;
     static UInt32 keyboardType = 0;
@@ -353,18 +353,18 @@
     if (layoutData) {
 	OptionBits options = 0;
 	UInt32 dummyState;
 	OSStatus err;
 
-	virtual &= 0xFF;
+	virt &= 0xFF;
 	modifiers = (modifiers >> 8) & 0xFF;
 	if (!deadKeyStatePtr) {
 	    options = kUCKeyTranslateNoDeadKeysMask;
 	    dummyState = 0;
 	    deadKeyStatePtr = &dummyState;
 	}
-	err = ChkErr(UCKeyTranslate, layoutData, virtual, keyaction, modifiers,
+	err = ChkErr(UCKeyTranslate, (const UCKeyboardLayout *)layoutData, virt, keyaction, modifiers,
 		keyboardType, options, deadKeyStatePtr, maxChars,
 		&actuallength, uniChars);
 	if (!actuallength && *deadKeyStatePtr) {
 
 	    /*
@@ -422,11 +422,11 @@
     /*
      * First check if the virtual keycode corresponds to a special key, such as
      * an Fn function key or Tab, Backspace, Home, End, etc.
      */
 
-    hPtr = Tcl_FindHashEntry(&special2keysym, INT2PTR(macKC.v.virtual));
+    hPtr = Tcl_FindHashEntry(&special2keysym, INT2PTR(macKC.v.virt));
     if (hPtr != NULL) {
 	return (KeySym) Tcl_GetHashValue(hPtr);
     }
 
     /*
@@ -433,11 +433,11 @@
      * If the virtual value in this keycode does not correspond to an actual
      * key in the current keyboard layout, try using its keychar to look up a
      * keysym.
      */
 
-    if (macKC.v.virtual > 127) {
+    if (macKC.v.virt > 127) {
 	hPtr = Tcl_FindHashEntry(&unichar2keysym, INT2PTR(macKC.v.keychar));
 	if (hPtr != NULL) {
 	    return (KeySym) Tcl_GetHashValue(hPtr);
 	}
     }
@@ -448,11 +448,11 @@
      * Framework; then translate the keychar to a keysym using the
      * unicode2keysym hash table.
      */
 
     modifiers = INDEX2CARBON(macKC.v.o_s);
-    result = KeyDataToUnicode(&keychar, 1, kUCKeyActionDown, macKC.v.virtual,
+    result = KeyDataToUnicode(&keychar, 1, kUCKeyActionDown, macKC.v.virt,
 			      modifiers, NULL);
     if (result) {
 	hPtr = Tcl_FindHashEntry(&unichar2keysym, INT2PTR(keychar));
 	if (hPtr != NULL) {
 	    return (KeySym) Tcl_GetHashValue(hPtr);
@@ -635,19 +635,19 @@
      * First check for a special key.
      */
 
     hPtr = Tcl_FindHashEntry(&keysym2keycode, INT2PTR(keysym));
     if (hPtr != NULL) {
-	return (KeyCode) Tcl_GetHashValue(hPtr);
+	return (KeyCode) PTR2INT(Tcl_GetHashValue(hPtr));
     }
 
     /*
      * Initialize the keycode as if the keysym cannot be converted to anything
      * else.
      */
 
-    macKC.v.virtual = NO_VIRTUAL;
+    macKC.v.virt = NO_VIRTUAL;
     macKC.v.o_s = 0;
     macKC.v.keychar = 0;
 
     /*
      * If the keysym is recognized fill in the keychar.  Also fill in the
@@ -717,11 +717,11 @@
 	    macKC.v.o_s |= eventIndex;
 	}
 	if (macKC.v.keychar < 0xF700) {
 	    UniChar keychar = macKC.v.keychar;
 	    NSString *str, *lower, *upper;
-	    if (macKC.v.virtual != NO_VIRTUAL) {
+	    if (macKC.v.virt != NO_VIRTUAL) {
 		macKC.x.keychar = xvirtual2unichar[macKC.x.xvirtual];
 	    } else {
 		str = [[NSString alloc] initWithCharacters:&keychar length:1];
 		lower = [str lowercaseString];
 		upper = [str uppercaseString];
@@ -779,11 +779,11 @@
     /*
      * Modifier key events have a special mac keycode (see tkProcessKeyEvent).
      */
 
     if (macKC.v.keychar == MOD_KEYCHAR) {
-	switch (macKC.v.virtual) {
+	switch (macKC.v.virt) {
 	case 54:
 	    return XK_Meta_R;
 	case 55:
 	    return XK_Meta_L;
 	case 56:
@@ -951,11 +951,11 @@
 					       INT2PTR(macKC.v.keychar));
     if (hPtr != NULL) {
 	unsigned long data = (unsigned long) Tcl_GetHashValue(hPtr);
 	macKC.x.xvirtual = (unsigned int) data;
     } else {
-	macKC.v.virtual = NO_VIRTUAL;
+	macKC.v.virt = NO_VIRTUAL;
     }
     return macKC.uint;
 }
 /*
  * Local Variables:

Index: macosx/tkMacOSXKeysyms.h
==================================================================
--- macosx/tkMacOSXKeysyms.h
+++ macosx/tkMacOSXKeysyms.h
@@ -2,15 +2,15 @@
  * tkMacOSXKeysyms.h --
  *
  *      Contains data used for processing key events, some of which was
  *      moved from tkMacOSXKeyboard.c.
  *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2020 Marc Culler
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2020 Marc Culler
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -29,11 +29,11 @@
  * as F20, which is reported to be usable in scripts even though it does not
  * appear on any Macintosh keyboard.
  */
 
 typedef struct {
-    int virtual;	/* value of [NSEvent keyCode] */
+    int virt;	/* value of [NSEvent keyCode] */
     KeySym keysym;	/* X11 keysym */
     KeyCode keychar;	/* XEvent keycode & 0xFFFF */
 } KeyInfo;
 
 static const KeyInfo keyArray[] = {

Index: macosx/tkMacOSXMenu.c
==================================================================
--- macosx/tkMacOSXMenu.c
+++ macosx/tkMacOSXMenu.c
@@ -1,14 +1,14 @@
 /*
  * tkMacOSXMenu.c --
  *
  *	This module implements the Mac-platform specific features of menus.
  *
- * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2012 Adrian Robert.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2012 Adrian Robert.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -89,11 +89,11 @@
     {NULL, 0, 0}
 };
 #undef ACCEL
 #undef sl
 
-static int inPostMenu = 0;
+static Bool   inPostMenu = false;
 static SInt32 menuMarkColumnWidth = 0, menuIconTrailingEdgeMargin = 0;
 static SInt32 menuTextLeadingEdgeMargin = 0, menuTextTrailingEdgeMargin = 0;
 static SInt16 menuItemExtraHeight = 0, menuItemExtraWidth = 0;
 static SInt16 menuSeparatorHeight = 0;
 
@@ -119,11 +119,11 @@
  * that the Tk event loop would block in its call to the check proc as long as
  * the menu was posted.  For example, opening a menu during the Rube Goldberg
  * demo would cause the animation to stop.  This was also the case for
  * menubuttons.
  *
- * The TKBackground object below works around this problem, and allows a Tk
+ * The TKBackgroundLoop object below works around this problem, and allows a Tk
  * event loop to run while a menu is open.  It is a subclass of NSThread which
  * inserts requests to call [NSApp _runBackgroundLoop] onto the queue
  * associated with the NSEventTrackingRunLoopMode.  One of these threads gets
  * started in the callback [NSApp menuBeginTracking] and cancelled in [NSApp
  * menuEndTracking].
@@ -162,11 +162,10 @@
 }
 @end
 
 TKBackgroundLoop *backgroundLoop = nil;
 
-
 #pragma mark TKMenu
 
 /*
  * This interface is not declared in tkMacOSXPrivate.h because it requires
  * tkMenu.h.
@@ -187,10 +186,49 @@
 }
 - (BOOL) isSpecial: (NSUInteger) special
 {
     return (_tkSpecial == special);
 }
+
+/*
+ * There are cases where a KeyEquivalent (aka menu accelerator) is defined for
+ * a "dead key", i.e. a key which does not have an associated character but is
+ * only meant to be the start of a composition sequence.  For example, on a
+ * Spanish keyboard both the ' and the ` keys are dead keys used to place
+ * accents over letters.  But ⌘` is a standard KeyEquivalent which cycles
+ * through the open windows of an application, changing the focus to the next
+ * window. This caused a bug reported in [1626ed65b8].  When a dead key that is
+ * also as a KeyEquivalent is pressed, a KeyDown event with no characters would
+ * be passed to performKeyEquivalent.  The default implementation provided by
+ * Apple would cause that event to be routed to some private methods of NSMenu
+ * which raise NSInvalidArgumentException, causing an abort. Returning NO in
+ * such a case prevents the abort.  So the override below returns NO when the
+ * event has no characters.
+ *
+ * In fact, however, we never want to handle accelerators because they are
+ * handled by Tk.  Hence this method could always return NO.  But if we did
+ * that then we would not see the menu flash when an accelerator is pressed.
+ * The flash is a useful visual indicator. It turns out that the flash is an
+ * undocumented side effect of calling the super method for
+ * performKeyEquivalent.  The super method also calls the NSMenuItem's action
+ * method - tkMenuItemInvoke in our case.  This is also not documented.
+ *
+ * To enable the flash we set up a flag that tells the action method to do
+ * nothing, because it is being called by an accelerator. The override below
+ * sets the flag and then calls super. See ticket [ead70921a9].
+ */
+
+static Bool runMenuCommand = true;
+- (BOOL)performKeyEquivalent:(NSEvent *)event
+{
+    if ([[event characters] length] == 0) {
+	return NO;
+    }
+    runMenuCommand = false;
+    /* Make the menu flash and call tkMenuItemInvoke. */
+    return [super performKeyEquivalent: event];
+}
 @end
 
 @implementation TKMenu(TKMenuPrivate)
 
 - (id) initWithTitle: (NSString *) aTitle
@@ -206,12 +244,12 @@
     return self;
 }
 
 - (id) initWithTkMenu: (TkMenu *) tkMenu
 {
-    NSString *title = [[NSString alloc] initWithUTF8String:
-	    Tk_PathName(tkMenu->tkwin)];
+    NSString *title = [[TKNSString alloc] initWithTclUtfBytes:
+	    Tk_PathName(tkMenu->tkwin) length:-1];
 
     self = [self initWithTitle:title];
     [title release];
     if (self) {
 	_tkMenu = tkMenu;
@@ -231,11 +269,11 @@
     return copy;
 }
 
 - (TkMenu *) tkMenu
 {
-    return _tkMenu;
+    return (TkMenu *)_tkMenu;
 }
 
 - (int) tkIndexOfItem: (NSMenuItem *) menuItem
 {
     return [self indexOfItem:menuItem] - _tkOffset;
@@ -299,36 +337,35 @@
     return YES;
 }
 
 - (void) tkMenuItemInvoke: (id) sender
 {
+    if (!runMenuCommand) {
+
+    	/*
+    	 * We are being called for a menu accelerator.  Tk will handle it.
+    	 * Just update the runMenuCommand flag.
+    	 */
+
+    	runMenuCommand = true;
+    	return;
+    }
+
     /*
-     * With the delegate matching key equivalents, when a menu action is sent
-     * in response to a key equivalent, the sender is the whole menu and not the
-     * specific menu item.  We use this to ignore key equivalents for Tk
-     * menus (as Tk handles them directly via bindings).
+     * We are being called for an actual menu item selection; run the command.
      */
 
     if ([sender isKindOfClass:[NSMenuItem class]]) {
 	NSMenuItem *menuItem = (NSMenuItem *) sender;
 	TkMenu *menuPtr = (TkMenu *) _tkMenu;
 	TkMenuEntry *mePtr = (TkMenuEntry *) [menuItem tag];
 
 	if (menuPtr && mePtr) {
 	    Tcl_Interp *interp = menuPtr->interp;
-
-	    /*
-	     * Add time for errors to fire if necessary. This is sub-optimal
-	     * but avoids issues with Tcl/Cocoa event loop integration.
-	     */
-
-	    //Tcl_Sleep(100);
 	    Tcl_Preserve(interp);
 	    Tcl_Preserve(menuPtr);
-
 	    int result = TkInvokeMenu(interp, menuPtr, mePtr->index);
-
 	    if (result != TCL_OK && result != TCL_CONTINUE &&
 		    result != TCL_BREAK) {
 		Tcl_AddErrorInfo(interp, "\n    (menu invoke)");
 		Tcl_BackgroundException(interp, result);
 	    }
@@ -414,11 +451,11 @@
 - (void) menuDidClose: (NSMenu *) menu
 {
     (void)menu;
 
     if (_tkMenu) {
-	RecursivelyClearActiveMenu(_tkMenu);
+	RecursivelyClearActiveMenu((TkMenu *)_tkMenu);
     }
 }
 
 - (void) menu: (NSMenu *) menu willHighlightItem: (NSMenuItem *) item
 {
@@ -438,11 +475,11 @@
 	Tcl_Interp *interp = menuPtr->interp;
 
 	Tcl_Preserve(interp);
 	Tcl_Preserve(menuPtr);
 
-	int result = TkPostCommand(_tkMenu);
+	int result = TkPostCommand(menuPtr);
 
 	if (result!=TCL_OK && result!=TCL_CONTINUE && result!=TCL_BREAK) {
 	      Tcl_AddErrorInfo(interp, "\n    (menu preprocess)");
 	      Tcl_BackgroundException(interp, result);
 	}
@@ -466,12 +503,17 @@
 	[backgroundLoop cancel];
 	[backgroundLoop release];
     }
     backgroundLoop = [[TKBackgroundLoop alloc] init];
     [backgroundLoop start];
-    //TkMacOSXClearMenubarActive();
-    //TkMacOSXPreprocessMenu();
+
+    /*
+     * Make sure that we can run commands when actually using a menu.
+     * See [412b80fcaf].
+     */
+
+    runMenuCommand = true;
 }
 
 - (void) menuEndTracking: (NSNotification *) notification
 {
     (void)notification;
@@ -683,74 +725,93 @@
     NSAttributedString *attributedTitle = nil;
     NSImage *image = nil;
     NSString *keyEquivalent = @"";
     NSUInteger modifierMask = NSCommandKeyMask;
     NSMenu *submenu = nil;
-    NSDictionary *attributes;
     int imageWidth, imageHeight;
     GC gc = (mePtr->textGC ? mePtr->textGC : mePtr->menuPtr->textGC);
     Tcl_Obj *fontPtr = (mePtr->fontPtr ?
 			mePtr->fontPtr : mePtr->menuPtr->fontPtr);
-    static unsigned long defaultBg, defaultFg;
     static int initialized = 0;
 
     if (!initialized) {
 	TkColor *tkColPtr = TkpGetColor(NULL, DEF_MENU_BG_COLOR);
-	defaultBg = tkColPtr->color.pixel;
 	ckfree(tkColPtr);
 	tkColPtr = TkpGetColor(NULL, DEF_MENU_FG);
-	defaultFg = tkColPtr->color.pixel;
 	ckfree(tkColPtr);
     }
 
     if (mePtr->image) {
     	Tk_SizeOfImage(mePtr->image, &imageWidth, &imageHeight);
 	image = TkMacOSXGetNSImageFromTkImage(mePtr->menuPtr->display,
 		mePtr->image, imageWidth, imageHeight);
-    } else if (mePtr->bitmapPtr != None) {
+    } else if (mePtr->bitmapPtr != NULL) {
 	Pixmap bitmap = Tk_GetBitmapFromObj(mePtr->menuPtr->tkwin,
 		mePtr->bitmapPtr);
 
 	Tk_SizeOfBitmap(mePtr->menuPtr->display, bitmap, &imageWidth,
 		&imageHeight);
 	image = TkMacOSXGetNSImageFromBitmap(mePtr->menuPtr->display, bitmap,
 		gc, imageWidth, imageHeight);
-	if (gc->foreground == defaultFg) {
-	    [image setTemplate:YES];
-	}
+	[image setTemplate:YES];
     }
     [menuItem setImage:image];
     if ((!image || mePtr->compound != COMPOUND_NONE) && mePtr->labelPtr &&
 	    mePtr->labelLength) {
-	title = [[[NSString alloc] initWithBytes:Tcl_GetString(mePtr->labelPtr)
-		length:mePtr->labelLength encoding:NSUTF8StringEncoding]
-		autorelease];
+	title = [[TKNSString alloc]
+		    initWithTclUtfBytes:Tcl_GetString(mePtr->labelPtr)
+				length:mePtr->labelLength];
 	if ([title hasSuffix:@"..."]) {
 	    title = [NSString stringWithFormat:@"%@%C",
 		    [title substringToIndex:[title length] - 3], 0x2026];
 	}
     }
     [menuItem setTitle:title];
-    if (strcmp(Tcl_GetString(fontPtr), "menu") || gc->foreground != defaultFg
-	    || gc->background != defaultBg) {
-	attributes = TkMacOSXNSFontAttributesForFont(Tk_GetFontFromObj(
-		mePtr->menuPtr->tkwin, fontPtr));
-	if (gc->foreground != defaultFg || gc->background != defaultBg) {
-	    NSColor *color = TkMacOSXGetNSColor(gc,
-		    gc->foreground!=defaultFg? gc->foreground:gc->background);
-
-	    attributes = [[attributes mutableCopy] autorelease];
-	    [(NSMutableDictionary *) attributes setObject:color
-		    forKey:NSForegroundColorAttributeName];
-	}
-	if (attributes) {
-	    attributedTitle = [[[NSAttributedString alloc]
-		    initWithString:title attributes:attributes] autorelease];
-	}
-    }
+
+#if 0
+
+    /*
+     * The -background and -foreground options are now ignored in Aqua.
+     * See ticket [635167af14].
+     */
+
+    NSDictionary fontAttributes = TkMacOSXNSFontAttributesForFont(
+	Tk_GetFontFromObj(mePtr->menuPtr->tkwin, fontPtr));
+    NSMutableDictionary *attributes = [fontAttributes mutableCopy];
+    static unsigned long defaultBg = 0, defaultFg = 0;
+    if (defaultBg == 0) {
+	tkColor *tkColPtr = TkpGetColor(NULL, DEF_MENU_BG_COLOR);
+	defaultBg = tkColPtr->color.pixel;
+	ckfree(tkColPtr);
+    }
+    if (defaultFg == 0) {
+	tkColor *tkColPtr = TkpGetColor(NULL, DEF_MENU_FG);
+	defaultFg = tkColPtr->color.pixel;
+	ckfree(tkColPtr);
+    }
+    if (gc->foreground != defaultFg) {
+	NSColor *fgcolor = TkMacOSXGetNSColor(gc, gc->foreground);
+	[attributes setObject:fgcolor
+		       forKey:NSForegroundColorAttributeName];
+    }
+    if (gc->background != defaultBg) {
+	NSColor *bgcolor = TkMacOSXGetNSColor(gc, gc->background);
+	[attributes setObject:bgcolor
+	 	       forKey:NSBackgroundColorAttributeName];
+    }
+
+#else
+
+    NSDictionary *attributes = TkMacOSXNSFontAttributesForFont(
+	Tk_GetFontFromObj(mePtr->menuPtr->tkwin, fontPtr));
+
+#endif
+
+    attributedTitle = [[NSAttributedString alloc] initWithString:title
+	attributes:attributes];
     [menuItem setAttributedTitle:attributedTitle];
-    [menuItem setEnabled:!(mePtr->state == ENTRY_DISABLED)];
+    [menuItem setEnabled:(mePtr->state != ENTRY_DISABLED)];
     [menuItem setState:((mePtr->type == CHECK_BUTTON_ENTRY ||
 	    mePtr->type == RADIO_BUTTON_ENTRY) && mePtr->indicatorOn &&
 	    (mePtr->entryFlags & ENTRY_SELECTED) ? NSOnState : NSOffState)];
     if (mePtr->type != CASCADE_ENTRY && mePtr->accelPtr && mePtr->accelLength) {
 	keyEquivalent = ParseAccelerator(Tcl_GetString(mePtr->accelPtr),
@@ -767,11 +828,11 @@
 	    CheckForSpecialMenu(menuRefPtr->menuPtr);
 	    submenu = (TKMenu *) menuRefPtr->menuPtr->platformData;
 	    if ([submenu supermenu] && [menuItem submenu] != submenu) {
 		/*
 		 * This happens during a clone, where the parent menu is
-		 * cloned before its children, so just ignore this temprary
+		 * cloned before its children, so just ignore this temporary
 		 * setting, it will be changed shortly (c.f. tkMenu.c
 		 * CloneMenu())
 		 */
 
 		submenu = nil;
@@ -779,31 +840,21 @@
 		[submenu setTitle:title];
 
     		if ([menuItem isEnabled]) {
 
 		    /*
-		     * This menuItem might have been previously disabled (XXX:
-		     * track this), which would have disabled entries; we must
-		     * re-enable the entries here.
-		     */
-
-		    int i = 0;
-		    NSArray *itemArray = [submenu itemArray];
-
-		    for (NSMenuItem *item in itemArray) {
-			TkMenuEntry *submePtr = menuRefPtr->menuPtr->entries[i];
-
-			/*
-			 * Work around an apparent bug where itemArray can have
-			 * more items than the menu's entries[] array.
-			 */
-
-			if (i >= (int) menuRefPtr->menuPtr->numEntries) {
-			    break;
-			}
-			[item setEnabled: !(submePtr->state == ENTRY_DISABLED)];
-			i++;
+		     * This menuItem might have been previously disabled which
+		     * would have disabled all of its entries; we must re-enable the
+		     * entries here.  It is important to iterate though the Tk
+		     * entries, not the NSMenuItems, since some NSMenuItems may
+		     * have been added by the system.  See [7185d26cf4].
+		     */
+
+		    for (TkSizeT i = 0; i < menuRefPtr->menuPtr->numEntries; i++) {
+			TkMenuEntry *submePtr = menuRefPtr->menuPtr->entries[i];
+			NSMenuItem *item = (NSMenuItem *) submePtr->platformEntryData;
+			[item setEnabled:(submePtr->state != ENTRY_DISABLED)];
 		    }
 		}
 	    }
 	}
     }
@@ -906,14 +957,14 @@
     NSInteger itemIndex = index;
     NSInteger numItems = [menu numberOfItems];
     NSMenuItem *item = nil;
     NSPoint location = NSMakePoint(x, TkMacOSXZeroScreenHeight() - y);
 
-    inPostMenu = 1;
+    inPostMenu = true;
     result = TkPreprocessMenu(menuPtr);
     if (result != TCL_OK) {
-        inPostMenu = 0;
+        inPostMenu = false;
         return result;
     }
     if (itemIndex >= numItems) {
     	itemIndex = numItems - 1;
     }
@@ -931,11 +982,11 @@
     }
 
     [menu popUpMenuPositioningItem:item
 			atLocation:[win tkConvertPointFromScreen:location]
 			    inView:view];
-    inPostMenu = 0;
+    inPostMenu = false;
     return TCL_OK;
 }
 
 /*
  *----------------------------------------------------------------------
@@ -974,17 +1025,10 @@
 				 * entry, will be located. */
 {
     int vRootX, vRootY, vRootWidth, vRootHeight;
     int result;
 
-    if (index >= (int) menuPtr->numEntries) {
-	index = menuPtr->numEntries - 1;
-    }
-    if (index >= 0) {
-	y -= menuPtr->entries[index]->y;
-    }
-
     TkActivateMenuEntry(menuPtr, -1);
     TkRecomputeMenu(menuPtr);
     result = TkPostCommand(menuPtr);
     if (result != TCL_OK) {
     	return result;
@@ -996,10 +1040,22 @@
      */
 
     if (menuPtr->tkwin == NULL) {
     	return TCL_OK;
     }
+
+    /*
+     * Adjust the menu y position so that the specified entry will be located
+     * at the given coordinates.
+     */
+
+    if (index < 0 || (TkSizeT)index >= menuPtr->numEntries) {
+	index = menuPtr->numEntries - 1;
+    }
+    if (index >= 0) {
+	y -= menuPtr->entries[index]->y;
+    }
 
     /*
      * Adjust the position of the menu if necessary to keep it visible on the
      * screen. There are two special tricks to make this work right:
      *
@@ -1070,11 +1126,11 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpSetMainMenubar --
+ * Tk_SetMainMenubar --
  *
  *	Puts the menu associated with a window into the menubar. Should only be
  *	called when the window is in front.
  *
  *      This is a no-op on all other platforms.  On OS X it is a no-op when
@@ -1090,11 +1146,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 void
-TkpSetMainMenubar(
+Tk_SetMainMenubar(
     Tcl_Interp *interp,		/* The interpreter of the application */
     Tk_Window tkwin,		/* The frame we are setting up */
     const char *menuName)	/* The name of the menu to put in front. */
 {
     static Tcl_Interp *currentInterp = NULL;
@@ -1272,21 +1328,21 @@
 	}
     }
     if (ch) {
 	return [[[NSString alloc] initWithCharacters:&ch length:1] autorelease];
     } else {
-	return [[[[NSString alloc] initWithUTF8String:accel] autorelease]
+	return [[[[TKNSString alloc] initWithTclUtfBytes:accel length:-1] autorelease]
 		lowercaseString];
     }
 }
 
 /*
  *--------------------------------------------------------------
  *
  * ModifierCharWidth --
  *
- *	Helper mesuring width of command char in given font.
+ *	Helper measuring width of command char in given font.
  *
  * Results:
  *	Width of command char.
  *
  * Side effects:
@@ -1332,11 +1388,11 @@
 TkpComputeStandardMenuGeometry(
     TkMenu *menuPtr)		/* Structure describing menu. */
 {
     NSSize menuSize;
     Tk_Font tkfont, menuFont;
-    Tk_FontMetrics menuMetrics, entryMetrics, *fmPtr;
+    Tk_FontMetrics menuMetrics, entryMetrics;
     int modifierCharWidth, menuModifierCharWidth;
     int x, y, modifierWidth, labelWidth, indicatorSpace;
     int windowWidth, windowHeight, accelWidth;
     int i, maxWidth;
     int entryWidth, maxIndicatorSpace, borderWidth, activeBorderWidth;
@@ -1387,16 +1443,14 @@
 	if (mePtr->type == TEAROFF_ENTRY) {
 	    continue;
 	}
 	if (mePtr->fontPtr == NULL) {
 	    tkfont = menuFont;
-	    fmPtr = &menuMetrics;
 	    modifierCharWidth = menuModifierCharWidth;
 	} else {
 	    tkfont = Tk_GetFontFromObj(menuPtr->tkwin, mePtr->fontPtr);
 	    Tk_GetFontMetrics(tkfont, &entryMetrics);
-	    fmPtr = &entryMetrics;
 	    modifierCharWidth = ModifierCharWidth(tkfont);
 	}
 	accelWidth = modifierWidth = indicatorSpace = 0;
 	if (mePtr->type == SEPARATOR_ENTRY) {
 	    mePtr->height = menuSeparatorHeight;
@@ -1563,30 +1617,30 @@
 
 void
 MenuSelectEvent(
     TkMenu *menuPtr)		/* the menu we have selected. */
 {
-    XVirtualEvent event;
-
-    bzero(&event, sizeof(XVirtualEvent));
-    event.type = VirtualEvent;
-    event.serial = LastKnownRequestProcessed(menuPtr->display);
-    event.send_event = false;
-    event.display = menuPtr->display;
-    event.event = Tk_WindowId(menuPtr->tkwin);
-    event.root = XRootWindow(menuPtr->display, 0);
-    event.subwindow = None;
-    event.time = TkpGetMS();
-    XQueryPointer(NULL, None, NULL, NULL, &event.x_root, &event.y_root, NULL,
-	    NULL, &event.state);
-    event.same_screen = true;
-    event.name = Tk_GetUid("MenuSelect");
+    union {XEvent general; XVirtualEvent virt;} event;
+
+    bzero(&event, sizeof(event));
+    event.virt.type = VirtualEvent;
+    event.virt.serial = LastKnownRequestProcessed(menuPtr->display);
+    event.virt.send_event = false;
+    event.virt.display = menuPtr->display;
+    event.virt.event = Tk_WindowId(menuPtr->tkwin);
+    event.virt.root = XRootWindow(menuPtr->display, 0);
+    event.virt.subwindow = None;
+    event.virt.time = TkpGetMS();
+    XQueryPointer(NULL, None, NULL, NULL, &event.virt.x_root, &event.virt.y_root, NULL,
+	    NULL, &event.virt.state);
+    event.virt.same_screen = true;
+    event.virt.name = Tk_GetUid("MenuSelect");
     Tk_MakeWindowExist(menuPtr->tkwin);
     if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) {
-	Tk_HandleEvent((XEvent *) &event);
+	Tk_HandleEvent(&event.general);
     } else {
-	Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
+	Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
     }
 }
 
 /*
  *----------------------------------------------------------------------
@@ -1672,12 +1726,10 @@
  */
 
 void
 TkpMenuInit(void)
 {
-    //    TkColor *tkColPtr;
-
     NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
 
 #define observe(n, s) \
 	[nc addObserver:NSApp selector:@selector(s) name:(n) object:nil]
     observe(NSMenuDidBeginTrackingNotification, menuBeginTracking:);
@@ -1813,17 +1865,21 @@
  *----------------------------------------------------------------------
  *
  * TkpDrawMenuEntry --
  *
  *	Draws the given menu entry at the given coordinates with the given
- *	attributes.
+ *	attributes.  This is a no-op on macOS since the menus are drawn by
+ *      the Apple window manager, which also handles all events related to
+ *      selecting menu items.  This function is only called for tearoff
+ *      menus, which are not supported on macOS but do get drawn as nearly
+ *      invisible 1 pixel wide windows on macOS
  *
  * Results:
  *	None.
  *
  * Side effects:
- *	X Server commands are executed to display the menu entry.
+ *	None
  *
  *----------------------------------------------------------------------
  */
 
 void

Index: macosx/tkMacOSXMenubutton.c
==================================================================
--- macosx/tkMacOSXMenubutton.c
+++ macosx/tkMacOSXMenubutton.c
@@ -2,15 +2,15 @@
  * tkMacOSXMenubutton.c --
  *
  *	This file implements the Macintosh specific portion of the menubutton
  *	widget.
  *
- * Copyright (c) 1996 by Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright 2007 Revar Desmera.
- * Copyright 2015 Kevin Walzer/WordTech Communications LLC.
+ * Copyright © 1996 Sun Microsystems, Inc.
+ * Copyright © 2001 Apple Computer, Inc.
+ * Copyright © 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2007 Revar Desmera.
+ * Copyright © 2015 Kevin Walzer/WordTech Communications LLC.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
  */
@@ -163,12 +163,12 @@
 
 void
 TkpDisplayMenuButton(
     ClientData clientData)	/* Information about widget. */
 {
-    MacMenuButton *mbPtr = clientData;
-    TkMenuButton *butPtr = clientData;
+    MacMenuButton *mbPtr = (MacMenuButton *)clientData;
+    TkMenuButton *butPtr = (TkMenuButton *)clientData;
     Tk_Window tkwin = butPtr->tkwin;
     Pixmap pixmap;
     DrawParams *dpPtr = &mbPtr->drawParams;
 
     butPtr->flags &= ~REDRAW_PENDING;
@@ -238,12 +238,12 @@
  *
  *----------------------------------------------------------------------
  */
 
 void
-TkpComputeMenuButtonGeometry(butPtr)
-    TkMenuButton *butPtr;	/* Widget record for menu button. */
+TkpComputeMenuButtonGeometry(
+    TkMenuButton *butPtr)	/* Widget record for menu button. */
 {
     int width, height, avgWidth, haveImage = 0, haveText = 0;
     int txtWidth, txtHeight;
     Tk_FontMetrics fm;
     int highlightWidth = butPtr->highlightWidth > 0 ? butPtr->highlightWidth : 0;
@@ -373,11 +373,10 @@
 {
     MacMenuButton *mbPtr = (MacMenuButton *) butPtr;
     Tk_Window tkwin  = butPtr->tkwin;
     Pixmap pixmap;
     int haveImage = 0, haveText = 0;
-    int imageWidth = 0, imageHeight = 0;
     int imageXOffset = 0, imageYOffset = 0;
     int textXOffset = 0, textYOffset = 0;
     int width = 0, height = 0;
     int fullWidth = 0, fullHeight = 0;
 
@@ -394,13 +393,10 @@
     } else if (butPtr->bitmap != None) {
         Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
         haveImage = 1;
     }
 
-    imageWidth = width;
-    imageHeight = height;
-
     haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0);
     if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) {
         int x = 0, y = 0;
 
         textXOffset = 0;
@@ -687,12 +683,12 @@
 static void
 MenuButtonEventProc(
     ClientData clientData,	/* Information about window. */
     XEvent *eventPtr)		/* Information about event. */
 {
-    TkMenuButton *buttonPtr = clientData;
-    MacMenuButton *mbPtr = clientData;
+    TkMenuButton *buttonPtr = (TkMenuButton *)clientData;
+    MacMenuButton *mbPtr = (MacMenuButton *)clientData;
 
     if (eventPtr->type == ActivateNotify
 	    || eventPtr->type == DeactivateNotify) {
 	if ((buttonPtr->tkwin == NULL) || (!Tk_IsMapped(buttonPtr->tkwin))) {
 	    return;

Index: macosx/tkMacOSXMenus.c
==================================================================
--- macosx/tkMacOSXMenus.c
+++ macosx/tkMacOSXMenus.c
@@ -1,13 +1,13 @@
 /*
  * tkMacOSXMenus.c --
  *
  *	These calls set up the default menus for Tk.
  *
- * Copyright (c) 1995-1996 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 1995-1996 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -201,11 +201,11 @@
 {
     (void)sender;
 
     if (!_eventInterp || !Tcl_FindCommand(_eventInterp, "tkAboutDialog",
 	    NULL, 0) || (GetCurrentEventKeyModifiers() & optionKey)) {
-	TkAboutDlg();
+	[super orderFrontStandardAboutPanel:nil];
     } else {
 	int code = Tcl_EvalEx(_eventInterp, "tkAboutDialog", -1,
 		TCL_EVAL_GLOBAL);
 
 	if (code != TCL_OK) {
@@ -389,11 +389,11 @@
 
 static void
 GenerateEditEvent(
     const char *name)
 {
-    XVirtualEvent event;
+    union {XEvent general; XVirtualEvent virt;} event;
     int x, y;
     TkWindow *winPtr = TkMacOSXGetTkWindow([NSApp keyWindow]);
     Tk_Window tkwin;
 
     if (!winPtr) {
@@ -401,25 +401,25 @@
     }
     tkwin = (Tk_Window)winPtr->dispPtr->focusPtr;
     if (!tkwin) {
 	return;
     }
-    bzero(&event, sizeof(XVirtualEvent));
-    event.type = VirtualEvent;
-    event.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
-    event.send_event = false;
-    event.display = Tk_Display(tkwin);
-    event.event = Tk_WindowId(tkwin);
-    event.root = XRootWindow(Tk_Display(tkwin), 0);
-    event.subwindow = None;
-    event.time = TkpGetMS();
+    bzero(&event, sizeof(event));
+    event.virt.type = VirtualEvent;
+    event.virt.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
+    event.virt.send_event = false;
+    event.virt.display = Tk_Display(tkwin);
+    event.virt.event = Tk_WindowId(tkwin);
+    event.virt.root = XRootWindow(Tk_Display(tkwin), 0);
+    event.virt.subwindow = None;
+    event.virt.time = TkpGetMS();
     XQueryPointer(NULL, winPtr->window, NULL, NULL,
-	    &event.x_root, &event.y_root, &x, &y, &event.state);
-    Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y);
-    event.same_screen = true;
-    event.name = Tk_GetUid(name);
-    Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
+	    &event.virt.x_root, &event.virt.y_root, &x, &y, &event.virt.state);
+    Tk_TopCoordsToWindow(tkwin, x, y, &event.virt.x, &event.virt.y);
+    event.virt.same_screen = true;
+    event.virt.name = Tk_GetUid(name);
+    Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
 }
 
 #pragma mark -
 
 #pragma mark NSMenu & NSMenuItem Utilities

Index: macosx/tkMacOSXMouseEvent.c
==================================================================
--- macosx/tkMacOSXMouseEvent.c
+++ macosx/tkMacOSXMouseEvent.c
@@ -2,12 +2,12 @@
  * tkMacOSXMouseEvent.c --
  *
  *	This file implements functions that decode & handle mouse events on
  *	MacOS X.
  *
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -23,73 +23,118 @@
     Window window;
     Point global;
     Point local;
 } MouseEventData;
 
+typedef struct {
+    uint64_t wheelTickPrev;	/* For high resolution wheels. */
+    double vWheelAcc;		/* For high resolution wheels (vertical). */
+    double hWheelAcc;		/* For high resolution wheels (horizontal). */
+} ThreadSpecificData;
+static Tcl_ThreadDataKey dataKey;
+
 static Tk_Window captureWinPtr = NULL;	/* Current capture window; may be
 					 * NULL. */
 
 static int		GenerateButtonEvent(MouseEventData *medPtr);
-static unsigned int	ButtonModifiers2State(UInt32 buttonState,
-			    UInt32 keyModifiers);
 
 #pragma mark TKApplication(TKMouseEvent)
 
 enum {
     NSWindowWillMoveEventType = 20
 };
 
 /*
  * In OS X 10.6 an NSEvent of type NSMouseMoved would always have a non-Nil
- * window attribute pointing to the active window.  As of 10.8 this behavior
- * had changed.  The new behavior was that if the mouse were ever moved outside
- * of a window, all subsequent NSMouseMoved NSEvents would have a Nil window
+ * window attribute pointing to the key window.  As of 10.8 this behavior had
+ * changed.  The new behavior was that if the mouse were ever moved outside of
+ * a window, all subsequent NSMouseMoved NSEvents would have a Nil window
  * attribute until the mouse returned to the window.  In 11.1 it changed again.
  * The window attribute can be non-nil, but referencing a window which does not
  * belong to the application.
  */
+
+/* The basic job of tkProcessMouseEvent is to generate a call to
+ * Tk_UpdatePointer.  That function receives a Tk_Window which (ignoring cases
+ * when a grab is in effect) should be the highest window within the focused
+ * toplevel that contains the pointer, as well as the pointer location in
+ * screen coordinates and the current button state.  Tk maintains a cache of
+ * these three values.  A change in any of these values causes Tk_UpdatePointer
+ * to generate, respectively, Enter/Leave events, or Motion events, or
+ * button Press/Release events. The Tk_Window value is allowed to be NULL,
+ * which indicates that the pointer is not in the focused toplevel.
+ *
+ * Enter or Leave events for toplevel windows are generated when the Tk_Window
+ * value changes to or from NULL.  This is problematic on macOS due to the fact
+ * that Tk_UpdatePointer does not generate Motion events when the Tk_Window
+ * value is NULL.  A consequence of this is that Tk_UpdatePointer will either
+ * fail to generate correct Enter/Leave events for toplevels or else be unable
+ * to generate Motion events when the pointer is outside of the focus window.
+ * It is important to be able to generate such events because otherwise a
+ * scrollbar on the edge of a toplevel becomes unusable.  Any time that the
+ * pointer wanders out of the window during a scroll, the scroll will stop.
+ * That is an extremely annoying and unexpected behavior.  Much of the code in
+ * this module, including the trickiest parts, is devoted to working around
+ * this problem.  The other tricky parts are related to transcribing Apple's
+ * NSMouseEntered, NSMouseExited, and NSLeftMouseDragged events into a form
+ * that makes sense to Tk.
+ */
+
 
 @implementation TKApplication(TKMouseEvent)
+
 - (NSEvent *) tkProcessMouseEvent: (NSEvent *) theEvent
 {
     NSWindow *eventWindow = [theEvent window];
     NSEventType eventType = [theEvent type];
-    NSRect viewFrame = [[eventWindow contentView] frame];
+    TKContentView *contentView = [eventWindow contentView];
     NSPoint location = [theEvent locationInWindow];
-    TkWindow *winPtr = NULL, *grabWinPtr;
+    NSPoint viewLocation = [contentView convertPoint:location fromView:nil];
+    TkWindow *winPtr = NULL, *grabWinPtr, *scrollTarget = NULL;
     Tk_Window tkwin = NULL, capture, target;
     NSPoint local, global;
     NSInteger button;
-    Bool inTitleBar = NO;
+    TkWindow *newFocus = NULL;
     int win_x, win_y;
     unsigned int buttonState = 0;
-    static int validPresses = 0, ignoredPresses = 0;
+    Bool isTestingEvent = NO;
+    Bool isMotionEvent = NO;
+    Bool isOutside = NO;
+    Bool firstDrag = NO;
+    static Bool ignoreDrags = NO;
+    static Bool ignoreUpDown = NO;
+    static NSTimeInterval timestamp = 0;
 
 #ifdef TK_MAC_DEBUG_EVENTS
     TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
 #endif
 
     /*
-     * If this event is not for a Tk toplevel, it should just be passed up the
-     * responder chain.  However, there is an exception for synthesized events,
-     * which are used in testing.  Those events are recognized by having their
-     * both the windowNumber and the eventNumber set to -1.
-     */
-
-    if (eventWindow && ![eventWindow isMemberOfClass:[TKWindow class]]) {
-	if ([theEvent windowNumber] != -1 || [theEvent eventNumber] != -1)
-	    return theEvent;
-    }
-
-    /*
-     * Check if the event is located in the titlebar.
-     */
-
-    if (eventWindow) {
-	inTitleBar = viewFrame.size.height < location.y;
-    }
-
+     * If this event is not for a Tk toplevel, it should normally just be
+     * passed up the responder chain.  However, there is are two exceptions.
+     * One is for synthesized events, which are used in testing.  Those events
+     * are recognized by having their timestamp set to 0.  The other is for
+     * motion events sent by the local event monitor, which will have their
+     * window attribute set to nil.
+     */
+
+    if (![eventWindow isMemberOfClass:[TKWindow class]]) {
+	if ([theEvent timestamp] == 0) {
+	    isTestingEvent = YES;
+	    eventWindow = [NSApp keyWindow];
+	}
+	if (eventType == NSLeftMouseDragged ||
+	    eventType == NSMouseMoved) {
+	    eventWindow = [NSApp keyWindow];
+	    isMotionEvent = YES;
+	}
+	if (!isTestingEvent && !isMotionEvent) {
+	    return theEvent;
+	}
+    } else if (!NSPointInRect(viewLocation, [contentView bounds])) {
+	isOutside = YES;
+    }
     button = [theEvent buttonNumber] + Button1;
     if ((button & -2) == Button2) {
 	button ^= 1; /* Swap buttons 2/3 */
     }
     switch (eventType) {
@@ -96,31 +141,168 @@
     case NSRightMouseUp:
     case NSOtherMouseUp:
 	buttonState &= ~Tk_GetButtonMask(button);
 	break;
     case NSLeftMouseDragged:
+	buttonState |= Tk_GetButtonMask(button);
+	if (![NSApp tkDragTarget]) {
+	    if (isOutside) {
+		ignoreDrags = YES;
+	    } else {
+		firstDrag = YES;
+	    }
+	}
+	if (ignoreDrags) {
+	    return theEvent;
+	}
+	if (![NSApp tkDragTarget]) {
+	    [NSApp setTkDragTarget: [NSApp tkEventTarget]];
+	}
+	break;
     case NSRightMouseDragged:
     case NSOtherMouseDragged:
+	isMotionEvent = YES;
     case NSRightMouseDown:
     case NSOtherMouseDown:
 	buttonState |= Tk_GetButtonMask(button);
 	break;
     case NSMouseEntered:
-	if ([eventWindow respondsToSelector:@selector(mouseInResizeArea)] &&
-	    !inTitleBar) {
-	    [(TKWindow *)eventWindow setMouseInResizeArea:YES];
+	if (![eventWindow isKeyWindow] || isOutside) {
+	    return theEvent;
 	}
+	[NSApp setTkLiveResizeEnded:NO];
+	[NSApp setTkPointerWindow:[NSApp tkEventTarget]];
 	break;
     case NSMouseExited:
-	if ([eventWindow respondsToSelector:@selector(mouseInResizeArea)]) {
-	    [(TKWindow *)eventWindow setMouseInResizeArea:NO];
-	    break;
+	if (![eventWindow isKeyWindow] || !isOutside) {
+	    return theEvent;
 	}
+	[NSApp setTkPointerWindow:nil];
+	break;
     case NSLeftMouseUp:
+	[NSApp setTkDragTarget: nil];
+	if ([theEvent clickCount] == 2) {
+	    ignoreUpDown = NO;
+	}
+	if (ignoreUpDown) {
+	    return theEvent;
+	}
+	if (ignoreDrags) {
+	    ignoreDrags = NO;
+	    return theEvent;
+	}
+	buttonState &= ~Tk_GetButtonMask(Button1);
+	break;
     case NSLeftMouseDown:
+
+	/*
+	 * There are situations where Apple does not send NSLeftMouseUp events
+	 * even though the mouse button has been released.  One of these is
+	 * whenever a menu is posted on the screen.  This causes Tk to have an
+	 * inaccurate idea of the current button state and to behave strangely.
+	 * (See ticket[a132b5507e].)  As a work-around we watch for NSButtonDown
+	 * events that arrive when Tk thinks the button is already down and
+	 * we attempt to correct Tk's cached button state by insering a call to
+	 * Tk_UpdatePointer showing the button as up.
+	 */
+
+	if ([NSApp tkButtonState] & Tk_GetButtonMask(Button1)) {
+	    int fakeState = [NSApp tkButtonState] & ~Tk_GetButtonMask(Button1);
+	    int x = location.x;
+	    int y = floor(TkMacOSXZeroScreenHeight() - location.y);
+	    Tk_UpdatePointer((Tk_Window) [NSApp tkEventTarget], x, y, fakeState);
+	}
+
+	/*
+	 * Ignore left mouse button events which are in an NSWindow but outside
+	 * of its contentView (see tickets [d72abe6b54] and [39cbacb9e8]).
+	 * Ignore the first left button press after a live resize ends. (Apple
+	 * sends the button press event that started the resize after the
+	 * resize ends.  It should not be seen by Tk.  See tickets [d72abe6b54]
+	 * and [39cbacb9e8]).  Ignore button press events when ignoreUpDown is
+	 * set.  These are extraneous events which appear when double-clicking
+	 * in a window without focus, causing duplicate Double-1 events (see
+	 * ticket [7bda9882cb]).  When a LeftMouseDown event with clickCount 2
+	 * is received we set the ignoreUpDown flag and we clear it when the
+	 * matching LeftMouseUp with click count 2 is received.
+	 */
+
+	/*
+	 * Make sure we don't ignore LeftMouseUp and LeftMouseDown forever.
+	 * Currently tkBind.c sets NEARBY_MS to 500 (the Windows default).
+	 */
+
+	if ([theEvent timestamp] - timestamp > 1) {
+	    ignoreUpDown = NO;
+	}
+	if ([theEvent clickCount] == 2) {
+	    if (ignoreUpDown == YES) {
+		return theEvent;
+	    } else {
+		timestamp = [theEvent timestamp];
+		ignoreUpDown = YES;
+	    }
+	}
+	if (!isTestingEvent) {
+	    NSRect bounds = [contentView bounds];
+	    NSRect grip = NSMakeRect(bounds.size.width - 10, 0, 10, 10);
+	    bounds = NSInsetRect(bounds, 2.0, 2.0);
+	    if (!NSPointInRect(viewLocation, bounds)) {
+		return theEvent;
+	    }
+	    if (NSPointInRect(viewLocation, grip)) {
+		return theEvent;
+	    }
+	    if ([NSApp tkLiveResizeEnded]) {
+		[NSApp setTkLiveResizeEnded:NO];
+		return theEvent;
+	    }
+	}
+
+	/*
+	 * If this click will change the focus, the Tk event should
+	 * be sent to the toplevel which will be receiving focus rather than to
+	 * the current focus window.  So reset tkEventTarget.
+	 */
+
+	if (eventWindow != [NSApp keyWindow]) {
+	    NSWindow *w;
+
+	    if (eventWindow && isOutside) {
+		return theEvent;
+	    }
+	    for (w in [NSApp orderedWindows]) {
+		if (NSPointInRect([NSEvent mouseLocation], [w frame])) {
+		    newFocus = TkMacOSXGetTkWindow(w);
+		    break;
+		}
+	    }
+	    if (newFocus) {
+		[NSApp setTkEventTarget: newFocus];
+		[NSApp setTkPointerWindow: newFocus];
+		target = (Tk_Window) newFocus;
+	    }
+	}
+	buttonState |= Tk_GetButtonMask(Button1);
+	break;
     case NSMouseMoved:
+	if (eventWindow && eventWindow != [NSApp keyWindow]) {
+	    return theEvent;
+	}
+	isMotionEvent = YES;
+	break;
     case NSScrollWheel:
+
+	/*
+	 * Scroll wheel events are sent to the window containing the pointer,
+	 * or ignored if no window contains the pointer.  See TIP #171.  Note,
+	 * however, that TIP #171 proposed sending scroll wheel events to the
+	 * focus window when no window contains the pointer.  That proposal was
+	 * ultimately rejected.
+	 */
+
+	scrollTarget = TkMacOSXGetTkWindow(eventWindow);
 #if 0
     case NSCursorUpdate:
     case NSTabletPoint:
     case NSTabletProximity:
 #endif
@@ -128,83 +310,48 @@
     default: /* This type of event is ignored. */
 	return theEvent;
     }
 
     /*
-     * Update the button state.  We ignore left button presses that start a
-     * resize or occur in the title bar.  See tickets [d72abe6b54] and
-     * [39cbacb9e8].
-     */
-
-    if (eventType == NSLeftMouseDown) {
-	if ([eventWindow respondsToSelector:@selector(mouseInResizeArea)] &&
-	    [(TKWindow *) eventWindow mouseInResizeArea]) {
-
-	    /*
-	     * When the left button is pressed in the resize area, we receive
-	     * NSMouseDown, but when it is released we do not receive
-	     * NSMouseUp.  So ignore the event and clear the button state but
-	     * do not change the ignoredPresses count.
-	     */
-
-	    buttonState &= ~Tk_GetButtonMask(Button1);
-	    return theEvent;
-	}
-	if (inTitleBar) {
-	    ignoredPresses++;
-	    return theEvent;
-	}
-	validPresses++;
-	buttonState |= Tk_GetButtonMask(Button1);
-    }
-    if (eventType == NSLeftMouseUp) {
-	if (ignoredPresses > 0) {
-	    ignoredPresses--;
-	} else if (validPresses > 0) {
-	    validPresses--;
-	}
-	if (validPresses == 0) {
-	    buttonState &= ~Tk_GetButtonMask(Button1);
-	}
-    }
-
-    /*
-     * Find an appropriate NSWindow to attach to this event, and its
-     * associated Tk window.
-     */
-
-    capture = TkpGetCapture();
-    if (capture) {
-	winPtr = (TkWindow *) capture;
-	eventWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window);
-	if (!eventWindow) {
-	    return theEvent;
-	}
-    } else {
-	if (eventWindow) {
-	    winPtr = TkMacOSXGetTkWindow(eventWindow);
-	}
-	if (!winPtr) {
-	    eventWindow = [NSApp mainWindow];
-	    winPtr = TkMacOSXGetTkWindow(eventWindow);
-	}
-    }
-    if (!winPtr) {
-
-	/*
-	 * We couldn't find a Tk window for this event.  We have to ignore it.
+     * Find the toplevel window for the event.
+     */
+
+    if ([NSApp tkDragTarget]) {
+	TkWindow *dragPtr = (TkWindow *) [NSApp tkDragTarget];
+	TKWindow *dragWindow = nil;
+	if (dragPtr) {
+	    dragWindow = (TKWindow *)TkMacOSXGetNSWindowForDrawable(
+			    dragPtr->window);
+	}
+	if (!dragWindow) {
+	    [NSApp setTkDragTarget: nil];
+	    target = NULL;
+	    return theEvent;
+	}
+	winPtr = TkMacOSXGetHostToplevel((TkWindow *) [NSApp tkDragTarget])->winPtr;
+    } else if (eventType == NSScrollWheel) {
+	winPtr = scrollTarget;
+    } else {
+	winPtr = [NSApp tkEventTarget];
+    }
+    if (!winPtr) {
+
+	/*
+	 * If we couldn't find a toplevel for this event we have to ignore it.
+	 * (But this should never happen.)
 	 */
 
 #ifdef TK_MAC_DEBUG_EVENTS
 	TkMacOSXDbgMsg("Event received with no Tk window.");
 #endif
+
 	return theEvent;
     }
     tkwin = (Tk_Window) winPtr;
 
     /*
-     * Compute the mouse position in local (window) and global (screen)
+     * Compute the mouse position in local (toplevel) and global (screen)
      * coordinates.  These are Tk coordinates, meaning that the local origin is
      * at the top left corner of the containing toplevel and the global origin
      * is at top left corner of the primary screen.
      */
 
@@ -211,67 +358,111 @@
     global = [NSEvent mouseLocation];
     local = [eventWindow tkConvertPointFromScreen: global];
     global.x = floor(global.x);
     global.y = floor(TkMacOSXZeroScreenHeight() - global.y);
     local.x = floor(local.x);
-    local.y = floor([eventWindow frame].size.height - local.y);
+    local.y = floor(eventWindow.frame.size.height - local.y);
     if (Tk_IsEmbedded(winPtr)) {
-	TkWindow *contPtr = TkpGetOtherWindow(winPtr);
+	TkWindow *contPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)winPtr);
 	if (Tk_IsTopLevel(contPtr)) {
 	    local.x -= contPtr->wmInfoPtr->xInParent;
 	    local.y -= contPtr->wmInfoPtr->yInParent;
 	} else {
 	    TkWindow *topPtr = TkMacOSXGetHostToplevel(winPtr)->winPtr;
 	    local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x);
 	    local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y);
 	}
+    }
+    else {
+    	if (winPtr && winPtr->wmInfoPtr) {
+    	    local.x -= winPtr->wmInfoPtr->xInParent;
+    	    local.y -= winPtr->wmInfoPtr->yInParent;
+    	} else {
+    	    return theEvent;
+    	}
+    }
+
+    /*
+     * Use the toplevel coordinates to decide which Tk window should receive
+     * this event.  Also convert the toplevel coordinates into the coordinate
+     * system of that window.  These converted coordinates are needed for
+     * XEvents that we generate, namely ScrollWheel events and Motion events
+     * when the mouse is outside of the focused toplevel.
+     */
+
+    if ([NSApp tkDragTarget]) {
+	Tk_Window dragTarget = (Tk_Window) [NSApp tkDragTarget];
+	Tk_Window dragWidget = NULL;
+	int x, y;
+	Tk_GetRootCoords(dragTarget, &x, &y);
+	win_x = global.x - x;
+	win_y = global.y - y;
+	if (firstDrag) {
+	    dragWidget = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &x, &y);
+	    if (dragWidget) {
+		[NSApp setTkDragTarget: (TkWindow *) dragWidget];
+	    }
+	}
+	target = (Tk_Window) [NSApp tkDragTarget];
     } else {
-	local.x -= winPtr->wmInfoPtr->xInParent;
-	local.y -= winPtr->wmInfoPtr->yInParent;
+	target = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y);
     }
 
-    /*
-     * Use the local coordinates to find the Tk window which should receive
-     * this event.  Also convert local into the coordinates of that window.
-     * (The converted local coordinates are only needed for scrollwheel
-     * events.)
-     */
-
-    target = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y);
+
+    grabWinPtr = winPtr->dispPtr->grabWinPtr;
 
     /*
      * Ignore the event if a local grab is in effect and the Tk window is
      * not in the grabber's subtree.
      */
 
-    grabWinPtr = winPtr->dispPtr->grabWinPtr;
     if (grabWinPtr && /* There is a grab in effect ... */
 	!winPtr->dispPtr->grabFlags && /* and it is a local grab ... */
 	grabWinPtr->mainPtr == winPtr->mainPtr){ /* in the same application. */
-	Tk_Window tkwin2;
+	Tk_Window w;
+	if (!target) {
+	    return theEvent;
+	}
+	for (w = target; !Tk_IsTopLevel(w); w = Tk_Parent(w)) {
+	    if (w == (Tk_Window)grabWinPtr) {
+		break;
+	    }
+	}
+	if (w != (Tk_Window)grabWinPtr) {
+	    return theEvent;
+	}
+    }
+
+    /*
+     * Ignore the event if a global grab is in effect and the Tk window is
+     * not in the grabber's subtree.
+     */
+
+    if (grabWinPtr && /* There is a grab in effect ... */
+	winPtr->dispPtr->grabFlags && /* and it is a global grab ... */
+	grabWinPtr->mainPtr == winPtr->mainPtr) { /* in the same application. */
+	Tk_Window w;
 	if (!target) {
 	    return theEvent;
 	}
-	for (tkwin2 = target;
-	     !Tk_IsTopLevel(tkwin2);
-	     tkwin2 = Tk_Parent(tkwin2)) {
-	    if (tkwin2 == (Tk_Window)grabWinPtr) {
+	for (w = target; !Tk_IsTopLevel(w); w = Tk_Parent(w)) {
+	    if (w == (Tk_Window)grabWinPtr) {
 		break;
 	    }
 	}
-	if (tkwin2 != (Tk_Window)grabWinPtr) {
-	    return theEvent;
+	if (w != (Tk_Window)grabWinPtr) {
+	    /* Force the focus back to the grab window. */
+	    TkpChangeFocus(grabWinPtr, 1);
 	}
     }
 
     /*
-     *  Generate an XEvent for this mouse event.
+     *  Translate the current button state into Tk's format.
      */
 
     unsigned int state = buttonState;
     NSUInteger modifiers = [theEvent modifierFlags];
-
     if (modifiers & NSAlphaShiftKeyMask) {
 	state |= LockMask;
     }
     if (modifiers & NSShiftKeyMask) {
 	state |= ShiftMask;
@@ -289,32 +480,74 @@
 	state |= Mod3Mask;
     }
     if (modifiers & NSFunctionKeyMask) {
 	state |= Mod4Mask;
     }
+    [NSApp setTkButtonState:state];
+
+    /*
+     * Send XEvents.  We do this here for Motion events outside of the focused
+     * toplevel and for MouseWheel events.  In other cases the XEvents will be
+     * sent when we call Tk_UpdatePointer.
+     */
 
     if (eventType != NSScrollWheel) {
-
-	/*
-	 * For normal mouse events, Tk_UpdatePointer will send the appropriate
-	 * XEvents using its cached state information.  Unfortunately, it will
-	 * also recompute the local coordinates.
-	 */
-
-#ifdef TK_MAC_DEBUG_EVENTS
-	TKLog(@"UpdatePointer %p x %.1f y %.1f %d",
-		target, global.x, global.y, state);
-#endif
-
-	Tk_UpdatePointer(target, global.x, global.y, state);
+	if ([NSApp tkDragTarget]) {
+
+	    /*
+	     * When dragging the mouse into the resize area Apple shows the
+	     * left button to be up, which confuses Tk_UpdatePointer.  So
+	     * we make sure that the button state appears the way that Tk
+	     * expects.
+	     */
+
+	    state |= Tk_GetButtonMask(Button1);
+	}
+	if (eventType == NSMouseEntered) {
+	    Tk_UpdatePointer((Tk_Window) [NSApp tkPointerWindow],
+				 global.x, global.y, state);
+	} else if (eventType == NSMouseExited) {
+	    if ([NSApp tkDragTarget]) {
+	    	Tk_UpdatePointer((Tk_Window) [NSApp tkDragTarget],
+	    			 global.x, global.y, state);
+	    } else {
+	    Tk_UpdatePointer(NULL, global.x, global.y, state);
+	    }
+	} else if (eventType == NSMouseMoved ||
+		   eventType == NSLeftMouseDragged) {
+	    if ([NSApp tkPointerWindow]) {
+		Tk_UpdatePointer(target, global.x, global.y, state);
+	    } else {
+		XEvent xEvent = {0};
+
+		xEvent.type = MotionNotify;
+		xEvent.xany.send_event = false;
+		xEvent.xany.display = Tk_Display(target);
+		xEvent.xany.window = Tk_WindowId(target);
+		xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
+		xEvent.xmotion.x = win_x;
+		xEvent.xmotion.y = win_y;
+		xEvent.xmotion.x_root = global.x;
+		xEvent.xmotion.y_root = global.y;
+		xEvent.xmotion.state = state;
+		Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
+
+		/*
+		 * Tk_UpdatePointer must not be called in this case.  Doing so
+		 * will break scrollbars; dragging will stop when the mouse
+		 * leaves the window.
+		 */
+
+	    }
+	} else {
+	    Tk_UpdatePointer(target, global.x, global.y, state);
+	}
     } else {
 	CGFloat delta;
-	XEvent xEvent;
-
-	/*
-	 * For scroll wheel events we need to send the XEvent here.
-	 */
+	XEvent xEvent = {0};
+	ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+		Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
 
 	xEvent.type = MouseWheelEvent;
 	xEvent.xbutton.x = win_x;
 	xEvent.xbutton.y = win_y;
 	xEvent.xbutton.x_root = global.x;
@@ -321,23 +554,67 @@
 	xEvent.xbutton.y_root = global.y;
 	xEvent.xany.send_event = false;
 	xEvent.xany.display = Tk_Display(target);
 	xEvent.xany.window = Tk_WindowId(target);
 
-	delta = [theEvent deltaY] * 120;
-	if (delta != 0.0) {
-	    xEvent.xbutton.state = state;
-	    xEvent.xkey.keycode = (delta > 0) ? ceil(delta) : floor(delta);
-	    xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
-	    Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
-	}
-	delta = [theEvent deltaX] * 120;
-	if (delta != 0.0) {
-	    xEvent.xbutton.state = state | ShiftMask;
-	    xEvent.xkey.keycode = (delta > 0) ? ceil(delta) : floor(delta);
-	    xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
-	    Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
+#define WHEEL_DELTA 120
+#define WHEEL_DELAY 300000000
+	uint64_t wheelTick = clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW);
+	Bool timeout = (wheelTick - tsdPtr->wheelTickPrev) >= WHEEL_DELAY;
+	if (timeout) {
+	    tsdPtr->vWheelAcc = tsdPtr->hWheelAcc = 0;
+	}
+	tsdPtr->wheelTickPrev = wheelTick;
+	delta = [theEvent deltaY];
+	if (delta != 0.0) {
+	    delta = (tsdPtr->vWheelAcc += delta);
+	    if (timeout && fabs(delta) < 1.0) {
+		delta = ((delta < 0.0) ? -1.0 : 1.0);
+	    }
+	    if (fabs(delta) >= 0.6) {
+		int intDelta = round(delta);
+		xEvent.xbutton.state = state;
+		xEvent.xkey.keycode = WHEEL_DELTA * intDelta;
+		tsdPtr->vWheelAcc -= intDelta;
+		xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
+		Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
+	    }
+	}
+	delta = [theEvent deltaX];
+	if (delta != 0.0) {
+	    delta = (tsdPtr->hWheelAcc += delta);
+	    if (timeout && fabs(delta) < 1.0) {
+		delta = ((delta < 0.0) ? -1.0 : 1.0);
+	    }
+	    if (fabs(delta) >= 0.6) {
+	    int intDelta = round(delta);
+		xEvent.xbutton.state = state | ShiftMask;
+		xEvent.xkey.keycode = WHEEL_DELTA * intDelta;
+		tsdPtr->hWheelAcc -= intDelta;
+		xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
+		Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
+	    }
+	}
+    }
+
+    /*
+     * If button events are being captured, and the target is not in the
+     * subtree below the capturing window, then the NSEvent should not be sent
+     * up the responder chain.  This avoids, for example, beeps when clicking
+     * the mouse button outside of a posted combobox.  See ticket [eb26d4ec8e].
+     */
+
+    capture = TkpGetCapture();
+    if (capture && eventType == NSLeftMouseDown) {
+	Tk_Window w;
+	for (w = target; w != NULL;  w = Tk_Parent(w)) {
+	    if (w == capture) {
+		break;
+	    }
+	}
+	if (w != capture) {
+	    return nil;
 	}
     }
     return theEvent;
 }
 @end
@@ -362,83 +639,11 @@
  */
 
 unsigned int
 TkMacOSXButtonKeyState(void)
 {
-    UInt32 buttonState = 0, keyModifiers;
-    int isFrontProcess = (GetCurrentEvent() && Tk_MacOSXIsAppInFront());
-
-    buttonState = isFrontProcess ? GetCurrentEventButtonState() :
-	    GetCurrentButtonState();
-    keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() :
-	    GetCurrentKeyModifiers();
-
-    return ButtonModifiers2State(buttonState, keyModifiers);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ButtonModifiers2State --
- *
- *	Converts Carbon mouse button state and modifier values into a Tk
- *	button/modifier state.
- *
- * Results:
- *	None.
- *
- * Side effects:
- *	None.
- *
- *----------------------------------------------------------------------
- */
-
-static unsigned int
-ButtonModifiers2State(
-    UInt32 buttonState,
-    UInt32 keyModifiers)
-{
-    unsigned int state;
-
-    /*
-     * Tk on OSX supports at most 9 buttons.
-     */
-
-    state = (buttonState & 0x079) * Button1Mask;
-	/* Handle swapped buttons 2/3 */
-	if (buttonState & 0x02) {
-	    state |= Button3Mask;
-	}
-	if (buttonState & 0x04) {
-	    state |= Button2Mask;
-	}
-	/* Handle buttons 8/9 */
-    state |= (buttonState & 0x180) * (Button8Mask >> 7);
-
-    if (keyModifiers & alphaLock) {
-	state |= LockMask;
-    }
-    if (keyModifiers & shiftKey) {
-	state |= ShiftMask;
-    }
-    if (keyModifiers & controlKey) {
-	state |= ControlMask;
-    }
-    if (keyModifiers & cmdKey) {
-	state |= Mod1Mask;		/* command key */
-    }
-    if (keyModifiers & optionKey) {
-	state |= Mod2Mask;		/* option key */
-    }
-    if (keyModifiers & kEventKeyModifierNumLockMask) {
-	state |= Mod3Mask;
-    }
-    if (keyModifiers & kEventKeyModifierFnMask) {
-	state |= Mod4Mask;
-    }
-
-    return state;
+    return [NSApp tkButtonState];
 }
 
 /*
  *----------------------------------------------------------------------
  *
@@ -458,25 +663,22 @@
  *----------------------------------------------------------------------
  */
 
 Bool
 XQueryPointer(
-    Display *display,
+    TCL_UNUSED(Display *),
     Window w,
-    Window *root_return,
-    Window *child_return,
+    TCL_UNUSED(Window *),
+    TCL_UNUSED(Window *),
     int *root_x_return,
     int *root_y_return,
     int *win_x_return,
     int *win_y_return,
     unsigned int *mask_return)
 {
     int getGlobal = (root_x_return && root_y_return);
     int getLocal = (win_x_return && win_y_return && w != None);
-    (void)display;
-    (void)root_return;
-    (void)child_return;
 
     if (getGlobal || getLocal) {
 	NSPoint global = [NSEvent mouseLocation];
 
 	if (getLocal) {
@@ -645,11 +847,10 @@
 
     if (tkwin != NULL) {
 	tkwin = Tk_TopCoordsToWindow(tkwin, medPtr->local.h, medPtr->local.v,
 		&dummy, &dummy);
     }
-
     Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v, medPtr->state);
     return true;
 }
 
 /*
@@ -684,10 +885,16 @@
 	pt.x = dispPtr->warpX;
 	pt.y = dispPtr->warpY;
     }
 
     CGWarpMouseCursorPosition(pt);
+
+    if (dispPtr->warpWindow) {
+        TkGenerateButtonEventForXPointer(Tk_WindowId(dispPtr->warpWindow));
+    } else {
+        TkGenerateButtonEventForXPointer(None);
+    }
 }
 
 /*
  *----------------------------------------------------------------------
  *

Index: macosx/tkMacOSXNotify.c
==================================================================
--- macosx/tkMacOSXNotify.c
+++ macosx/tkMacOSXNotify.c
@@ -2,32 +2,59 @@
  * tkMacOSXNotify.c --
  *
  *	This file contains the implementation of a tcl event source
  *	for the AppKit event loop.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright 2015 Marc Culler.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009, Apple Inc.
+ * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2015 Marc Culler.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
-#include <tclInt.h>
 #include "tkMacOSXPrivate.h"
 #include "tkMacOSXInt.h"
 #include "tkMacOSXConstants.h"
+#if TCL_MAJOR_VERSION < 9
+#undef Tcl_MacOSXNotifierAddRunLoopMode
+#ifdef USE_TCL_STUBS
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*  Little hack to eliminate the need for "tclInt.h" here:
+    Just copy a small portion of TclIntPlatStubs, just
+    enough to make it work. See [600b72bfbc] */
+typedef struct TclIntPlatStubs {
+    int magic;
+    void *hooks;
+    void (*dummy[19]) (void); /* dummy entries 0-18, not used */
+    void (*tclMacOSXNotifierAddRunLoopMode) (const void *runLoopMode); /* 19 */
+} TclIntPlatStubs;
+extern const TclIntPlatStubs *tclIntPlatStubsPtr;
+#ifdef __cplusplus
+}
+#endif
+#define Tcl_MacOSXNotifierAddRunLoopMode \
+	(tclIntPlatStubsPtr->tclMacOSXNotifierAddRunLoopMode) /* 19 */
+#elif TCL_MINOR_VERSION < 7
+    extern void TclMacOSXNotifierAddRunLoopMode(const void *runLoopMode);
+#   define Tcl_MacOSXNotifierAddRunLoopMode TclMacOSXNotifierAddRunLoopMode
+#else
+    extern void Tcl_MacOSXNotifierAddRunLoopMode(const void *runLoopMode);
+#endif
+#endif
 #import <objc/objc-auto.h>
 
 /* This is not used for anything at the moment. */
 typedef struct ThreadSpecificData {
     int initialized;
 } ThreadSpecificData;
 static Tcl_ThreadDataKey dataKey;
 
-#define TSD_INIT() ThreadSpecificData *tsdPtr = \
+#define TSD_INIT() ThreadSpecificData *tsdPtr = (ThreadSpecificData *) \
 	Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData))
 
 static void TkMacOSXNotifyExitHandler(ClientData clientData);
 static void TkMacOSXEventsSetupProc(ClientData clientData, int flags);
 static void TkMacOSXEventsCheckProc(ClientData clientData, int flags);
@@ -267,12 +294,12 @@
 		    "first [load] of TkAqua has to occur in the main thread!");
 	    }
 	    Tcl_CreateEventSource(TkMacOSXEventsSetupProc,
 		    TkMacOSXEventsCheckProc, NULL);
 	    TkCreateExitHandler(TkMacOSXNotifyExitHandler, NULL);
-	    TclMacOSXNotifierAddRunLoopMode(NSEventTrackingRunLoopMode);
-	    TclMacOSXNotifierAddRunLoopMode(NSModalPanelRunLoopMode);
+	    Tcl_MacOSXNotifierAddRunLoopMode(NSEventTrackingRunLoopMode);
+	    Tcl_MacOSXNotifierAddRunLoopMode(NSModalPanelRunLoopMode);
 	}
     }
 }
 
 /*
@@ -314,12 +341,13 @@
  *       This relies on a feature of [NSApp nextEventMatchingMask: ...] which
  *       is undocumented, namely that it sometimes blocks and calls drawRect
  *       for all views that need display before it returns.  We call it with
  *       deQueue=NO so that it will not change anything on the AppKit event
  *       queue, because we only want the side effect that it runs drawRect. The
- *       only time when any NSViews have the needsDisplay property set to YES
- *       is during execution of this function.
+ *       only times when any NSViews have the needsDisplay property set to YES
+ *       are during execution of this function or in the addTkDirtyRect method
+ *       of TKContentView.
  *
  *       The reason for running this function as an idle task is to try to
  *       arrange that all widgets will be fully configured before they are
  *       drawn.  Any idle tasks that might reconfigure them should be higher on
  *       the idle queue, so they should be run before the display procs are run
@@ -332,11 +360,11 @@
  *
  * Results:
  *	None.
  *
  * Side effects:
- *	Parts of windows my get redrawn.
+ *	Parts of windows may get redrawn.
  *
  *----------------------------------------------------------------------
  */
 
 void
@@ -351,11 +379,12 @@
 	    if ([view tkNeedsDisplay]) {
 		count++;
 		if (dirtyCount) {
 		   continue;
 		}
-		[view setNeedsDisplayInRect:[view tkDirtyRect]];
+		[[view layer] setNeedsDisplayInRect:[view tkDirtyRect]];
+		[view setNeedsDisplay:YES];
 	    }
 	} else {
 	    [window displayIfNeeded];
 	}
     }
@@ -410,11 +439,11 @@
 #define TICK 200
 static Tcl_TimerToken ticker = NULL;
 
 static void
 Heartbeat(
-    TCL_UNUSED(ClientData))
+    TCL_UNUSED(void *))
 {
 
     if (ticker) {
 	ticker = Tcl_CreateTimerHandler(TICK, Heartbeat, NULL);
     }
@@ -443,11 +472,11 @@
  	 * Tcl_WaitForEvent.  Then it will call check proc to collect the
  	 * events and translate them into XEvents.
 	 *
  	 * If we have any events waiting or if there is any drawing to be done
 	 * we want Tcl_WaitForEvent to return immediately.  So we set the block
-	 * time to 0 and stop the heatbeat.
+	 * time to 0 and stop the heartbeat.
   	 */
 
 	NSEvent *currentEvent =
 	        [NSApp nextEventMatchingMask:NSAnyEventMask
 			untilDate:[NSDate distantPast]
@@ -489,11 +518,11 @@
  *
  *----------------------------------------------------------------------
  */
 static void
 TkMacOSXEventsCheckProc(
-    TCL_UNUSED(ClientData),
+    TCL_UNUSED(void *),
     int flags)
 {
     NSString *runloopMode = [[NSRunLoop currentRunLoop] currentMode];
     int eventsFound = 0;
 

Index: macosx/tkMacOSXPort.h
==================================================================
--- macosx/tkMacOSXPort.h
+++ macosx/tkMacOSXPort.h
@@ -33,21 +33,15 @@
 #endif
 #include <sys/stat.h>
 #ifndef _TCL
 #   include <tcl.h>
 #endif
-#if TIME_WITH_SYS_TIME
-#   include <sys/time.h>
-#   include <time.h>
-#else
-#   if HAVE_SYS_TIME_H
+#ifdef HAVE_SYS_TIME_H
 #	include <sys/time.h>
-#   else
-#	include <time.h>
-#   endif
 #endif
-#if HAVE_INTTYPES_H
+#include <time.h>
+#ifdef HAVE_INTTYPES_H
 #    include <inttypes.h>
 #endif
 #include <unistd.h>
 #if defined(__GNUC__) && !defined(__cplusplus)
 #   pragma GCC diagnostic ignored "-Wc++-compat"
@@ -75,10 +69,23 @@
 #   else
 #	define SELECT_MASK int
 #   endif
 #endif
 
+/*
+ * Used to tag functions that are only to be visible within the module being
+ * built and not outside it (where this is supported by the linker).
+ */
+
+#ifndef MODULE_SCOPE
+#   ifdef __cplusplus
+#	define MODULE_SCOPE extern "C"
+#   else
+#	define MODULE_SCOPE extern
+#   endif
+#endif
+
 /*
  * The following macro defines the number of fd_masks in an fd_set:
  */
 
 #ifndef FD_SETSIZE
@@ -133,36 +140,39 @@
 #define TK_NO_DOUBLE_BUFFERING 1
 #define TK_HAS_DYNAMIC_COLORS 1
 #define TK_DYNAMIC_COLORMAP 0x0fffffff
 
 /*
- * Inform tkImgPhInstance.c that our tkPutImage can render an image with an
- * alpha channel directly into a window.
+ * Inform tkImgPhInstance.c that we implement TkpPutRGBAImage to render RGBA
+ * images directly into a window.
+ */
+
+#define TK_CAN_RENDER_RGBA
+
+MODULE_SCOPE int TkpPutRGBAImage(
+		     Display* display, Drawable drawable, GC gc,XImage* image,
+		     int src_x, int src_y, int dest_x, int dest_y,
+		     unsigned int width, unsigned int height);
+
+/*
+ * Inform tkCanvas.c that our XGetImage returns a 32pp pixmap packed as 0xAABBGGRR
  */
 
-#define TKPUTIMAGE_CAN_BLEND
+#define TK_XGETIMAGE_USES_ABGR32
 
 /*
  * Used by xcolor.c
  */
 
 MODULE_SCOPE unsigned long TkMacOSXRGBPixel(unsigned long red, unsigned long green,
 					    unsigned long blue);
 #define TkpGetPixel(p) (TkMacOSXRGBPixel(p->red >> 8, p->green >> 8, p->blue >> 8))
 
-/*
- * Used by tkWindow.c
- */
-
-MODULE_SCOPE void TkMacOSXHandleMapOrUnmap(Tk_Window tkwin, XEvent *event);
-
-#define TkpHandleMapOrUnmap(tkwin, event)  TkMacOSXHandleMapOrUnmap(tkwin, event)
-
 /*
  * Used by tkAppInit
  */
 
 #define USE_CUSTOM_EXIT_PROC
 EXTERN int TkpWantsExitProc(void);
 EXTERN TCL_NORETURN void TkpExitProc(void *);
 
 #endif /* _TKMACPORT */

ADDED   macosx/tkMacOSXPrint.c
Index: macosx/tkMacOSXPrint.c
==================================================================
--- /dev/null
+++ macosx/tkMacOSXPrint.c
@@ -0,0 +1,356 @@
+/*
+ * tkMacOSXPrint.c --
+ *
+ *      This module implements native printing dialogs for macOS.
+ *
+ * Copyright © 2006 Apple Inc.
+ * Copyright © 2011-2021 Kevin Walzer/WordTech Communications LLC.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+#include <tcl.h>
+#include <tk.h>
+#include <tkInt.h>
+#include <Cocoa/Cocoa.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include <CoreServices/CoreServices.h>
+#include <ApplicationServices/ApplicationServices.h>
+#include <tkMacOSXInt.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+/* Forward declarations of functions and variables. */
+NSString * fileName = nil;
+CFStringRef urlFile = NULL;
+int			StartPrint(ClientData clientData, Tcl_Interp * interp,
+			    int objc, Tcl_Obj * const objv[]);
+OSStatus		FinishPrint(NSString *file, int buttonValue);
+int			MacPrint_Init(Tcl_Interp * interp);
+
+/* Delegate class for print dialogs. */
+@interface PrintDelegate: NSObject
+    - (id) init;
+    - (void) printPanelDidEnd: (NSPrintPanel *) printPanel
+		   returnCode: (int) returnCode
+		  contextInfo: (void *) contextInfo;
+@end
+
+@implementation PrintDelegate
+- (id) init {
+    self = [super init];
+    return self;
+}
+
+- (void) printPanelDidEnd: (NSPrintPanel *) printPanel
+	       returnCode: (int) returnCode
+	      contextInfo: (void *) contextInfo {
+    (void) printPanel;
+    (void) contextInfo;
+
+    /*
+     * Pass returnCode to FinishPrint function to determine how to
+     * handle.
+     */
+
+    FinishPrint(fileName, returnCode);
+}
+@end
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StartPrint --
+ *
+ * 	Launch native print dialog.
+ *
+ * Results:
+ *	Configures values and starts print process.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+StartPrint(
+    ClientData clientData,
+    Tcl_Interp * interp,
+    int objc,
+    Tcl_Obj *const objv[])
+{
+    (void) clientData;
+    NSPrintInfo * printInfo = [NSPrintInfo sharedPrintInfo];
+    NSPrintPanel * printPanel = [NSPrintPanel printPanel];
+    int accepted;
+    PMPrintSession printSession;
+    PMPrintSettings printSettings;
+    OSStatus status = noErr;
+
+    /* Check for proper number of arguments. */
+    if (objc < 2) {
+        Tcl_WrongNumArgs(interp, 1, objv, "file");
+        return TCL_ERROR;
+    }
+
+    fileName = [NSString stringWithUTF8String: Tcl_GetString(objv[1])];
+    urlFile = (CFStringRef) fileName;
+    CFRetain(urlFile);
+
+    /* Initialize the delegate for the callback from the page panel. */
+    PrintDelegate * printDelegate = [[PrintDelegate alloc] init];
+
+    status = PMCreateSession( & printSession);
+    if (status != noErr) {
+        NSLog(@ "Error creating print session.");
+        return TCL_ERROR;
+    }
+
+    status = PMCreatePrintSettings( & printSettings);
+    if (status != noErr) {
+        NSLog(@ "Error creating print settings.");
+        return TCL_ERROR;
+    }
+
+    status = PMSessionDefaultPrintSettings(printSession, printSettings);
+    if (status != noErr) {
+        NSLog(@ "Error creating default print settings.");
+        return TCL_ERROR;
+    }
+
+    printSession = (PMPrintSession)[printInfo PMPrintSession];
+    (void)(PMPageFormat)[printInfo PMPageFormat];
+    printSettings = (PMPrintSettings)[printInfo PMPrintSettings];
+
+    accepted = [printPanel runModalWithPrintInfo: printInfo];
+    [printDelegate printPanelDidEnd: printPanel
+			 returnCode: accepted
+			contextInfo: printInfo];
+
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FinishPrint --
+ *
+ * 	Handles print process based on input from dialog.
+ *
+ * Results:
+ *	Completes print process.
+ *
+ *----------------------------------------------------------------------
+ */
+
+OSStatus
+FinishPrint(
+    NSString *file,
+    int buttonValue)
+{
+    NSPrintInfo * printInfo = [NSPrintInfo sharedPrintInfo];
+    PMPrintSession printSession;
+    PMPageFormat pageFormat;
+    PMPrintSettings printSettings;
+    OSStatus status = noErr;
+    CFStringRef mimeType = NULL;
+
+    /*
+     * If value passed here is NSCancelButton, return noErr;
+     * otherwise printing will occur regardless of value.
+     */
+    if (buttonValue == NSModalResponseCancel) {
+        return noErr;
+    }
+
+    status = PMCreateSession( & printSession);
+    if (status != noErr) {
+        NSLog(@ "Error creating print session.");
+        return status;
+    }
+
+    status = PMCreatePrintSettings( & printSettings);
+    if (status != noErr) {
+        NSLog(@ "Error creating print settings.");
+        return status;
+    }
+
+    status = PMSessionDefaultPrintSettings(printSession, printSettings);
+    if (status != noErr) {
+        NSLog(@ "Error creating default print settings.");
+        return status;
+    }
+
+    printSession = (PMPrintSession)[printInfo PMPrintSession];
+    pageFormat = (PMPageFormat)[printInfo PMPageFormat];
+    printSettings = (PMPrintSettings)[printInfo PMPrintSettings];
+
+    /*Handle print operation.*/
+    if (buttonValue == NSModalResponseOK) {
+
+        if (urlFile == NULL) {
+            NSLog(@ "Could not get file to print.");
+            return noErr;
+        }
+
+        fileName = file;
+
+        CFURLRef printURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, urlFile, kCFURLPOSIXPathStyle, false);
+
+        PMPrinter currentPrinter;
+        PMDestinationType printDestination;
+
+        /*Get the intended destination.*/
+        status = PMSessionGetDestinationType(printSession, printSettings, & printDestination);
+
+        /*Destination is printer. Send file to printer.*/
+        if (status == noErr && printDestination == kPMDestinationPrinter) {
+
+            status = PMSessionGetCurrentPrinter(printSession, & currentPrinter);
+            if (status == noErr) {
+                CFArrayRef mimeTypes;
+                status = PMPrinterGetMimeTypes(currentPrinter, printSettings, & mimeTypes);
+                if (status == noErr && mimeTypes != NULL) {
+                    mimeType = CFSTR("application/pdf");
+                    if (CFArrayContainsValue(mimeTypes, CFRangeMake(0, CFArrayGetCount(mimeTypes)), mimeType)) {
+                        status = PMPrinterPrintWithFile(currentPrinter, printSettings, pageFormat, mimeType, printURL);
+                        CFRelease(urlFile);
+                        return status;
+                    }
+                }
+            }
+        }
+
+        /* Destination is file. Determine how to handle. */
+        if (status == noErr && printDestination == kPMDestinationFile) {
+            CFURLRef outputLocation = NULL;
+
+            status = PMSessionCopyDestinationLocation(printSession, printSettings, & outputLocation);
+            if (status == noErr) {
+                /*Get the source file and target destination, convert to strings.*/
+                CFStringRef sourceFile = CFURLCopyFileSystemPath(printURL, kCFURLPOSIXPathStyle);
+                CFStringRef savePath = CFURLCopyFileSystemPath(outputLocation, kCFURLPOSIXPathStyle);
+                NSString * sourcePath = (NSString * ) sourceFile;
+                NSString * finalPath = (NSString * ) savePath;
+                NSString * pathExtension = [finalPath pathExtension];
+                NSFileManager * fileManager = [NSFileManager defaultManager];
+		NSError * error = nil;
+
+                /*
+		 * Is the target file a PDF? If so, copy print file
+		 * to output location.
+		 */
+                if ([pathExtension isEqualToString: @ "pdf"]) {
+
+		    /*Make sure no file conflict exists.*/
+		    if ([fileManager fileExistsAtPath: finalPath]) {
+			[fileManager removeItemAtPath: finalPath error: &error];
+		    }
+                    if ([fileManager fileExistsAtPath: sourcePath]) {
+                        error = nil;
+                        [fileManager copyItemAtPath: sourcePath toPath: finalPath error: & error];
+                    }
+		    return status;
+                }
+
+                /*
+                 * Is the target file PostScript? If so, run print file
+                 * through CUPS filter to convert back to PostScript.
+                 */
+
+              if ([pathExtension isEqualToString: @ "ps"]) {
+                    char source[5012];
+                    char target[5012];
+                    [sourcePath getCString: source maxLength: (sizeof source) encoding: NSUTF8StringEncoding];
+                    [finalPath getCString: target maxLength: (sizeof target) encoding: NSUTF8StringEncoding];
+		    /*Make sure no file conflict exists.*/
+		    if ([fileManager fileExistsAtPath: finalPath]) {
+			[fileManager removeItemAtPath: finalPath error: &error];
+		    }
+
+		    /*
+		     *  Fork and start new process with command string. Thanks to Peter da Silva
+		     *  for assistance.
+		     */
+  		    pid_t pid;
+		    if ((pid = fork()) == -1) {
+		      return -1;
+		    } else if (pid == 0) {
+		      /* Redirect output to file and silence debugging output.*/
+		      dup2(open(target, O_RDWR | O_CREAT, 0777), 1);
+		      dup2(open("/dev/null", O_WRONLY), 2);
+		      execl("/usr/sbin/cupsfilter", "/usr/sbin/cupsfilter", "-m", "application/postscript", source, NULL);
+		      exit(0);
+		    }
+	      return status;
+	      }
+	    }
+	}
+
+        /* Destination is preview. Open file in default application for PDF. */
+        if ((status == noErr) && (printDestination == kPMDestinationPreview)) {
+            CFStringRef urlpath = CFURLCopyFileSystemPath(printURL, kCFURLPOSIXPathStyle);
+            NSString * path = (NSString * ) urlpath;
+            NSURL * url = [NSURL fileURLWithPath: path];
+            NSWorkspace * ws = [NSWorkspace sharedWorkspace];
+            [ws openURL: url];
+            status = noErr;
+            return status;
+        }
+
+        /*
+         * If destination is not printer, file or preview,
+         * we do not support it. Display alert.
+         */
+
+	if (((status == noErr) && (printDestination != kPMDestinationPreview)) || ((status == noErr) && (printDestination != kPMDestinationFile)) || ((status == noErr) &&  (printDestination != kPMDestinationPrinter))) {
+
+            NSAlert * alert = [[[NSAlert alloc] init] autorelease];
+            [alert addButtonWithTitle: @ "OK"];
+
+            [alert setMessageText: @ "Unsupported Printing Operation"];
+            [alert setInformativeText: @ "This printing operation is not supported."];
+            [alert setAlertStyle: NSAlertStyleInformational];
+            [alert runModal];
+            return status;
+        }
+    }
+
+    /* Return because cancel button was clicked. */
+    if (buttonValue == NSModalResponseCancel) {
+        PMRelease(printSession);
+        return status;
+    }
+
+    return status;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * MacPrint_Init--
+ *
+ * 	Initializes the printing module.
+ *
+ * Results:
+ *	Printing module initialized.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int MacPrint_Init(Tcl_Interp * interp) {
+    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+    Tcl_CreateObjCommand(interp, "::tk::print::_print", StartPrint, NULL, NULL);
+    [pool release];
+    return TCL_OK;
+}
+
+/*
+ * Local Variables:
+ * mode: objc
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */

Index: macosx/tkMacOSXPrivate.h
==================================================================
--- macosx/tkMacOSXPrivate.h
+++ macosx/tkMacOSXPrivate.h
@@ -1,13 +1,13 @@
 /*
  * tkMacOSXPrivate.h --
  *
  *	Macros and declarations that are purely internal & private to TkAqua.
  *
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2008-2009 Apple Inc.
- * Copyright (c) 2020 Marc Culler
+ * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2008-2009 Apple Inc.
+ * Copyright © 2020 Marc Culler
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
  * RCS: @(#) $Id$
@@ -23,12 +23,18 @@
 #ifndef __clang__
 #define instancetype id
 #endif
 
 #define TextStyle MacTextStyle
+#define Cursor QDCursor
 #import <ApplicationServices/ApplicationServices.h>
+#undef Cursor
 #import <Cocoa/Cocoa.h>
+#import <QuartzCore/QuartzCore.h>
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
+#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
+#endif
 #ifndef NO_CARBON_H
 #import <Carbon/Carbon.h>
 #endif
 #undef TextStyle
 #import <objc/runtime.h> /* for sel_isEqual() */
@@ -134,11 +140,11 @@
  */
 
 typedef struct keycode_v_t {
     unsigned keychar: 22;    /* UCS-32 character */
     unsigned o_s: 2;         /* State of Option and Shift keys. */
-    unsigned virtual: 8;     /* 8-bit virtual keycode - identifies a key. */
+    unsigned virt: 8;     /* 8-bit virtual keycode - identifies a key. */
 } keycode_v;
 
 typedef struct keycode_x_t {
     unsigned keychar: 22;     /* UCS-32 character */
     unsigned xvirtual: 10;    /* Combines o_s and virtual. This 10-bit integer
@@ -156,11 +162,11 @@
 /*
  * Macros used in tkMacOSXKeyboard.c and tkMacOSXKeyEvent.c.
  * Note that 0x7f is del and 0xF8FF is the Apple Logo character.
  */
 
-#define ON_KEYPAD(virtual) ((virtual >= 0x41) && (virtual <= 0x5C))
+#define ON_KEYPAD(virt) ((virt >= 0x41) && (virt <= 0x5C))
 #define IS_PRINTABLE(keychar) ((keychar >= 0x20) && (keychar != 0x7f) && \
                                ((keychar < 0xF700) || keychar >= 0xF8FF))
 
 /*
  * An "index" is 2-bit bitfield showing the state of the Option and Shift
@@ -202,19 +208,12 @@
 
 typedef struct TkMacOSXDrawingContext {
     CGContextRef context;
     NSView *view;
     HIShapeRef clipRgn;
-    CGRect portBounds;
 } TkMacOSXDrawingContext;
 
-/*
- * Variables internal to TkAqua.
- */
-
-MODULE_SCOPE long tkMacOSXMacOSXVersion;
-
 /*
  * Prototypes for TkMacOSXRegion.c.
  */
 
 MODULE_SCOPE HIShapeRef	TkMacOSXGetNativeRegion(Region r);
@@ -230,11 +229,12 @@
 			    HIMutableShapeRef inShape, const CGRect *inRect);
 MODULE_SCOPE OSStatus	TkMacOSHIShapeUnionWithRect(HIMutableShapeRef inShape,
 			    const CGRect *inRect);
 MODULE_SCOPE OSStatus	TkMacOSHIShapeUnion(HIShapeRef inShape1,
 			    HIShapeRef inShape2, HIMutableShapeRef outResult);
-
+MODULE_SCOPE int	TkMacOSXCountRectsInRegion(HIShapeRef shape);
+MODULE_SCOPE void       TkMacOSXPrintRectsInRegion(HIShapeRef shape);
 /*
  * Prototypes of TkAqua internal procs.
  */
 
 MODULE_SCOPE void *	TkMacOSXGetNamedSymbol(const char *module,
@@ -256,11 +256,11 @@
 			    TkMacOSXDrawingContext *dcPtr);
 MODULE_SCOPE void	TkMacOSXRestoreDrawingContext(
 			    TkMacOSXDrawingContext *dcPtr);
 MODULE_SCOPE void	TkMacOSXSetColorInContext(GC gc, unsigned long pixel,
 			    CGContextRef context);
-#define TkMacOSXGetTkWindow(window) (TkWindow *)Tk_MacOSXGetTkWindow(window)
+#define TkMacOSXGetTkWindow(window) ((TkWindow *)Tk_MacOSXGetTkWindow(window))
 #define TkMacOSXGetNSWindowForDrawable(drawable) ((NSWindow *)Tk_MacOSXGetNSWindowForDrawable(drawable))
 #define TkMacOSXGetNSViewForDrawable(macWin) ((NSView *)Tk_MacOSXGetNSViewForDrawable((Drawable)(macWin)))
 #define TkMacOSXGetCGContextForDrawable(drawable) ((CGContextRef)Tk_MacOSXGetCGContextForDrawable(drawable))
 MODULE_SCOPE void	TkMacOSXWinCGBounds(TkWindow *winPtr, CGRect *bounds);
 MODULE_SCOPE HIShapeRef	TkMacOSXGetClipRgn(Drawable drawable);
@@ -268,35 +268,37 @@
 			    HIShapeRef rgn);
 MODULE_SCOPE NSImage*	TkMacOSXGetNSImageFromTkImage(Display *display,
 			    Tk_Image image, int width, int height);
 MODULE_SCOPE NSImage*	TkMacOSXGetNSImageFromBitmap(Display *display,
 			    Pixmap bitmap, GC gc, int width, int height);
-MODULE_SCOPE CGColorRef	TkMacOSXCreateCGColor(GC gc, unsigned long pixel);
 MODULE_SCOPE NSColor*	TkMacOSXGetNSColor(GC gc, unsigned long pixel);
 MODULE_SCOPE NSFont*	TkMacOSXNSFontForFont(Tk_Font tkfont);
 MODULE_SCOPE NSDictionary* TkMacOSXNSFontAttributesForFont(Tk_Font tkfont);
 MODULE_SCOPE NSModalSession TkMacOSXGetModalSession(void);
 MODULE_SCOPE void	TkMacOSXSelDeadWindow(TkWindow *winPtr);
 MODULE_SCOPE void	TkMacOSXApplyWindowAttributes(TkWindow *winPtr,
 			    NSWindow *macWindow);
-MODULE_SCOPE int	TkMacOSXStandardAboutPanelObjCmd(ClientData clientData,
-			    Tcl_Interp *interp, int objc,
-			    Tcl_Obj *const objv[]);
-MODULE_SCOPE int	TkMacOSXIconBitmapObjCmd(ClientData clientData,
-			    Tcl_Interp *interp, int objc,
-			    Tcl_Obj *const objv[]);
+MODULE_SCOPE Tcl_ObjCmdProc TkMacOSXStandardAboutPanelObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc TkMacOSXIconBitmapObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc TkMacOSXNSImageObjCmd;
 MODULE_SCOPE void       TkMacOSXDrawSolidBorder(Tk_Window tkwin, GC gc,
 			    int inset, int thickness);
 MODULE_SCOPE int 	TkMacOSXServices_Init(Tcl_Interp *interp);
-MODULE_SCOPE int	TkMacOSXRegisterServiceWidgetObjCmd(ClientData clientData,
-			    Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
+MODULE_SCOPE Tcl_ObjCmdProc TkMacOSXRegisterServiceWidgetObjCmd;
 MODULE_SCOPE unsigned   TkMacOSXAddVirtual(unsigned int keycode);
+MODULE_SCOPE int 	TkMacOSXNSImage_Init(Tcl_Interp *interp);
 MODULE_SCOPE void       TkMacOSXWinNSBounds(TkWindow *winPtr, NSView *view,
 					    NSRect *bounds);
 MODULE_SCOPE Bool       TkMacOSXInDarkMode(Tk_Window tkwin);
-MODULE_SCOPE void	TkMacOSXDrawAllViews(ClientData clientData);
+MODULE_SCOPE void	TkMacOSXDrawAllViews(void *clientData);
+MODULE_SCOPE NSColor*   controlAccentColor(void);
+MODULE_SCOPE void       Ttk_MacOSXInit(void);
 MODULE_SCOPE unsigned long TkMacOSXClearPixel(void);
+MODULE_SCOPE int MacSystrayInit(Tcl_Interp *);
+MODULE_SCOPE int MacPrint_Init(Tcl_Interp *);
+MODULE_SCOPE NSString*  TkMacOSXOSTypeToUTI(OSType ostype);
+MODULE_SCOPE NSImage*   TkMacOSXIconForFileType(NSString *filetype);
 
 #pragma mark Private Objective-C Classes
 
 #define VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
 
@@ -324,24 +326,26 @@
     NSMenuItem *_demoMenuItem;
     NSArray *_defaultApplicationMenuItems, *_defaultWindowsMenuItems;
     NSArray *_defaultHelpMenuItems, *_defaultFileMenuItems;
     NSAutoreleasePool *_mainPool;
     NSThread *_backgoundLoop;
-
-#ifdef __i386__
-    /* The Objective C runtime used on i386 requires this. */
-    int _poolLock;
-    int _macOSVersion;  /* 10000 * major + 100*minor */
-    Bool _isDrawing;
-    Bool _needsToDraw;
-#endif
-
 }
 @property int poolLock;
 @property int macOSVersion;
 @property Bool isDrawing;
 @property Bool needsToDraw;
+@property Bool isSigned;
+@property Bool tkLiveResizeEnded;
+
+/*
+ * Persistent state variables used by processMouseEvent.
+ */
+
+@property(nonatomic) TkWindow *tkPointerWindow;
+@property(nonatomic) TkWindow *tkEventTarget;
+@property(nonatomic) TkWindow *tkDragTarget;
+@property unsigned int tkButtonState;
 
 @end
 @interface TKApplication(TKInit)
 - (NSString *)tkFrameworkImagePath:(NSString*)image;
 - (void)_resetAutoreleasePool;
@@ -412,10 +416,11 @@
 {
 @private
     NSString *privateWorkingText;
     Bool _tkNeedsDisplay;
     NSRect _tkDirtyRect;
+    NSTrackingArea *trackingArea;
 }
 @property Bool tkNeedsDisplay;
 @property NSRect tkDirtyRect;
 @end
 
@@ -437,17 +442,11 @@
 @end
 
 VISIBILITY_HIDDEN
 @interface TKWindow : NSWindow
 {
-#ifdef __i386__
-    /* The Objective C runtime used on i386 requires this. */
-    Bool _mouseInResizeArea;
-    Window _tkWindow;
-#endif
 }
-@property Bool mouseInResizeArea;
 @property Window tkWindow;
 @end
 
 @interface TKWindow(TKWm)
 - (void)    tkLayoutChanged;
@@ -454,24 +453,16 @@
 @end
 
 @interface TKDrawerWindow : NSWindow
 {
     id _i1, _i2;
-#ifdef __i386__
-    /* The Objective C runtime used on i386 requires this. */
-    Window _tkWindow;
-#endif
 }
 @property Window tkWindow;
 @end
 
 @interface TKPanel : NSPanel
 {
-#ifdef __i386__
-    /* The Objective C runtime used on i386 requires this. */
-    Window _tkWindow;
-#endif
 }
 @property Window tkWindow;
 @end
 
 #pragma mark NSMenu & NSMenuItem Utilities
@@ -557,10 +548,11 @@
 
 @interface TKNSString:NSString {
 @private
     Tcl_DString _ds;
     NSString *_string;
+    const char *_UTF8String;
 }
 @property const char *UTF8String;
 @property (readonly) Tcl_DString DString;
 - (instancetype)initWithTclUtfBytes:(const void *)bytes
 			     length:(NSUInteger)len;

Index: macosx/tkMacOSXRegion.c
==================================================================
--- macosx/tkMacOSXRegion.c
+++ macosx/tkMacOSXRegion.c
@@ -1,13 +1,13 @@
 /*
  * tkMacOSXRegion.c --
  *
  *	Implements X window calls for manipulating regions
  *
- * Copyright (c) 1995-1996 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 1995-1996 Sun Microsystems, Inc.
+ * Copyright © 2001-2009, Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -553,13 +553,62 @@
 
     result = HIShapeUnion(inShape1, inShape2, outResult);
     return result;
 }
 
+static OSStatus
+rectCounter(
+    TCL_UNUSED(int),
+    TCL_UNUSED(HIShapeRef),
+    TCL_UNUSED(const CGRect *),
+    void *ref)
+{
+    int *count = (int *)ref;
+    (*count)++;
+    return noErr;
+}
+
+static OSStatus
+rectPrinter(
+    TCL_UNUSED(int),
+    TCL_UNUSED(HIShapeRef),
+    const CGRect *rect,
+    TCL_UNUSED(void *))
+{
+    if (rect) {
+	fprintf(stderr, "    %s\n", NSStringFromRect(*rect).UTF8String);
+    }
+    return noErr;
+}
+
+int
+TkMacOSXCountRectsInRegion(
+    HIShapeRef shape)
+{
+    int rect_count = 0;
+    if (!HIShapeIsEmpty(shape)) {
+	HIShapeEnumerate(shape,
+	    kHIShapeParseFromBottom|kHIShapeParseFromLeft,
+	    (HIShapeEnumerateProcPtr) rectCounter, (void *) &rect_count);
+    }
+    return rect_count;
+}
+
+void
+TkMacOSXPrintRectsInRegion(
+    HIShapeRef shape)
+{
+    if (!HIShapeIsEmpty(shape)) {
+	HIShapeEnumerate( shape,
+	    kHIShapeParseFromBottom|kHIShapeParseFromLeft,
+	    (HIShapeEnumerateProcPtr) rectPrinter, NULL);
+    }
+}
+
 /*
  * Local Variables:
  * mode: objc
  * c-basic-offset: 4
  * fill-column: 79
  * coding: utf-8
  * End:
  */

Index: macosx/tkMacOSXScale.c
==================================================================
--- macosx/tkMacOSXScale.c
+++ macosx/tkMacOSXScale.c
@@ -2,14 +2,14 @@
  * tkMacOSXScale.c --
  *
  *	This file implements the Macintosh specific portion of the
  *	scale widget.
  *
- * Copyright (c) 1996 by Sun Microsystems, Inc.
- * Copyright (c) 1998-2000 by Scriptics Corporation.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright 2008-2009, Apple Inc.
+ * Copyright © 1996 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Scriptics Corporation.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2008-2009 Apple Inc.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: macosx/tkMacOSXScrlbr.c
==================================================================
--- macosx/tkMacOSXScrlbr.c
+++ macosx/tkMacOSXScrlbr.c
@@ -2,15 +2,15 @@
  * tkMacOSXScrollbar.c --
  *
  *	This file implements the Macintosh specific portion of the scrollbar
  *	widget.
  *
- * Copyright (c) 1996 by Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2015 Kevin Walzer/WordTech Commununications LLC.
- * Copyright (c) 2018-2019 Marc Culler
+ * Copyright © 1996 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2015 Kevin Walzer/WordTech Commununications LLC.
+ * Copyright © 2018-2019 Marc Culler
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -244,11 +244,11 @@
 
 void
 TkpDisplayScrollbar(
     ClientData clientData)	/* Information about window. */
 {
-    TkScrollbar *scrollPtr = clientData;
+    TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
     MacScrollbar *msPtr = (MacScrollbar *) scrollPtr;
     Tk_Window tkwin = scrollPtr->tkwin;
     TkWindow *winPtr = (TkWindow *) tkwin;
     TkMacOSXDrawingContext dc;
 
@@ -291,11 +291,11 @@
     	if (scrollPtr->flags & GOT_FOCUS) {
     	    fgGC = Tk_GCForColor(scrollPtr->highlightColorPtr, (Pixmap) macWin);
     	} else {
     	    fgGC = bgGC;
     	}
-    	TkpDrawHighlightBorder(tkwin, fgGC, bgGC, scrollPtr->highlightWidth,
+    	Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, scrollPtr->highlightWidth,
     		(Pixmap) macWin);
     }
 
     Tk_Draw3DRectangle(tkwin, (Pixmap) macWin, scrollPtr->bgBorder,
 	    scrollPtr->highlightWidth, scrollPtr->highlightWidth,
@@ -454,14 +454,14 @@
 TkpDestroyScrollbar(
     TkScrollbar *scrollPtr)
 {
     MacScrollbar *macScrollPtr = (MacScrollbar *) scrollPtr;
 
-    if (macScrollPtr->troughGC != None) {
+    if (macScrollPtr->troughGC != NULL) {
 	Tk_FreeGC(scrollPtr->display, macScrollPtr->troughGC);
     }
-    if (macScrollPtr->copyGC != None) {
+    if (macScrollPtr->copyGC != NULL) {
 	Tk_FreeGC(scrollPtr->display, macScrollPtr->copyGC);
     }
 }
 
 /*
@@ -591,11 +591,11 @@
     MacScrollbar *msPtr = (MacScrollbar *) scrollPtr;
     Tk_Window tkwin = scrollPtr->tkwin;
     MacDrawable *macWin = (MacDrawable *)Tk_WindowId(scrollPtr->tkwin);
     double dViewSize;
     HIRect contrlRect;
-    short width, height;
+    short height;
 
     NSView *view = TkMacOSXGetNSViewForDrawable(macWin);
     CGFloat viewHeight = [view bounds].size.height;
     NSRect frame;
 
@@ -605,11 +605,10 @@
     frame.origin.y = viewHeight - (frame.origin.y + frame.size.height);
 
     contrlRect = NSRectToCGRect(frame);
     msPtr->info.bounds = contrlRect;
 
-    width = contrlRect.size.width;
     height = contrlRect.size.height - scrollPtr->arrowLength;
 
     /*
      * Ensure we set scrollbar control bounds only once all size adjustments
      * have been computed.
@@ -768,11 +767,11 @@
 static void
 ScrollbarEventProc(
     ClientData clientData,	/* Information about window. */
     XEvent *eventPtr)		/* Information about event. */
 {
-    TkScrollbar *scrollPtr = clientData;
+    TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
 
     switch (eventPtr->type) {
     case UnmapNotify:
 	TkMacOSXSetScrollbarGrow((TkWindow *) scrollPtr->tkwin, false);
 	break;
@@ -782,14 +781,14 @@
 	break;
     case ButtonPress:
     case ButtonRelease:
     case EnterNotify:
     case LeaveNotify:
-    	ScrollbarEvent(clientData, eventPtr);
+    	ScrollbarEvent(scrollPtr, eventPtr);
 	break;
     default:
-	TkScrollbarEventProc(clientData, eventPtr);
+	TkScrollbarEventProc(scrollPtr, eventPtr);
     }
 }
 
 /*
  * Local Variables:

Index: macosx/tkMacOSXSend.c
==================================================================
--- macosx/tkMacOSXSend.c
+++ macosx/tkMacOSXSend.c
@@ -20,14 +20,14 @@
  *	Implementing this has been on our list of things to do, but what with
  *	the demise of Tcl at Sun, and the lack of resources at Scriptics it
  *	may not get done for awhile. So this sketch is offered for the brave
  *	to attempt if they need the functionality...
  *
- * Copyright (c) 1989-1994 The Regents of the University of California.
- * Copyright (c) 1994-1998 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 1989-1994 The Regents of the University of California.
+ * Copyright © 1994-1998 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: macosx/tkMacOSXServices.c
==================================================================
--- macosx/tkMacOSXServices.c
+++ macosx/tkMacOSXServices.c
@@ -1,13 +1,13 @@
 /*
  * tkMacOSXServices.c --
  *\
  *	This file allows the integration of Tk and the Cocoa NSServices API.
  *
- * Copyright (c) 2010-2019 Kevin Walzer/WordTech Communications LLC.
- * Copyright (c) 2019 Marc Culler.
- * Copyright (c) 2010 Adrian Robert.
+ * Copyright © 2010-2019 Kevin Walzer/WordTech Communications LLC.
+ * Copyright © 2019 Marc Culler.
+ * Copyright © 2010 Adrian Robert.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: macosx/tkMacOSXSubwindows.c
==================================================================
--- macosx/tkMacOSXSubwindows.c
+++ macosx/tkMacOSXSubwindows.c
@@ -1,13 +1,13 @@
 /*
  * tkMacOSXSubwindows.c --
  *
  *	Implements subwindows for the macintosh version of Tk.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -103,11 +103,11 @@
         macWin->drawRgn = NULL;
     }
     macWin->view = nil;
 
     /*
-     * Delay deletion of a toplevel data structure untill all children have
+     * Delay deletion of a toplevel data structure until all children have
      * been deleted.
      */
 
     if (macWin->toplevel->referenceCount == 0) {
 	ckfree(macWin->toplevel);
@@ -146,10 +146,12 @@
     }
     MacDrawable *macWin = (MacDrawable *)window;
     TkWindow *winPtr = macWin->winPtr;
     NSWindow *win = TkMacOSXGetNSWindowForDrawable(window);
     static Bool initialized = NO;
+    NSPoint mouse = [NSEvent mouseLocation];
+    int x = mouse.x, y = TkMacOSXZeroScreenHeight() - mouse.y;
 
     /*
      * Under certain situations it's possible for this function to be called
      * before the toplevel window it's associated with has actually been
      * mapped. In that case we need to create the real Macintosh window now as
@@ -183,19 +185,29 @@
 		    [win makeKeyAndOrderFront:NSApp];
 		} else {
 		    [win orderFrontRegardless];
 		}
 	    }
+
+	    /*
+	     * Call Tk_UpdatePointer to tell Tk whether the pointer is in the
+	     * new window.
+	     */
+
+	    NSPoint viewLocation = [view convertPoint:mouse fromView:nil];
+	    if (NSPointInRect(viewLocation, NSInsetRect([view bounds], 2, 2))) {
+		Tk_UpdatePointer((Tk_Window) winPtr, x, y, [NSApp tkButtonState]);
+	    }
 	} else {
-	    TkWindow *contWinPtr = TkpGetOtherWindow(winPtr);
+	    Tk_Window contWinPtr = Tk_GetOtherWindow((Tk_Window)winPtr);
 
 	    /*
 	     * Rebuild the container's clipping region and display
 	     * the window.
 	     */
 
-	    TkMacOSXInvalClipRgns((Tk_Window)contWinPtr);
+	    TkMacOSXInvalClipRgns(contWinPtr);
 	    TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
 	}
 	TkMacOSXInvalClipRgns((Tk_Window)winPtr);
     } else {
 
@@ -301,25 +313,54 @@
 	return BadWindow;
     }
     display->request++;
     if (Tk_IsTopLevel(winPtr)) {
 	if (!Tk_IsEmbedded(winPtr) &&
-		winPtr->wmInfoPtr->hints.initial_state!=IconicState) {
-	    [win orderOut:nil];
+	    winPtr->wmInfoPtr->hints.initial_state!=IconicState) {
 	    [win setExcludedFromWindowsMenu:YES];
+	    [win orderOut:NSApp];
+	    if ([win isKeyWindow]) {
+
+		/*
+		 * If we are unmapping the key window then we need to make sure
+		 * that a new key window is assigned, if possible.  This is
+		 * supposed to happen when a key window is ordered out, but as
+		 * noted in tkMacOSXWm.c this does not happen, in spite of
+		 * Apple's claims to the contrary.
+		 */
+
+		for (NSWindow *w in [NSApp orderedWindows]) {
+		    TkWindow *winPtr2 = TkMacOSXGetTkWindow(w);
+		    WmInfo *wmInfoPtr;
+
+		    BOOL isOnScreen;
+
+		    if (!winPtr2 || !winPtr2->wmInfoPtr) {
+			continue;
+		    }
+		    wmInfoPtr = winPtr2->wmInfoPtr;
+		    isOnScreen = (wmInfoPtr->hints.initial_state != IconicState &&
+				  wmInfoPtr->hints.initial_state != WithdrawnState);
+		    if (w != win && isOnScreen && [w canBecomeKeyWindow]) {
+			[w makeKeyAndOrderFront:NSApp];
+			break;
+		    }
+		}
+	    }
 	}
 	TkMacOSXInvalClipRgns((Tk_Window)winPtr);
     } else {
+
 	/*
 	 * Rebuild the visRgn clip region for the parent so it will be allowed
 	 * to draw in the space from which this subwindow was removed and then
 	 * redraw the window.
 	 */
 
 	if (parentPtr && parentPtr->privatePtr->visRgn) {
 	    TkMacOSXInvalidateViewRegion(
-		    TkMacOSXGetNSViewForDrawable(parentPtr->privatePtr),
+		    TkMacOSXGetNSViewForDrawable(parentPtr->window),
 		    parentPtr->privatePtr->visRgn);
 	}
 	TkMacOSXInvalClipRgns((Tk_Window)parentPtr);
 	TkMacOSXUpdateClipRgn(parentPtr);
     }
@@ -499,11 +540,11 @@
     /*
      * Find the Parent window, for an embedded window it will be its container.
      */
 
     if (Tk_IsEmbedded(macWin->winPtr)) {
-	TkWindow *contWinPtr = TkpGetOtherWindow(macWin->winPtr);
+	TkWindow *contWinPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)macWin->winPtr);
 
 	if (contWinPtr) {
 	    macParent = contWinPtr->privatePtr;
 	} else {
 	    /*
@@ -757,11 +798,11 @@
     /*
      * If the window is a container, set the flag for its embedded window.
      */
 
     if (Tk_IsContainer(winPtr)) {
-	childPtr = TkpGetOtherWindow(winPtr);
+	childPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)winPtr);
 
 	if (childPtr) {
 	    TkMacOSXSetDrawingEnabled(childPtr, flag);
 	}
     }
@@ -838,11 +879,11 @@
 		    }
 		    TkMacOSXWinCGBounds(win2Ptr, &bounds);
 		    ChkErr(TkMacOSHIShapeDifferenceWithRect, rgn, &bounds);
 		}
 	    } else if (Tk_IsEmbedded(winPtr)) {
-		win2Ptr = TkpGetOtherWindow(winPtr);
+		win2Ptr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)winPtr);
 		if (win2Ptr) {
 		    TkMacOSXUpdateClipRgn(win2Ptr);
 		    ChkErr(HIShapeIntersect,
 			    win2Ptr->privatePtr->aboveVisRgn, rgn, rgn);
 		}
@@ -871,11 +912,11 @@
 		rgnChanged = 1;
 		win2Ptr = win2Ptr->nextPtr;
 	    }
 
 	    if (Tk_IsContainer(winPtr)) {
-		win2Ptr = TkpGetOtherWindow(winPtr);
+		win2Ptr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)winPtr);
 		if (win2Ptr) {
 		    if (Tk_IsMapped(win2Ptr)) {
 			TkMacOSXWinCGBounds(win2Ptr, &bounds);
 			ChkErr(TkMacOSHIShapeDifferenceWithRect, rgn, &bounds);
 			rgnChanged = 1;
@@ -905,11 +946,11 @@
 	     */
 
 	    if (!Tk_IsTopLevel(winPtr)) {
 		TkMacOSXUpdateClipRgn(winPtr->parentPtr);
 	    } else if (Tk_IsEmbedded(winPtr)) {
-		win2Ptr = TkpGetOtherWindow(winPtr);
+		win2Ptr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)winPtr);
 		if (win2Ptr) {
 		    TkMacOSXUpdateClipRgn(win2Ptr);
 		}
 	    }
 	    macWin->aboveVisRgn = TkMacOSXHIShapeCreateEmpty();
@@ -971,11 +1012,11 @@
     TCL_UNUSED(HIShapeRef),
     const CGRect *rect,
     void *ref)
 {
     static CGAffineTransform t;
-    TKContentView *view = ref;
+    TKContentView *view = (TKContentView *)ref;
     NSRect dirtyRect;
 
     if (!view) {
 	return paramErr;
     }
@@ -1068,11 +1109,11 @@
 	result = macWin->toplevel->winPtr->wmInfoPtr->window;
     } else if (macWin->winPtr && macWin->winPtr->wmInfoPtr &&
 	    macWin->winPtr->wmInfoPtr->window) {
 	result = macWin->winPtr->wmInfoPtr->window;
     } else if (macWin->toplevel && (macWin->toplevel->flags & TK_EMBEDDED)) {
-	TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
+	TkWindow *contWinPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)macWin->toplevel->winPtr);
 
 	if (contWinPtr) {
 	    result = TkMacOSXGetNSWindowForDrawable((Drawable)contWinPtr->privatePtr);
 	}
     }
@@ -1114,11 +1155,11 @@
     } else if (!macWin->toplevel) {
 	result = macWin->view;
     } else if (!(macWin->toplevel->flags & TK_EMBEDDED)) {
 	result = macWin->toplevel->view;
     } else {
-	TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
+	TkWindow *contWinPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)macWin->toplevel->winPtr);
 
 	if (contWinPtr) {
 	    result = TkMacOSXGetRootControl((Drawable)contWinPtr->privatePtr);
 	}
     }
@@ -1196,11 +1237,11 @@
     /*
      * Also, if the window is a container, mark its embedded window.
      */
 
     if (Tk_IsContainer(winPtr)) {
-	childPtr = TkpGetOtherWindow(winPtr);
+	childPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)winPtr);
 
 	if (childPtr) {
 	    TkMacOSXInvalClipRgns((Tk_Window)childPtr);
 	}
 
@@ -1351,11 +1392,11 @@
 	}
 	childPtr = childPtr->nextPtr;
     }
 
     if (Tk_IsContainer(winPtr)) {
-	childPtr = TkpGetOtherWindow(winPtr);
+	childPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)winPtr);
 	if (childPtr != NULL) {
 	    UpdateOffsets(childPtr,deltaX,deltaY);
 	}
 
 	/*
@@ -1433,16 +1474,20 @@
 {
     MacDrawable *macPix = (MacDrawable *)pixmap;
 
     display->request++;
     if (macPix->context) {
-	char *data = CGBitmapContextGetData(macPix->context);
+	char *data = (char *)CGBitmapContextGetData(macPix->context);
 
 	if (data) {
 	    ckfree(data);
 	}
-	CFRelease(macPix->context);
+	/*
+	 * Releasing the context here causes a crash in the 8.7 regression
+	 * tests, but not in 8.6.
+	 *	CFRelease(macPix->context);
+	 */
     }
     ckfree(macPix);
 }
 
 /*

ADDED   macosx/tkMacOSXSysTray.c
Index: macosx/tkMacOSXSysTray.c
==================================================================
--- /dev/null
+++ macosx/tkMacOSXSysTray.c
@@ -0,0 +1,497 @@
+/*
+ * tkMacOSXSysTray.c --
+ *
+ *	tkMacOSXSysTray.c implements a "systray" Tcl command which allows
+ *      one to change the system tray/taskbar icon of a Tk toplevel
+ *      window and a "sysnotify" command to post system notifications.
+ *      In macOS the icon appears on the right hand side of the menu bar.
+ *
+ * Copyright © 2020 Kevin Walzer/WordTech Communications LLC.
+ * Copyright © 2020 Jan Nijtmans.
+ * Copyright © 2020 Marc Culler.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+#include <tkInt.h>
+#include <tkMacOSXInt.h>
+#include "tkMacOSXPrivate.h"
+
+/*
+ * Class declaration for TkStatusItem.
+ */
+
+@interface TkStatusItem: NSObject {
+    NSStatusItem * statusItem;
+    NSStatusBar * statusBar;
+    NSImage * icon;
+    NSString * tooltip;
+    Tcl_Interp * interp;
+    Tcl_Obj * b1_callback;
+    Tcl_Obj * b3_callback;
+}
+
+- (id) init : (Tcl_Interp *) interp;
+- (void) setImagewithImage : (NSImage *) image;
+- (void) setTextwithString : (NSString *) string;
+- (void) setB1Callback : (Tcl_Obj *) callback;
+- (void) setB3Callback : (Tcl_Obj *) callback;
+- (void) clickOnStatusItem;
+- (void) dealloc;
+
+@end
+
+
+
+/*
+ * Class declaration for TkStatusItem. A TkStatusItem represents an icon posted
+ * on the status bar located on the right side of the MenuBar.  Each interpreter
+ * may have at most one TkStatusItem.  A pointer to the TkStatusItem belonging
+ * to an interpreter is stored as the clientData of the MacSystrayObjCmd instance
+ * in that interpreter.  It will be NULL until the tk systray command is executed
+ * by the interpreter.
+ */
+
+@implementation TkStatusItem : NSObject
+
+- (id) init : (Tcl_Interp *) interpreter {
+    [super init];
+    statusBar = [NSStatusBar systemStatusBar];
+    statusItem = [[statusBar statusItemWithLength:NSVariableStatusItemLength] retain];
+    statusItem.button.target = self;
+    statusItem.button.action = @selector(clickOnStatusItem);
+    [statusItem.button sendActionOn : NSEventMaskLeftMouseUp | NSEventMaskRightMouseUp];
+    statusItem.visible = YES;
+    interp = interpreter;
+    b1_callback = NULL;
+    b3_callback = NULL;
+    return self;
+}
+
+- (void) setImagewithImage : (NSImage *) image
+{
+    icon = nil;
+    icon = image;
+    statusItem.button.image = icon;
+}
+
+- (void) setTextwithString : (NSString *) string
+{
+    tooltip = nil;
+    tooltip = string;
+    statusItem.button.toolTip = tooltip;
+}
+
+- (void) setB1Callback : (Tcl_Obj *) obj
+{
+    if (obj != NULL) {
+	Tcl_IncrRefCount(obj);
+    }
+    if (b1_callback != NULL) {
+	Tcl_DecrRefCount(b1_callback);
+    }
+    b1_callback = obj;
+}
+
+- (void) setB3Callback : (Tcl_Obj *) obj
+{
+    if (obj != NULL) {
+	Tcl_IncrRefCount(obj);
+    }
+    if (b3_callback != NULL) {
+	Tcl_DecrRefCount(b3_callback);
+    }
+    b3_callback = obj;
+}
+
+- (void) clickOnStatusItem
+{
+    NSEvent *event = [NSApp currentEvent];
+    if (([event type] == NSEventTypeLeftMouseUp) && (b1_callback != NULL)) {
+	int result = Tcl_EvalObjEx(interp, b1_callback, TCL_EVAL_GLOBAL);
+	if (result != TCL_OK) {
+	    Tcl_BackgroundException(interp, result);
+	}
+    } else {
+	if (([event type] == NSEventTypeRightMouseUp) && (b3_callback != NULL)) {
+	    int result = Tcl_EvalObjEx(interp, b3_callback, TCL_EVAL_GLOBAL);
+	    if (result != TCL_OK) {
+		Tcl_BackgroundException(interp, result);
+	    }
+	}
+    }
+}
+- (void) dealloc
+{
+    [statusBar removeStatusItem: statusItem];
+    if (b1_callback != NULL) {
+	Tcl_DecrRefCount(b1_callback);
+    }
+    if (b3_callback != NULL) {
+	Tcl_DecrRefCount(b3_callback);
+    }
+    [super dealloc];
+}
+
+@end
+
+/*
+ * Type used for the ClientData of a MacSystrayObjCmd instance.
+ */
+
+typedef TkStatusItem** StatusItemInfo;
+
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * MacSystrayDestroy --
+ *
+ * 	Removes an intepreters icon from the status bar.
+ *
+ * Results:
+ *	None.
+ *
+ * Side effects:
+ *	The icon is removed and memory is freed.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+MacSystrayDestroy(
+    ClientData clientData,
+    TCL_UNUSED(Tcl_Interp *))
+{
+    StatusItemInfo info = (StatusItemInfo)clientData;
+    if (info) {
+	[*info release];
+	ckfree(info);
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * MacSystrayObjCmd --
+ *
+ * 	Main command for creating, displaying, and removing icons from the
+ * 	status bar.
+ *
+ * Results:
+ *
+ *      A standard Tcl result.
+ *
+ * Side effects:
+ *
+ *	Management of icon display in the status bar.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+MacSystrayObjCmd(
+    void *clientData,
+    Tcl_Interp * interp,
+    int objc,
+    Tcl_Obj *const *objv)
+{
+    Tk_Image tk_image;
+    int result, idx;
+    static const char *options[] =
+	{"create", "modify", "destroy", NULL};
+    typedef enum {TRAY_CREATE, TRAY_MODIFY, TRAY_DESTROY} optionsEnum;
+    static const char *modifyOptions[] =
+	{"image", "text", "b1_callback", "b3_callback", NULL};
+    typedef enum {TRAY_IMAGE, TRAY_TEXT, TRAY_B1_CALLBACK, TRAY_B3_CALLBACK
+        } modifyOptionsEnum;
+
+    if ([NSApp macOSVersion] < 101000) {
+	Tcl_AppendResult(interp,
+	    "StatusItem icons not supported on macOS versions lower than 10.10",
+	    NULL);
+	return TCL_OK;
+    }
+
+    StatusItemInfo info = (StatusItemInfo)clientData;
+    TkStatusItem *statusItem = *info;
+
+    if (objc < 2) {
+	Tcl_WrongNumArgs(interp, 1, objv, "create | modify | destroy");
+	return TCL_ERROR;
+    }
+
+    result = Tcl_GetIndexFromObjStruct(interp, objv[1], options,
+				       sizeof(char *), "command", 0, &idx);
+
+    if (result != TCL_OK) {
+    	return TCL_ERROR;
+    }
+    switch((optionsEnum)idx) {
+    case TRAY_CREATE: {
+
+	if (objc < 3 ||  objc > 6) {
+	    Tcl_WrongNumArgs(interp, 1, objv, "create -image -text -button1 -button3");
+	    return TCL_ERROR;
+	}
+
+	if (statusItem == NULL) {
+	    statusItem = [[TkStatusItem alloc] init: interp];
+	    *info = statusItem;
+	} else {
+	    Tcl_AppendResult(interp, "Only one system tray icon supported per interpreter", NULL);
+	    return TCL_ERROR;
+	}
+
+	/*
+	 * Create the icon.
+	 */
+
+	int width, height;
+	Tk_Window tkwin = Tk_MainWindow(interp);
+	TkWindow *winPtr = (TkWindow *)tkwin;
+	Display *d = winPtr->display;
+	NSImage *icon;
+
+	tk_image = Tk_GetImage(interp, tkwin, Tcl_GetString(objv[2]), NULL, NULL);
+	if (tk_image == NULL) {
+	    return TCL_ERROR;
+	}
+
+	Tk_SizeOfImage(tk_image, &width, &height);
+	if (width != 0 && height != 0) {
+	    icon = TkMacOSXGetNSImageFromTkImage(d, tk_image,
+						 width, height);
+	    [statusItem setImagewithImage: icon];
+	    Tk_FreeImage(tk_image);
+	}
+
+	/*
+	 * Set the text for the tooltip.
+	 */
+
+	NSString *tooltip = [NSString stringWithUTF8String: Tcl_GetString(objv[3])];
+	if (tooltip == nil) {
+	    Tcl_AppendResult(interp, " unable to set tooltip for systray icon", NULL);
+	    return TCL_ERROR;
+	}
+
+	[statusItem setTextwithString: tooltip];
+
+	/*
+	 * Set the proc for the callback.
+	 */
+
+	[statusItem setB1Callback : (objc > 4) ? objv[4] : NULL];
+	[statusItem setB3Callback : (objc > 5) ? objv[5] : NULL];
+	break;
+
+    }
+    case TRAY_MODIFY: {
+	if (objc != 4) {
+	    Tcl_WrongNumArgs(interp, 1, objv, "modify object item");
+	    return TCL_ERROR;
+	}
+
+	/*
+	 * Modify the icon.
+	 */
+
+	result = Tcl_GetIndexFromObjStruct(interp, objv[2], modifyOptions,
+					   sizeof(char *), "option", 0, &idx);
+
+	if (result != TCL_OK) {
+	    return TCL_ERROR;
+	}
+	switch ((modifyOptionsEnum)idx) {
+	case TRAY_IMAGE: {
+	    Tk_Window tkwin = Tk_MainWindow(interp);
+	    TkWindow *winPtr = (TkWindow *)tkwin;
+	    Display *d = winPtr -> display;
+	    NSImage *icon;
+	    int width, height;
+
+	    tk_image = Tk_GetImage(interp, tkwin, Tcl_GetString(objv[3]), NULL, NULL);
+	    if (tk_image == NULL) {
+		Tcl_AppendResult(interp, " unable to obtain image for systray icon",
+				 NULL);
+		return TCL_ERROR;
+	    }
+
+	    Tk_SizeOfImage(tk_image, &width, &height);
+	    if (width != 0 && height != 0) {
+		icon = TkMacOSXGetNSImageFromTkImage(d, tk_image,
+						     width, height);
+		[statusItem setImagewithImage: icon];
+	    }
+	    Tk_FreeImage(tk_image);
+	    break;
+	}
+
+        /*
+         * Modify the text for the tooltip.
+         */
+
+	case TRAY_TEXT: {
+	    NSString *tooltip = [NSString stringWithUTF8String:Tcl_GetString(objv[3])];
+	    if (tooltip == nil) {
+		Tcl_AppendResult(interp, "unable to set tooltip for systray icon",
+				 NULL);
+		return TCL_ERROR;
+	    }
+
+	    [statusItem setTextwithString: tooltip];
+	    break;
+	}
+
+        /*
+         * Modify the proc for the callback.
+         */
+
+	case TRAY_B1_CALLBACK: {
+	    [statusItem setB1Callback : objv[3]];
+	    break;
+	}
+	case TRAY_B3_CALLBACK: {
+	    [statusItem setB3Callback : objv[3]];
+	    break;
+	}
+    }
+    break;
+    }
+
+    case TRAY_DESTROY: {
+	/*
+	 * Set all properties to nil, and release statusItem.
+	 */
+        [statusItem setImagewithImage: nil];
+        [statusItem setTextwithString: nil];
+        [statusItem setB1Callback : NULL];
+        [statusItem setB3Callback : NULL];
+        [statusItem release];
+        *info = NULL;
+        statusItem = NULL;
+        break;
+    }
+    }
+
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SysNotifyObjCmd --
+ *
+ *      Create system notification.
+ *
+ * Results:
+ *
+ *      A standard Tcl result.
+ *
+ * Side effects:
+ *
+ *      System notifications are posted.
+ *
+ *-------------------------------z---------------------------------------
+ */
+
+static int SysNotifyObjCmd(
+    TCL_UNUSED(void *),
+    Tcl_Interp * interp,
+    int objc,
+    Tcl_Obj *const *objv)
+{
+    if (objc < 3) {
+	Tcl_WrongNumArgs(interp, 1, objv, "title message");
+	return TCL_ERROR;
+    }
+
+    if ([NSApp macOSVersion] < 101000) {
+	Tcl_AppendResult(interp,
+	    "Notifications not supported on macOS versions lower than 10.10",
+	     NULL);
+	return TCL_OK;
+    }
+
+    /*
+     * Using NSAppleScript API here allows us to use a single API rather
+     * than multiple, some deprecated, API's, and also allows notifications
+     * to work correctly without requiring Wish to be code-signed - an
+     * undocumented but apparently consistent requirement. And by calling
+     * NSAppleScript inline rather than shelling to out osascript,
+     * Wish shows correctly as the calling app rather than Script Editor.
+     */
+
+    NSString *title = [NSString stringWithUTF8String: Tcl_GetString(objv[1])];
+    NSString *message = [NSString stringWithUTF8String: Tcl_GetString(objv[2])];
+    NSMutableString *notify = [NSMutableString new];
+    [notify appendString: @"display notification "];
+    [notify appendString:@"\""];
+    [notify appendString:message];
+    [notify appendString:@"\""];
+    [notify appendString:@" with title \""];
+    [notify appendString:title];
+    [notify appendString:@"\""];
+    NSAppleScript *scpt = [[[NSAppleScript alloc] initWithSource:notify] autorelease];
+    NSDictionary *errorInfo;
+    NSAppleEventDescriptor *result = [scpt executeAndReturnError:&errorInfo];
+    NSString *info = [result stringValue];
+    const char* output = [info UTF8String];
+
+    Tcl_AppendResult(interp,
+		     output,
+		     NULL);
+
+    return TCL_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * MacSystrayInit --
+ *
+ * 	Initialize this package and create script-level commands.
+ *      This is called from TkpInit for each interpreter.
+ *
+ * Results:
+ *
+ *      A standard Tcl result.
+ *
+ * Side effects:
+ *
+ *	The tk systray and tk sysnotify commands are installed in an
+ *	interpreter
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+MacSystrayInit(Tcl_Interp *interp)
+{
+
+    /*
+     * Initialize the TkStatusItem for this interpreter.
+     */
+
+    StatusItemInfo info = (StatusItemInfo) ckalloc(sizeof(StatusItemInfo));
+    *info = 0;
+
+    Tcl_CreateObjCommand(interp, "::tk::systray::_systray", MacSystrayObjCmd, info,
+            (Tcl_CmdDeleteProc *)MacSystrayDestroy);
+    Tcl_CreateObjCommand(interp, "::tk::sysnotify::_sysnotify", SysNotifyObjCmd, NULL, NULL);
+    return TCL_OK;
+}
+
+
+/*
+ * Local Variables:
+ * mode: objc
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */

Index: macosx/tkMacOSXTest.c
==================================================================
--- macosx/tkMacOSXTest.c
+++ macosx/tkMacOSXTest.c
@@ -2,13 +2,13 @@
  * tkMacOSXTest.c --
  *
  *	Contains commands for platform specific tests for
  *	the Macintosh platform.
  *
- * Copyright (c) 1996 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 1996 Sun Microsystems, Inc.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -19,20 +19,16 @@
 
 /*
  * Forward declarations of procedures defined later in this file:
  */
 
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080
-static int		DebuggerObjCmd (ClientData dummy, Tcl_Interp *interp,
-					int objc, Tcl_Obj *const objv[]);
+#if !defined(NDEBUG) && MAC_OS_X_VERSION_MAX_ALLOWED < 1080
+static Tcl_ObjCmdProc DebuggerObjCmd;
 #endif
-static int		PressButtonObjCmd (ClientData dummy, Tcl_Interp *interp,
-					int objc, Tcl_Obj *const *objv);
-static int		InjectKeyEventObjCmd (ClientData dummy, Tcl_Interp *interp,
-					int objc, Tcl_Obj *const *objv);
-static int		MenuBarHeightObjCmd (ClientData dummy, Tcl_Interp *interp,
-					int objc, Tcl_Obj *const *objv);
+static Tcl_ObjCmdProc PressButtonObjCmd;
+static Tcl_ObjCmdProc InjectKeyEventObjCmd;
+static Tcl_ObjCmdProc MenuBarHeightObjCmd;
 
 
 /*
  *----------------------------------------------------------------------
  *
@@ -56,11 +52,11 @@
 {
     /*
      * Add commands for platform specific tests on MacOS here.
      */
 
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080
+#if !defined(NDEBUG) && MAC_OS_X_VERSION_MAX_ALLOWED < 1080
     Tcl_CreateObjCommand(interp, "debugger", DebuggerObjCmd, NULL, NULL);
 #endif
     Tcl_CreateObjCommand(interp, "pressbutton", PressButtonObjCmd, NULL, NULL);
     Tcl_CreateObjCommand(interp, "injectkeyevent", InjectKeyEventObjCmd, NULL, NULL);
     Tcl_CreateObjCommand(interp, "menubarheight", MenuBarHeightObjCmd, NULL, NULL);
@@ -82,17 +78,17 @@
  *	None.
  *
  *----------------------------------------------------------------------
  */
 
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080
+#if !defined(NDEBUG) && MAC_OS_X_VERSION_MAX_ALLOWED < 1080
 static int
 DebuggerObjCmd(
-    ClientData clientData,		/* Not used. */
-    Tcl_Interp *interp,			/* Not used. */
-    int objc,				/* Not used. */
-    Tcl_Obj *const objv[])			/* Not used. */
+    TCL_UNUSED(void *),
+    TCL_UNUSED(Tcl_Interp *),
+    TCL_UNUSED(int),
+    TCL_UNUSED(Tcl_Obj *const *))
 {
     Debugger();
     return TCL_OK;
 }
 #endif
@@ -196,11 +192,10 @@
     Tcl_Interp *interp,
     int objc,
     Tcl_Obj *const objv[])
 {
     int x = 0, y = 0, i, value;
-    NSInteger signal = -1;
     CGPoint pt;
     NSPoint loc;
     NSEvent *motion, *press, *release;
     NSArray *screens = [NSScreen screens];
     CGFloat ScreenHeight = 0;
@@ -232,44 +227,43 @@
     pt.x = loc.x = x;
     pt.y = y;
     loc.y = ScreenHeight - y;
 
     /*
-     *  We set the window number and the eventNumber to -1 as a signal to
-     *  processMouseEvent.
+     *  We set the timestamp to 0 as a signal to processMouseEvent.
      */
 
     CGWarpMouseCursorPosition(pt);
     motion = [NSEvent mouseEventWithType:NSMouseMoved
 	location:loc
 	modifierFlags:0
-	timestamp:GetCurrentEventTime()
-	windowNumber:signal
+	timestamp:0
+	windowNumber:0
 	context:nil
-	eventNumber:signal
+	eventNumber:0
 	clickCount:1
-	pressure:0.0];
+	pressure:0];
     [NSApp postEvent:motion atStart:NO];
     press = [NSEvent mouseEventWithType:NSLeftMouseDown
 	location:loc
 	modifierFlags:0
-	timestamp:GetCurrentEventTime()
-	windowNumber:signal
+	timestamp:0
+	windowNumber:0
 	context:nil
-	eventNumber:signal
+	eventNumber:0
 	clickCount:1
-	pressure:0.0];
+	pressure:0];
     [NSApp postEvent:press atStart:NO];
     release = [NSEvent mouseEventWithType:NSLeftMouseUp
 	location:loc
 	modifierFlags:0
-	timestamp:GetCurrentEventTime()
-	windowNumber:signal
+	timestamp:0
+	windowNumber:0
 	context:nil
-	eventNumber:signal
+	eventNumber:0
 	clickCount:1
-	pressure:-1.0];
+	pressure:0];
     [NSApp postEvent:release atStart:NO];
     return TCL_OK;
 }
 
 static int
@@ -278,16 +272,16 @@
     Tcl_Interp *interp,
     int objc,
     Tcl_Obj *const objv[])
 {
     static const char *const optionStrings[] = {
-	"press", "release", "flagschanged", NULL};
-    NSUInteger types[3] = {NSKeyDown, NSKeyUp, NSFlagsChanged};
+	"flagschanged", "press", "release", NULL};
+    NSUInteger types[3] = {NSFlagsChanged, NSKeyDown, NSKeyUp};
     static const char *const argStrings[] = {
-	"-shift", "-control", "-option", "-command", "-function", "-x", "-y", NULL};
-    enum args {KEYEVENT_SHIFT, KEYEVENT_CONTROL, KEYEVENT_OPTION, KEYEVENT_COMMAND,
-	       KEYEVENT_FUNCTION, KEYEVENT_X, KEYEVENT_Y};
+	"-command", "-control", "-function", "-option", "-shift", "-x", "-y", NULL};
+    enum args {KEYEVENT_COMMAND, KEYEVENT_CONTROL, KEYEVENT_FUNCTION, KEYEVENT_OPTION,
+	       KEYEVENT_SHIFT, KEYEVENT_X, KEYEVENT_Y};
     int i, index, keysym, mods = 0, x = 0, y = 0;
     NSString *chars = nil, *unmod = nil, *upper, *lower;
     NSEvent *keyEvent;
     NSUInteger type;
     MacKeycode macKC;
@@ -295,12 +289,12 @@
     if (objc < 3) {
     wrongArgs:
         Tcl_WrongNumArgs(interp, 1, objv, "option keysym ?arg?");
         return TCL_ERROR;
     }
-    if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
-            &index) != TCL_OK) {
+    if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings,
+            sizeof(char *), "option", 0, &index) != TCL_OK) {
         return TCL_ERROR;
     }
     type = types[index];
     if (Tcl_GetIntFromObj(interp, objv[2], &keysym) != TCL_OK) {
 	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -374,11 +368,11 @@
 	windowNumber:0
 	context:nil
 	characters:chars
 	charactersIgnoringModifiers:unmod
 	isARepeat:NO
-	keyCode:macKC.v.virtual];
+	keyCode:macKC.v.virt];
     [NSApp postEvent:keyEvent atStart:NO];
     return TCL_OK;
 }
 /*
  * Local Variables:

Index: macosx/tkMacOSXWindowEvent.c
==================================================================
--- macosx/tkMacOSXWindowEvent.c
+++ macosx/tkMacOSXWindowEvent.c
@@ -2,14 +2,14 @@
  * tkMacOSXWindowEvent.c --
  *
  *	This file defines the routines for both creating and handling Window
  *	Manager class events for Tk.
  *
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2015 Kevin Walzer/WordTech Communications LLC.
- * Copyright (c) 2015 Marc Culler.
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2015 Kevin Walzer/WordTech Communications LLC.
+ * Copyright © 2015 Marc Culler.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -50,17 +50,37 @@
 - (void) windowActivation: (NSNotification *) notification
 {
 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
     TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
 #endif
-    BOOL activate = [[notification name]
-	    isEqualToString:NSWindowDidBecomeKeyNotification];
     NSWindow *w = [notification object];
     TkWindow *winPtr = TkMacOSXGetTkWindow(w);
+    NSString *name = [notification name];
+    Bool flag = [name isEqualToString:NSWindowDidBecomeKeyNotification];
+    if (winPtr && flag) {
+	NSPoint location = [NSEvent mouseLocation];
+	int x = location.x;
+	int y = floor(TkMacOSXZeroScreenHeight() - location.y);
+	/*
+	 * The Tk event target persists when there is no key window but
+	 * gets reset when a new window becomes the key window.
+	 */
 
+	[NSApp setTkEventTarget: winPtr];
+
+	/*
+	 * Call Tk_UpdatePointer if the pointer is in the window.
+	 */
+
+	NSView *view = [w contentView];
+	NSPoint viewLocation = [view convertPoint:location fromView:nil];
+	if (NSPointInRect(viewLocation, NSInsetRect([view bounds], 2, 2))) {
+	    Tk_UpdatePointer((Tk_Window) winPtr, x, y, [NSApp tkButtonState]);
+	}
+    }
     if (winPtr && Tk_IsMapped(winPtr)) {
-	GenerateActivateEvents(winPtr, activate);
+	GenerateActivateEvents(winPtr, flag);
     }
 }
 
 - (void) windowBoundsChanged: (NSNotification *) notification
 {
@@ -160,18 +180,24 @@
 - (void) windowEnteredFullScreen: (NSNotification *) notification
 {
 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
     TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
 #endif
+    if (![[notification object] respondsToSelector: @selector (tkLayoutChanged)]) {
+	return;
+    }
     [(TKWindow *)[notification object] tkLayoutChanged];
 }
 
 - (void) windowExitedFullScreen: (NSNotification *) notification
 {
 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
     TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
 #endif
+    if (![[notification object] respondsToSelector: @selector (tkLayoutChanged)]) {
+	return;
+    }
     [(TKWindow *)[notification object] tkLayoutChanged];
 }
 
 - (void) windowCollapsed: (NSNotification *) notification
 {
@@ -180,10 +206,11 @@
 #endif
     NSWindow *w = [notification object];
     TkWindow *winPtr = TkMacOSXGetTkWindow(w);
 
     if (winPtr) {
+	winPtr->wmInfoPtr->hints.initial_state = IconicState;
 	Tk_UnmapWindow((Tk_Window)winPtr);
     }
 }
 
 - (BOOL) windowShouldClose: (NSWindow *) w
@@ -230,24 +257,29 @@
 
     if (winPtr) {
 	while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}
     }
 }
+
+- (void) windowLiveResize: (NSNotification *) notification
+{
+    NSString *name = [notification name];
+    if ([name isEqualToString:NSWindowWillStartLiveResizeNotification]) {
+	// printf("Starting live resize.\n");
+    } else if ([name isEqualToString:NSWindowDidEndLiveResizeNotification]) {
+	[self setTkLiveResizeEnded:YES];
+	// printf("Ending live resize\n");
+    }
+}
 
 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
 
 - (void) windowDragStart: (NSNotification *) notification
 {
     TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
 }
 
-- (void) windowLiveResize: (NSNotification *) notification
-{
-    TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
-    //BOOL start = [[notification name] isEqualToString:NSWindowWillStartLiveResizeNotification];
-}
-
 - (void) windowUnmapped: (NSNotification *) notification
 {
     TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
     NSWindow *w = [notification object];
     TkWindow *winPtr = TkMacOSXGetTkWindow(w);
@@ -272,27 +304,37 @@
     observe(NSWindowDidResizeNotification, windowBoundsChanged:);
     observe(NSWindowDidDeminiaturizeNotification, windowExpanded:);
     observe(NSWindowDidMiniaturizeNotification, windowCollapsed:);
     observe(NSWindowWillOrderOnScreenNotification, windowMapped:);
     observe(NSWindowDidOrderOnScreenNotification, windowBecameVisible:);
+    observe(NSWindowWillStartLiveResizeNotification, windowLiveResize:);
+    observe(NSWindowDidEndLiveResizeNotification, windowLiveResize:);
 
 #if !(MAC_OS_X_VERSION_MAX_ALLOWED < 1070)
     observe(NSWindowDidEnterFullScreenNotification, windowEnteredFullScreen:);
     observe(NSWindowDidExitFullScreenNotification, windowExitedFullScreen:);
 #endif
 
 #ifdef TK_MAC_DEBUG_NOTIFICATIONS
     observe(NSWindowWillMoveNotification, windowDragStart:);
-    observe(NSWindowWillStartLiveResizeNotification, windowLiveResize:);
-    observe(NSWindowDidEndLiveResizeNotification, windowLiveResize:);
     observe(NSWindowDidOrderOffScreenNotification, windowUnmapped:);
 #endif
 #undef observe
 
 }
 @end
 
+
+/*
+ * Idle task which forces focus to a particular window.
+ */
+
+static void RefocusGrabWindow(void *data) {
+    TkWindow *winPtr = (TkWindow *) data;
+    TkpChangeFocus(winPtr, 1);
+}
+
 #pragma mark TKApplication(TKApplicationEvent)
 
 @implementation TKApplication(TKApplicationEvent)
 
 - (void) applicationActivate: (NSNotification *) notification
@@ -306,19 +348,28 @@
 
     /*
      * When the application is activated with Command-Tab it will create a
      * zombie window for every Tk window which has been withdrawn.  So iterate
      * through the list of windows and order out any withdrawn window.
+     * If one of the windows is the grab window for its display we focus
+     * it.  This is done as at idle, in case the app was reactivated by
+     * clicking a different window.  In that case we need to wait until the
+     * mouse event has been processed before focusing the grab window.
      */
 
     for (NSWindow *win in [NSApp windows]) {
 	TkWindow *winPtr = TkMacOSXGetTkWindow(win);
 	if (!winPtr || !winPtr->wmInfoPtr) {
 	    continue;
 	}
 	if (winPtr->wmInfoPtr->hints.initial_state == WithdrawnState) {
-	    [win orderOut:nil];
+	    [win orderOut:NSApp];
+	}
+	if (winPtr->dispPtr->grabWinPtr == winPtr) {
+	    Tcl_DoWhenIdle(RefocusGrabWindow, winPtr);
+	} else {
+	    [[self keyWindow] orderFront: self];
 	}
     }
 }
 
 - (void) applicationDeactivate: (NSNotification *) notification
@@ -404,11 +455,11 @@
  *
  *      A widget display procedure can call this to determine whether it is
  *      being run inside of the drawRect method. If not, it may be desirable
  *      for the display procedure to simply clear the REDRAW_PENDING flag
  *      and return.  The widget can be recorded in order to schedule a
- *      redraw, via and Expose event, from within drawRect.
+ *      redraw, via an Expose event, from within drawRect.
  *
  *      This is also needed for some tests, especially of the Text widget,
  *      which record data in a global Tcl variable and assume that display
  *      procedures will be run in a predictable sequence as Tcl idle tasks.
  *
@@ -519,11 +570,11 @@
     /*
      * Generate updates for any contained windows
      */
 
     if (Tk_IsContainer(winPtr)) {
-	childPtr = TkpGetOtherWindow(winPtr);
+	childPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)winPtr);
 	if (childPtr != NULL && Tk_IsMapped(childPtr)) {
 	    GenerateUpdates(updateBounds, childPtr);
 	}
 
 	/*
@@ -912,16 +963,74 @@
 {
     return (eventPtr->type==ConfigureNotify ? TK_PROCESS_EVENT : TK_DEFER_EVENT);
 }
 
 @implementation TKContentView(TKWindowEvent)
+
+- (id)initWithFrame:(NSRect)frame
+{
+    self = [super initWithFrame:frame];
+    if (self) {
+	/*
+	 * The layer must exist before we set wantsLayer to YES.
+	 */
+
+	self.layer = [CALayer layer];
+	self.wantsLayer = YES;
+	self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawOnSetNeedsDisplay;
+	self.layer.contentsGravity = self.layer.contentsAreFlipped ?
+	    kCAGravityTopLeft : kCAGravityBottomLeft;
+
+	/*
+	 * Nothing gets drawn at all if the layer does not have a delegate.
+	 * Currently, we do not implement any methods of the delegate, however.
+	 */
+
+	self.layer.delegate = (id) self;
+	trackingArea = [[NSTrackingArea alloc]
+			   initWithRect:[self bounds]
+				options:(NSTrackingMouseEnteredAndExited |
+					 NSTrackingMouseMoved |
+					 NSTrackingEnabledDuringMouseDrag |
+					 NSTrackingInVisibleRect |
+					 NSTrackingActiveAlways)
+				  owner:self
+			       userInfo:nil];
+        [self addTrackingArea:trackingArea];
+    }
+    return self;
+}
+
+/*
+ * We will just use drawRect.
+ */
+
+- (BOOL) wantsUpdateLayer
+{
+    return NO;
+}
+
+- (void) viewDidChangeBackingProperties
+{
+
+    /*
+     * Make sure that the layer uses a contentScale that matches the
+     * backing scale factor of the screen.  This avoids blurry text when
+     * the view is on a Retina display, as well as incorrect size when
+     * the view is on a normal display.
+     */
+
+    self.layer.contentsScale = self.window.screen.backingScaleFactor;
+}
 
 - (void) addTkDirtyRect: (NSRect) rect
 {
     _tkNeedsDisplay = YES;
     _tkDirtyRect = NSUnionRect(_tkDirtyRect, rect);
     [NSApp setNeedsToDraw:YES];
+    [self setNeedsDisplay:YES];
+    [[self layer] setNeedsDisplay];
 }
 
 - (void) clearTkDirtyRect
 {
     _tkNeedsDisplay = NO;
@@ -1166,10 +1275,12 @@
 - (void)observeValueForKeyPath:(NSString *)keyPath
 		      ofObject:(id)object
 			change:(NSDictionary *)change
 		       context:(void *)context
 {
+    (void) change;
+    (void) context;
     NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
     if (object == preferences && [keyPath isEqualToString:@"AppleHighlightColor"]) {
 	if (@available(macOS 10.14, *)) {
 	    [self viewDidChangeEffectiveAppearance];
 	}
@@ -1186,34 +1297,34 @@
 - (void) tkToolbarButton: (id) sender
 {
 #ifdef TK_MAC_DEBUG_EVENTS
     TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd);
 #endif
-    XVirtualEvent event;
+    union {XEvent general; XVirtualEvent virt;} event;
     int x, y;
     TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
     Tk_Window tkwin = (Tk_Window)winPtr;
     (void)sender;
 
     if (!winPtr){
 	return;
     }
-    bzero(&event, sizeof(XVirtualEvent));
-    event.type = VirtualEvent;
-    event.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
-    event.send_event = false;
-    event.display = Tk_Display(tkwin);
-    event.event = Tk_WindowId(tkwin);
-    event.root = XRootWindow(Tk_Display(tkwin), 0);
-    event.subwindow = None;
-    event.time = TkpGetMS();
+    bzero(&event, sizeof(event));
+    event.virt.type = VirtualEvent;
+    event.virt.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
+    event.virt.send_event = false;
+    event.virt.display = Tk_Display(tkwin);
+    event.virt.event = Tk_WindowId(tkwin);
+    event.virt.root = XRootWindow(Tk_Display(tkwin), 0);
+    event.virt.subwindow = None;
+    event.virt.time = TkpGetMS();
     XQueryPointer(NULL, winPtr->window, NULL, NULL,
-	    &event.x_root, &event.y_root, &x, &y, &event.state);
-    Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y);
-    event.same_screen = true;
-    event.name = Tk_GetUid("ToolbarButton");
-    Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
+	    &event.virt.x_root, &event.virt.y_root, &x, &y, &event.virt.state);
+    Tk_TopCoordsToWindow(tkwin, x, y, &event.virt.x, &event.virt.y);
+    event.virt.same_screen = true;
+    event.virt.name = Tk_GetUid("ToolbarButton");
+    Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
 }
 
 /*
  * On Catalina this is never called and drawRect clips to the rect that
  * is passed to it by AppKit.

Index: macosx/tkMacOSXWm.c
==================================================================
--- macosx/tkMacOSXWm.c
+++ macosx/tkMacOSXWm.c
@@ -3,15 +3,15 @@
  *
  *	This module takes care of the interactions between a Tk-based
  *	application and the window manager. Among other things, it implements
  *	the "wm" command and passes geometry information to the window manager.
  *
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2010 Kevin Walzer/WordTech Communications LLC.
- * Copyright (c) 2017-2019 Marc Culler.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009, Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2010 Kevin Walzer/WordTech Communications LLC.
+ * Copyright © 2017-2019 Marc Culler.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -240,10 +240,13 @@
 static int		WmGridCmd(Tk_Window tkwin, TkWindow *winPtr,
 			    Tcl_Interp *interp, int objc,
 			    Tcl_Obj *const objv[]);
 static int		WmGroupCmd(Tk_Window tkwin, TkWindow *winPtr,
 			    Tcl_Interp *interp, int objc,
+			    Tcl_Obj *const objv[]);
+static int		WmIconbadgeCmd(Tk_Window tkwin, TkWindow *winPtr,
+			    Tcl_Interp *interp, int objc,
 			    Tcl_Obj *const objv[]);
 static int		WmIconbitmapCmd(Tk_Window tkwin, TkWindow *winPtr,
 			    Tcl_Interp *interp, int objc,
 			    Tcl_Obj *const objv[]);
 static int		WmIconifyCmd(Tk_Window tkwin, TkWindow *winPtr,
@@ -360,11 +363,10 @@
 @implementation TKDrawerWindow: NSWindow
 @synthesize tkWindow = _tkWindow;
 @end
 
 @implementation TKWindow: NSWindow
-@synthesize mouseInResizeArea = _mouseInResizeArea;
 @synthesize tkWindow = _tkWindow;
 @end
 
 #pragma mark TKWindow(TKWm)
 
@@ -744,78 +746,10 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkMacOSXHandleMapOrUnmap --
- *
- *      The mechanism used by a geometry manager to propogate the information
- *      about which of its content widgets are mapped is to call Tk_MapWindow
- *      or Tk_UnmapNotify.  Those functions generate MapNotify or UnmapNotify
- *      events and then handle them immediately.  Other platforms use
- *      Tk_HandleEvent to do this.  But that does not work correctly on macOS
- *      due to the fact that the calls to Tk_MapNotify or Tk_UnmapNotify can
- *      occur in display procedures which are being run in the drawRect method
- *      of a TKContentView. The events will be processed after drawRect
- *      returns, but they need to be processed immediately in some cases.
-
- *      This function operates as a macOS alternative to Tk_HandleEvent, for
- *      processing MapNotify or UnmapNotify events only.  It is called by
- *      Tk_MapWindow, Tk_UnmapWindow, TkWmMapWindow and TkWmUnmapWindow.
- *      Rather than using Tk_HandleEvent it installs a filter which restricts
- *      to the MapNotify or UnmapNotify events, it queues the event and then
- *      processes window events with the filter installed.  This allows the
- *      event to be handled immediately even from within the drawRect method.
- *
- * Results:
- *	None.
- *
- * Side effects:
- *	Handles a MapNotify or UnMapNotify event.
- *
- *----------------------------------------------------------------------
- */
-static Tk_RestrictAction
-MapUnmapRestrictProc(
-    TCL_UNUSED(void*),
-    XEvent *eventPtr)
-{
-    return (eventPtr->type==MapNotify || eventPtr->type==UnmapNotify ?
-	    TK_PROCESS_EVENT : TK_DEFER_EVENT);
-}
-
-MODULE_SCOPE
-void TkMacOSXHandleMapOrUnmap(
-    Tk_Window tkwin,
-    XEvent *event)
-{
-    ClientData oldArg;
-    Tk_RestrictProc *oldProc;
-    TkWindow *winPtr = (TkWindow *) tkwin;
-    const Tk_GeomMgr *geomMgrPtr = winPtr->geomMgrPtr;
-
-    /*
-     * Sadly, this approach does not work with the "text" geometry manager.
-     * The mysterious unexplained crash elicited by textDisp-5.2 occurs.  So we
-     * have to check for the "text" manager and revert to using Tk_HandleEvent
-     * in that case.  Hopefully this can be removed when the revised text
-     * widget is in place.
-     */
-
-    if (geomMgrPtr && strcmp(geomMgrPtr->name, "text") == 0) {
-	Tk_HandleEvent(event);
-	return;
-    }
-    oldProc = Tk_RestrictEvents(MapUnmapRestrictProc, NULL, &oldArg);
-    Tk_QueueWindowEvent(event, TCL_QUEUE_TAIL);
-    while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {}
-    Tk_RestrictEvents(oldProc, oldArg, &oldArg);
-}
-
-/*
- *----------------------------------------------------------------------
- *
  * TkWmMapWindow --
  *
  *	This procedure is invoked to map a top-level window. This module gets
  *	a chance to update all window-manager-related information in
  *	properties before the window manager sees the map event and checks the
@@ -915,11 +849,11 @@
     event.xany.display = winPtr->display;
     event.xmap.window = winPtr->window;
     event.xmap.type = MapNotify;
     event.xmap.event = winPtr->window;
     event.xmap.override_redirect = winPtr->atts.override_redirect;
-    TkpHandleMapOrUnmap((Tk_Window)winPtr, &event);
+    Tk_HandleEvent(&event);
 }
 
 /*
  *----------------------------------------------------------------------
  *
@@ -951,11 +885,11 @@
     event.xunmap.window = winPtr->window;
     event.xunmap.event = winPtr->window;
     event.xunmap.from_configure = false;
     winPtr->flags &= ~TK_MAPPED;
     XUnmapWindow(winPtr->display, winPtr->window);
-    TkpHandleMapOrUnmap((Tk_Window)winPtr, &event);
+    Tk_HandleEvent(&event);
 }
 
 /*
  *----------------------------------------------------------------------
  *
@@ -977,10 +911,11 @@
 TkWmDeadWindow(
     TkWindow *winPtr)		/* Top-level window that's being deleted. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2;
     TKWindow *deadNSWindow;
+    TkWindow *dragTarget = [NSApp tkDragTarget];
 
     if (wmPtr == NULL) {
 	return;
     }
 
@@ -1048,18 +983,46 @@
 	Transient *transientPtr = wmPtr->transientPtr;
 
 	wmPtr->transientPtr = transientPtr->nextPtr;
 	ckfree(transientPtr);
     }
+
+    deadNSWindow = (TKWindow *)wmPtr->window;
+
+    /*
+     * Remove references to the Tk window from the mouse event processing
+     * state which is recorded in the NSApplication object.
+     */
+
+    if (dragTarget && winPtr == TkMacOSXGetHostToplevel(dragTarget)->winPtr) {
+	[NSApp setTkDragTarget:nil];
+    }
+    if (winPtr == [NSApp tkPointerWindow]) {
+	NSWindow *w;
+	NSPoint mouse = [NSEvent mouseLocation];
+	[NSApp setTkPointerWindow:nil];
+	for (w in [NSApp orderedWindows]) {
+	    if (w == deadNSWindow) {
+		continue;
+	    }
+	    if (NSPointInRect(mouse, [w frame])) {
+		TkWindow *winPtr2 = TkMacOSXGetTkWindow(w);
+		int x = mouse.x, y = TkMacOSXZeroScreenHeight() - mouse.y;
+		[NSApp setTkPointerWindow:winPtr2];
+		Tk_UpdatePointer((Tk_Window) winPtr2, x, y,
+				 [NSApp tkButtonState]);
+		break;
+	    }
+	}
+    }
 
     /*
      * Unregister the NSWindow and remove all references to it from the Tk
      * data structures.  If the NSWindow is a child, disassociate it from
      * the parent.  Then close and release the NSWindow.
      */
 
-    deadNSWindow = (TKWindow *)wmPtr->window;
     if (deadNSWindow && !Tk_IsEmbedded(winPtr)) {
 	NSWindow *parent = [deadNSWindow parentWindow];
 	[deadNSWindow setTkWindow:None];
         if (winPtr->window) {
             ((MacDrawable *)winPtr->window)->view = nil;
@@ -1092,10 +1055,17 @@
 	 * key window which prevents it from being deallocated until it stops
 	 * being the key window.  On these systems the only option for
 	 * preventing zombies is to set the key window to nil.
 	 */
 
+
+	/*
+	 * Fix bug 5692042764:
+	 * set tkEventTarget to NULL when there is no window to send Tk events to.
+	 */
+	TkWindow *newTkEventTarget = NULL;
+
 	for (NSWindow *w in [NSApp orderedWindows]) {
 	    TkWindow *winPtr2 = TkMacOSXGetTkWindow(w);
 	    BOOL isOnScreen;
 
 	    if (!winPtr2 || !winPtr2->wmInfoPtr) {
@@ -1104,13 +1074,16 @@
 	    wmPtr2 = winPtr2->wmInfoPtr;
 	    isOnScreen = (wmPtr2->hints.initial_state != IconicState &&
 			  wmPtr2->hints.initial_state != WithdrawnState);
 	    if (w != deadNSWindow && isOnScreen && [w canBecomeKeyWindow]) {
 		[w makeKeyAndOrderFront:NSApp];
+		newTkEventTarget = TkMacOSXGetTkWindow(w);
 		break;
 	    }
 	}
+
+	[NSApp setTkEventTarget:newTkEventTarget];
 
 	/*
 	 * Prevent zombies on systems with a TouchBar.
 	 */
 
@@ -1118,11 +1091,10 @@
 	    [NSApp _setKeyWindow:nil];
 	    [NSApp _setMainWindow:nil];
 	}
 	[deadNSWindow close];
 	[deadNSWindow release];
-	[NSApp _resetAutoreleasePool];
 
 #if DEBUG_ZOMBIES > 1
 	fprintf(stderr, "================= Pool dump ===================\n");
 	[NSAutoreleasePool showPools];
 #endif
@@ -1189,21 +1161,21 @@
 {
     Tk_Window tkwin = (Tk_Window)clientData;
     static const char *const optionStrings[] = {
 	"aspect", "attributes", "client", "colormapwindows",
 	"command", "deiconify", "focusmodel", "forget",
-	"frame", "geometry", "grid", "group",
+	"frame", "geometry", "grid", "group", "iconbadge",
 	"iconbitmap", "iconify", "iconmask", "iconname",
 	"iconphoto", "iconposition", "iconwindow",
 	"manage", "maxsize", "minsize", "overrideredirect",
 	"positionfrom", "protocol", "resizable", "sizefrom",
 	"stackorder", "state", "title", "transient",
 	"withdraw", NULL };
     enum options {
 	WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
 	WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FORGET,
-	WMOPT_FRAME, WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP,
+	WMOPT_FRAME, WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP,  WMOPT_ICONBADGE,
 	WMOPT_ICONBITMAP, WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME,
 	WMOPT_ICONPHOTO, WMOPT_ICONPOSITION, WMOPT_ICONWINDOW,
 	WMOPT_MANAGE, WMOPT_MAXSIZE, WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT,
 	WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM,
 	WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT,
@@ -1224,11 +1196,11 @@
 	if ((objc != 2) && (objc != 3)) {
 	    Tcl_WrongNumArgs(interp, 2, objv, "?boolean?");
 	    return TCL_ERROR;
 	}
 	if (objc == 2) {
-	    Tcl_SetObjResult(interp, Tcl_NewWideIntObj(wmTracing != 0));
+	    Tcl_SetObjResult(interp, Tcl_NewBooleanObj(wmTracing));
 	    return TCL_OK;
 	}
 	return Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing);
     }
 
@@ -1277,10 +1249,12 @@
 	return WmGeometryCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_GRID:
 	return WmGridCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_GROUP:
 	return WmGroupCmd(tkwin, winPtr, interp, objc, objv);
+    case WMOPT_ICONBADGE:
+	return WmIconbadgeCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_ICONBITMAP:
 	return WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_ICONIFY:
 	return WmIconifyCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_ICONMASK:
@@ -1480,11 +1454,11 @@
 	    }
 	    tkMacOSXWmAttrNotifyVal = boolean;
 	}
 	break;
     case WMATT_TITLEPATH: {
-	const char *path = Tcl_FSGetNativePath(value);
+	const char *path = (const char *)Tcl_FSGetNativePath(value);
 	NSString *filename = @"";
 
 	if (path && *path) {
 	    filename = [NSString stringWithUTF8String:path];
 	}
@@ -1566,24 +1540,24 @@
 	break;
     case WMATT_FULLSCREEN:
 	result = Tcl_NewBooleanObj([macWindow styleMask] & NSFullScreenWindowMask);
 	break;
     case WMATT_MODIFIED:
-	result = Tcl_NewWideIntObj([macWindow isDocumentEdited] != 0);
+	result = Tcl_NewBooleanObj([macWindow isDocumentEdited]);
 	break;
     case WMATT_NOTIFY:
-	result = Tcl_NewWideIntObj(tkMacOSXWmAttrNotifyVal != 0);
+	result = Tcl_NewBooleanObj(tkMacOSXWmAttrNotifyVal);
 	break;
     case WMATT_TITLEPATH:
 	result = Tcl_NewStringObj([[macWindow representedFilename] UTF8String],
 		-1);
 	break;
     case WMATT_TOPMOST:
-	result = Tcl_NewWideIntObj((wmPtr->flags & WM_TOPMOST) != 0);
+	result = Tcl_NewBooleanObj(wmPtr->flags & WM_TOPMOST);
 	break;
     case WMATT_TRANSPARENT:
-	result = Tcl_NewWideIntObj((wmPtr->flags & WM_TRANSPARENT) != 0);
+	result = Tcl_NewBooleanObj(wmPtr->flags & WM_TRANSPARENT);
 	break;
     case WMATT_TYPE:
 	result = Tcl_NewStringObj("unsupported", -1);
 	break;
     case _WMATT_LAST_ATTRIBUTE:
@@ -1634,28 +1608,28 @@
 
 	for (attribute = 0; attribute < _WMATT_LAST_ATTRIBUTE; ++attribute) {
 	    Tcl_ListObjAppendElement(NULL, result,
 		    Tcl_NewStringObj(WmAttributeNames[attribute], -1));
 	    Tcl_ListObjAppendElement(NULL, result,
-		    WmGetAttribute(winPtr, macWindow, attribute));
+		    WmGetAttribute(winPtr, macWindow, (WmAttribute)attribute));
 	}
 	Tcl_SetObjResult(interp, result);
     } else if (objc == 4) {	/* wm attributes $win -attribute */
 	if (Tcl_GetIndexFromObjStruct(interp, objv[3], WmAttributeNames,
 		sizeof(char *), "attribute", 0, &attribute) != TCL_OK) {
 	    return TCL_ERROR;
 	}
-	Tcl_SetObjResult(interp, WmGetAttribute(winPtr, macWindow, attribute));
+	Tcl_SetObjResult(interp, WmGetAttribute(winPtr, macWindow, (WmAttribute)attribute));
     } else if ((objc - 3) % 2 == 0) {	/* wm attributes $win -att value... */
 	int i;
 
 	for (i = 3; i < objc; i += 2) {
 	    if (Tcl_GetIndexFromObjStruct(interp, objv[i], WmAttributeNames,
 		    sizeof(char *), "attribute", 0, &attribute) != TCL_OK) {
 		return TCL_ERROR;
 	    }
-	    if (WmSetAttribute(winPtr, macWindow, interp, attribute, objv[i+1])
+	    if (WmSetAttribute(winPtr, macWindow, interp, (WmAttribute)attribute, objv[i+1])
 		    != TCL_OK) {
 		return TCL_ERROR;
 	    }
 	}
     } else {
@@ -1801,11 +1775,11 @@
     }
     wmPtr->cmapList = cmapList;
     wmPtr->cmapCount = windowObjc;
 
     /*
-     * On the Macintosh all of this is just an excercise in compatability as
+     * On the Macintosh all of this is just an excercise in compatibility as
      * we don't support colormaps. If we did they would be installed here.
      */
 
     return TCL_OK;
 }
@@ -1940,10 +1914,12 @@
 		transientPtr->flags &= ~WITHDRAWN_BY_CONTAINER;
 	    }
 	}
     }
 
+    [[win contentView] setNeedsDisplay:YES];
+    Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL);
     return TCL_OK;
 }
 
 /*
  *----------------------------------------------------------------------
@@ -2333,10 +2309,78 @@
 	wmPtr->leaderName = (char *)ckalloc(length + 1);
 	strcpy(wmPtr->leaderName, argv3);
     }
     return TCL_OK;
 }
+
+ /*----------------------------------------------------------------------
+ *
+ * WmIconbadgeCmd --
+ *
+ *	This procedure is invoked to process the "wm iconbadge" Tcl command.
+ *	See the user documentation for details on what it does.
+ *
+ * Results:
+ *	A standard Tcl result.
+ *
+ * Side effects:
+ *	See the user documentation.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+WmIconbadgeCmd(
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
+    TkWindow *winPtr,		/* Toplevel to work with */
+    Tcl_Interp *interp,		/* Current interpreter. */
+    int objc,			/* Number of arguments. */
+    Tcl_Obj *const objv[])	/* Argument objects. */
+{
+    (void) winPtr;
+    NSString *label;
+
+    if (objc < 4) {
+	Tcl_WrongNumArgs(interp, 2, objv,"window badge");
+	return TCL_ERROR;
+    }
+
+    label = [NSString stringWithUTF8String:Tcl_GetString(objv[3])];
+
+    int number = [label intValue];
+    NSDockTile *dockicon = [NSApp dockTile];
+
+    /*
+     * First, check that the label is not a decimal. If it is,
+     * return an error.
+     */
+
+    if ([label containsString:@"."]) {
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"can't use \"%s\" as icon badge", Tcl_GetString(objv[3])));
+	return TCL_ERROR;
+    }
+
+    /*
+     * Next, check that label is an int, empty string, or exclamation
+     * point. If so, set the icon badge on the Dock icon. Otherwise,
+     * return an error.
+     */
+
+    NSArray *array = @[@"", @"!"];
+    if ([array containsObject: label]) {
+	[dockicon setBadgeLabel:label];
+    } else if (number > 0) {
+	NSString *str = [@(number) stringValue];
+	[dockicon setBadgeLabel:str];
+    } else {
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"can't use \"%s\" as icon badge", Tcl_GetString(objv[3])));
+	return TCL_ERROR;
+    }
+    return TCL_OK;
+}
 
 /*
  *----------------------------------------------------------------------
  *
  * WmIconbitmapCmd --
@@ -2623,11 +2667,11 @@
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     Tk_Image tk_icon;
-    int width, height, isDefault = 0;
+    int width, height;
     NSImage *newIcon = NULL;
 
     if (objc < 4) {
 	Tcl_WrongNumArgs(interp, 2, objv,
 			 "window ?-default? image1 ?image2 ...?");
@@ -2637,11 +2681,10 @@
     /*
      * Parse args.
      */
 
     if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) {
-	isDefault = 1;
 	if (objc == 4) {
 	    Tcl_WrongNumArgs(interp, 2, objv,
 		    "window ?-default? image1 ?image2 ...?");
 	    return TCL_ERROR;
 	}
@@ -2823,11 +2866,11 @@
 	    /*
 	     * The old icon should be withdrawn.
 	     */
 
 	    TkpWmSetState(oldIcon, WithdrawnState);
-	    [win orderOut:nil];
+	    [win orderOut:NSApp];
     	    [win setExcludedFromWindowsMenu:YES];
 	    wmPtr3->iconFor = NULL;
 	}
 	Tk_MakeWindowExist(tkwin2);
 	wmPtr->hints.icon_window = Tk_WindowId(tkwin2);
@@ -2866,13 +2909,13 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmManageCmd(
-    TCL_UNUSED(Tk_Window),		/* Main window of the application. */
-    TkWindow *winPtr,           /* Toplevel or Frame to work with */
-    Tcl_Interp *interp,		/* Current interpreter. */
+    TCL_UNUSED(Tk_Window),	        /* Main window of the application. */
+    TkWindow *winPtr,           	/* Toplevel or Frame to work with */
+    Tcl_Interp *interp,			/* Current interpreter. */
     TCL_UNUSED(int),			/* Number of arguments. */
     TCL_UNUSED(Tcl_Obj *const *))	/* Argument objects. */
 {
     Tk_Window frameWin = (Tk_Window)winPtr;
     WmInfo *wmPtr = winPtr->wmInfoPtr;
@@ -2886,10 +2929,22 @@
 		    " frame, labelframe or toplevel",
 		    Tk_PathName(frameWin)));
 	    Tcl_SetErrorCode(interp, "TK", "WM", "MANAGE", NULL);
 	    return TCL_ERROR;
 	}
+
+	/*
+	 * Draw the managed widget at the top left corner of its toplevel.
+	 * See [4a40c6cace].
+	 */
+
+	if (macWin) {
+	    winPtr->changes.x -= macWin->xOff;
+	    winPtr->changes.y -= macWin->yOff;
+	    XMoveWindow(winPtr->display, winPtr->window, 0, 0);
+	}
+
 	TkFocusSplit(winPtr);
 	Tk_UnmapWindow(frameWin);
 	if (wmPtr == NULL) {
 	    TkWmNewWindow(winPtr);
 	    if (winPtr->window == None) {
@@ -3055,11 +3110,11 @@
 	return TCL_ERROR;
     }
 
     if (objc == 3) {
 	Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
-		Tk_Attributes((Tk_Window) winPtr)->override_redirect));
+		Tk_Attributes((Tk_Window)winPtr)->override_redirect));
 	return TCL_OK;
     }
 
     if (Tcl_GetBooleanFromObj(interp, objv[3], &flag) != TCL_OK) {
 	return TCL_ERROR;
@@ -3273,14 +3328,12 @@
     }
 
     if (objc == 3) {
 	Tcl_Obj *results[2];
 
-	results[0] = Tcl_NewWideIntObj(
-		(wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) == 0);
-	results[1] = Tcl_NewWideIntObj(
-		(wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) == 0);
+	results[0] = Tcl_NewBooleanObj(!(wmPtr->flags & WM_WIDTH_NOT_RESIZABLE));
+	results[1] = Tcl_NewBooleanObj(!(wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE));
 	Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
 	return TCL_OK;
     }
 
     if ((Tcl_GetBooleanFromObj(interp, objv[3], &width) != TCL_OK)
@@ -3501,11 +3554,11 @@
 	if (index == OPT_ISABOVE) {
 	    result = index1 > index2;
 	} else { /* OPT_ISBELOW */
 	    result = index1 < index2;
 	}
-	Tcl_SetObjResult(interp, Tcl_NewWideIntObj(result != 0));
+	Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result));
 	return TCL_OK;
     }
 }
 
 /*
@@ -3533,13 +3586,13 @@
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     static const char *const optionStrings[] = {
-	"normal", "iconic", "withdrawn", "zoomed", NULL };
+	"iconic", "normal", "withdrawn", "zoomed", NULL };
     enum options {
-	OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN, OPT_ZOOMED };
+	OPT_ICONIC, OPT_NORMAL, OPT_WITHDRAWN, OPT_ZOOMED };
     int index;
 
     if ((objc < 3) || (objc > 4)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?state?");
 	return TCL_ERROR;
@@ -3722,10 +3775,11 @@
 	RemoveTransient(winPtr);
     } else {
 	if (TkGetWindowFromObj(interp, tkwin, objv[3], &container) != TCL_OK) {
 	    return TCL_ERROR;
 	}
+	RemoveTransient(winPtr);
 	containerPtr = (TkWindow*) container;
 	while (!Tk_TopWinHierarchy(containerPtr)) {
             /*
              * Ensure that the container window is actually a Tk toplevel.
              */
@@ -3755,11 +3809,11 @@
 	    Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
 	    return TCL_ERROR;
 	}
 
 	for (w = containerPtr; w != NULL && w->wmInfoPtr != NULL;
-		w = (TkWindow *)w->wmInfoPtr->container) {
+	    w = (TkWindow *)w->wmInfoPtr->container) {
 	    if (w == winPtr) {
 		Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 		    "can't set \"%s\" as container: would cause management loop",
 		    Tk_PathName(containerPtr)));
 		Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL);
@@ -4116,11 +4170,11 @@
 static void
 TopLevelEventProc(
     ClientData clientData,	/* Window for which event occurred. */
     XEvent *eventPtr)		/* Event that just happened. */
 {
-    TkWindow *winPtr = clientData;
+    TkWindow *winPtr = (TkWindow *)clientData;
 
     winPtr->wmInfoPtr->flags |= WM_VROOT_OFFSET_STALE;
     if (eventPtr->type == DestroyNotify) {
 	if (!(winPtr->flags & TK_ALREADY_DEAD)) {
 	    /*
@@ -4202,11 +4256,11 @@
 
 static void
 UpdateGeometryInfo(
     ClientData clientData)	/* Pointer to the window's record. */
 {
-    TkWindow *winPtr = clientData;
+    TkWindow *winPtr = (TkWindow *)clientData;
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     int x, y, width, height, min, max;
 
     wmPtr->flags &= ~WM_UPDATE_PENDING;
 
@@ -4329,11 +4383,11 @@
      *    ICCCM. Moving a window to its current location may cause it to shift
      *    position on the screen.
      */
 
     if (Tk_IsEmbedded(winPtr)) {
-	TkWindow *contWinPtr = TkpGetOtherWindow(winPtr);
+	Tk_Window contWinPtr = Tk_GetOtherWindow((Tk_Window)winPtr);
 
 	/*
 	 * TODO: Here we should handle out of process embedding.
 	 */
 
@@ -4346,11 +4400,11 @@
 	     * embedded windows are not allowed to move.
 	     */
 
 	    wmPtr->x = wmPtr->y = 0;
 	    wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y);
-	    Tk_GeometryRequest((Tk_Window)contWinPtr, width, height);
+	    Tk_GeometryRequest(contWinPtr, width, height);
 	}
 	return;
     }
     if (wmPtr->flags & WM_MOVE_PENDING) {
 	wmPtr->configWidth = width;
@@ -4619,11 +4673,11 @@
 		x += winPtr->wmInfoPtr->xInParent;
 		y += winPtr->wmInfoPtr->yInParent;
 		break;
 	    }
 
-	    otherPtr = TkpGetOtherWindow(winPtr);
+	    otherPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)winPtr);
 	    if (otherPtr == NULL) {
 		break;
 	    }
 
 	    /*
@@ -4702,11 +4756,11 @@
 	 * Container windows cannot have children. So if it is a container,
 	 * look there, otherwise inspect the children.
 	 */
 
 	if (Tk_IsContainer(winPtr)) {
-	    childPtr = TkpGetOtherWindow(winPtr);
+	    childPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)winPtr);
 	    if (childPtr != NULL) {
 		if (Tk_IsMapped(childPtr)) {
 		    tmpx = x - childPtr->changes.x;
 		    tmpy = y - childPtr->changes.y;
 		    bd = childPtr->changes.border_width;
@@ -4783,26 +4837,24 @@
 {
     TkWindow *winPtr, *childPtr;
     TkWindow *nextPtr;		/* Coordinates of highest child found so far
 				 * that contains point. */
     int x, y;			/* Coordinates in winPtr. */
-    Window *children;		/* Children of winPtr, or NULL. */
 
     winPtr = (TkWindow *)tkwin;
     x = rootX;
     y = rootY;
     while (1) {
 	nextPtr = NULL;
-	children = NULL;
 
 	/*
 	 * Container windows cannot have children. So if it is a container,
 	 * look there, otherwise inspect the children.
 	 */
 
 	if (Tk_IsContainer(winPtr)) {
-	    childPtr = TkpGetOtherWindow(winPtr);
+	    childPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)winPtr);
 	    if (childPtr != NULL) {
 		if (Tk_IsMapped(childPtr) &&
 			x > childPtr->changes.x &&
 			x < childPtr->changes.x + childPtr->changes.width &&
 			y > childPtr->changes.y &&
@@ -5182,11 +5234,11 @@
 
     topPtr->wmInfoPtr->cmapList = newPtr;
     topPtr->wmInfoPtr->cmapCount = count+1;
 
     /*
-     * On the Macintosh all of this is just an excercise in compatability as
+     * On the Macintosh all of this is just an excercise in compatibility as
      * we don't support colormaps. If we did they would be installed here.
      */
 }
 
 /*
@@ -5417,11 +5469,11 @@
 {
     if (Tk_IsEmbedded(winPtr)) {
 	return;
     }
 
-    NSString *title = [[NSString alloc] initWithUTF8String:titleUid];
+    NSString *title = [[TKNSString alloc] initWithTclUtfBytes:titleUid length:-1];
     [TkMacOSXGetNSWindowForDrawable(winPtr->window) setTitle:title];
     [title release];
 }
 
 /*
@@ -5502,16 +5554,19 @@
 Tk_Window
 Tk_MacOSXGetTkWindow(
     void *w)
 {
     Window window = None;
-    TkDisplay *dispPtr = TkGetDisplayList();
     if ([(NSWindow *)w respondsToSelector: @selector (tkWindow)]) {
 	window = [(TKWindow *)w tkWindow];
     }
-    return (window != None ?
-	    Tk_IdToWindow(dispPtr->display, window) : NULL);
+    if (window) {
+	TkDisplay *dispPtr = TkGetDisplayList();
+	return Tk_IdToWindow(dispPtr->display, window);
+    } else {
+	return NULL;
+    }
 }
 
 /*
  *----------------------------------------------------------------------
  *
@@ -5560,12 +5615,12 @@
 int
 TkMacOSXZoomToplevel(
     void *whichWindow,		/* The Macintosh window to zoom. */
     short zoomPart)		/* Either inZoomIn or inZoomOut */
 {
-    NSWindow *window = whichWindow;
-    TkWindow *winPtr = TkMacOSXGetTkWindow(window);
+    NSWindow *window = (NSWindow *)whichWindow;
+    TkWindow *winPtr = (TkWindow *)TkMacOSXGetTkWindow(window);
     WmInfo *wmPtr;
 
     if (!winPtr || !winPtr->wmInfoPtr) {
 	return false;
     }
@@ -5613,16 +5668,16 @@
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     static const char *const subcmds[] = {
-	"style", "tabbingid", "appearance", "isdark", NULL
+	"appearance", "isdark", "style", "tabbingid", NULL
     };
     enum SubCmds {
-	TKMWS_STYLE, TKMWS_TABID, TKMWS_APPEARANCE, TKMWS_ISDARK
+	TKMWS_APPEARANCE, TKMWS_ISDARK, TKMWS_STYLE, TKMWS_TABID
     };
-    Tk_Window tkwin = clientData;
+    Tk_Window tkwin = (Tk_Window)clientData;
     TkWindow *winPtr;
     int index;
 
     if (objc < 3) {
 	Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?");
@@ -5911,11 +5966,18 @@
     Tcl_Interp *interp,		/* Current interpreter. */
     TkWindow *winPtr,		/* Window to be manipulated. */
     int objc,			/* Number of arguments. */
     Tcl_Obj * const objv[])	/* Argument objects. */
 {
-#if !(MAC_OS_X_VERSION_MAX_ALLOWED < 101200)
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
+    (void) interp;
+    (void) winPtr;
+    (void) objc;
+    (void) objv;
+    return TCL_OK;
+#endif
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
     Tcl_Obj *result = NULL;
     NSString *idString;
     NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window);
     if (win) {
 	idString = win.tabbingIdentifier;
@@ -5962,11 +6024,11 @@
  *	This procedure is invoked to process the
  *	"::tk::unsupported::MacWindowStyle appearance" subcommand. The command
  *	allows you to get or set the appearance for the NSWindow associated
  *	with a Tk Window.  The syntax is:
  *
- *	    tk::unsupported::MacWindowStyle tabbingid window ?newAppearance?
+ *	    tk::unsupported::MacWindowStyle appearance window ?newAppearance?
  *
  *      Allowed appearance names are "aqua", "darkaqua", and "auto".
  *
  * Results:
  *      Returns the appearance setting of the window prior to calling this
@@ -5990,16 +6052,23 @@
     Tcl_Interp *interp,		/* Current interpreter. */
     TkWindow *winPtr,		/* Window to be manipulated. */
     int objc,			/* Number of arguments. */
     Tcl_Obj * const objv[])	/* Argument objects. */
 {
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1090
+    (void) interp;
+    (void) winPtr;
+    (void) objc;
+    (void) objv;
+    return TCL_OK;
+#endif
 #if MAC_OS_X_VERSION_MAX_ALLOWED > 1090
     static const char *const appearanceStrings[] = {
-	"aqua", "darkaqua", "auto", NULL
+	"aqua", "auto", "darkaqua", NULL
     };
     enum appearances {
-	APPEARANCE_AQUA, APPEARANCE_DARKAQUA, APPEARANCE_AUTO
+	APPEARANCE_AQUA, APPEARANCE_AUTO, APPEARANCE_DARKAQUA
     };
     Tcl_Obj *result = NULL;
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
     NSAppearanceName appearance;
 #else
@@ -6028,13 +6097,13 @@
 	return TCL_OK;
     }
     if (objc == 4) {
 	int index;
 	if (Tcl_GetIndexFromObjStruct(interp, objv[3], appearanceStrings,
-                sizeof(char *), "appearancename", 0, &index) != TCL_OK) {
-            return TCL_ERROR;
-        }
+		sizeof(char *), "appearancename", 0, &index) != TCL_OK) {
+	    return TCL_ERROR;
+	}
 	switch ((enum appearances) index) {
 	case APPEARANCE_AQUA:
 	    win.appearance = [NSAppearance appearanceNamed:
 		NSAppearanceNameAqua];
 	    break;
@@ -6131,11 +6200,11 @@
      * If this is embedded, make sure its container's toplevel exists, then
      * return...
      */
 
     if (Tk_IsEmbedded(winPtr)) {
-	TkWindow *contWinPtr = TkpGetOtherWindow(winPtr);
+	TkWindow *contWinPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)winPtr);
 
 	if (contWinPtr != NULL) {
 	    TkMacOSXMakeRealWindowExist(
 		    contWinPtr->privatePtr->toplevel->winPtr);
 	    macWin->flags |= TK_HOST_EXISTS;
@@ -6198,11 +6267,11 @@
     TKContentView *contentView = [[TKContentView alloc]
 				     initWithFrame:NSZeroRect];
     [window setContentView:contentView];
     [contentView release];
     [window setDelegate:NSApp];
-    [window setAcceptsMouseMovedEvents:YES];
+    [window setAcceptsMouseMovedEvents:NO];
     [window setReleasedWhenClosed:NO];
     if (styleMask & NSUtilityWindowMask) {
 	[(TKPanel*)window setFloatingPanel:YES];
     }
     if ((styleMask & (NSTexturedBackgroundWindowMask|NSHUDWindowMask)) &&
@@ -6231,10 +6300,11 @@
 
     	atts.override_redirect = True;
     	Tk_ChangeWindowAttributes((Tk_Window)winPtr, CWOverrideRedirect, &atts);
     	ApplyContainerOverrideChanges(winPtr, NULL);
     }
+    [window display];
 }
 
 /*
  *----------------------------------------------------------------------
  *
@@ -6269,12 +6339,11 @@
 	TkMacOSXWinBounds(winPtr, &tkBounds);
 	bounds = NSMakeRect(tkBounds.left,
 			    [view bounds].size.height - tkBounds.bottom,
 			    tkBounds.right - tkBounds.left,
 			    tkBounds.bottom - tkBounds.top);
-	[view setTkNeedsDisplay:YES];
-	[view setTkDirtyRect:bounds];
+	[view addTkDirtyRect:bounds];
     }
 }
 
 
 /*
@@ -6403,10 +6472,23 @@
 	return;
     }
 
     macWin = TkMacOSXGetNSWindowForDrawable(winPtr->window);
 
+    /*
+     * Make sure windows are updated before the state change.  As an exception,
+     * do not process idle tasks before withdrawing a window.  The purpose of
+     * this is to support the common paradigm of immediately withdrawing the
+     * root window.  Processing idle tasks before changing the state causes the
+     * root to briefly flash on the screen, which users of this paradigm find
+     * annoying.  Not processing the events does not guarantee that the window
+     * will not appear but makes it more likely.
+     */
+
+    if (state != WithdrawnState) {
+	while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {};
+    }
     if (state == WithdrawnState) {
 	Tk_UnmapWindow((Tk_Window)winPtr);
     } else if (state == IconicState) {
 
 	/*
@@ -6423,12 +6505,13 @@
 	Tk_MapWindow((Tk_Window)winPtr);
 	[macWin deminiaturize:NSApp];
 	[macWin orderFront:NSApp];
 	TkMacOSXZoomToplevel(macWin, state == NormalState ? inZoomIn : inZoomOut);
     }
+
     /*
-     * Make sure windows are updated after the state change.
+     * Make sure windows are updated after the state change too.
      */
 
     while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){}
 }
 
@@ -6585,10 +6668,11 @@
     	if (force) {
     	    [NSApp activateIgnoringOtherApps:YES];
     	}
 	if (win && [win canBecomeKeyWindow]) {
 	    [win makeKeyAndOrderFront:NSApp];
+	    [NSApp setTkEventTarget:TkMacOSXGetTkWindow(win)];
 	}
     }
 
     /*
      * Remember the current serial number for the X server and issue a dummy
@@ -6677,11 +6761,11 @@
 	Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS);
 	WmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table);
 	for (NSWindow *w in backToFront) {
 	    hPtr = Tcl_FindHashEntry(&table, (char*) w);
 	    if (hPtr != NULL) {
-		childWinPtr = Tcl_GetHashValue(hPtr);
+		childWinPtr = (TkWindow *)Tcl_GetHashValue(hPtr);
 		*windowPtr++ = childWinPtr;
 	    }
 	}
 	*windowPtr = NULL;
 	Tcl_DeleteHashTable(&table);
@@ -6860,11 +6944,11 @@
 		     * allow the window to be resized when it is a split
 		     * window. To work around this we make the max size equal
 		     * to the screen size.  (For 10.11 and up, only)
 		     */
 
-		    if (@available(macOS 10.11, *)) {
+		    if ([NSApp macOSVersion] >= 101100) {
 			NSSize screenSize = [[macWindow screen] frame].size;
 			[macWindow setMaxFullScreenContentSize:screenSize];
 		    }
 		}
 	    }
@@ -7002,11 +7086,11 @@
 	    [macWindow setStyleMask:styleMask];
 	    [macWindow setTitle:[NSString stringWithUTF8String:title]];
 	    [macWindow setExcludedFromWindowsMenu:NO];
 	    wmPtr->flags &= ~WM_TOPMOST;
 	}
-	if (wmPtr->container != None) {
+	if (wmPtr->container != NULL) {
 	    TkWindow *containerWinPtr = (TkWindow *)wmPtr->container;
 
 	    if (containerWinPtr && (containerWinPtr->window != None)
 		    && TkMacOSXHostToplevelExists(containerWinPtr)) {
 		NSWindow *containerMacWin = TkMacOSXGetNSWindowForDrawable(

Index: macosx/tkMacOSXWm.h
==================================================================
--- macosx/tkMacOSXWm.h
+++ macosx/tkMacOSXWm.h
@@ -1,12 +1,12 @@
 /*
  * tkMacOSXWm.h --
  *
  *	Declarations of Macintosh specific window manager structures.
  *
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2001-2009 Apple Inc.
+ * Copyright © 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: macosx/tkMacOSXXCursors.h
==================================================================
--- macosx/tkMacOSXXCursors.h
+++ macosx/tkMacOSXXCursors.h
@@ -3,13 +3,13 @@
  *
  *	This file defines a set of Macintosh cursors that
  *	emulate the X cursor set. All of these cursors were
  *	constructed and donated by Grant Neufeld. (gneufeld@ccs.carleton.ca)
  *
- * Copyright (c) 1995-1996 Sun Microsystems, Inc.
- * Copyright 2008-2009, Apple Inc.
- * Copyright (c) 2008-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 1995-1996 Sun Microsystems, Inc.
+ * Copyright © 2008-2009 Apple Inc.
+ * Copyright © 2008-2009 Daniel A. Steffen <das@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: macosx/tkMacOSXXStubs.c
==================================================================
--- macosx/tkMacOSXXStubs.c
+++ macosx/tkMacOSXXStubs.c
@@ -4,14 +4,14 @@
  *	This file contains most of the X calls called by Tk. Many of these
  *	calls are just stubs and either don't make sense on the Macintosh or
  *	their implementation just doesn't do anything. Other calls will
  *	eventually be moved into other files.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright 2014 Marc Culler.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 2001-2009, Apple Inc.
+ * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright © 2014 Marc Culler.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -875,11 +875,11 @@
      */
 
     display->request++;
     return Success;
 }
-
+
 int
 XSetClipRectangles(
     Display *d,
     GC gc,
     int clip_x_origin,

Index: macosx/ttkMacOSXTheme.c
==================================================================
--- macosx/ttkMacOSXTheme.c
+++ macosx/ttkMacOSXTheme.c
@@ -4,13 +4,13 @@
  *      Tk theme engine for Mac OSX, using the Appearance Manager API.
  *
  * Copyright (c) 2004 Joe English
  * Copyright (c) 2005 Neil Madden
  * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright 2008-2009, Apple Inc.
- * Copyright 2009 Kevin Walzer/WordTech Communications LLC.
- * Copyright 2019 Marc Culler
+ * Copyright (c) 2008-2009 Apple Inc.
+ * Copyright (c) 2009 Kevin Walzer/WordTech Communications LLC.
+ * Copyright (c) 2019 Marc Culler
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
  * See also:
@@ -29,126 +29,161 @@
  *      window, not to the Tk_Window.  BoxToRect() accounts for this.
  */
 
 #include "tkMacOSXPrivate.h"
 #include "ttk/ttkTheme.h"
+#include "ttkMacOSXTheme.h"
+#include "tkColor.h"
 #include <math.h>
 
-/*
- * Macros for handling drawing contexts.
- */
-
-#define BEGIN_DRAWING(d) {	   \
-	TkMacOSXDrawingContext dc; \
-	if (!TkMacOSXSetupDrawingContext((d), NULL, &dc)) {return;}
-#define END_DRAWING \
-    TkMacOSXRestoreDrawingContext(&dc);}
-
-#define HIOrientation kHIThemeOrientationNormal
-#define NoThemeMetric 0xFFFFFFFF
-
-#ifdef __LP64__
-#define RangeToFactor(maximum) (((double) (INT_MAX >> 1)) / (maximum))
-#else
-#define RangeToFactor(maximum) (((double) (LONG_MAX >> 1)) / (maximum))
-#endif /* __LP64__ */
-
-#define TTK_STATE_FIRST_TAB     TTK_STATE_USER1
-#define TTK_STATE_LAST_TAB      TTK_STATE_USER2
-#define TTK_TREEVIEW_STATE_SORTARROW    TTK_STATE_USER1
-
-/*
- * Colors and gradients used in Dark Mode.
- */
-
-static CGFloat darkButtonFace[4] = {
-    112.0 / 255, 113.0 / 255, 115.0 / 255, 1.0
-};
-static CGFloat darkPressedBevelFace[4] = {
-    135.0 / 255, 136.0 / 255, 138.0 / 255, 1.0
-};
-static CGFloat darkSelectedBevelFace[4] = {
-    162.0 / 255, 163.0 / 255, 165.0 / 255, 1.0
-};
-static CGFloat darkDisabledButtonFace[4] = {
-    86.0 / 255, 87.0 / 255, 89.0 / 255, 1.0
-};
-static CGFloat darkInactiveSelectedTab[4] = {
-    159.0 / 255, 160.0 / 255, 161.0 / 255, 1.0
-};
-static CGFloat darkFocusRing[4] = {
-    38.0 / 255, 113.0 / 255, 159.0 / 255, 1.0
-};
-static CGFloat darkFocusRingTop[4] = {
-    50.0 / 255, 124.0 / 255, 171.0 / 255, 1.0
-};
-static CGFloat darkFocusRingBottom[4] = {
-    57.0 / 255, 130.0 / 255, 176.0 / 255, 1.0
-};
-static CGFloat darkTabSeparator[4] = {0.0, 0.0, 0.0, 0.25};
-static CGFloat darkTrack[4] = {1.0, 1.0, 1.0, 0.25};
-static CGFloat darkFrameTop[4] = {1.0, 1.0, 1.0, 0.0625};
-static CGFloat darkFrameBottom[4] = {1.0, 1.0, 1.0, 0.125};
-static CGFloat darkFrameAccent[4] = {0.0, 0.0, 0.0, 0.0625};
-static CGFloat darkTopGradient[8] = {
-    1.0, 1.0, 1.0, 0.3,
-    1.0, 1.0, 1.0, 0.0
-};
-static CGFloat darkBackgroundGradient[8] = {
-    0.0, 0.0, 0.0, 0.1,
-    0.0, 0.0, 0.0, 0.25
-};
-static CGFloat darkInactiveGradient[8] = {
-    89.0 / 255, 90.0 / 255, 93.0 / 255, 1.0,
-    119.0 / 255, 120.0 / 255, 122.0 / 255, 1.0
-};
-static CGFloat darkSelectedGradient[8] = {
-    23.0 / 255, 111.0 / 255, 232.0 / 255, 1.0,
-    20.0 / 255, 94.0 / 255,  206.0 / 255, 1.0
-};
-static CGFloat pressedPushButtonGradient[8] = {
-    35.0 / 255, 123.0 / 255, 244.0 / 255, 1.0,
-    30.0 / 255, 114.0 / 255, 235.0 / 255, 1.0
-};
-
-/*
- * When building on systems earlier than 10.8 there is no reasonable way to
- * convert an NSColor to a CGColor.  We do run-time checking of the OS version,
- * and never need the CGColor property on older systems, so we can use this
- * CGCOLOR macro, which evaluates to NULL without raising compiler warnings.
- * Similarly, we never draw rounded rectangles on older systems which did not
- * have CGPathCreateWithRoundedRect, so we just redefine it to return NULL.
+MODULE_SCOPE NSColor *controlAccentColor(void) {
+    static int accentPixel = -1;
+    if (accentPixel == -1) {
+	TkColor *temp = TkpGetColor(NULL, "systemControlAccentColor");
+	accentPixel = temp->color.pixel;
+	ckfree(temp);
+    }
+    return TkMacOSXGetNSColor(NULL, accentPixel);
+}
+
+/*
+ * Values which depend on the OS version.  These are initialized
+ * in Ttk_MacOSXInit.
+ */
+
+static Ttk_Padding entryElementPadding;
+static CGFloat Ttk_ContrastDelta;
+
+/*----------------------------------------------------------------------
+ * +++ ComputeButtonDrawInfo --
+ *
+ *      Fill in an appearance manager HIThemeButtonDrawInfo record
+ *      from a Ttk state and the ThemeButtonParams used as the
+ *      clientData.
+ */
+
+static inline HIThemeButtonDrawInfo ComputeButtonDrawInfo(
+    ThemeButtonParams *params,
+    Ttk_State state,
+    TCL_UNUSED(Tk_Window))
+{
+    /*
+     * See ButtonElementDraw for the explanation of why we always draw
+     * some buttons in the active state.
+     */
+
+    SInt32 HIThemeState;
+    int adornment = 0;
+
+    HIThemeState = Ttk_StateTableLookup(ThemeStateTable, state);
+
+    /*
+     * HITheme uses the adornment to decide the direction of the
+     * arrow on a Disclosure Button.  Also HITheme draws inactive
+     * (TTK_STATE_BACKGROUND) buttons in a gray color but macOS
+     * no longer does that.  So we adjust the HIThemeState.
+     */
+
+    switch (params->kind) {
+    case kThemeArrowButton:
+	adornment = kThemeAdornmentDrawIndicatorOnly;
+	if (state & TTK_STATE_SELECTED) {
+	    adornment |= kThemeAdornmentArrowUpArrow;
+	}
+	/* Fall through. */
+    case kThemeRadioButton:
+	/*
+	 * The gray color is better than the blue color for a
+	 * background selected Radio Button.
+	 */
+
+	if (state & TTK_STATE_SELECTED) {
+	    break;
+	}
+    default:
+	if (state & TTK_STATE_BACKGROUND) {
+	    HIThemeState |= kThemeStateActive;
+	}
+	break;
+    }
+
+    const HIThemeButtonDrawInfo info = {
+	.version = 0,
+	.state = HIThemeState,
+	.kind = params ? params->kind : 0,
+	.value = Ttk_StateTableLookup(ButtonValueTable, state),
+	.adornment = Ttk_StateTableLookup(ButtonAdornmentTable, state) | adornment,
+    };
+    return info;
+}
+
+/*
+ * When we draw simulated Apple widgets we use the Core Graphics framework.
+ * Core Graphics uses CGColorRefs, not NSColors.  A CGColorRef must be retained
+ * and released explicitly while an NSColor is autoreleased.  In version 10.8
+ * of macOS Apple introduced a CGColor property of an NSColor which is guaranteed
+ * to be a valid CGColorRef for (approximately) the same color and is released
+ * when the NSColor is autoreleased.
+ *
+ * When building on systems earlier than 10.8 there is no painless way to
+ * convert an NSColor to a CGColor. On the other hand, on those systems we use
+ * the HIToolbox to draw all widgets, so we never need to call Core Graphics
+ * drawing routines directly.  This means that the functions and macros below
+ * which construct CGColorRefs can be defined to return nil on systems before
+ * 10.8.
+ *
+ * Similarly, those older systems did not have CGPathCreateWithRoundedRect, but
+ * since we never need to draw rounded rectangles on those systems we can just
+ * define it to return nil.
  */
 
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
-#define CGCOLOR(nscolor) nscolor.CGColor
+static CGColorRef
+CGColorFromRGBA(
+    CGFloat *rgba)
+{
+    NSColorSpace *colorSpace = [NSColorSpace sRGBColorSpace];
+    NSColor *nscolor = [NSColor colorWithColorSpace: colorSpace
+					 components: rgba
+					      count: 4];
+    return nscolor.CGColor;
+}
+
+static CGColorRef
+CGColorFromGray(
+    GrayColor g)
+{
+    CGFloat rgba[4] = {g.grayscale, g.grayscale, g.grayscale, g.alpha};
+    NSColorSpace *colorSpace = [NSColorSpace sRGBColorSpace];
+    NSColor *nscolor = [NSColor colorWithColorSpace: colorSpace
+					 components: rgba
+					      count: 4];
+    return nscolor.CGColor;
+}
+
+#define CGCOLOR(nscolor) (nscolor).CGColor
+
 #else
-#define CGCOLOR(nscolor) (0 ? (CGColorRef) nscolor : NULL)
+
+#define CGCOLOR(nscolor) NULL
+#define CGColorFromRGBA(rgba) NULL
+#define CGColorFromGray(gray) NULL
 #define CGPathCreateWithRoundedRect(w, x, y, z) NULL
+
 #endif
 
-/*
- * If we try to draw a rounded rectangle with too large of a radius
- * CoreGraphics will raise a fatal exception.  This macro returns if
- * the width or height is less than twice the radius.  Presumably this
- * only happens when a widget has not yet been configured and has size
- * 1x1.
- */
-
-#define CHECK_RADIUS(radius, bounds)                                         \
-    if (radius > bounds.size.width / 2 || radius > bounds.size.height / 2) { \
-        return;                                                              \
-    }
-
 /*----------------------------------------------------------------------
  * +++ Utilities.
  */
 
-/*
+/*----------------------------------------------------------------------
  * BoxToRect --
- *    Convert a Ttk_Box in Tk coordinates relative to the given Drawable
- *    to a native Rect relative to the containing port.
+ *
+ *    Convert a Ttk_Box in Tk coordinates relative to the given Drawable to a
+ *    native CGRect relative to the containing NSView.  (The coordinate system
+ *    is the one used by CGContextRef, which has origin at the upper left
+ *    corner, and y increasing downward.)
  */
 
 static inline CGRect BoxToRect(
     Drawable d,
     Ttk_Box b)
@@ -162,103 +197,128 @@
     rect.size.width     = b.width;
 
     return rect;
 }
 
-/*
- * Table mapping Tk states to Appearance manager ThemeStates
- */
-
-static Ttk_StateTable ThemeStateTable[] = {
-    {kThemeStateActive, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND, 0},
-    {kThemeStateUnavailable, TTK_STATE_DISABLED, 0},
-    {kThemeStatePressed, TTK_STATE_PRESSED, 0},
-    {kThemeStateInactive, TTK_STATE_BACKGROUND, 0},
-    {kThemeStateActive, 0, 0}
-
-    /* Others: Not sure what these are supposed to mean.  Up/Down have
-     * something to do with "little arrow" increment controls...  Dunno what
-     * a "Rollover" is.
-     * NEM: Rollover is TTK_STATE_ACTIVE... but we don't handle that yet, by
-     * the looks of things
-     *
-     * {kThemeStateRollover, 0, 0},
-     * {kThemeStateUnavailableInactive, 0, 0}
-     * {kThemeStatePressedUp, 0, 0},
-     * {kThemeStatePressedDown, 0, 0}
-     */
-};
+/*----------------------------------------------------------------------
+ * LookupGrayPalette
+ *
+ * Retrieves the palette of grayscale colors needed to draw a particular
+ * type of button, in a particular state, in light or dark mode.
+ *
+ */
+
+static GrayPalette LookupGrayPalette(
+    const ButtonDesign *design,
+    unsigned int state,
+    int isDark)
+{
+    const PaletteStateTable *entry = design->palettes;
+    while ((state & entry->onBits) != entry->onBits ||
+           (~state & entry->offBits) != entry->offBits)
+    {
+        ++entry;
+    }
+    return isDark ? entry->dark : entry->light;
+}
 
 /*----------------------------------------------------------------------
  * NormalizeButtonBounds --
  *
- *      Apple's Human Interface Guidelines only allow three specific heights
- *      for most buttons: Regular, small and mini. We always use the regular
- *      size.  However, Ttk may provide an arbitrary bounding rectangle.  We
- *      always draw the button centered vertically on the rectangle, and
- *      having the same width as the rectangle.  This function returns the
- *      actual bounding rectangle that will be used in drawing the button.
- *
- *      The BevelButton is allowed to have arbitrary size, and also has
- *      external padding.  This is handled separately here.
+ *      This function returns the actual bounding rectangle that will be used
+ *      in drawing the button.
+ *
+ *      Apple only allows three specific heights for most buttons: regular,
+ *      small and mini. We always use the regular size.  However, Ttk may
+ *      provide a bounding rectangle with arbitrary height.  We draw the Mac
+ *      button centered vertically in the Ttk rectangle, with the same width as
+ *      the rectangle.  (But we take care to produce an integer y coordinate,
+ *      to avoid unexpected anti-aliasing.)
+ *
+ *      In addition, the button types which are not known to HIToolbox need some
+ *      adjustments to their bounds.
+ *
  */
 
 static CGRect NormalizeButtonBounds(
-    SInt32 heightMetric,
-    CGRect bounds)
+    ThemeButtonParams *params,
+    CGRect bounds,
+    int isDark)
 {
     SInt32 height;
 
-    if (heightMetric != (SInt32) NoThemeMetric) {
-	ChkErr(GetThemeMetric, heightMetric, &height);
-	bounds.origin.y += (bounds.size.height - height) / 2;
+    if (params->heightMetric != NoThemeMetric) {
+	ChkErr(GetThemeMetric, params->heightMetric, &height);
+	height += 2;
+	bounds.origin.y += round(1 + (bounds.size.height - height) / 2);
 	bounds.size.height = height;
+    }
+    switch (params->kind) {
+    case TkRoundedRectButton:
+	bounds.size.height -= 1;
+	break;
+    case TkInlineButton:
+	bounds.size.height -= 4;
+	bounds.origin.y += 1;
+	break;
+    case TkRecessedButton:
+	bounds.size.height -= 2;
+	break;
+    case kThemeRoundButtonHelp:
+	if (isDark) {
+	    bounds.size.height = bounds.size.width = 22;
+	} else {
+	    bounds.size.height = bounds.size.width = 22;
+	}
+	break;
+    default:
+	break;
     }
     return bounds;
 }
 
 /*----------------------------------------------------------------------
- * +++ Backgrounds
+ * +++ Background Colors
  *
  * Support for contrasting background colors when GroupBoxes or Tabbed
  * panes are nested inside each other.  Early versions of macOS used ridged
  * borders, so do not need contrasting backgrounds.
  */
 
 /*
- * For systems older than 10.14, [NSColor windowBackGroundColor] generates
+ * For systems older than 10.14, [NSColor windowBackgroundColor] generates
  * garbage when called from this function.  In 10.14 it works correctly, and
  * must be used in order to have a background color which responds to Dark
  * Mode.  So we use this hard-wired RGBA color on the older systems which don't
  * support Dark Mode anyway.
  */
 
-static const CGFloat WINDOWBACKGROUND[4] = {
-    235.0 / 255, 235.0 / 255, 235.0 / 255, 1.0
-};
-static const CGFloat WHITERGBA[4] = {1.0, 1.0, 1.0, 1.0};
-static const CGFloat BLACKRGBA[4] = {0.0, 0.0, 0.0, 1.0};
+RGBACOLOR windowBackground[4] = RGBA256(235.0, 235.0, 235.0, 1.0);
 
 /*----------------------------------------------------------------------
  * GetBackgroundColor --
  *
  *      Fills the array rgba with the color coordinates for a background color.
- *      Start with the background color of a window's geometry container, or
- *      the standard ttk window background if there is no container. If the
+ *      Start with the background color of a window's container, or the
+ *      standard ttk window background if there is no container. If the
  *      contrast parameter is nonzero, modify this color to be darker, for the
  *      aqua appearance, or lighter for the DarkAqua appearance.  This is
- *      primarily used by the Fill and Background elements.
+ *      primarily used by the Fill and Background elements.  The save parameter
+ *      is normally YES, so the contrasting color is saved in the private
+ *      data of the widget.  This behavior can be disabled in special cases,
+ *      such as when drawing notebook tabs in macOS 11.
  */
 
-static void GetBackgroundColor(
+static void GetBackgroundColorRGBA(
     TCL_UNUSED(CGContextRef),
     Tk_Window tkwin,
     int contrast,
+    Bool save,
     CGFloat *rgba)
 {
-    TkWindow *winPtr = (TkWindow *)tkwin;
-    TkWindow *containerPtr = (TkWindow *)TkGetContainer(tkwin);
+    TkWindow *winPtr = (TkWindow *) tkwin;
+    TkWindow *containerPtr = (TkWindow *) TkGetContainer(tkwin);
 
     while (containerPtr && containerPtr->privatePtr) {
 	if (containerPtr->privatePtr->flags & TTK_HAS_CONTRASTING_BG) {
 	    break;
 	}
@@ -274,75 +334,398 @@
 	    NSColor *windowColor = [[NSColor windowBackgroundColor]
 		colorUsingColorSpace: deviceRGB];
 	    [windowColor getComponents: rgba];
 	} else {
 	    for (int i = 0; i < 4; i++) {
-		rgba[i] = WINDOWBACKGROUND[i];
+		rgba[i] = windowBackground[i];
 	    }
 	}
     }
+
     if (contrast) {
 	int isDark = (rgba[0] + rgba[1] + rgba[2] < 1.5);
 
 	if (isDark) {
 	    for (int i = 0; i < 3; i++) {
-		rgba[i] += 8.0 / 255.0;
+		rgba[i] += Ttk_ContrastDelta*contrast / 255.0;
 	    }
 	} else {
 	    for (int i = 0; i < 3; i++) {
-		rgba[i] -= 8.0 / 255.0;
+		rgba[i] -= Ttk_ContrastDelta*contrast / 255.0;
 	    }
 	}
-        if (winPtr->privatePtr) {
+        if (save && winPtr->privatePtr) {
             winPtr->privatePtr->flags |= TTK_HAS_CONTRASTING_BG;
             for (int i = 0; i < 4; i++) {
                 winPtr->privatePtr->fillRGBA[i] = rgba[i];
             }
         }
     }
 }
 
+static CGColorRef GetBackgroundCGColor(
+    CGContextRef context,
+    Tk_Window tkwin,
+    int contrast,
+    Bool save)
+{
+    CGFloat rgba[4];
+    GetBackgroundColorRGBA(context, tkwin, contrast, save, rgba);
+    return CGColorFromRGBA(rgba);
+}
+
+/*----------------------------------------------------------------------
+ * +++ Buttons
+ */
+
+/*----------------------------------------------------------------------
+ * FillRoundedRectangle --
+ *
+ *      Fill a rounded rectangle with a specified solid color.
+ */
+
+static void FillRoundedRectangle(
+    CGContextRef context,
+    CGRect bounds,
+    CGFloat radius,
+    CGColorRef color)
+{
+    CGPathRef path;
+    CHECK_RADIUS(radius, bounds)
+
+    path = CGPathCreateWithRoundedRect(bounds, radius, radius, NULL);
+    if (!path) {
+	return;
+    }
+    CGContextSetFillColorWithColor(context, color);
+    CGContextBeginPath(context);
+    CGContextAddPath(context, path);
+    CGContextFillPath(context);
+    CFRelease(path);
+}
+
+/*----------------------------------------------------------------------
+ * FillBorder --
+ *
+ *      Draw a 1-pixel border around a rounded rectangle using a 3-step
+ *      gradient of shades of gray.
+ */
+
+static void FillBorder(
+    CGContextRef context,
+    CGRect bounds,
+    GrayPalette palette,
+    CGFloat radius)
+{
+    if (bounds.size.width < 2) {
+	return;
+    }
+    NSColorSpace *sRGB = [NSColorSpace sRGBColorSpace];
+    CGPoint end = CGPointMake(bounds.origin.x, bounds.origin.y + bounds.size.height);
+    CGFloat corner = (radius > 0 ? radius : 2.0) / bounds.size.height;
+    CGFloat locations[4] = {0.0, corner, 1.0 - corner, 1.0};
+    CGPathRef path = CGPathCreateWithRoundedRect(bounds, radius, radius, NULL);
+    CGFloat colors[16];
+    colors[0] = colors[1] = colors[2] = palette.top / 255.0;
+    colors[4] = colors[5] = colors[6] = palette.side / 255.0;
+    colors[8] = colors[9] = colors[10] = palette.side / 255.0;
+    colors[12] = colors[13] = colors[14] = palette.bottom / 255.0;
+    colors[3] = colors[7] = colors[11] = colors[15] = 1.0;
+    CGGradientRef gradient = CGGradientCreateWithColorComponents(
+	 sRGB.CGColorSpace, colors, locations, 4);
+    if (!gradient) {
+	return;
+    }
+    CGContextSaveGState(context);
+    CGContextBeginPath(context);
+    CGContextAddPath(context, path);
+    CGContextClip(context);
+    CGContextDrawLinearGradient(context, gradient, bounds.origin, end, 0.0);
+    CGContextRestoreGState(context);
+    CFRelease(path);
+    CFRelease(gradient);
+}
+
+/*----------------------------------------------------------------------
+ * DrawFocusRing --
+ *
+ *      Draw a 4-pixel wide rounded focus ring enclosing a rounded
+ *      rectangle, using the current system accent color.
+ */
+
+static void DrawFocusRing(
+    CGContextRef context,
+    CGRect bounds,
+    const ButtonDesign *design)
+{
+    CGColorRef highlightColor;
+    CGFloat highlight[4] = {1.0, 1.0, 1.0, 0.2};
+    CGColorRef focusColor;
+
+    focusColor = CGCOLOR([controlAccentColor() colorWithAlphaComponent:0.6]);
+    FillRoundedRectangle(context, bounds, design->radius, focusColor);
+    bounds = CGRectInset(bounds, 3, 3);
+    highlightColor = CGColorFromRGBA(highlight);
+    CGContextSetFillColorWithColor(context, highlightColor);
+    CGContextFillRect(context, bounds);
+}
+
+/*----------------------------------------------------------------------
+ * DrawGrayButton --
+ *
+ *      Draw a button in normal gray colors.
+ *
+ *      Aqua buttons are normally drawn in a grayscale color.  The buttons,
+ *      which are shaped as rounded rectangles have a 1-pixel border which is
+ *      drawn in a 3-step gradient and a solid gray face.
+ *
+ *      Note that this will produce a round button if length = width =
+ *      2*radius.
+ */
+
+static void DrawGrayButton(
+    CGContextRef context,
+    CGRect bounds,
+    const ButtonDesign *design,
+    unsigned int state,
+    Tk_Window tkwin)
+{
+    int isDark = TkMacOSXInDarkMode(tkwin);
+    GrayPalette palette = LookupGrayPalette(design, state, isDark);
+    GrayColor faceGray = {.grayscale = 0.0, .alpha = 1.0};
+    CGFloat radius = 2 * design->radius <= bounds.size.height ?
+	design->radius : bounds.size.height / 2;
+    if (palette.top <= 255.0) {
+	FillBorder(context, bounds, palette, radius);
+    }
+    if (palette.face <= 255.0) {
+	faceGray.grayscale = palette.face / 255.0;
+    } else {
+
+	/*
+	 * Color values > 255 are "transparent" which really means that we
+	 * fill with the background color.
+	 */
+
+	CGFloat rgba[4], gray;
+	GetBackgroundColorRGBA(context, tkwin, 0, NO, rgba);
+	gray = (rgba[0] + rgba[1] + rgba[2]) / 3.0;
+	faceGray.grayscale = gray;
+    }
+    FillRoundedRectangle(context, CGRectInset(bounds, 1, 1), radius - 1,
+			 CGColorFromGray(faceGray));
+}
+
+/*----------------------------------------------------------------------
+ * DrawAccentedButton --
+ *
+ *      The accent color is only used when drawing buttons in the active
+ *      window.  Push Buttons and segmented Arrow Buttons are drawn in color
+ *      when in the pressed state.  Selected Check Buttons, Radio Buttons and
+ *      notebook Tabs are also drawn in color.  The color is based on the
+ *      user's current choice for the controlAccentColor, but is actually a
+ *      linear gradient with a 1-pixel darker line at the top and otherwise
+ *      changing from lighter at the top to darker at the bottom.  This
+ *      function draws a colored rounded rectangular button.
+ */
+
+static void DrawAccentedButton(
+    CGContextRef context,
+    CGRect bounds,
+    const ButtonDesign *design,
+    int state,
+    int isDark)
+{
+    NSColorSpace *sRGB = [NSColorSpace sRGBColorSpace];
+    CGColorRef faceColor = CGCOLOR(controlAccentColor());
+    CGFloat radius = design->radius;
+    CGPathRef path = CGPathCreateWithRoundedRect(bounds, radius, radius, NULL);
+    // This gradient should only be used for PushButtons and Tabs, and it needs
+    // to be lighter at the top.
+    static CGFloat components[12] = {1.0, 1.0, 1.0, 0.05,
+				     1.0, 1.0, 1.0, 0.2,
+				     1.0, 1.0, 1.0, 0.0};
+    CGFloat locations[3] = {0.0, 0.05, 1.0};
+    CGGradientRef gradient = CGGradientCreateWithColorComponents(
+				 sRGB.CGColorSpace, components, locations, 3);
+    CGPoint end;
+    if (bounds.size.height > 2*radius) {
+	bounds.size.height -= 1;
+    }
+    end = CGPointMake(bounds.origin.x, bounds.origin.y + bounds.size.height);
+    CGContextSaveGState(context);
+    CGContextBeginPath(context);
+    CGContextAddPath(context, path);
+    CGContextClip(context);
+    FillRoundedRectangle(context, bounds, radius, faceColor);
+    CGContextDrawLinearGradient(context, gradient, bounds.origin, end, 0.0);
+    if (state & TTK_STATE_PRESSED &&
+	state & TTK_STATE_ALTERNATE) {
+	CGColorRef color = isDark ?
+	    CGColorFromGray(darkPressedDefaultButton) :
+	    CGColorFromGray(pressedDefaultButton);
+	FillRoundedRectangle(context, bounds, radius, color);
+    }
+    CGContextRestoreGState(context);
+    CFRelease(path);
+    CFRelease(gradient);
+}
+
+/*----------------------------------------------------------------------
+ * DrawAccentedSegment --
+ *
+ *      Draw the colored ends of widgets like popup buttons and combo buttons.
+ */
+
+static void DrawAccentedSegment(
+    CGContextRef context,
+    CGRect bounds,
+    const ButtonDesign *design,
+    unsigned int state,
+    Tk_Window tkwin)
+{
+    /*
+     * Clip to the bounds and then draw an accented button which is extended so
+     * that the rounded corners on the left will be clipped off.  This assumes
+     * that the bounds include room for the focus ring.
+     */
+    int isDark = TkMacOSXInDarkMode(tkwin);
+    GrayColor sepGray = isDark ? darkComboSeparator : lightComboSeparator;
+    CGColorRef sepColor = CGColorFromGray(sepGray);
+    CGRect clip = bounds;
+    clip.size.height += 10;
+    bounds.origin.x -= 10;
+    bounds.size.width += 10;
+    CGPoint separator[2] = {
+	CGPointMake(clip.origin.x - 1, bounds.origin.y + 5),
+	CGPointMake(clip.origin.x - 1,
+		    bounds.origin.y + bounds.size.height - 3)};
+    CGContextSaveGState(context);
+    CGContextSetStrokeColorWithColor(context, sepColor);
+    CGContextSetShouldAntialias(context, false);
+    CGContextSetLineWidth(context, 0.5);
+    CGContextAddLines(context, separator, 2);
+    CGContextStrokePath(context);
+    CGContextSetShouldAntialias(context, true);
+    if (state & TTK_STATE_FOCUS) {
+	CGRect focusClip = clip;
+	clip.size.width += 4;
+	CGContextClipToRect(context, focusClip);
+	bounds = CGRectInset(bounds, 0, 1);
+	DrawFocusRing(context, bounds, design);
+    }
+    bounds = CGRectInset(bounds, 4, 4);
+    if (state & TTK_STATE_BACKGROUND) {
+	bounds.size.height += 2;
+    } else {
+	bounds.size.height += 1;
+    }
+    CGContextClipToRect(context, clip);
+    if ((state & TTK_STATE_BACKGROUND) || (state & TTK_STATE_DISABLED)) {
+	DrawGrayButton(context, bounds, design, state, tkwin);
+    } else {
+	DrawAccentedButton(context, bounds, design, state | TTK_STATE_ALTERNATE,
+			   isDark);
+    }
+    CGContextRestoreGState(context);
+}
+
+/*----------------------------------------------------------------------
+ * +++ Entry boxes
+ */
+
+static void DrawEntry(
+    CGContextRef context,
+    CGRect bounds,
+    const ButtonDesign *design,
+    int state,
+    Tk_Window tkwin)
+{
+    int isDark = TkMacOSXInDarkMode(tkwin);
+    GrayPalette palette = LookupGrayPalette(design, state, isDark);
+    CGColorRef backgroundColor;
+    CGFloat bgRGBA[4];
+    if (isDark) {
+    	GetBackgroundColorRGBA(context, tkwin, 0, NO, bgRGBA);
+
+	/*
+	 * Lighten the entry background to provide contrast.
+	 */
+
+	for (int i = 0; i < 3; i++) {
+		bgRGBA[i] += 8.0 / 255.0;
+	    }
+	backgroundColor = CGColorFromRGBA(bgRGBA);
+    } else {
+	backgroundColor = CG_WHITE;
+    }
+    if (state & TTK_STATE_FOCUS) {
+	DrawFocusRing(context, bounds, design);
+    } else {
+	FillBorder(context, CGRectInset(bounds,3,3), palette, design->radius);
+    }
+    bounds = CGRectInset(bounds, 4, 4);
+    FillRoundedRectangle(context, bounds, design->radius, backgroundColor);
+}
 
 /*----------------------------------------------------------------------
- * +++ Single Arrow Images --
- *
- * Used in ListHeaders and Comboboxes as well as disclosure triangles in
- * macOS 11.
+ * +++ Chevrons, CheckMarks, etc. --
  */
 
 static void DrawDownArrow(
     CGContextRef context,
     CGRect bounds,
     CGFloat inset,
     CGFloat size,
-    const CGFloat *rgba)
+    int state)
 {
+    CGColorRef strokeColor;
     CGFloat x, y;
 
-    CGContextSetRGBStrokeColor(context, rgba[0], rgba[1], rgba[2], rgba[3]);
+
+    if (state & TTK_STATE_DISABLED) {
+	strokeColor = CGCOLOR([NSColor disabledControlTextColor]);
+    } else if (state & TTK_STATE_IS_ACCENTED) {
+	strokeColor = CG_WHITE;
+    } else {
+	strokeColor = CGCOLOR([NSColor controlTextColor]);
+    }
+    CGContextSetStrokeColorWithColor(context, strokeColor);
     CGContextSetLineWidth(context, 1.5);
     x = bounds.origin.x + inset;
-    y = bounds.origin.y + trunc(bounds.size.height / 2);
+    y = bounds.origin.y + trunc(bounds.size.height / 2) + 1;
     CGContextBeginPath(context);
     CGPoint arrow[3] = {
 	{x, y - size / 4}, {x + size / 2, y + size / 4},
 	{x + size, y - size / 4}
     };
     CGContextAddLines(context, arrow, 3);
     CGContextStrokePath(context);
 }
+
+/*----------------------------------------------------------------------
+ * DrawUpArrow --
+ *
+ * Draws a single upward pointing arrow for ListHeaders and Disclosure Buttons.
+ */
 
 static void DrawUpArrow(
     CGContextRef context,
     CGRect bounds,
     CGFloat inset,
     CGFloat size,
-    const CGFloat *rgba)
+    int state)
 {
+    NSColor *strokeColor;
     CGFloat x, y;
 
-    CGContextSetRGBStrokeColor(context, rgba[0], rgba[1], rgba[2], rgba[3]);
+    if (state & TTK_STATE_DISABLED) {
+	strokeColor = [NSColor disabledControlTextColor];
+    } else {
+	strokeColor = [NSColor controlTextColor];
+    }
+    CGContextSetStrokeColorWithColor(context, CGCOLOR(strokeColor));
     CGContextSetLineWidth(context, 1.5);
     x = bounds.origin.x + inset;
     y = bounds.origin.y + trunc(bounds.size.height / 2);
     CGContextBeginPath(context);
     CGPoint arrow[3] = {
@@ -350,10 +733,63 @@
 	{x + size, y + size / 4}
     };
     CGContextAddLines(context, arrow, 3);
     CGContextStrokePath(context);
 }
+
+/*----------------------------------------------------------------------
+ * DrawUpDownArrows --
+ *
+ * Draws the double arrows used in menu buttons and spin buttons.
+ */
+
+static void DrawUpDownArrows(
+    CGContextRef context,
+    CGRect bounds,
+    CGFloat inset,
+    CGFloat size,
+    CGFloat gap,
+    int state,
+    ThemeDrawState drawState)
+{
+    CGFloat x, y;
+    NSColor *topStrokeColor, *bottomStrokeColor;
+    if (drawState == BOTH_ARROWS && !(state & TTK_STATE_BACKGROUND)) {
+	topStrokeColor = bottomStrokeColor = [NSColor whiteColor];
+    } else if (drawState == kThemeStatePressedDown) {
+	topStrokeColor = [NSColor controlTextColor];
+	bottomStrokeColor = [NSColor whiteColor];
+    } else if (drawState == kThemeStatePressedUp) {
+	topStrokeColor = [NSColor whiteColor];
+	bottomStrokeColor = [NSColor controlTextColor];
+    } else if (state & TTK_STATE_DISABLED) {
+	topStrokeColor = bottomStrokeColor = [NSColor disabledControlTextColor];
+    } else {
+	topStrokeColor = bottomStrokeColor = [NSColor controlTextColor];
+    }
+    CGContextSetLineWidth(context, 1.5);
+    x = bounds.origin.x + inset;
+    y = bounds.origin.y + trunc(bounds.size.height / 2);
+    CGContextBeginPath(context);
+    CGPoint bottomArrow[3] =
+	{{x, y + gap}, {x + size / 2, y + gap + size / 2}, {x + size, y + gap}};
+    CGContextAddLines(context, bottomArrow, 3);
+    CGContextSetStrokeColorWithColor(context, CGCOLOR(bottomStrokeColor));
+    CGContextStrokePath(context);
+    CGContextBeginPath(context);
+    CGPoint topArrow[3] =
+	{{x, y - gap}, {x + size / 2, y - gap - size / 2}, {x + size, y - gap}};
+    CGContextAddLines(context, topArrow, 3);
+    CGContextSetStrokeColorWithColor(context, CGCOLOR(topStrokeColor));
+    CGContextStrokePath(context);
+}
+
+/*----------------------------------------------------------------------
+ * DrawClosedDisclosure --
+ *
+ * Draws a disclosure chevron in the Big Sur style, for Treeviews.
+ */
 
 static void DrawClosedDisclosure(
     CGContextRef context,
     CGRect bounds,
     CGFloat inset,
@@ -371,10 +807,16 @@
 	{x, y - size / 4 - 1}, {x + size / 2, y}, {x, y + size / 4 + 1}
     };
     CGContextAddLines(context, arrow, 3);
     CGContextStrokePath(context);
 }
+
+/*----------------------------------------------------------------------
+ * DrawOpenDisclosure --
+ *
+ * Draws an open disclosure chevron in the Big Sur style, for Treeviews.
+ */
 
 static void DrawOpenDisclosure(
     CGContextRef context,
     CGRect bounds,
     CGFloat inset,
@@ -394,236 +836,610 @@
     CGContextAddLines(context, arrow, 3);
     CGContextStrokePath(context);
 }
 
 /*----------------------------------------------------------------------
- * +++ Double Arrow Buttons --
- *
- * Used in MenuButtons and SpinButtons.
- */
-
-static void DrawUpDownArrows(
-    CGContextRef context,
-    CGRect bounds,
-    CGFloat inset,
-    CGFloat size,
-    const CGFloat *rgba)
-{
-    CGFloat x, y;
-
-    CGContextSetRGBStrokeColor(context, rgba[0], rgba[1], rgba[2], rgba[3]);
-    CGContextSetLineWidth(context, 1.5);
-    x = bounds.origin.x + inset;
-    y = bounds.origin.y + trunc(bounds.size.height / 2);
-    CGContextBeginPath(context);
-    CGPoint bottomArrow[3] =
-    {{x, y + 2}, {x + size / 2, y + 2 + size / 2}, {x + size, y + 2}};
-    CGContextAddLines(context, bottomArrow, 3);
-    CGPoint topArrow[3] =
-    {{x, y - 2}, {x + size / 2, y - 2 - size / 2}, {x + size, y - 2}};
-    CGContextAddLines(context, topArrow, 3);
-    CGContextStrokePath(context);
-}
-
-
-/*----------------------------------------------------------------------
- * +++ FillButtonBackground --
- *
- *      Fills a rounded rectangle with a transparent black gradient.
- *      This is a no-op if building on 10.8 or older.
- */
-
-static void FillButtonBackground(
-    CGContextRef context,
-    CGRect bounds,
-    CGFloat radius)
-{
-    CHECK_RADIUS(radius, bounds)
-
-    CGPathRef path;
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    CGGradientRef backgroundGradient = CGGradientCreateWithColorComponents(
-	deviceRGB.CGColorSpace, darkBackgroundGradient, NULL, 2);
-    CGPoint backgroundEnd = {
-	bounds.origin.x,
-	bounds.origin.y + bounds.size.height
-    };
-    CGContextBeginPath(context);
-    path = CGPathCreateWithRoundedRect(bounds, radius, radius, NULL);
-    CGContextAddPath(context, path);
-    CGContextClip(context);
-    CGContextDrawLinearGradient(context, backgroundGradient,
-	bounds.origin, backgroundEnd, 0);
-    CFRelease(path);
-    CFRelease(backgroundGradient);
-}
-
-/*----------------------------------------------------------------------
- * +++ HighlightButtonBorder --
- *
- * Accent the top border of a rounded rectangle with a transparent
- * white gradient.
- */
-
-static void HighlightButtonBorder(
-    CGContextRef context,
-    CGRect bounds)
-{
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    CGPoint topEnd = {bounds.origin.x, bounds.origin.y + 3};
-    CGGradientRef topGradient = CGGradientCreateWithColorComponents(
-	deviceRGB.CGColorSpace, darkTopGradient, NULL, 2);
-
+ * IndicatorColor --
+ *
+ * Returns a CGColorRef of the appropriate shade for a check button or
+ * radio button in a given state.
+ */
+
+static CGColorRef IndicatorColor(
+   int state,
+   int isDark)
+{
+    if (state & TTK_STATE_DISABLED) {
+	return isDark ?
+	    CGColorFromGray(darkDisabledIndicator) :
+	    CGColorFromGray(lightDisabledIndicator);
+    } else if ((state & TTK_STATE_SELECTED || state & TTK_STATE_ALTERNATE) &&
+	       !(state & TTK_STATE_BACKGROUND)) {
+	return CG_WHITE;
+    } else {
+	return CGCOLOR([NSColor controlTextColor]);
+    }
+}
+
+/*----------------------------------------------------------------------
+ * DrawCheckIndicator --
+ *
+ * Draws the checkmark or horizontal bar in a check box.
+ */
+
+static void DrawCheckIndicator(
+    CGContextRef context,
+    CGRect bounds,
+    int state,
+    int isDark)
+{
+    CGFloat x = bounds.origin.x, y = bounds.origin.y;
+    CGColorRef strokeColor = IndicatorColor(state, isDark);
+
+    CGContextSetStrokeColorWithColor(context, strokeColor);
+    if (state & TTK_STATE_SELECTED) {
+	CGContextSetLineWidth(context, 1.5);
+	CGContextBeginPath(context);
+	CGPoint check[3] = {{x + 3, y + 7}, {x + 6, y + 10}, {x + 10, y + 3}};
+	CGContextAddLines(context, check, 3);
+	CGContextStrokePath(context);
+    } else if (state & TTK_STATE_ALTERNATE) {
+	CGContextSetLineWidth(context, 2.0);
+	CGContextBeginPath(context);
+	CGPoint bar[2] = {{x + 3, y + 7}, {x + 11, y + 7}};
+	CGContextAddLines(context, bar, 2);
+	CGContextStrokePath(context);
+    }
+}
+
+/*----------------------------------------------------------------------
+ * DrawRadioIndicator --
+ *
+ * Draws the dot in the middle of a selected radio button.
+ */
+
+static void DrawRadioIndicator(
+    CGContextRef context,
+    CGRect bounds,
+    int state,
+    int isDark)
+{
+    CGFloat x = bounds.origin.x, y = bounds.origin.y;
+    CGColorRef fillColor = IndicatorColor(state, isDark);
+
+    CGContextSetFillColorWithColor(context, fillColor);
+    if (state & TTK_STATE_SELECTED) {
+	CGContextBeginPath(context);
+	CGRect dot = {{x + 5, y + 5}, {6, 6}};
+	CGContextAddEllipseInRect(context, dot);
+	CGContextFillPath(context);
+    } else if (state & TTK_STATE_ALTERNATE) {
+	CGRect bar = {{x + 4, y + 7}, {8, 2}};
+	CGContextFillRect(context, bar);
+    }
+}
+
+static void
+DrawHelpSymbol(
+    CGContextRef context,
+    CGRect bounds,
+    int state)
+{
+    NSFont *font = [NSFont controlContentFontOfSize:15];
+    NSColor *foreground = state & TTK_STATE_DISABLED ?
+	[NSColor disabledControlTextColor] : [NSColor controlTextColor];
+    NSDictionary *attrs = @{
+        NSForegroundColorAttributeName : foreground,
+        NSFontAttributeName : font
+    };
+    NSAttributedString *attributedString = [[NSAttributedString alloc]
+						      initWithString:@"?"
+							  attributes:attrs];
+    CTTypesetterRef typesetter = CTTypesetterCreateWithAttributedString(
+	       (CFAttributedStringRef)attributedString);
+    CTLineRef line = CTTypesetterCreateLine(typesetter, CFRangeMake(0, 1));
+    CGAffineTransform t = CGAffineTransformMake(
+			      1.0, 0.0, 0.0, -1.0, 0.0, bounds.size.height);
+    CGContextSaveGState(context);
+    CGContextSetTextMatrix(context, t);
+    CGContextSetTextPosition(context,
+			     bounds.origin.x + 6.5,
+			     bounds.origin.y + bounds.size.height - 5);
+    CTLineDraw(line, context);
+    CGContextRestoreGState(context);
+    CFRelease(line);
+    CFRelease(typesetter);
+    [attributedString release];
+}
+
+
+
+/*----------------------------------------------------------------------
+ * +++ Progress bars.
+ */
+
+/*----------------------------------------------------------------------
+ * DrawProgressBar --
+ *
+ * Draws a progress bar, with parameters supplied by a HIThemeTrackDrawInfo
+ * struct.  Draws a rounded rectangular track overlayed by a colored
+ * rounded rectangular indicator.  An indeterminate progress bar is
+ * animated.
+ */
+
+static void DrawProgressBar(
+    CGContextRef context,
+    CGRect bounds,
+    HIThemeTrackDrawInfo info,
+    int state,
+    Tk_Window tkwin)
+{
+    CGRect colorBounds;
+    CGFloat rgba[4];
+    CGColorRef trackColor, highlightColor, fillColor;
+    NSColor *accent;
+    CGFloat ratio = (CGFloat) info.value / (CGFloat) (info.max - info.min);
+
+    GetBackgroundColorRGBA(context, tkwin, 0, NO, rgba);
+
+    /*
+     * Compute the bounds for the track and indicator.  The track is 6 pixels
+     * wide in the center of the widget bounds.
+     */
+
+    if (info.attributes & kThemeTrackHorizontal) {
+	bounds = CGRectInset(bounds, 1, bounds.size.height / 2 - 3);
+	colorBounds = bounds;
+	if (info.kind == kThemeIndeterminateBar) {
+	    CGFloat width = 0.25*bounds.size.width;
+	    CGFloat travel = 0.75*bounds.size.width;
+	    CGFloat center = bounds.origin.x + (width / 2) + ratio*travel;
+	    colorBounds.origin.x = center - width / 2;
+	    colorBounds.size.width = width;
+	} else {
+	    colorBounds.size.width = ratio*bounds.size.width;
+	}
+	if (colorBounds.size.width > 0 && colorBounds.size.width < 6) {
+	    colorBounds.size.width = 6;
+	}
+    } else {
+	bounds = CGRectInset(bounds, bounds.size.width / 2 - 3, 1);
+	colorBounds = bounds;
+	if (info.kind == kThemeIndeterminateBar) {
+	    CGFloat height = 0.25*bounds.size.height;
+	    CGFloat travel = 0.75*bounds.size.height;
+	    CGFloat center = bounds.origin.y + (height / 2) + ratio*travel;
+	    colorBounds.origin.y = center - height / 2;
+	    colorBounds.size.height = height;
+	} else {
+	    colorBounds.size.height = ratio*(bounds.size.height);
+	}
+	if (colorBounds.size.height > 0 && colorBounds.size.height < 6) {
+	    colorBounds.size.height = 6;
+	}
+	colorBounds.origin.y += bounds.size.height - colorBounds.size.height;
+    }
+
+    /*
+     * Compute the colors for the track and indicator.
+     */
+
+    if (TkMacOSXInDarkMode(tkwin)) {
+	for(int i=0; i < 3; i++) {
+	    rgba[i] += 30.0 / 255.0;
+	}
+	trackColor = CGColorFromRGBA(rgba);
+	for(int i=0; i < 3; i++) {
+	    rgba[i] -= 5.0 / 255.0;
+	}
+	highlightColor = CGColorFromRGBA(rgba);
+	FillRoundedRectangle(context, bounds, 3, trackColor);
+    } else {
+	for(int i=0; i < 3; i++) {
+	    rgba[i] -= 14.0 / 255.0;
+	}
+	trackColor = CGColorFromRGBA(rgba);
+	for(int i=0; i < 3; i++) {
+	    rgba[i] += 3.0 / 255.0;
+	}
+	highlightColor = CGColorFromRGBA(rgba);
+	bounds.size.height -= 1;
+	bounds = CGRectInset(bounds, 0, -1);
+    }
+    if (state & TTK_STATE_BACKGROUND) {
+	accent = [NSColor colorWithRed:0.72 green:0.72 blue:0.72 alpha:0.72];
+    } else {
+	accent = controlAccentColor();
+    }
+
+    /*
+     * Draw the track, with highlighting around the edge.
+     */
+
+    FillRoundedRectangle(context, bounds, 3, trackColor);
+    bounds = CGRectInset(bounds, 0, 0.5);
+    FillRoundedRectangle(context, bounds, 2.5, highlightColor);
+    bounds = CGRectInset(bounds, 0.5, 0.5);
+    FillRoundedRectangle(context, bounds, 2, trackColor);
+    bounds = CGRectInset(bounds, -0.5, -1);
+
+    /*
+     * Draw the indicator.  Make it slightly transparent around the
+     * edge so the highlightng shows through.
+     */
+
+    if (info.kind == kThemeIndeterminateBar &&
+	(state & TTK_STATE_SELECTED) == 0) {
+	return;
+    }
+
+    fillColor = CGCOLOR([accent colorWithAlphaComponent:0.9]);
+    FillRoundedRectangle(context, colorBounds, 3, fillColor);
+    colorBounds = CGRectInset(colorBounds, 1, 1);
+    fillColor = CGCOLOR([accent colorWithAlphaComponent:1.0]);
+    FillRoundedRectangle(context, colorBounds, 2.5, fillColor);
+}
+
+/*----------------------------------------------------------------------
+ * +++ Sliders.
+ */
+
+/*----------------------------------------------------------------------
+ * DrawSlider --
+ *
+ * Draws a slider track and round thumb for a Ttk scale widget.  The accent
+ * color is used on the left or top part of the track, so the fraction of
+ * the track which is colored is equal to (value - from) / (to - from).
+ *
+ */
+
+static void DrawSlider(
+    CGContextRef context,
+    CGRect bounds,
+    HIThemeTrackDrawInfo info,
+    int state,
+    Tk_Window tkwin)
+{
+    CGColorRef trackColor;
+    CGRect clipBounds, trackBounds, thumbBounds;
+    CGPoint thumbPoint;
+    CGFloat position;
+    CGColorRef accentColor;
+    Bool fromIsSmaller = info.reserved;
+    double from = info.min, to = fabs((double) info.max), value = info.value;
+
+    /*
+     * info.min, info.max and info.value are integers.  When this is called
+     * we will have arranged that min = 0 and max is a large positive integer.
+     */
+
+    double fraction = (from < to) ? (value - from) / (to - from) : 0.5;
+    int isDark = TkMacOSXInDarkMode(tkwin);
+
+    if (info.attributes & kThemeTrackHorizontal) {
+	trackBounds = CGRectInset(bounds, 0, bounds.size.height / 2 - 3);
+	trackBounds.size.height = 3;
+	position = 8 + fraction * (trackBounds.size.width - 16);
+	clipBounds = trackBounds;
+	if (fromIsSmaller) {
+	    clipBounds.size.width = position;
+	} else {
+	    clipBounds.origin.x += position;
+	    clipBounds.size.width -= position;
+	}
+	thumbPoint = CGPointMake(trackBounds.origin.x + position,
+				 trackBounds.origin.y + 1);
+    } else {
+	trackBounds = CGRectInset(bounds, bounds.size.width / 2 - 3, 0);
+	trackBounds.size.width = 3;
+	position = 8 + fraction * (trackBounds.size.height - 16);
+	clipBounds = trackBounds;
+	if (fromIsSmaller) {
+	    clipBounds.size.height = position;
+	} else {
+	    clipBounds.origin.y += position;
+	    clipBounds.size.height -= position;
+	}
+	thumbPoint = CGPointMake(trackBounds.origin.x + 1,
+				 trackBounds.origin.y + position);
+    }
+    trackColor = isDark ? CGColorFromGray(darkTrack):
+	CGColorFromGray(lightTrack);
+    thumbBounds = CGRectMake(thumbPoint.x - 8, thumbPoint.y - 8, 17, 17);
     CGContextSaveGState(context);
-    CGContextBeginPath(context);
-    CGContextAddArc(context, bounds.origin.x + 4, bounds.origin.y + 4,
-	4, PI, 3 * PI / 2, 0);
-    CGContextAddArc(context, bounds.origin.x + bounds.size.width - 4,
-	bounds.origin.y + 4, 4, 3 * PI / 2, 0, 0);
-    CGContextReplacePathWithStrokedPath(context);
-    CGContextClip(context);
-    CGContextDrawLinearGradient(context, topGradient, bounds.origin, topEnd,
-	0.0);
+    FillRoundedRectangle(context, trackBounds, 1.5, trackColor);
+    CGContextClipToRect(context, clipBounds);
+    if (state & (TTK_STATE_BACKGROUND | TTK_STATE_DISABLED)) {
+	accentColor = isDark ? CGColorFromGray(darkInactiveTrack) :
+	    CGColorFromGray(lightInactiveTrack);
+    } else {
+	accentColor = CGCOLOR(controlAccentColor());
+    }
+    FillRoundedRectangle(context, trackBounds, 1.5, accentColor);
     CGContextRestoreGState(context);
-    CFRelease(topGradient);
+    DrawGrayButton(context, thumbBounds, &sliderDesign, state, tkwin);
+}
+
+/*----------------------------------------------------------------------
+ * +++ Drawing procedures for native widgets.
+ *
+ *      The HIToolbox does not support Dark Mode, and apparently never will.
+ *      It also draws some widgets in discontinued older styles even when used
+ *      on new OS releases.  So to make widgets look "native" we have to provide
+ *      analogues of the HIToolbox drawing functions to be used on newer systems.
+ *      We continue to use NIToolbox for older versions of the OS.
+ *
+ *      Drawing the dark widgets requires NSColors that were introduced in OSX
+ *      10.14, so we make some of these functions be no-ops when building on
+ *      systems older than 10.14.
+ */
+
+/*----------------------------------------------------------------------
+ * DrawButton --
+ *
+ * This is a standalone drawing procedure which draws most types of macOS
+ * buttons for newer OS releases.  The button style is specified in the
+ * "kind" field of a HIThemeButtonDrawInfo struct, although some of the
+ * identifiers are not recognized by HIToolbox.
+ */
+
+static void DrawButton(
+    CGRect bounds,
+    HIThemeButtonDrawInfo info,
+    Ttk_State state,
+    CGContextRef context,
+    Tk_Window tkwin)
+{
+    ThemeButtonKind kind = info.kind;
+    ThemeDrawState drawState = info.state;
+    CGRect arrowBounds = bounds = CGRectInset(bounds, 1, 1);
+    int hasIndicator, isDark = TkMacOSXInDarkMode(tkwin);
+
+    switch (kind) {
+    case TkRoundedRectButton:
+	DrawGrayButton(context, bounds, &roundedrectDesign, state, tkwin);
+	break;
+    case TkInlineButton:
+	DrawGrayButton(context, bounds, &inlineDesign, state, tkwin);
+	break;
+    case TkRecessedButton:
+	DrawGrayButton(context, bounds, &recessedDesign, state, tkwin);
+	break;
+    case kThemeRoundedBevelButton:
+	DrawGrayButton(context, bounds, &bevelDesign, state, tkwin);
+	break;
+    case kThemePushButton:
+
+	/*
+	 * The TTK_STATE_ALTERNATE bit means -default active.  Apple only
+	 * indicates the default state (which means that the key equivalent is
+	 * "\n") for Push Buttons.
+	 */
+
+	if ((state & TTK_STATE_PRESSED || state & TTK_STATE_ALTERNATE) &&
+	    !(state & TTK_STATE_BACKGROUND)) {
+	    DrawAccentedButton(context, bounds, &pushbuttonDesign, state, isDark);
+	} else {
+	    DrawGrayButton(context, bounds, &pushbuttonDesign, state, tkwin);
+	}
+	break;
+    case kThemeRoundButtonHelp:
+	DrawGrayButton(context, bounds, &helpDesign, state, tkwin);
+	DrawHelpSymbol(context, bounds, state);
+	break;
+    case kThemePopupButton:
+	drawState = 0;
+	DrawGrayButton(context, bounds, &popupDesign, state, tkwin);
+	arrowBounds.size.width = 17;
+	arrowBounds.origin.x += bounds.size.width - 17;
+	if (!(state & TTK_STATE_BACKGROUND) &&
+	    !(state & TTK_STATE_DISABLED)) {
+	    CGRect popupBounds = arrowBounds;
+
+	    /*
+	     * Allow room for nonexistent focus ring.
+	     */
+
+	    popupBounds.size.width += 4;
+	    popupBounds.origin.y -= 4;
+	    popupBounds.size.height += 8;
+	    DrawAccentedSegment(context, popupBounds, &popupDesign, state, tkwin);
+	    drawState = BOTH_ARROWS;
+	}
+	arrowBounds.origin.x += 2;
+	DrawUpDownArrows(context, arrowBounds, 3, 7, 2, state, drawState);
+	break;
+    case kThemeComboBox:
+	if (state & TTK_STATE_DISABLED) {
+	    // Need to add the disabled case to entryDesign.
+	    DrawEntry(context, bounds, &entryDesign, state, tkwin);
+	} else {
+	    DrawEntry(context, bounds, &entryDesign, state, tkwin);
+	}
+	arrowBounds.size.width = 17;
+	if (state & TTK_STATE_BACKGROUND) {
+	    arrowBounds.origin.x += bounds.size.width - 20;
+	    arrowBounds.size.width += 4;
+	    arrowBounds.origin.y -= 1;
+	} else {
+	    arrowBounds.origin.y -= 1;
+	    arrowBounds.origin.x += bounds.size.width - 20;
+	    arrowBounds.size.width += 4;
+	    arrowBounds.size.height += 2;
+	}
+	DrawAccentedSegment(context, arrowBounds, &comboDesign, state, tkwin);
+	if (!(state & TTK_STATE_BACKGROUND)) {
+	    state |= TTK_STATE_IS_ACCENTED;
+	}
+	DrawDownArrow(context, arrowBounds, 6, 6, state);
+	break;
+    case kThemeCheckBox:
+	bounds = CGRectOffset(CGRectMake(0, bounds.size.height / 2 - 8, 16, 16),
+			      bounds.origin.x, bounds.origin.y);
+	bounds = CGRectInset(bounds, 1, 1);
+	hasIndicator = state & TTK_STATE_SELECTED || state & TTK_STATE_ALTERNATE;
+	if (hasIndicator &&
+	    !(state & TTK_STATE_BACKGROUND) &&
+	    !(state & TTK_STATE_DISABLED)) {
+	    DrawAccentedButton(context, bounds, &checkDesign, 0, isDark);
+	} else {
+	    DrawGrayButton(context, bounds, &checkDesign, state, tkwin);
+	}
+	if (hasIndicator) {
+	    DrawCheckIndicator(context, bounds, state, isDark);
+	}
+	break;
+    case kThemeRadioButton:
+	bounds = CGRectOffset(CGRectMake(0, bounds.size.height / 2 - 9, 18, 18),
+					 bounds.origin.x, bounds.origin.y);
+	bounds = CGRectInset(bounds, 1, 1);
+	hasIndicator = state & TTK_STATE_SELECTED || state & TTK_STATE_ALTERNATE;
+	if (hasIndicator &&
+	    !(state & TTK_STATE_BACKGROUND) &&
+	    !(state & TTK_STATE_DISABLED)) {
+	    DrawAccentedButton(context, bounds, &radioDesign, 0, isDark);
+	} else {
+	    DrawGrayButton(context, bounds, &radioDesign, state, tkwin);
+	}
+	if (hasIndicator) {
+	    DrawRadioIndicator(context, bounds, state, isDark);
+	}
+	break;
+    case kThemeArrowButton:
+	DrawGrayButton(context, bounds, &pushbuttonDesign, state, tkwin);
+	arrowBounds.origin.x = bounds.origin.x + bounds.size.width - 17;
+	arrowBounds.size.width = 16;
+	arrowBounds.origin.y -= 1;
+	if (state & TTK_STATE_SELECTED) {
+	    DrawUpArrow(context, arrowBounds, 5, 6, state);
+	} else {
+	    DrawDownArrow(context, arrowBounds, 5, 6, state);
+	}
+	break;
+    case kThemeIncDecButton:
+	DrawGrayButton(context, bounds, &incdecDesign, state, tkwin);
+	if (state & TTK_STATE_PRESSED) {
+	    CGRect clip;
+	    if (drawState == kThemeStatePressedDown) {
+		clip = bounds;
+		clip.size.height /= 2;
+		clip.origin.y += clip.size.height;
+		bounds.size.height += 1;
+		clip.size.height += 1;
+	    } else {
+		clip = bounds;
+		clip.size.height /= 2;
+	    }
+	    CGContextSaveGState(context);
+	    CGContextClipToRect(context, clip);
+	    DrawAccentedButton(context, bounds, &incdecDesign, 0, isDark);
+	    CGContextRestoreGState(context);
+	}
+	{
+	    CGFloat inset = (bounds.size.width - 5) / 2;
+	    DrawUpDownArrows(context, bounds, inset, 5, 3, state, drawState);
+	}
+	break;
+    default:
+	break;
+    }
 }
-
+
 /*----------------------------------------------------------------------
  * DrawGroupBox --
  *
- *      This is a standalone drawing procedure which draws the contrasting
- *      rounded rectangular box for LabelFrames and Notebook panes used in
- *      more recent versions of macOS.
+ * This is a standalone drawing procedure which draws the contrasting rounded
+ * rectangular box for LabelFrames and Notebook panes used in more recent
+ * versions of macOS.  Normally the contrast is set to one, since the nesting
+ * level of the Group Box is higher by 1 compared to its container.  But we
+ * allow higher contrast for special cases, notably notebook tabs in macOS 11.
+ * The save parameter is passed to GetBackgroundColor and should probably be
+ * NO in such special cases.
  */
 
 static void DrawGroupBox(
     CGRect bounds,
     CGContextRef context,
-    Tk_Window tkwin)
+    Tk_Window tkwin,
+    int contrast,
+    Bool save)
 {
-    CHECK_RADIUS(4, bounds)
+    CHECK_RADIUS(5, bounds)
 
     CGPathRef path;
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    NSColor *borderColor, *bgColor;
-    static CGFloat border[4] = {1.0, 1.0, 1.0, 0.25};
-    CGFloat fill[4];
-
-    GetBackgroundColor(context, tkwin, 1, fill);
-    bgColor = [NSColor colorWithColorSpace: deviceRGB components: fill
-	count: 4];
-    CGContextSetFillColorSpace(context, deviceRGB.CGColorSpace);
-    CGContextSetFillColorWithColor(context, CGCOLOR(bgColor));
-    path = CGPathCreateWithRoundedRect(bounds, 4, 4, NULL);
+    CGColorRef backgroundColor, borderColor;
+
+    backgroundColor = GetBackgroundCGColor(context, tkwin, contrast, save);
+    borderColor = CGColorFromGray(boxBorder);
+    CGContextSetFillColorWithColor(context, backgroundColor);
+    path = CGPathCreateWithRoundedRect(bounds, 5, 5, NULL);
     CGContextClipToRect(context, bounds);
     CGContextBeginPath(context);
     CGContextAddPath(context, path);
     CGContextFillPath(context);
-    borderColor = [NSColor colorWithColorSpace: deviceRGB components: border
-	count: 4];
-    CGContextSetFillColorWithColor(context, CGCOLOR(borderColor));
-    [borderColor getComponents: fill];
-    CGContextSetRGBFillColor(context, fill[0], fill[1], fill[2], fill[3]);
-
+    CGContextSetFillColorWithColor(context, borderColor);
     CGContextBeginPath(context);
     CGContextAddPath(context, path);
     CGContextReplacePathWithStrokedPath(context);
     CGContextFillPath(context);
     CFRelease(path);
 }
-
-/*----------------------------------------------------------------------
- * SolidFillRoundedRectangle --
- *
- *      Fill a rounded rectangle with a specified solid color.
- */
-
-static void SolidFillRoundedRectangle(
-    CGContextRef context,
-    CGRect bounds,
-    CGFloat radius,
-    NSColor *color)
-{
-    CGPathRef path;
-
-    CHECK_RADIUS(radius, bounds)
-    path = CGPathCreateWithRoundedRect(bounds, radius, radius, NULL);
-    if (!path) {
-	return;
-    }
-    CGContextSetFillColorWithColor(context, CGCOLOR(color));
-    CGContextBeginPath(context);
-    CGContextAddPath(context, path);
-    CGContextFillPath(context);
-    CFRelease(path);
-}
-
-/*----------------------------------------------------------------------
- * +++ DrawListHeader --
- *
- *      This is a standalone drawing procedure which draws column headers for
- *      a Treeview in the Aqua appearance.  The HITheme headers have not
- *      matched the native ones since OSX 10.8.  Note that the header image is
- *      ignored, but we draw arrows according to the state.
+
+/*----------------------------------------------------------------------
+ * DrawListHeader --
+ *
+ * This is a standalone drawing procedure which draws column headers for a
+ * Treeview in the Aqua appearance.  (The HIToolbox headers have not matched the
+ * native ones since OSX 10.8)  Note that the header image is ignored, but we
+ * draw arrows according to the state.
  */
 
 static void DrawListHeader(
     CGRect bounds,
     CGContextRef context,
     Tk_Window tkwin,
     int state)
 {
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    NSColor *strokeColor, *bgColor;
-    static CGFloat borderRGBA[4] = {
-	200.0 / 255, 200.0 / 255, 200.0 / 255, 1.0
-    };
-    static CGFloat separatorRGBA[4] = {
-	220.0 / 255, 220.0 / 255, 220.0 / 255, 1.0
-    };
-    static CGFloat activeBgRGBA[4] = {
-	238.0 / 255, 238.0 / 255, 238.0 / 255, 1.0
-    };
-    static CGFloat inactiveBgRGBA[4] = {
-	246.0 / 255, 246.0 / 255, 246.0 / 255, 1.0
-    };
-
-    /*
-     * Apple changes the background of a list header when the window is not
-     * active.  But Ttk does not indicate that in the state of a TreeHeader.
-     * So we have to query the Apple window manager.
-     */
-
-    NSWindow *win = TkMacOSXGetNSWindowForDrawable(Tk_WindowId(tkwin));
-    CGFloat *bgRGBA = [win isKeyWindow] ? activeBgRGBA : inactiveBgRGBA;
+    int isDark = TkMacOSXInDarkMode(tkwin);
     CGFloat x = bounds.origin.x, y = bounds.origin.y;
     CGFloat w = bounds.size.width, h = bounds.size.height;
     CGPoint top[2] = {{x, y + 1}, {x + w, y + 1}};
     CGPoint bottom[2] = {{x, y + h}, {x + w, y + h}};
     CGPoint separator[2] = {{x + w - 1, y + 3}, {x + w - 1, y + h - 3}};
+    CGColorRef strokeColor, backgroundColor;
 
-    bgColor = [NSColor colorWithColorSpace: deviceRGB
-	components: bgRGBA
-	count: 4];
+    /*
+     * Apple changes the background color of a list header when the window is
+     * not active.  But Ttk does not indicate that in the state of a
+     * TreeHeader.  So we have to query the Apple window manager.
+     */
+
+    NSWindow *win = TkMacOSXGetNSWindowForDrawable(Tk_WindowId(tkwin));
+    if (!isDark) {
+	GrayColor bgGray = [win isKeyWindow] ?
+	    listheaderActiveBG : listheaderInactiveBG;
+	backgroundColor = CGColorFromGray(bgGray);
+    }
+
     CGContextSaveGState(context);
     CGContextSetShouldAntialias(context, false);
-    CGContextSetFillColorSpace(context, deviceRGB.CGColorSpace);
-    CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace);
-    CGContextBeginPath(context);
-    CGContextSetFillColorWithColor(context, CGCOLOR(bgColor));
-    CGContextAddRect(context, bounds);
-    CGContextFillPath(context);
-    strokeColor = [NSColor colorWithColorSpace: deviceRGB
-	components: separatorRGBA
-	count: 4];
-    CGContextSetStrokeColorWithColor(context, CGCOLOR(strokeColor));
+    if (!isDark) {
+	CGContextBeginPath(context);
+	CGContextSetFillColorWithColor(context, backgroundColor);
+	CGContextAddRect(context, bounds);
+	CGContextFillPath(context);
+    }
+    strokeColor = isDark ?
+	CGColorFromGray(darkListheaderBorder) :
+	CGColorFromGray(listheaderSeparator);
+    CGContextSetStrokeColorWithColor(context, strokeColor);
     CGContextAddLines(context, separator, 2);
     CGContextStrokePath(context);
-    strokeColor = [NSColor colorWithColorSpace: deviceRGB
-	components: borderRGBA
-	count: 4];
-    CGContextSetStrokeColorWithColor(context, CGCOLOR(strokeColor));
+    strokeColor = isDark ?
+	CGColorFromGray(darkListheaderBorder) :
+	CGColorFromGray(lightListheaderBorder);
+    CGContextSetStrokeColorWithColor(context, strokeColor);
     CGContextAddLines(context, top, 2);
     CGContextStrokePath(context);
     CGContextAddLines(context, bottom, 2);
     CGContextStrokePath(context);
     CGContextRestoreGState(context);
@@ -631,420 +1447,69 @@
     if (state & TTK_TREEVIEW_STATE_SORTARROW) {
 	CGRect arrowBounds = bounds;
 	arrowBounds.origin.x = bounds.origin.x + bounds.size.width - 16;
 	arrowBounds.size.width = 16;
 	if (state & TTK_STATE_ALTERNATE) {
-	    DrawUpArrow(context, arrowBounds, 3, 8, BLACKRGBA);
-	} else if (state & TTK_STATE_SELECTED) {
-	    DrawDownArrow(context, arrowBounds, 3, 8, BLACKRGBA);
-	}
-    }
-}
-
-/*----------------------------------------------------------------------
- * +++ Drawing procedures for widgets in Apple's "Dark Mode" (10.14 and up).
- *
- *      The HIToolbox does not support Dark Mode, and apparently never will,
- *      so to make widgets look "native" we have to provide analogues of the
- *      HITheme drawing functions to be used in DarkAqua.  We continue to use
- *      HITheme in Aqua, since it understands earlier versions of the OS.
- *
- *      Drawing the dark widgets requires NSColors that were introduced in OSX
- *      10.14, so we make some of these functions be no-ops when building on
- *      systems older than 10.14.
- */
-
-/*----------------------------------------------------------------------
- * GradientFillRoundedRectangle --
- *
- *      Fill a rounded rectangle with a specified gradient.
- */
-
-static void GradientFillRoundedRectangle(
-    CGContextRef context,
-    CGRect bounds,
-    CGFloat radius,
-    CGFloat *colors,
-    int numColors)
-{
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    CGPathRef path;
-    CHECK_RADIUS(radius, bounds)
-
-    CGPoint end = {
-	bounds.origin.x,
-	bounds.origin.y + bounds.size.height
-    };
-    CGGradientRef gradient = CGGradientCreateWithColorComponents(
-	deviceRGB.CGColorSpace, colors, NULL, numColors);
-
-    path = CGPathCreateWithRoundedRect(bounds, radius, radius, NULL);
-    CGContextBeginPath(context);
-    CGContextAddPath(context, path);
-    CGContextClip(context);
-    CGContextDrawLinearGradient(context, gradient, bounds.origin, end, 0);
-    CFRelease(path);
-    CFRelease(gradient);
-}
-
-/*----------------------------------------------------------------------
- * +++ DrawDarkButton --
- *
- *      This is a standalone drawing procedure which draws PushButtons and
- *      PopupButtons in the Dark Mode style.
- */
-
-static void DrawDarkButton(
-    CGRect bounds,
-    ThemeButtonKind kind,
-    Ttk_State state,
-    CGContextRef context)
-{
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    NSColor *faceColor;
-
-    /*
-     * To match the appearance of Apple's buttons we need to increase the
-     * height by 1 pixel.
-     */
-
-    bounds.size.height += 1;
-
-    CGContextClipToRect(context, bounds);
-    FillButtonBackground(context, bounds, 5);
-
-    /*
-     * Fill the button face with the appropriate color.
-     */
-
-    bounds = CGRectInset(bounds, 1, 1);
-    if (kind == kThemePushButton && (state & TTK_STATE_PRESSED)) {
-	GradientFillRoundedRectangle(context, bounds, 4,
-	    pressedPushButtonGradient, 2);
-    } else if (kind == kThemePushButton &&
-	       (state & TTK_STATE_ALTERNATE) &&
-	       !(state & TTK_STATE_BACKGROUND)) {
-	GradientFillRoundedRectangle(context, bounds, 4,
-	    darkSelectedGradient, 2);
-    } else {
-	if (state & TTK_STATE_DISABLED) {
-	    faceColor = [NSColor colorWithColorSpace: deviceRGB
-		components: darkDisabledButtonFace
-		count: 4];
-	} else {
-	    faceColor = [NSColor colorWithColorSpace: deviceRGB
-		components: darkButtonFace
-		count: 4];
-	}
-	SolidFillRoundedRectangle(context, bounds, 4, faceColor);
-    }
-
-    /*
-     * If this is a popup, draw the arrow button.
-     */
-
-    if ((kind == kThemePopupButton) | (kind == kThemeComboBox)) {
-	CGRect arrowBounds = bounds;
-	arrowBounds.size.width = 16;
-	arrowBounds.origin.x += bounds.size.width - 16;
-
-        /*
-         * If the toplevel is front, paint the button blue.
-         */
-
-	if (!(state & TTK_STATE_BACKGROUND) &&
-	    !(state & TTK_STATE_DISABLED)) {
-	    GradientFillRoundedRectangle(context, arrowBounds, 4,
-		darkSelectedGradient, 2);
-	}
-	if (kind == kThemePopupButton) {
-	    DrawUpDownArrows(context, arrowBounds, 3, 7, WHITERGBA);
-	} else {
-	    DrawDownArrow(context, arrowBounds, 4, 8, WHITERGBA);
-	}
-    }
-
-    HighlightButtonBorder(context, bounds);
-}
-
-/*----------------------------------------------------------------------
- * +++ DrawDarkIncDecButton --
- *
- *      This is a standalone drawing procedure which draws an IncDecButton
- *      (as used in a Spinbox) in the Dark Mode style.
- */
-
-static void DrawDarkIncDecButton(
-    CGRect bounds,
-    ThemeDrawState drawState,
-    Ttk_State state,
-    CGContextRef context)
-{
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    NSColor *faceColor;
-
-    bounds = CGRectInset(bounds, 0, -1);
-    CGContextClipToRect(context, bounds);
-    FillButtonBackground(context, bounds, 6);
-
-    /*
-     * Fill the button face with the appropriate color.
-     */
-
-    bounds = CGRectInset(bounds, 1, 1);
-    if (state & TTK_STATE_DISABLED) {
-	faceColor = [NSColor colorWithColorSpace: deviceRGB
-	    components: darkDisabledButtonFace
-	    count: 4];
-    } else {
-	faceColor = [NSColor colorWithColorSpace: deviceRGB
-	    components: darkButtonFace
-	    count: 4];
-    }
-    SolidFillRoundedRectangle(context, bounds, 4, faceColor);
-
-    /*
-     * If pressed, paint the appropriate half blue.
-     */
-
-    if (state & TTK_STATE_PRESSED) {
-	CGRect clip = bounds;
-	clip.size.height /= 2;
-	CGContextSaveGState(context);
-	if (drawState == kThemeStatePressedDown) {
-	    clip.origin.y += clip.size.height;
-	}
-	CGContextClipToRect(context, clip);
-	GradientFillRoundedRectangle(context, bounds, 5,
-	    darkSelectedGradient, 2);
-	CGContextRestoreGState(context);
-    }
-    DrawUpDownArrows(context, bounds, 3, 5, WHITERGBA);
-    HighlightButtonBorder(context, bounds);
-}
-
-/*----------------------------------------------------------------------
- * +++ DrawDarkBevelButton --
- *
- *      This is a standalone drawing procedure which draws RoundedBevelButtons
- *      in the Dark Mode style.
- */
-
-static void DrawDarkBevelButton(
-    CGRect bounds,
-    Ttk_State state,
-    CGContextRef context)
-{
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    NSColor *faceColor;
-
-    CGContextClipToRect(context, bounds);
-    FillButtonBackground(context, bounds, 5);
-
-    /*
-     * Fill the button face with the appropriate color.
-     */
-
-    bounds = CGRectInset(bounds, 1, 1);
-    if (state & TTK_STATE_PRESSED) {
-	faceColor = [NSColor colorWithColorSpace: deviceRGB
-	    components: darkPressedBevelFace
-	    count: 4];
-    } else if ((state & TTK_STATE_DISABLED) ||
-	(state & TTK_STATE_ALTERNATE)) {
-	faceColor = [NSColor colorWithColorSpace: deviceRGB
-	    components: darkDisabledButtonFace
-	    count: 4];
-    } else if (state & TTK_STATE_SELECTED) {
-	faceColor = [NSColor colorWithColorSpace: deviceRGB
-	    components: darkSelectedBevelFace
-	    count: 4];
-    } else {
-	faceColor = [NSColor colorWithColorSpace: deviceRGB
-	    components: darkButtonFace
-	    count: 4];
-    }
-    SolidFillRoundedRectangle(context, bounds, 4, faceColor);
-    HighlightButtonBorder(context, bounds);
-}
-
-/*----------------------------------------------------------------------
- * +++ DrawDarkCheckBox --
- *
- *      This is a standalone drawing procedure which draws Checkboxes in the
- *      Dark Mode style.
- */
-
-static void DrawDarkCheckBox(
-    CGRect bounds,
-    Ttk_State state,
-    CGContextRef context)
-{
-    CGRect checkbounds = {{0, bounds.size.height / 2 - 8}, {16, 16}};
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    NSColor *stroke;
-    CGFloat x, y;
-
-    bounds = CGRectOffset(checkbounds, bounds.origin.x, bounds.origin.y);
-    x = bounds.origin.x;
-    y = bounds.origin.y;
-
-    CGContextClipToRect(context, bounds);
-    FillButtonBackground(context, bounds, 4);
-    bounds = CGRectInset(bounds, 1, 1);
-    if (!(state & TTK_STATE_BACKGROUND) &&
-	!(state & TTK_STATE_DISABLED) &&
-	((state & TTK_STATE_SELECTED) || (state & TTK_STATE_ALTERNATE))) {
-	GradientFillRoundedRectangle(context, bounds, 3,
-	    darkSelectedGradient, 2);
-    } else {
-	GradientFillRoundedRectangle(context, bounds, 3,
-	    darkInactiveGradient, 2);
-    }
-    HighlightButtonBorder(context, bounds);
-    if ((state & TTK_STATE_SELECTED) || (state & TTK_STATE_ALTERNATE)) {
-	CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace);
-	if (state & TTK_STATE_DISABLED) {
-	    stroke = [NSColor disabledControlTextColor];
-	} else {
-	    stroke = [NSColor controlTextColor];
-	}
-	CGContextSetStrokeColorWithColor(context, CGCOLOR(stroke));
-    }
-    if (state & TTK_STATE_SELECTED) {
-	CGContextSetLineWidth(context, 1.5);
-	CGContextBeginPath(context);
-	CGPoint check[3] = {{x + 4, y + 8}, {x + 7, y + 11}, {x + 11, y + 4}};
-	CGContextAddLines(context, check, 3);
-	CGContextStrokePath(context);
-    } else if (state & TTK_STATE_ALTERNATE) {
-	CGContextSetLineWidth(context, 2.0);
-	CGContextBeginPath(context);
-	CGPoint bar[2] = {{x + 4, y + 8}, {x + 12, y + 8}};
-	CGContextAddLines(context, bar, 2);
-	CGContextStrokePath(context);
-    }
-}
-
-/*----------------------------------------------------------------------
- * +++ DrawDarkRadioButton --
- *
- *    This is a standalone drawing procedure which draws RadioButtons
- *    in the Dark Mode style.
- */
-
-static void DrawDarkRadioButton(
-    CGRect bounds,
-    Ttk_State state,
-    CGContextRef context)
-{
-    CGRect checkbounds = {{0, bounds.size.height / 2 - 9}, {18, 18}};
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    NSColor *fill;
-    CGFloat x, y;
-
-    bounds = CGRectOffset(checkbounds, bounds.origin.x, bounds.origin.y);
-    x = bounds.origin.x;
-    y = bounds.origin.y;
-
-    CGContextClipToRect(context, bounds);
-    FillButtonBackground(context, bounds, 9);
-    bounds = CGRectInset(bounds, 1, 1);
-    if (!(state & TTK_STATE_BACKGROUND) &&
-	!(state & TTK_STATE_DISABLED) &&
-	((state & TTK_STATE_SELECTED) || (state & TTK_STATE_ALTERNATE))) {
-	GradientFillRoundedRectangle(context, bounds, 8,
-	    darkSelectedGradient, 2);
-    } else {
-	GradientFillRoundedRectangle(context, bounds, 8,
-	    darkInactiveGradient, 2);
-    }
-    HighlightButtonBorder(context, bounds);
-    if ((state & TTK_STATE_SELECTED) || (state & TTK_STATE_ALTERNATE)) {
-	CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace);
-	if (state & TTK_STATE_DISABLED) {
-	    fill = [NSColor disabledControlTextColor];
-	} else {
-	    fill = [NSColor controlTextColor];
-	}
-	CGContextSetFillColorWithColor(context, CGCOLOR(fill));
-    }
-    if (state & TTK_STATE_SELECTED) {
-	CGContextBeginPath(context);
-	CGRect dot = {{x + 6, y + 6}, {6, 6}};
-	CGContextAddEllipseInRect(context, dot);
-	CGContextFillPath(context);
-    } else if (state & TTK_STATE_ALTERNATE) {
-	CGRect bar = {{x + 5, y + 8}, {8, 2}};
-	CGContextFillRect(context, bar);
-    }
-}
-
-/*----------------------------------------------------------------------
- * +++ DrawDarkTab --
- *
- *      This is a standalone drawing procedure which draws Tabbed Pane
- *      Tabs in the Dark Mode style.
- */
-
-static void DrawDarkTab(
-    CGRect bounds,
-    Ttk_State state,
-    CGContextRef context)
-{
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    NSColor *faceColor, *stroke;
-    CGRect originalBounds = bounds;
-
-    CGContextSetLineWidth(context, 1.0);
-    CGContextClipToRect(context, bounds);
+	    DrawUpArrow(context, arrowBounds, 3, 8, state);
+	} else if (state & TTK_STATE_SELECTED) {
+	    DrawDownArrow(context, arrowBounds, 3, 8, state);
+	}
+    }
+}
+
+/*----------------------------------------------------------------------
+ * DrawTab --
+ *
+ * This is a standalone drawing procedure which draws Tabbed Pane Tabs for the
+ * notebook widget.
+ */
+
+static void
+DrawTab(
+    CGRect bounds,
+    Ttk_State state,
+    CGContextRef context,
+    Tk_Window tkwin)
+{
+    CGRect originalBounds = bounds;
+    CGColorRef strokeColor;
+    int OSVersion = [NSApp macOSVersion];
 
     /*
      * Extend the bounds to one or both sides so the rounded part will be
-     * clipped off.
+     * clipped off if the right of the left tab, the left of the right tab,
+     * and both sides of the middle tabs.
      */
 
-    if (!(state & TTK_STATE_FIRST_TAB)) {
-	bounds.origin.x -= 10;
-	bounds.size.width += 10;
-    }
-
-    if (!(state & TTK_STATE_LAST_TAB)) {
-	bounds.size.width += 10;
-    }
-
+    CGContextClipToRect(context, bounds);
+    if (OSVersion < 110000 || !(state & TTK_STATE_SELECTED)) {
+	if (!(state & TTK_STATE_FIRST_TAB)) {
+	    bounds.origin.x -= 10;
+	    bounds.size.width += 10;
+	}
+	if (!(state & TTK_STATE_LAST_TAB)) {
+	    bounds.size.width += 10;
+	}
+    }
     /*
      * Fill the tab face with the appropriate color or gradient.  Use a solid
-     * color if the tab is not selected, otherwise use a blue or gray
-     * gradient.
+     * color if the tab is not selected, otherwise use the accent color with
+     * highlights
      */
 
-    bounds = CGRectInset(bounds, 1, 1);
     if (!(state & TTK_STATE_SELECTED)) {
-	if (state & TTK_STATE_DISABLED) {
-	    faceColor = [NSColor colorWithColorSpace: deviceRGB
-		components: darkDisabledButtonFace
-		count: 4];
-	} else {
-	    faceColor = [NSColor colorWithColorSpace: deviceRGB
-		components: darkButtonFace
-		count: 4];
-	}
-	SolidFillRoundedRectangle(context, bounds, 4, faceColor);
+	DrawGrayButton(context, bounds, &tabDesign, state, tkwin);
 
         /*
          * Draw a separator line on the left side of the tab if it
          * not first.
          */
 
 	if (!(state & TTK_STATE_FIRST_TAB)) {
 	    CGContextSaveGState(context);
-	    CGContextSetShouldAntialias(context, false);
-	    stroke = [NSColor colorWithColorSpace: deviceRGB
-		components: darkTabSeparator
-		count: 4];
-	    CGContextSetStrokeColorWithColor(context, CGCOLOR(stroke));
+	    strokeColor = CGColorFromGray(darkTabSeparator);
+	    CGContextSetStrokeColorWithColor(context, strokeColor);
 	    CGContextBeginPath(context);
 	    CGContextMoveToPoint(context, originalBounds.origin.x,
 		originalBounds.origin.y + 1);
 	    CGContextAddLineToPoint(context, originalBounds.origin.x,
 		originalBounds.origin.y + originalBounds.size.height - 1);
@@ -1051,304 +1516,133 @@
 	    CGContextStrokePath(context);
 	    CGContextRestoreGState(context);
 	}
     } else {
 
-        /*
-         * This is the selected tab; paint it blue.  If it is first, cover up
-         * the separator line drawn by the second one.  (The selected tab is
-         * always drawn last.)
-         */
+	/*
+	 * This is the selected tab; paint it with the current accent color.
+	 * If it is first, cover up the separator line drawn by the second one.
+	 * (The selected tab is always drawn last.)
+	 */
 
 	if ((state & TTK_STATE_FIRST_TAB) && !(state & TTK_STATE_LAST_TAB)) {
 	    bounds.size.width += 1;
 	}
 	if (!(state & TTK_STATE_BACKGROUND)) {
-	    GradientFillRoundedRectangle(context, bounds, 4,
-		darkSelectedGradient, 2);
+	    DrawAccentedButton(context, bounds, &tabDesign, 0, 0);
 	} else {
-	    faceColor = [NSColor colorWithColorSpace: deviceRGB
-		components: darkInactiveSelectedTab
-		count: 4];
-	    SolidFillRoundedRectangle(context, bounds, 4, faceColor);
-	}
-	HighlightButtonBorder(context, bounds);
-    }
-}
-
-/*----------------------------------------------------------------------
- * +++ DrawDarkSeparator --
- *
- *      This is a standalone drawing procedure which draws a separator widget
- *      in Dark Mode.
+	    DrawGrayButton(context, bounds, &tabDesign, state, tkwin);
+	}
+    }
+}
+
+static void
+DrawTab11(
+    CGRect bounds,
+    Ttk_State state,
+    CGContextRef context,
+    Tk_Window tkwin)
+{
+
+    if (state & TTK_STATE_SELECTED) {
+	DrawGrayButton(context, bounds, &pushbuttonDesign, state, tkwin);
+    } else {
+	CGRect clipRect = bounds;
+	/*
+	 * Draw a segment of a Group Box as a background for non-selected tabs.
+	 * Clip the Group Box so that the segments fit together to form a long
+	 * rounded rectangle behind the entire tab bar.
+	 */
+
+	if (!(state & TTK_STATE_FIRST_TAB)) {
+	    clipRect.origin.x -= 5;
+	    bounds.origin.x -= 5;
+	    bounds.size.width += 5;
+	}
+	if (!(state & TTK_STATE_LAST_TAB)) {
+	    clipRect.size.width += 5;
+	    bounds.size.width += 5;
+	}
+	CGContextSaveGState(context);
+	CGContextClipToRect(context, clipRect);
+	DrawGroupBox(bounds, context, tkwin, 3, NO);
+	CGContextRestoreGState(context);
+    }
+}
+
+/*----------------------------------------------------------------------
+ * DrawDarkSeparator --
+ *
+ * This is a standalone drawing procedure which draws a separator widget
+ * in Dark Mode.  HIToolbox is used in light mode.
  */
 
 static void DrawDarkSeparator(
     CGRect bounds,
     CGContextRef context,
     TCL_UNUSED(Tk_Window))
 {
-    static CGFloat fill[4] = {1.0, 1.0, 1.0, 0.3};
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    NSColor *fillColor = [NSColor colorWithColorSpace: deviceRGB
-	components: fill
-	count:4];
+    CGColorRef sepColor = CGColorFromGray(darkSeparator);
 
-    CGContextSetFillColorWithColor(context, CGCOLOR(fillColor));
+    CGContextSetFillColorWithColor(context, sepColor);
     CGContextFillRect(context, bounds);
 }
 
 /*----------------------------------------------------------------------
- * +++ DrawDarkFocusRing --
- *
- *      This is a standalone drawing procedure which draws a focus ring around
- *      an Entry widget in Dark Mode.
- */
-
-static void DrawDarkFocusRing(
-    CGRect bounds,
-    CGContextRef context)
-{
-    CGRect insetBounds = CGRectInset(bounds, -3, -3);
-    CHECK_RADIUS(4, insetBounds)
-
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    NSColor *strokeColor;
-    NSColor *fillColor = [NSColor colorWithColorSpace:deviceRGB
-					   components:darkFocusRing
-						count:4];
-    CGFloat x = bounds.origin.x, y = bounds.origin.y;
-    CGFloat w = bounds.size.width, h = bounds.size.height;
-    CGPoint topPart[4] = {
-	{x, y + h}, {x, y + 1}, {x + w - 1, y + 1}, {x + w - 1, y + h}
-    };
-    CGPoint bottom[2] = {{x, y + h}, {x + w, y + h}};
-
-    CGContextSaveGState(context);
-    CGContextSetShouldAntialias(context, false);
-    CGContextBeginPath(context);
-    strokeColor = [NSColor colorWithColorSpace: deviceRGB
-				    components: darkFocusRingTop
-					 count: 4];
-    CGContextSetStrokeColorWithColor(context, CGCOLOR(strokeColor));
-    CGContextAddLines(context, topPart, 4);
-    CGContextStrokePath(context);
-    strokeColor = [NSColor colorWithColorSpace: deviceRGB
-				    components: darkFocusRingBottom
-					 count: 4];
-    CGContextSetStrokeColorWithColor(context, CGCOLOR(strokeColor));
-    CGContextAddLines(context, bottom, 2);
-    CGContextStrokePath(context);
-    CGContextSetShouldAntialias(context, true);
-    CGContextSetFillColorWithColor(context, CGCOLOR(fillColor));
-    CGPathRef path = CGPathCreateWithRoundedRect(insetBounds, 4, 4, NULL);
-    CGContextBeginPath(context);
-    CGContextAddPath(context, path);
-    CGContextAddRect(context, bounds);
-    CGContextEOFillPath(context);
-    CGContextRestoreGState(context);
-}
-/*----------------------------------------------------------------------
- * +++ DrawDarkFrame --
- *
- *      This is a standalone drawing procedure which draws various
- *      types of borders in Dark Mode.
- */
-
-static void DrawDarkFrame(
-    CGRect bounds,
-    CGContextRef context,
-    HIThemeFrameKind kind)
-{
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    NSColor *stroke;
-
-    CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace);
-    CGFloat x = bounds.origin.x, y = bounds.origin.y;
-    CGFloat w = bounds.size.width, h = bounds.size.height;
-    CGPoint topPart[4] = {
-	{x, y + h - 1}, {x, y + 1}, {x + w, y + 1}, {x + w, y + h - 1}
-    };
-    CGPoint bottom[2] = {{x, y + h}, {x + w, y + h}};
-    CGPoint accent[2] = {{x, y + 1}, {x + w, y + 1}};
-
-    switch (kind) {
-    case kHIThemeFrameTextFieldSquare:
-	CGContextSaveGState(context);
-	CGContextSetShouldAntialias(context, false);
-	CGContextBeginPath(context);
-	stroke = [NSColor colorWithColorSpace: deviceRGB
-	    components: darkFrameTop
-	    count: 4];
-	CGContextSetStrokeColorWithColor(context, CGCOLOR(stroke));
-	CGContextAddLines(context, topPart, 4);
-	CGContextStrokePath(context);
-	stroke = [NSColor colorWithColorSpace: deviceRGB
-	    components: darkFrameBottom
-	    count: 4];
-	CGContextSetStrokeColorWithColor(context, CGCOLOR(stroke));
-	CGContextAddLines(context, bottom, 2);
-	CGContextStrokePath(context);
-	stroke = [NSColor colorWithColorSpace: deviceRGB
-	    components: darkFrameAccent
-	    count: 4];
-	CGContextSetStrokeColorWithColor(context, CGCOLOR(stroke));
-	CGContextAddLines(context, accent, 2);
-	CGContextStrokePath(context);
-	CGContextRestoreGState(context);
-	break;
-    default:
-	break;
-    }
-}
-
-/*----------------------------------------------------------------------
- * +++ DrawListHeader --
- *
- *      This is a standalone drawing procedure which draws column
- *      headers for a Treeview in the Dark Mode.
- */
-
-static void DrawDarkListHeader(
-    CGRect bounds,
-    CGContextRef context,
-    TCL_UNUSED(Tk_Window),
-    int state)
-{
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    NSColor *stroke;
-
-    CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace);
-    CGFloat x = bounds.origin.x, y = bounds.origin.y;
-    CGFloat w = bounds.size.width, h = bounds.size.height;
-
-    CGPoint top[2] = {{x, y + 1}, {x + w, y + 1}};
-    CGPoint bottom[2] = {{x, y + h}, {x + w, y + h}};
-    CGPoint separator[2] = {{x + w - 1, y + 3}, {x + w - 1, y + h - 3}};
-    CGContextSaveGState(context);
-    CGContextSetShouldAntialias(context, false);
-    stroke = [NSColor colorWithColorSpace: deviceRGB
-	components: darkFrameBottom
-	count: 4];
-    CGContextSetStrokeColorWithColor(context, CGCOLOR(stroke));
-    CGContextBeginPath(context);
-    CGContextAddLines(context, top, 2);
-    CGContextStrokePath(context);
-    CGContextAddLines(context, bottom, 2);
-    CGContextStrokePath(context);
-    CGContextAddLines(context, separator, 2);
-    CGContextStrokePath(context);
-    CGContextRestoreGState(context);
-
-    if (state & TTK_TREEVIEW_STATE_SORTARROW) {
-	CGRect arrowBounds = bounds;
-
-	arrowBounds.origin.x = bounds.origin.x + bounds.size.width - 16;
-	arrowBounds.size.width = 16;
-	if (state & TTK_STATE_ALTERNATE) {
-	    DrawUpArrow(context, arrowBounds, 3, 8, WHITERGBA);
-	} else if (state & TTK_STATE_SELECTED) {
-	    DrawDownArrow(context, arrowBounds, 3, 8, WHITERGBA);
-	}
-    }
-}
-
-/*----------------------------------------------------------------------
- * +++ Button element: Used for elements drawn with DrawThemeButton.
- */
-
-/*
- * When Ttk draws the various types of buttons, a pointer to one of these
- * is passed as the clientData.
- */
-
-typedef struct {
-    ThemeButtonKind kind;
-    ThemeMetric heightMetric;
-} ThemeButtonParams;
-static ThemeButtonParams
-    PushButtonParams =  {kThemePushButton, kThemeMetricPushButtonHeight},
-    CheckBoxParams =    {kThemeCheckBox, kThemeMetricCheckBoxHeight},
-    RadioButtonParams = {kThemeRadioButton, kThemeMetricRadioButtonHeight},
-    BevelButtonParams = {kThemeRoundedBevelButton, NoThemeMetric},
-    PopupButtonParams = {kThemePopupButton, kThemeMetricPopupButtonHeight},
-    DisclosureParams =  {
-    kThemeDisclosureButton, kThemeMetricDisclosureTriangleHeight
-},
-    ListHeaderParams =
-{kThemeListHeaderButton, kThemeMetricListHeaderHeight};
-static Ttk_StateTable ButtonValueTable[] = {
-    {kThemeButtonOff, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND, 0},
-    {kThemeButtonMixed, TTK_STATE_ALTERNATE, 0},
-    {kThemeButtonOn, TTK_STATE_SELECTED, 0},
-    {kThemeButtonOff, 0, 0}
-
-    /*
-     * Others: kThemeDisclosureRight, kThemeDisclosureDown,
-     * kThemeDisclosureLeft
-     */
-
-};
-static Ttk_StateTable ButtonAdornmentTable[] = {
-    {kThemeAdornmentNone, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND, 0},
-    {kThemeAdornmentDefault | kThemeAdornmentFocus,
-     TTK_STATE_ALTERNATE | TTK_STATE_FOCUS, 0},
-    {kThemeAdornmentFocus, TTK_STATE_FOCUS, 0},
-    {kThemeAdornmentDefault, TTK_STATE_ALTERNATE, 0},
-    {kThemeAdornmentNone, 0, 0}
-};
-
-/*----------------------------------------------------------------------
- * +++ computeButtonDrawInfo --
- *
- *      Fill in an appearance manager HIThemeButtonDrawInfo record.
- */
-
-static inline HIThemeButtonDrawInfo computeButtonDrawInfo(
-    ThemeButtonParams *params,
-    Ttk_State state,
-    TCL_UNUSED(Tk_Window))
-{
-
-    /*
-     * See ButtonElementDraw for the explanation of why we always draw
-     * PushButtons in the active state.
-     */
-
-    SInt32 HIThemeState;
-
-    HIThemeState = Ttk_StateTableLookup(ThemeStateTable, state);
-    switch (params->kind) {
-    case kThemePushButton:
-	HIThemeState &= ~kThemeStateInactive;
-	HIThemeState |= kThemeStateActive;
-	break;
-    default:
-	break;
-    }
-
-    const HIThemeButtonDrawInfo info = {
-	.version = 0,
-	.state = HIThemeState,
-	.kind = params ? params->kind : 0,
-	.value = Ttk_StateTableLookup(ButtonValueTable, state),
-	.adornment = Ttk_StateTableLookup(ButtonAdornmentTable, state),
-    };
-    return info;
+ * +++ DrawGradientButton --
+ *
+ *      This is a standalone drawing procedure which draws a
+ *      a Gradient Button.
+ */
+
+static void DrawGradientBorder(
+    CGRect bounds,
+    CGContextRef context,
+    Tk_Window tkwin,
+    Ttk_State state)
+{
+    CGColorRef faceColor, borderColor;
+    GrayColor faceGray, borderGray;
+    CGRect inside = CGRectInset(bounds, 1, 1);
+
+    if (TkMacOSXInDarkMode(tkwin)) {
+	if (state & TTK_STATE_DISABLED) {
+	    faceGray = darkGradientDisabled;
+	    borderGray = darkGradientBorderDisabled;
+	} else {
+	    faceGray = state & TTK_STATE_PRESSED ?
+		darkGradientPressed : darkGradientNormal;
+	    borderGray = darkGradientBorder;
+	}
+    } else {
+	if (state & TTK_STATE_DISABLED) {
+	    faceGray = lightGradientDisabled;
+	    borderGray = lightGradientBorderDisabled;
+	} else {
+	    faceGray = state & TTK_STATE_PRESSED ?
+		lightGradientPressed : lightGradientNormal;
+	    borderGray = lightGradientBorder;
+	}
+    }
+    faceColor = CGColorFromGray(faceGray);
+    borderColor = CGColorFromGray(borderGray);
+    CGContextSetFillColorWithColor(context, faceColor);
+    CGContextFillRect(context, inside);
+    CGContextSetFillColorWithColor(context, borderColor);
+    CGContextAddRect(context, bounds);
+    CGContextAddRect(context, inside);
+    CGContextEOFillPath(context);
 }
 
 /*----------------------------------------------------------------------
  * +++ Button elements.
  */
 
 static void ButtonElementMinSize(
     void *clientData,
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
     int *minWidth,
-    int *minHeight,
-    TCL_UNUSED(Ttk_Padding *))
+    int *minHeight)
 {
     ThemeButtonParams *params = (ThemeButtonParams *)clientData;
 
     if (params->heightMetric != NoThemeMetric) {
 	ChkErr(GetThemeMetric, params->heightMetric, minHeight);
@@ -1360,46 +1654,67 @@
          */
 
 	*minHeight += 2;
 
         /*
-         * The minwidth must be 0 to force the generic ttk code to compute the
+         * For buttons with labels the minwidth must be 0 to force the
          * correct text layout.  For example, a non-zero value will cause the
          * text to be left justified, no matter what -anchor setting is used in
          * the style.
          */
 
-	*minWidth = 0;
+	if (params->widthMetric != NoThemeMetric) {
+	    ChkErr(GetThemeMetric, params->widthMetric, minWidth);
+	    *minWidth += 2;
+	    *minHeight += 2;
+	} else {
+	    *minWidth = 0;
+	}
     }
 }
 
 static void ButtonElementSize(
     void *clientData,
-    void *elementRecord,
+    TCL_UNUSED(void *), /* elementRecord */
     Tk_Window tkwin,
     int *minWidth,
     int *minHeight,
     Ttk_Padding *paddingPtr)
 {
-    ThemeButtonParams *params = clientData;
-    const HIThemeButtonDrawInfo info =
-	computeButtonDrawInfo(params, 0, tkwin);
+    ThemeButtonParams *params = (ThemeButtonParams *)clientData;
+    HIThemeButtonDrawInfo info =
+	ComputeButtonDrawInfo(params, 0, tkwin);
     static const CGRect scratchBounds = {{0, 0}, {100, 100}};
     CGRect contentBounds, backgroundBounds;
     int verticalPad;
 
-    ButtonElementMinSize(clientData, elementRecord, tkwin,
-	minWidth, minHeight, paddingPtr);
+    ButtonElementMinSize(clientData, minWidth, minHeight);
+    switch (info.kind) {
+    case TkGradientButton:
+	*paddingPtr = Ttk_MakePadding(1, 1, 1, 1);
+        /* Fall through. */
+    case kThemeArrowButton:
+    case kThemeRoundButtonHelp:
+        return;
+	/* Buttons which are sized like PushButtons but unknown to HITheme. */
+    case TkRoundedRectButton:
+    case TkRecessedButton:
+    case TkInlineButton:
+	info.kind = kThemePushButton;
+	break;
+    default:
+        break;
+    }
 
     /*
      * Given a hypothetical bounding rectangle for a button, HIToolbox will
      * compute a bounding rectangle for the button contents and a bounding
      * rectangle for the button background.  The background bounds are large
      * enough to contain the image of the button in any state, which might
      * include highlight borders, shadows, etc.  The content rectangle is not
      * centered vertically within the background rectangle, presumably because
-     * shadows only appear on the bottom.  Nonetheless, when HITools is asked
+     * shadows only appear on the bottom.  Nonetheless, when HIToolbox is asked
      * to draw a button with a certain bounding rectangle it draws the button
      * centered within the rectangle.
      *
      * To compute the effective padding around a button we request the
      * content and bounding rectangles for a 100x100 button and use the
@@ -1414,87 +1729,117 @@
     paddingPtr->left = contentBounds.origin.x - backgroundBounds.origin.x;
     paddingPtr->right =
 	CGRectGetMaxX(backgroundBounds) - CGRectGetMaxX(contentBounds);
     verticalPad = backgroundBounds.size.height - contentBounds.size.height;
     paddingPtr->top = paddingPtr->bottom = verticalPad / 2;
+    if (info.kind == kThemePopupButton) {
+	paddingPtr->top += 1;
+	paddingPtr->bottom -= 1;
+    }
 }
 
 static void ButtonElementDraw(
     void *clientData,
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *), /* elementRecord */
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
-    ThemeButtonParams *params = clientData;
+    ThemeButtonParams *params = (ThemeButtonParams *)clientData;
     CGRect bounds = BoxToRect(d, b);
-    HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, state, tkwin);
+    HIThemeButtonDrawInfo info = ComputeButtonDrawInfo(params, state, tkwin);
+    int isDark = TkMacOSXInDarkMode(tkwin);
 
-    bounds = NormalizeButtonBounds(params->heightMetric, bounds);
+    switch (info.kind) {
+
+    /*
+     * A Gradient Button should have an image and no text.  The size is set to
+     * that of the image.  All we need to do is draw a 1-pixel border.
+     */
+
+    case TkGradientButton:
+	BEGIN_DRAWING(d)
+	    DrawGradientBorder(bounds, dc.context, tkwin, state);
+	END_DRAWING
+	return;
+    /*
+     * Buttons with no height restrictions are ready to draw.
+     */
+
+    case kThemeArrowButton:
+    case kThemeCheckBox:
+    case kThemeRadioButton:
+    	break;
+
+    /*
+     * Other buttons have a maximum height.   We have to deal with that.
+     */
+
+    default:
+	bounds = NormalizeButtonBounds(params, bounds, isDark);
+	break;
+    }
+
+    /* We do our own drawing on new systems.*/
+
+    if ([NSApp macOSVersion] > 100800) {
+	BEGIN_DRAWING(d)
+	DrawButton(bounds, info, state, dc.context, tkwin);
+	END_DRAWING
+	return;
+    }
+
+    /*
+     * If execution reaches here it means we should use HIToolbox to draw the
+     * button.  Buttons that HIToolbox doesn't know are rendered as
+     * PushButtons.
+     */
+
+    switch (info.kind) {
+    case TkRoundedRectButton:
+    case TkRecessedButton:
+	info.kind = kThemePushButton;
+	break;
+    default:
+	break;
+    }
+
+    /*
+     * Apple's PushButton and PopupButton do not change their fill color
+     * when the window is inactive.  However, except in 10.7 (Lion), the
+     * color of the arrow button on a PopupButton does change.  For some
+     * reason HITheme fills inactive buttons with a transparent color that
+     * allows the window background to show through, leading to
+     * inconsistent behavior.  We work around this by filling behind an
+     * inactive PopupButton with a text background color before asking
+     * HIToolbox to draw it. For PushButtons, we simply draw them in the
+     * active state.
+     */
 
     BEGIN_DRAWING(d)
-    if (TkMacOSXInDarkMode(tkwin)) {
-	switch (info.kind) {
-	case kThemePushButton:
-	case kThemePopupButton:
-	    DrawDarkButton(bounds, info.kind, state, dc.context);
-	    break;
-	case kThemeCheckBox:
-	    DrawDarkCheckBox(bounds, state, dc.context);
-	    break;
-	case kThemeRadioButton:
-	    DrawDarkRadioButton(bounds, state, dc.context);
-	    break;
-	case kThemeRoundedBevelButton:
-	    DrawDarkBevelButton(bounds, state, dc.context);
-	    break;
-	default:
-	    ChkErr(HIThemeDrawButton, &bounds, &info, dc.context,
-		HIOrientation, NULL);
-	}
-    } else if (info.kind == kThemePushButton &&
-	       (state & TTK_STATE_PRESSED)) {
-	bounds.size.height += 2;
-	if ([NSApp macOSVersion] > 100800) {
-	    GradientFillRoundedRectangle(dc.context, bounds, 4,
-					 pressedPushButtonGradient, 2);
-	}
-    } else {
-
-        /*
-         * Apple's PushButton and PopupButton do not change their fill color
-         * when the window is inactive.  However, except in 10.7 (Lion), the
-         * color of the arrow button on a PopupButton does change.  For some
-         * reason HITheme fills inactive buttons with a transparent color that
-         * allows the window background to show through, leading to
-         * inconsistent behavior.  We work around this by filling behind an
-         * inactive PopupButton with a text background color before asking
-         * HIToolbox to draw it. For PushButtons, we simply draw them in the
-         * active state.
-         */
-
-	if (info.kind == kThemePopupButton &&
-	    (state & TTK_STATE_BACKGROUND)) {
-	    CGRect innerBounds = CGRectInset(bounds, 1, 1);
-	    NSColor *whiteRGBA = [NSColor whiteColor];
-	    SolidFillRoundedRectangle(dc.context, innerBounds, 4, whiteRGBA);
-	}
-
-        /*
-         * A BevelButton with mixed value is drawn borderless, which does make
-         * much sense for us.
-         */
-
-	if (info.kind == kThemeRoundedBevelButton &&
-	    info.value == kThemeButtonMixed) {
-	    info.value = kThemeButtonOff;
-	    info.state = kThemeStateInactive;
-	}
-	ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation,
-	    NULL);
-    }
+    if (info.kind == kThemePopupButton  &&
+	(state & TTK_STATE_BACKGROUND)) {
+	CGRect innerBounds = CGRectInset(bounds, 1, 1);
+	FillRoundedRectangle(dc.context, innerBounds, 4, CG_WHITE);
+    }
+
+    /*
+     * A BevelButton with mixed value is drawn borderless, which does make
+     * much sense for us.
+     */
+
+    if (info.kind == kThemeRoundedBevelButton &&
+	info.value == kThemeButtonMixed) {
+	info.value = kThemeButtonOff;
+	info.state = kThemeStateInactive;
+    }
+    if (info.kind == kThemePushButton) {
+	bounds.origin.y -= 2;
+    }
+    ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation,
+	   NULL);
     END_DRAWING
 }
 
 static Ttk_ElementSpec ButtonElementSpec = {
     TK_STYLE_VERSION_2,
@@ -1507,26 +1852,26 @@
 /*----------------------------------------------------------------------
  * +++ Notebook elements.
  */
 
 /* Tab position logic, c.f. ttkNotebook.c TabState() */
-static Ttk_StateTable TabStyleTable[] = {
+static const Ttk_StateTable TabStyleTable[] = {
     {kThemeTabFrontInactive, TTK_STATE_SELECTED | TTK_STATE_BACKGROUND, 0},
     {kThemeTabNonFrontInactive, TTK_STATE_BACKGROUND, 0},
     {kThemeTabFrontUnavailable, TTK_STATE_DISABLED | TTK_STATE_SELECTED, 0},
     {kThemeTabNonFrontUnavailable, TTK_STATE_DISABLED, 0},
     {kThemeTabFront, TTK_STATE_SELECTED, 0},
     {kThemeTabNonFrontPressed, TTK_STATE_PRESSED, 0},
     {kThemeTabNonFront, 0, 0}
 };
-static Ttk_StateTable TabAdornmentTable[] = {
+static const Ttk_StateTable TabAdornmentTable[] = {
     {kHIThemeTabAdornmentNone, TTK_STATE_FIRST_TAB | TTK_STATE_LAST_TAB, 0},
     {kHIThemeTabAdornmentTrailingSeparator, TTK_STATE_FIRST_TAB, 0},
     {kHIThemeTabAdornmentNone, TTK_STATE_LAST_TAB, 0},
     {kHIThemeTabAdornmentTrailingSeparator, 0, 0},
 };
-static Ttk_StateTable TabPositionTable[] = {
+static const Ttk_StateTable TabPositionTable[] = {
     {kHIThemeTabPositionOnly, TTK_STATE_FIRST_TAB | TTK_STATE_LAST_TAB, 0},
     {kHIThemeTabPositionFirst, TTK_STATE_FIRST_TAB, 0},
     {kHIThemeTabPositionLast, TTK_STATE_LAST_TAB, 0},
     {kHIThemeTabPositionMiddle, 0, 0},
 };
@@ -1570,45 +1915,44 @@
  *       AppleHIGuidelines/XHIGControls/XHIGControls.html#//apple_ref/doc/uid/
  *       TP30000359-TPXREF116>
  */
 
 static void TabElementSize(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
-    TCL_UNUSED(int *),
-    int *minHeight,
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
+    TCL_UNUSED(Tk_Window), /* tkwin */
+    TCL_UNUSED(int *),     /* minWidth */
+    TCL_UNUSED(int *),     /* minHeight */
     Ttk_Padding *paddingPtr)
 {
-    GetThemeMetric(kThemeMetricLargeTabHeight, (SInt32 *) minHeight);
-    *paddingPtr = Ttk_MakePadding(0, 0, 0, 2);
-
+    *paddingPtr = Ttk_MakePadding(0, -2, 0, 1);
 }
 
 static void TabElementDraw(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
     CGRect bounds = BoxToRect(d, b);
-    HIThemeTabDrawInfo info = {
-	.version = 1,
-	.style = Ttk_StateTableLookup(TabStyleTable, state),
-	.direction = kThemeTabNorth,
-	.size = kHIThemeTabSizeNormal,
-	.adornment = Ttk_StateTableLookup(TabAdornmentTable, state),
-	.kind = kHIThemeTabKindNormal,
-	.position = Ttk_StateTableLookup(TabPositionTable, state),
-    };
-
     BEGIN_DRAWING(d)
-    if (TkMacOSXInDarkMode(tkwin)) {
-	DrawDarkTab(bounds, state, dc.context);
+    if ([NSApp macOSVersion] >= 110000) {
+	DrawTab11(bounds, state, dc.context, tkwin);
+    } else if ([NSApp macOSVersion] > 100800) {
+	DrawTab(bounds, state, dc.context, tkwin);
     } else {
+	HIThemeTabDrawInfo info = {
+	    .version = 1,
+	    .style = Ttk_StateTableLookup(TabStyleTable, state),
+	    .direction = kThemeTabNorth,
+	    .size = kHIThemeTabSizeNormal,
+	    .adornment = Ttk_StateTableLookup(TabAdornmentTable, state),
+	    .kind = kHIThemeTabKindNormal,
+	    .position = Ttk_StateTableLookup(TabPositionTable, state),
+	};
 	ChkErr(HIThemeDrawTab, &bounds, &info, dc.context, HIOrientation,
 	    NULL);
     }
     END_DRAWING
 }
@@ -1624,23 +1968,23 @@
 /*
  * Notebook panes:
  */
 
 static void PaneElementSize(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
-    TCL_UNUSED(int *),
-    TCL_UNUSED(int *),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
+    TCL_UNUSED(Tk_Window), /* tkwin */
+    TCL_UNUSED(int *),     /* minWidth */
+    TCL_UNUSED(int *),     /* minHeight */
     Ttk_Padding *paddingPtr)
 {
     *paddingPtr = Ttk_MakePadding(9, 5, 9, 9);
 }
 
 static void PaneElementDraw(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
@@ -1648,11 +1992,11 @@
 
     bounds.origin.y -= kThemeMetricTabFrameOverlap;
     bounds.size.height += kThemeMetricTabFrameOverlap;
     BEGIN_DRAWING(d)
     if ([NSApp macOSVersion] > 100800) {
-	DrawGroupBox(bounds, dc.context, tkwin);
+	DrawGroupBox(bounds, dc.context, tkwin, 1, YES);
     } else {
 	HIThemeTabPaneDrawInfo info = {
 	    .version = 1,
 	    .state = Ttk_StateTableLookup(ThemeStateTable, state),
 	    .direction = kThemeTabNorth,
@@ -1680,38 +2024,36 @@
  *
  * Labelframe borders: Use "primary group box ..."  Quoth
  * DrawThemePrimaryGroup reference: "The primary group box frame is drawn
  * inside the specified rectangle and is a maximum of 2 pixels thick."
  *
- * "Maximum of 2 pixels thick" is apparently a lie; looks more like 4 to me
- * with shading.
  */
 
 static void GroupElementSize(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
-    TCL_UNUSED(int *),
-    TCL_UNUSED(int *),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
+    TCL_UNUSED(Tk_Window), /* tkwin */
+    TCL_UNUSED(int *),     /* minWidth */
+    TCL_UNUSED(int *),     /* minHeight */
     Ttk_Padding *paddingPtr)
 {
-    *paddingPtr = Ttk_UniformPadding(4);
+    *paddingPtr = Ttk_MakePadding(0, 0, 0, 0);
 }
 
 static void GroupElementDraw(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
     CGRect bounds = BoxToRect(d, b);
 
     BEGIN_DRAWING(d)
     if ([NSApp macOSVersion] > 100800) {
-	DrawGroupBox(bounds, dc.context, tkwin);
+	DrawGroupBox(bounds, dc.context, tkwin, 1, YES);
     } else {
 	const HIThemeGroupBoxDrawInfo info = {
 	    .version = 0,
 	    .state = Ttk_StateTableLookup(ThemeStateTable, state),
 	    .kind = kHIThemeGroupBoxKindPrimaryOpaque,
@@ -1750,63 +2092,54 @@
      offsetof(EntryElement, fieldbackgroundObj), ENTRY_DEFAULT_BACKGROUND},
     {NULL, TK_OPTION_BOOLEAN, 0, NULL}
 };
 
 static void EntryElementSize(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
-    TCL_UNUSED(int *),
-    TCL_UNUSED(int *),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
+    TCL_UNUSED(Tk_Window), /* tkwin */
+    TCL_UNUSED(int *),     /* minWidth */
+    TCL_UNUSED(int *),     /* minHeight */
     Ttk_Padding *paddingPtr)
 {
-    *paddingPtr = Ttk_MakePadding(7, 5, 7, 6);
+    *paddingPtr = entryElementPadding;
 }
 
 static void EntryElementDraw(
-    TCL_UNUSED(void *),
+    void *clientData,
     void *elementRecord,
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
-    EntryElement *e = elementRecord;
-    Ttk_Box inner = Ttk_PadBox(b, Ttk_UniformPadding(3));
-    CGRect bounds = BoxToRect(d, inner);
-    NSColor *background;
+    EntryElement *e = (EntryElement *)elementRecord;
+    ThemeFrameParams *params = (ThemeFrameParams *)clientData;
+    HIThemeFrameKind kind = params ? params->kind :
+	kHIThemeFrameTextFieldSquare;
+    CGRect bounds = BoxToRect(d, b);
+    CGColorRef background;
     Tk_3DBorder backgroundPtr = NULL;
     static const char *defaultBG = ENTRY_DEFAULT_BACKGROUND;
 
-    if (TkMacOSXInDarkMode(tkwin)) {
+    if ([NSApp macOSVersion] > 100800) {
 	BEGIN_DRAWING(d)
-	NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-	CGFloat fill[4];
-	GetBackgroundColor(dc.context, tkwin, 1, fill);
-
-	/*
-	 * Lighten the background to provide contrast.
-	 */
-
-	for (int i = 0; i < 3; i++) {
-		fill[i] += 9.0 / 255.0;
-	    }
-	background = [NSColor colorWithColorSpace: deviceRGB
-	    components: fill
-	    count: 4];
-	CGContextSetFillColorWithColor(dc.context, CGCOLOR(background));
-	CGContextFillRect(dc.context, bounds);
-	if (state & TTK_STATE_FOCUS) {
-	    DrawDarkFocusRing(bounds, dc.context);
-	} else {
-	    DrawDarkFrame(bounds, dc.context, kHIThemeFrameTextFieldSquare);
-	}
+	    switch(kind) {
+	    case kHIThemeFrameTextFieldRound:
+		DrawEntry(dc.context, bounds, &searchDesign, state, tkwin);
+		break;
+	    case kHIThemeFrameTextFieldSquare:
+		DrawEntry(dc.context, bounds, &entryDesign, state, tkwin);
+		break;
+	    default:
+		return;
+	    }
 	END_DRAWING
     } else {
 	const HIThemeFrameDrawInfo info = {
 	    .version = 0,
-	    .kind = kHIThemeFrameTextFieldSquare,
+	    .kind = params->kind,
 	    .state = Ttk_StateTableLookup(ThemeStateTable, state),
 	    .isFocused = state & TTK_STATE_FOCUS,
 	};
 
         /*
@@ -1825,17 +2158,17 @@
 	    backgroundPtr = Tk_Get3DBorderFromObj(tkwin, e->backgroundObj);
 	}
 	if (backgroundPtr != NULL) {
 	    XFillRectangle(Tk_Display(tkwin), d,
 		Tk_3DBorderGC(tkwin, backgroundPtr, TK_3D_FLAT_GC),
-		inner.x, inner.y, inner.width, inner.height);
+		b.x, b.y, b.width, b.height);
 	}
 	BEGIN_DRAWING(d)
 	if (backgroundPtr == NULL) {
 	    if ([NSApp macOSVersion] > 100800) {
-		background = [NSColor textBackgroundColor];
-		CGContextSetFillColorWithColor(dc.context, CGCOLOR(background));
+		background = CGCOLOR([NSColor textBackgroundColor]);
+		CGContextSetFillColorWithColor(dc.context, background);
 	    } else {
 		CGContextSetRGBFillColor(dc.context, 1.0, 1.0, 1.0, 1.0);
 	    }
 	    CGContextFillRect(dc.context, bounds);
 	}
@@ -1870,28 +2203,29 @@
  *      With no help available from HIToolbox, we have to use hard-wired
  *      constants for the padding. We shift the bounding rectangle downward by
  *      1 pixel to account for the fact that the button is not centered.
  */
 
-static Ttk_Padding ComboboxPadding = {4, 2, 20, 2};
+// OS dependent ???
+static Ttk_Padding ComboboxPadding = {7, 5, 24, 5};
 
 static void ComboboxElementSize(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
+    TCL_UNUSED(Tk_Window), /* tkwin */
     int *minWidth,
     int *minHeight,
     Ttk_Padding *paddingPtr)
 {
     *minWidth = 24;
-    *minHeight = 23;
+    *minHeight = 0;
     *paddingPtr = ComboboxPadding;
 }
 
 static void ComboboxElementDraw(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
@@ -1903,23 +2237,18 @@
 	.value = Ttk_StateTableLookup(ButtonValueTable, state),
 	.adornment = Ttk_StateTableLookup(ButtonAdornmentTable, state),
     };
 
     BEGIN_DRAWING(d)
-    bounds.origin.y += 1;
-    if (TkMacOSXInDarkMode(tkwin)) {
-	bounds.size.height += 1;
-	DrawDarkButton(bounds, info.kind, state, dc.context);
-    } else if ([NSApp macOSVersion] > 100800) {
-	if ((state & TTK_STATE_BACKGROUND) &&
-	    !(state & TTK_STATE_DISABLED)) {
-	    NSColor *background = [NSColor textBackgroundColor];
-	    CGRect innerBounds = CGRectInset(bounds, 1, 2);
-	    SolidFillRoundedRectangle(dc.context, innerBounds, 4, background);
-	}
-    }
-    ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
+    if ([NSApp macOSVersion] > 100800) {
+	bounds = CGRectInset(bounds, -1, -1);
+	DrawButton(bounds, info, state, dc.context, tkwin);
+    } else {
+	bounds.origin.y += 1;
+	ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation,
+	       NULL);
+    }
     END_DRAWING
 }
 
 static Ttk_ElementSpec ComboboxElementSpec = {
     TK_STYLE_VERSION_2,
@@ -1948,39 +2277,55 @@
  *      drawn twice, first in unpressed state by the up arrow and then in
  *      "pressed down" state by the down button.  The drawing must be done in
  *      that order.  So the up button must be listed first in the layout.
  */
 
-static Ttk_Padding SpinbuttonMargins = {0, 0, 2, 0};
+static Ttk_Padding SpinbuttonMargins = {2, 0, 0, 0};
 
-static void SpinButtonUpElementSize(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
+static void SpinButtonReBounds(
+    Tk_Window tkwin,
+    CGRect *bounds)
+{
+    if (TkMacOSXInDarkMode(tkwin)) {
+	bounds->origin.x -= 2;
+	bounds->origin.y += 1;
+	bounds->size.height -= 0.5;
+    } else {
+	bounds->origin.x -= 3;
+	bounds->origin.y += 1;
+	bounds->size.width += 1;
+    }
+}
+
+static void SpinButtonElementSize(
+    TCL_UNUSED(void *),       /* clientdata */
+    TCL_UNUSED(void *),       /* elementRecord */
+    TCL_UNUSED(Tk_Window),    /* tkwin */
     int *minWidth,
     int *minHeight,
-    TCL_UNUSED(Ttk_Padding *))
+    TCL_UNUSED(Ttk_Padding *)) /* PaddingPtr */
 {
     SInt32 s;
 
     ChkErr(GetThemeMetric, kThemeMetricLittleArrowsWidth, &s);
     *minWidth = s + Ttk_PaddingWidth(SpinbuttonMargins);
     ChkErr(GetThemeMetric, kThemeMetricLittleArrowsHeight, &s);
-    *minHeight = (s + Ttk_PaddingHeight(SpinbuttonMargins)) / 2;
+    *minHeight = 2 + (s + Ttk_PaddingHeight(SpinbuttonMargins)) / 2;
 }
 
 static void SpinButtonUpElementDraw(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
     CGRect bounds = BoxToRect(d, Ttk_PadBox(b, SpinbuttonMargins));
     int infoState;
 
+    SpinButtonReBounds(tkwin, &bounds);
     bounds.size.height *= 2;
     if (state & TTK_STATE_PRESSED) {
 	infoState = kThemeStatePressedUp;
     } else {
 	infoState = Ttk_StateTableLookup(ThemeStateTable, state);
@@ -1991,12 +2336,12 @@
 	.kind = kThemeIncDecButton,
 	.value = Ttk_StateTableLookup(ButtonValueTable, state),
 	.adornment = kThemeAdornmentNone,
     };
     BEGIN_DRAWING(d)
-    if (TkMacOSXInDarkMode(tkwin)) {
-	DrawDarkIncDecButton(bounds, infoState, state, dc.context);
+    if ([NSApp macOSVersion] > 100800) {
+	DrawButton(bounds, info, state, dc.context, tkwin);
     } else {
 	ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation,
 	       NULL);
     }
     END_DRAWING
@@ -2004,42 +2349,28 @@
 
 static Ttk_ElementSpec SpinButtonUpElementSpec = {
     TK_STYLE_VERSION_2,
     sizeof(NullElement),
     TtkNullElementOptions,
-    SpinButtonUpElementSize,
+    SpinButtonElementSize,
     SpinButtonUpElementDraw
 };
-static void SpinButtonDownElementSize(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
-    int *minWidth,
-    int *minHeight,
-    TCL_UNUSED(Ttk_Padding *))
-{
-    SInt32 s;
-
-    ChkErr(GetThemeMetric, kThemeMetricLittleArrowsWidth, &s);
-    *minWidth = s + Ttk_PaddingWidth(SpinbuttonMargins);
-    ChkErr(GetThemeMetric, kThemeMetricLittleArrowsHeight, &s);
-    *minHeight = (s + Ttk_PaddingHeight(SpinbuttonMargins)) / 2;
-}
 
 static void SpinButtonDownElementDraw(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
     CGRect bounds = BoxToRect(d, Ttk_PadBox(b, SpinbuttonMargins));
     int infoState = 0;
 
+    SpinButtonReBounds(tkwin, &bounds);
     bounds.origin.y -= bounds.size.height;
-    bounds.size.height *= 2;
+    bounds.size.height += bounds.size.height;
     if (state & TTK_STATE_PRESSED) {
 	infoState = kThemeStatePressedDown;
     } else {
 	return;
     }
@@ -2050,12 +2381,12 @@
 	.value = Ttk_StateTableLookup(ButtonValueTable, state),
 	.adornment = kThemeAdornmentNone,
     };
 
     BEGIN_DRAWING(d)
-    if (TkMacOSXInDarkMode(tkwin)) {
-	DrawDarkIncDecButton(bounds, infoState, state, dc.context);
+    if ([NSApp macOSVersion] > 100800) {
+	DrawButton(bounds, info, state, dc.context, tkwin);
     } else {
 	ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation,
 	       NULL);
     }
     END_DRAWING
@@ -2063,11 +2394,11 @@
 
 static Ttk_ElementSpec SpinButtonDownElementSpec = {
     TK_STYLE_VERSION_2,
     sizeof(NullElement),
     TtkNullElementOptions,
-    SpinButtonDownElementSize,
+    SpinButtonElementSize,
     SpinButtonDownElementDraw
 };
 
 /*----------------------------------------------------------------------
  * +++ DrawThemeTrack-based elements --
@@ -2078,11 +2409,11 @@
 /*
  * Apple does not change the appearance of a slider when the window becomes
  * inactive.  So we shouldn't either.
  */
 
-static Ttk_StateTable ThemeTrackEnableTable[] = {
+static const Ttk_StateTable ThemeTrackEnableTable[] = {
     {kThemeTrackDisabled, TTK_STATE_DISABLED, 0},
     {kThemeTrackActive, TTK_STATE_BACKGROUND, 0},
     {kThemeTrackActive, 0, 0}
     /* { kThemeTrackNothingToScroll, ?, ? }, */
 };
@@ -2110,15 +2441,15 @@
     {"-orient", TK_OPTION_STRING, offsetof(TrackElement, orientObj), NULL},
     {NULL, TK_OPTION_BOOLEAN, 0, NULL}
 };
 static void TrackElementSize(
     void *clientData,
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
+    TCL_UNUSED(void *),       /* elementRecord */
+    TCL_UNUSED(Tk_Window),    /* tkwin */
     int *minWidth,
     int *minHeight,
-    TCL_UNUSED(Ttk_Padding *))
+    TCL_UNUSED(Ttk_Padding *)) /* paddingPtr */
 {
     TrackElementData *data = (TrackElementData *)clientData;
     SInt32 size = 24;   /* reasonable default ... */
 
     ChkErr(GetThemeMetric, data->thicknessMetric, &size);
@@ -2131,40 +2462,35 @@
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
-    TrackElementData *data = clientData;
-    TrackElement *elem = elementRecord;
+    TrackElementData *data = (TrackElementData *)clientData;
+    TrackElement *elem = (TrackElement *)elementRecord;
     Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
-    double from = 0, to = 100, value = 0, factor;
-    CGRect bounds;
+    double from = 0, to = 100, value = 0, fraction, max;
+    CGRect bounds = BoxToRect(d, b);
 
     TtkGetOrientFromObj(NULL, elem->orientObj, &orientation);
     Tcl_GetDoubleFromObj(NULL, elem->fromObj, &from);
     Tcl_GetDoubleFromObj(NULL, elem->toObj, &to);
     Tcl_GetDoubleFromObj(NULL, elem->valueObj, &value);
-    factor = RangeToFactor(to);
-
-    /*
-     * HIThemeTrackDrawInfo uses 2-byte alignment; assigning to a separate
-     * bounds variable avoids UBSan (-fsanitize=alignment) complaints.
-     */
-
-    bounds = BoxToRect(d, b);
+
+    fraction = (value - from) / (to - from);
+    max = RangeToFactor(fabs(to - from));
     HIThemeTrackDrawInfo info = {
 	.version = 0,
 	.kind = data->kind,
 	.bounds = bounds,
-	.min = from * factor,
-	.max = to * factor,
-	.value = value * factor,
+	.min = 0,
+	.max = max,
+	.value = fraction * max,
 	.attributes = kThemeTrackShowThumb |
 	    (orientation == TTK_ORIENT_HORIZONTAL ?
 	    kThemeTrackHorizontal : 0),
 	.enableState = Ttk_StateTableLookup(ThemeTrackEnableTable, state),
-	.trackInfo.progress.phase = 0,
+	.trackInfo.progress.phase = 0
     };
 
     if (info.kind == kThemeSlider) {
 	info.trackInfo.slider.pressState = state & TTK_STATE_PRESSED ?
 	    kThemeThumbPressed : 0;
@@ -2173,24 +2499,23 @@
 	} else {
 	    info.trackInfo.slider.thumbDir = kThemeThumbPlain;
 	}
     }
     BEGIN_DRAWING(d)
-    if (TkMacOSXInDarkMode(tkwin)) {
-	bounds = BoxToRect(d, b);
-	NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-	NSColor *trackColor = [NSColor colorWithColorSpace: deviceRGB
-	    components: darkTrack
-	    count: 4];
-	if (orientation == TTK_ORIENT_HORIZONTAL) {
-	    bounds = CGRectInset(bounds, 1, bounds.size.height / 2 - 2);
-	} else {
-	    bounds = CGRectInset(bounds, bounds.size.width / 2 - 3, 2);
-	}
-	SolidFillRoundedRectangle(dc.context, bounds, 2, trackColor);
-    }
-    ChkErr(HIThemeDrawTrack, &info, NULL, dc.context, HIOrientation);
+    if (([NSApp macOSVersion] > 100800) && !(state & TTK_STATE_ALTERNATE)) {
+
+	/*
+	 * We use the reserved field to indicate whether "from" is less than
+	 * "to".  It should be 0 if passing the info to HIThemeDrawInfo, but
+	 * we aren't doing that.
+	 */
+
+	info.reserved = (from < to);
+	DrawSlider(dc.context, bounds, info, state, tkwin);
+    } else {
+	ChkErr(HIThemeDrawTrack, &info, NULL, dc.context, HIOrientation);
+    }
     END_DRAWING
 }
 
 static Ttk_ElementSpec TrackElementSpec = {
     TK_STYLE_VERSION_2,
@@ -2208,16 +2533,16 @@
  * drawn as part of the trough element.
  *
  */
 
 static void SliderElementSize(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
+    TCL_UNUSED(void *),        /* clientData */
+    TCL_UNUSED(void *),        /* elementRecord */
+    TCL_UNUSED(Tk_Window),     /* tkwin */
     int *minWidth,
     int *minHeight,
-    TCL_UNUSED(Ttk_Padding *))
+    TCL_UNUSED(Ttk_Padding *)) /* paddingPtr */
 {
     *minWidth = *minHeight = 24;
 }
 
 static Ttk_ElementSpec SliderElementSpec = {
@@ -2256,55 +2581,60 @@
     {"-mode", TK_OPTION_STRING,
      offsetof(PbarElement, modeObj), "determinate"},
     {NULL, TK_OPTION_BOOLEAN, 0, NULL}
 };
 static void PbarElementSize(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
+    TCL_UNUSED(void *),        /* clientData */
+    TCL_UNUSED(void *),        /* elementRecord */
+    TCL_UNUSED(Tk_Window),     /* tkwin */
     int *minWidth,
     int *minHeight,
-    TCL_UNUSED(Ttk_Padding *))
+    TCL_UNUSED(Ttk_Padding *)) /* paddingPtr */
 {
     SInt32 size = 24;           /* @@@ Check HIG for correct default */
 
     ChkErr(GetThemeMetric, kThemeMetricLargeProgressBarThickness, &size);
     *minWidth = *minHeight = size;
 }
 
 static void PbarElementDraw(
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* clientData */
     void *elementRecord,
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
-    PbarElement *pbar = elementRecord;
+    PbarElement *pbar = (PbarElement *)elementRecord;
     Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
-    int phase = 0;
+    int phase;
     double value = 0, maximum = 100, factor;
-    CGRect bounds;
+    CGRect bounds = BoxToRect(d, b);
+    int isIndeterminate = !strcmp("indeterminate",
+				  Tcl_GetString(pbar->modeObj));
 
     TtkGetOrientFromObj(NULL, pbar->orientObj, &orientation);
     Tcl_GetDoubleFromObj(NULL, pbar->valueObj, &value);
     Tcl_GetDoubleFromObj(NULL, pbar->maximumObj, &maximum);
     Tcl_GetIntFromObj(NULL, pbar->phaseObj, &phase);
+
+    if (isIndeterminate) {
+
+	/*
+	 * When an indeterminate progress bar is animated the phase is
+	 * (currently) always 0 and the value increases from min to max
+	 * and then decreases back to min.  We scale the value by 3 to
+	 * speed the animation up a bit.
+	 */
+
+	double remainder = fmod(3*value, 2*maximum);
+	value = remainder > maximum ? 2*maximum - remainder : remainder;
+    }
     factor = RangeToFactor(maximum);
-
-    /*
-     * HIThemeTrackDrawInfo uses 2-byte alignment; assigning to a separate
-     * bounds variable avoids UBSan (-fsanitize=alignment) complaints.
-     */
-
-    bounds = BoxToRect(d, b);
     HIThemeTrackDrawInfo info = {
 	.version = 0,
-	.kind =
-	    (!strcmp("indeterminate",
-	    Tcl_GetString(pbar->modeObj)) && value) ?
-	    kThemeIndeterminateBar : kThemeProgressBar,
+	.kind = isIndeterminate? kThemeIndeterminateBar : kThemeProgressBar,
 	.bounds = bounds,
 	.min = 0,
 	.max = maximum * factor,
 	.value = value * factor,
 	.attributes = kThemeTrackShowThumb |
@@ -2313,24 +2643,15 @@
 	.enableState = Ttk_StateTableLookup(ThemeTrackEnableTable, state),
 	.trackInfo.progress.phase = phase,
     };
 
     BEGIN_DRAWING(d)
-    if (TkMacOSXInDarkMode(tkwin)) {
-	bounds = BoxToRect(d, b);
-	NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-	NSColor *trackColor = [NSColor colorWithColorSpace: deviceRGB
-	    components: darkTrack
-	    count: 4];
-	if (orientation == TTK_ORIENT_HORIZONTAL) {
-	    bounds = CGRectInset(bounds, 1, bounds.size.height / 2 - 3);
-	} else {
-	    bounds = CGRectInset(bounds, bounds.size.width / 2 - 3, 1);
-	}
-	SolidFillRoundedRectangle(dc.context, bounds, 3, trackColor);
-    }
-    ChkErr(HIThemeDrawTrack, &info, NULL, dc.context, HIOrientation);
+    if ([NSApp macOSVersion] > 100800) {
+	DrawProgressBar(dc.context, bounds, info, state, tkwin);
+    } else {
+	ChkErr(HIThemeDrawTrack, &info, NULL, dc.context, HIOrientation);
+    }
     END_DRAWING
 }
 
 static Ttk_ElementSpec PbarElementSpec = {
     TK_STYLE_VERSION_2,
@@ -2353,18 +2674,18 @@
     {"-orient", TK_OPTION_STRING,
      offsetof(ScrollbarElement, orientObj), "horizontal"},
     {NULL, TK_OPTION_BOOLEAN, 0, NULL}
 };
 static void TroughElementSize(
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* clientData */
     void *elementRecord,
-    TCL_UNUSED(Tk_Window),
+    TCL_UNUSED(Tk_Window), /* tkwin */
     int *minWidth,
     int *minHeight,
     Ttk_Padding *paddingPtr)
 {
-    ScrollbarElement *scrollbar = elementRecord;
+    ScrollbarElement *scrollbar = (ScrollbarElement *)elementRecord;
     Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
     SInt32 thickness = 15;
 
     TtkGetOrientFromObj(NULL, scrollbar->orientObj, &orientation);
     ChkErr(GetThemeMetric, kThemeMetricScrollBarWidth, &thickness);
@@ -2379,51 +2700,33 @@
 	    *paddingPtr = Ttk_MakePadding(4, 4, 3, 4);
 	}
     }
 }
 
-static CGFloat lightTrough[4] = {250.0 / 255, 250.0 / 255, 250.0 / 255, 1.0};
-static CGFloat darkTrough[4] = {45.0 / 255, 46.0 / 255, 49.0 / 255, 1.0};
-static CGFloat lightInactiveThumb[4] = {
-    200.0 / 255, 200.0 / 255, 200.0 / 255, 1.0
-};
-static CGFloat lightActiveThumb[4] = {
-    133.0 / 255, 133.0 / 255, 133.0 / 255, 1.0
-};
-static CGFloat darkInactiveThumb[4] = {
-    116.0 / 255, 117.0 / 255, 118.0 / 255, 1.0
-};
-static CGFloat darkActiveThumb[4] = {
-    158.0 / 255, 158.0 / 255, 159.0 / 255, 1.0
-};
 static void TroughElementDraw(
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* clientData */
     void *elementRecord,
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
-    TCL_UNUSED(Ttk_State))
+    TCL_UNUSED(Ttk_State)) /* state */
 {
-    ScrollbarElement *scrollbar = elementRecord;
+    ScrollbarElement *scrollbar = (ScrollbarElement *)elementRecord;
     Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
     CGRect bounds = BoxToRect(d, b);
-    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-    NSColor *troughColor;
-    CGFloat *rgba = TkMacOSXInDarkMode(tkwin) ? darkTrough : lightTrough;
+    GrayColor bgGray;
 
     TtkGetOrientFromObj(NULL, scrollbar->orientObj, &orientation);
     if (orientation == TTK_ORIENT_HORIZONTAL) {
 	bounds = CGRectInset(bounds, 0, 1);
     } else {
 	bounds = CGRectInset(bounds, 1, 0);
     }
-    troughColor = [NSColor colorWithColorSpace: deviceRGB
-	components: rgba
-	count: 4];
     BEGIN_DRAWING(d)
     if ([NSApp macOSVersion] > 100800) {
-	CGContextSetFillColorWithColor(dc.context, CGCOLOR(troughColor));
+	bgGray = TkMacOSXInDarkMode(tkwin) ? darkTrough : lightTrough;
+	CGContextSetFillColorWithColor(dc.context, CGColorFromGray(bgGray));
     } else {
 	ChkErr(HIThemeSetFill, kThemeBrushDocumentWindowBackground, NULL,
 	    dc.context, HIOrientation);
     }
     CGContextFillRect(dc.context, bounds);
@@ -2436,18 +2739,18 @@
     ScrollbarElementOptions,
     TroughElementSize,
     TroughElementDraw
 };
 static void ThumbElementSize(
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),        /* clientData */
     void *elementRecord,
-    TCL_UNUSED(Tk_Window),
+    TCL_UNUSED(Tk_Window),     /* tkwin */
     int *minWidth,
     int *minHeight,
-    TCL_UNUSED(Ttk_Padding *))
+    TCL_UNUSED(Ttk_Padding *)) /* paddingPtr */
 {
-    ScrollbarElement *scrollbar = elementRecord;
+    ScrollbarElement *scrollbar = (ScrollbarElement *)elementRecord;
     Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
 
     TtkGetOrientFromObj(NULL, scrollbar->orientObj, &orientation);
     if (orientation == TTK_ORIENT_VERTICAL) {
 	*minHeight = 18;
@@ -2457,18 +2760,18 @@
 	*minWidth = 18;
     }
 }
 
 static void ThumbElementDraw(
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),        /* clientData */
     void *elementRecord,
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
-    ScrollbarElement *scrollbar = elementRecord;
+    ScrollbarElement *scrollbar = (ScrollbarElement *)elementRecord;
     Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
 
     TtkGetOrientFromObj(NULL, scrollbar->orientObj, &orientation);
 
     /*
@@ -2476,38 +2779,40 @@
      * able to display the thumb element at the size and location which the ttk
      * scrollbar widget requests.  The algorithm that HIToolbox uses to
      * determine the thumb geometry from the input values of min, max, value
      * and viewSize is undocumented.  A seemingly natural algorithm is
      * implemented below.  This code uses that algorithm for older OS versions,
-     * because using HITools also handles drawing the buttons and 3D thumb used
+     * because using HIToolbox also handles drawing the buttons and 3D thumb used
      * on those systems.  For newer systems the cleanest approach is to just
      * draw the thumb directly.
      */
 
     if ([NSApp macOSVersion] > 100800) {
 	CGRect thumbBounds = BoxToRect(d, b);
-	NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-	NSColor *thumbColor;
-	CGFloat *rgba;
+	CGColorRef thumbColor;
+	GrayColor bgGray;
+
+	/*
+	 * Apple does not draw the thumb when scrolling is not possible.
+	 */
+
 	if ((orientation == TTK_ORIENT_HORIZONTAL &&
 	    thumbBounds.size.width >= Tk_Width(tkwin) - 8) ||
 	    (orientation == TTK_ORIENT_VERTICAL &&
 	    thumbBounds.size.height >= Tk_Height(tkwin) - 8)) {
 	    return;
 	}
 	int isDark = TkMacOSXInDarkMode(tkwin);
 	if ((state & TTK_STATE_PRESSED) ||
 	    (state & TTK_STATE_HOVER)) {
-	    rgba = isDark ? darkActiveThumb : lightActiveThumb;
-	} else {
-	    rgba = isDark ? darkInactiveThumb : lightInactiveThumb;
-	}
-	thumbColor = [NSColor colorWithColorSpace: deviceRGB
-	    components: rgba
-	    count: 4];
-	BEGIN_DRAWING(d)
-	SolidFillRoundedRectangle(dc.context, thumbBounds, 4, thumbColor);
+	    bgGray = isDark ? darkActiveThumb : lightActiveThumb;
+	} else {
+	    bgGray = isDark ? darkInactiveThumb : lightInactiveThumb;
+	}
+	thumbColor = CGColorFromGray(bgGray);
+	BEGIN_DRAWING(d)
+	FillRoundedRectangle(dc.context, thumbBounds, 4, thumbColor);
 	END_DRAWING
     } else {
 	double thumbSize, trackSize, visibleSize, factor, fraction;
 	MacDrawable *macWin = (MacDrawable *)Tk_WindowId(tkwin);
 	CGRect troughBounds = {{macWin->xOff, macWin->yOff},
@@ -2572,16 +2877,16 @@
     ScrollbarElementOptions,
     ThumbElementSize,
     ThumbElementDraw
 };
 static void ArrowElementSize(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
+    TCL_UNUSED(void *),        /* clientData */
+    TCL_UNUSED(void *),        /* elementRecord */
+    TCL_UNUSED(Tk_Window),     /* tkwin */
     int *minWidth,
     int *minHeight,
-    TCL_UNUSED(Ttk_Padding *))
+    TCL_UNUSED(Ttk_Padding *)) /* paddingPtr */
 {
     if ([NSApp macOSVersion] < 100800) {
 	*minHeight = *minWidth = 14;
     } else {
 	*minHeight = *minWidth = -1;
@@ -2603,23 +2908,23 @@
  *    and height of the rectangle, so the same element can can be used for
  *    horizontal, vertical, and general separators.
  */
 
 static void SeparatorElementSize(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
+    TCL_UNUSED(void *),       /* clientData */
+    TCL_UNUSED(void *),       /* elementRecord */
+    TCL_UNUSED(Tk_Window),    /* tkwin */
     int *minWidth,
     int *minHeight,
-    TCL_UNUSED(Ttk_Padding *))
+    TCL_UNUSED(Ttk_Padding *)) /* paddingPtr */
 {
     *minWidth = *minHeight = 1;
 }
 
 static void SeparatorElementDraw(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),       /* clientData */
+    TCL_UNUSED(void *),       /* elementRecord */
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     unsigned int state)
 {
@@ -2655,16 +2960,16 @@
 
 static const ThemeGrowDirection sizegripGrowDirection
     = kThemeGrowRight | kThemeGrowDown;
 
 static void SizegripElementSize(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
+    TCL_UNUSED(Tk_Window), /* tkwin */
     int *minWidth,
     int *minHeight,
-    TCL_UNUSED(Ttk_Padding *))
+    TCL_UNUSED(Ttk_Padding *)) /* paddingPtr */
 {
     HIThemeGrowBoxDrawInfo info = {
 	.version = 0,
 	.state = kThemeStateActive,
 	.kind = kHIThemeGrowBoxKindNormal,
@@ -2677,13 +2982,13 @@
     *minWidth = bounds.size.width;
     *minHeight = bounds.size.height;
 }
 
 static void SizegripElementDraw(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
+    TCL_UNUSED(Tk_Window), /* tkwin */
     Drawable d,
     Ttk_Box b,
     unsigned int state)
 {
     CGRect bounds = BoxToRect(d, b);
@@ -2754,38 +3059,32 @@
  *      off-screen graphics port.  The code for handling this is currently
  *      commented out.
  */
 
 static void FillElementDraw(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
     CGRect bounds = BoxToRect(d, b);
 
     if ([NSApp macOSVersion] > 100800) {
-	NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
-	NSColor *bgColor;
-	CGFloat fill[4];
+	CGColorRef bgColor;
 	BEGIN_DRAWING(d)
-	GetBackgroundColor(dc.context, tkwin, 0, fill);
-	bgColor = [NSColor colorWithColorSpace: deviceRGB components: fill
-					 count: 4];
-	CGContextSetFillColorSpace(dc.context, deviceRGB.CGColorSpace);
-	CGContextSetFillColorWithColor(dc.context, CGCOLOR(bgColor));
+	bgColor = GetBackgroundCGColor(dc.context, tkwin, NO, 0);
+	CGContextSetFillColorWithColor(dc.context, bgColor);
 	CGContextFillRect(dc.context, bounds);
 	END_DRAWING
     } else {
 	ThemeBrush brush = (state & TTK_STATE_BACKGROUND)
 	    ? kThemeBrushModelessDialogBackgroundInactive
 	    : kThemeBrushModelessDialogBackgroundActive;
 	BEGIN_DRAWING(d)
 	ChkErr(HIThemeSetFill, brush, NULL, dc.context, HIOrientation);
-	//QDSetPatternOrigin(PatternOrigin(tkwin, d));
 	CGContextFillRect(dc.context, bounds);
 	END_DRAWING
     }
 }
 
@@ -2829,12 +3128,12 @@
  *    /apple_ref/doc/uid/TP30000243/C005321>
  *
  */
 
 static void ToolbarBackgroundElementDraw(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
     Tk_Window tkwin,
     Drawable d,
     TCL_UNUSED(Ttk_Box),
     TCL_UNUSED(Ttk_State))
 {
@@ -2858,11 +3157,11 @@
 
 /*----------------------------------------------------------------------
  * +++ Field elements --
  *
  *      Used for the Treeview widget. This is like the BackgroundElement
- *      except that the fieldbackground color is configureable.
+ *      except that the fieldbackground color is configurable.
  */
 
 typedef struct {
     Tcl_Obj     *backgroundObj;
 } FieldElement;
@@ -2872,18 +3171,18 @@
      offsetof(FieldElement, backgroundObj), "white"},
     {NULL, TK_OPTION_BOOLEAN, 0, NULL}
 };
 
 static void FieldElementDraw(
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* clientData */
     void *elementRecord,
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     TCL_UNUSED(Ttk_State))
 {
-    FieldElement *e = elementRecord;
+    FieldElement *e = (FieldElement *)elementRecord;
     Tk_3DBorder backgroundPtr =
 	Tk_Get3DBorderFromObj(tkwin, e->backgroundObj);
 
     XFillRectangle(Tk_Display(tkwin), d,
 	Tk_3DBorderGC(tkwin, backgroundPtr, TK_3D_FLAT_GC),
@@ -2899,22 +3198,22 @@
 };
 
 /*----------------------------------------------------------------------
  * +++ Treeview headers --
  *
- *    On systems older than 10.9 The header is a kThemeListHeaderButton drawn
+ *    On systems older than 10.9 the header is a kThemeListHeaderButton drawn
  *    by HIToolbox.  On newer systems those buttons do not match the Apple
  *    buttons, so we draw them from scratch.
  */
 
-static Ttk_StateTable TreeHeaderValueTable[] = {
+static const Ttk_StateTable TreeHeaderValueTable[] = {
     {kThemeButtonOn, TTK_STATE_ALTERNATE, 0},
     {kThemeButtonOn, TTK_STATE_SELECTED, 0},
     {kThemeButtonOff, 0, 0}
 };
 
-static Ttk_StateTable TreeHeaderAdornmentTable[] = {
+static const Ttk_StateTable TreeHeaderAdornmentTable[] = {
     {kThemeAdornmentHeaderButtonSortUp,
      TTK_STATE_ALTERNATE | TTK_TREEVIEW_STATE_SORTARROW, 0},
     {kThemeAdornmentDefault,
      TTK_STATE_SELECTED | TTK_TREEVIEW_STATE_SORTARROW, 0},
     {kThemeAdornmentHeaderButtonNoSortArrow, TTK_STATE_ALTERNATE, 0},
@@ -2922,25 +3221,25 @@
     {kThemeAdornmentFocus, TTK_STATE_FOCUS, 0},
     {kThemeAdornmentNone, 0, 0}
 };
 
 static void TreeAreaElementSize (
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
-    TCL_UNUSED(int *),
-    TCL_UNUSED(int *),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
+    TCL_UNUSED(Tk_Window), /* tkwin */
+    TCL_UNUSED(int *),     /* minWidth */
+    TCL_UNUSED(int *),     /* minHeight */
     Ttk_Padding *paddingPtr)
 {
 
     /*
      * Padding is needed to get the heading text to align correctly, since the
      * widget expects the heading to be the same height as a row.
      */
 
     if ([NSApp macOSVersion] > 100800) {
-	paddingPtr->top = 4;
+	*paddingPtr = Ttk_MakePadding(0, 4, 0, 0);
     }
 }
 
 static Ttk_ElementSpec TreeAreaElementSpec = {
     TK_STYLE_VERSION_2,
@@ -2965,17 +3264,17 @@
     }
 }
 
 static void TreeHeaderElementDraw(
     void *clientData,
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* elementRecord */
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
-    ThemeButtonParams *params = clientData;
+    ThemeButtonParams *params = (ThemeButtonParams *)clientData;
     CGRect bounds = BoxToRect(d, b);
     const HIThemeButtonDrawInfo info = {
 	.version = 0,
 	.state = Ttk_StateTableLookup(ThemeStateTable, state),
 	.kind = params->kind,
@@ -2990,15 +3289,11 @@
          * Compensate for the padding added in TreeHeaderElementSize, so
          * the larger heading will be drawn at the top of the widget.
          */
 
 	bounds.origin.y -= 4;
-	if (TkMacOSXInDarkMode(tkwin)) {
-	    DrawDarkListHeader(bounds, dc.context, tkwin, state);
-	} else {
-	    DrawListHeader(bounds, dc.context, tkwin, state);
-	}
+	DrawListHeader(bounds, dc.context, tkwin, state);
     } else {
 	ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation,
 	    NULL);
     }
     END_DRAWING
@@ -3016,21 +3311,21 @@
  * +++ Disclosure triangles --
  */
 
 #define TTK_TREEVIEW_STATE_OPEN         TTK_STATE_USER1
 #define TTK_TREEVIEW_STATE_LEAF         TTK_STATE_USER2
-static Ttk_StateTable DisclosureValueTable[] = {
+static const Ttk_StateTable DisclosureValueTable[] = {
     {kThemeDisclosureDown, TTK_TREEVIEW_STATE_OPEN, 0},
     {kThemeDisclosureRight, 0, 0},
 };
 static void DisclosureElementSize(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
-    TCL_UNUSED(Tk_Window),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
+    TCL_UNUSED(Tk_Window), /* tkwin */
     int *minWidth,
     int *minHeight,
-    TCL_UNUSED(Ttk_Padding *))
+    TCL_UNUSED(Ttk_Padding *)) /* paddingPtr */
 {
     SInt32 s;
 
     ChkErr(GetThemeMetric, kThemeMetricDisclosureTriangleWidth, &s);
     *minWidth = s;
@@ -3037,12 +3332,12 @@
     ChkErr(GetThemeMetric, kThemeMetricDisclosureTriangleHeight, &s);
     *minHeight = s;
 }
 
 static void DisclosureElementDraw(
-    TCL_UNUSED(void *),
-    TCL_UNUSED(void *),
+    TCL_UNUSED(void *),    /* clientData */
+    TCL_UNUSED(void *),    /* elementRecord */
     Tk_Window tkwin,
     Drawable d,
     Ttk_Box b,
     Ttk_State state)
 {
@@ -3118,10 +3413,48 @@
 TTK_LAYOUT("TCombobox",
     TTK_GROUP("Combobox.button", TTK_FILL_BOTH,
     TTK_GROUP("Combobox.padding", TTK_FILL_BOTH,
     TTK_NODE("Combobox.textarea", TTK_FILL_BOTH))))
 
+/* Image Button - no button */
+TTK_LAYOUT("ImageButton",
+    TTK_GROUP("Button.padding", TTK_FILL_BOTH,
+    TTK_NODE("Button.label", TTK_FILL_BOTH)))
+
+/* Inline Button */
+TTK_LAYOUT("InlineButton",
+    TTK_GROUP("InlineButton.button", TTK_FILL_BOTH,
+    TTK_GROUP("Button.padding", TTK_FILL_BOTH,
+    TTK_NODE("Button.label", TTK_FILL_BOTH))))
+
+/* Rounded Rect Button -- transparent face */
+TTK_LAYOUT("RoundedRectButton",
+    TTK_GROUP("RoundedRectButton.button", TTK_FILL_BOTH,
+    TTK_GROUP("Button.padding", TTK_FILL_BOTH,
+    TTK_NODE("Button.label", TTK_FILL_BOTH))))
+
+/* Gradient Button */
+TTK_LAYOUT("GradientButton",
+    TTK_GROUP("GradientButton.button", TTK_FILL_BOTH,
+    TTK_GROUP("Button.padding", TTK_FILL_BOTH,
+    TTK_NODE("Button.label", TTK_FILL_BOTH))))
+
+/* Recessed Button - text only radio button */
+
+TTK_LAYOUT("RecessedButton",
+    TTK_GROUP("RecessedButton.button", TTK_FILL_BOTH,
+    TTK_GROUP("Button.padding", TTK_FILL_BOTH,
+    TTK_NODE("Button.label", TTK_FILL_BOTH))))
+
+/* DisclosureButton (not a triangle) -- No label, no border*/
+TTK_LAYOUT("DisclosureButton",
+    TTK_NODE("DisclosureButton.button", TTK_FILL_BOTH))
+
+/* HelpButton -- No label, no border*/
+TTK_LAYOUT("HelpButton",
+    TTK_NODE("HelpButton.button", TTK_FILL_BOTH))
+
 /* Notebook tabs -- no focus ring */
 TTK_LAYOUT("Tab",
     TTK_GROUP("Notebook.tab", TTK_FILL_BOTH,
     TTK_GROUP("Notebook.padding", TTK_FILL_BOTH,
     TTK_NODE("Notebook.label", TTK_FILL_BOTH))))
@@ -3132,10 +3465,21 @@
     TTK_NODE("Spinbox.uparrow", TTK_PACK_TOP | TTK_STICK_E)
     TTK_NODE("Spinbox.downarrow", TTK_PACK_BOTTOM | TTK_STICK_E))
     TTK_GROUP("Spinbox.field", TTK_FILL_X,
     TTK_NODE("Spinbox.textarea", TTK_FILL_X)))
 
+TTK_LAYOUT("TEntry",
+    TTK_GROUP("Entry.field", TTK_FILL_BOTH|TTK_BORDER,
+        TTK_GROUP("Entry.padding", TTK_FILL_BOTH,
+	    TTK_NODE("Entry.textarea", TTK_FILL_BOTH))))
+
+/* Searchbox */
+TTK_LAYOUT("Searchbox",
+    TTK_GROUP("Searchbox.field", TTK_FILL_BOTH|TTK_BORDER,
+        TTK_GROUP("Entry.padding", TTK_FILL_BOTH,
+	    TTK_NODE("Entry.textarea", TTK_FILL_BOTH))))
+
 /* Progress bars -- track only */
 TTK_LAYOUT("TProgressbar",
     TTK_NODE("Progressbar.track", TTK_FILL_BOTH))
 
 /* Treeview -- no border. */
@@ -3174,10 +3518,38 @@
 TTK_END_LAYOUT_TABLE
 
 /*----------------------------------------------------------------------
  * +++ Initialization --
  */
+
+/*----------------------------------------------------------------------
+ * +++ Ttk_MacOSXInit --
+ *
+ *    Initialize variables which depend on [NSApp macOSVersion].  Called from
+ *    [NSApp applicationDidFinishLaunching].
+ */
+
+MODULE_SCOPE
+void Ttk_MacOSXInit(
+    void)
+{
+    if ([NSApp macOSVersion] < 101400) {
+	entryElementPadding = Ttk_MakePadding(7, 6, 7, 5);
+    } else {
+	entryElementPadding = Ttk_MakePadding(7, 5, 7, 6);
+    }
+    if ([NSApp macOSVersion] < 110000) {
+	Ttk_ContrastDelta = 8.0;
+    } else {
+
+	/*
+	 * The subtle contrast became event more subtle in 11.0.
+	 */
+
+	Ttk_ContrastDelta = 5.0;
+    }
+}
 
 static int AquaTheme_Init(
     Tcl_Interp *interp)
 {
     Ttk_Theme themePtr = Ttk_CreateTheme(interp, "aqua", NULL);
@@ -3197,18 +3569,30 @@
     Ttk_RegisterElementSpec(themePtr, "Toolbar.background",
 	&ToolbarBackgroundElementSpec, 0);
 
     Ttk_RegisterElementSpec(themePtr, "Button.button",
 	&ButtonElementSpec, &PushButtonParams);
+    Ttk_RegisterElementSpec(themePtr, "InlineButton.button",
+	&ButtonElementSpec, &InlineButtonParams);
+    Ttk_RegisterElementSpec(themePtr, "RoundedRectButton.button",
+	&ButtonElementSpec, &RoundedRectButtonParams);
     Ttk_RegisterElementSpec(themePtr, "Checkbutton.button",
 	&ButtonElementSpec, &CheckBoxParams);
     Ttk_RegisterElementSpec(themePtr, "Radiobutton.button",
 	&ButtonElementSpec, &RadioButtonParams);
+    Ttk_RegisterElementSpec(themePtr, "RecessedButton.button",
+	&ButtonElementSpec, &RecessedButtonParams);
     Ttk_RegisterElementSpec(themePtr, "Toolbutton.border",
 	&ButtonElementSpec, &BevelButtonParams);
     Ttk_RegisterElementSpec(themePtr, "Menubutton.button",
 	&ButtonElementSpec, &PopupButtonParams);
+    Ttk_RegisterElementSpec(themePtr, "DisclosureButton.button",
+	&ButtonElementSpec, &DisclosureButtonParams);
+    Ttk_RegisterElementSpec(themePtr, "HelpButton.button",
+	&ButtonElementSpec, &HelpButtonParams);
+    Ttk_RegisterElementSpec(themePtr, "GradientButton.button",
+	&ButtonElementSpec, &GradientButtonParams);
     Ttk_RegisterElementSpec(themePtr, "Spinbox.uparrow",
 	&SpinButtonUpElementSpec, 0);
     Ttk_RegisterElementSpec(themePtr, "Spinbox.downarrow",
 	&SpinButtonDownElementSpec, 0);
     Ttk_RegisterElementSpec(themePtr, "Combobox.button",
@@ -3223,12 +3607,16 @@
     Ttk_RegisterElementSpec(themePtr, "Notebook.tab", &TabElementSpec, 0);
     Ttk_RegisterElementSpec(themePtr, "Notebook.client", &PaneElementSpec, 0);
 
     Ttk_RegisterElementSpec(themePtr, "Labelframe.border", &GroupElementSpec,
 	0);
-    Ttk_RegisterElementSpec(themePtr, "Entry.field", &EntryElementSpec, 0);
-    Ttk_RegisterElementSpec(themePtr, "Spinbox.field", &EntryElementSpec, 0);
+    Ttk_RegisterElementSpec(themePtr, "Entry.field", &EntryElementSpec,
+			    &EntryFieldParams);
+    Ttk_RegisterElementSpec(themePtr, "Searchbox.field", &EntryElementSpec,
+			    &SearchboxFieldParams);
+    Ttk_RegisterElementSpec(themePtr, "Spinbox.field", &EntryElementSpec,
+			    &EntryFieldParams);
 
     Ttk_RegisterElementSpec(themePtr, "separator", &SeparatorElementSpec, 0);
     Ttk_RegisterElementSpec(themePtr, "hseparator", &SeparatorElementSpec, 0);
     Ttk_RegisterElementSpec(themePtr, "vseparator", &SeparatorElementSpec, 0);
 

ADDED   macosx/ttkMacOSXTheme.h
Index: macosx/ttkMacOSXTheme.h
==================================================================
--- /dev/null
+++ macosx/ttkMacOSXTheme.h
@@ -0,0 +1,563 @@
+/*
+ * ttkMacOSXTheme.h --
+ *
+ *      Static data and macros used in ttkMacOSXTheme.c
+ *
+ * Copyright 2019 Marc Culler
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+/*
+ * Macros for handling drawing contexts.
+ */
+
+#define BEGIN_DRAWING(d) {				    \
+    TkMacOSXDrawingContext dc;				    \
+    if (!TkMacOSXSetupDrawingContext((d), NULL, &dc)) {	    \
+	return;						    \
+    }							    \
+
+#define END_DRAWING				\
+    TkMacOSXRestoreDrawingContext(&dc);}
+
+
+#define HIOrientation kHIThemeOrientationNormal
+#define NoThemeMetric 0xFFFFFFFF
+
+/*
+ *  A scale factor used to map a range of non-negative doubles into a large
+ *  range of non-negative 32-bit integers without losing too much information.
+ *  (Use 1073741824 == 2^30 so we don't get surprised by roundoff.)
+ */
+
+#define RangeToFactor(max) ((double) (1073741824.0) / (max < 1.0 ? 1.0 : max))
+
+/*
+ * Meanings of Ttk states represented by User1 and User2.
+ */
+
+#define TTK_STATE_FIRST_TAB     TTK_STATE_USER1
+#define TTK_STATE_LAST_TAB      TTK_STATE_USER2
+#define TTK_STATE_IS_ACCENTED   TTK_STATE_USER2
+#define TTK_TREEVIEW_STATE_SORTARROW    TTK_STATE_USER1
+
+/*
+ * Colors and gradients used when drawing buttons.
+ */
+
+typedef struct GrayColor {
+    CGFloat grayscale;
+    CGFloat alpha;
+} GrayColor;
+
+#define RGBACOLOR static CGFloat
+#define RGBA256(r, g, b, a) {r / 255.0, g / 255.0, b / 255.0, a}
+#define GRAYCOLOR static GrayColor
+#define GRAY256(grayscale) {grayscale / 255.0, 1.0}
+
+/*
+ * Opaque Grays used for Gradient Buttons, Scrollbars and List Headers
+ */
+
+GRAYCOLOR darkDisabledIndicator = GRAY256(122.0);
+GRAYCOLOR lightDisabledIndicator = GRAY256(152.0);
+
+GRAYCOLOR darkGradientNormal = GRAY256(95.0);
+GRAYCOLOR darkGradientPressed = GRAY256(118.0);
+GRAYCOLOR darkGradientDisabled = GRAY256(82.0);
+GRAYCOLOR darkGradientBorder = GRAY256(118.0);
+GRAYCOLOR darkGradientBorderDisabled = GRAY256(94.0);
+GRAYCOLOR lightGradientNormal = GRAY256(244.0);
+GRAYCOLOR lightGradientPressed = GRAY256(175.0);
+GRAYCOLOR lightGradientDisabled = GRAY256(235.0);
+GRAYCOLOR lightGradientBorder = GRAY256(165.0);
+GRAYCOLOR lightGradientBorderDisabled = GRAY256(204.0);
+
+GRAYCOLOR lightTrough = GRAY256(250.0);
+GRAYCOLOR darkTrough = GRAY256(47.0);
+GRAYCOLOR lightInactiveThumb = GRAY256(200.0);
+GRAYCOLOR lightActiveThumb = GRAY256(133.0);
+GRAYCOLOR darkInactiveThumb = GRAY256(117.0);
+GRAYCOLOR darkActiveThumb = GRAY256(158.0);
+
+GRAYCOLOR lightListheaderBorder = GRAY256(200.0);
+GRAYCOLOR listheaderSeparator = GRAY256(220.0);
+GRAYCOLOR listheaderActiveBG = GRAY256(238.0);
+GRAYCOLOR listheaderInactiveBG = GRAY256(246.0);
+
+GRAYCOLOR lightComboSeparator = GRAY256(236.0);
+GRAYCOLOR darkComboSeparator = GRAY256(66.0);
+
+GRAYCOLOR darkTrack = GRAY256(84.0);
+GRAYCOLOR darkInactiveTrack = GRAY256(107.0);
+GRAYCOLOR lightTrack = GRAY256(177.0);
+GRAYCOLOR lightInactiveTrack = GRAY256(139.0);
+
+/*
+ * Transparent Grays
+ */
+
+GRAYCOLOR boxBorder = {1.0, 0.20};
+GRAYCOLOR darkSeparator = {1.0, 0.3};
+GRAYCOLOR darkTabSeparator = {0.0, 0.25};
+GRAYCOLOR darkListheaderBorder = {1.0, 0.125};
+GRAYCOLOR pressedDefaultButton = {0.0, 0.1};
+GRAYCOLOR darkPressedDefaultButton = {1.0, 0.1};
+
+#define CG_WHITE CGColorGetConstantColor(kCGColorWhite)
+
+
+/*
+ * Structures which comprise a database of corner radii and state-dependent
+ * colors used when drawing various types of buttons or entry widgets.
+ */
+
+typedef struct GrayPalette {
+    CGFloat face;
+    CGFloat top;
+    CGFloat side;
+    CGFloat bottom;
+} GrayPalette;
+
+typedef struct PaletteStateTable {
+    GrayPalette light;          /* Light palette to use if this entry matches */
+    GrayPalette dark;           /* dark palette to use if this entry matches */
+    unsigned int onBits;        /* Bits which must be set */
+    unsigned int offBits;       /* Bits which must be cleared */
+} PaletteStateTable;
+
+typedef struct ButtonDesign {
+    CGFloat radius;
+    PaletteStateTable palettes[];
+} ButtonDesign;
+
+/*
+ * The data.
+ */
+
+static const ButtonDesign pushbuttonDesign = {
+  .radius = 4.0,
+  .palettes = {
+    {
+      .light = {.face = 242.0, .top = 213.0, .side = 210.0, .bottom = 200.0},
+      .dark =  {.face = 94.0,  .top = 98.0,  .side = 94.0,  .bottom = 58.0},
+      .onBits = TTK_STATE_DISABLED, .offBits = 0},
+    {
+      .light = {.face = 205.0, .top = 215.0, .side = 211.0, .bottom = 173.0},
+      .dark =  {.face = 140.0, .top = 150.0, .side = 140.0, .bottom = 42.0},
+      .onBits = TTK_STATE_PRESSED, .offBits = 0
+    },
+    {
+      .light = {.face = 255.0, .top = 198.0, .side = 192.0, .bottom = 173.0},
+      .dark =  {.face = 118.0, .top = 132.0, .side = 118.0, .bottom = 48.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+static const ButtonDesign helpDesign = {
+  .radius = 11,
+  .palettes = {
+    {
+      .light = {.face = 241.0, .top = 218.0, .side = 217.0, .bottom = 206.0},
+      .dark =  {.face = 83.0,  .top = 89.0,  .side = 82.0,  .bottom = 82.0},
+      .onBits = TTK_STATE_DISABLED, .offBits = 0},
+    {
+      .light = {.face = 240.0, .top = 208.0, .side = 205.0, .bottom = 188.0},
+      .dark =  {.face = 129.0, .top = 121.0, .side = 106.0, .bottom = 106.0},
+      .onBits = TTK_STATE_PRESSED, .offBits = 0
+    },
+    {
+      .light = {.face = 255.0, .top = 208.0, .side = 205.0, .bottom = 188.0},
+      .dark =  {.face = 107.0, .top = 121.0, .side = 106.0, .bottom = 106.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+static const ButtonDesign inlineDesign = {
+  .radius = 8.0,
+  .palettes = {
+    {
+      .light = {.face = 170.0, .top = 170.0, .side = 170.0, .bottom = 170.0},
+      .dark =  {.face = 106.0,  .top = 106.0,  .side = 106.0,  .bottom = 106.0},
+      .onBits = TTK_STATE_DISABLED, .offBits = 0},
+    {
+      .light = {.face = 34.0, .top = 34.0, .side = 34.0, .bottom = 34.0},
+      .dark =  {.face = 225.0, .top = 225.0, .side = 225.0, .bottom = 225.0},
+      .onBits = TTK_STATE_PRESSED, .offBits = 0
+    },
+    {
+      .light = {.face = 113.0, .top = 113.0, .side = 113.0, .bottom = 113.0},
+      .dark =  {.face = 165.0, .top = 165.0, .side = 165.0, .bottom = 165.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+static const ButtonDesign roundedrectDesign = {
+  .radius = 3.0,
+  .palettes = {
+    {
+      .light = {.face = 256.0, .top = 192.0, .side = 192.0, .bottom = 192.0},
+      .dark =  {.face = 256.0, .top = 165.0, .side = 163.0, .bottom = 42.0},
+      .onBits = TTK_STATE_DISABLED, .offBits = 0
+    },
+    {
+      .light = {.face = 204.0, .top = 158.0, .side = 158.0, .bottom = 158.0},
+      .dark =  {.face = 85.0,  .top = 115.0, .side = 115.0, .bottom = 115.0},
+      .onBits = TTK_STATE_PRESSED, .offBits = 0
+    },
+    {
+      .light = {.face = 205.0, .top = 215.0, .side = 211.0, .bottom = 173.0},
+      .dark =  {.face = 140.0, .top = 150.0, .side = 140.0, .bottom = 42.0},
+      .onBits = TTK_STATE_ALTERNATE, .offBits = TTK_STATE_BACKGROUND
+    },
+
+    /*
+     * Gray values > 255 are replaced by the background color.
+     */
+
+    {
+      .light = {.face = 256.0, .top = 158.0, .side = 158.0, .bottom = 158.0},
+      .dark =  {.face = 256.0, .top = 115.0, .side = 115.0, .bottom = 115.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+static const ButtonDesign popupDesign = {
+  .radius = 4.0,
+  .palettes = {
+    {
+      .light = {.face = 242.0, .top = 213.0, .side = 210.0, .bottom = 200.0},
+      .dark =  {.face = 94.0,  .top = 98.0,  .side = 94.0,  .bottom = 58.0},
+      .onBits = TTK_STATE_DISABLED, .offBits = 0
+    },
+    {
+      .light = {.face = 255.0, .top = 198.0, .side = 192.0, .bottom = 173.0},
+      .dark =  {.face = 118.0, .top = 132.0, .side = 118.0, .bottom = 48.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+static const ButtonDesign checkDesign = {
+  .radius = 4.0,
+  .palettes = {
+    {
+      .light = {.face = 242.0, .top = 192.0, .side = 199.0, .bottom = 199.0},
+      .dark =  {.face = 80.0,  .top = 90.0,  .side = 80.0,  .bottom = 49.0},
+      .onBits = TTK_STATE_DISABLED, .offBits = 0
+    },
+    {
+      .light = {.face = 255.0, .top = 165.0, .side = 184.0, .bottom = 184.0},
+      .dark =  {.face = 118.0, .top = 132.0, .side = 118.0, .bottom = 48.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+static const ButtonDesign radioDesign = {
+  .radius = 8.0,
+  .palettes = {
+    {
+      .light = {.face = 242.0, .top = 189.0, .side = 198.0, .bottom = 199.0},
+      .dark =  {.face = 80.0,  .top = 84.0,  .side = 88.0,  .bottom = 60.0},
+      .onBits = TTK_STATE_DISABLED, .offBits = 0
+    },
+    {
+      .light = {.face = 255.0, .top = 165.0, .side = 184.0, .bottom = 184.0},
+      .dark =  {.face = 118.0, .top = 132.0, .side = 118.0, .bottom = 48.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+static const ButtonDesign recessedDesign = {
+  .radius = 4.0,
+  .palettes = {
+    {
+      .light = {.face = 117.0, .top = 117.0, .side = 117.0, .bottom = 117.0},
+      .dark =  {.face = 129.0, .top = 129.0, .side = 129.0, .bottom = 129.0},
+      .onBits = TTK_STATE_PRESSED, .offBits = 0
+    },
+    {
+      .light = {.face = 182.0, .top = 182.0, .side = 182.0, .bottom = 182.0},
+      .dark =  {.face = 105.0,  .top = 105.0, .side = 105.0, .bottom = 105.0},
+      .onBits = TTK_STATE_ACTIVE, .offBits = TTK_STATE_SELECTED
+    },
+    {
+      .light = {.face = 145.0, .top = 145.0, .side = 145.0, .bottom = 145.0},
+      .dark =  {.face = 166.0, .top = 166.0, .side = 166.0, .bottom = 166.0},
+      .onBits = TTK_STATE_SELECTED, .offBits = 0
+    },
+    {
+      .light = {.face = 256.0, .top = 256.0, .side = 256.0, .bottom = 256.0},
+      .dark =  {.face = 256.0, .top = 256.0, .side = 256.0, .bottom = 256.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+static const ButtonDesign incdecDesign = {
+  .radius = 5.0,
+  .palettes = {
+    {
+      .light = {.face = 246.0, .top = 236.0, .side = 227.0, .bottom = 213.0},
+      .dark =  {.face = 80.0,  .top = 90.0,  .side = 80.0,  .bottom = 49.0},
+      .onBits = TTK_STATE_DISABLED, .offBits = 0
+    },
+    {
+      .light = {.face = 255.0, .top = 198.0, .side = 192.0, .bottom = 173.0},
+      .dark =  {.face = 118.0, .top = 132.0, .side = 118.0, .bottom = 48.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+static const ButtonDesign bevelDesign = {
+  .radius = 4.0,
+  .palettes = {
+    {
+      .light = {.face = 242.0, .top = 213.0, .side = 210.0, .bottom = 200.0},
+      .dark =  {.face = 94.0,  .top = 98.0,  .side = 94.0,  .bottom = 58.0},
+      .onBits = TTK_STATE_DISABLED, .offBits = 0
+    },
+    {
+      .light = {.face = 205.0, .top = 215.0, .side = 211.0, .bottom = 173.0},
+      .dark =  {.face = 140.0, .top = 150.0, .side = 140.0, .bottom = 42.0},
+      .onBits = TTK_STATE_PRESSED, .offBits = 0
+    },
+    {
+      .light = {.face = 228.0, .top = 215.0, .side = 211.0, .bottom = 173.0},
+      .dark =  {.face = 163.0, .top = 150.0, .side = 140.0, .bottom = 42.0},
+      .onBits = TTK_STATE_SELECTED, .offBits = 0
+    },
+    {
+      .light = {.face = 255.0, .top = 198.0, .side = 192.0, .bottom = 173.0},
+      .dark =  {.face = 118.0, .top = 132.0, .side = 118.0, .bottom = 48.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+static const ButtonDesign tabDesign = {
+  .radius = 4.0,
+  .palettes = {
+
+    /*
+     * Apple does not have such a thing as a disabled tab.  If it is
+     * disabled, it should be removed.  But we provide one based on the
+     * disabled button.
+     */
+
+    {
+      .light = {.face = 229.0, .top = 213.0, .side = 242.0, .bottom = 200.0},
+      .dark =  {.face = 163.0,  .top = 90.0,  .side = 80.0,  .bottom = 49.0},
+      .onBits = TTK_STATE_DISABLED, .offBits = 0
+    },
+    {
+      .light = {.face = 229.0, .top = 205.0, .side = 211.0, .bottom = 183.0},
+      .dark =  {.face = 163.0, .top = 165.0, .side = 163.0, .bottom = 42.0},
+      .onBits = TTK_STATE_SELECTED, .offBits = 0
+    },
+    {
+      .light = {.face = 255.0, .top = 215.0, .side = 211.0, .bottom = 183.0},
+      .dark =  {.face = 108.0, .top = 129.0, .side = 108.0, .bottom = 47.0},
+      .onBits = 0, .offBits = 0
+    },
+  }
+};
+
+static const ButtonDesign entryDesign = {
+  .radius = 0.0,
+  .palettes = {
+    {
+      .light = {.face = 256.0, .top = 198.0, .side = 198.0, .bottom = 198.0},
+      .dark =  {.face = 256.0,  .top = 66.0,  .side = 66.0,  .bottom = 84.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+static const ButtonDesign searchDesign = {
+  .radius = 3.5,
+  .palettes = {
+    {
+      .light = {.face = 256.0, .top = 198.0, .side = 198.0, .bottom = 198.0},
+      .dark =  {.face = 256.0,  .top = 66.0,  .side = 66.0,  .bottom = 84.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+static const ButtonDesign comboDesign = {
+  .radius = 4.0,
+  .palettes = {
+    {
+      .light = {.face = 256.0, .top = 190.0, .side = 190.0, .bottom = 190.0},
+      .dark =  {.face = 256.0,  .top = 66.0,  .side = 66.0,  .bottom = 90.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+static const ButtonDesign sliderDesign = {
+  .radius = 8.0,
+  .palettes = {
+    {
+      .light = {.face = 242.0, .top = 189.0, .side = 198.0, .bottom = 199.0},
+      .dark =  {.face = 80.0,  .top = 84.0,  .side = 88.0,  .bottom = 60.0},
+      .onBits = TTK_STATE_DISABLED, .offBits = 0
+    },
+    {
+      .light = {.face = 255.0, .top = 165.0, .side = 184.0, .bottom = 184.0},
+      .dark =  {.face = 205.0, .top = 205.0, .side = 205.0, .bottom = 198.0},
+      .onBits = 0, .offBits = 0
+    }
+  }
+};
+
+
+/*
+ * Table mapping Tk states to Appearance manager ThemeStates
+ */
+
+static const Ttk_StateTable ThemeStateTable[] = {
+    {kThemeStateActive, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND, 0},
+    {kThemeStateUnavailable, TTK_STATE_DISABLED, 0},
+    {kThemeStatePressed, TTK_STATE_PRESSED, 0},
+    {kThemeStateInactive, TTK_STATE_BACKGROUND, 0},
+    {kThemeStateUnavailableInactive, TTK_STATE_DISABLED | TTK_STATE_BACKGROUND, 0},
+    {kThemeStateActive, 0, 0}
+
+    /* Others:
+     * The kThemeStatePressedUp and kThemeStatePressedDown bits indicate
+     * which of the two segments of an IncDec button is being pressed.
+     * We don't use these. kThemeStateRollover roughly corresponds to
+     * TTK_STATE_ACTIVE, but does not do what we want with the help button.
+     *
+     * {kThemeStatePressedUp, 0, 0},
+     * {kThemeStatePressedDown, 0, 0}
+     * {kThemeStateRollover, TTK_STATE_ACTIVE, 0},
+     */
+};
+
+/*
+ * Translation between Ttk and HIToolbox.
+ */
+
+static const Ttk_StateTable ButtonValueTable[] = {
+    {kThemeButtonOff, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND, 0},
+    {kThemeButtonMixed, TTK_STATE_ALTERNATE, 0},
+    {kThemeButtonOn, TTK_STATE_SELECTED, 0},
+    {kThemeButtonOff, 0, 0}
+};
+
+static const Ttk_StateTable ButtonAdornmentTable[] = {
+    {kThemeAdornmentNone, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND, 0},
+    {kThemeAdornmentDefault | kThemeAdornmentFocus,
+     TTK_STATE_ALTERNATE | TTK_STATE_FOCUS, 0},
+    {kThemeAdornmentFocus, TTK_STATE_FOCUS, 0},
+    {kThemeAdornmentDefault, TTK_STATE_ALTERNATE, 0},
+    {kThemeAdornmentNone, 0, 0}
+};
+
+/*
+ * Our enums for button styles not known to HIToolbox.
+ */
+
+#define TkGradientButton    0x8001
+#define TkRoundedRectButton 0x8002
+#define TkRecessedButton    0x8003
+#define TkInlineButton      0x8004
+/*
+ * The struct passed as clientData when drawing Ttk buttons.
+ */
+
+typedef struct {
+    ThemeButtonKind kind;
+    ThemeMetric heightMetric;
+    ThemeMetric widthMetric;
+} ThemeButtonParams;
+
+static ThemeButtonParams
+    PushButtonParams =  {kThemePushButton, kThemeMetricPushButtonHeight,
+			 NoThemeMetric},
+    CheckBoxParams =    {kThemeCheckBox, kThemeMetricCheckBoxHeight,
+			 NoThemeMetric},
+    RadioButtonParams = {kThemeRadioButton, kThemeMetricRadioButtonHeight,
+			 NoThemeMetric},
+    BevelButtonParams = {kThemeRoundedBevelButton, NoThemeMetric, NoThemeMetric},
+    PopupButtonParams = {kThemePopupButton, kThemeMetricPopupButtonHeight,
+			 NoThemeMetric},
+    DisclosureParams =  {kThemeDisclosureButton,
+			 kThemeMetricDisclosureTriangleHeight,
+			 kThemeMetricDisclosureTriangleWidth},
+    DisclosureButtonParams = {kThemeArrowButton,
+			      kThemeMetricSmallDisclosureButtonHeight,
+			      kThemeMetricSmallDisclosureButtonWidth},
+    HelpButtonParams = {kThemeRoundButtonHelp, kThemeMetricRoundButtonSize,
+			kThemeMetricRoundButtonSize},
+    ListHeaderParams = {kThemeListHeaderButton, kThemeMetricListHeaderHeight,
+			NoThemeMetric},
+    GradientButtonParams = {TkGradientButton, NoThemeMetric, NoThemeMetric},
+    RoundedRectButtonParams = {TkRoundedRectButton, kThemeMetricPushButtonHeight,
+			       NoThemeMetric},
+    RecessedButtonParams = {TkRecessedButton, kThemeMetricPushButtonHeight,
+ 			    NoThemeMetric},
+    InlineButtonParams = {TkInlineButton,  kThemeMetricPushButtonHeight,
+  			  NoThemeMetric};
+
+    /*
+     * Others: kThemeDisclosureRight, kThemeDisclosureDown,
+     * kThemeDisclosureLeft
+     */
+
+/*
+ *  The struct passed as clientData when drawing Ttk Entry widgets.
+ */
+
+typedef struct {
+    HIThemeFrameKind kind;
+    ThemeMetric heightMetric;
+    ThemeMetric widthMetric;
+} ThemeFrameParams;
+
+static ThemeFrameParams
+    EntryFieldParams = {kHIThemeFrameTextFieldSquare, NoThemeMetric, NoThemeMetric},
+    SearchboxFieldParams = {kHIThemeFrameTextFieldRound, NoThemeMetric, NoThemeMetric};
+
+/*
+ * If we try to draw a rounded rectangle with too large of a radius, the Core
+ * Graphics library will sometimes raise a fatal exception.  This macro
+ * protects against this by returning if the width or height is less than
+ * twice the radius.  Presumably this only happens when a widget has not yet
+ * been configured and has size 1x1, so there is nothing to draw anyway.
+ */
+
+#define CHECK_RADIUS(radius, bounds)                                                 \
+    if ((radius) > (bounds).size.width / 2 || (radius) > (bounds).size.height / 2) { \
+        return;                                                                      \
+    }
+
+/*
+ * The spinbox widget needs to draw the two arrows in different colors when
+ * one half or the other is being pressed, but the menubutton always draws
+ * them in the same color.  This constant is used to distinguish those two
+ * situations.
+ */
+
+#define BOTH_ARROWS 1 << 30
+
+/*
+ * Local Variables:
+ * mode: objc
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */

Index: tests/all.tcl
==================================================================
--- tests/all.tcl
+++ tests/all.tcl
@@ -2,16 +2,16 @@
 #
 # This file contains a top-level script to run all of the Tk
 # tests.  Execute it by invoking "source all.tcl" when running tktest
 # in this directory.
 #
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
-package require Tk ;# This is the Tk test suite; fail early if no Tk!
+package require tk ;# This is the Tk test suite; fail early if no Tk!
 package require tcltest 2.2
 tcltest::configure {*}$argv
 tcltest::configure -testdir [file normalize [file dirname [info script]]]
 tcltest::configure -loadfile \
     [file join [tcltest::testsDirectory] constraints.tcl]

Index: tests/bell.test
==================================================================
--- tests/bell.test
+++ tests/bell.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test out Tk's "bell" command.
 # It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
-# Copyright © 1998-2000 by Scriptics Corporation.
+# Copyright © 1998-2000 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv

Index: tests/bgerror.test
==================================================================
--- tests/bgerror.test
+++ tests/bgerror.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test the bgerror command.
 # It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv

Index: tests/bind.test
==================================================================
--- tests/bind.test
+++ tests/bind.test
@@ -2,20 +2,20 @@
 # commands plus the procedures in tkBind.c.  It is organized in the
 # standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1995 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 tk useinputmethods 0
 
-testConstraint nodeprecated [expr {"nodeprecated" ni [tk::pkgconfig list]}]
+testConstraint failsOnWindows [expr {![info exists ::env(CI)] || [tk windowingsystem] ne "win32"}]
 
 
 toplevel .t -width 100 -height 50
 wm geom .t +0+0
 update idletasks
@@ -41,11 +41,11 @@
 # otherwise some spurious events may pollute the tests
 toplevel .top
 wm geometry .top 50x50-50-50
 update
 event generate .top <Button-1> -warp 1
-update
+controlPointerWarpTiming
 destroy .top
 
 test bind-1.1 {bind command} -body {
     bind
 } -returnCodes error -result {wrong # args: should be "bind window ?pattern? ?command?"}
@@ -385,17 +385,17 @@
     destroy .t.c
 } -result {Test}
 
 test bind-11.1 {Tk_GetAllBindings procedure} -body {
     frame .t.f
-    foreach i "! a \\\{ ~ <Delete> <space> <<Paste>> <Tab> <Linefeed> <less> <Meta-a> <Acircumflex>" {
+    foreach i "! a \\\{ ~ <Delete> <space> <<Paste>> <Tab> <Linefeed> <Key-<> <Meta-a> <Â>" {
         bind .t.f $i Test
     }
     lsort [bind .t.f]
 } -cleanup {
     destroy .t.f
-} -result {! <<Paste>> <Key-Acircumflex> <Key-Delete> <Key-Linefeed> <Key-Tab> <Key-less> <Key-space> <Meta-Key-a> a \{ ~}
+} -result "! <<Paste>> <Key-<> <Key-Delete> <Key-Linefeed> <Key-Tab> <Key-space> <Key-Â> <Meta-Key-a> a \\\{ ~"
 test bind-11.2 {Tk_GetAllBindings procedure} -body {
     frame .t.f
     foreach i "<Double-Button-1> <Triple-Button-1> <Meta-Control-a> <Double-Alt-Enter> <Button-1>" {
         bind .t.f $i Test
     }
@@ -437,21 +437,21 @@
     bind all <Key> {lappend x "%W %K all Key"}
     bind Test : {lappend x "%W %K Test :"}
     bind all  _ {lappend x "%W %K all _"}
     bind .t.f : {lappend x "%W %K .t.f :"}
 
-    event generate .t.f <colon>
-    event generate .t.f <plus>
-    event generate .t.f <underscore>
+    event generate .t.f <:>
+    event generate .t.f <+>
+    event generate .t.f <_>
     return $x
 } -cleanup {
     destroy .t.f
     bind all <Key> {}
     bind Test <Key> {}
     bind all _ {}
     bind Test : {}
-} -result {{.t.f colon .t.f :} {.t.f colon Test :} {.t.f colon all Key} {.t.f plus Test Key} {.t.f plus all Key} {.t.f underscore Test Key} {.t.f underscore all _}}
+} -result {{.t.f : .t.f :} {.t.f : Test :} {.t.f : all Key} {.t.f + Test Key} {.t.f + all Key} {.t.f _ Test Key} {.t.f _ all _}}
 
 test bind-13.2 {Tk_BindEvent procedure} -setup {
     frame .t.f -class Test -width 150 -height 100
     pack .t.f
     focus -force .t.f
@@ -460,17 +460,17 @@
 } -body {
     bind Test <Key> {lappend x "%W %K Test press any"; break}
     bind all <Key> {continue; lappend x "%W %K all press any"}
     bind .t.f : {lappend x "%W %K .t.f pressed colon"}
 
-    event generate .t.f <colon>
+    event generate .t.f <:>
     return $x
 } -cleanup {
     destroy .t.f
     bind all <Key> {}
     bind Test <Key> {}
-} -result {{.t.f colon .t.f pressed colon} {.t.f colon Test press any}}
+} -result {{.t.f : .t.f pressed colon} {.t.f : Test press any}}
 
 test bind-13.3 {Tk_BindEvent procedure} -setup {
     proc bgerror args {}
     frame .t.f -class Test -width 150 -height 100
     pack .t.f
@@ -478,25 +478,25 @@
     update
     set x {}
 } -body {
     bind Test <Key> {lappend x "%W %K Test press any"; error Test}
     bind .t.f : {lappend x "%W %K .t.f pressed colon"}
-    event generate .t.f <colon>
+    event generate .t.f <:>
     update
     list $x $errorInfo
 } -cleanup {
     destroy .t.f
     bind Test <Key> {}
     rename bgerror {}
-}  -result {{{.t.f colon .t.f pressed colon} {.t.f colon Test press any}} {Test
+}  -result {{{.t.f : .t.f pressed colon} {.t.f : Test press any}} {Test
     while executing
 "error Test"
     (command bound to event)}}
 test bind-13.4 {Tk_BindEvent procedure} -setup {
     proc foo {} {
         set x 44
-        event generate .t.f <colon>
+        event generate .t.f <:>
     }
     frame .t.f -class Test -width 150 -height 100
     pack .t.f
     focus -force .t.f
     update
@@ -507,11 +507,11 @@
     foo
     return $x
 } -cleanup {
     destroy .t.f
     bind Test : {}
-} -result {{.t.f colon .t.f} {.t.f colon Test}}
+} -result {{.t.f : .t.f} {.t.f : Test}}
 
 test bind-13.5 {Tk_BindEvent procedure} -body {
     bind all <Destroy> {lappend x "%W destroyed"}
     set x {}
     frame .t.g -gorp foo
@@ -535,11 +535,11 @@
     set x {}
 } -body {
     bind .t.f : {lappend x "%W (.t.f binding)"}
     bind Test : {lappend x "%W (Test binding)"}
     bind all : {bind .t.f : {}; lappend x "%W (all binding)"}
-    event generate .t.f <colon>
+    event generate .t.f <:>
     return $x
 } -cleanup {
     bind Test : {}
     bind all : {}
     destroy .t.f
@@ -552,11 +552,11 @@
     set x {}
 } -body {
     bind .t.f : {lappend x "%W (.t.f binding)"}
     bind Test : {lappend x "%W (Test binding)"}
     bind all : {destroy .t.f; lappend x "%W (all binding)"}
-    event generate .t.f <colon>
+    event generate .t.f <:>
     return $x
 } -cleanup {
     bind Test : {}
     bind all : {}
     destroy .t.f
@@ -634,16 +634,16 @@
     update
     set x {}
 } -body {
     bind .t.f <Key> "lappend x Key%K"
     bind .t.f <KeyRelease> "lappend x Release%K"
-    event generate .t.f <Key> -keysym colon
-    event generate .t.f <KeyRelease> -keysym colon
+    event generate .t.f <Key> -keysym :
+    event generate .t.f <KeyRelease> -keysym :
     return $x
 } -cleanup {
     destroy .t.f
-} -result {Keycolon Releasecolon}
+} -result {Key: Release:}
 test bind-13.14 {Tk_BindEvent procedure: invalid key detail} -setup {
     frame .t.f -class Test -width 150 -height 100
     pack .t.f
     focus -force .t.f
     update
@@ -1043,10 +1043,11 @@
 } -result {b1 {invalid command name "blap"}}
 
 test bind-15.1 {MatchPatterns procedure, ignoring type mismatches} -setup {
     frame .t.f -class Test -width 150 -height 100
     pack .t.f
+    update idletasks
     focus -force .t.f
     update
 } -body {
     bind .t.f 12 {set x 1}
     set x 0
@@ -1059,10 +1060,11 @@
     destroy .t.f
 } -result 1
 test bind-15.2 {MatchPatterns procedure, ignoring type mismatches} -setup {
     frame .t.f -class Test -width 150 -height 100
     pack .t.f
+    update idletasks
     focus -force .t.f
     update
 } -body {
     bind .t.f 12 {set x 1}
     set x 0
@@ -1470,10 +1472,11 @@
     event delete <<V3>> <Shift-Button-1>
 } -result {V2102 V2103 V2105 Shift-Button-1}
 test bind-15.27 {MatchPatterns procedure, conflict resolution} -setup {
     frame .t.f -class Test -width 150 -height 100
     pack .t.f
+    update idletasks
     focus -force .t.f
     update
 } -body {
     bind .t.f <Key> {set x 0}
     bind .t.f 1 {set x 1}
@@ -1484,10 +1487,11 @@
     destroy .t.f
 } -result 1
 test bind-15.28 {MatchPatterns procedure, conflict resolution} -setup {
     frame .t.f -class Test -width 150 -height 100
     pack .t.f
+    update idletasks
     focus -force .t.f
     update
 } -body {
     bind .t.f <Key> {set x 0}
     bind .t.f 1 {set x 1}
@@ -1498,10 +1502,11 @@
     destroy .t.f
 } -result 0
 test bind-15.29 {MatchPatterns procedure, conflict resolution} -setup {
     frame .t.f -class Test -width 150 -height 100
     pack .t.f
+    update idletasks
     focus -force .t.f
     update
 } -body {
     bind .t.f <Key> {lappend x 0}
     bind .t.f 1 {lappend x 1}
@@ -2049,11 +2054,11 @@
     event generate .t.f <e>
     event generate .t.f <apostrophe>
     set x
 } -cleanup {
     destroy .t.f
-} -result {a A {	} {\r} {{}} {{}} { } {\$} \\\{ {{}} {{}} \xE9}
+} -result {a A {	} {\r} {{}} {{}} { } {\$} \\\{ {{}} {{}} é}
 test bind-16.36 {ExpandPercents procedure} -setup {
     frame .t.f -class Test -width 150 -height 100
     pack .t.f
     focus -force .t.f
     update
@@ -2221,10 +2226,23 @@
     destroy .t.e
     bind Entry <Key> $savedBind(Entry)
     bind all <Key> $savedBind(All)
     unset savedBind
 } -result {0 1 2}
+test bind-16.47 {ExpandPercents procedure} -constraints {aquaOrWin32 needsTcl87 failsOnWindows} -setup {
+    frame .t.f -class Test -width 150 -height 100
+    pack .t.f
+    focus -force .t.f
+    update
+} -body {
+    bind .t.f <Key> {set x "%K"}
+    set x none
+    event generate .t.f <Key> -keysym €
+    set x
+} -cleanup {
+    destroy .t.f
+} -result €
 
 test bind-17.1 {event command} -body {
     event
 } -returnCodes error -result {wrong # args: should be "event option ?arg?"}
 test bind-17.2 {event command} -body {
@@ -2237,11 +2255,11 @@
     event delete <<Paste>>
     event add <<Paste>> <Control-v>
     event info <<Paste>>
 } -cleanup {
     event delete <<Paste>> <Control-v>
-} -result {<Control-Key-v>}
+} -result <Control-Key-v>
 test bind-17.5 {event command: add 2} -body {
     event delete <<Paste>>
     event add <<Paste>> <Control-v> <Button-2>
     lsort [event info <<Paste>>]
 } -cleanup {
@@ -2350,19 +2368,19 @@
     event delete <<xyz>>
     event add <<xyz>> <Control-v>
     event info <<xyz>>
 } -cleanup {
     event delete <<xyz>>
-} -result {<Control-Key-v>}
+} -result <Control-Key-v>
 test bind-18.4 {CreateVirtualEvent procedure: duplicate physical} -body {
     event delete <<xyz>>
     event add <<xyz>> <Control-v>
     event add <<xyz>> <Control-v>
     event info <<xyz>>
 } -cleanup {
     event delete <<xyz>>
-} -result {<Control-Key-v>}
+} -result <Control-Key-v>
 test bind-18.5 {CreateVirtualEvent procedure: existing physical} -body {
     foreach p [event info] {event delete $p}
     event add <<xyz>> <Control-v>
     event add <<abc>> <Control-v>
     list [lsort [event info]] [event info <<xyz>>] [event info <<abc>>]
@@ -2407,11 +2425,11 @@
     event delete <<xyz>>
 } -body {
     event add <<xyz>> <Control-v>
     event delete <<xyz>> <Button-1>
     event info <<xyz>>
-} -result {<Control-Key-v>}
+} -result <Control-Key-v>
 test bind-19.5 {DeleteVirtualEvent procedure: delete 1, badly formed} -body {
     event add <<xyz>> <Control-v>
     event delete <<xyz>> <xyz>
 } -cleanup {
     event delete <<xyz>>
@@ -2689,11 +2707,11 @@
 } -body {
     event add <<xyz>> <Control-v>
     event info <<xyz>>
 } -cleanup {
     event delete <<xyz>>
-} -result {<Control-Key-v>}
+} -result <Control-Key-v>
 test bind-20.4 {GetVirtualEvent procedure: owns many} -setup {
     event delete <<xyz>>
 } -body {
     event add <<xyz>> <Control-v> <Button-2> spack
     event info <<xyz>>
@@ -2710,11 +2728,11 @@
     foreach p [event info] {event delete $p}
     event add <<xyz>> <Control-v>
     event info
 } -cleanup {
     event delete <<xyz>>
-} -result {<<xyz>>}
+} -result <<xyz>>
 test bind-21.3 {GetAllVirtualEvents procedure: many events} -body {
     foreach p [event info] {event delete $p}
     event add <<xyz>> <Control-v>
     event add <<xyz>> <Button-2>
     event add <<abc>> <Control-v>
@@ -5087,11 +5105,11 @@
 } -result test
 test bind-25.2 {ParseEventDescription procedure: misinterpreted modifier} -setup {
     button .b
 } -body {
     bind .b <Control-M> a
-    bind .b <M-M> b
+    bind .b <Meta-M> b
     lsort [bind .b]
 } -cleanup {
     destroy .b
 } -result {<Control-Key-M> <Meta-Key-M>}
 test bind-25.3 {ParseEventDescription procedure} -setup {
@@ -5107,11 +5125,11 @@
 } -body {
     bind .t.f <<Shift-Paste>> {puts hi}
     bind .t.f
 } -cleanup {
     destroy .t.f
-} -result {<<Shift-Paste>>}
+} -result <<Shift-Paste>>
 
 # Assorted error cases in event sequence parsing
 test bind-25.5 {ParseEventDescription procedure error cases} -body {
     bind .t \x7 {puts hi}
 } -returnCodes error -result {bad ASCII character 0x7}
@@ -5191,11 +5209,11 @@
 } -result <Meta-Key-a>
 
 test bind-25.22 {modifier names} -setup {
     frame .t.f -class Test -width 150 -height 100
 } -body {
-    bind .t.f <M-a> foo
+    bind .t.f <Meta-a> foo
     bind .t.f
 } -cleanup {
     destroy .t.f
 } -result <Meta-Key-a>
 
@@ -5476,10 +5494,27 @@
     bind .t.f
 } -cleanup {
     destroy .t.f
 } -result <B9-Key-a>
 
+test bind-25.54 {modifier names} -setup {
+    frame .t.f -class Test -width 150 -height 100
+} -body {
+    bind .t.f <Num-a> foo
+    bind .t.f
+} -cleanup {
+    destroy .t.f
+} -result <Mod3-Key-a>
+
+test bind-25.55 {modifier names} -setup {
+    frame .t.f -class Test -width 150 -height 100
+} -body {
+    bind .t.f <Fn-a> foo
+    bind .t.f
+} -cleanup {
+    destroy .t.f
+} -result <Mod4-Key-a>
 
 
 test bind-26.1 {event names} -setup {
     frame .t.f -class Test -width 150 -height 100
 } -body {
@@ -5525,24 +5560,10 @@
 } -result {{event Motion} <Motion>}
 
 test bind-26.5 {event names: Button} -setup {
     frame .t.f -class Test -width 150 -height 100
     pack .t.f
-    focus -force .t.f
-    update
-} -body {
-    bind .t.f <Button> "set x {event Button}"
-    set x xyzzy
-    event generate .t.f <Button>
-    list $x [bind .t.f]
-} -cleanup {
-    destroy .t.f
-} -result {{event Button} <Button>}
-
-test bind-26.6 {event names: ButtonPress} -setup {
-    frame .t.f -class Test -width 150 -height 100
-    pack .t.f
     focus -force .t.f
     update
 } -body {
     bind .t.f <Button> "set x {event Button}"
     set x xyzzy
@@ -5634,24 +5655,10 @@
     list $x [bind .t.f]
 } -cleanup {
     destroy .t.f
 } -result {{event Key} <Key>}
 
-test bind-26.13 {event names: KeyPress} -setup {
-    frame .t.f -class Test -width 150 -height 100
-    pack .t.f
-    focus -force .t.f
-    update
-} -body {
-    bind .t.f <Key> "set x {event KeyPress}"
-    set x xyzzy
-    event generate .t.f <Key>
-    list $x [bind .t.f]
-} -cleanup {
-    destroy .t.f
-} -result {{event KeyPress} <Key>}
-
 test bind-26.14 {event names: KeyRelease} -setup {
     frame .t.f -class Test -width 150 -height 100
     pack .t.f
     focus -force .t.f
     update
@@ -5961,14 +5968,14 @@
     frame .t.f -class Test -width 150 -height 100
     pack .t.f
     focus -force .t.f
     update
 } -body {
-    bind .t.f <colon> "lappend x \"keysym received\""
-    bind .t.f <underscore> "lappend x {bad binding match}"
+    bind .t.f <:> "lappend x \"keysym received\""
+    bind .t.f <_> "lappend x {bad binding match}"
     set x [lsort [bind .t.f]]
-    event generate .t.f <colon> ;# -state 0
+    event generate .t.f <:> ;# -state 0
     set x
 } -cleanup {
     destroy .t.f
 } -result {: _ {keysym received}}
 test bind-28.6 {keysym names} -setup {
@@ -6011,38 +6018,59 @@
     event generate .t.f <X> -state 1
     set x
 } -cleanup {
     destroy .t.f
 } -result {X x {keysym X}}
-test bind-28.9 {keysym names, Eth -> ETH} -body {
+test bind-28.9 {keysym names, Ð} -body {
     frame .t.f -class Test -width 150 -height 100
-    bind .t.f <Eth> foo
+    bind .t.f <Ð> foo
     bind .t.f
 } -cleanup {
     destroy .t.f
-} -result {<Key-ETH>}
-test bind-28.10 {keysym names, Ooblique -> Oslash} -constraints nodeprecated -body {
+} -result <Key-Ð>
+test bind-28.10 {keysym names, Ø} -constraints deprecated -body {
     frame .t.f -class Test -width 150 -height 100
-    bind .t.f <Ooblique> foo
+    bind .t.f <Ø> foo
     bind .t.f
 } -cleanup {
     destroy .t.f
-} -result {<Key-Oslash>}
+} -result <Key-Ø>
 test bind-28.11 {keysym names, gcedilla} -body {
     frame .t.f -class Test -width 150 -height 100
     bind .t.f <gcedilla> foo
     bind .t.f
 } -cleanup {
     destroy .t.f
-} -result {<Key-gcedilla>}
-test bind-28.12 {keysym names, Greek_IOTAdiaeresis -> Greek_IOTAdieresis} -body {
+} -result <Key-gcedilla>
+test bind-28.12 {keysym names, Greek_IOTAdiaeresis -> Greek_IOTAdieresis} -constraints deprecated -body {
     frame .t.f -class Test -width 150 -height 100
     bind .t.f <Greek_IOTAdiaeresis> foo
     bind .t.f
 } -cleanup {
     destroy .t.f
-} -result {<Key-Greek_IOTAdieresis>}
+} -result <Key-Greek_IOTAdieresis>
+test bind-28.13 {keysym names, Unicode} -body {
+    frame .t.f -class Test -width 150 -height 100
+    bind .t.f <€> foo
+    bind .t.f
+} -cleanup {
+    destroy .t.f
+} -result "<Key-€>"
+test bind-28.14 {keysym names, Emoji} -body {
+    frame .t.f -class Test -width 150 -height 100
+    bind .t.f <\U1F44D> foo
+    bind .t.f
+} -cleanup {
+    destroy .t.f
+} -result "<Key-\U1F44D>"
+test bind-28.15 {keysym names, Emoji} -constraints needsTcl87 -body {
+    frame .t.f -class Test -width 150 -height 100
+    bind .t.f <👍> foo
+    bind .t.f
+} -cleanup {
+    destroy .t.f
+} -result "<Key-👍>"
 
 
 test bind-29.1 {Tcl_BackgroundError procedure} -setup {
     proc bgerror msg {
         global x errorInfo
@@ -6238,10 +6266,11 @@
     pack .t.f
     focus -force .t.f
     update
 } -body {
     event generate .t.f <Button-1> -warp 1
+    controlPointerWarpTiming
     event generate .t.f <ButtonRelease-1>
     destroy .t.f
     update  ;  # shall simply not crash
 } -cleanup {
 } -result {}
@@ -6494,11 +6523,11 @@
     event generate .t.f <Button-1>
     event generate .t.f <Button-1>
     set x
 } -cleanup {
     destroy .t.f
-} -result {Double}
+} -result Double
 test bind-33.3 {prefer most specific event} -setup {
     pack [frame .t.f]
     focus -force .t.f
     update
     set x {}
@@ -6510,11 +6539,11 @@
     event generate .t.f <Button-1>
     event generate .t.f <a>
     set x
 } -cleanup {
     destroy .t.f
-} -result {Double}
+} -result Double
 test bind-33.4 {prefer most specific event} -setup {
     pack [frame .t.f]
     focus -force .t.f
     update
     set x {}
@@ -6602,11 +6631,11 @@
     event generate .t.f <Button-1>
     event generate .t.f <Button-1>
     set x
 } -cleanup {
     destroy .t.f
-} -result {last}
+} -result last
 test bind-33.10 {prefer last in case of homogeneous equal patterns} -setup {
     pack [frame .t.f]
     focus -force .t.f
     update
     set x {}
@@ -6619,11 +6648,11 @@
     event generate .t.f <Button-1>
     event generate .t.f <Button-1>
     set x
 } -cleanup {
     destroy .t.f
-} -result {last}
+} -result last
 test bind-33.11 {should prefer most specific} -setup {
     pack [frame .t.f]
     focus -force .t.f
     update
     set x {}
@@ -6640,11 +6669,11 @@
     event generate .t.f <Button-2>
     event generate .t.f <Button-2>
     set x
 } -cleanup {
     destroy .t.f
-} -result {first}
+} -result first
 test bind-33.12 {prefer last in case of homogeneous equal patterns} -setup {
     pack [frame .t.f]
     focus -force .t.f
     update
     set x {}
@@ -6654,28 +6683,28 @@
     event generate .t.f <Control-Button-1>
     event generate .t.f <Control-Button-1>
     set x
 } -cleanup {
     destroy .t.f
-} -result {last}
+} -result last
 test bind-33.13 {prefer last in case of homogeneous equal patterns} -setup {
     pack [frame .t.f]
     focus -force .t.f
     update
     set x {}
 } -body {
-    bind .t.f <Button-1><Control-1> { lappend x "first" }
-    bind .t.f <Control-1><Button-1> { lappend x "last" }
+    bind .t.f <Button-1><Control-Button-1> { lappend x "first" }
+    bind .t.f <Control-Button-1><Button-1> { lappend x "last" }
     event generate .t.f <Control-Button-1>
     event generate .t.f <Control-Button-1>
     set x
 } -cleanup {
     destroy .t.f
     # Old implementation failed, and returned "first", but this was wrong,
     # because both bindings are homogeneous equal, so the most recently defined
     # must be preferred.
-} -result {last}
+} -result last
 test bind-33.14 {prefer last in case of homogeneous equal patterns} -setup {
     pack [frame .t.f]
     focus -force .t.f
     update
     set x {}
@@ -6687,11 +6716,11 @@
     event generate .t.f <Button-1>
     event generate .t.f <Button-1>
     set x
 } -cleanup {
     destroy .t.f
-} -result {last}
+} -result last
 test bind-33.15 {prefer last in case of homogeneous equal patterns} -setup {
     pack [frame .t.f]
     focus -force .t.f
     update
     set x {}
@@ -6706,11 +6735,11 @@
 } -cleanup {
     destroy .t.f
     # Old implementation failed, and returned "first", but this was wrong,
     # because both bindings are homogeneous equal, so the most recently defined
     # must be preferred.
-} -result {last}
+} -result last
 test bind-33.16 {simulate use of the keyboard to trigger a pattern sequence with modifier - bug [16ef161925]} -setup {
     pack [frame .t.f]
     focus -force .t.f
     update
     set x {}
@@ -6809,23 +6838,25 @@
 } -result {1_Button1 1_Button1_2}
 
 test bind-34.1 {-warp works relatively to a window} -setup {
     toplevel .top
     wm geometry .top +100+100
-    update
+    after 10 ; update
 } -body {
     # In order to avoid platform-dependent coordinate results due to
     # decorations and borders, this test warps the pointer twice
     # relatively to a window that moved in the meantime, and checks
     # how much the pointer moved
     wm geometry .top +200+200
-    update
+    after 10 ; update
     event generate .top <Motion> -x 20 -y 20 -warp 1
+    controlPointerWarpTiming
     set pointerPos1 [winfo pointerxy .top]
     wm geometry .top +600+600
-    update
+    after 10 ; update
     event generate .top <Motion> -x 20 -y 20 -warp 1
+    controlPointerWarpTiming
     set pointerPos2 [winfo pointerxy .top]
     # from the first warped position to the second one, the mouse
     # pointer should have moved the same amount as the window moved
     set res 1
     foreach pos1 $pointerPos1 pos2 $pointerPos2 {
@@ -6839,12 +6870,14 @@
 } -result 1
 test bind-34.2 {-warp works relatively to the screen} -setup {
 } -body {
     # Contrary to bind-34.1, we're directly checking screen coordinates
     event generate {} <Motion> -x 20 -y 20 -warp 1
+    controlPointerWarpTiming
     set res [winfo pointerxy .]
     event generate {} <Motion> -x 200 -y 200 -warp 1
+    controlPointerWarpTiming
     lappend res {*}[winfo pointerxy .]
 } -cleanup {
 } -result {20 20 200 200}
 test bind-34.3 {-warp works with null or negative coordinates} -setup {
     # On some OS/WM, at least Linux with KDE, the "Screen edges" feature
@@ -6858,19 +6891,22 @@
         set halo 0
     }
     set res {}
 } -body {
     event generate {} <Motion> -x 0 -y 0 -warp 1
+    controlPointerWarpTiming
     foreach dim [winfo pointerxy .] {
         if {$dim <= $halo} {
             lappend res ok
         } else {
             lappend res $dim
         }
     }
     event generate {} <Motion> -x 100 -y 100 -warp 1
+    controlPointerWarpTiming
     event generate {} <Motion> -x -1 -y -1 -warp 1
+    controlPointerWarpTiming
     foreach dim [winfo pointerxy .] {
         if {$dim <= $halo} {
             lappend res ok
         } else {
             lappend res $dim
@@ -6978,12 +7014,12 @@
 test bind-35.3 {Events agree for modifier keys} -constraints {aqua} -setup {
 } -body {
     global keyInfo numericalKeysym
     set result {}
     bind . <Key> {
-    	set keyInfo [format "%K,0x%%X,0x%%X,%A" %N %k]
-    	set numericalKeysym [format "0x%x" %N]
+	set keyInfo [format "%K,0x%%X,0x%%X,%A" %N %k]
+	set numericalKeysym [format "0x%x" %N]
     }
     foreach event {
 	{<Control_L> -control}
 	{<Control_R> -control}
 	{<Alt_L> -option}
@@ -7011,10 +7047,11 @@
 } -cleanup {
 } -result pass
 
 test bind-36.1 {pointer warp with grab on toplevel, bug [e3888d5820]} -setup {
     event generate {} <Motion> -warp 1 -x 50 -y 50
+    controlPointerWarpTiming
     toplevel .top
     grab release .top
     wm geometry .top 200x200+300+300
     label .top.l -height 5 -width 20 -highlightthickness 2 \
             -highlightbackground black -bg yellow -text "My label"
@@ -7026,14 +7063,17 @@
     # but let's wait more (it depends on computer performance).
     after 100 ; update
 } -body {
     grab .top
     event generate .top.l <Motion> -warp 1 -x 10 -y 10
+    controlPointerWarpTiming
     foreach {x1 y1} [winfo pointerxy .top.l] {}
     event generate {} <Motion> -warp 1 -x 50 -y 50
+    controlPointerWarpTiming
     grab release .top
     event generate .top.l <Motion> -warp 1 -x 10 -y 10
+    controlPointerWarpTiming
     foreach {x2 y2} [winfo pointerxy .top.l] {}
     # success if the coords are the same with or without the grab, and if they
     # are at (10,10) inside the label widget as requested by the warping
     expr {$x1==$x2 && $y1==$y2 && $x1==[winfo rootx .top.l]+10 \
                                && $y1==[winfo rooty .top.l]+10}

Index: tests/bitmap.test
==================================================================
--- tests/bitmap.test
+++ tests/bitmap.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out the procedures in the file
 # tkBitmap.c.  It is organized in the standard white-box fashion for
 # Tcl tests.
 #
 # Copyright © 1998 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv

Index: tests/border.test
==================================================================
--- tests/border.test
+++ tests/border.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test out the procedures in the file
 # tkBorder.c.  It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1998 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv

Index: tests/busy.test
==================================================================
--- tests/busy.test
+++ tests/busy.test
@@ -2,11 +2,11 @@
 #
 # This file contains a collection of tests for one or more of the Tk built-in
 # commands. Sourcing this file runs the tests and generates output for errors.
 # No output means no errors were found.
 #
-# Copyright © 1998-2000 by Jos Decoster. All rights reserved.
+# Copyright © 1998-2000 Jos Decoster. All rights reserved.
 
 package require tcltest 2.2
 tcltest::configure {*}$argv
 tcltest::loadTestedCommands
 namespace import -force tcltest::test

Index: tests/butGeom2.tcl
==================================================================
--- tests/butGeom2.tcl
+++ tests/butGeom2.tcl
@@ -6,11 +6,11 @@
 wm title .t "Visual Tests for Button Geometry"
 wm iconname .t "Button Geometry"
 wm geom .t +0+0
 wm minsize .t 1 1
 
-label .t.l -text {This screen exercises the color options for various flavors of buttons.  Select display options below, and they will be applied to the appropiate button widgets.} -wraplength 5i
+label .t.l -text {This screen exercises the color options for various flavors of buttons.  Select display options below, and they will be applied to the appropriate button widgets.} -wraplength 5i
 pack .t.l -side top -fill both
 
 button .t.quit -text Quit -command {destroy .t}
 pack .t.quit -side bottom -pady 2m
 

Index: tests/button.test
==================================================================
--- tests/button.test
+++ tests/button.test
@@ -2,11 +2,11 @@
 # radiobuttons in Tk (i.e., all the widgets defined in tkButton.c).  It is
 # organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -1742,19 +1742,19 @@
     .b configure -overrelief ""
     .b cget -overrelief
 } -cleanup {
     destroy .b
 } -result {}
-test button-1.178 {configuration option: "overrelief" for button} -setup {
+test button-1.178 {configuration option: "overrelief" for button} -constraints needsTcl87 -setup {
     button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
     pack .b
     update
 } -body {
     .b configure -overrelief 1.5
 } -cleanup {
     destroy .b
-} -returnCodes {error} -result {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}
+} -returnCodes {error} -result {bad relief "1.5": must be flat, groove, raised, ridge, solid, sunken, or ""}
 test button-1.179 {configuration option: "overrelief" for checkbutton} -setup {
     checkbutton .c -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
     pack .c
     update
 } -body {
@@ -1761,19 +1761,19 @@
     .c configure -overrelief ""
     .c cget -overrelief
 } -cleanup {
     destroy .c
 } -result {}
-test button-1.180 {configuration option: "overrelief" for checkbutton} -setup {
+test button-1.180 {configuration option: "overrelief" for checkbutton} -constraints needsTcl87 -setup {
     checkbutton .c -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
     pack .c
     update
 } -body {
     .c configure -overrelief 1.5
 } -cleanup {
     destroy .c
-} -returnCodes {error} -result {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}
+} -returnCodes {error} -result {bad relief "1.5": must be flat, groove, raised, ridge, solid, sunken, or ""}
 test button-1.181 {configuration option: "overrelief" for radiobutton} -setup {
     radiobutton .r -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
     pack .r
     update
 } -body {
@@ -1780,19 +1780,19 @@
     .r configure -overrelief ""
     .r cget -overrelief
 } -cleanup {
     destroy .r
 } -result {}
-test button-1.182 {configuration option: "overrelief" for radiobutton} -setup {
+test button-1.182 {configuration option: "overrelief" for radiobutton} -constraints needsTcl87 -setup {
     radiobutton .r -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
     pack .r
     update
 } -body {
     .r configure -overrelief 1.5
 } -cleanup {
     destroy .r
-} -returnCodes {error} -result {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}
+} -returnCodes {error} -result {bad relief "1.5": must be flat, groove, raised, ridge, solid, sunken, or ""}
 
 test button-1.183 {configuration option: "padx" for label} -setup {
     label .l -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
     pack .l
     update
@@ -2412,11 +2412,11 @@
     update
 } -body {
     .l configure -underline 3p
 } -cleanup {
     destroy .l
-} -returnCodes {error} -result {expected integer but got "3p"}
+} -returnCodes {error} -result {bad index "3p": must be integer?[+-]integer?, end?[+-]integer?, or ""}
 test button-1.245 {configuration option: "underline" for button} -setup {
     button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
     pack .b
     update
 } -body {
@@ -2431,11 +2431,11 @@
     update
 } -body {
     .b configure -underline 3p
 } -cleanup {
     destroy .b
-} -returnCodes {error} -result {expected integer but got "3p"}
+} -returnCodes {error} -result {bad index "3p": must be integer?[+-]integer?, end?[+-]integer?, or ""}
 test button-1.247 {configuration option: "underline" for checkbutton} -setup {
     checkbutton .c -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
     pack .c
     update
 } -body {
@@ -2450,11 +2450,11 @@
     update
 } -body {
     .c configure -underline 3p
 } -cleanup {
     destroy .c
-} -returnCodes {error} -result {expected integer but got "3p"}
+} -returnCodes {error} -result {bad index "3p": must be integer?[+-]integer?, end?[+-]integer?, or ""}
 test button-1.249 {configuration option: "underline" for radiobutton} -setup {
     radiobutton .r -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
     pack .r
     update
 } -body {
@@ -2469,11 +2469,11 @@
     update
 } -body {
     .r configure -underline 3p
 } -cleanup {
     destroy .r
-} -returnCodes {error} -result {expected integer but got "3p"}
+} -returnCodes {error} -result {bad index "3p": must be integer?[+-]integer?, end?[+-]integer?, or ""}
 
 test button-1.251 {configuration option: "tristatevalue" for checkbutton} -setup {
     checkbutton .c -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
     pack .c
     update

Index: tests/canvImg.test
==================================================================
--- tests/canvImg.test
+++ tests/canvImg.test
@@ -2,11 +2,11 @@
 # which implement canvas "image" items.  It is organized in the standard
 # fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -359,15 +359,12 @@
 } -cleanup {
     .c delete all
     image delete foo
 } -result {5 23 35 38}
 
-# The following test is non-portable because of differences in
-# coordinate rounding on some machines (does 0.5 round  up?).
-
 test canvImg-7.1 {DisplayImage procedure} -constraints {
-	nonPortable testImageType
+    testImageType
 } -setup {
     .c delete all
 } -body {
     image create test foo -variable x
     .c create image 50 100 -image foo -tags i1 -anchor nw
@@ -374,11 +371,11 @@
     update
     set x {}
     .c create rect 55 110 65 115 -width 1 -outline black -fill white
     update
     set x
-} -result {{foo display 4 9 12 6 30 30}}
+} -result {{foo display 4 9 12 6}}
 test canvImg-7.2 {DisplayImage procedure, no image} -body {
     .c delete all
     .c create image 50 100 -tags i1
     update
     .c create rect 55 110 65 115 -width 1 -outline black -fill white

Index: tests/canvMoveto.test
==================================================================
--- tests/canvMoveto.test
+++ tests/canvMoveto.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test out the canvas "moveto" command. It is
 # derived from canvRect.test.
 #
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # Copyright © 2004 Neil McKay.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv

Index: tests/canvPs.test
==================================================================
--- tests/canvPs.test
+++ tests/canvPs.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out procedures to write postscript
 # for canvases to files and channels. It exercises the procedure
 # TkCanvPostscriptCmd in generic/tkCanvPs.c
 #
 # Copyright © 1995 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -131,13 +131,11 @@
     removeFile bar.ps
 } -result ok
 destroy .c
 
 
-test canvPs-3.1 {test ps generation with an embedded window} -constraints {
-    notAqua
-} -setup {
+test canvPs-3.1 {test ps generation with an embedded window} -setup {
     set bar [makeFile {} bar.ps]
     file delete $bar
 } -body {
     pack [canvas .c -width 200 -height 200 -background white]
     .c create rect 20 20 150 150 -tags rect0 -dash . -width 2
@@ -178,10 +176,28 @@
 test canvPs-4.1 {test ps generation with single-point uncolored poly, bug 734498} -body {
     pack [canvas .c]
     .c create poly 10 20 10 20
     .c postscript
 } -cleanup {
+    destroy .c
+} -returnCodes ok -match glob -result *
+
+
+test canvPs-5.1 {test ps generation with bitmap, bug 424773a00c} -body {
+    pack [canvas .c]
+    update
+    .c create bitmap 50 50 -bitmap questhead
+    .c postscript  ; # was crashing on macOS
+} -cleanup {
+    destroy .c
+} -returnCodes ok -match glob -result *
+test canvPs-5.2 {test ps generation with image} -body {
+    pack [canvas .c]
+    update
+    .c create image 50 50 -image ::tk::icons::information
+    .c postscript
+} -cleanup {
     destroy .c
 } -returnCodes ok -match glob -result *
 
 
 # cleanup

Index: tests/canvRect.test
==================================================================
--- tests/canvRect.test
+++ tests/canvRect.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out the procedures in tkRectOval.c,
 # which implement canvas "rectangle" and "oval" items.  It is organized
 # in the standard fashion for Tcl tests.
 #
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -121,15 +121,12 @@
     .c create rectangle 10 20 30 40 -tags x
     .c coords x 1 2 3 d
 } -cleanup {
     .c delete withtag all
 } -returnCodes error -result {bad screen distance "d"}
-test canvRect-3.6 {RectOvalCoords procedure} -constraints {
-    nonPortable
-} -body {
+test canvRect-3.6 {RectOvalCoords procedure} -body {
     .c create rectangle 10 20 30 40 -tags x
-    # Non-portable due to rounding differences.
     .c coords x 10 25 15 40
     .c bbox x
 } -cleanup {
     .c delete withtag all
 } -result {9 24 16 41}
@@ -158,12 +155,11 @@
     .c create rectangle 10 20 30 40 -tags x -width 1
     .c itemconfigure x -width -5
 } -cleanup {
     .c delete withtag all
 } -returnCodes error -result {bad screen distance "-5"}
-test canvRect-4.4 {ConfigureRectOval procedure} -constraints nonPortable -body {
-    # Non-portable due to rounding differences
+test canvRect-4.4 {ConfigureRectOval procedure} -body {
     .c create rectangle 10 20 30 40 -tags x -width 1
     .c itemconfigure x -width 10
     .c bbox x
 } -cleanup {
     .c delete withtag all

Index: tests/canvText.test
==================================================================
--- tests/canvText.test
+++ tests/canvText.test
@@ -1,19 +1,19 @@
 # This file is a Tcl script to test out the procedures in tkCanvText.c,
 # which implement canvas "text" items.  It is organized in the standard
 # fashion for Tcl tests.
 #
 # Copyright © 1996-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 # Canvas used in 1.* - 17.* tests
 canvas .c -width 400 -height 300 -bd 2 -relief sunken
 pack .c
@@ -64,11 +64,11 @@
     .c itemconfigure test -underline 0
     list [lindex [.c itemconfigure test -underline] 4] [.c itemcget test -underline]
 } -result {0 0}
 test canvasText-1.13 {configuration options: bad value for "underline"} -body {
     .c itemconfigure test -underline xyz
-} -returnCodes error -result {expected integer but got "xyz"}
+} -returnCodes error -result {bad index "xyz": must be integer?[+-]integer?, end?[+-]integer?, or ""}
 test canvText-1.14 {configuration options: good value for "width"} -body {
     .c itemconfigure test -width 6
     list [lindex [.c itemconfigure test -width] 4] [.c itemcget test -width]
 } -result {6 6}
 test canvasText-1.15 {configuration options: bad value for "width"} -body {
@@ -754,11 +754,11 @@
     .c icursor test 12
     .c coords test 0 0
     list [.c index test end] [.c index test insert] \
 	[.c index test sel.first] [.c index test sel.last] \
 	[.c index test @0,0] \
-	[.c index test -1] [.c index test 10] [.c index test 100]
+	[.c index test {}] [.c index test 10] [.c index test 100]
 } -cleanup {
     .c delete test
 } -result {15 12 5 8 0 0 10 15}
 test canvText-14.2 {GetTextIndex procedure: select error} -setup {
     .c create text 0 0 -tag test

Index: tests/canvWind.test
==================================================================
--- tests/canvWind.test
+++ tests/canvWind.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out the procedures in tkCanvWind.c,
 # which implement canvas "window" items.  It is organized in the standard
 # fashion for Tcl tests.
 #
 # Copyright © 1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -136,9 +136,25 @@
     update
     lappend x [list [winfo ismapped $f] [winfo x $f]]
 } -cleanup {
     destroy .t
 } -result {{1 3} {1 -79} {0 -79} {1 255} {0 255}}
+
+test canvWind-2.1 {DisplayWinItem, window gets destroyed during <Configure>} -setup {
+    destroy .t
+} -body {
+    toplevel .t
+    canvas .t.c
+    pack .t.c
+    frame .t.c.f -width 50 -height 50 -background red
+    set id [.t.c create window 50 50 -window .t.c.f]
+    update
+    bind .t.c.f <Configure> {destroy .t.c.f}
+    .t.c coords $id 60 60 ;  # was crashing
+    update
+} -cleanup {
+    destroy .t
+} -result {}
 
 # cleanup
 cleanupTests
 return

Index: tests/canvas.test
==================================================================
--- tests/canvas.test
+++ tests/canvas.test
@@ -214,13 +214,11 @@
     set x [list [.c xview]]
     .c xview scroll 2 units
     update
     lappend x [.c xview]
 } -result {{0.0 0.3} {0.4 0.7}}
-test canvas-2.4 {CanvasWidgetCmd, xview option} -constraints nonPortable -body {
-    # This test gives slightly different results on platforms such as NetBSD.
-    # I don't know why...
+test canvas-2.4 {CanvasWidgetCmd, xview option} -body {
     .c configure -xscrollincrement 0 -yscrollincrement 5
     .c xview moveto 0.6
     update
     set x [list [.c xview]]
     .c xview scroll 2 units
@@ -756,10 +754,26 @@
     canvas .c
 } -body {
     set id [.c create rect 0 0 1cm 1cm]
     expr {[lindex [.c coords $id] 2]>1}
 } -result 1
+test canvas-15.20 {bug [237971ce]} -setup {
+    destroy .c
+    canvas .c
+} -body {
+    set id [.c create line {0 0 50 50 100 50}]
+    .c insert $id end {200 200}
+    .c coords $id
+} -result {0.0 0.0 50.0 50.0 100.0 50.0 200.0 200.0}
+test canvas-15.21 {bug [237971ce]} -setup {
+    destroy .c
+    canvas .c
+} -body {
+    set id [.c create poly {0 0 50 50 100 50}]
+    .c insert $id end {200 200}
+    .c coords $id
+} -result {0.0 0.0 50.0 50.0 100.0 50.0 200.0 200.0}
 destroy .c
 
 test canvas-16.1 {arc coords check} -setup {
     canvas .c
 } -body {

Index: tests/choosedir.test
==================================================================
--- tests/choosedir.test
+++ tests/choosedir.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test out Tk's "tk_chooseDir" and
 # It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -100,11 +100,11 @@
 test choosedir-1.5.1 {tk_chooseDirectory command} -constraints notAqua -body {
     tk_chooseDirectory -foo bar
 } -returnCodes error -result {bad option "-foo": must be -initialdir, -mustexist, -parent, or -title}
 test choosedir-1.5.2 {tk_chooseDirectory command} -constraints aqua -body {
     tk_chooseDirectory -foo bar
-} -returnCodes error -result {bad option "-foo": must be -initialdir, -message, -mustexist, -parent, -title, or -command}
+} -returnCodes error -result {bad option "-foo": must be -command, -initialdir, -message, -mustexist, -parent, or -title}
 test choosedir-1.6 {tk_chooseDirectory command} -body {
     tk_chooseDirectory -parent foo.bar
 } -returnCodes error -result {bad window path name "foo.bar"}
 
 

Index: tests/clipboard.test
==================================================================
--- tests/clipboard.test
+++ tests/clipboard.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out Tk's clipboard management code,
 # especially the "clipboard" command.  It is organized in the standard
 # fashion for Tcl tests.
 #
 # Copyright © 1994 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 #
 # Note: Multiple display clipboard handling will only be tested if the
 # environment variable TK_ALT_DISPLAY is set to an alternate display.

Index: tests/clrpick.test
==================================================================
--- tests/clrpick.test
+++ tests/clrpick.test
@@ -1,16 +1,18 @@
 # This file is a Tcl script to test out Tk's "tk_chooseColor" command.
 # It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 namespace import -force tcltest::test
+
+testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 if {[testConstraint defaultPseudocolor8]} {
     # let's soak up a bunch of colors...so that
     # machines with small color palettes still fail.
     # some tests will be skipped if there are no more colors
@@ -170,11 +172,11 @@
     set colors "128 128 64"
     ToChooseColorByKey . 128 128 64
     tk_chooseColor -parent . -title "choose #808040"
 } -result {#808040}
 test clrpick-2.3 {tk_chooseColor command} -constraints {
-    nonUnixUserInteraction colorsLeftover
+    nonUnixUserInteraction colorsLeftover failsOnXQuarz
 } -body {
     ToPressButton . ok
     tk_chooseColor -parent . -title "Press OK"
 } -result {#808040}
 test clrpick-2.4 {tk_chooseColor command} -constraints {

ADDED   tests/cluster.test
Index: tests/cluster.test
==================================================================
--- /dev/null
+++ tests/cluster.test
@@ -0,0 +1,246 @@
+# This file is a Tcl script to test the [::tk::startOf|endOf]* functions in
+# tk.tcl and tkIcu.c.  It is organized in the standard fashion for Tcl tests.
+#
+# Copyright © 1994 The Regents of the University of California.
+# Copyright © 1994-1995 Sun Microsystems, Inc.
+# Copyright © 1998-1999 Scriptics Corporation.
+# All rights reserved.
+
+package require tcltest 2.2
+eval tcltest::configure $argv
+tcltest::loadTestedCommands
+namespace import -force tcltest::test
+
+testConstraint needsTcl87orICU [expr {[package vsatisfies [package provide Tcl] 8.7] || [catch {info body ::tk::startOfCluster}]}]
+
+
+test cluster-1.0 {::tk::startOfCluster} -body {
+    ::tk::startOfCluster 🤡 -1
+} -result {}
+test cluster-1.1 {::tk::startOfCluster} -body {
+    ::tk::startOfCluster 🤡 0
+} -result 0
+test cluster-1.2 {::tk::startOfCluster} -constraints needsTcl87orICU -body {
+    ::tk::startOfCluster 🤡 1
+} -result 0
+test cluster-1.3 {::tk::startOfCluster} -constraints needsTcl87orICU -body {
+    ::tk::startOfCluster 🤡 2
+} -result 2
+test cluster-1.4 {::tk::startOfCluster} -constraints needsTcl87orICU -body {
+    ::tk::startOfCluster 🤡 3
+} -result 2
+test cluster-1.5 {::tk::startOfCluster} -constraints needsTcl87orICU -body {
+    ::tk::startOfCluster 🤡 end
+} -result 0
+test cluster-1.6 {::tk::startOfCluster} -body {
+    ::tk::startOfCluster 🤡 {}
+} -result {}
+test cluster-1.7 {::tk::startOfCluster} -constraints needsTcl87orICU -body {
+    ::tk::startOfCluster 🤡 end-1
+} -result 0
+
+test cluster-2.0 {::tk::endOfCluster} -body {
+    ::tk::endOfCluster 🤡 -1
+} -result 0
+test cluster-2.1 {::tk::endOfCluster} -constraints needsTcl87orICU -body {
+    ::tk::endOfCluster 🤡 0
+} -result 2
+test cluster-2.2 {::tk::endOfCluster} -constraints needsTcl87orICU -body {
+    ::tk::endOfCluster 🤡 1
+} -result 2
+test cluster-2.3 {::tk::endOfCluster} -body {
+    ::tk::endOfCluster 🤡 2
+} -result {}
+test cluster-2.4 {::tk::endOfCluster} -body {
+    ::tk::endOfCluster 🤡 3
+} -result {}
+test cluster-2.5 {::tk::endOfCluster} -constraints needsTcl87orICU -body {
+    ::tk::endOfCluster 🤡 end
+} -result 2
+test cluster-2.6 {::tk::endOfCluster} -body {
+    ::tk::endOfCluster 🤡 {}
+} -result 0
+test cluster-2.7 {::tk::endOfCluster} -constraints needsTcl87orICU -body {
+    ::tk::endOfCluster 🤡 end-1
+} -result 2
+
+test cluster-3.0 {::tk::endOfWord} -body {
+    ::tk::endOfWord "ab cd" -1
+} -result 2
+test cluster-3.1 {::tk::endOfWord} -body {
+    ::tk::endOfWord "ab cd" 0
+} -result 2
+test cluster-3.2 {::tk::endOfWord} -body {
+    ::tk::endOfWord "ab cd" 1
+} -result 2
+test cluster-3.3 {::tk::endOfWord} -body {
+    ::tk::endOfWord "ab cd" 2
+} -result {}
+test cluster-3.4 {::tk::endOfWord} -body {
+    ::tk::endOfWord "ab cd" 3
+} -result {}
+test cluster-3.5 {::tk::endOfWord} -body {
+    ::tk::endOfWord "ab cd" 4
+} -result {}
+test cluster-3.6 {::tk::endOfWord} -body {
+    ::tk::endOfWord "ab cd" 5
+} -result {}
+test cluster-3.7 {::tk::endOfWord} -body {
+    ::tk::endOfWord "ab cd" end
+} -result {}
+test cluster-3.8 {::tk::endOfWord} -body {
+    ::tk::endOfWord "ab cd" {}
+} -result 2
+test cluster-3.9 {::tk::endOfWord} -body {
+    ::tk::endOfWord "ab cd" end-1
+} -result {}
+
+test cluster-4.0 {::tk::startOfPreviousWord} -body {
+    ::tk::startOfPreviousWord "ab cd" -1
+} -result {}
+test cluster-4.1 {::tk::startOfPreviousWord} -body {
+    ::tk::startOfPreviousWord "ab cd" 0
+} -result {}
+test cluster-4.2 {::tk::startOfPreviousWord} -body {
+    ::tk::startOfPreviousWord "ab cd" 1
+} -result 0
+test cluster-4.3 {::tk::startOfPreviousWord} -body {
+    ::tk::startOfPreviousWord "ab cd" 2
+} -result 0
+test cluster-4.4 {::tk::startOfPreviousWord} -body {
+    ::tk::startOfPreviousWord "ab cd" 3
+} -result 0
+test cluster-4.5 {::tk::startOfPreviousWord} -body {
+    ::tk::startOfPreviousWord "ab cd" 4
+} -result 3
+test cluster-4.6 {::tk::startOfPreviousWord} -body {
+    ::tk::startOfPreviousWord "ab cd" 5
+} -result 3
+test cluster-4.7 {::tk::startOfPreviousWord} -body {
+    ::tk::startOfPreviousWord "ab cd" end
+} -result 3
+test cluster-4.8 {::tk::startOfPreviousWord} -body {
+    ::tk::startOfPreviousWord "ab cd" {}
+} -result {}
+test cluster-4.9 {::tk::startOfPreviousWord} -body {
+    ::tk::startOfPreviousWord "ab cd" end-1
+} -result 0
+
+test cluster-5.0 {::tk::startOfNextWord} -body {
+    ::tk::startOfNextWord "ab cd" -1
+} -result 3
+test cluster-5.1 {::tk::startOfNextWord} -body {
+    ::tk::startOfNextWord "ab cd" 0
+} -result 3
+test cluster-5.2 {::tk::startOfNextWord} -body {
+    ::tk::startOfNextWord "ab cd" 1
+} -result 3
+test cluster-5.3 {::tk::startOfNextWord} -body {
+    ::tk::startOfNextWord "ab cd" 2
+} -result 3
+test cluster-5.4 {::tk::startOfNextWord} -body {
+    ::tk::startOfNextWord "ab cd" 3
+} -result {}
+test cluster-5.5 {::tk::startOfNextWord} -body {
+    ::tk::startOfNextWord "ab cd" 4
+} -result {}
+test cluster-5.6 {::tk::startOfNextWord} -body {
+    ::tk::startOfNextWord "ab cd" 5
+} -result {}
+test cluster-5.7 {::tk::startOfNextWord} -body {
+    ::tk::startOfNextWord "ab cd" end
+} -result {}
+test cluster-5.8 {::tk::startOfNextWord} -body {
+    ::tk::startOfNextWord "ab cd" {}
+} -result 3
+test cluster-5.9 {::tk::startOfNextWord} -body {
+    ::tk::startOfNextWord "ab cd" end-1
+} -result {}
+
+test cluster-6.0 {::tk::wordBreakBefore} -body {
+    ::tk::wordBreakBefore "ab cd" -1
+} -result {}
+test cluster-6.1 {::tk::wordBreakBefore} -body {
+    ::tk::wordBreakBefore "ab cd" 0
+} -result {}
+test cluster-6.2 {::tk::wordBreakBefore} -body {
+    ::tk::wordBreakBefore "ab cd" 1
+} -result {}
+test cluster-6.3 {::tk::wordBreakBefore} -body {
+    ::tk::wordBreakBefore "ab cd" 2
+} -result 2
+test cluster-6.4 {::tk::wordBreakBefore} -body {
+    ::tk::wordBreakBefore "ab cd" 3
+} -result 3
+test cluster-6.5 {::tk::wordBreakBefore} -body {
+    ::tk::wordBreakBefore "ab cd" 4
+} -result 3
+test cluster-6.6 {::tk::wordBreakBefore} -body {
+    ::tk::wordBreakBefore "ab cd" 5
+} -result 3
+test cluster-6.7 {::tk::wordBreakBefore} -body {
+    ::tk::wordBreakBefore "ab cd" end
+} -result 3
+test cluster-6.8 {::tk::wordBreakBefore} -body {
+    ::tk::wordBreakBefore "ab cd" {}
+} -result {}
+test cluster-6.9 {::tk::wordBreakBefore} -body {
+    ::tk::startOfNextWord "ab cd" end-1
+} -result {}
+
+test cluster-7.0 {::tk::wordBreakAfter} -body {
+    ::tk::wordBreakAfter "ab cd" -1
+} -result 2
+test cluster-7.1 {::tk::wordBreakAfter} -body {
+    ::tk::wordBreakAfter "ab cd" 0
+} -result 2
+test cluster-7.2 {::tk::wordBreakAfter} -body {
+    ::tk::wordBreakAfter "ab cd" 1
+} -result 2
+test cluster-7.3 {::tk::wordBreakAfter} -body {
+    ::tk::wordBreakAfter "ab cd" 2
+} -result 3
+test cluster-7.4 {::tk::wordBreakAfter} -body {
+    ::tk::wordBreakAfter "ab cd" 3
+} -result {}
+test cluster-7.5 {::tk::wordBreakAfter} -body {
+    ::tk::wordBreakAfter "ab cd" 4
+} -result {}
+test cluster-7.6 {::tk::wordBreakAfter} -body {
+    ::tk::wordBreakAfter "ab cd" 5
+} -result {}
+test cluster-7.7 {::tk::wordBreakAfter} -body {
+    ::tk::wordBreakAfter "ab cd" end
+} -result {}
+test cluster-7.8 {::tk::wordBreakAfter} -body {
+    ::tk::wordBreakAfter "ab cd" {}
+} -result 2
+test cluster-7.9 {::tk::wordBreakAfter} -body {
+    ::tk::wordBreakAfter "ab cd" end-1
+} -result {}
+
+
+test cluster-8.0 {::tk::startOfCluster} -body {
+    ::tk::startOfCluster a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::startOfCluster str start ?locale?"}
+test cluster-8.1 {::tk::endOfCluster} -body {
+    ::tk::endOfCluster a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::endOfCluster str start ?locale?"}
+test cluster-8.2 {::tk::startOfPreviousWord} -body {
+    ::tk::startOfPreviousWord a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::startOfPreviousWord str start ?locale?"}
+test cluster-8.3 {::tk::startOfNextWord} -body {
+    ::tk::startOfNextWord a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::startOfNextWord str start ?locale?"}
+test cluster-8.4 {::tk::endOfWord} -body {
+    ::tk::endOfWord a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::endOfWord str start ?locale?"}
+test cluster-8.5 {::tk::wordBreakBefore} -body {
+    ::tk::wordBreakBefore a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::wordBreakBefore str start ?locale?"}
+test cluster-8.6 {::tk::wordBreakAfter} -body {
+    ::tk::wordBreakAfter a b c d
+} -returnCodes 1 -result {wrong # args: should be "::tk::wordBreakAfter str start ?locale?"}
+
+cleanupTests
+return

Index: tests/cmds.test
==================================================================
--- tests/cmds.test
+++ tests/cmds.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test the procedures in the file
 # tkCmds.c.  It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands

Index: tests/color.test
==================================================================
--- tests/color.test
+++ tests/color.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test out the procedures in the file
 # tkColor.c.  It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1995-1998 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
@@ -161,11 +161,11 @@
 } {{{1 1}} {{1 1} {1 0}} {{1 0} {2 1}}}
 test color-1.5 {Color table} nonPortable {
     set fd [open ../xlib/rgb.txt]
     set result {}
     while {[gets $fd line] >= 0} {
-    	if {[string index $line 0] == "!"} continue
+	if {[string index $line 0] == "!"} continue
 	set rgb [c255 [winfo rgb . [lrange $line 3 end]]]
 	if {$rgb != [lrange $line 0 2] } {
 		append result $line\n
 	}
 

Index: tests/config.test
==================================================================
--- tests/config.test
+++ tests/config.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test the procedures in tkConfig.c,
 # which comprise the new new option configuration system.  It is
 # organized in the standard "white-box" fashion for Tcl tests.
 #
 # Copyright © 1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -40,19 +40,19 @@
     testobjconfig alltypes .b
     lappend x [testobjconfig info alltypes]
     set x
 } -cleanup {
     killTables
-} -result {{1 16 -boolean} {2 16 -boolean}}
+} -result {{1 17 -boolean} {2 17 -boolean}}
 test config-1.2 {Tk_CreateOptionTable - synonym initialization} -constraints {
     testobjconfig
 } -body {
     testobjconfig alltypes .a -synonym green
     .a cget -color
 } -cleanup {
     killTables
-} -result {green}
+} -result green
 test config-1.3 {Tk_CreateOptionTable - option database initialization} -constraints {
     testobjconfig
 } -body {
     testobjconfig alltypes .a
     option add *b.string different
@@ -75,14 +75,14 @@
 } -result {foo bar}
 test config-1.5 {Tk_CreateOptionTable - default initialization} -constraints {
     testobjconfig
 } -body {
     testobjconfig alltypes .a
-    .a cget -relief
+    .a cget -anchor
 } -cleanup {
     killTables
-} -result {raised}
+} -result center
 test config-1.6 {Tk_CreateOptionTable - chained tables} -constraints {
     testobjconfig
 } -body {
     testobjconfig chain1 .a
     testobjconfig chain2 .b
@@ -154,34 +154,34 @@
     testobjconfig alltypes .a
     list [.a cget -color]
 } -cleanup {
     killTables
     option clear
-} -result {blue}
+} -result blue
 test config-3.3 {Tk_InitOptions - initialize from database} -constraints {
     testobjconfig
 } -body {
     option add *a.justify bogus
     testobjconfig alltypes .a
     list [.a cget -justify]
 } -cleanup {
     killTables
     option clear
-} -result {left}
+} -result left
 test config-3.4 {Tk_InitOptions - initialize from widget class} -constraints {
     testobjconfig
 } -body {
     testobjconfig alltypes .a
     list [.a cget -color]
 } -cleanup {
     killTables
-} -result {red}
+} -result red
 test config-3.5 {Tk_InitOptions - no initial value} -constraints {
     testobjconfig
 } -body {
     testobjconfig alltypes .a
-    .a cget -anchor
+    .a cget -relief
 } -cleanup {
     killTables
 } -result {}
 test config-3.6 {Tk_InitOptions - bad initial value} -constraints {
     testobjconfig
@@ -208,17 +208,17 @@
 
 test config-3.8 {Tk_InitOptions - bad initial value} -constraints {
     testobjconfig
 } -body {
     testobjconfig configerror
-} -returnCodes error -result {expected integer but got "bogus"}
+} -returnCodes error -result {expected integer or "" but got "bogus"}
 test config-3.9 {Tk_InitOptions - bad initial value} -constraints {
     testobjconfig
 } -body {
     catch {testobjconfig configerror}
     return $errorInfo
-} -result {expected integer but got "bogus"
+} -result {expected integer or "" but got "bogus"
     (default value for "-int")
     invoked from within
 "testobjconfig configerror"}
 
 test config-4.1 {DoObjConfig - boolean} -constraints testobjconfig -setup {
@@ -225,11 +225,11 @@
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -boolean 0
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.2 {DoObjConfig - boolean} -constraints testobjconfig -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -boolean 0
     .foo cget -boolean
@@ -249,11 +249,11 @@
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -boolean 1
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.5 {DoObjConfig - boolean} -constraints testobjconfig -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -boolean 1
     .foo cget -boolean
@@ -272,14 +272,14 @@
 test config-4.7 {DoObjConfig - invalid boolean} -constraints {
     testobjconfig
 } -setup {
     catch {rename .foo {}}
 } -body {
-    testobjconfig alltypes .foo -boolean {}
+    testobjconfig alltypes .foo -boolean foo
 } -cleanup {
     killTables
-} -returnCodes error -result {expected boolean value but got ""}
+} -returnCodes error -result {expected boolean value or "" but got "foo"}
 test config-4.8 {DoObjConfig - boolean internal value} -constraints {
     testobjconfig
 } -setup {
     catch {rename .foo {}}
 } -body {
@@ -293,11 +293,11 @@
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -integer 3
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.10 {DoObjConfig - integer} -constraints testobjconfig -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -integer 3
     .foo cget -integer
@@ -339,19 +339,19 @@
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -double 3.14
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.15 {DoObjConfig - double} -constraints testobjconfig -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -double 3.14
     .foo cget -double
 } -cleanup {
     killTables
-} -returnCodes ok -result {3.14}
+} -returnCodes ok -result 3.14
 test config-4.16 {DoObjConfig - double} -constraints testobjconfig -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -double 3.14
     .foo cget -double
@@ -375,27 +375,27 @@
 } -body {
     testobjconfig internal .foo -double 62.75
     .foo cget -double
 } -cleanup {
     killTables
-} -result {62.75}
+} -result 62.75
 
 test config-4.19 {DoObjConfig - string} -constraints testobjconfig -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -string test
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.20 {DoObjConfig - string} -constraints testobjconfig -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -string test
     .foo cget -string
 } -cleanup {
     killTables
-} -returnCodes ok -result {test}
+} -returnCodes ok -result test
 test config-4.21 {DoObjConfig - string} -constraints testobjconfig -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -string test
     .foo cget -string
@@ -407,11 +407,11 @@
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -string {}
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.23 {DoObjConfig - null string} -constraints testobjconfig -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -string {}
     .foo cget -string
@@ -441,31 +441,38 @@
 
 test config-4.26 {DoObjConfig - string table} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -stringtable two
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.27 {DoObjConfig - string table} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -stringtable two
     .foo cget -stringtable
 } -cleanup {
     killTables
-} -returnCodes ok -result {two}
+} -returnCodes ok -result two
 test config-4.28 {DoObjConfig - string table} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -stringtable two
     .foo cget -stringtable
     rename .foo {}
 } -cleanup {
     killTables
 } -returnCodes ok
 test config-4.29 {DoObjConfig - invalid string table} -constraints {
-    testobjconfig
+    testobjconfig needsTcl87
 } -body {
     testobjconfig alltypes .foo -stringtable foo
 } -cleanup {
     killTables
-} -returnCodes error -result {bad stringtable "foo": must be one, two, three, or four}
+} -returnCodes error -result {bad stringtable "foo": must be one, two, three, four, or ""}
+test config-4.29a {DoObjConfig - invalid string table} -constraints {
+    testobjconfig needsTcl87
+} -body {
+    testobjconfig alltypes .foo -stringtable2 foo
+} -cleanup {
+    killTables
+} -returnCodes error -result {bad stringtable2 "foo": must be one, two, or ""}
 
 test config-4.30 {DoObjConfig - new string table} -constraints {
     testobjconfig
 } -body {
     testobjconfig alltypes .foo -stringtable two
@@ -479,11 +486,11 @@
     testobjconfig alltypes .foo -stringtable two
     .foo configure -stringtable three
     .foo cget -stringtable
 } -cleanup {
     killTables
-} -returnCodes ok -result {three}
+} -returnCodes ok -result three
 test config-4.32 {DoObjConfig - new string table} -constraints {
     testobjconfig
 } -body {
     testobjconfig alltypes .foo -stringtable two
     .foo configure -stringtable three
@@ -499,23 +506,23 @@
 } -body {
     testobjconfig internal .foo -stringtable "four"
     .foo cget -stringtable
 } -cleanup {
     killTables
-} -result {four}
+} -result four
 
 test config-4.34 {DoObjConfig - color} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -color blue
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.35 {DoObjConfig - color} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -color blue
     .foo cget -color
 } -cleanup {
     killTables
-} -returnCodes ok -result {blue}
+} -returnCodes ok -result blue
 test config-4.36 {DoObjConfig - color} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -color blue
     .foo cget -color
     rename .foo {}
 } -cleanup {
@@ -535,17 +542,17 @@
 } -body {
     testobjconfig internal .foo -color purple
     .foo cget -color
 } -cleanup {
     killTables
-} -result {purple}
+} -result purple
 
 test config-4.39 {DoObjConfig - null color} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -color {}
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.40 {DoObjConfig - null color} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -color {}
     .foo cget -color
 } -cleanup {
     killTables
@@ -589,11 +596,11 @@
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -font {Helvetica 72}
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.46 {DoObjConfig - font} -constraints testobjconfig -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -font {Helvetica 72}
     .foo cget -font
@@ -630,11 +637,11 @@
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -font {}
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.51 {DoObjConfig - null font} -constraints testobjconfig -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -font {}
     .foo cget -font
@@ -654,17 +661,17 @@
 
 test config-4.53 {DoObjConfig - bitmap} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -bitmap gray75
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.54 {DoObjConfig - bitmap} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -bitmap gray75
     .foo cget -bitmap
 } -cleanup {
     killTables
-} -returnCodes ok -result {gray75}
+} -returnCodes ok -result gray75
 test config-4.55 {DoObjConfig - new bitmap} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -bitmap gray75
     .foo configure -bitmap gray50
 } -cleanup {
     killTables
@@ -673,11 +680,11 @@
     testobjconfig alltypes .foo -bitmap gray75
     .foo configure -bitmap gray50
     .foo cget -bitmap
 } -cleanup {
     killTables
-} -returnCodes ok -result {gray50}
+} -returnCodes ok -result gray50
 test config-4.57 {DoObjConfig - invalid bitmap} -constraints {
     testobjconfig
 } -body {
     testobjconfig alltypes .foo -bitmap foobar
 } -cleanup {
@@ -685,11 +692,11 @@
 } -returnCodes error -result {bitmap "foobar" not defined}
 test config-4.58 {DoObjConfig - null bitmap} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -bitmap {}
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.59 {DoObjConfig - null bitmap} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -bitmap {}
     .foo cget -bitmap
 } -cleanup {
     killTables
@@ -701,23 +708,23 @@
 } -body {
     testobjconfig internal .foo -bitmap gray25
     .foo cget -bitmap
 } -cleanup {
     killTables
-} -result {gray25}
+} -result gray25
 
 test config-4.61 {DoObjConfig - border} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -border green
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.62 {DoObjConfig - border} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -border green
     .foo cget -border
 } -cleanup {
     killTables
-} -returnCodes ok -result {green}
+} -returnCodes ok -result green
 test config-4.63 {DoObjConfig - invalid border} -constraints {
     testobjconfig
 } -body {
     testobjconfig alltypes .foo -border xxx
 } -cleanup {
@@ -725,11 +732,11 @@
 } -returnCodes error -result {unknown color name "xxx"}
 test config-4.64 {DoObjConfig - null border} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -border {}
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.65 {DoObjConfig - null border} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -border {}
     .foo cget -border
 } -cleanup {
     killTables
@@ -764,32 +771,32 @@
 
 test config-4.69 {DoObjConfig - relief} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -relief flat
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.70 {DoObjConfig - relief} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -relief flat
     .foo cget -relief
 } -cleanup {
     killTables
-} -returnCodes ok -result {flat}
+} -returnCodes ok -result flat
 test config-4.71 {DoObjConfig - invalid relief} -constraints {
-    testobjconfig
+    testobjconfig needsTcl87
 } -body {
     testobjconfig alltypes .foo -relief foo
 } -cleanup {
     killTables
-} -returnCodes error -result {bad relief "foo": must be flat, groove, raised, ridge, solid, or sunken}
+} -returnCodes error -result {bad relief "foo": must be flat, groove, raised, ridge, solid, sunken, or ""}
 test config-4.72 {DoObjConfig - relief internal value} -constraints testobjconfig -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig internal .foo -relief ridge
     .foo cget -relief
 } -cleanup {
     killTables
-} -result {ridge}
+} -result ridge
 test config-4.73 {DoObjConfig - new relief} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -relief raised
     .foo configure -relief flat
 } -cleanup {
     killTables
@@ -798,23 +805,23 @@
     testobjconfig alltypes .foo -relief raised
     .foo configure -relief flat
     .foo cget -relief
 } -cleanup {
     killTables
-} -returnCodes ok -result {flat}
+} -returnCodes ok -result flat
 
 test config-4.75 {DoObjConfig - cursor} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -cursor arrow
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.76 {DoObjConfig - cursor} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -cursor arrow
     .foo cget -cursor
 } -cleanup {
     killTables
-} -returnCodes ok -result {arrow}
+} -returnCodes ok -result arrow
 test config-4.77 {DoObjConfig - invalid cursor} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -cursor foo
 } -cleanup {
     killTables
 } -returnCodes error -result {bad cursor spec "foo"}
@@ -822,11 +829,11 @@
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -cursor {}
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.79 {DoObjConfig - null cursor} -constraints testobjconfig -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig alltypes .foo -cursor {}
     .foo cget -cursor
@@ -843,38 +850,38 @@
     testobjconfig alltypes .foo -cursor xterm
     .foo configure -cursor arrow
     .foo cget -cursor
 } -cleanup {
     killTables
-} -returnCodes ok -result {arrow}
+} -returnCodes ok -result arrow
 test config-4.82 {DoObjConfig - cursor internal value} -constraints {
     testobjconfig
 } -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig internal .foo -cursor watch
     .foo cget -cursor
 } -cleanup {
     killTables
-} -result {watch}
+} -result watch
 
 test config-4.83 {DoObjConfig - justify} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -justify center
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.84 {DoObjConfig - justify} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -justify center
     .foo cget -justify
 } -cleanup {
     killTables
-} -returnCodes ok -result {center}
-test config-4.85 {DoObjConfig - invalid justify} -constraints testobjconfig -body {
+} -returnCodes ok -result center
+test config-4.85 {DoObjConfig - invalid justify} -constraints {testobjconfig needsTcl87} -body {
     testobjconfig alltypes .foo -justify foo
 } -cleanup {
     killTables
-} -returnCodes error -result {bad justification "foo": must be left, right, or center}
+} -returnCodes error -result {bad justification "foo": must be left, right, center, or ""}
 test config-4.86 {DoObjConfig - new justify} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -justify left
     .foo configure -justify right
 } -cleanup {
     killTables
@@ -883,38 +890,38 @@
     testobjconfig alltypes .foo -justify left
     .foo configure -justify right
     .foo cget -justify
 } -cleanup {
     killTables
-} -returnCodes ok -result {right}
+} -returnCodes ok -result right
 test config-4.88 {DoObjConfig - justify internal value} -constraints {
     testobjconfig
 } -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig internal .foo -justify center
     .foo cget -justify
 } -cleanup {
     killTables
-} -result {center}
+} -result center
 
 test config-4.89 {DoObjConfig - anchor} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -anchor center
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.90 {DoObjConfig - anchor} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -anchor center
     .foo cget -anchor
 } -cleanup {
     killTables
-} -returnCodes ok -result {center}
+} -returnCodes ok -result center
 test config-4.91 {DoObjConfig - invalid anchor} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -anchor foo
-} -cleanup {
+} -constraints needsTcl87 -cleanup {
     killTables
-} -returnCodes error -result {bad anchor "foo": must be n, ne, e, se, s, sw, w, nw, or center}
+} -returnCodes error -result {bad anchor "foo": must be n, ne, e, se, s, sw, w, nw, center, or ""}
 test config-4.92 {DoObjConfig - new anchor} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -anchor e
     .foo configure -anchor n
 } -cleanup {
     killTables
@@ -923,26 +930,26 @@
     testobjconfig alltypes .foo -anchor e
     .foo configure -anchor n
     .foo cget -anchor
 } -cleanup {
     killTables
-} -returnCodes ok -result {n}
+} -returnCodes ok -result n
 test config-4.94 {DoObjConfig - anchor internal value} -constraints {
     testobjconfig
 } -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig internal .foo -anchor sw
     .foo cget -anchor
 } -cleanup {
     killTables
-} -result {sw}
+} -result sw
 test config-4.95 {DoObjConfig - pixel} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -pixel 42
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.96 {DoObjConfig - pixel} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -pixel 42
     .foo cget -pixel
 } -cleanup {
     killTables
@@ -962,11 +969,11 @@
     testobjconfig alltypes .foo -pixel 42m
     .foo configure -pixel 3c
     .foo cget -pixel
 } -cleanup {
     killTables
-} -returnCodes ok -result {3c}
+} -returnCodes ok -result 3c
 test config-4.100 {DoObjConfig - pixel internal value} -constraints {
     testobjconfig
 } -setup {
     catch {rename .foo {}}
 } -body {
@@ -981,18 +988,18 @@
 test config-4.101 {DoObjConfig - window} -constraints testobjconfig -body {
     toplevel .bar
     testobjconfig twowindows .foo -window .bar
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.102 {DoObjConfig - window} -constraints testobjconfig -body {
     toplevel .bar
     testobjconfig twowindows .foo -window .bar
     .foo cget -window
 } -cleanup {
     killTables
-} -returnCodes ok -result {.bar}
+} -returnCodes ok -result .bar
 test config-4.103 {DoObjConfig - invalid window} -constraints testobjconfig -body {
     toplevel .bar
     testobjconfig twowindows .foo -window foo
 } -cleanup {
     killTables
@@ -1000,11 +1007,11 @@
 test config-4.104 {DoObjConfig - null window} -constraints testobjconfig -body {
     toplevel .bar
     testobjconfig twowindows .foo -window {}
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.105 {DoObjConfig - null window} -constraints testobjconfig -body {
     toplevel .bar
     testobjconfig twowindows .foo -window {}
     .foo cget -window
 } -cleanup {
@@ -1024,21 +1031,21 @@
     testobjconfig twowindows .foo -window .bar
     .foo configure -window .blamph
     .foo cget -window
 } -cleanup {
     killTables
-} -returnCodes ok -result {.blamph}
+} -returnCodes ok -result .blamph
 test config-4.108 {DoObjConfig - window internal value} -constraints {
     testobjconfig
 } -setup {
     catch {rename .foo {}}
 } -body {
     testobjconfig internal .foo -window .
     .foo cget -window
 } -cleanup {
     killTables
-} -result {.}
+} -result .
 
 test config-4.109 {DoObjConfig - releasing old values} -constraints {
     testobjconfig
 } -setup {
     catch {rename .foo {}}
@@ -1079,22 +1086,22 @@
 
 test config-4.111 {DoObjConfig - custom} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -custom test
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.112 {DoObjConfig - custom} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -custom test
     .foo cget -custom
 } -cleanup {
     killTables
-} -returnCodes ok -result {TEST}
+} -returnCodes ok -result TEST
 test config-4.113 {DoObjConfig - null custom} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -custom {}
 } -cleanup {
     killTables
-} -returnCodes ok -result {.foo}
+} -returnCodes ok -result .foo
 test config-4.114 {DoObjConfig - null custom} -constraints testobjconfig -body {
     testobjconfig alltypes .foo -custom {}
     .foo cget -custom
 } -cleanup {
     killTables
@@ -1149,19 +1156,19 @@
 } -body {
     testobjconfig chain2 .a
     .a cget -one
 } -cleanup {
     killTables
-} -result {one}
+} -result one
 test config-6.3 {GetOptionFromObj - abbreviation} -constraints {
     testobjconfig
 } -body {
     testobjconfig chain2 .a
     .a cget -fo
 } -cleanup {
     killTables
-} -result {four}
+} -result four
 test config-6.4 {GetOptionFromObj - ambiguous abbreviation} -constraints {
     testobjconfig
 } -body {
     testobjconfig chain2 .a
     .a cget -on
@@ -1181,11 +1188,11 @@
 test config-6.6 {GetOptionFromObj - synonym} -constraints testobjconfig -body {
     testobjconfig alltypes .b
     .b cget -synonym
 } -cleanup {
     killTables
-} -result {red}
+} -result red
 
 
 if {[testConstraint testobjconfig]} {
     testobjconfig alltypes .a
 }
@@ -1199,11 +1206,11 @@
     .a configure -bogus
 } -returnCodes error -result {unknown option "-bogus"}
 test config-7.3 {Tk_SetOptions - synonym} -constraints testobjconfig -body {
     .a configure -synonym blue
     .a cget -color
-} -result {blue}
+} -result blue
 test config-7.4 {Tk_SetOptions - missing value} -constraints {
     testobjconfig
 } -body {
     .a configure -color green -relief
 } -returnCodes error -result {value for "-relief" missing}
@@ -1210,11 +1217,11 @@
 test config-7.5 {Tk_SetOptions - missing value} -constraints {
     testobjconfig
 } -body {
     catch {.a configure -color green -relief}
     .a cget -color
-} -result {green}
+} -result green
 test config-7.6 {Tk_SetOptions - saving old values} -constraints {
     testobjconfig
 } -body {
     .a configure -color red -int 7 -relief raised -double 3.14159
     .a csave -color green -int 432 -relief sunken -double 2.0 -color bogus
@@ -1294,11 +1301,11 @@
     catch {.a csave -color green -color black -color blue \
 	    -color #ffff00 -color #ff00ff -color bogus}
 	.a cget -color
 } -cleanup {
     killTables
-} -result {red}
+} -result red
 test config-8.3 {Tk_RestoreSavedOptions - freeing object memory} -constraints {
     testobjconfig
 } -body {
     testobjconfig alltypes .a
     .a csave -color green -color black -color blue -color #ffff00 -color #ff00ff
@@ -1345,38 +1352,38 @@
     testobjconfig internal .a
     catch {.a csave -double 62.4 -color bogus}
     .a cget -double
 } -cleanup {
     killTables
-} -result {3.14159}
+} -result 3.14159
 test config-8.9 {Tk_RestoreSavedOptions - string internal form} -constraints {
     testobjconfig
 } -body {
     testobjconfig internal .a
     catch {.a csave -string "A long string" -color bogus}
 	.a cget -string
 } -cleanup {
     killTables
-} -result {foo}
+} -result foo
 test config-8.10 {Tk_RestoreSavedOptions - string table internal form} -constraints {
     testobjconfig
 } -body {
     testobjconfig internal .a
     catch {.a csave -stringtable three -color bogus}
 	.a cget -stringtable
 } -cleanup {
     killTables
-} -result {one}
+} -result one
 test config-8.11 {Tk_RestoreSavedOptions - color internal form} -constraints {
     testobjconfig
 } -body {
     testobjconfig internal .a
     catch {.a csave -color green -color bogus}
     .a cget -color
 } -cleanup {
     killTables
-} -result {red}
+} -result red
 test config-8.12 {Tk_RestoreSavedOptions - font internal form} -constraints {
     testobjconfig nonPortable
 } -body {
     testobjconfig internal .a
     catch {.a csave -font {Times 12} -color bogus}
@@ -1390,74 +1397,74 @@
     testobjconfig internal .a
     catch {.a csave -bitmap questhead -color bogus}
     .a cget -bitmap
 } -cleanup {
     killTables
-} -result {gray50}
+} -result gray50
 test config-8.14 {Tk_RestoreSavedOptions - border internal form} -constraints {
     testobjconfig
 } -body {
     testobjconfig internal .a
     catch {.a csave -border brown -color bogus}
     .a cget -border
 } -cleanup {
     killTables
-} -result {blue}
-test config-8.15 {Tk_RestoreSavedOptions - relief internal form} -constraints {
+} -result blue
+test config-8.15 {Tk_RestoreSavedOptions - anchor internal form} -constraints {
     testobjconfig
 } -body {
     testobjconfig internal .a
-    catch {.a csave -relief sunken -color bogus}
-    .a cget -relief
+    catch {.a csave -anchor e -color bogus}
+    .a cget -anchor
 } -cleanup {
     killTables
-} -result {raised}
+} -result center
 test config-8.16 {Tk_RestoreSavedOptions - cursor internal form} -constraints {
     testobjconfig
 } -body {
     testobjconfig internal .a
     catch {.a csave -cursor watch -color bogus}
     .a cget -cursor
 } -cleanup {
     killTables
-} -result {xterm}
+} -result xterm
 test config-8.17 {Tk_RestoreSavedOptions - justify internal form} -constraints {
     testobjconfig
 } -body {
     testobjconfig internal .a
     catch {.a csave -justify right -color bogus}
     .a cget -justify
 } -cleanup {
     killTables
-} -result {left}
+} -result left
 test config-8.18 {Tk_RestoreSavedOptions - anchor internal form} -constraints {
     testobjconfig
 } -body {
     testobjconfig internal .a
-    catch {.a csave -anchor center -color bogus}
+    catch {.a csave -anchor n -color bogus}
     .a cget -anchor
 } -cleanup {
     killTables
-} -result {n}
+} -result center
 test config-8.19 {Tk_RestoreSavedOptions - window internal form} -constraints {
     testobjconfig
 } -body {
     testobjconfig internal .a -window .a
     catch {.a csave -window .a -color bogus}
     .a cget -window
 } -cleanup {
     killTables
-} -result {.a}
+} -result .a
 test config-8.20 {Tk_RestoreSavedOptions - custom internal form} -constraints {
     testobjconfig
 } -body {
     testobjconfig internal .a -custom "foobar"
     catch {.a csave -custom "barbaz" -color bogus}
     .a cget -custom
 } -cleanup {
     killTables
-} -result {FOOBAR}
+} -result FOOBAR
 
 # Most of the tests below will cause memory leakage if there is a
 # problem.  This may not be evident unless the tests are run in
 # conjunction with a memory usage analyzer such as Purify.
 
@@ -1558,15 +1565,15 @@
 }
 
 
 test config-10.1 {Tk_GetOptionInfo - one item} -constraints testobjconfig -body {
     testobjconfig alltypes .foo
-    .foo configure -relief groove
-    .foo configure -relief
+    .foo configure -anchor e
+    .foo configure -anchor
 } -cleanup {
     destroy .foo
-} -result {-relief relief Relief raised groove}
+} -result {-anchor anchor Anchor center e}
 test config-10.2 {Tk_GetOptionInfo - one item, synonym} -constraints {
     testobjconfig
 } -body {
     testobjconfig alltypes .foo
     .foo configure -color black
@@ -1579,11 +1586,11 @@
 } -body {
     testobjconfig alltypes .foo -font {Helvetica 18} -integer 13563
     .foo configure
 } -cleanup {
     destroy .foo
-} -result {{-boolean boolean Boolean 1 1} {-integer integer Integer 7 13563} {-double double Double 3.14159 3.14159} {-string string String foo foo} {-stringtable StringTable stringTable one one} {-color color Color red red} {-font font Font {Helvetica 12} {Helvetica 18}} {-bitmap bitmap Bitmap gray50 gray50} {-border border Border blue blue} {-relief relief Relief raised raised} {-cursor cursor Cursor xterm xterm} {-justify {} {} left left} {-anchor anchor Anchor {} {}} {-pixel pixel Pixel 1 1} {-custom {} {} {} {}} {-synonym -color}}
+} -result {{-boolean boolean Boolean {} {}} {-integer integer Integer 7 13563} {-double double Double 3.14159 3.14159} {-string string String foo foo} {-stringtable StringTable stringTable one one} {-stringtable2 StringTable2 stringTable2 two two} {-color color Color red red} {-font font Font {Helvetica 12} {Helvetica 18}} {-bitmap bitmap Bitmap gray50 gray50} {-border border Border blue blue} {-relief relief Relief {} {}} {-cursor cursor Cursor xterm xterm} {-justify {} {} left left} {-anchor anchor Anchor center center} {-pixel pixel Pixel 1 1} {-custom {} {} {} {}} {-synonym -color}}
 test config-10.4 {Tk_GetOptionInfo - chaining through tables} -constraints testobjconfig -body {
     testobjconfig chain2 .foo -one asdf -three xyzzy
     .foo configure
 } -cleanup {
     destroy .foo
@@ -1605,12 +1612,12 @@
     .a configure -justify
 } -result {-justify {} {} left left}
 test config-11.3 {GetConfigList - null default and current value} -constraints {
     testobjconfig
 } -body {
-    .a configure -anchor
-} -result {-anchor anchor Anchor {} {}}
+    .a configure -relief
+} -result {-relief relief Relief {} {}}
 if {[testConstraint testobjconfig]} {
     killTables
 }
 
 
@@ -1636,61 +1643,61 @@
 test config-12.5 {GetObjectForOption - stringTable} -constraints {
     testobjconfig
 } -body {
     .a configure -stringtable "two"
     .a cget -stringtable
-} -result {two}
+} -result two
 test config-12.6 {GetObjectForOption - color} -constraints testobjconfig -body {
     .a configure -color "green"
     .a cget -color
-} -result {green}
+} -result green
 test config-12.7 {GetObjectForOption - font} -constraints testobjconfig -body {
     .a configure -font {Times 36}
     .a cget -font
 } -result {Times 36}
 test config-12.8 {GetObjectForOption - bitmap} -constraints testobjconfig -body {
     .a configure -bitmap "questhead"
     .a cget -bitmap
-} -result {questhead}
+} -result questhead
 test config-12.9 {GetObjectForOption - border} -constraints testobjconfig -body {
     .a configure -border #33217c
     .a cget -border
 } -result {#33217c}
 test config-12.10 {GetObjectForOption - relief} -constraints {
     testobjconfig
 } -body {
     .a configure -relief groove
     .a cget -relief
-} -result {groove}
+} -result groove
 test config-12.11 {GetObjectForOption - cursor} -constraints {
     testobjconfig
 } -body {
     .a configure -cursor watch
     .a cget -cursor
-} -result {watch}
+} -result watch
 test config-12.12 {GetObjectForOption - justify} -constraints {
     testobjconfig
 } -body {
     .a configure -justify right
     .a cget -justify
-} -result {right}
+} -result right
 test config-12.13 {GetObjectForOption - anchor} -constraints testobjconfig -body {
     .a configure -anchor e
     .a cget -anchor
-} -result {e}
+} -result e
 test config-12.14 {GetObjectForOption - pixels} -constraints testobjconfig -body {
     .a configure -pixel 193.2
     .a cget -pixel
 } -result 193
 test config-12.15 {GetObjectForOption - window} -constraints testobjconfig -body {
     .a configure -window .a
     .a cget -window
-} -result {.a}
+} -result .a
 test config-12.16 {GetObjectForOption -custom} -constraints testobjconfig -body {
     .a configure -custom foobar
     .a cget -custom
-} -result {FOOBAR}
+} -result FOOBAR
 test config-12.17 {GetObjectForOption - null values} -constraints {
     testobjconfig
 } -body {
     .a configure -string {} -color {} -font {} -bitmap {} -border {} \
 	    -cursor {} -window {} -custom {}

Index: tests/constraints.tcl
==================================================================
--- tests/constraints.tcl
+++ tests/constraints.tcl
@@ -3,11 +3,11 @@
     wm geometry . {}
     raise .
     return
 }
 
-package require Tk
+package require tk
 tk appname tktest
 wm title . tktest
 # If the main window isn't already mapped (e.g. because the tests are
 # being run automatically) , specify a precise size for it so that the
 # user won't have to position it manually.
@@ -170,10 +170,112 @@
                 if {$img ni $ImageNames} {lappend r $img}
             }
             return $r
         }
 
+	#
+	#  CONTROL TIMING ASPECTS OF POINTER WARPING
+	#
+	# The proc [controlPointerWarpTiming] is intended to ensure that the (mouse)
+	# pointer has actually been moved to its new position after a Tk test issued:
+	#
+	#    [event generate $w $event -warp 1 ...]
+	#
+	# It takes care of the following timing details of pointer warping:
+	#
+	# a. Allow pointer warping to happen if it was scheduled for execution at
+	#    idle time.
+	#    - In Tk releases 8.6 and older, pointer warping is scheduled for
+	#      execution at idle time
+	#    - In release 8.7 and newer this happens synchronously if $w refers to the
+	#      whole screen or if the -when option to [event generate] is "now".
+	#    The namespace variable idle_pointer_warping records which of these is
+	#    the case.
+	#
+	# b. Work around a race condition associated with OS notification of
+	#    mouse motion on Windows.
+	#
+	#    When calling [event generate $w $event -warp 1 ...], the following
+	#    sequence occurs:
+	#    - At some point in the processing of this command, either via a
+	#      synchronous execution path, or asynchronously at idle time, Tk calls
+	#      an OS function* to carry out the mouse cursor motion.
+	#    - Tk has previously registered a callback function** with the OS, for
+	#      the OS to call in order to notify Tk when a mouse move is completed.
+	#    - Tk doesn't wait for the callback function to receive the notification
+	#      from the OS, but continues processing. This suits most use cases
+	#      because usually the notification arrives fast enough (within a few tens
+	#      of microseconds). However ...
+	#    - A problem arises if Tk performs some processing, immediately following
+	#      up on [event generate $w $event -warp 1 ...], and that processing
+	#      relies on the mouse pointer having actually moved. If such processing
+	#      happens just before the notification from the OS has been received,
+	#      Tk will be using not yet updated info (e.g. mouse coordinates).
+	#
+	#         Hickup, choke etc ... !
+	#
+	#            *  the function SendInput() of the Win32 API
+	#            ** the callback function is TkWinChildProc()
+	#
+	#    This timing issue can be addressed by putting the Tk process on hold
+	#    (do nothing at all) for a somewhat extended amount of time, while
+	#    letting the OS complete its job in the meantime. This is what is
+	#    accomplished by calling [after ms].
+	#
+	#    ----
+	#    For the history of this issue please refer to Tk ticket [69b48f427e],
+	#    specifically the comment on 2019-10-27 14:24:26.
+	#
+	#
+	# Beware: there are cases, not (yet) exercised by the Tk test suite, where
+	# [controlPointerWarpTiming] doesn't ensure the new position of the pointer.
+	# For example, when issued under Tk8.7+, if the value for the -when option
+	# to [event generate $w] is not "now", and $w refers to a Tk window, i.e. not
+	# the whole screen.
+	#
+	variable idle_pointer_warping [expr {![package vsatisfies [package provide Tk] 8.7-]}]
+	proc controlPointerWarpTiming {{duration 50}} {
+		variable idle_pointer_warping
+		if {$idle_pointer_warping} {
+			update idletasks ;# see a. above
+		}
+		if {[tk windowingsystem] eq "win32"} {
+			after $duration ;# see b. above
+		}
+	}
+	namespace export controlPointerWarpTiming
+
+	namespace export updateWidgets
+	# Platform specific procedure for updating the display.
+	if {[tk windowingsystem] == "aqua"} {
+	    proc updateWidgets {} {
+		update idletasks
+	    }
+	} else {
+	    proc updateWidgets {} {
+		update
+	    }
+	}
+
+	namespace export waitForMap waitForUnmap
+	# Procedures waiting for a window to be mapped or unmapped, with timeout
+	proc waitForMap {w} {
+	    set count 0
+	    while {$count < 10 && ![winfo ismapped $w]} {
+		updateWidgets
+		incr count
+		after 50
+	    }
+	}
+	proc waitForUnmap {w} {
+	    set count 0
+	    while {$count < 10 && [winfo ismapped $w]} {
+		updateWidgets
+		incr count
+		after 50
+	    }
+	}
     }
 }
 
 namespace import -force tk::test::*
 
@@ -193,10 +295,16 @@
 testConstraint haveDISPLAY [expr {[info exists env(DISPLAY)] && [testConstraint x11]}]
 testConstraint altDisplay  [info exists env(TK_ALT_DISPLAY)]
 testConstraint noExceed [expr {
     ![testConstraint unix] || [catch {font actual "\{xyz"}]
 }]
+testConstraint deprecated [expr {![package vsatisfies [package provide Tcl] 8.7-] || ![::tk::build-info no-deprecate]}]
+testConstraint needsTcl87 [package vsatisfies [package provide Tcl] 8.7-]
+
+# constraint for running a test on all windowing system except aqua
+# where the test fails due to a known bug
+testConstraint aquaKnownBug [expr {[testConstraint notAqua] || [testConstraint knownBug]}]
 
 # constraints for testing facilities defined in the tktest executable...
 testConstraint testImageType [expr {"test" in [image types]}]
 testConstraint testOldImageType [expr {"oldtest" in [image types]}]
 testConstraint testbitmap    [llength [info commands testbitmap]]
@@ -233,13 +341,10 @@
 set x [list [.t bbox 1.3] [.t bbox 2.5]]
 destroy .t
 if {![string match {{22 3 6 15} {31 18 [34] 15}} $x]} {
     testConstraint fonts 0
 }
-testConstraint textfonts [expr {
-    [testConstraint fonts] || [tk windowingsystem] eq "win32"
-}]
 
 # constraints for the visuals available..
 testConstraint pseudocolor8 [expr {
     ([catch {
 	toplevel .t -visual {pseudocolor 8} -colormap new

Index: tests/cursor.test
==================================================================
--- tests/cursor.test
+++ tests/cursor.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out the procedures in the file
 # tkCursor.c.  It is organized in the standard white-box fashion for
 # Tcl tests.
 #
 # Copyright © 1998 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv

Index: tests/earth.gif
==================================================================
--- tests/earth.gif
+++ tests/earth.gif
cannot compute difference between binary files

Index: tests/embed.test
==================================================================
--- tests/embed.test
+++ tests/embed.test
@@ -1,9 +1,9 @@
 # This file is a Tcl script to test out embedded Windows.
 #
 # Copyright © 1996-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv

Index: tests/entry.test
==================================================================
--- tests/entry.test
+++ tests/entry.test
@@ -1,19 +1,19 @@
 # This file is a Tcl script to test entry widgets in Tk.  It is
 # organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnUbuntuNoXft [expr {[testConstraint failsOnUbuntu] || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))}]
 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 # For xscrollcommand
 set scrollInfo {}
@@ -45,381 +45,381 @@
 set cy [font metrics {Courier -12} -linespace]
 
 
 test entry-1.1 {configuration option: "background" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -background #ff0000
     .e cget -background
 } -cleanup {
     destroy .e
 } -result {#ff0000}
 test entry-1.2 {configuration option: "background" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -background non-existent
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {unknown color name "non-existent"}
 
 test entry-1.3 {configuration option: "bd" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -bd 4
     .e cget -bd
 } -cleanup {
     destroy .e
 } -result 4
 test entry-1.4 {configuration option: "bd" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -bd badValue
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {bad screen distance "badValue"}
 
 test entry-1.5 {configuration option: "bg" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -bg #ff0000
     .e cget -bg
 } -cleanup {
     destroy .e
 } -result {#ff0000}
 test entry-1.6 {configuration option: "bg" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -bg non-existent
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {unknown color name "non-existent"}
 
 test entry-1.7 {configuration option: "borderwidth" for entry} -setup {
     entry .e -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -borderwidth 1.3
     .e cget -borderwidth
 } -cleanup {
     destroy .e
 } -result 1
 test entry-1.8 {configuration option: "borderwidth" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -borderwidth badValue
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {bad screen distance "badValue"}
 
 test entry-1.9 {configuration option: "cursor" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -cursor arrow
     .e cget -cursor
 } -cleanup {
     destroy .e
 } -result {arrow}
 test entry-1.10 {configuration option: "cursor" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -cursor badValue
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {bad cursor spec "badValue"}
 
 test entry-1.11 {configuration option: "disabledbackground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -disabledbackground green
     .e cget -disabledbackground
 } -cleanup {
     destroy .e
 } -result {green}
 test entry-1.12 {configuration option: "disabledbackground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -disabledbackground non-existent
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {unknown color name "non-existent"}
 
 test entry-1.13 {configuration option: "disabledforeground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -disabledforeground blue
     .e cget -disabledforeground
 } -cleanup {
     destroy .e
 } -result {blue}
 test entry-1.14 {configuration option: "disabledforeground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -disabledforeground non-existent
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {unknown color name "non-existent"}
 
 test entry-1.15 {configuration option: "exportselection" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -exportselection yes
     .e cget -exportselection
 } -cleanup {
     destroy .e
 } -result 1
 test entry-1.16 {configuration option: "exportselection" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -exportselection xyzzy
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {expected boolean value but got "xyzzy"}
 
 test entry-1.17 {configuration option: "fg" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -fg #110022
     .e cget -fg
 } -cleanup {
     destroy .e
 } -result {#110022}
 test entry-1.18 {configuration option: "fg" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -fg non-existent
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {unknown color name "non-existent"}
 
 test entry-1.19 {configuration option: "font" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -font {Helvetica -12}
     .e cget -font
 } -cleanup {
     destroy .e
 } -result {Helvetica -12}
 test entry-1.20 {configuration option: "font" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -font {}
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {font "" doesn't exist}
 
 test entry-1.21 {configuration option: "foreground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -foreground #110022
     .e cget -foreground
 } -cleanup {
     destroy .e
 } -result {#110022}
 test entry-1.22 {configuration option: "foreground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -foreground non-existent
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {unknown color name "non-existent"}
 
 test entry-1.23 {configuration option: "highlightbackground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -highlightbackground #110022
     .e cget -highlightbackground
 } -cleanup {
     destroy .e
 } -result {#110022}
 test entry-1.24 {configuration option: "highlightbackground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -highlightbackground non-existent
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {unknown color name "non-existent"}
 
 test entry-1.25 {configuration option: "highlightcolor" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -highlightcolor #110022
     .e cget -highlightcolor
 } -cleanup {
     destroy .e
 } -result {#110022}
 test entry-1.26 {configuration option: "highlightcolor" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -highlightcolor non-existent
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {unknown color name "non-existent"}
 
 test entry-1.27 {configuration option: "highlightthickness" for entry} -setup {
     entry .e -borderwidth 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -highlightthickness 6
     .e cget -highlightthickness
 } -cleanup {
     destroy .e
 } -result 6
 test entry-1.28 {configuration option: "highlightthickness" for entry} -setup {
     entry .e -borderwidth 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -highlightthickness -2
     .e cget -highlightthickness
 } -cleanup {
     destroy .e
 } -result 0
 test entry-1.29 {configuration option: "highlightthickness" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -highlightthickness badValue
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {bad screen distance "badValue"}
 
 test entry-1.30 {configuration option: "insertbackground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -insertbackground #110022
     .e cget -insertbackground
 } -cleanup {
     destroy .e
 } -result {#110022}
 test entry-1.31 {configuration option: "insertbackground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -insertbackground non-existent
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {unknown color name "non-existent"}
 
 test entry-1.32 {configuration option: "insertborderwidth" for entry} -setup {
     entry .e -borderwidth 2 -insertwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -insertborderwidth 1.3
     .e cget -insertborderwidth
 } -cleanup {
     destroy .e
 } -result 1
 test entry-1.33 {configuration option: "insertborderwidth" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -insertborderwidth 2.6x
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {bad screen distance "2.6x"}
 
 test entry-1.34 {configuration option: "insertofftime" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -insertofftime 100
     .e cget -insertofftime
 } -cleanup {
     destroy .e
 } -result 100
 test entry-1.35 {configuration option: "insertofftime" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -insertofftime 3.2
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {expected integer but got "3.2"}
 
 test entry-1.36 {configuration option: "insertontime" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -insertontime 100
     .e cget -insertontime
 } -cleanup {
     destroy .e
 } -result 100
 test entry-1.37 {configuration option: "insertontime" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -insertontime 3.2
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {expected integer but got "3.2"}
 
 test entry-1.38 {configuration option: "invalidcommand" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -invalidcommand "any string"
     .e cget -invalidcommand
 } -cleanup {
@@ -426,11 +426,11 @@
     destroy .e
 } -result {any string}
 
 test entry-1.39 {configuration option: "invcmd" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -invcmd "any string"
     .e cget -invcmd
 } -cleanup {
@@ -437,51 +437,51 @@
     destroy .e
 } -result {any string}
 
 test entry-1.40 {configuration option: "justify" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -justify right
     .e cget -justify
 } -cleanup {
     destroy .e
 } -result {right}
 test entry-1.41 {configuration option: "justify" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -justify bogus
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {bad justification "bogus": must be left, right, or center}
 
 test entry-1.42 {configuration option: "readonlybackground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -readonlybackground green
     .e cget -readonlybackground
 } -cleanup {
     destroy .e
 } -result {green}
 test entry-1.43 {configuration option: "readonlybackground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -readonlybackground non-existent
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {unknown color name "non-existent"}
 
 test entry-1.44 {configuration option: "relief" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -relief flat
     .e cget -relief
 } -cleanup {
@@ -488,71 +488,71 @@
     destroy .e
 } -result {flat}
 
 test entry-1.45 {configuration option: "selectbackground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -selectbackground #110022
     .e cget -selectbackground
 } -cleanup {
     destroy .e
 } -result {#110022}
 test entry-1.46 {configuration option: "selectbackground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -selectbackground non-existent
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {unknown color name "non-existent"}
 
 test entry-1.47 {configuration option: "selectborderwidth" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -selectborderwidth 1.3
     .e cget -selectborderwidth
 } -cleanup {
     destroy .e
 } -result 1
 test entry-1.48 {configuration option: "selectborderwidth" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -selectborderwidth badValue
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {bad screen distance "badValue"}
 
 test entry-1.49 {configuration option: "selectforeground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -selectforeground #110022
     .e cget -selectforeground
 } -cleanup {
     destroy .e
 } -result {#110022}
 test entry-1.50 {configuration option: "selectforeground" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -selectforeground non-existent
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {unknown color name "non-existent"}
 
 test entry-1.51 {configuration option: "show" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -show *
     .e cget -show
 } -cleanup {
@@ -559,31 +559,31 @@
     destroy .e
 } -result {*}
 
 test entry-1.52 {configuration option: "state" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -state n
     .e cget -state
 } -cleanup {
     destroy .e
 } -result {normal}
 test entry-1.53 {configuration option: "state" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -state bogus
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {bad state "bogus": must be disabled, normal, or readonly}
 
 test entry-1.54 {configuration option: "takefocus" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -takefocus "any string"
     .e cget -takefocus
 } -cleanup {
@@ -590,11 +590,11 @@
     destroy .e
 } -result {any string}
 
 test entry-1.55 {configuration option: "textvariable" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -textvariable i
     .e cget -textvariable
 } -cleanup {
@@ -601,31 +601,31 @@
     destroy .e
 } -result {i}
 
 test entry-1.56 {configuration option: "width" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -width 402
     .e cget -width
 } -cleanup {
     destroy .e
 } -result 402
 test entry-1.57 {configuration option: "width" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -width 3p
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {expected integer but got "3p"}
 
 test entry-1.58 {configuration option: "xscrollcommand" for entry} -setup {
     entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold}
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -xscrollcommand {Some command}
     .e cget -xscrollcommand
 } -cleanup {
@@ -657,11 +657,11 @@
 test entry-2.2 {Tk_EntryCmd procedure} -body {
     entry gorp
 } -returnCodes error -result {bad window path name "gorp"}
 test entry-2.3 {Tk_EntryCmd procedure} -body {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
     list [winfo exists .e] [winfo class .e] [info commands .e]
 } -cleanup {
     destroy .e
 } -result {1 Entry .e}
@@ -683,47 +683,47 @@
 } -result {.e}
 
 
 test entry-3.1 {EntryWidgetCmd procedure} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e
 } -cleanup {
     destroy .e
 } -returnCodes error -result {wrong # args: should be ".e option ?arg ...?"}
 test entry-3.2 {EntryWidgetCmd procedure, "bbox" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e bbox
 } -cleanup {
     destroy .e
 } -returnCodes error -result {wrong # args: should be ".e bbox index"}
 test entry-3.3 {EntryWidgetCmd procedure, "bbox" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e bbox a b
 } -cleanup {
     destroy .e
 } -returnCodes error -result {wrong # args: should be ".e bbox index"}
 test entry-3.4 {EntryWidgetCmd procedure, "bbox" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e bbox bogus
 } -cleanup {
     destroy .e
 } -returnCodes error -result {bad entry index "bogus"}
 test entry-3.5 {EntryWidgetCmd procedure, "bbox" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
    .e bbox 0
 } -cleanup {
     destroy .e
@@ -734,11 +734,11 @@
 # that passes fonts constraint (this concerns tests 3.6, 3.7, 3.8, 3.10)
 test entry-3.6 {EntryWidgetCmd procedure, "bbox" widget command} -constraints {
 	fonts
 } -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
 # Tcl_UtfAtIndex(): no utf chars
     .e insert 0 "abc"
     list [.e bbox 3] [.e bbox end]
@@ -747,11 +747,11 @@
 } -result {{19 5 7 13} {19 5 7 13}}
 test entry-3.7 {EntryWidgetCmd procedure, "bbox" widget command} -constraints {
 	fonts
 } -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
 # Tcl_UtfAtIndex(): utf at end
     .e insert 0 "ab乎"
     .e bbox end
@@ -760,11 +760,11 @@
 } -result {19 5 12 13}
 test entry-3.8 {EntryWidgetCmd procedure, "bbox" widget command} -constraints {
 	fonts
 } -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
 # Tcl_UtfAtIndex(): utf before index
     .e insert 0 "ab乎c"
     .e bbox 3
@@ -771,11 +771,11 @@
 } -cleanup {
     destroy .e
 } -result {31 5 7 13}
 test entry-3.9 {EntryWidgetCmd procedure, "bbox" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
 # Tcl_UtfAtIndex(): no chars
     .e bbox end
 } -cleanup {
@@ -783,11 +783,11 @@
 } -result "5 5 0 $cy"
 test entry-3.10 {EntryWidgetCmd procedure, "bbox" widget command} -constraints {
 	fonts
 } -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert 0 "abcdefghij乎klmnop"
     list [.e bbox 0] [.e bbox 1] [.e bbox 10] [.e bbox end]
 } -cleanup {
@@ -822,11 +822,11 @@
 } -cleanup {
     destroy .e
 } -result 4
 test entry-3.15 {EntryWidgetCmd procedure, "configure" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     llength [.e configure]
 } -cleanup {
     destroy .e
@@ -875,11 +875,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {bad entry index "bar"}
 test entry-3.22 {EntryWidgetCmd procedure, "delete" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "01234567890"
     .e delete 2 4
     .e get
@@ -895,11 +895,11 @@
 } -cleanup {
     destroy .e
 } -result 0123457890
 test entry-3.24 {EntryWidgetCmd procedure, "delete" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
     set x {}
 } -body {
 # UTF
     .e insert end "01234乎67890"
@@ -916,11 +916,11 @@
 } -cleanup {
     destroy .e
 } -result [list "01234乎7890" "0123457890" "012345乎890"]
 test entry-3.25 {EntryWidgetCmd procedure, "delete" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "01234567890"
     .e delete 6 5
     .e get
@@ -927,11 +927,11 @@
 } -cleanup {
     destroy .e
 } -result 01234567890
 test entry-3.26 {EntryWidgetCmd procedure, "delete" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "01234567890"
     .e configure -state disabled
     .e delete 2 8
@@ -940,11 +940,11 @@
 } -cleanup {
     destroy .e
 } -result 01234567890
 test entry-3.26a {EntryWidgetCmd procedure, "delete" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "01234567890"
     .e configure -state readonly
     .e delete 2 8
@@ -1004,20 +1004,20 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {bad entry index "foo"}
 test entry-3.34 {EntryWidgetCmd procedure, "index" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e index 0
 } -cleanup {
     destroy .e
 } -returnCodes {ok} -match glob -result {*}
 test entry-3.35 {EntryWidgetCmd procedure, "index" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
 # UTF
     .e insert 0 abc乎œdef
     list [.e index 3] [.e index 4] [.e index end]
@@ -1045,11 +1045,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {bad entry index "foo"}
 test entry-3.39 {EntryWidgetCmd procedure, "insert" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "01234567890"
     .e insert 3 xxx
     .e get
@@ -1056,11 +1056,11 @@
 } -cleanup {
     destroy .e
 } -result {012xxx34567890}
 test entry-3.40 {EntryWidgetCmd procedure, "insert" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "01234567890"
     .e configure -state disabled
     .e insert 3 xxx
@@ -1069,11 +1069,11 @@
 } -cleanup {
     destroy .e
 } -result 01234567890
 test entry-3.40a {EntryWidgetCmd procedure, "insert" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "01234567890"
     .e configure -state readonly
     .e insert 3 xxx
@@ -1089,38 +1089,38 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {wrong # args: should be ".e insert index text"}
 test entry-3.42 {EntryWidgetCmd procedure, "scan" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e scan a
 } -cleanup {
     destroy .e
 } -returnCodes error -result {wrong # args: should be ".e scan mark|dragto x"}
 test entry-3.43 {EntryWidgetCmd procedure, "scan" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e scan a b c
 } -cleanup {
     destroy .e
 } -returnCodes error -result {wrong # args: should be ".e scan mark|dragto x"}
 test entry-3.44 {EntryWidgetCmd procedure, "scan" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e scan foobar 20
 } -cleanup {
     destroy .e
-} -returnCodes error -result {bad scan option "foobar": must be mark or dragto}
+} -returnCodes error -result {bad scan option "foobar": must be dragto or mark}
 test entry-3.45 {EntryWidgetCmd procedure, "scan" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e scan mark 20.1
 } -cleanup {
     destroy .e
@@ -1129,11 +1129,11 @@
 # This test is non-portable because character sizes vary.
 test entry-3.46 {EntryWidgetCmd procedure, "scan" widget command} -constraints {
     fonts
 } -setup {
     entry .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "This is quite a long string, in fact a "
     .e insert end "very very long string"
     .e scan mark 30
@@ -1176,11 +1176,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {PRIMARY selection doesn't exist or form "STRING" not defined}
 test entry-3.50.1 {EntryWidgetCmd procedure, "select clear" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "0123456789"
     .e select from 1
     .e select to 4
@@ -1199,11 +1199,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {wrong # args: should be ".e selection present"}
 test entry-3.52 {EntryWidgetCmd procedure, "selection present" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end 0123456789
     .e select from 3
     .e select to 6
@@ -1211,11 +1211,11 @@
 } -cleanup {
     destroy .e
 } -result 1
 test entry-3.53 {EntryWidgetCmd procedure, "selection present" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end 0123456789
     .e select from 3
     .e select to 6
@@ -1224,11 +1224,11 @@
 } -cleanup {
     destroy .e
 } -result 1
 test entry-3.54 {EntryWidgetCmd procedure, "selection present" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end 0123456789
     .e select from 3
     .e select to 6
@@ -1251,11 +1251,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {wrong # args: should be ".e selection adjust index"}
 test entry-3.57 {EntryWidgetCmd procedure, "selection adjust" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "0123456789"
     .e select from 1
     .e select to 5
@@ -1265,11 +1265,11 @@
 } -cleanup {
     destroy .e
 } -result 123
 test entry-3.58 {EntryWidgetCmd procedure, "selection adjust" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "0123456789"
     .e select from 1
     .e select to 5
@@ -1312,11 +1312,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {selection isn't in widget .e}
 test entry-3.63 {EntryWidgetCmd procedure, "selection range" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end 0123456789
     .e select from 3
     .e select to 7
@@ -1325,11 +1325,11 @@
 } -cleanup {
     destroy .e
 } -result {2 9 3}
 test entry-3.64 {EntryWidgetCmd procedure, "selection" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end 0123456789
     .e selection range 0 end
     .e configure -state disabled
@@ -1339,11 +1339,11 @@
 } -cleanup {
     destroy .e
 } -result {0 10}
 test entry-3.64a {EntryWidgetCmd procedure, "selection" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end 0123456789
     .e selection range 0 end
     .e configure -state readonly
@@ -1353,11 +1353,11 @@
 } -cleanup {
     destroy .e
 } -result {2 4}
 test entry-3.64b {EntryWidgetCmd procedure, "selection to" widget command} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
 } -body {
     .e select to 2 3
@@ -1365,11 +1365,11 @@
     destroy .e
 } -returnCodes error -result {wrong # args: should be ".e selection to index"}
 
 test entry-3.65 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     .e xview 5
@@ -1377,20 +1377,20 @@
 } -cleanup {
     destroy .e
 } -result {0.0537634 0.2688172}
 test entry-3.66 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e xview gorp
 } -cleanup {
     destroy .e
 } -returnCodes error -result {bad entry index "gorp"}
 test entry-3.67 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     .e xview 0
@@ -1400,29 +1400,29 @@
 } -cleanup {
     destroy .e
 } -result {0.107527 0.322581}
 test entry-3.68 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e xview moveto foo bar
 } -cleanup {
     destroy .e
 } -returnCodes error -result {wrong # args: should be ".e xview moveto fraction"}
 test entry-3.69 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e xview moveto foo
 } -cleanup {
     destroy .e
 } -returnCodes error -result {expected floating-point number but got "foo"}
 test entry-3.70 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     .e xview moveto 0.5
@@ -1430,11 +1430,11 @@
 } -cleanup {
     destroy .e
 } -result {0.505376 0.720430}
 test entry-3.71 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     .e xview scroll 24
@@ -1441,11 +1441,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {wrong # args: should be ".e xview scroll number pages|units"}
 test entry-3.72 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     update
     .e xview scroll gorp units
@@ -1452,11 +1452,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {expected floating-point number but got "gorp"}
 test entry-3.73 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     update
     .e xview moveto 0
@@ -1465,11 +1465,11 @@
 } -cleanup {
     destroy .e
 } -result {0.193548 0.408602}
 test entry-3.74 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     .e xview moveto .9
@@ -1479,11 +1479,11 @@
 } -cleanup {
     destroy .e
 } -result {0.397849 0.612903}
 test entry-3.75 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     update
     .e xview 30
@@ -1493,11 +1493,11 @@
 } -cleanup {
     destroy .e
 } -result 32
 test entry-3.76 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     update
     .e xview 30
@@ -1507,11 +1507,11 @@
 } -cleanup {
     destroy .e
 } -result 29
 test entry-3.77 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     update
     .e xview scroll 23 foobars
@@ -1518,11 +1518,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {bad argument "foobars": must be pages or units}
 test entry-3.78 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     update
     .e xview eat 23 hamburgers
@@ -1529,25 +1529,25 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {unknown option "eat": must be moveto or scroll}
 test entry-3.79 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     .e xview 0
     update
-    .e xview -1
+    .e xview {}
     .e index @0
 } -cleanup {
     destroy .e
 } -result 0
 test entry-3.80 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     update
     .e xview 300
@@ -1555,11 +1555,11 @@
 } -cleanup {
     destroy .e
 } -result 73
 test entry-3.86 {EntryWidgetCmd procedure, "xview" widget command} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     .e insert 10 乎
     update
@@ -1577,11 +1577,11 @@
     destroy .e
 } -result {0.095745 0.106383 0.117021}
 
 test entry-3.82 {EntryWidgetCmd procedure} -setup {
     entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e gorp
 } -cleanup {
     destroy .e
@@ -1591,11 +1591,11 @@
 # with Purify or some other memory-allocation-checking program it will
 # ensure that resources get properly freed.
 
 test entry-4.1 {DestroyEntry procedure} -body {
     entry .e -textvariable x -show *
-    pack .e
+    pack .e ; update idletasks
     .e insert end "Sample text"
     update
     destroy .e
 } -result {}
 
@@ -1646,11 +1646,11 @@
     entry .e2
 } -body {
     .e2 insert end "This is some sample text"
     .e1 configure -exportselection false
     .e1 insert end "0123456789"
-    pack .e1 .e2
+    pack .e1 .e2 ; update idletasks
     .e2 select from 0
     .e2 select to 10
     lappend x [selection get]
     .e1 select from 1
     .e1 select to 5
@@ -1661,11 +1661,11 @@
 } -cleanup {
     destroy .e1 .e2
 } -result {{This is so} {This is so} 1234}
 test entry-5.6 {ConfigureEntry procedure} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert end "0123456789"
     .e select from 1
     .e select to 5
     .e configure -exportselection 0
@@ -1673,11 +1673,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {PRIMARY selection doesn't exist or form "STRING" not defined}
 test entry-5.6.1 {ConfigureEntry procedure} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert end "0123456789"
     .e select from 1
     .e select to 5
     .e configure -exportselection 0
@@ -1687,11 +1687,11 @@
     destroy .e
 } -result {1 5}
 
 test entry-5.7 {ConfigureEntry procedure} -setup {
     entry .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -font {Courier -12} -width 4 -xscrollcommand scroll
     .e insert end "01234567890"
     update idletasks
     set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
@@ -1706,11 +1706,11 @@
 
 test entry-5.8 {ConfigureEntry procedure} -constraints {
     fonts failsOnXQuarz
 } -setup {
     entry .e -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -width 0 -font {Helvetica -12}
     .e insert end "0123"
     update
     .e configure -font {Helvetica -24}
@@ -1721,11 +1721,11 @@
 } -result {62x37+0+0}
 test entry-5.9 {ConfigureEntry procedure} -constraints {
     fonts
 } -setup {
     entry .e -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -font {Courier -12} -bd 2 -relief raised
     .e insert end "0123"
     update
     list [.e index @10] [.e index @11] [.e index @12] [.e index @13]
@@ -1734,11 +1734,11 @@
 } -result {0 0 1 1}
 test entry-5.10 {ConfigureEntry procedure} -constraints {
     fonts
 } -setup {
     entry .e -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -font {Courier -12} -bd 2 -relief flat
     .e insert end "0123"
     update
     list [.e index @10] [.e index @11] [.e index @12] [.e index @13]
@@ -1745,11 +1745,11 @@
 } -cleanup {
     destroy .e
 } -result {0 0 1 1}
 test entry-5.11 {ConfigureEntry procedure} -setup {
     entry .e -borderwidth 2 -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
 # If "0" in selected font had 0 width, caused divide-by-zero error.
     .e configure -font {{open look glyph}}
     .e scan dragto 30
     update
@@ -1761,11 +1761,11 @@
 
 test entry-6.1 {EntryComputeGeometry procedure} -constraints {
     fonts
 } -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -font {Courier -12} -bd 2 -relief raised -width 20 \
         -highlightthickness 3
     .e insert end 012\t45
     update
@@ -1775,11 +1775,11 @@
 } -result {3 4}
 test entry-6.2 {EntryComputeGeometry procedure} -constraints {
     fonts
 } -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -font {Courier -12} -bd 2 -relief raised -width 20 \
         -justify center -highlightthickness 3
     .e insert end 012\t45
     update
@@ -1789,11 +1789,11 @@
 } -result {3 4}
 test entry-6.3 {EntryComputeGeometry procedure} -constraints {
     fonts
 } -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -font {Courier -12} -bd 2 -relief raised -width 20 \
         -justify right -highlightthickness 3
     .e insert end 012\t45
     update
@@ -1801,11 +1801,11 @@
 } -cleanup {
     destroy .e
 } -result {3 4}
 test entry-6.4 {EntryComputeGeometry procedure} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -font {Courier -12} -bd 2 -relief raised -width 5
     .e insert end "01234567890"
     update
     .e xview 6
@@ -1813,11 +1813,11 @@
 } -cleanup {
     destroy .e
 } -result 6
 test entry-6.5 {EntryComputeGeometry procedure} -setup {
     entry .e -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -font {Courier -12} -bd 2 -relief raised -width 5
     .e insert end "01234567890"
     update
     .e xview 7
@@ -1827,11 +1827,11 @@
 } -result 6
 test entry-6.6 {EntryComputeGeometry procedure} -constraints {
     fonts
 } -setup {
     entry .e -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -font {Courier -12} -bd 2 -relief raised -width 10
     .e insert end "01234\t67890"
     update
     .e xview 3
@@ -1841,11 +1841,11 @@
 } -result {5 6}
 test entry-6.7 {EntryComputeGeometry procedure} -constraints {
     fonts
 } -setup {
     entry .e -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -font {Helvetica -24} -bd 3 -relief raised -width 5
     .e insert end "01234567"
     update
     list [winfo reqwidth .e] [winfo reqheight .e]
@@ -1854,11 +1854,11 @@
 } -result {77 39}
 test entry-6.8 {EntryComputeGeometry procedure} -constraints {
     fonts
 } -setup {
     entry .e -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -font {Helvetica -24} -bd 3 -relief raised -width 0
     .e insert end "01234567"
     update
     list [winfo reqwidth .e] [winfo reqheight .e]
@@ -1867,11 +1867,11 @@
 } -result {116 39}
 test entry-6.9 {EntryComputeGeometry procedure} -constraints {
     fonts
 } -setup {
     entry .e -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -font {Helvetica -24} -bd 3 -relief raised -width 0
     update
     list [winfo reqwidth .e] [winfo reqheight .e]
 } -cleanup {
@@ -1879,11 +1879,11 @@
 } -result {25 39}
 test entry-6.10 {EntryComputeGeometry procedure} -constraints {
     unix fonts
 } -setup {
     entry .e -highlightthickness 2 -font {Helvetica -12}
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -bd 1 -relief raised -width 0 -show .
     .e insert 0 12345
     update
     set x [winfo reqwidth .e]
@@ -1896,11 +1896,11 @@
 } -result {23 53 43}
 test entry-6.11 {EntryComputeGeometry procedure} -constraints {
     win
 } -setup {
     entry .e -highlightthickness 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -bd 1 -relief raised -width 0 -show . -font {helvetica 12}
     .e insert 0 12345
     update
     set x1 [winfo reqwidth .e]
@@ -1920,11 +1920,11 @@
 test entry-6.12 {EntryComputeGeometry procedure} -constraints {
     fonts
 } -setup {
     catch {destroy .e}
     entry .e -font {Courier -12} -bd 2 -relief raised -width 20
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert end "012\t456\t"
     update
     list [.e index @80] [.e index @81] [.e index @115] [.e index @116]
 } -cleanup {
@@ -1933,11 +1933,11 @@
 
 
 test entry-7.1 {InsertChars procedure} -setup {
     unset -nocomplain contents
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e configure -textvariable contents -xscrollcommand scroll
     set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
     .e insert 0 abcde
@@ -1950,11 +1950,11 @@
 } -result {abXXXcde abXXXcde {0.000000 1.000000}}
 
 test entry-7.2 {InsertChars procedure} -setup {
     unset -nocomplain contents
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e configure -textvariable contents -xscrollcommand scroll
     set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
     .e insert 0 abcde
@@ -1965,11 +1965,11 @@
     destroy .e
     after cancel $timeout
 } -result {abcdeXXX abcdeXXX {0.000000 1.000000}}
 test entry-7.3 {InsertChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 0123456789
     .e select from 2
     .e select to 6
     .e insert 2 XXX
@@ -1979,11 +1979,11 @@
 } -cleanup {
     destroy .e
 } -result {5 9 5 8}
 test entry-7.4 {InsertChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 0123456789
     .e select from 2
     .e select to 6
     .e insert 3 XXX
@@ -1993,11 +1993,11 @@
 } -cleanup {
     destroy .e
 } -result {2 9 2 8}
 test entry-7.5 {InsertChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 0123456789
     .e select from 2
     .e select to 6
     .e insert 5 XXX
@@ -2007,11 +2007,11 @@
 } -cleanup {
     destroy .e
 } -result {2 9 2 8}
 test entry-7.6 {InsertChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 0123456789
     .e select from 2
     .e select to 6
     .e insert 6 XXX
@@ -2021,11 +2021,11 @@
 } -cleanup {
     destroy .e
 } -result {2 6 2 5}
 test entry-7.7 {InsertChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -xscrollcommand scroll
     .e insert 0 0123456789
     .e icursor 4
     .e insert 4 XXX
@@ -2033,11 +2033,11 @@
 } -cleanup {
     destroy .e
 } -result 7
 test entry-7.8 {InsertChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 0123456789
     .e icursor 4
     .e insert 5 XXX
     .e index insert
@@ -2044,11 +2044,11 @@
 } -cleanup {
     destroy .e
 } -result 4
 test entry-7.9 {InsertChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 "This is a very long string"
     update
     .e xview 4
     .e insert 3 XXX
@@ -2056,11 +2056,11 @@
 } -cleanup {
     destroy .e
 } -result 7
 test entry-7.10 {InsertChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 "This is a very long string"
     update
     .e xview 4
     .e insert 4 XXX
@@ -2071,11 +2071,11 @@
 
 test entry-7.11 {InsertChars procedure} -constraints {
     fonts
 } -setup {
     entry .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 "xyzzy"
     update
     .e insert 2 00
     winfo reqwidth .e
@@ -2084,11 +2084,11 @@
 } -result 59
 
 test entry-8.1 {DeleteChars procedure} -setup {
     unset -nocomplain contents
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e configure -textvariable contents -xscrollcommand scroll
     set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
     .e insert 0 abcde
@@ -2100,27 +2100,27 @@
     after cancel $timeout
 } -result {abe abe {0.000000 1.000000}}
 test entry-8.2 {DeleteChars procedure} -setup {
     unset -nocomplain contents
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e configure -textvariable contents -xscrollcommand scroll
     set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
     .e insert 0 abcde
-    .e delete -1 2
+    .e delete {} 2
     vwait scrollInfo
     list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
 } -cleanup {
     destroy .e
     after cancel $timeout
 } -result {cde cde {0.000000 1.000000}}
 test entry-8.3 {DeleteChars procedure} -setup {
     unset -nocomplain contents
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e configure -textvariable contents -xscrollcommand scroll
     set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
     .e insert 0 abcde
@@ -2131,11 +2131,11 @@
     destroy .e
     after cancel $timeout
 } -result {abc abc {0.000000 1.000000}}
 test entry-8.4 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 0123456789abcde
     .e select from 3
     .e select to 8
@@ -2147,11 +2147,11 @@
 } -cleanup {
     destroy .e
 } -result {1 6 1 5}
 test entry-8.5 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 0123456789abcde
     .e select from 3
     .e select to 8
@@ -2163,11 +2163,11 @@
 } -cleanup {
     destroy .e
 } -result {1 5 1 4}
 test entry-8.6 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 0123456789abcde
     .e select from 3
     .e select to 8
@@ -2179,11 +2179,11 @@
 } -cleanup {
     destroy .e
 } -result {1 2 1 5}
 test entry-8.7 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 0123456789abcde
     .e select from 3
     .e select to 8
@@ -2193,11 +2193,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {selection isn't in widget .e}
 test entry-8.8 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 0123456789abcde
     .e select from 3
     .e select to 8
@@ -2209,11 +2209,11 @@
 } -cleanup {
     destroy .e
 } -result {3 4 3 8}
 test entry-8.9 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 0123456789abcde
     .e select from 3
     .e select to 8
     .e delete 3 8
@@ -2222,11 +2222,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {selection isn't in widget .e}
 test entry-8.10 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 0123456789abcde
     .e select from 8
     .e select to 3
@@ -2238,11 +2238,11 @@
 } -cleanup {
     destroy .e
 } -result {3 5 5 8}
 test entry-8.11 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 0123456789abcde
     .e select from 8
     .e select to 3
@@ -2254,11 +2254,11 @@
 } -cleanup {
     destroy .e
 } -result {3 8 4 8}
 test entry-8.12 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 0123456789abcde
     .e icursor 4
     .e delete 1 4
@@ -2267,11 +2267,11 @@
 } -cleanup {
     destroy .e
 } -result 1
 test entry-8.13 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 0123456789abcde
     .e icursor 4
     .e delete 1 5
@@ -2280,11 +2280,11 @@
 } -cleanup {
     destroy .e
 } -result 1
 test entry-8.14 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 0123456789abcde
     .e icursor 4
     .e delete 4 6
@@ -2293,11 +2293,11 @@
 } -cleanup {
     destroy .e
 } -result 4
 test entry-8.15 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 "This is a very long string"
     .e xview 4
     .e delete 1 4
@@ -2306,11 +2306,11 @@
 } -cleanup {
     destroy .e
 } -result 1
 test entry-8.16 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 "This is a very long string"
     .e xview 4
     .e delete 1 5
@@ -2319,11 +2319,11 @@
 } -cleanup {
     destroy .e
 } -result 1
 test entry-8.17 {DeleteChars procedure} -setup {
     entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 "This is a very long string"
     .e xview 4
     .e delete 4 6
@@ -2332,11 +2332,11 @@
 } -cleanup {
     destroy .e
 } -result 4
 test entry-8.18 {DeleteChars procedure} -constraints failsOnUbuntuNoXft -setup {
     entry .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     focus .e
 } -body {
     .e insert 0 "xyzzy"
     update
     .e delete 2 4
@@ -2371,11 +2371,11 @@
 
 test entry-10.1 {EntrySetValue procedure} -constraints fonts -body {
     set x abcde
     set y ab
     entry .e  -font {Helvetica -12} -highlightthickness 2 -bd 2  -width 0
-    pack .e
+    pack .e ; update idletasks
     .e configure -textvariable x
     .e configure -textvariable y
     update
     list [.e get] [winfo reqwidth .e]
 } -cleanup {
@@ -2382,11 +2382,11 @@
     destroy .e
 } -result {ab 24}
 test entry-10.2 {EntrySetValue procedure, updating selection} -setup {
     unset -nocomplain x
     entry .e -font {Helvetica -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -textvariable x
     .e insert 0 "abcdefghjklmnopqrstu"
     .e selection range 4 10
     set x "a"
@@ -2395,11 +2395,11 @@
     destroy .e
 } -returnCodes error -result {selection isn't in widget .e}
 test entry-10.3 {EntrySetValue procedure, updating selection} -setup {
     unset -nocomplain x
     entry .e -font {Helvetica -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -textvariable x
     .e insert 0 "abcdefghjklmnopqrstu"
     .e selection range 4 10
     set x "abcdefg"
@@ -2408,11 +2408,11 @@
     destroy .e
 } -result {4 7}
 test entry-10.4 {EntrySetValue procedure, updating selection} -setup {
     unset -nocomplain x
     entry .e -font {Helvetica -12} -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -textvariable x
     .e insert 0 "abcdefghjklmnopqrstu"
     .e selection range 4 10
     set x "abcdefghijklmn"
@@ -2421,11 +2421,11 @@
     destroy .e
 } -result {4 10}
 test entry-10.5 {EntrySetValue procedure, updating display position} -setup {
     unset -nocomplain x
     entry .e -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -width 10 -font {Courier -12} -textvariable x
     .e insert 0 "abcdefghjklmnopqrstuvwxyz"
     .e xview 10
     update
@@ -2436,14 +2436,14 @@
     destroy .e
 } -result 0
 test entry-10.6 {EntrySetValue procedure, updating display position} -setup {
     unset -nocomplain x
     entry .e -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -width 10 -font {Courier -12} -textvariable x
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 "abcdefghjklmnopqrstuvwxyz"
     .e xview 10
     update
     set x "1234567890123456789012"
     update
@@ -2452,15 +2452,15 @@
     destroy .e
 } -result 10
 test entry-10.7 {EntrySetValue procedure, updating insertion cursor} -setup {
     unset -nocomplain x
     entry .e -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e configure -width 10 -font {Courier -12} -textvariable x
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 "abcdefghjklmnopqrstuvwxyz"
     .e icursor 5
     set x "123"
     .e index insert
 } -cleanup {
@@ -2467,14 +2467,14 @@
     destroy .e
 } -result 3
 test entry-10.8 {EntrySetValue procedure, updating insertion cursor} -setup {
     unset -nocomplain x
     entry .e -highlightthickness 2 -bd 2
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e configure -width 10 -font {Courier -12} -textvariable x
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 "abcdefghjklmnopqrstuvwxyz"
     .e icursor 5
     set x "123456"
     .e index insert
 } -cleanup {
@@ -2481,11 +2481,11 @@
     destroy .e
 } -result 5
 
 test entry-11.1 {EntryEventProc procedure} -setup {
     entry .e -highlightthickness 2 -bd 2 -font {Helvetica -12}
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 abcdefg
     destroy .e
     update
 } -cleanup {
@@ -2513,11 +2513,11 @@
 } -result {{} {}}
 
 
 test entry-13.1 {GetEntryIndex procedure} -setup {
     entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e index end
@@ -2530,11 +2530,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {bad entry index "abogus"}
 test entry-13.3 {GetEntryIndex procedure} -setup {
     entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e select from 1
@@ -2543,11 +2543,11 @@
 } -cleanup {
     destroy .e
 } -result 1
 test entry-13.4 {GetEntryIndex procedure} -setup {
     entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e select from 4
@@ -2556,11 +2556,11 @@
 } -cleanup {
     destroy .e
 } -result 4
 test entry-13.5 {GetEntryIndex procedure} -setup {
     entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e select from 3
@@ -2577,11 +2577,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {bad entry index "ebogus"}
 test entry-13.7 {GetEntryIndex procedure} -setup {
     entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e icursor 2
@@ -2596,11 +2596,11 @@
 } -cleanup {
     destroy .e
 } -returnCodes error -result {bad entry index "ibogus"}
 test entry-13.9 {GetEntryIndex procedure} -setup {
     entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
-    pack .e
+    pack .e ; update idletasks
 } -body {
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e select from 1
@@ -2618,11 +2618,11 @@
 test entry-13.10 {GetEntryIndex procedure} -constraints x11 -body {
 # On unix, when selection is cleared, entry widget's internal
 # selection range is reset.
 # Previous settings:
 	entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
-	pack .e
+	pack .e ; update idletasks
 	.e insert 0 012345678901234567890
 	.e xview 4
 	update
     .e select from 1
     .e select to 6
@@ -2638,11 +2638,11 @@
 # On mac and pc, when selection is cleared, entry widget remembers
 # last selected range.  When selection ownership is restored to
 # entry, the old range will be rehighlighted.
 # Previous settings:
 	entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
-	pack .e
+	pack .e ; update idletasks
 	.e insert 0 012345678901234567890
 	.e xview 4
 	update
     .e select from 1
     .e select to 6
@@ -2656,11 +2656,11 @@
 } -result 1
 
 test entry-13.12 {GetEntryIndex procedure} -constraints x11 -body {
 # Previous settings:
 	entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
-	pack .e
+	pack .e ; update idletasks
 	.e insert 0 012345678901234567890
 	.e xview 4
 	update
     .e select from 1
     .e select to 6
@@ -2675,11 +2675,11 @@
 # why when string in .e index changed to not beginning with s,
 # it behaves differently?
 test entry-13.12.1 {GetEntryIndex procedure} -constraints unix -body {
 # Previous settings:
 	entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
-	pack .e
+	pack .e ; update idletasks
 	.e insert 0 012345678901234567890
 	.e xview 4
 	update
     .e select from 1
     .e select to 6
@@ -2692,11 +2692,11 @@
 } -returnCodes error -result {bad entry index "bogus"}
 
 test entry-13.13 {GetEntryIndex procedure} -constraints win -body {
 # Previous settings:
 	entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
-	pack .e
+	pack .e ; update idletasks
 	.e insert 0 012345678901234567890
 	.e xview 4
 	update
     .e select from 1
     .e select to 6
@@ -2712,11 +2712,11 @@
 # On mac and pc, when selection is cleared, entry widget remembers
 # last selected range.  When selection ownership is restored to
 # entry, the old range will be rehighlighted.
 # Previous settings:
 	entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
-	pack .e
+	pack .e ; update idletasks
 	.e insert 0 012345678901234567890
 	.e xview 4
 	update
     .e select from 1
     .e select to 6
@@ -2732,11 +2732,11 @@
 # On mac and pc, when selection is cleared, entry widget remembers
 # last selected range.  When selection ownership is restored to
 # entry, the old range will be rehighlighted.
 # Previous settings:
 	entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken
-	pack .e
+	pack .e ; update idletasks
 	.e insert 0 012345678901234567890
 	.e xview 4
 	update
     .e select from 1
     .e select to 6
@@ -2758,11 +2758,11 @@
 } -returnCodes error -result {bad entry index "@xyz"}
 
 test entry-13.16 {GetEntryIndex procedure} -constraints fonts -body {
     entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
         -font {Courier -12}
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e index @4
 } -cleanup {
@@ -2769,11 +2769,11 @@
     destroy .e
 } -result 4
 test entry-13.17 {GetEntryIndex procedure} -constraints fonts -body {
     entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
         -font {Courier -12}
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e index @11
 } -cleanup {
@@ -2780,11 +2780,11 @@
     destroy .e
 } -result 4
 test entry-13.18 {GetEntryIndex procedure} -constraints fonts -body {
     entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
         -font {Courier -12}
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e index @12
 } -cleanup {
@@ -2791,11 +2791,11 @@
     destroy .e
 } -result 5
 test entry-13.19 {GetEntryIndex procedure} -constraints fonts -body {
     entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
         -font {Courier -12}
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e index @[expr {[winfo width .e] - 6}]
 } -cleanup {
@@ -2802,11 +2802,11 @@
     destroy .e
 } -result 8
 test entry-13.20 {GetEntryIndex procedure} -constraints fonts -body {
     entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
         -font {Courier -12}
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e index @[expr {[winfo width .e] - 5}]
 } -cleanup {
@@ -2813,42 +2813,42 @@
     destroy .e
 } -result 9
 test entry-13.21 {GetEntryIndex procedure} -body {
     entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
         -font {Courier -12}
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e index @1000
 } -cleanup {
     destroy .e
 } -result 9
 test entry-13.22 {GetEntryIndex procedure} -setup {
     entry .e
-    pack .e
+    pack .e ; update idletasks
     update
 } -body {
     .e index 1xyz
 } -cleanup {
     destroy .e
 } -returnCodes error -result {bad entry index "1xyz"}
 test entry-13.23 {GetEntryIndex procedure} -body {
     entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
         -font {Courier -12}
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 012345678901234567890
     .e xview 4
     update
-    .e index -1
+    .e index {}
 } -cleanup {
     destroy .e
 } -result 0
 test entry-13.24 {GetEntryIndex procedure} -body {
     entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
         -font {Courier -12}
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e index 12
 } -cleanup {
@@ -2855,11 +2855,11 @@
     destroy .e
 } -result 12
 test entry-13.25 {GetEntryIndex procedure} -body {
     entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\
         -font {Courier -12}
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 012345678901234567890
     .e xview 4
     update
     .e index 49
 } -cleanup {
@@ -2868,11 +2868,11 @@
 test entry-13.26 {GetEntryIndex procedure} -constraints fonts -body {
     entry .e -highlightthickness 2 -bd 2 -font {Helvetica -12}
     selection clear .e
     .e configure -show .
     .e insert 0 XXXYZZY
-    pack .e
+    pack .e ; update idletasks
     update
     list [.e index @7] [.e index @8]
 } -cleanup {
     destroy .e
 } -result {0 1}
@@ -2928,11 +2928,11 @@
 } -result {Text Text}
 
 # is scrollcommand needed here??
 test entry-16.1 {EntryVisibleRange procedure} -constraints fonts  -body {
     entry .e -width 10 -font {Helvetica -12}
-    pack .e
+    pack .e ; update idletasks
     update
     .e insert 0 "............................."
     format {%.6f %.6f} {*}[.e xview]
 } -cleanup {
     destroy .e
@@ -2939,11 +2939,11 @@
 } -result {0.000000 0.827586}
 test entry-16.2 {EntryVisibleRange procedure} -constraints {
     unix fonts
 } -body {
     entry .e -show X -width 10  -font {Helvetica -12}
-    pack .e
+    pack .e ; update idletasks
     update
     .e insert 0 "............................."
     format {%.6f %.6f} {*}[.e xview]
 } -cleanup {
     destroy .e
@@ -2950,11 +2950,11 @@
 } -result {0.000000 0.275862}
 test entry-16.3 {EntryVisibleRange procedure} -constraints {
     win
 } -body {
     entry .e -show . -width 10  -font {Helvetica -12}
-	pack .e
+	pack .e ; update idletasks
     update
     .e insert 0 XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     format {%.6f %.6f} {*}[.e xview]
 } -cleanup {
     destroy .e
@@ -2967,11 +2967,11 @@
 } -result {0.000000 1.000000}
 
 
 test entry-17.1 {EntryUpdateScrollbar procedure} -body {
     entry .e -width 10 -xscrollcommand scroll -font {Courier -12}
-    pack .e
+    pack .e ; update idletasks
     update idletasks
     set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
     .e delete 0 end
     .e insert 0 123
     vwait scrollInfo
@@ -2980,11 +2980,11 @@
     destroy .e
     after cancel $timeout
 } -result {0.000000 1.000000}
 test entry-17.2 {EntryUpdateScrollbar procedure} -body {
     entry .e -width 10 -xscrollcommand scroll -font {Courier -12}
-    pack .e
+    pack .e ; update idletasks
     set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
     .e insert 0 0123456789abcdef
     .e xview 3
     vwait scrollInfo
     format {%.6f %.6f} {*}$scrollInfo
@@ -2992,11 +2992,12 @@
     destroy .e
     after cancel $timeout
 } -result {0.187500 0.812500}
 test entry-17.3 {EntryUpdateScrollbar procedure} -body {
     entry .e -width 10 -xscrollcommand scroll -font {Courier -12}
-    pack .e
+    pack .e ; update idletasks
+    update idletasks
     set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
     .e insert 0 abcdefghijklmnopqrs
     .e xview 6
     vwait scrollInfo
     format {%.6f %.6f} {*}$scrollInfo
@@ -3009,11 +3010,11 @@
 	global x
 	set x $msg
 }
 } -body {
     entry .e -width 5
-    pack .e
+    pack .e ; update idletasks
     update idletasks
     .e configure -xscrollcommand thisisnotacommand
     vwait x
     list $x $errorInfo
 } -cleanup {
@@ -3052,11 +3053,11 @@
     entry .e -validate all \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 a
     set ::vVals
 } -cleanup {
     destroy .e
 } -result {.e 1 0 a {} a all key}
@@ -3067,11 +3068,11 @@
     entry .e -validate all \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 a   ;# previous settings
     .e insert 1 b
     return $::vVals
 } -cleanup {
     destroy .e
@@ -3083,11 +3084,11 @@
     entry .e -validate all \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 ab   ;# previous settings
     .e insert end c
     set ::vVals
 } -cleanup {
     destroy .e
@@ -3099,11 +3100,11 @@
     entry .e -validate all \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 abc   ;# previous settings
     .e insert 1 123
     list $::vVals $::e
 } -cleanup {
     destroy .e
@@ -3115,11 +3116,11 @@
     entry .e -validate all \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 a123bc   ;# previous settings
     .e delete 2
     set ::vVals
 } -cleanup {
     destroy .e
@@ -3131,11 +3132,11 @@
     entry .e -validate all \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 a13bc   ;# previous settings
     .e configure -validate key
     .e delete 1 3
     set ::vVals
 } -cleanup {
@@ -3148,11 +3149,11 @@
     entry .e -validate focus \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert end abc                 ;# previous settings
     set ::vVals {}
     .e insert end d
     set ::vVals
 } -cleanup {
@@ -3165,11 +3166,11 @@
     entry .e -validate all \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e configure -validate focus    ;# previous settings
     .e insert end abcd              ;# previous settings
     focus -force .e
 # update necessary to process FocusIn event
     update
@@ -3184,11 +3185,11 @@
     entry .e -validate focus \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert end abcd      ;# previous settings
     focus -force .e         ;# previous settings
     update                  ;# previous settings
 # update necessary to process FocusIn event
     focus -force .
@@ -3205,11 +3206,11 @@
     entry .e -validate all \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert end abcd          ;# previous settings
     focus -force .e
 # update necessary to process FocusIn event
     update
     set ::vVals
@@ -3223,11 +3224,11 @@
     entry .e -validate all \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert end abcd          ;# previous settings
     focus -force .e             ;# previous settings
 # update necessary to process FocusIn event
     update                      ;# previous settings
     focus -force .
@@ -3244,11 +3245,11 @@
     entry .e -validate focusin \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert 0 abcd              ;# previous settings
     focus -force .e
 # update necessary to process FocusIn event
     update
     set ::vVals
@@ -3262,11 +3263,11 @@
     entry .e -validate focusin \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert end abcd              ;# previous settings
     set ::vVals {}
     focus -force .
 # update necessary to process FocusOut event
     update
@@ -3281,11 +3282,11 @@
     entry .e -validate focuso \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert end abcd              ;# previous settings
     set ::vVals {}                  ;# previous settings
     focus -force .e
 # update necessary to process FocusIn event
     update
@@ -3300,11 +3301,11 @@
     entry .e -validate focuso \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert end abcd              ;# previous settings
     set ::vVals {}                  ;# previous settings
     focus -force .e                 ;# previous settings
 # update necessary to process FocusIn event
     update                          ;# previous settings
@@ -3323,11 +3324,11 @@
     entry .e -validate focuso \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert end abcd              ;# previous settings
     set ::vVals {}                  ;# previous settings
     focus -force .e                 ;# previous settings
 # update necessary to process FocusIn event
     update                          ;# previous settings
@@ -3346,11 +3347,11 @@
     entry .e -validate focuso \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     .e insert end abcd              ;# previous settings
     set ::e newdata
     list [.e cget -validate] $::vVals
 } -cleanup {
     destroy .e
@@ -3364,11 +3365,11 @@
     entry .e -validate all \
         -validatecommand [list doval3 %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     set ::e newdata                 ;# previous settings
     .e configure -validate all
     set ::e nextdata
     list [.e cget -validate] $::vVals
 } -cleanup {
@@ -3384,11 +3385,11 @@
     entry .e -validate all \
         -validatecommand [list doval3 %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     set ::e nextdata                 ;# previous settings
 
     .e configure -validatecommand [list doval2 %W %d %i %P %s %S %v %V]
     .e validate
     list [.e cget -validate] [.e get] $::vVals
@@ -3407,11 +3408,11 @@
     entry .e -validate all \
         -validatecommand [list doval %W %d %i %P %s %S %v %V] \
         -invalidcommand bell \
         -textvariable ::e \
         -background red -foreground white
-    pack .e
+    pack .e ; update idletasks
     set ::e nextdata                 ;# previous settings
     .e configure -validatecommand [list doval2 %W %d %i %P %s %S %v %V] ;# prev
     .e validate                     ;# previous settings
 
     .e configure -validate all
@@ -3430,11 +3431,11 @@
     unset -nocomplain ::e ::vVals
 } -body {
     entry .e -validate key \
         -validatecommand [list doval2 %W %d %i %P %s %S %v %V] \
         -textvariable ::e
-    pack .e
+    pack .e ; update idletasks
     set ::e origdata
     .e insert 0 A
     list [.e cget -validate] [.e get] $::e $::vVals
 } -cleanup {
     destroy .e
@@ -3504,11 +3505,11 @@
 
 test entry-20.7 {widget deletion with textvariable active} -body {
 # SF bugs 607390 and 617446
     set FOO init
     entry .e -textvariable FOO -validate all \
-	    -vcmd {%W configure -bg white; format 1}
+	    -validatecommand {%W configure -bg white; format 1}
     bind .e <Destroy> { set FOO hello }
     destroy .e
     winfo exists .e
 } -cleanup {
     destroy .e

Index: tests/event.test
==================================================================
--- tests/event.test
+++ tests/event.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test the code in tkEvent.c.  It is
 # organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1995 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
@@ -18,61 +18,14 @@
 # Setup table used to query key events.
 
 proc _init_keypress_lookup {} {
     global keypress_lookup
 
-    scan A %c start
-    scan Z %c finish
-
-    for {set i $start} {$i <= $finish} {incr i} {
-        set l [format %c $i]
-        set keypress_lookup($l) $l
-    }
-
-    scan a %c start
-    scan z %c finish
-
-    for {set i $start} {$i <= $finish} {incr i} {
-        set l [format %c $i]
-        set keypress_lookup($l) $l
-    }
-
-    scan 0 %c start
-    scan 9 %c finish
-
-    for {set i $start} {$i <= $finish} {incr i} {
-        set l [format %c $i]
-        set keypress_lookup($l) $l
-    }
-
-    # Most punctuation
-    array set keypress_lookup {
-        ! exclam
-        % percent
-        & ampersand
-        ( parenleft
-        ) parenright
-        * asterisk
-        + plus
-        , comma
-        - minus
-        . period
-        / slash
-        : colon
-        < less
-        = equal
-        > greater
-        ? question
-        @ at
-        ^ asciicircum
-        _ underscore
-        | bar
-        ~ asciitilde
-        ' apostrophe
-    }
     # Characters with meaning to Tcl...
     array set keypress_lookup [list \
+	    -    minus \
+	    >    greater \
 	    \"   quotedbl \
 	    \#   numbersign \
 	    \$   dollar \
 	    \;   semicolon \
 	    \[   bracketleft \
@@ -79,19 +32,20 @@
 	    \\   backslash \
 	    \]   bracketright \
 	    \{   braceleft \
 	    \}   braceright \
 	    " "  space \
+	    \xA0 nobreakspace \
 	    "\n" Return \
 	    "\t" Tab]
 }
 
 # Lookup an event in the keypress table.
 # For example:
 # Q -> Q
-# . -> period
-# / -> slash
+# ; -> semicolon
+# > -> greater
 # Delete -> Delete
 # Escape -> Escape
 
 proc _keypress_lookup {char} {
     global keypress_lookup
@@ -754,10 +708,11 @@
     lappend result [_get_selection $e]
 
     return $result
 } -cleanup {
     deleteWindows
+    unset x1 y1 width height middle_y left_x left_y right_x right_y
 } -result {1.3 A 1.3 A}
 test event-7.2(double-click) {A double click on a lone character
     in an entry widget should select that character} -setup {
 	deleteWindows
 } -body {
@@ -820,10 +775,11 @@
     lappend result [_get_selection $e]
 
     return $result
 } -cleanup {
     deleteWindows
+    unset x1 y1 width height middle_y left_x left_y right_x right_y
 } -result {4 A 4 A}
 
 test event-8 {event generate with keysyms corresponding to
               multi-byte virtual keycodes - bug
               e36963bfe8df9f5e528134707a91b9c0051de723} -constraints nonPortable -setup {
@@ -856,10 +812,97 @@
                 physical key - in this case, test is actually void."
     }
 } -cleanup {
     deleteWindows
 } -result {OK}
+
+test event-9 {no <Enter> event is generated for the container window when its
+              managed window in which the mouse pointer was inside gets
+              destroyed - bug 9e1312f32c} -setup {
+    set res [list ]
+    set iconified false
+    if {[winfo ismapped .]} {
+        wm iconify .
+        update
+        set iconified true
+    }
+} -body {
+    toplevel .top
+    pack propagate .top 0
+    bind .top <Enter> {lappend res %W}
+    pack [frame .top.f -bg green -width 50 -height 50] -anchor se -side bottom
+    tkwait visibility .top.f
+    after 50
+    update
+    focus -force .top.f
+    event generate .top.f <Motion> -warp 1 -x 25 -y 25  ; # <Enter> sent to .top and .top.f
+    controlPointerWarpTiming
+    update  ; # idletasks not enough
+    destroy .top.f  ; # no <Enter> event sent
+    update
+    set res
+} -cleanup {
+    deleteWindows
+    if {$iconified} {
+        wm deiconify .
+        update
+    }
+} -result {.top .top.f}
+
+test event-9.1 {enter . window by destroying a toplevel - bug b1d115fa60} -setup {
+    set EnterBind [bind . <Enter>]
+} -body {
+    wm geometry . 200x200+300+300
+    wm deiconify .
+    _pause 200
+    toplevel .top2 -width 200 -height 200
+    wm geometry .top2 +[expr {[winfo rootx .]+50}]+[expr {[winfo rooty .]+50}]
+    wm deiconify .top2
+    raise .top2
+    _pause 400
+    event generate .top2 <Motion> -warp 1 -x 50 -y 50
+    _pause 100
+    bind . <Enter> {lappend res %W}
+    set res [list ]
+    destroy .top2
+    _pause 200
+    set res
+} -cleanup {
+    deleteWindows
+    bind . <Enter> $EnterBind
+} -result {.}
+test event-9.2 {enter toplevel window by destroying a toplevel - bug b1d115fa60} -setup {
+    set iconified false
+    if {[winfo ismapped .]} {
+        wm iconify .
+        update
+        set iconified true
+    }
+} -body {
+    toplevel .top1
+    wm geometry .top1 200x200+300+300
+    wm deiconify .top1
+    _pause 200
+    toplevel .top2 -width 200 -height 200
+    wm geometry .top2 +[expr {[winfo rootx .top1]+50}]+[expr {[winfo rooty .top1]+50}]
+    wm deiconify .top2
+    raise .top2
+    _pause 400
+    event generate .top2 <Motion> -warp 1 -x 50 -y 50
+    _pause 100
+    bind .top1 <Enter> {lappend res %W}
+    set res [list ]
+    destroy .top2
+    _pause 200
+    set res
+} -cleanup {
+    deleteWindows ; # destroy all children of ".", this already includes .top1
+    if {$iconified} {
+        wm deiconify .
+        update
+    }
+} -result {.top1}
 
 # cleanup
 update
 unset -nocomplain keypress_lookup
 rename _init_keypress_lookup {}

Index: tests/filebox.test
==================================================================
--- tests/filebox.test
+++ tests/filebox.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out Tk's "tk_getOpenFile" and
 # "tk_getSaveFile" commands. It is organized in the standard fashion
 # for Tcl tests.
 #
 # Copyright © 1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
@@ -72,11 +72,10 @@
     update
     SendButtonPress $parent ok mouse
 }
 
 proc SendButtonPress {parent btn type} {
-    global tk_strictMotif
     if {$parent == "."} {
 	set w .__tk_filedialog
     } else {
 	set w $parent.__tk_filedialog
     }
@@ -109,13 +108,13 @@
 } else {
     set modes 1
 }
 
 set unknownOptionsMsg(tk_getOpenFile,notAqua) {bad option "-foo": must be -defaultextension, -filetypes, -initialdir, -initialfile, -multiple, -parent, -title, or -typevariable}
-set unknownOptionsMsg(tk_getOpenFile,aqua) {bad option "-foo": must be -defaultextension, -filetypes, -initialdir, -initialfile, -message, -multiple, -parent, -title, -typevariable, or -command}
+set unknownOptionsMsg(tk_getOpenFile,aqua) {bad option "-foo": must be -command, -defaultextension, -filetypes, -initialdir, -initialfile, -message, -multiple, -parent, -title, or -typevariable}
 set unknownOptionsMsg(tk_getSaveFile,notAqua) {bad option "-foo": must be -confirmoverwrite, -defaultextension, -filetypes, -initialdir, -initialfile, -parent, -title, or -typevariable}
-set unknownOptionsMsg(tk_getSaveFile,aqua) {bad option "-foo": must be -defaultextension, -filetypes, -initialdir, -initialfile, -message, -parent, -title, -typevariable, -command, or -confirmoverwrite}
+set unknownOptionsMsg(tk_getSaveFile,aqua) {bad option "-foo": must be -command, -confirmoverwrite, -defaultextension, -filetypes, -initialdir, -initialfile, -message, -parent, -title, or -typevariable}
 
 set tmpFile "filebox.tmp"
 makeFile {
     # this file can be empty!
 } $tmpFile
@@ -208,11 +207,10 @@
     # set verylongstring $verylongstring$verylongstring
     # set verylongstring $verylongstring$verylongstring
     # set verylongstring $verylongstring$verylongstring
     # set verylongstring $verylongstring$verylongstring
 
-    set color #404040
     test filebox-2.1-$mode "tk_getOpenFile command" nonUnixUserInteraction {
         ToPressButton $parent cancel
         tk_getOpenFile -title "Press Cancel ($verylongstring)" -parent $parent
     } ""
 
@@ -279,13 +277,10 @@
 	set t [expr {$x + [llength [array names filters]]}]
         test filebox-3.$t-$mode "tk_getOpenFile command" nonUnixUserInteraction {
 	    catch {unset tv}
 	    catch {unset typeName}
 	    ToPressButton $parent ok
-	    if {[info exists tv]} {
-	    } else {
-	    }
 	    set choice [tk_getOpenFile -title "Press Ok" \
 		    -filetypes $filters($x) -parent $parent \
 		    -initialfile $fileName -initialdir $fileDir \
 		    -typevariable tv]
 	    if {[info exists tv]} {
@@ -335,24 +330,10 @@
     set isNative [expr {
 	[info commands ::tk::MotifFDialog] eq "" &&
 	[info commands ::tk::dialog::file::] eq ""
     }]
 
-    set parent .
-
-    set verylongstring longstring:
-    set verylongstring $verylongstring$verylongstring
-    set verylongstring $verylongstring$verylongstring
-    set verylongstring $verylongstring$verylongstring
-    set verylongstring $verylongstring$verylongstring
-    # set verylongstring $verylongstring$verylongstring
-    # set verylongstring $verylongstring$verylongstring
-    # set verylongstring $verylongstring$verylongstring
-    # set verylongstring $verylongstring$verylongstring
-    # set verylongstring $verylongstring$verylongstring
-
-    set color #404040
     test filebox-5.1-$mode "tk_getSaveFile command" nonUnixUserInteraction {
 	ToPressButton $parent cancel
 	tk_getSaveFile -title "Press Cancel ($verylongstring)" -parent $parent
     } ""
 

Index: tests/focus.test
==================================================================
--- tests/focus.test
+++ tests/focus.test
@@ -1,19 +1,19 @@
 # This file is a Tcl script to test out the "focus" command and the
 # other procedures in the file tkFocus.c.  It is organized in the
 # standard fashion for Tcl tests.
 #
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 namespace import -force tcltest::test
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 proc focusSetup {} {
     destroy .t
     toplevel .t

Index: tests/focusTcl.test
==================================================================
--- tests/focusTcl.test
+++ tests/focusTcl.test
@@ -2,11 +2,11 @@
 # file focus.tcl, which includes the procedures tk_focusNext and
 # tk_focusPrev, among other things.  This file is organized in the
 # standard fashion for Tcl tests.
 #
 # Copyright © 1995 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands

Index: tests/font.test
==================================================================
--- tests/font.test
+++ tests/font.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out Tk's "font" command
 # plus the procedures in tkFont.c.  It is organized in the
 # standard white-box fashion for Tcl tests.
 #
 # Copyright © 1996-1998 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -12,11 +12,11 @@
 tcltest::loadTestedCommands
 
 # Some tests require support for 4-byte UTF-8 sequences
 testConstraint fullutf [expr {[format %c 0x010000] != "\uFFFD"}]
 testConstraint utfcompat [expr {([string length "\U10000"] == 2) && [package vsatisfies [package provide Tcl] 8]}]
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnUbuntuNoXft [expr {[testConstraint failsOnUbuntu] || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))}]
 
 set defaultfontlist [font names]
 
 proc getnondefaultfonts {} {
@@ -154,17 +154,17 @@
     font actual {-family times} -- \uD800
 } -match glob -result {*}
 test font-4.13 {font command: actual} -body {
     font actual {-family times} -- \uDC00
 } -match glob -result {*}
-test font-4.14 {font command: actual} -constraints {utfcompat win} -body {
+test font-4.14 {font command: actual} -constraints {utfcompat win knownBug} -body {
     font actual {-family times} -family -- \uD800\uDC00
 } -result {times}
 test font-4.15 {font command: actual} -body {
     font actual {-family times} -- \uDC00\uD800
 } -returnCodes 1 -match glob -result {expected a single character but got "*"}
-test font-4.16 {font command: actual} -constraints {fullutf win} -body {
+test font-4.16 {font command: actual} -constraints {fullutf win knownBug} -body {
     font actual {-family times} -family -- \U10000
 } -result {times}
 
 
 test font-5.1 {font command: configure} -body {
@@ -438,11 +438,11 @@
     font metrics xyz abc def
 } -returnCodes error -result {wrong # args: should be "font metrics font ?-displayof window? ?-option?"}
 test font-10.5 {font command: metrics: arguments} -body {
     # (objc - skip) > 4) when skip == 2
     font metrics xyz -displayof . abc
-} -returnCodes error -result {bad metric "abc": must be -ascent, -descent, -linespace, or -fixed}
+} -returnCodes error -result {bad metric "abc": must be -ascent, -descent, -fixed, or -linespace}
 test font-10.6 {font command: metrics: bad font} -constraints noExceed -body {
     # (tkfont == NULL)
     font metrics "\{xyz"
 } -returnCodes error -result "font \"{xyz\" doesn't exist"
 test font-10.7 {font command: metrics: get all metrics} -setup {
@@ -455,11 +455,11 @@
     unset a
 } -result {-ascent -descent -fixed -linespace}
 test font-10.8 {font command: metrics: bad metric} -body {
     # (Tcl_GetIndexFromObj() != TCL_OK)
     font metrics $fixed -xyz
-} -returnCodes error -result {bad metric "-xyz": must be -ascent, -descent, -linespace, or -fixed}
+} -returnCodes error -result {bad metric "-xyz": must be -ascent, -descent, -fixed, or -linespace}
 test font-10.9 {font command: metrics: get individual metrics} -body {
     font metrics $fixed -ascent
     font metrics $fixed -descent
     font metrics $fixed -linespace
     font metrics $fixed -fixed
@@ -521,20 +521,20 @@
 } -result {}
 test font-12.2 {UpdateDependantFonts procedure: pings the widgets} -setup {
     destroy .t.f
     catch {font delete xyz}
     pack [label .t.f]
-    update
+    update idletasks
 } -body {
     font create xyz -family times -size 20
     .t.f config -font xyz -text "abcd" -padx 0 -bd 0 -highlightthickness 0
     set a1 [font measure xyz "abcd"]
-    update
+    update idletasks
     set b1 [winfo reqwidth .t.f]
     font configure xyz -family helvetica -size 20
     set a2 [font measure xyz "abcd"]
-    update
+    update idletasks
     set b2 [winfo reqwidth .t.f]
     expr {$a1==$b1 && $a2==$b2}
 } -cleanup {
     destroy .t.f
     font delete xyz
@@ -1681,18 +1681,18 @@
 #  Label used in 27.* tests
 destroy .t.f
 pack [label .t.f]
 update
 test font-27.1 {Tk_UnderlineTextLayout procedure: no underline chosen} -body {
-    .t.f config -text "foo" -underline -1
+    .t.f config -text "foo" -underline {}
 } -result {}
 test font-27.2 {Tk_UnderlineTextLayout procedure: underline not visible} -body {
     .t.f config -text "000          00000" -wrap [expr $ax*7] -under 10
 } -result {}
 test font-27.3 {Tk_UnderlineTextLayout procedure: underline is visible} -body {
     .t.f config -text "000          00000" -wrap [expr $ax*7] -under 5
-    .t.f config -wrap -1 -underline -1
+    .t.f config -wrap -1 -underline {}
 } -result {}
 destroy .t.f
 
 
 
@@ -1763,11 +1763,11 @@
 #  Label used in 29.* tests
 destroy .t.f
 pack [label .t.f]
 update
 test font-29.1 {Tk_CharBBox procedure: index < 0} -body {
-    .t.f config -text "000" -underline -1
+    .t.f config -text "000" -underline {}
 } -result {}
 test font-29.2 {Tk_CharBBox procedure: loop} -body {
     .t.f config -text "000\t000\t000\t000" -underline 9
 } -result {}
 test font-29.3 {Tk_CharBBox procedure: special char} -body {
@@ -2338,11 +2338,11 @@
     font actual -xyz-?-*-*-*-*-*-*-*-*-*-*-*-*
     lindex [font actual -xyz-times-*-*-*-*-*-*-*-*-*-*-*-*] 1
 } -result [font actual {times 0} -family]
 
 
-test font-44.1 {TkFontGetPixels: size < 0} -constraints failsOnUbuntuNoXft -setup {
+test font-44.1 {TkFontGetPixels: size < 0} -constraints failsOnUbuntu -setup {
     set oldscale [tk scaling]
 } -body {
     tk scaling 0.5
     font actual {times -12} -size
 } -cleanup {
@@ -2362,11 +2362,11 @@
     font actual {snarky 10} -family
 } -result [font actual {-size 10} -family]
 test font-45.2 {TkFontGetAliasList: match} -constraints win -body {
     font actual {times 10} -family
 } -result {times}
-test font-45.3 {TkFontGetAliasList: match} -constraints {noExceed} -body {
+test font-45.3 {TkFontGetAliasList: match} -constraints {noExceed failsOnUbuntu} -body {
     if {[font actual {{times new roman} 10} -family] eq "Times New Roman"} {
         # avoid test failure on systems that have a real "times new roman" font
         set res 1
     } else {
         set res [expr {[font actual {{times new roman} 10} -family] eq \
@@ -2405,13 +2405,154 @@
     one eval menu .menubar
     two eval menu .menubar
     interp delete one
     interp delete two
 } -result {}
+
+test font-47.2 {Bug 3049518 - Canvas} -body {
+    if {"MyFont" ni [font names]} {
+	font create MyFont -family "Liberation Sans" -size 13
+    }
+    set text Hello!
+    destroy .t.c
+    set c [canvas .t.c]
+    set textid [$c create text 20 20 -font MyFont -text $text -anchor nw]
+    set twidth [font measure MyFont $text]
+    set theight [font metrics MyFont -linespace]
+    set circid [$c create polygon \
+		    15                    15 \
+		    [expr {15 + $twidth}] 15 \
+		    [expr {15 + $twidth}] [expr {15 + $theight}] \
+		    15                    [expr {15 + $theight}] \
+		    -width 1 -joinstyle round -smooth true -fill {} -outline blue]
+    pack $c -fill both -expand 1 -side top
+    tkwait visibility $c
+
+    # Lamda test functions
+    set circle_text {{w user_data text circ} {
+	if {[winfo class $w] ne "Canvas"} {
+	    puts "Wrong widget type: $w"
+	    return
+	}
+	if {$user_data ne "FontChanged"} {
+	    return
+	}
+	lappend ::results called-$w
+	lassign [$w bbox $text] x0 y0 x1 y1
+	set offset 5
+	set coord [lmap expr {
+			      $x0-5 $y0-5   $x1+5 $y0-5
+			      $x1+5 $y1+5   $x0-5 $y1+5
+			  } {expr $expr}]
+	if {[catch {$w coord $circ $coord} err]} {
+	    puts Error:$err
+	}
+    }}
+    set waitfor {{tag {time 333}} {after $time incr ::wait4; vwait ::wait4}}
+    set enclosed {{can id} {$can find enclosed {*}[$can bbox $id]}}
+
+    set results {}
+    apply $circle_text $c FontChanged $textid $circid
+    bind $c <<TkWorldChanged>> [list apply $circle_text %W %d $textid $circid]
+    apply $waitfor 1
+
+    # Begin test:
+    set results {}
+    lappend results [apply $enclosed $c $circid]
+    font configure MyFont -size 26
+    apply $waitfor 2
+    lappend results [apply $enclosed $c $circid]
+    font configure MyFont -size 9
+    apply $waitfor 3
+    lappend results [apply $enclosed $c $circid]
+    apply $waitfor 4
+    font configure MyFont -size 12
+    apply $waitfor 5
+    lappend results [apply $enclosed $c $circid]
+} -cleanup {
+    destroy $c
+    unset -nocomplain ::results
+} -result {{1 2} called-.t.c {1 2} called-.t.c {1 2} called-.t.c {1 2}}
+
+test font-47.3 {Bug 3049518 - Label} -body {
+    if {"MyFont" ni [font names]} {
+	font create MyFont -family "Liberation Sans" -size 13
+    }
+    set text "Label Test"
+    destroy .t.l
+
+    set make-img {{size} {
+	set img [image create photo -width $size -height $size]
+	$img blank
+	set max [expr {$size - 1}]
+	for {set x 0} {$x < $size} {incr x} {
+	    $img put red -to $x $x
+	    $img put black -to 0 $x
+	    $img put black -to $x 0
+	    $img put black -to $max $x
+	    $img put black -to $x $max
+	}
+	return $img
+    }}
+
+    set testWorldChanged {{w user_data} {
+	global make-img
+	if {$user_data ne "FontChanged"} {
+	    return
+	}
+	if {![winfo exists $w] || [winfo class $w] ne "Label"} {
+	    return
+	}
+	if {[$w cget -image] ne ""} {
+	    image delete [$w cget -image]
+	}
+	set size [font metrics [$w cget -font] -linespace]
+	set img [apply ${make-img} $size]
+	$w configure -image $img
+    }}
+
+    set waitfor {{tag {time 500}} {
+	after $time incr ::wait4
+	vwait ::wait4
+    }}
+
+    set check {{w} {
+	global results
+	set f [$w cget -font]
+	set i [$w cget -image]
+	set fs [font metrics $f -linespace]
+	set ish [image height $i]
+	set isw [image width $i]
+	lappend results [list [expr {$fs == $ish ? 1 : [list $fs $ish]}] [expr {$fs == $isw ? 1 : [list $fs $isw]}]]
+    }}
+
+    set size [font metrics MyFont -linespace]
+    set img [apply ${make-img} $size]
+    set l [label .t.l -compound left -image $img -text $text -font MyFont]
+    pack $l -side top -fill both -expand 1
+    bind $l <<TkWorldChanged>> [list apply $testWorldChanged %W %d]
+    set ::results {}
+
+    apply $waitfor 0
+    apply $check $l
+    font configure MyFont -size 26
+    apply $waitfor 1
+    apply $check $l
+    font configure MyFont -size 9
+    apply $waitfor 2
+    apply $check $l
+    font configure MyFont -size 13
+    apply $waitfor 3
+    apply $check $l
+    set results
+} -cleanup {
+    destroy $l
+    unset -nocomplain ::results
+} -result {{1 1} {1 1} {1 1} {1 1}}
 
 # cleanup
 cleanupTests
 return
 
 
 
 

Index: tests/fontchooser.test
==================================================================
--- tests/fontchooser.test
+++ tests/fontchooser.test
@@ -4,16 +4,16 @@
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnUbuntuNoXft [expr {[testConstraint failsOnUbuntu] || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))}]
 
 # the following helper functions are related to the functions used
 # in winDialog.test where they are used to send messages to the win32
-# dialog (hence the wierdness).
+# dialog (hence the weirdness).
 
 proc start {cmd} {
     set ::tk_dialog {}
     set ::iter_after 0
     after 1 $cmd
@@ -190,10 +190,16 @@
     then {
         Click ok
     }
     lrange $::testfont 1 end
 } -result {14 bold}
+
+test fontchooser-5.1 {fontchooser multiple configure} -constraints {scriptImpl} -body {
+    tk fontchooser configure -title TestTitle -command foo
+    tk fontchooser configure -command bar
+    tk fontchooser configure -title
+} -result {TestTitle}
 
 # -------------------------------------------------------------------------
 
 cleanupTests
 return

Index: tests/frame.test
==================================================================
--- tests/frame.test
+++ tests/frame.test
@@ -2,11 +2,11 @@
 # "toplevel" commands of Tk.  It is organized in the standard fashion for Tcl
 # tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 tcltest::configure {*}$argv

Index: tests/geometry.test
==================================================================
--- tests/geometry.test
+++ tests/geometry.test
@@ -2,11 +2,11 @@
 # tkGeometry.c (generic support for geometry managers).  It is
 # organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 proc getsize w {
     regexp {(^[^+-]*)} [wm geometry $w] foo x
     return $x

Index: tests/get.test
==================================================================
--- tests/get.test
+++ tests/get.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out the procedures in the file
 # tkGet.c.  It is organized in the standard fashion for Tcl
 # white-box tests.
 #
 # Copyright © 1998 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands

Index: tests/grab.test
==================================================================
--- tests/grab.test
+++ tests/grab.test
@@ -2,11 +2,11 @@
 #
 # This file contains a collection of tests for one or more of the Tk
 # built-in commands.  Sourcing this file runs the tests and
 # generates output for errors.  No output means no errors were found.
 #
-# Copyright © 1998-2000 by Ajuba Solutions.
+# Copyright © 1998-2000 Ajuba Solutions.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands

Index: tests/grid.test
==================================================================
--- tests/grid.test
+++ tests/grid.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test out the *NEW* "grid" command of Tk. It is
 # (almost) organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands

Index: tests/image.test
==================================================================
--- tests/image.test
+++ tests/image.test
@@ -2,11 +2,11 @@
 # other procedures in the file tkImage.c.  It is organized in the
 # standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv

Index: tests/imgBmap.test
==================================================================
--- tests/imgBmap.test
+++ tests/imgBmap.test
@@ -2,11 +2,11 @@
 # the procedures in the file tkImgBmap.c).  It is organized in the
 # standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1995 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -219,11 +219,11 @@
 
 
 test imageBmap-5.1 {GetBitmapData procedure} -body {
     list [catch {image create bitmap -file ~bad_user/a/b} msg] \
 	    [string tolower $msg]
-} -result {1 {user "bad_user" doesn't exist}}
+} -result {1 {couldn't read bitmap file "~bad_user/a/b": no such file or directory}}
 test imageBmap-5.2 {GetBitmapData procedure} -body {
     list [catch {image create bitmap -file bad_name} msg] [string tolower $msg]
 } -result {1 {couldn't read bitmap file "bad_name": no such file or directory}}
 test imageBmap-5.3 {GetBitmapData procedure} -setup {imageCleanup} -body {
     image create bitmap -data { }

Index: tests/imgPNG.test
==================================================================
--- tests/imgPNG.test
+++ tests/imgPNG.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out the code in tkImgFmtPNG.c, which reads
 # and write PNG-format image files for photo widgets. The files is organized
 # in the standard fashion for Tcl tests.
 #
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # Copyright © 1998 Willem van Schaik (images only)
 # Copyright © 2008 Donal K. Fellows
 # All rights reserved.
 
 package require tcltest 2.2
@@ -1054,11 +1054,14 @@
 0dt3Gzx47dvzRUnHNQ8Cf2yQZE7mg+XtslqVWi5XocjlDu7K0pgS+dfbs2V8tFotPlUqlr+ZyuXNO+
 duFtaSrZF3pfCpiGjN2imToJJ39m6BjG1XZRwrkAI8YUKSZWlEZQDAIrNArHnyvpXtmM/B7wJeAbwO
 fBcxKuQMrzfLdBoz29fX9led5v6u1XnBJW7vnr/YlrXEoNo22LRYOYlxZ1S6rkOfDcLvPAY/hGmWC7
 H68uFI+x0oSPg2MAN/L5/M/vtqSED/T5cMu9J4Wf7HMGsB/4TEv/DFwe3Y/NPN57VXh+5BWApwFLlh
 r661tV1eju/ne8YJrkWtES0tmRe2VOviv2j2aBp5nHihiRaz/A4oCnsAsje/+AAAAAElFTkSuQmCC"
-    }
+    dpi100aspect2
+"iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAACXBIWXMAAA9hAAAewgEw8YEEAAAA
+FklEQVR4nGP4+vXrP11lJgYGhj9xSQAzOwXsETZ69QAAAABJRU5ErkJggg=="
+	}
 
 # $encoded(basn0g08), $encoded(basn2c08), $encoded(basn3p08), $encoded(basn6a08)
 test imgPNG-1.1 {reading basic images; grayscale} -setup {
     catch {rename foo ""}
 } -body {
@@ -1112,16 +1115,61 @@
     # it's an ancillary chunk that shall not trigger an error
     catch {set i [image create photo -file $fileName]}
 } -cleanup {
     image delete $i
 } -result 0
-
+
+test imgPNG-4.1 {data image with metadata} -body {
+    image create photo i1 -data $encoded(dpi100aspect2)
+    i1 cget -metadata
+} -cleanup {
+    image delete i1
+} -result {DPI 99.9998 aspect 2.0}
+
+test imgPNG-4.2 {file image with metadata} -setup {
+    set path [file join [configure -tmpdir] test.png]
+    set h [open $path "WRONLY BINARY CREAT"]
+    puts -nonewline $h [binary decode base64 $encoded(dpi100aspect2)]
+    close $h
+} -body {
+    image create photo i1 -file $path
+    i1 cget -metadata
+} -cleanup {
+    image delete i1
+    file delete $path
+} -result {DPI 99.9998 aspect 2.0}
+
+test imgPNG-4.3 {data output with metadata} -setup {
+    image create photo i1 -data $encoded(dpi100aspect2)
+} -body {
+    set imgData [i1 data -format png]
+    image delete i1
+    image create photo i1 -data $imgData
+    i1 cget -metadata
+} -cleanup {
+    image delete i1
+} -result {DPI 99.9998 aspect 2.0}
+
+test imgPNG-4.4 {file output with metadata} -setup {
+    image create photo i1 -data $encoded(dpi100aspect2)
+    set path [file join [configure -tmpdir] test.png]
+} -body {
+    i1 write $path -format png
+    image delete i1
+    image create photo i1 -file $path
+    i1 cget -metadata
+} -cleanup {
+    image delete i1
+    file delete $path
+} -result {DPI 99.9998 aspect 2.0}
+
 }
+
 namespace delete png
 imageFinish
 cleanupTests
 return
 
 # Local Variables:
 # mode: tcl
 # fill-column: 78
 # End:

Index: tests/imgPPM.test
==================================================================
--- tests/imgPPM.test
+++ tests/imgPPM.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out the code in tkImgFmtPPM.c,
 # which reads and write PPM-format image files for photo widgets.
 # The files is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv

Index: tests/imgPhoto.test
==================================================================
--- tests/imgPhoto.test
+++ tests/imgPhoto.test
@@ -2,11 +2,11 @@
 # procedures in the file tkImgPhoto.c. It is organized in the standard fashion
 # for Tcl tests.
 #
 # Copyright © 1994 The Australian National University
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # Copyright © 2002-2008 Donal K. Fellows
 # All rights reserved.
 #
 # Author: Paul Mackerras (paulus@cs.anu.edu.au)
 
@@ -55,10 +55,12 @@
 # Tk_PhotoPutZoomedBlock_NoComposite    no tests, probably none needed
 # Tk_PhotoExpand_Panic                  no tests, probably none needed
 # Tk_PhotoPutBlock_Panic                no tests, probably none needed
 # Tk_PhotoPutZoomedBlock_Panic          no tests, probably none needed
 # Tk_PhotoSetSize_Panic                 no tests, probably none needed
+# Tk_PhotoGetMetadata:                  imgPhoto-21.*
+# Tk_PhotoSetMetadata:                  imgPhoto-22.*
 #--------------------------------------------------------------------------
 #
 
 #
 # Some tests are not specific to a function in tkImgPhoto.c. They are:
@@ -194,10 +196,13 @@
     photo1 put {{blue green}}
     photo1 get 1 0 -withalpha
 } -cleanup {
     imageCleanup
 } -result {0 128 0 255}
+test imgPhoto-1.14 {options for photo images - error case} -body {
+    image create photo photo1 -metadata
+} -returnCodes error -result {value for "-metadata" missing}
 
 test imgPhoto-2.1 {ImgPhotoCreate procedure} -setup {
     imageCleanup
 } -body {
     catch {image create photo -blah blah}
@@ -330,11 +335,11 @@
     image create photo photo1
 } -body {
     llength [photo1 configure]
 } -cleanup {
     image delete photo1
-} -result 7
+} -result 8
 test imgPhoto-4.7 {ImgPhotoCmd procedure: configure option} -setup {
     image create photo photo1
 } -body {
     photo1 conf -palette 3/4/2
     photo1 configure -palette
@@ -572,11 +577,11 @@
     image create photo photo1
 } -body {
     photo1 read $teapotPhotoFile -zoom 2
 } -returnCodes error -cleanup {
     image delete photo1
-} -result {unrecognized option "-zoom": must be -format, -from, -shrink, or -to}
+} -result {unrecognized option "-zoom": must be -format, -from, -metadata, -shrink, or -to}
 test imgPhoto-4.32 {ImgPhotoCmd procedure: read option} -setup {
     image create photo photo1
 } -body {
     list [catch {photo1 read bogus} err] [string tolower $err]
 } -cleanup {
@@ -1089,17 +1094,17 @@
 } -body {
     photo1 put yellow -from 0 0 1 1
 } -cleanup {
     imageCleanup
 } -returnCodes error -result \
-    {unrecognized option "-from": must be -format, or -to}
+    {unrecognized option "-from": must be -format, -metadata, or -to}
 test imgPhoto-4.91 {ImgPhotoCmd put: invalid option} -setup {
     image create photo photo1
 } -body {
     photo1 put {{0 1 2 3}} -bogus x
 } -returnCodes error -result \
-    {unrecognized option "-bogus": must be -format, or -to}
+    {unrecognized option "-bogus": must be -format, -metadata, or -to}
 test imgPhoto-4.92 {ImgPhotocmd put: missing data} -setup {
     image create photo photo1
 } -body {
     photo1 put -to 0 0
 } -returnCodes error -result \
@@ -1235,19 +1240,19 @@
 } -body {
     photo1 data -to
 } -cleanup {
     imageCleanup
 } -returnCodes error -result \
-{unrecognized option "-to": must be -background, -format, -from, or -grayscale}
+{unrecognized option "-to": must be -background, -format, -from, -grayscale, or -metadata}
 test imgPhoto-4.105 {ImgPhotoCmd data: invalid option} -setup {
     image create photo photo1
 } -body {
     photo1 data -bogus
 } -cleanup {
     imageCleanup
 } -returnCodes error -result \
-{unrecognized option "-bogus": must be -background, -format, -from, or -grayscale}
+{unrecognized option "-bogus": must be -background, -format, -from, -grayscale, or -metadata}
 test imgPhoto-4.106 {ImgPhotoCmd data: extra arg before options} -setup {
     image create photo photo1
 } -body {
     photo1 data bogus -grayscale
 } -cleanup {
@@ -2071,10 +2076,447 @@
 } -body {
     image create photo gif1 -file $fileName
 } -cleanup {
     catch {image delete gif1}
 } -result gif1
+
+# imgPhoto-21.x : Tk_PhotoGetMetadata
+
+test imgPhoto-21.1 {option -metadata, get configure list} -setup {
+    image create photo photo1 -metadata {dpi 100}
+} -body {
+    photo1 configure -metadata
+} -cleanup {
+    catch {image delete photo1}
+} -result {-metadata {} {} {} {dpi 100}}
+
+test imgPhoto-21.2 {option -metadata, get value} -setup {
+    image create photo photo1 -metadata {dpi 100}
+} -body {
+    photo1 cget -metadata
+} -cleanup {
+    catch {image delete photo1}
+} -result {dpi 100}
+
+test imgPhoto-21.3 {option -metadata, get default value} -setup {
+    image create photo photo1
+} -body {
+    photo1 cget -metadata
+} -cleanup {
+    catch {image delete photo1}
+} -result {}
+
+# imgPhoto-22.x : Tk_PhotoSetMetadata
+
+test imgPhoto-22.1 {option -metadata, set value} -setup {
+    image create photo photo1
+} -body {
+    photo1 configure -metadata {dpi 100}
+    photo1 cget -metadata
+} -cleanup {
+    catch {image delete photo1}
+} -result {dpi 100}
+
+test imgPhoto-22.2 {option -metadata, change value} -setup {
+    image create photo photo1 -metadata {dpi 200}
+} -body {
+    photo1 configure -metadata {dpi 100}
+    photo1 cget -metadata
+} -cleanup {
+    catch {image delete photo1}
+} -result {dpi 100}
+
+test imgPhoto-22.3 {option -metadata, clear value} -setup {
+    image create photo photo1 -metadata {dpi 200}
+} -body {
+    photo1 configure -metadata {}
+    photo1 cget -metadata
+} -cleanup {
+    catch {image delete photo1}
+} -result {}
+
+# 23.x GIF images with metadata
+
+# The following gif core data is used by the following data.
+# N.B. this is the same image as test imgPhoto-18.10
+
+# size 16x16, global color table size: 8
+set gifstart "GIF89a\x10\x00\x10\x00\xc2\x07\x00"
+# color table
+append gifstart "\x00\x00\x00\x33\x33\xff\xff\x33\x33\xff\x33\xff\x33\xff\x33\x33\xff\xff\xff\xff\x33\xff\xff\xff"
+# Graphic control extension: Transparent color index: 7 (not needed here)
+# append gifdata "\x21\xf9\x04\x01\x0a\x00\x07\x00"
+# Image descriptor: 16x16, no local color table
+set gifdata "\x2c\x00\x00\x00\x00\x10\x00\x10\x00\x00"
+# Image data
+append gifdata "\x03\x21\x78\xba\xdc\x2d\x30\x42\x77\xa4\x15\xef\xda\xa5\xb5\xea\xd7\x07\x4a\xe2\x38\x55\xe6\x99\xaa\x6b\x69\x72\x2f\x33\x52\x1d\x65\x37\x09\x00"
+set gifend "\x3b"
+
+test imgPhoto-23.1 {GIF comment before image data (-data)} -setup {
+    set data $::gifstart
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifdata $::gifend
+} -body {
+    image create photo gif1 -data $data
+    gif1 cget -metadata
+} -cleanup {
+    catch {image delete gif1}
+} -result {comment ABCD}
+
+test imgPhoto-23.2 {GIF file comment before image data (-file)} -setup {
+    set data $::gifstart
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifdata $::gifend
+    set path [file join [configure -tmpdir] test.gif]
+    set h [open $path "WRONLY BINARY CREAT"]
+    puts -nonewline $h $data
+    close $h
+} -body {
+    image create photo gif1 -file $path
+    gif1 cget -metadata
+} -cleanup {
+    catch {image delete gif1}
+    file delete $path
+} -result {comment ABCD}
+
+test imgPhoto-23.3 {GIF comment after image data (-data)} -setup {
+    set data $::gifstart
+    append data $::gifdata
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifend
+} -body {
+    image create photo gif1 -data $data
+    gif1 cget -metadata
+} -cleanup {
+    catch {image delete gif1}
+} -result {comment ABCD}
+
+test imgPhoto-23.4 {GIF comment after image data (-file)} -setup {
+    set data $::gifstart
+    append data $::gifdata
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifend
+    set path [file join [configure -tmpdir] test.gif]
+    set h [open $path "WRONLY BINARY CREAT"]
+    puts $h $data
+    close $h
+} -body {
+    image create photo gif1 -file $path
+    gif1 cget -metadata
+} -cleanup {
+    catch {image delete gif1}
+    file delete $path
+} -result {comment ABCD}
+
+test imgPhoto-23.5 {Two GIF comment blocks (-data)} -setup {
+    set data $::gifstart
+    # Append a comment extension block with data "1234"
+    append data "\x21\xfe\x04" "1234" "\x0"
+    append data $::gifdata
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifend
+} -body {
+    image create photo gif1 -data $data
+    gif1 cget -metadata
+} -cleanup {
+    catch {image delete gif1}
+} -result {comment ABCD}
+
+test imgPhoto-23.6 {Two GIF comment blocks (-file)} -setup {
+    set data $::gifstart
+    # Append a comment extension block with data "1234"
+    append data "\x21\xfe\x04" "1234" "\x0"
+    append data $::gifdata
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifend
+    set path [file join [configure -tmpdir] test.gif]
+    set h [open $path "WRONLY BINARY CREAT"]
+    puts $h $data
+    close $h
+} -body {
+    image create photo gif1 -file $path
+    gif1 cget -metadata
+} -cleanup {
+    catch {image delete gif1}
+    file delete $path
+} -result {comment ABCD}
+
+test imgPhoto-23.7 {create: test if shared metadata object is not preserved\
+	(-data)}\
+-setup {
+    set data $::gifstart
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifdata $::gifend
+} -body {
+    set metadataDict [dict create A 1]
+    set metadataDict2 $metadataDict
+    image create photo gif1 -data $data -metadata $metadataDict
+    list [dict get [gif1 cget -metadata]] $metadataDict $metadataDict2
+} -cleanup {
+    catch {image delete gif1}
+} -result {{A 1 comment ABCD} {A 1} {A 1}}
+
+test imgPhoto-23.8 {create: test if shared metadata object is not preserved\
+	(-file)}\
+-setup {
+    set data $::gifstart
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifdata $::gifend
+
+    set path [file join [configure -tmpdir] test.gif]
+    set h [open $path "WRONLY BINARY CREAT"]
+    puts $h $data
+    close $h
+} -body {
+    set metadataDict [dict create A 1]
+    set metadataDict2 $metadataDict
+    image create photo gif1 -file $path -metadata $metadataDict
+    list [dict get [gif1 cget -metadata]] $metadataDict $metadataDict2
+} -cleanup {
+    catch {image delete gif1}
+    file delete $path
+} -result {{A 1 comment ABCD} {A 1} {A 1}}
+
+test imgPhoto-23.9 {configure: test if shared metadata object is not\
+	preserved (empty image, -data)}\
+-setup {
+    set data $::gifstart
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifdata $::gifend
+} -body {
+    image create photo gif1
+    set metadataDict [dict create A 1]
+    set metadataDict2 $metadataDict
+    gif1 configure -data $data -format gif -metadata $metadataDict
+    list [dict get [gif1 cget -metadata]] $metadataDict $metadataDict2
+} -cleanup {
+    catch {image delete gif1}
+} -result {{A 1 comment ABCD} {A 1} {A 1}}
+
+test imgPhoto-23.10 {configure: test if shared metadata object is not preserved\
+	(empty image, -file)}\
+-setup {
+    set data $::gifstart
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifdata $::gifend
+
+    set path [file join [configure -tmpdir] test.gif]
+    set h [open $path "WRONLY BINARY CREAT"]
+    puts $h $data
+    close $h
+} -body {
+    image create photo gif1
+    set metadataDict [dict create A 1]
+    set metadataDict2 $metadataDict
+    gif1 configure -file $path -format gif -metadata $metadataDict
+    list [dict get [gif1 cget -metadata]] $metadataDict $metadataDict2
+} -cleanup {
+    catch {image delete gif1}
+    file delete $path
+} -result {{A 1 comment ABCD} {A 1} {A 1}}
+
+test imgPhoto-23.11 {configure: test if shared metadata object is not preserved\
+	(metadata replace, -data}\
+-setup {
+    set data $::gifstart
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifdata $::gifend
+} -body {
+    image create photo gif1 -data "$::gifstart$::gifdata$::gifend"
+    set metadataDict [dict create A 1]
+    set metadataDict2 $metadataDict
+    gif1 configure -data $data -format gif -metadata $metadataDict
+    list [dict get [gif1 cget -metadata]] $metadataDict $metadataDict2
+} -cleanup {
+    catch {image delete gif1}
+} -result {{A 1 comment ABCD} {A 1} {A 1}}
+
+test imgPhoto-23.12 {configure: test if shared metadata object is not preserved\
+	(metadata replace, -file}\
+-setup {
+    set data $::gifstart
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifdata $::gifend
+
+    set path [file join [configure -tmpdir] test.gif]
+    set h [open $path "WRONLY BINARY CREAT"]
+    puts $h $data
+    close $h
+} -body {
+    image create photo gif1 -data "$::gifstart$::gifdata$::gifend"
+    set metadataDict [dict create A 1]
+    set metadataDict2 $metadataDict
+    gif1 configure -file $path -format gif -metadata $metadataDict
+    list [dict get [gif1 cget -metadata]] $metadataDict $metadataDict2
+} -cleanup {
+    catch {image delete gif1}
+    file delete $path
+} -result {{A 1 comment ABCD} {A 1} {A 1}}
+
+test imgPhoto-23.13 {configure: test if shared metadata object is not preserved\
+	(-data)}\
+-setup {
+    set data $::gifstart$::gifdata$::gifend
+} -body {
+    image create photo gif1 -data $data
+    set metadataDict [dict create A 1]
+    set metadataDict2 $metadataDict
+    set data $::gifstart
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifdata $::gifend
+    gif1 configure -data $data -format gif -metadata $metadataDict
+    list [dict get [gif1 cget -metadata]] $metadataDict $metadataDict2
+} -cleanup {
+    catch {image delete gif1}
+} -result {{A 1 comment ABCD} {A 1} {A 1}}
+
+test imgPhoto-23.14 {configure: test if shared metadata object is not preserved\
+	(-file)}\
+-setup {
+    set data $::gifstart
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifdata $::gifend
+
+    set path [file join [configure -tmpdir] test.gif]
+    set h [open $path "WRONLY BINARY CREAT"]
+    puts $h $data
+    close $h
+} -body {
+    image create photo gif1 -data "$::gifstart$::gifdata$::gifend"
+    set metadataDict [dict create A 1]
+    set metadataDict2 $metadataDict
+    gif1 configure -file $path -format gif -metadata $metadataDict
+    list [dict get [gif1 cget -metadata]] $metadataDict $metadataDict2
+} -cleanup {
+    catch {image delete gif1}
+    file delete $path
+} -result {{A 1 comment ABCD} {A 1} {A 1}}
+
+test imgPhoto-23.15 {output data with comment (from -metadata argument)}\
+-setup {
+    set data $::gifstart$::gifdata$::gifend
+} -body {
+    image create photo gif1 -data $data
+    set gifData [gif1 data -format gif -metadata [dict create comment ABCD]]
+} -cleanup {
+    catch {image delete gif1}
+} -match glob -result {*ABCD*}
+
+test imgPhoto-23.22 {output file with comment (from -metadata argument)}\
+-setup {
+    set data $::gifstart$::gifdata$::gifend
+    set path [file join [configure -tmpdir] test.gif]
+} -body {
+    image create photo gif1 -data $data
+    gif1 write $path -format gif -metadata [dict create comment ABCD]
+    image delete gif1
+    image create photo gif1 -file $path
+    dict get [gif1 cget -metadata] comment
+} -cleanup {
+    catch {image delete gif1}
+    file delete $path
+} -result {ABCD}
+
+test imgPhoto-23.16 {output data with comment (from -metadata property)}\
+-setup {
+    set data $::gifstart$::gifdata$::gifend
+} -body {
+    image create photo gif1 -data $data
+    gif1 configure -metadata [dict create comment ABCD]
+    set gifData [gif1 data -format gif]
+} -cleanup {
+    catch {image delete gif1}
+} -match glob -result {*ABCD*}
+
+test imgPhoto-23.17 {output file with comment (from -metadata property)}\
+-setup {
+    set data $::gifstart$::gifdata$::gifend
+    set path [file join [configure -tmpdir] test.gif]
+} -body {
+    image create photo gif1 -data $data
+    gif1 configure -metadata [dict create comment ABCD]
+    gif1 write $path -format gif
+    image delete gif1
+    image create photo gif1 -file $path
+    dict get [gif1 cget -metadata] comment
+} -cleanup {
+    catch {image delete gif1}
+    file delete $path
+} -result {ABCD}
+
+test imgPhoto-23.18 {configure: empty metadata parameter overwrites image metadata} -setup {
+    image create photo gif1 -data $::gifstart$::gifdata$::gifend\
+	    -metadata {foo bar}
+    set data $::gifstart
+    # Append a comment extension block with data "ABCD"
+    append data "\x21\xfe\x04" "ABCD" "\x0"
+    # Trailer
+    append data $::gifdata $::gifend
+} -body {
+    gif1 configure -data $data -metadata {}
+    gif1 cget -metadata
+} -cleanup {
+    catch {image delete gif1}
+} -result {comment ABCD}
+
+test imgPhoto-23.19 {write: empty metadata parameter overwrites image metadata} -setup {
+    image create photo gif1 -data $::gifstart$::gifdata$::gifend\
+	    -metadata {comment bar}
+    set path [file join [configure -tmpdir] test.gif]
+} -body {
+    gif1 write $path -format gif -metadata {}
+    image delete gif1
+    image create photo gif1 -file $path
+    dict size [gif1 cget -metadata]
+} -cleanup {
+    catch {image delete gif1}
+    file delete $path
+} -result {0}
+
+test imgPhoto-23.20 {data: empty metadata parameter overwrites image metadata} -setup {
+    image create photo gif1 -data $::gifstart$::gifdata$::gifend\
+	    -metadata {comment bar}
+} -body {
+    set data [gif1 data -format gif -metadata {}]
+    image delete gif1
+    image create photo gif1 -data $data
+    dict size [gif1 cget -metadata]
+} -cleanup {
+    catch {image delete gif1}
+    file delete $path
+} -result {0}
+
+unset -nocomplain gifstart gifdata gifend
+
 
 catch {rename foreachPixel {}}
 catch {rename checkImgTrans {}}
 catch {rename checkImgTransLoop {}}
 imageFinish

Index: tests/imgSVGnano.test
==================================================================
--- tests/imgSVGnano.test
+++ tests/imgSVGnano.test
@@ -10,30 +10,34 @@
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 imageInit
 
 namespace eval svgnano {
+
     variable data
-    set data(plus) {<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
-<path fill="none" stroke="#000000" d="M0 0 h16 v16 h-16 z"/>
-<path fill="none" stroke="#000000" d="M8 4 v 8 M4 8 h 8"/>
-<circle fill="yellow" stroke="red" cx="10" cy="80" r="10" />
-<ellipse fill="none" stroke="blue" stroke-width="3" cx="60" cy="60" rx="10" ry="20" />
-<line x1="10" y1="90" x2="50" y2="99"/>
-<rect fill="none" stroke="green"  x="20" y="20" width="60" height="50" rx="3" ry="3"/>
-<polyline fill="red" stroke="purple" points="80,10 90,20 85,40"/>
-<polygon fill ="yellow" points="80,80 70,85 90,90"/>
-</svg>}
-    set data(bad) {<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0:w
-">
-</svg>}
+
+    set data(plus) {\
+            <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
+                <path fill="none" stroke="#000000" d="M0 0 h16 v16 h-16 z"/>
+                <path fill="none" stroke="#000000" d="M8 4 v 8 M4 8 h 8"/>
+                <circle fill="yellow" stroke="red" cx="10" cy="80" r="10" />
+                <ellipse fill="none" stroke="blue" stroke-width="3" cx="60" cy="60" rx="10" ry="20" />
+                <line x1="10" y1="90" x2="50" y2="99"/>
+                <rect fill="none" stroke="green"  x="20" y="20" width="60" height="50" rx="3" ry="3"/>
+                <polyline fill="red" stroke="purple" points="80,10 90,20 85,40"/>
+                <polygon fill ="yellow" points="80,80 70,85 90,90"/>
+                </svg>}
+                set data(bad) {<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0:w">
+            </svg>\
+    }
 
     tcltest::makeFile $data(plus) plus.svg
     set data(plusFilePath) [file join [tcltest::configure -tmpdir] plus.svg]
 
     tcltest::makeFile $data(bad) bad.svg
     set data(badFilePath) [file join [tcltest::configure -tmpdir] bad.svg]
+
 
 test imgSVGnano-1.1 {reading simple image} -setup {
     catch {rename foo ""}
 } -body {
     image create photo foo -data $data(plus)
@@ -70,35 +74,36 @@
     foo configure -format {svg -dpi 600}
     list [image width foo] [image height foo]
 } -cleanup {
     rename foo ""
 } -result {100 100}
+
 test imgSVGnano-1.5 {reading simple image from file} -setup {
     catch {rename foo ""}
 } -body {
     image create photo foo -file $data(plusFilePath)
     list [image width foo] [image height foo]
 } -cleanup {
     rename foo ""
 } -result {100 100}
-
-test imgSVGnano-1.6 {simple image with options} -setup {
+test imgSVGnano-1.6 {simple image from file with options} -setup {
     catch {rename foo ""}
 } -body {
     image create photo foo -file $data(plusFilePath) -format {svg -dpi 100 -scale 3}
     list [image width foo] [image height foo]
 } -cleanup {
     rename foo ""
 } -result {300 300}
-test imgSVGnano-1.7 {Very small scale gives 1x1 image} -body {
+
+test imgSVGnano-1.7 {very small scale gives 1x1 image} -body {
     image create photo foo -format "svg -scale 0.000001"\
 	    -data $data(plus)
     list [image width foo] [image height foo]
 } -cleanup {
     rename foo ""
 } -result {1 1}
-test imgSVGnano-1.8 {Very small scale gives 1x1 image from file} -body {
+test imgSVGnano-1.8 {very small scale gives 1x1 image, from file} -body {
     image create photo foo -format "svg -scale 0.000001"\
 	    -file $data(plusFilePath)
     list [image width foo] [image height foo]
 } -cleanup {
     rename foo ""
@@ -150,19 +155,19 @@
 test imgSVGnano-3.6 {no number parameter to -scaletoheight} -body {
     image create photo foo -format "svg -scaletoheight invalid"\
 	    -data $data(plus)
 } -returnCodes error -result {expected integer but got "invalid"}
 
-test imgSVGnano-3.7 {Option -scaletowidth} -body {
+test imgSVGnano-3.7 {option -scaletowidth} -body {
     image create photo foo -format "svg -scaletowidth 20"\
 	    -data $data(plus)
     image width foo
 } -cleanup {
     rename foo ""
 } -result 20
 
-test imgSVGnano-3.8 {Option -scaletoheight} -body {
+test imgSVGnano-3.8 {option -scaletoheight} -body {
     image create photo foo -format "svg -scaletoheight 20"\
 	    -data $data(plus)
     image height foo
 } -cleanup {
     rename foo ""
@@ -191,11 +196,10 @@
     lappend res [image width foo] [image height foo]
 } -cleanup {
     rename foo ""
     unset res
 } -result {100 100 200 200}
-
 
 test imgSVGnano-4.2 {error on file not accessible on reread due to configure} -setup {
     catch {rename foo ""}
     tcltest::makeFile $data(plus) tmpplus.svg
     image create photo foo -file [file join [tcltest::configure -tmpdir] tmpplus.svg]
@@ -232,10 +236,20 @@
 			<circle cx="6.5cm" cy="2cm" r="100" transform="skewX(1 1)"/>\
 			</g></svg>}
 } -cleanup {
     rename foo ""
 } -result {foo}
+
+test imgSVGnano-5.2 {bug d6e9b4db40 - "<svg" and ">" must be present} -body {
+    image create photo foo -format svg -data\
+			{<?xml version="1.0"?><!DOCTYPE svg PUBLIC\
+			"-//W3C//DTD SVG 1.0//EN\" \
+			"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">\
+			<sERRORvBADFILEg xmlns="http://www.w3.org/2000/svg">\
+			<circle cx="6.5cm" cy="2cm" r="100" transform="skewX(1 1)"/>\
+			</g></svg>}
+} -returnCodes error -result {couldn't recognize image data}
 
 };# end of namespace svgnano
 
 namespace delete svgnano
 imageFinish

Index: tests/listbox.test
==================================================================
--- tests/listbox.test
+++ tests/listbox.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out the "listbox" command
 # of Tk.  It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1993-1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
@@ -366,17 +366,17 @@
 test listbox-3.3 {ListboxWidgetCmd procedure, "activate" option} -body {
     .l activate a b
 } -returnCodes error -result {wrong # args: should be ".l activate index"}
 test listbox-3.4 {ListboxWidgetCmd procedure, "activate" option} -body {
     .l activate fooey
-} -returnCodes error -result {bad listbox index "fooey": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "fooey": must be active, anchor, end, @x,y, or an index}
 test listbox-3.5 {ListboxWidgetCmd procedure, "activate" option} -body {
     .l activate 3
     .l index active
 } -result 3
 test listbox-3.6 {ListboxWidgetCmd procedure, "activate" option} -body {
-    .l activate -1
+    .l activate {}
     .l index active
 } -result 0
 test listbox-3.7 {ListboxWidgetCmd procedure, "activate" option} -body {
     .l activate 30
     .l index active
@@ -391,11 +391,11 @@
 test listbox-3.10 {ListboxWidgetCmd procedure, "bbox" option} -body {
     .l bbox a b
 } -returnCodes error -result {wrong # args: should be ".l bbox index"}
 test listbox-3.11 {ListboxWidgetCmd procedure, "bbox" option} -body {
     .l bbox fooey
-} -returnCodes error -result {bad listbox index "fooey": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "fooey": must be active, anchor, end, @x,y, or an index}
 test listbox-3.12 {ListboxWidgetCmd procedure, "bbox" option} -body {
     .l yview 3
     update
     list [.l bbox 2] [.l bbox 8]
 } -result {{} {}}
@@ -424,11 +424,11 @@
 test listbox-3.15 {ListboxWidgetCmd procedure, "bbox" option} -constraints {
 	fonts
 } -body {
     .l yview 0
     update
-    list [.l bbox -1] [.l bbox 0]
+    list [.l bbox {}] [.l bbox 0]
 } -result {{} {7 7 17 14}}
 test listbox-3.16 {ListboxWidgetCmd procedure, "bbox" option} -constraints {
 	fonts
 } -body {
     .l yview end
@@ -556,14 +556,14 @@
 test listbox-3.31 {ListboxWidgetCmd procedure, "delete" option} -body {
     .l delete a b c
 } -returnCodes error -result {wrong # args: should be ".l delete firstIndex ?lastIndex?"}
 test listbox-3.32 {ListboxWidgetCmd procedure, "delete" option} -body {
     .l delete badIndex
-} -returnCodes error -result {bad listbox index "badIndex": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "badIndex": must be active, anchor, end, @x,y, or an index}
 test listbox-3.33 {ListboxWidgetCmd procedure, "delete" option} -body {
     .l delete 2 123ab
-} -returnCodes error -result {bad listbox index "123ab": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "123ab": must be active, anchor, end, @x,y, or an index}
 test listbox-3.34 {ListboxWidgetCmd procedure, "delete" option} -setup {
     destroy .l2
 } -body {
     listbox .l2
     .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
@@ -585,21 +585,21 @@
 test listbox-3.36 {ListboxWidgetCmd procedure, "delete" option} -setup {
     destroy .l2
 } -body {
     listbox .l2
     .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
-    .l2 delete -1 2
+    .l2 delete {} 2
     .l2 get 0 end
 } -cleanup {
     destroy .l2
 } -result {el3 el4 el5 el6 el7}
 test listbox-3.37 {ListboxWidgetCmd procedure, "delete" option} -setup {
     destroy .l2
 } -body {
     listbox .l2
     .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
-    .l2 delete -1 -1
+    .l2 delete {} {}
     .l2 get 0 end
 } -cleanup {
     destroy .l2
 } -result {el0 el1 el2 el3 el4 el5 el6 el7}
 test listbox-3.38 {ListboxWidgetCmd procedure, "delete" option} -setup {
@@ -648,14 +648,14 @@
 test listbox-3.43 {ListboxWidgetCmd procedure, "get" option} -body {
     .l get a b c
 } -returnCodes error -result {wrong # args: should be ".l get firstIndex ?lastIndex?"}
 test listbox-3.44 {ListboxWidgetCmd procedure, "get" option} -body {
     .l get 2.4
-} -returnCodes error -result {bad listbox index "2.4": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "2.4": must be active, anchor, end, @x,y, or an index}
 test listbox-3.45 {ListboxWidgetCmd procedure, "get" option} -body {
     .l get end bogus
-} -returnCodes error -result {bad listbox index "bogus": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "bogus": must be active, anchor, end, @x,y, or an index}
 test listbox-3.46 {ListboxWidgetCmd procedure, "get" option} -setup {
     destroy .l2
 } -body {
     listbox .l2
     .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
@@ -679,17 +679,17 @@
     .l2 get 3 end
 } -cleanup {
     destroy .l2
 } -result {{two words} el4 el5 el6 el7}
 test listbox-3.49 {ListboxWidgetCmd procedure, "get" option} -body {
-    .l get -1
+    .l get {}
 } -result {}
 test listbox-3.50 {ListboxWidgetCmd procedure, "get" option} -body {
-    .l get -1 -1
+    .l get {} {}
 } -result {}
 test listbox-3.51 {ListboxWidgetCmd procedure, "get" option} -body {
-    .l get -1 3
+    .l get {} 3
 } -result {el0 el1 el2 el3}
 test listbox-3.52 {ListboxWidgetCmd procedure, "get" option} -body {
     .l get 12 end
 } -result {el12 el13 el14 el15 el16 el17}
 test listbox-3.53 {ListboxWidgetCmd procedure, "get" option} -body {
@@ -710,17 +710,17 @@
 test listbox-3.58 {ListboxWidgetCmd procedure, "index" option} -body {
     .l index a b
 } -returnCodes error -result {wrong # args: should be ".l index index"}
 test listbox-3.59 {ListboxWidgetCmd procedure, "index" option} -body {
     .l index @
-} -returnCodes error -result {bad listbox index "@": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "@": must be active, anchor, end, @x,y, or an index}
 test listbox-3.60 {ListboxWidgetCmd procedure, "index" option} -body {
     .l index 2
 } -result 2
 test listbox-3.61 {ListboxWidgetCmd procedure, "index" option} -body {
-    .l index -1
-} -result -1
+    expr {[.l index {}]<0}
+} -result 1
 test listbox-3.62 {ListboxWidgetCmd procedure, "index" option} -body {
     .l index end
 } -result 18
 test listbox-3.63 {ListboxWidgetCmd procedure, "index" option} -body {
     .l index 34
@@ -728,11 +728,11 @@
 test listbox-3.64 {ListboxWidgetCmd procedure, "insert" option} -body {
     .l insert
 } -returnCodes error -result {wrong # args: should be ".l insert index ?element ...?"}
 test listbox-3.65 {ListboxWidgetCmd procedure, "insert" option} -body {
     .l insert badIndex
-} -returnCodes error -result {bad listbox index "badIndex": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "badIndex": must be active, anchor, end, @x,y, or an index}
 test listbox-3.66 {ListboxWidgetCmd procedure, "insert" option} -setup {
     destroy .l2
 } -body {
     listbox .l2
     .l2 insert end a b c d e
@@ -744,11 +744,11 @@
 test listbox-3.67 {ListboxWidgetCmd procedure, "insert" option} -setup {
     destroy .l2
 } -body {
     listbox .l2
     .l2 insert end a b c
-    .l2 insert -1 x
+    .l2 insert 0 x
     .l2 get 0 end
 } -cleanup {
     destroy .l2
 } -result {x a b c}
 test listbox-3.68 {ListboxWidgetCmd procedure, "insert" option} -setup {
@@ -814,20 +814,20 @@
 } -cleanup {
     destroy .t
 } -result {{0.249364 0.427481} {0.0714286 0.428571}}
 test listbox-3.79 {ListboxWidgetCmd procedure, "scan" option} -body {
     .l scan foo 2 4
-} -returnCodes error -result {bad option "foo": must be mark or dragto}
+} -returnCodes error -result {bad option "foo": must be dragto or mark}
 test listbox-3.80 {ListboxWidgetCmd procedure, "see" option} -body {
     .l see
 } -returnCodes error -result {wrong # args: should be ".l see index"}
 test listbox-3.81 {ListboxWidgetCmd procedure, "see" option} -body {
     .l see a b
 } -returnCodes error -result {wrong # args: should be ".l see index"}
 test listbox-3.82 {ListboxWidgetCmd procedure, "see" option} -body {
     .l see gorp
-} -returnCodes error -result {bad listbox index "gorp": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "gorp": must be active, anchor, end, @x,y, or an index}
 test listbox-3.83 {ListboxWidgetCmd procedure, "see" option} -body {
     .l yview 7
     .l see 7
     .l index @0,0
 } -result 7
@@ -856,11 +856,11 @@
     .l see 13
     .l index @0,0
 } -result 11
 test listbox-3.89 {ListboxWidgetCmd procedure, "see" option} -body {
     .l yview 7
-    .l see -1
+    .l see {}
     .l index @0,0
 } -result 0
 test listbox-3.90 {ListboxWidgetCmd procedure, "see" option} -body {
     .l yview 7
     .l see end
@@ -882,23 +882,23 @@
 test listbox-3.94 {ListboxWidgetCmd procedure, "selection" option} -body {
     .l select a b c d
 } -returnCodes error -result {wrong # args: should be ".l selection option index ?index?"}
 test listbox-3.95 {ListboxWidgetCmd procedure, "selection" option} -body {
     .l selection a bogus
-} -returnCodes error -result {bad listbox index "bogus": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "bogus": must be active, anchor, end, @x,y, or an index}
 test listbox-3.96 {ListboxWidgetCmd procedure, "selection" option} -body {
     .l selection a 0 lousy
-} -returnCodes error -result {bad listbox index "lousy": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "lousy": must be active, anchor, end, @x,y, or an index}
 test listbox-3.97 {ListboxWidgetCmd procedure, "selection" option} -body {
     .l selection anchor 0 0
 } -returnCodes error -result {wrong # args: should be ".l selection anchor index"}
 test listbox-3.98 {ListboxWidgetCmd procedure, "selection" option} -body {
     list [.l selection anchor 5; .l index anchor] \
 	    [.l selection anchor 0; .l index anchor]
 } -result {5 0}
 test listbox-3.99 {ListboxWidgetCmd procedure, "selection" option} -body {
-    .l selection anchor -1
+    .l selection anchor {}
     .l index anchor
 } -result 0
 test listbox-3.100 {ListboxWidgetCmd procedure, "selection" option} -body {
     .l selection anchor end
     .l index anchor
@@ -923,11 +923,11 @@
     list [.l selection includes 3] [.l selection includes 4] \
 	    [.l selection includes 5]
 } -result {1 0 1}
 test listbox-3.105 {ListboxWidgetCmd procedure, "selection" option} -body {
     .l selection set 0 end
-    .l selection includes -1
+    .l selection includes {}
 } -result 0
 test listbox-3.106 {ListboxWidgetCmd procedure, "selection" option} -body {
     .l selection clear 0 end
     .l selection set end
     .l selection includes end
@@ -1133,11 +1133,11 @@
 .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11 el12 el13 el14 \
 	el15 el16 el17
 update
 test listbox-3.127 {ListboxWidgetCmd procedure, "xview" option} -body {
     .l yview foo
-} -returnCodes error -result {bad listbox index "foo": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "foo": must be active, anchor, end, @x,y, or an index}
 test listbox-3.128 {ListboxWidgetCmd procedure, "xview" option} -body {
     .l yview foo a b
 } -returnCodes error -result {unknown option "foo": must be moveto or scroll}
 test listbox-3.129 {ListboxWidgetCmd procedure, "xview" option} -setup {
     destroy .l2
@@ -1975,11 +1975,11 @@
     .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
     update
     .l index a
 } -cleanup {
     destroy .l
-} -returnCodes error -result {bad listbox index "a": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "a": must be active, anchor, end, @x,y, or an index}
 test listbox-10.5 {GetListboxIndex procedure} -setup {
     destroy .l
 } -body {
     pack [listbox .l]
     .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
@@ -2016,61 +2016,61 @@
     .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
     update
     .l index @
 } -cleanup {
     destroy .l
-} -returnCodes error -result {bad listbox index "@": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "@": must be active, anchor, end, @x,y, or an index}
 test listbox-10.9 {GetListboxIndex procedure} -setup {
     destroy .l
 } -body {
     pack [listbox .l]
     .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
     update
     .l index @foo
 } -cleanup {
     destroy .l
-} -returnCodes error -result {bad listbox index "@foo": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "@foo": must be active, anchor, end, @x,y, or an index}
 test listbox-10.10 {GetListboxIndex procedure} -setup {
     destroy .l
 } -body {
     pack [listbox .l]
     .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
     update
     .l index @1x3
 } -cleanup {
     destroy .l
-} -returnCodes error -result {bad listbox index "@1x3": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "@1x3": must be active, anchor, end, @x,y, or an index}
 test listbox-10.11 {GetListboxIndex procedure} -setup {
     destroy .l
 } -body {
     pack [listbox .l]
     .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
     update
     .l index @1,
 } -cleanup {
     destroy .l
-} -returnCodes error -result {bad listbox index "@1,": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "@1,": must be active, anchor, end, @x,y, or an index}
 test listbox-10.12 {GetListboxIndex procedure} -setup {
     destroy .l
 } -body {
     pack [listbox .l]
     .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
     update
     .l index @1,foo
 } -cleanup {
     destroy .l
-} -returnCodes error -result {bad listbox index "@1,foo": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "@1,foo": must be active, anchor, end, @x,y, or an index}
 test listbox-10.13 {GetListboxIndex procedure} -setup {
     destroy .l
 } -body {
     pack [listbox .l]
     .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
     update
     .l index @1,2x
 } -cleanup {
     destroy .l
-} -returnCodes error -result {bad listbox index "@1,2x": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "@1,2x": must be active, anchor, end, @x,y, or an index}
 test listbox-10.14 {GetListboxIndex procedure} -constraints {
     fonts
 } -setup {
     destroy .l
 } -body {
@@ -2090,11 +2090,11 @@
     .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
     update
     .l index 1xy
 } -cleanup {
     destroy .l
-} -returnCodes error -result {bad listbox index "1xy": must be active, anchor, end, @x,y, or a number}
+} -returnCodes error -result {bad listbox index "1xy": must be active, anchor, end, @x,y, or an index}
 test listbox-10.16 {GetListboxIndex procedure} -setup {
     destroy .l
 } -body {
     pack [listbox .l]
     .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
@@ -2127,14 +2127,14 @@
     destroy .l
 } -body {
     pack [listbox .l]
     .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
     update
-    .l index -1
+    expr {[.l index {}]<0}
 } -cleanup {
     destroy .l
-} -result -1
+} -result 1
 test listbox-10.20 {GetListboxIndex procedure} -setup {
     destroy .l
 } -body {
     pack [listbox .l]
     .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
@@ -2153,11 +2153,11 @@
     pack .l
     .l insert 0 a b c d e f g h i j
     .l yview 3
     update
     set x [.l index @0,0]
-    .l yview -1
+    .l yview {}
     update
     lappend x [.l index @0,0]
 } -cleanup {
     destroy .l
 } -result {3 0}
@@ -2376,18 +2376,18 @@
 } -result {}
 test listbox-15.4 {ListboxSelect procedure, boundary conditions for indices} -body {
     .l delete 0 end
     .l insert 0 a b c d e f
     .l select clear 0 end
-    .l select set -1 -1
+    .l select set {} {}
     .l curselection
 } -result {}
 test listbox-15.5 {ListboxSelect procedure, boundary conditions for indices} -body {
     .l delete 0 end
     .l insert 0 a b c d e f
     .l select clear 0 end
-    .l select set -1 3
+    .l select set {} 3
     .l curselection
 } -result {0 1 2 3}
 test listbox-15.6 {ListboxSelect procedure, boundary conditions for indices} -body {
     .l delete 0 end
     .l insert 0 a b c d e f

Index: tests/main.test
==================================================================
--- tests/main.test
+++ tests/main.test
@@ -2,12 +2,12 @@
 #
 # This file contains a collection of tests for one or more of the Tcl
 # built-in commands.  Sourcing this file into Tcl runs the tests and
 # generates output for errors.  No output means no errors were found.
 #
-# Copyright © 1997 by Sun Microsystems, Inc.
-# Copyright (c) 1998-1999 by Scriptics Corporation.
+# Copyright © 1997 Sun Microsystems, Inc.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -43,11 +43,11 @@
 	set f [open $script w]
 	fconfigure $f -encoding utf-8
 	puts $f {puts [list $argv0 $argv $tcl_interactive]}
 	puts $f {puts [string equal \u20AC €]; exit}
 	close $f
-	catch {set f [open "|[list [interpreter] -encoding ascii script]" r]}
+	catch {set f [open "|[list [interpreter] -encoding iso8859-1 script]" r]}
 } -body {
 	read $f
 } -cleanup {
 	close $f
 	removeFile script
@@ -89,11 +89,11 @@
 } -returnCodes ok -result {-enc utf-8 script}
 
 test main-3.1 {Tk_ParseArgv: -help option} -constraints unix -body {
     # Run only on unix as Win32 pops up native dialog
     exec [interpreter] -help
-} -returnCodes error -match glob -result {% application-specific initialization failed: Command-specific options:*}
+} -returnCodes error -match glob -result {*application-specific initialization failed: Command-specific options:*}
 
 test main-3.2 {Tk_ParseArgv: -help option} -setup {
     set maininterp [interp create]
 } -body {
     $maininterp eval { set argc 1 ; set argv -help }

Index: tests/menu.test
==================================================================
--- tests/menu.test
+++ tests/menu.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test menus in Tk.  It is
 # organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1995-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -1197,27 +1197,27 @@
     .m1 entryconfigure 0 -underline 3p
 } -returnCodes error -result {unknown option "-underline"}
 
 test menu-2.224 {entry configuration options 1 -underline 3p command} -body {
     .m1 entryconfigure 1 -underline 3p
-} -returnCodes error -result {expected integer but got "3p"}
+} -returnCodes error -result {bad index "3p": must be integer?[+-]integer?, end?[+-]integer?, or ""}
 
 test menu-2.225 {entry configuration options 2 -underline 3p cascade} -body {
     .m1 entryconfigure 2 -underline 3p
-} -returnCodes error -result {expected integer but got "3p"}
+} -returnCodes error -result {bad index "3p": must be integer?[+-]integer?, end?[+-]integer?, or ""}
 
 test menu-2.226 {entry configuration options 3 -underline 3p separator} -body {
     .m1 entryconfigure 3 -underline 3p
 } -returnCodes error -result {unknown option "-underline"}
 
 test menu-2.227 {entry configuration options 4 -underline 3p checkbutton} -body {
     .m1 entryconfigure 4 -underline 3p
-} -returnCodes error -result {expected integer but got "3p"}
+} -returnCodes error -result {bad index "3p": must be integer?[+-]integer?, end?[+-]integer?, or ""}
 
 test menu-2.228 {entry configuration options 5 -underline 3p radiobutton} -body {
     .m1 entryconfigure 5 -underline 3p
-} -returnCodes error -result {expected integer but got "3p"}
+} -returnCodes error -result {bad index "3p": must be integer?[+-]integer?, end?[+-]integer?, or ""}
 
 deleteWindows
 if {[testConstraint hasEarthPhoto]} {
     image delete image1
 }
@@ -1228,14 +1228,14 @@
     destroy .m1
 } -body {
     menu .m1
     .m1
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {wrong # args: should be ".m1 option ?arg ...?"}
 test menu-3.2 {MenuWidgetCmd, Tcl_Preserve and Tcl_Release} -constraints {
-	nonUnixUserInteraction
+    nonUnixUserInteraction
 } -setup {
     destroy .m1
 } -body  {
     menu .m1 -postcommand "destroy .m1"
     .m1 add command -label "menu-3.2: Hit Escape"
@@ -1242,226 +1242,226 @@
     .m1 post 40 40
 } -cleanup {
     destroy .m1
 } -returnCodes ok -result {}
 test menu-3.3 {MenuWidgetCmd procedure, "activate" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "test"
     .m1 activate
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {wrong # args: should be ".m1 activate index"}
 test menu-3.4 {MenuWidgetCmd procedure, "activate" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 activate "foo"
 } -returnCodes error -result {bad menu entry index "foo"}
 test menu-3.5 {MenuWidgetCmd procedure, "activate" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "test"
     .m1 add separator
     .m1 activate 2
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.6 {MenuWidgetCmd procedure, "activate" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "test"
     .m1 entryconfigure 1 -state disabled
     .m1 activate 1
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.7 {MenuWidgetCmd procedure, "activate" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "test"
     .m1 activate 1
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.8 {MenuWidgetCmd procedure, "add" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {wrong # args: should be ".m1 add type ?-option value ...?"}
 test menu-3.9 {MenuWidgetCmd procedure, "add" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add foo
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {bad menu entry type "foo": must be cascade, checkbutton, command, radiobutton, or separator}
 test menu-3.10 {MenuWidgetCmd procedure, "add" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add separator
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.11 {MenuWidgetCmd procedure, "cget" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 cget
 } -returnCodes error -result {wrong # args: should be ".m1 cget option"}
 test menu-3.12 {MenuWidgetCmd procedure, "cget" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 cget -gorp
 } -returnCodes error -result {unknown option "-gorp"}
 test menu-3.13 {MenuWidgetCmd procedure, "cget" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 configure -postcommand "Some string"
     .m1 cget -postcommand
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {Some string}
 test menu-3.14 {MenuWidgetCmd procedure, "clone" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 clone
 } -returnCodes error -result {wrong # args: should be ".m1 clone newMenuName ?menuType?"}
 test menu-3.15 {MenuWidgetCmd procedure, "clone" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 clone a b c d
 } -returnCodes error -result {wrong # args: should be ".m1 clone newMenuName ?menuType?"}
 test menu-3.16 {MenuWidgetCmd procedure, "clone" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 clone .m1.clone1
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.17 {MenuWidgetCmd procedure, "clone" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 clone .m1.clone1 tearoff
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.18 {MenuWidgetCmd procedure, "configure" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     llength [.m1 configure]
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result 21
 test menu-3.19 {MenuWidgetCmd procedure, "configure" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 configure -gorp
 } -returnCodes error -result {unknown option "-gorp"}
 test menu-3.20 {MenuWidgetCmd procedure, "configure" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 configure -postcommand "A random String"
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.21 {MenuWidgetCmd procedure, "configure" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 configure -postcommand "Another string"
     lindex [.m1 configure -postcommand] 4
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {Another string}
 test menu-3.22 {MenuWidgetCmd procedure, "delete" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 delete
 } -returnCodes error -result {wrong # args: should be ".m1 delete first ?last?"}
 test menu-3.23 {MenuWidgetCmd procedure, "delete" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 delete foo
 } -returnCodes error -result {bad menu entry index "foo"}
 test menu-3.24 {MenuWidgetCmd procedure, "delete" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1 -tearoff 1
     .m1 delete 0 "foo"
 } -returnCodes error -result {bad menu entry index "foo"}
 test menu-3.25 {MenuWidgetCmd procedure, "delete" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 delete 0
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.26 {MenuWidgetCmd procedure, "delete" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "foo"
     .m1 delete 1 0
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.27 {MenuWidgetCmd procedure, "delete" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "1"
     .m1 add command -label "2"
     .m1 add command -label "3"
     .m1 delete 1 3
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.28 {MenuWidgetCmd procedure, "delete" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "1"
     .m1 add command -label "2"
     .m1 add command -label "3"
     .m1 activate 2
     .m1 delete 1 3
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.29 {MenuWidgetCmd procedure, "delete" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "1"
     .m1 add command -label "2"
     .m1 add command -label "3"
     .m1 activate 3
     .m1 delete 1
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.29+1 {MenuWidgetCmd, "delete", Bug 220950} -setup {
     destroy .m1
 } -body {
     menu .m1
@@ -1471,90 +1471,90 @@
     .m1 entrycget last -label
 } -cleanup {
     destroy .m1
 } -result ok
 test menu-3.30 {MenuWidgetCmd procedure, "entrycget" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 entrycget
 } -returnCodes error -result {wrong # args: should be ".m1 entrycget index option"}
 test menu-3.31 {MenuWidgetCmd procedure, "entrycget" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 entrycget index option foo
 } -returnCodes error -result {wrong # args: should be ".m1 entrycget index option"}
 test menu-3.32 {MenuWidgetCmd procedure, "entrycget" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 entrycget foo -label
 } -returnCodes error -result {bad menu entry index "foo"}
 test menu-3.33 {MenuWidgetCmd procedure, "entrycget" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "test"
     .m1 entrycget 1 -label
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {test}
 test menu-3.34 {MenuWidgetCmd procedure, "entryconfigure" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 entryconfigure
 } -returnCodes error -result {wrong # args: should be ".m1 entryconfigure index ?-option value ...?"}
 test menu-3.35 {MenuWidgetCmd procedure, "entryconfigure" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 entryconfigure foo
 } -returnCodes error -result {bad menu entry index "foo"}
 test menu-3.36 {MenuWidgetCmd procedure, "entryconfigure" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "test"
     llength [.m1 entryconfigure 1]
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result 15
 test menu-3.37 {MenuWidgetCmd procedure, "entryconfigure" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "test"
     lindex [.m1 entryconfigure 1 -label] 4
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {test}
 test menu-3.38 {MenuWidgetCmd procedure, "entryconfigure" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "test"
     .m1 entryconfigure 1 -label "changed"
     lindex [.m1 entryconfigure 1 -label] 4
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {changed}
 test menu-3.39 {MenuWidgetCmd procedure, "index" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 index
 } -returnCodes error -result {wrong # args: should be ".m1 index string"}
 test menu-3.40 {MenuWidgetCmd procedure, "index" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 index foo
 } -returnCodes error -result {bad menu entry index "foo"}
 test menu-3.41 {MenuWidgetCmd procedure, "index" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1 -tearoff 1
     .m1 add command -label "test"
     .m1 add command -label "3"
     .m1 add command -label "another label"
@@ -1561,266 +1561,266 @@
     .m1 add command -label "end"
     .m1 add command -label "3a"
     .m1 add command -label "final entry"
     list [.m1 index "test"] [.m1 index "3"] [.m1 index "3a"] [.m1 index "end"]
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {1 3 5 6}
 test menu-3.42 {MenuWidgetCmd procedure, "insert" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 insert
 } -returnCodes error -result {wrong # args: should be ".m1 insert index type ?-option value ...?"}
 test menu-3.43 {MenuWidgetCmd procedure, "insert" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 insert 1 command -label "test"
     .m1 entrycget 1 -label
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {test}
 test menu-3.44 {MenuWidgetCmd procedure, "invoke" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 invoke
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {wrong # args: should be ".m1 invoke index"}
 test menu-3.45 {MenuWidgetCmd procedure, "invoke" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 invoke foo
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {bad menu entry index "foo"}
 test menu-3.46 {MenuWidgetCmd procedure, "invoke" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     catch {unset foo}
     menu .m1
     .m1 add command -label "set foo" -command "set foo hello"
     list [.m1 invoke 1] [set foo] [unset foo]
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes ok -result {hello hello {}}
 test menu-3.47 {MenuWidgetCmd procedure, "post" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "On Windows, hit Escape to get this menu to go away"
     .m1 post
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {wrong # args: should be ".m1 post x y ?index?"}
 test menu-3.48 {MenuWidgetCmd procedure, "post" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 post foo 40
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {expected integer but got "foo"}
 test menu-3.49 {MenuWidgetCmd procedure, "post" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 post 40 bar
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {expected integer but got "bar"}
 test menu-3.50 {MenuWidgetCmd procedure, "post" option} -constraints {
-	nonUnixUserInteraction
+    nonUnixUserInteraction
 } -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "menu-3.50: hit Escape" -command "puts hello"
     .m1 post 40 40
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.51 {MenuWidgetCmd procedure, "postcascade" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 postcascade
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {wrong # args: should be ".m1 postcascade index"}
 test menu-3.52 {MenuWidgetCmd procedure, "postcascade" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 postcascade foo
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {bad menu entry index "foo"}
 test menu-3.53 {MenuWidgetCmd procedure, "postcascade" option} -constraints {
-	nonUnixUserInteraction
+    nonUnixUserInteraction
 } -setup {
-	destroy .m1 .m2
+    destroy .m1 .m2
 } -body {
     menu .m1
     .m1 add command -label "menu-3.53 - hit Escape"
     menu .m2
     .m1 post 40 40
     .m1 add cascade -menu .m2
     .m1 postcascade 1
 } -cleanup {
-	destroy .m1 .m2
+    destroy .m1 .m2
 } -result {}
 test menu-3.54 {MenuWidgetCmd procedure, "postcascade" option} -setup {
-	destroy .m1 .m2
+    destroy .m1 .m2
 } -body {
     menu .m1
     menu .m2
     .m1 add cascade -menu .m2 -label "menu-3.57 - hit Escape"
     .m1 postcascade 1
-    .m1 postcascade none
+    .m1 postcascade {}
 } -cleanup {
-	destroy .m1 .m2
+    destroy .m1 .m2
 } -result {}
 test menu-3.55 {MenuWidgetCmd procedure, "type" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 type
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {wrong # args: should be ".m1 type index"}
 test menu-3.56 {MenuWidgetCmd procedure, "type" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 type foo
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {bad menu entry index "foo"}
 test menu-3.57 {MenuWidgetCmd procedure, "type" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "test"
     .m1 type 1
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {command}
 test menu-3.58 {MenuWidgetCmd procedure, "type" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add separator
     .m1 type 1
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {separator}
 test menu-3.59 {MenuWidgetCmd procedure, "type" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add checkbutton -label "test"
     .m1 type 1
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {checkbutton}
 test menu-3.60 {MenuWidgetCmd procedure, "type" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add radiobutton -label "test"
     .m1 type 1
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {radiobutton}
 test menu-3.61 {MenuWidgetCmd procedure, "type" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add cascade -label "test"
     .m1 type 1
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {cascade}
 test menu-3.62 {MenuWidgetCmd procedure, "type" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1 -tearoff 1
     .m1 type 0
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {tearoff}
 test menu-3.63 {MenuWidgetCmd procedure, "unpost" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 unpost foo
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {wrong # args: should be ".m1 unpost"}
 test menu-3.64 {MenuWidgetCmd procedure, "unpost" option} -constraints {
-	nonUnixUserInteraction
+    nonUnixUserInteraction
 } -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 add command -label "menu-3.64 - hit Escape"
     .m1 post 40 40
     .m1 unpost
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {}
 test menu-3.65 {MenuWidgetCmd procedure, "yposition" option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 yposition
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {wrong # args: should be ".m1 yposition index"}
 test menu-3.66a {MenuWidgetCmd procedure, "yposition" option, no tearoff} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1 -tearoff 0
     .m1 yposition 1
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result 0
 test menu-3.66b {MenuWidgetCmd procedure, "yposition" option, with tearoff} -constraints {
     notAqua
 } -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     # on Win or Linux, tearoff menus are supported
     # see menu-3.66c for aqua
     menu .m1 -tearoff 1
     .m1 yposition 1
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result 1
 test menu-3.66c {MenuWidgetCmd procedure, "yposition" option, with tearoff} -constraints {
     aqua
 } -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     # on OS X, tearoff menus are not supported
     # see menu-3.66b for win or linux
     menu .m1 -tearoff 1
     .m1 yposition 1
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result 0
 test menu-3.67 {MenuWidgetCmd procedure, bad option} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     .m1 foo
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -returnCodes error -result {bad option "foo": must be activate, add, cget, clone, configure, delete, entrycget, entryconfigure, index, insert, invoke, post, postcascade, type, unpost, xposition, or yposition}
 test menu-3.68 {MenuWidgetCmd procedure, fix for bug#508988} -setup {
     deleteWindows
 } -body {
     set t .t
@@ -1860,32 +1860,32 @@
 } -result {}
 test menu-3.71 {MenuWidgetCmd procedure, "index end" option, bug [f3cd942e9e]} -setup {
     destroy .m1
 } -body {
     menu .m1
-    list [.m1 index "end"]
+    .m1 index "end"
 } -cleanup {
     destroy .m1
-} -result none
+} -result {}
 
 
 test menu-4.1 {TkInvokeMenu: disabled} -setup {
     destroy .m1
 } -body {
     catch {unset foo}
     menu .m1
     .m1 add checkbutton -label "test" -variable foo -onvalue on -offvalue off \
-	-state disabled
+    -state disabled
     list [catch {.m1 invoke 1} msg] $foo
 } -cleanup {
     destroy .m1
 } -result {0 off}
 test menu-4.2 {TkInvokeMenu: tearoff} -setup {
     destroy .m1
 } -body {
     menu .m1
-	catch {.m1 invoke 0}
+    catch {.m1 invoke 0}
 } -cleanup {
     deleteWindows
 } -result 0
 test menu-4.3 {TkInvokeMenu: checkbutton -on} -setup {
     destroy .m1
@@ -1892,11 +1892,11 @@
 } -body {
     catch {unset foo}
     menu .m1
     .m1 add checkbutton -label "test" -variable foo -onvalue on -offvalue off
     list [catch {.m1 invoke 1} msg] $msg [catch {set foo} msg2] $msg2 \
-		[catch {unset foo} msg3] $msg3
+            [catch {unset foo} msg3] $msg3
 } -cleanup {
     destroy .m1
 } -result {0 {} 0 on 0 {}}
 test menu-4.4 {TkInvokeMenu: checkbutton -off} -setup {
     destroy .m1
@@ -1915,11 +1915,11 @@
     catch {unset foo}
     menu .m1
     .m1 add checkbutton -label "test" -variable foo(1) -onvalue on
     list [catch {.m1 invoke 1} msg] $msg [catch {set foo(1)} msg2] $msg2 [catch {unset foo} msg3] $msg3
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {0 {} 0 on 0 {}}
 test menu-4.6 {TkInvokeMenu: radiobutton} -setup {
     destroy .m1
 } -body {
     catch {unset foo}
@@ -1927,11 +1927,11 @@
     .m1 add radiobutton -label "1" -variable foo -value one
     .m1 add radiobutton -label "2" -variable foo -value two
     .m1 add radiobutton -label "3" -variable foo -value three
     list [catch {.m1 invoke 1} msg] $msg [catch {set foo} msg2] $msg2 [catch {unset foo} msg3] $msg3
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {0 {} 0 one 0 {}}
 test menu-4.7 {TkInvokeMenu: radiobutton} -setup {
     destroy .m1
 } -body {
     catch {unset foo}
@@ -1939,11 +1939,11 @@
     .m1 add radiobutton -label "1" -variable foo -value one
     .m1 add radiobutton -label "2" -variable foo -value two
     .m1 add radiobutton -label "3" -variable foo -value three
     list [catch {.m1 invoke 2} msg] $msg [catch {set foo} msg2] $msg2 [catch {unset foo} msg3] $msg3
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {0 {} 0 two 0 {}}
 test menu-4.8 {TkInvokeMenu: radiobutton} -setup {
     destroy .m1
 } -body {
     catch {unset foo}
@@ -1951,11 +1951,11 @@
     .m1 add radiobutton -label "1" -variable foo -value one
     .m1 add radiobutton -label "2" -variable foo -value two
     .m1 add radiobutton -label "3" -variable foo -value three
     list [catch {.m1 invoke 3} msg] $msg [catch {set foo} msg2] $msg2 [catch {unset foo} msg3] $msg3
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {0 {} 0 three 0 {}}
 test menu-4.9 {TkInvokeMenu: radiobutton array element} -setup {
     destroy .m1
 } -body {
     catch {unset foo}
@@ -1963,39 +1963,39 @@
     .m1 add radiobutton -label "1" -variable foo(2) -value one
     .m1 add radiobutton -label "2" -variable foo(2) -value two
     .m1 add radiobutton -label "3" -variable foo(2) -value three
     list [catch {.m1 invoke 3} msg] $msg [catch {set foo(2)} msg2] $msg2 [catch {unset foo} msg3] $msg3
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {0 {} 0 three 0 {}}
 test menu-4.10 {TkInvokeMenu} -setup {
     destroy .m1
 } -body {
     catch {unset foo}
     menu .m1
     .m1 add command -label "test" -command "set menu_test menu-4.8"
     list [catch {.m1 invoke 1} msg] $msg [catch {set menu_test} msg2] $msg2 [catch {unset menu_test} msg3] $msg3
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {0 menu-4.8 0 menu-4.8 0 {}}
 test menu-4.11 {TkInvokeMenu} -setup {
     destroy .m1
 } -body {
     menu .m1
     .m1 add cascade -label "test" -menu .m1.m2
     list [catch {.m1 invoke 1} msg] $msg
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {0 {}}
 test menu-4.12 {TkInvokeMenu} -setup {
     destroy .m1
 } -body {
     menu .m1 -tearoff 1
     .m1 add command -label "test" -command ".m1 delete 1"
     list [catch {.m1 invoke 1} msg] $msg [catch {.m1 type "test"} msg2] $msg2
 } -cleanup {
-	destroy .m1
+    destroy .m1
 } -result {0 {} 1 {bad menu entry index "test"}}
 
 test menu-5.1 {DestroyMenuInstance} -setup {
     destroy .m1
 } -body {
@@ -2176,49 +2176,49 @@
     deleteWindows
 } -body {
     menu .m1
     .m1 clone .m2
     .m1 clone .m3
-	list [destroy .m2] [destroy .m3] [destroy .m1]
+    list [destroy .m2] [destroy .m3] [destroy .m1]
 } -returnCodes ok -result {{} {} {}}
 test menu-6.10 {TkDestroyMenu} -setup {
     deleteWindows
 } -body {
     menu .m1
     .m1 clone .m2
     .m1 clone .m3
-	list [destroy .m3] [destroy .m1]
+    list [destroy .m3] [destroy .m1]
 } -returnCodes ok -result {{} {}}
 test menu-6.11 {TkDestroyMenu} -setup {
     deleteWindows
 } -body {
     menu .m1
     .m1 clone .m2
     .m1 clone .m3
     .m1 clone .m4
-	list [destroy .m2] [destroy .m1]
+    list [destroy .m2] [destroy .m1]
 } -returnCodes ok -result {{} {}}
 test menu-6.12 {TkDestroyMenu} -setup {
     deleteWindows
 } -body {
     menu .m1
     .m1 clone .m2
     .m1 clone .m3
     .m1 clone .m4
-	list [destroy .m3] [destroy .m1]
+    list [destroy .m3] [destroy .m1]
 } -returnCodes ok -result {{} {}}
 test menu-6.13 {TkDestroyMenu} -setup {
     deleteWindows
 } -body {
     menu .m1
     .m1 clone .m2
     .m1 clone .m3
     .m1 clone .m4
-	list [destroy .m4] [destroy .m1]
+    list [destroy .m4] [destroy .m1]
 } -returnCodes ok -result {{} {}}
 test menu-6.14 {TkDestroyMenu} -setup {
-	destroy .m1
+    destroy .m1
 } -body {
     menu .m1
     . configure -menu .m1
     list [destroy .m1] [. configure -menu ""]
 } -returnCodes ok -result {{} {}}
@@ -2834,11 +2834,11 @@
     menu .m1
     .m1 add command -label "active"
     .m1 add command -label "test2"
     .m1 add command -label "test3"
     .m1 activate 2
-    .m1 entrycget none -label
+    .m1 entrycget {} -label
 } -cleanup {
     deleteWindows
 } -result {}
 #test menu-13.7 - Need to add @test here.
 test menu-13.7 {TkGetMenuIndex} -setup {
@@ -3115,13 +3115,13 @@
     .menubar add cascade -label Test -underline 0 -menu .menubar.test
     menu .menubar.test.cascade -tearoff 0
     .menubar.test.cascade add command -label SubItem -command "puts SubItemSelected"
     . configure -menu .menubar
     list [catch {.menubar.test add cascade -label SubMenu \
-		-menu .menubar.test.cascade}] \
-		[info commands .\#menubar.\#menubar\#test.\#menubar\#test\#cascade] \
-		[. configure -menu ""]
+            -menu .menubar.test.cascade}] \
+            [info commands .\#menubar.\#menubar\#test.\#menubar\#test\#cascade] \
+            [. configure -menu ""]
 } -cleanup {
     deleteWindows
 } -result {0 .#menubar.#menubar#test.#menubar#test#cascade {}}
 
 
@@ -3130,11 +3130,11 @@
 } -body {
     catch {unset foo}
     menu .m1
     set foo "hello"
     list [.m1 add checkbutton -variable foo -onvalue hello -offvalue goodbye] \
-		[unset foo]
+            [unset foo]
 } -cleanup {
     deleteWindows
 } -result {{} {}}
 # menu-17.2 - Don't know how to generate the flags in the if
 test menu-17.2 {MenuVarProc} -setup {
@@ -3141,11 +3141,11 @@
     deleteWindows
 } -body {
     catch {unset foo}
     menu .m1
     list [.m1 add checkbutton -variable foo -onvalue hello -offvalue goodbye] \
-		[set foo ""]
+            [set foo ""]
 } -cleanup {
     deleteWindows
 } -result {{} {}}
 test menu-17.3 {MenuVarProc} -setup {
     deleteWindows
@@ -3152,31 +3152,31 @@
 } -body {
     catch {unset foo}
     menu .m1
     set foo "hello"
     list [.m1 add checkbutton -variable foo -onvalue hello -offvalue goodbye] \
-		[set foo "hello"] [unset foo]
+            [set foo "hello"] [unset foo]
 } -cleanup {
     deleteWindows
 } -result {{} hello {}}
 test menu-17.4 {MenuVarProc} -setup {
     deleteWindows
 } -body {
     menu .m1
     set foo "goodbye"
     list [.m1 add checkbutton -variable foo -onvalue hello -offvalue goodbye] \
-		[set foo "hello"] [unset foo]
+            [set foo "hello"] [unset foo]
 } -cleanup {
     deleteWindows
 } -result {{} hello {}}
 test menu-17.5 {MenuVarProc} -setup {
     deleteWindows
 } -body {
     menu .m1
     set foo "hello"
     list [.m1 add checkbutton -variable foo -onvalue hello -offvalue goodbye] \
-		[set foo "goodbye"] [unset foo]
+            [set foo "goodbye"] [unset foo]
 } -cleanup {
     deleteWindows
 } -result {{} goodbye {}}
 test menu-17.6 {MenuVarProc [5d991b822e]} -setup {
     deleteWindows
@@ -3303,11 +3303,11 @@
 test menu-20.5 {CloneMenu} -setup {
     deleteWindows
 } -body {
     menu .m1
     .m1 clone .m2 foo
-} -returnCodes error -result {bad menu type "foo": must be normal, tearoff, or menubar}
+} -returnCodes error -result {bad menu type "foo": must be menubar, normal, or tearoff}
 test menu-20.6 {CloneMenu - hooking up bookeeping ptrs} -setup {
     deleteWindows
 } -body {
     menu .m1
     .m1 clone .m2
@@ -3433,10 +3433,32 @@
     set x [expr {[winfo width .m1] - [.m1 cget -borderwidth] - 1}]
     .m1 index @$x,5
 } -cleanup {
     deleteWindows
 } -result 0
+
+test menu-22.6 {tk_popup on separator entry} -setup {
+    deleteWindows
+} -constraints {x11} -body {
+    menu .m1
+    label .l -text ClickMe!
+    .m1 add command -label "Example 1" -command bell
+    .m1 add command -label "Example 2" -command bell
+    .m1 add separator
+    .m1 add command -label "Example Other" -command "bell;bell"
+    tk_popup .m1 100 100 2
+    set waiting 0
+    tkwait visibility .m1
+    after 333 incr waiting
+    vwait waiting
+    .m1 invoke 4
+    after 333 incr waiting
+    vwait waiting
+    destroy .m1
+} -cleanup {
+    deleteWindows
+} -result {}
 
 test menu-23.1 {RecursivelyDeleteMenu} -setup {
     deleteWindows
 } -body {
     menu .m1
@@ -3479,11 +3501,11 @@
     deleteWindows
 } -body {
     menu .#m
     rename .#m hideme
     list [catch {. configure -menu [menu .m]}] [. configure -menu ""] [destroy .#m] \
-		[destroy .m] [destroy hideme]
+            [destroy .m] [destroy hideme]
 } -result {0 {} {} {} {}}
 
 
 test menu-25.1 {TkSetWindowMenuBar} -setup {
     deleteWindows
@@ -3836,11 +3858,11 @@
 test menu-32.6 {DeleteMenuCloneEntries - reentrancy - crashes tk8.0} -setup {
     deleteWindows
 } -body {
     menu .m1
     .m1 add command -label test \
-		-command ".m1 delete test ; .m1 add command -label test -command \".m1 delete test\"; .m1 delete test"
+            -command ".m1 delete test ; .m1 add command -label test -command \".m1 delete test\"; .m1 delete test"
     .m1 invoke test
 } -cleanup {
     deleteWindows
 } -result {}
 test menu-32.7 {DeleteMenuCloneEntries - one entry} -setup {
@@ -3859,12 +3881,12 @@
     menu .menubar
     . configure -menu .menubar
     menu .menubar.test
     .menubar.test add command -label "hi"
     for {set i 0} {$i < 10} {incr i} {
-		.menubar add cascade -menu .menubar.test -label "Test"
-		.menubar delete Test
+        .menubar add cascade -menu .menubar.test -label "Test"
+        .menubar delete Test
     }
 
     info commands .#menubar*test*
 } -cleanup {
     deleteWindows
@@ -3894,25 +3916,25 @@
 
 
 test menu-33.1 {menu vs command hiding} -setup {
     deleteWindows
 } -body {
-	set l [interp hidden]
+    set l [interp hidden]
     menu .m
     interp hide {} .m
     destroy .m
     set result [list [winfo children .] [interp hidden]]
-	expr {$result eq [list {} $l]}
+    expr {$result eq [list {} $l]}
 } -result 1
 
 # menu-34 MenuInit only called at boot time
 
 # creating menus on two different screens then deleting the
 # menu from the first screen crashes Tk8.3.1
 #
 test menu-34.1 {menus on multiple screens - crashes tk8.3.1, Bug 5454} -constraints {
-	altDisplay
+    altDisplay
 } -setup {
     deleteWindows
 } -body {
     toplevel .one
     menu .one.m
@@ -3945,11 +3967,11 @@
 } -cleanup {
     destroy .m
 } -result {1 {a menubar menu cannot be posted}}
 
 test menu-38.1 {Can't dismiss ttk::menubutton menu until mouse has hovered over it - bug fa32290898} -setup {
-} -constraints {userInteraction} -body {
+} -constraints {x11} -body {
     toplevel .top
     ttk::menubutton .top.mb -text "Some menu";
     menu .top.mb.m;
     .top.mb.m add command -label "Item 1";
     .top.mb.m add command -label "Item 2";
@@ -3956,12 +3978,11 @@
     .top.mb configure -menu .top.mb.m;
     pack .top.mb
     update
     # simulate mouse click on the menubutton, which posts its menu
     event generate .top.mb <Button-1> -warp 1
-    update
-    after 50
+    controlPointerWarpTiming
     event generate .top.mb <ButtonRelease-1>
     update
     # simulate mouse click on the menu again, i.e. without
     # entering/leaving the posted menu
     event generate .top.mb <Button-1>
@@ -3973,10 +3994,18 @@
     winfo ismapped .top.mb.m
 } -cleanup {
     destroy .top.mb.m .top.m .top
 } -result 0
 
+test menu-39.1 {empty -type - bug be8f5b9fc2} -setup {
+    catch {destroy .m}
+} -body {
+    menu .m -type {}
+} -cleanup {
+    destroy .m
+} -returnCodes error -result {ambiguous type "": must be menubar, normal, or tearoff}
+
 
 # cleanup
 imageFinish
 deleteWindows
 cleanupTests

Index: tests/menuDraw.test
==================================================================
--- tests/menuDraw.test
+++ tests/menuDraw.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test drawing of menus in Tk.  It is
 # organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1996-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
@@ -130,11 +130,11 @@
     menu .m1
     .m1 add command -label "foo"
     .m1 entryconfigure 1 -state foo
 } -cleanup {
     deleteWindows
-} -returnCodes error -result {bad state "foo": must be active, normal, or disabled}
+} -returnCodes error -result {bad state "foo": must be active, disabled, or normal}
 test menuDraw-6.7 {TkMenuConfigureEntryDrawOptions - tkfont specified} -setup {
     deleteWindows
 } -body {
     menu .m1
     .m1 add command -label "foo" -font "Courier 12"
@@ -556,14 +556,14 @@
     deleteWindows
 } -body {
     menu .m1
     .m1 add command -label "foo" -state active
     set tearoff [tk::TearOffMenu .m1 40 40]
-    $tearoff index active
+    expr {[$tearoff index active]<0}
 } -cleanup {
     deleteWindows
-} -result none
+} -result 1
 test menuDraw-15.3 {TkPostTearoffMenu - post command} -setup {
     deleteWindows
 } -body {
     catch {unset foo}
     menu .m1 -postcommand "set foo .m1"

Index: tests/menubut.test
==================================================================
--- tests/menubut.test
+++ tests/menubut.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test menubuttons in Tk.  It is
 # organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 # XXX This test file is woefully incomplete right now.  If any part
 # XXX of a procedure has tests then the whole procedure has tests,
 # XXX but many procedures have no tests.
@@ -292,11 +292,11 @@
 } -cleanup {
     .mb configure -underline [lindex [.mb configure -underline] 3]
 } -result 5
 test menubutton-1.55 {configuration options} -body {
     .mb configure -underline 3p
-} -returnCodes error -result {expected integer but got "3p"}
+} -returnCodes error -result {bad index "3p": must be integer?[+-]integer?, end?[+-]integer?, or ""}
 test menubutton-1.56 {configuration options} -body {
     .mb configure -width 402
     .mb cget -width
 } -cleanup {
     .mb configure -width [lindex [.mb configure -width] 3]

Index: tests/message.test
==================================================================
--- tests/message.test
+++ tests/message.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out the "message" command
 # of Tk.  It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-2000 by Ajuba Solutions.
+# Copyright © 1998-2000 Ajuba Solutions.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 tcltest::loadTestedCommands

Index: tests/msgbox.test
==================================================================
--- tests/msgbox.test
+++ tests/msgbox.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test out Tk's "tk_messageBox" command.
 # It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands

Index: tests/obj.test
==================================================================
--- tests/obj.test
+++ tests/obj.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test new object types in Tk.
 # It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv

Index: tests/oldpack.test
==================================================================
--- tests/oldpack.test
+++ tests/oldpack.test
@@ -2,11 +2,11 @@
 # "pack" command (before release 3.3).  It is organized in the
 # standard fashion for Tcl tests.
 #
 # Copyright © 1991-1994 The Regents of the University of California.
 # Copyright © 1994 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
@@ -30,11 +30,11 @@
 label .pack.violet.l -text P -bd 2 -relief raised
 place .pack.violet.l -relwidth 1.0 -relheight 1.0
 
 if {![catch {pack ap .pack .pack.red top}]} {
 
-# Don't execute any of this file if Tk is compiled with -DTCL_NO_DEPRECATED
+# Don't execute any of this file if Tk is compiled with -DTK_NO_DEPRECATED
 
 
 test oldpack-1.1 {basic positioning} -body {
     #pack ap .pack .pack.red top
     update

Index: tests/option.test
==================================================================
--- tests/option.test
+++ tests/option.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out the option-handling facilities
 # of Tk.  It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1991-1993 The Regents of the University of California.
 # Copyright © 1994 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv

Index: tests/pack.test
==================================================================
--- tests/pack.test
+++ tests/pack.test
@@ -1,19 +1,19 @@
 # This file is a Tcl script to test out the "pack" command of Tk.  It is
 # organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1993 The Regents of the University of California.
 # Copyright © 1994 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 namespace import -force tcltest::test
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 # Create some test windows.
 
 destroy .pack
@@ -1261,11 +1261,11 @@
 } -returnCodes error -result {bad ipady value "5 5": must be positive screen distance}
 test pack-12.29 {command options and errors} -setup {
     pack forget .pack.a .pack.b .pack.c .pack.d
 } -body {
     pack .pack.a -side bac
-} -returnCodes error -result {bad side "bac": must be top, bottom, left, or right}
+} -returnCodes error -result {bad side "bac": must be bottom, left, right, or top}
 test pack-12.30 {command options and errors} -setup {
     pack forget .pack.a .pack.b .pack.c .pack.d
 } -body {
     pack .pack.a -lousy bac
 } -returnCodes error -result {bad option "-lousy": must be -after, -anchor, -before, -expand, -fill, -in, -ipadx, -ipady, -padx, -pady, or -side}
@@ -1532,11 +1532,11 @@
     winfo manager .pack.a
     winfo geometry .pack.a
     pack info .pack.a
 } -returnCodes error -result {window ".pack.a" isn't packed}
 
-if {[tk windowingsystem] == "win32"} {
+if {[tk windowingsystem] ne "aqua"} {
     proc packUpdate {} {
 	update
     }
 } else {
     proc packUpdate {} {

Index: tests/panedwindow.test
==================================================================
--- tests/panedwindow.test
+++ tests/panedwindow.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test entry widgets in Tk.  It is
 # organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
@@ -120,13 +120,13 @@
     .p configure -proxyrelief groove
     list [lindex [.p configure -proxyrelief] 4] [.p cget -proxyrelief]
 } -cleanup {
     .p configure -proxyrelief [lindex [.p configure -proxyrelief] 3]
 } -result {groove groove}
-test panedwindow-1.24 {configuration options: -proxyrelief (bad)} -body {
+test panedwindow-1.24 {configuration options: -proxyrelief (bad)} -constraints needsTcl87 -body {
     .p configure -proxyrelief 1.5
-} -returnCodes error -result {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}
+} -returnCodes error -result {bad relief "1.5": must be flat, groove, raised, ridge, solid, sunken, or ""}
 test panedwindow-1.25 {configuration options: -relief (good)} -body {
     .p configure -relief groove
     list [lindex [.p configure -relief] 4] [.p cget -relief]
 } -cleanup {
     .p configure -relief [lindex [.p configure -relief] 3]

Index: tests/pkgconfig.test
==================================================================
--- tests/pkgconfig.test
+++ tests/pkgconfig.test
@@ -5,11 +5,11 @@
 # built-in commands.  Sourcing this file into Tk runs the tests and
 # generates output for errors.  No output means no errors were found.
 #
 # Copyright © 1991-1993 The Regents of the University of California.
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # Copyright © 2017 Stuart Cassoff <stwo@users.sourceforge.net>
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
@@ -16,27 +16,26 @@
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 
-testConstraint nodeprecated [expr {"nodeprecated" ni [tk::pkgconfig list]}]
-
-test pkgconfig-1.1 {query keys} nodeprecated {
+test pkgconfig-1.1 {query keys} -constraints {nonwin} -body {
     lsort [::tk::pkgconfig list]
-} [list \
-    64bit bindir,install bindir,runtime debug demodir,install demodir,runtime \
-    docdir,install docdir,runtime fontsystem includedir,install includedir,runtime \
-    libdir,install libdir,runtime mem_debug optimized profiled \
-    scriptdir,install scriptdir,runtime threaded \
+} -match glob -result [list \
+    *bindir,install bindir,runtime *demodir,install \
+    demodir,runtime*docdir,install docdir,runtime fontsystem \
+    includedir,install includedir,runtime \
+    libdir,install libdir,runtime*\
+    scriptdir,install scriptdir,runtime*\
 ]
 test pkgconfig-1.2 {query keys multiple times} {
     string compare [::tk::pkgconfig list] [::tk::pkgconfig list]
 } 0
 test pkgconfig-1.3 {query value multiple times} {
     string compare \
-	    [::tk::pkgconfig get 64bit] \
-	    [::tk::pkgconfig get 64bit]
+	    [::tk::pkgconfig get fontsystem] \
+	    [::tk::pkgconfig get fontsystem]
 } 0
 
 
 test pkgconfig-2.0 {error: missing subcommand} {
     catch {::tk::pkgconfig} msg

Index: tests/place.test
==================================================================
--- tests/place.test
+++ tests/place.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test out the "place" command.  It is
 # organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1995 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -11,11 +11,11 @@
 tcltest::loadTestedCommands
 
 # Used for constraining memory leak tests
 testConstraint memory [llength [info commands memory]]
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 # XXX - This test file is woefully incomplete.  At present, only a
 # few of the features are tested.
 
@@ -77,11 +77,11 @@
 } -result 60
 
 
 test place-3.1 {ConfigureContent procedure, -relheight option} -body {
     place .t.f2 -relheight abcd
-} -returnCodes error -result {expected floating-point number but got "abcd"}
+} -returnCodes error -result {expected floating-point number or "" but got "abcd"}
 test place-3.2 {ConfigureContent procedure, -relheight option} -setup {
     place forget .t.f2
 } -body {
     place .t.f2 -in .t.f -relheight .5
     update
@@ -142,11 +142,11 @@
     place .t.f3 -in .t.f1
 } -returnCodes error -result {can't put ".t.f3" inside ".t.f1": would cause management loop}
 
 test place-5.1 {ConfigureContent procedure, -relwidth option} -body {
     place .t.f2 -relwidth abcd
-} -returnCodes error -result {expected floating-point number but got "abcd"}
+} -returnCodes error -result {expected floating-point number or "" but got "abcd"}
 test place-5.2 {ConfigureContent procedure, -relwidth option} -setup {
     place forget .t.f2
 } -body {
     place .t.f2 -in .t.f -relwidth .5
     update
@@ -259,11 +259,11 @@
     place .t.f2 -width {} -relwidth {} -height {} -relheight {}
     update
     list [winfo width .t.f2] [winfo height .t.f2]
 } -result {30 60}
 
-if {[tk windowingsystem] == "win32"} {
+if {[tk windowingsystem] ne "aqua"} {
     proc placeUpdate {} {
 	update
     }
 } else {
     proc placeUpdate {} {
@@ -414,11 +414,11 @@
 } -body {
     frame .foo
     place .foo -bordermode j
 } -cleanup {
     destroy .foo
-} -returnCodes error -result {bad bordermode "j": must be inside, outside, or ignore}
+} -returnCodes error -result {bad bordermode "j": must be inside, ignore, or outside}
 test place-10.4 {ConfigureContent} -setup {
     destroy .foo
 } -body {
     frame .foo
     place configure .foo -x 0 -y
@@ -505,20 +505,21 @@
 } -body {
     # Test all manners of forgetting content
     frame .f
     frame .f.f
     stress {
-        place .f.f -x [expr {1 + 1}] -y [expr {2 + 2}]
-        place forget .f.f
-    } {
-        place .f.f -x [expr {1 + 1}] -y [expr {2 + 2}]
-        pack .f.f
-    } {
-        place .f.f -x [expr {1 + 1}] -y [expr {2 + 2}]
-        destroy .f
-        frame .f
-        frame .f.f
+	place .f.f -x [expr {1 + 1}] -y [expr {2 + 2}]
+	place forget .f.f
+    } {
+	place .f.f -x [expr {1 + 1}] -y [expr {2 + 2}]
+	pack .f.f
+	update; # Needed because of TIP #518, handle <<NoManagedChild>> event.
+    } {
+	place .f.f -x [expr {1 + 1}] -y [expr {2 + 2}]
+	destroy .f
+	frame .f
+	frame .f.f
     }
 } -cleanup {
     destroy .f
     rename getbytes {}
     rename stress {}

Index: tests/raise.test
==================================================================
--- tests/raise.test
+++ tests/raise.test
@@ -3,11 +3,11 @@
 # stacking order.  It is organized in the standard fashion
 # for Tcl tests.
 #
 # Copyright © 1993-1994 The Regents of the University of California.
 # Copyright © 1994 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands

Index: tests/safe.test
==================================================================
--- tests/safe.test
+++ tests/safe.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test the Safe Tk facility. It is organized in
 # the standard fashion for Tk tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1995 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands

Index: tests/safePrimarySelection.test
==================================================================
--- tests/safePrimarySelection.test
+++ tests/safePrimarySelection.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test entry widgets in Tk.  It is
 # organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -61,11 +61,11 @@
     catch {{*}$TkLoadCmd $name}
 }
 
 
 set ::_test_tmp::script {
-    package require Tk
+    package require tk
     namespace eval ::_test_tmp {}
 
     proc ::_test_tmp::getPrimarySelection {} {
         if {[catch {::tk::GetSelection . PRIMARY} sel]} {
             set sel {}

Index: tests/scale.test
==================================================================
--- tests/scale.test
+++ tests/scale.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out the "scale" command
 # of Tk.  It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -1394,10 +1394,29 @@
     unset ::error
     rename bgerror {}
     destroy .s
 } -result {0 {}}
 
+test scale-18.4 {Bug [415415ffff] - Long callback: One click -> Several steps} -setup {
+    catch {destroy .s}
+    scale .s -from 0 -to 5 -resolution 1 -variable x1 -orient horizontal -length 100 \
+            -command longCmd -repeatdelay 300
+    pack .s
+    update
+    proc longCmd {unused} {
+      after 500  ; # larger than -repeatdelay
+    }
+} -body {
+    foreach {x y} [.s coord 50] {}
+    event generate .s <Button-1> -x $x -y $y
+    update
+    event generate .s <ButtonRelease-1> -x $x -y $y
+    update
+    set x1
+} -cleanup {
+    destroy .s
+} -result {1}
 
 test scale-19 {Bug [3529885fff] - Click in through goes in wrong direction} \
     -setup {
         catch {destroy .s}
         catch {destroy .s1 .s2 .s3 .s4}
@@ -1471,29 +1490,31 @@
     destroy .s
 } -result {10 -1}
 test scale-20.4 {Bug [2262543fff] - Scale widget unexpectedly fires command callback, case 4} -setup {
     catch {destroy .s}
     set res {}
-    set commandedVar -1
 } -body {
     scale .s -from 1 -to 50 -command {set commandedVar}
-    .s set 10
     pack .s
+    update idletasks
+    .s set 10
     set timeout [after 500 {set $commandedVar "timeout"}]
+    set commandedVar -1
     vwait commandedVar  ; # -command callback shall fire
     set res [list [.s get] $commandedVar]
 } -cleanup {
-    destroy .s
     after cancel $timeout
+    destroy .s
 } -result {10 10}
 test scale-20.5 {Bug [2262543fff] - Scale widget unexpectedly fires command callback, case 5} -setup {
     catch {destroy .s}
     set res {}
     set commandedVar -1
 } -body {
     scale .s -from 1 -to 50
     pack .s
+    update idletasks
     .s set 10
     .s configure -command {set commandedVar}
     update  ; # -command callback shall NOT fire
     set res [list [.s get] $commandedVar]
 } -cleanup {
@@ -1504,10 +1525,11 @@
     set res {}
     set commandedVar -1
 } -body {
     scale .s -from 1 -to 50
     pack .s
+    update idletasks
     .s configure -command {set commandedVar}
     .s set 10
     set timeout [after 500 {set $commandedVar "timeout"}]
     vwait commandedVar  ; # -command callback shall fire
     set res [list [.s get] $commandedVar]
@@ -1520,10 +1542,11 @@
     set res {}
     set commandedVar -1
 } -body {
     scale .s -from 1 -to 50 -command {set commandedVar}
     pack .s
+    update idletasks
     .s set 10
     set timeout [after 500 {set $commandedVar "timeout"}]
     vwait commandedVar  ; # -command callback shall fire
     set res [list [.s get] $commandedVar]
 } -cleanup {
@@ -1536,10 +1559,11 @@
     set commandedVar -1
     set scaleVar 7
 } -body {
     scale .s -from 1 -to 50 -variable scaleVar -command {set commandedVar}
     pack .s
+    update idletasks
     .s set 10
     set timeout [after 500 {set $commandedVar "timeout"}]
     vwait commandedVar  ; # -command callback shall fire
     set res [list [.s get] $commandedVar]
 } -cleanup {

Index: tests/scrollbar.test
==================================================================
--- tests/scrollbar.test
+++ tests/scrollbar.test
@@ -2,20 +2,19 @@
 # the "scrollbar" command of Tk.  It is organized in the standard
 # fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
-testConstraint nodeprecated [expr {"nodeprecated" ni [tk::pkgconfig list]}]
 
 proc scroll args {
     global scrollInfo
     set scrollInfo $args
 }
@@ -316,11 +315,11 @@
 } 0
 destroy .t
 test scrollbar-3.43 {ScrollbarWidgetCmd procedure, "get" option} {
     list [catch {.s get a} msg] $msg
 } {1 {wrong # args: should be ".s get"}}
-test scrollbar-3.44 {ScrollbarWidgetCmd procedure, "get" option} nodeprecated {
+test scrollbar-3.44 {ScrollbarWidgetCmd procedure, "get" option} deprecated {
     .s set 100 10 13 14
     .s get
 } {100 10 13 14}
 test scrollbar-3.45 {ScrollbarWidgetCmd procedure, "get" option} {
     .s set 0.6 0.8
@@ -401,31 +400,31 @@
     foreach element [.s get] {
 	lappend result [format %.1f $element]
     }
     set result
 } {0.4 0.4}
-test scrollbar-3.64 {ScrollbarWidgetCmd procedure, "set" option} nodeprecated {
+test scrollbar-3.64 {ScrollbarWidgetCmd procedure, "set" option} deprecated {
     list [catch {.s set abc def ghi jkl} msg] $msg
 } {1 {expected integer but got "abc"}}
-test scrollbar-3.65 {ScrollbarWidgetCmd procedure, "set" option} nodeprecated {
+test scrollbar-3.65 {ScrollbarWidgetCmd procedure, "set" option} deprecated {
     list [catch {.s set 1 def ghi jkl} msg] $msg
 } {1 {expected integer but got "def"}}
-test scrollbar-3.66 {ScrollbarWidgetCmd procedure, "set" option} nodeprecated {
+test scrollbar-3.66 {ScrollbarWidgetCmd procedure, "set" option} deprecated {
     list [catch {.s set 1 2 ghi jkl} msg] $msg
 } {1 {expected integer but got "ghi"}}
-test scrollbar-3.67 {ScrollbarWidgetCmd procedure, "set" option} nodeprecated {
+test scrollbar-3.67 {ScrollbarWidgetCmd procedure, "set" option} deprecated {
     list [catch {.s set 1 2 3 jkl} msg] $msg
 } {1 {expected integer but got "jkl"}}
-test scrollbar-3.68 {ScrollbarWidgetCmd procedure, "set" option} nodeprecated {
+test scrollbar-3.68 {ScrollbarWidgetCmd procedure, "set" option} deprecated {
     .s set -10 50 20 30
     .s get
 } {0 50 0 0}
-test scrollbar-3.69 {ScrollbarWidgetCmd procedure, "set" option} nodeprecated {
+test scrollbar-3.69 {ScrollbarWidgetCmd procedure, "set" option} deprecated {
     .s set 100 -10 20 30
     .s get
 } {100 0 20 30}
-test scrollbar-3.70 {ScrollbarWidgetCmd procedure, "set" option} nodeprecated {
+test scrollbar-3.70 {ScrollbarWidgetCmd procedure, "set" option} deprecated {
     .s set 100 50 30 20
     .s get
 } {100 50 30 30}
 test scrollbar-3.71 {ScrollbarWidgetCmd procedure, "set" option} {
     list [catch {.s set 1 2 3} msg] $msg
@@ -700,11 +699,11 @@
     event generate .s <MouseWheel> -delta -120
     after 200 {set eventprocessed 1} ; vwait eventprocessed
     .t index @0,0
 } -cleanup {
     destroy .t .s
-} -result {5.0}
+} -result {4.0}
 
 test scrollbar-10.2 {<MouseWheel> event on scrollbar} -setup {
     destroy .t .s
 } -body {
     pack [text .t -xscrollcommand {.s set} -wrap none] -side top
@@ -715,12 +714,12 @@
     event generate .s <Shift-MouseWheel> -delta -120
     after 200 {set eventprocessed 1} ; vwait eventprocessed
     .t index @0,0
 } -cleanup {
     destroy .t .s
-} -result {1.4}
-test scrollbar-10.2.3 {<MouseWheel> event on horizontal scrollbar} -setup {
+} -result {1.3}
+test scrollbar-10.3 {<MouseWheel> event on horizontal scrollbar} -setup {
     destroy .t .s
 } -body {
     pack [text .t -xscrollcommand {.s set} -wrap none] -side top
     for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "}
     pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top
@@ -729,11 +728,11 @@
     event generate .s <MouseWheel> -delta -120
     after 200 {set eventprocessed 1} ; vwait eventprocessed
     .t index @0,0
 } -cleanup {
     destroy .t .s
-} -result {1.4}
+} -result {1.3}
 
 test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destruction} -body {
     proc destroy_scrollbar {} {
         if {[winfo exists .top.s]} {
             destroy .top.s

Index: tests/select.test
==================================================================
--- tests/select.test
+++ tests/select.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out Tk's selection management code,
 # especially the "selection" command. It is organized in the standard fashion
 # for Tcl tests.
 #
 # Copyright © 1994 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 #
 # Note: Multiple display selection handling will only be tested if the
 # environment variable TK_ALT_DISPLAY is set to an alternate display.
@@ -21,11 +21,11 @@
 if {![catch {selection get -selection CLIPBOARD_MANAGER -type TARGETS}]} {
     if {"SAVE_TARGETS" in [selection get -selection CLIPBOARD_MANAGER -type TARGETS]} {
         testConstraint cliboardManagerPresent 1
     }
 }
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 
 global longValue selValue selInfo
 
 set selValue {}
 set selInfo {}

Index: tests/send.test
==================================================================
--- tests/send.test
+++ tests/send.test
@@ -2,22 +2,23 @@
 # other procedures in the file tkSend.c.  It is organized in the
 # standard fashion for Tcl tests.
 #
 # Copyright © 1994 Sun Microsystems, Inc.
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
-# Copyright © 2001 by ActiveState Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
+# Copyright © 2001 ActiveState Corporation.
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 
 testConstraint xhost [llength [auto_execok xhost]]
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
+testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 # Compute a script that will load Tk into a child interpreter.
 
 foreach pkg [info loaded] {
     if {[lindex $pkg 1] == "Tk"} {
@@ -295,11 +296,11 @@
 "open bogus_file_name"
     invoked from within
 "if 1 {open bogus_file_name}"
     invoked from within
 "send t_s_1 {if 1 {open bogus_file_name}}"} {POSIX ENOENT {no such file or directory}}}
-test send-8.16 {Tk_SendCmd procedure, bogusCommWindow} {secureserver testsend failsOnUbuntu} {
+test send-8.16 {Tk_SendCmd procedure, bogusCommWindow} {secureserver testsend failsOnUbuntu failsOnXQuarz} {
     testsend prop root InterpRegistry "10234 bogus\n"
     set result [list [catch {send bogus bogus command} msg] $msg]
     winfo interps
     tk appname tktest
     set result
@@ -521,14 +522,14 @@
     set x [list [catch {send t_s_3 exit} msg] $msg]
     cleanupbg
     set x
 } {1 {target application died}}
 
-test send-11.1 {AppendPropCarefully and AppendErrorProc procedures} {secureserver testsend} {
+test send-11.1 {AppendPropCarefully and AppendErrorProc procedures} -constraints {secureserver testsend} -body {
     testsend prop root InterpRegistry "0x21447 dummy\n"
-    list [catch {send dummy foo} msg] $msg
-} {1 {no application named "dummy"}}
+    send dummy foo
+} -returnCodes 1 -match regexp -result {^(target application died|no application named "dummy")$}
 test send-11.2 {AppendPropCarefully and AppendErrorProc procedures} {secureserver testsend} {
     testsend prop comm Comm "c\n-r0x123 44\n-n tktest\n-s concat a b c\n"
     update
 } {}
 

Index: tests/spinbox.test
==================================================================
--- tests/spinbox.test
+++ tests/spinbox.test
@@ -1,19 +1,19 @@
 # This file is a Tcl script to test spinbox widgets in Tk.  It is
 # organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnUbuntuNoXft [expr {[testConstraint failsOnUbuntu] || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))}]
 
 # For xscrollcommand
 set scrollInfo {}
 proc scroll args {
@@ -917,18 +917,18 @@
     .e configure -values {bad {}list}
 } -cleanup {
     destroy .e
 } -returnCodes {error} -result {list element in braces followed by "list" instead of space}
 
-test spinbox-1.80 {configuration option: "vcmd"} -setup {
+test spinbox-1.80 {configuration option: "validatecommand"} -setup {
         spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \
         -relief sunken
     pack .e
     update
 } -body {
-    .e configure -vcmd "a command"
-    .e cget -vcmd
+    .e configure -validatecommand "a command"
+    .e cget -validatecommand
 } -cleanup {
     destroy .e
 } -result {a command}
 
 test spinbox-1.81 {configuration option: "width"} -setup {
@@ -1450,11 +1450,11 @@
     update
 } -body {
     .e scan foobar 20
 } -cleanup {
     destroy .e
-} -returnCodes error -result {bad scan option "foobar": must be mark or dragto}
+} -returnCodes error -result {bad scan option "foobar": must be dragto or mark}
 test spinbox-3.45 {SpinboxWidgetCmd procedure, "scan" widget command} -setup {
     spinbox .e
     pack .e
     update
 } -body {
@@ -1873,11 +1873,11 @@
 } -body {
     .e insert end "This is quite a long text string, so long that it "
     .e insert end "runs off the end of the window quite a bit."
     .e xview 0
     update
-    .e xview -1
+    .e xview {}
     .e index @0
 } -cleanup {
     destroy .e
 } -result 0
 test spinbox-3.80 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
@@ -2394,11 +2394,11 @@
 } -body {
     .e configure -textvariable contents -xscrollcommand scroll
     .e insert 0 abcde
     update idletasks
     set timeout [after 500 {set scrollInfo {-1000000 -1000000}}]
-    .e delete -1 2
+    .e delete {} 2
     vwait scrollInfo
     list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
 } -cleanup {
     destroy .e
     after cancel $timeout
@@ -3123,11 +3123,11 @@
         -font {Courier -12}
     pack .e
     .e insert 0 012345678901234567890
     .e xview 4
     update
-    .e index -1
+    .e index {}
 } -cleanup {
     destroy .e
 } -result 0
 test spinbox-13.24 {GetSpinboxIndex procedure} -body {
     spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \

ADDED   tests/systray.test
Index: tests/systray.test
==================================================================
--- /dev/null
+++ tests/systray.test
@@ -0,0 +1,223 @@
+# This file is a Tcl script to test systray and sysnotify features in Tk.
+# It is organized in the standard fashion for Tcl tests.
+#
+# Copyright © 2020 Kevin Walzer/WordTech Communications LLC.
+# Copyright © 2020 Francois Vogel.
+# All rights reserved.
+
+package require tcltest 2.2
+namespace import ::tcltest::*
+eval tcltest::configure $argv
+tcltest::loadTestedCommands
+
+test systray-1 {systray icon creation, all options} -setup {
+    image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+} -body {
+    tk systray create -image _book -text "Systray sample" \
+            -button1 {puts "button 1 click"} -button3 {puts "button 3 click"}
+} -cleanup {
+    tk systray destroy
+    image delete _book
+} -result {}
+
+test systray-2 {systray create, argument checking} -body {
+    tk systray create
+} -returnCodes {error} -result {missing required option "-image"}
+
+test systray-3 {systray create, argument checking} -body {
+    tk systray create -text Hell
+} -returnCodes {error} -result {missing required option "-image"}
+
+test systray-4 {systray create, argument checking} -setup {
+    image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+} -body {
+    tk systray create -image _book -gorp invalidOption
+} -returnCodes {error} -result {unknown option "-gorp": must be -image, -text, -button1 or -button3}
+
+test systray-5 {systray icon creation, only required option present} -setup {
+    image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+} -body {
+    tk systray create -image _book
+} -cleanup {
+    tk systray destroy
+    image delete _book
+} -result {}
+
+test systray-6 {systray icon creation, some options present} -setup {
+    image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+} -body {
+    tk systray create -image _book -button3 {puts b3}
+} -cleanup {
+    tk systray destroy
+    image delete _book
+} -result {}
+
+test systray-7 {systray icon, all parameters modification, introspection} -setup {
+    image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+    image create photo _page -data R0lGODlhCwAPAKIAAP//////AMDAwICAgAAA/wAAAAAAAAAAACwAAAAACwAPAAADMzi6CzAugiAgDGE68aB0RXgRJBFVX0SNpQlUWfahQOvSsgrX7eZJMlQMWBEYj8iQchlKAAA7
+} -body {
+    tk systray create -image _book -text "Systray icon text"
+    tk systray configure -image _page
+    tk systray configure -text "Another text for my icon"
+    tk systray configure -button1 {set a 1}
+    tk systray configure -button3 {set b 2}
+    tk systray configure
+} -cleanup {
+    tk systray destroy
+    image delete _book
+    image delete _page
+} -result {-image _page -text {Another text for my icon} -button1 {set a 1} -button3 {set b 2}}
+
+test systray-8 {systray icon, single parameter modification, introspection} -setup {
+    image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+} -body {
+    tk systray create -image _book -text "Systray icon text" -button1 {puts b1}
+    tk systray configure -button1 {set a 1}
+    tk systray configure -button1
+} -cleanup {
+    tk systray destroy
+    image delete _book
+} -result {set a 1}
+
+test systray-9 {systray icon, several parameters modification at once, introspection} -setup {
+    image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+} -body {
+    tk systray create -image _book -text "Systray icon text" -button1 {puts b1}
+    tk systray configure -button1 {set a 1} -text NewText
+    list [tk systray configure -button1] [tk systray configure -text]
+} -cleanup {
+    tk systray destroy
+    image delete _book
+} -result {{set a 1} NewText}
+
+test systray-10 {configure non-existing systray icon} -setup {
+    catch {tk systray destroy}
+} -body {
+    tk systray configure
+} -returnCodes {error} -result {systray not created}
+
+test systray-11 {destroy non-existing systray icon} -setup {
+    catch {tk systray destroy}
+} -body {
+    tk systray destroy
+} -returnCodes {error} -result {systray not created}
+
+test systray-12 {destroy systray icon works} -setup {
+    image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+} -body {
+    tk systray create -image _book
+    tk systray destroy
+    tk systray create -image _book
+} -result {}
+
+test systray-13 {systray icon creation, attempt to create more than one in an interp} -setup {
+    image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+} -body {
+    tk systray create -image _book
+    tk systray create -image _book
+} -cleanup {
+    tk systray destroy
+    image delete _book
+} -returnCodes {error} -result {only one system tray icon supported per interpeter}
+
+test systray-14 {systray icon creation, create one per interp, visibiliy checks} -setup {
+    image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+} -body {
+    tk systray create -image _book -text "first interp"
+    interp create second
+    # load Tk into the 'second' interp
+    foreach pkg [info loaded] {
+        if {[lindex $pkg 1] == "Tk"} {
+        set loadTk "load $pkg"
+        break
+        }
+    }
+    eval $loadTk second
+    # create the icon in the 'second' interp
+    second eval {
+        # should trigger an error: image _book unknown in 'second' interp'
+        # image from higer interp should not be visible by 'tk systray'
+        tk systray create -image _book -text "second interp"
+    }
+} -cleanup {
+    tk systray destroy
+    image delete _book
+    interp delete second
+} -returnCodes {error} -result {image "_book" doesn't exist}
+
+test systray-15 {systray icon creation, create one per interp} -setup {
+    image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+} -body {
+    tk systray create -image _book -text "first interp"
+    interp create second
+    # load Tk into the 'second' interp
+    foreach pkg [info loaded] {
+        if {[lindex $pkg 1] == "Tk"} {
+        set loadTk "load $pkg"
+        break
+        }
+    }
+    eval $loadTk second
+    # create the icon in the 'second' interp
+    second eval {
+        image create photo _page -data R0lGODlhCwAPAKIAAP//////AMDAwICAgAAA/wAAAAAAAAAAACwAAAAACwAPAAADMzi6CzAugiAgDGE68aB0RXgRJBFVX0SNpQlUWfahQOvSsgrX7eZJMlQMWBEYj8iQchlKAAA7
+        tk systray create -image _page -text "second interp"
+    }
+} -cleanup {
+    second eval {
+        tk systray destroy
+        image delete _page
+    }
+    interp delete second
+    tk systray destroy
+    image delete _book
+} -result {}
+
+test systray-16 {systray icon creation from a bitmap, on Linux and macOS only} -constraints {
+    nonwin
+} -setup {
+    set data1 {
+        #define foo_width 16
+        #define foo_height 16
+        static unsigned char foo_bits[] = {
+           0xff, 0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
+           0x81, 0x81, 0xff, 0xff, 0xff, 0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
+           0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff, 0xff
+        };
+    }
+    image create bitmap cross -data $data1
+} -body {
+    tk systray create -image cross
+} -cleanup {
+    tk systray destroy
+    image delete cross
+} -result {}
+
+
+test sysnotify-1 {system notification popup} -setup {
+    image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
+    tk systray create -image _book -text "Systray sample"
+} -body {
+    tk sysnotify {Alert} {This is an alert}
+} -cleanup {
+    tk systray destroy
+    image delete _book
+} -result {}
+
+test sysnotify-2.1 {system notification stems from a systray icon on Windows} -constraints {
+    win
+} -setup {
+    catch {tk systray destroy}
+} -body {
+    tk sysnotify {Alert} {This is an alert}
+} -returnCodes {error} -result {must create a system tray icon with the "tk systray" command first}
+test sysnotify-2.2 {system notification is not linked to any systray icon on X11 or aqua} -constraints {
+    nonwin
+} -setup {
+    catch {tk systray destroy}
+} -body {
+    tk sysnotify {Alert} {This is an alert}
+} -result {}
+
+
+cleanupTests

Index: tests/text.test
==================================================================
--- tests/text.test
+++ tests/text.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test the code in the file tkText.c.
 # This file is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1992-1994 The Regents of the University of California.
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
@@ -2250,11 +2250,11 @@
     .t tag configure elide -elide 1
     .t tag add elide 2.2 3.4
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     .t count -displayindices 2.0 3.0
 } -cleanup {
@@ -2273,11 +2273,11 @@
     .t tag configure elide -elide 1
     .t tag add elide 2.2 3.4
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     .t count -displayindices 2.2 3.0
 } -cleanup {
@@ -2298,11 +2298,11 @@
     .t tag add elide 4.0 4.1
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
     .t mark set a 2.2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3, but 'a' is automatically moved to 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     .t count -displayindices a 3.0
 } -cleanup {
@@ -2322,11 +2322,11 @@
     .t tag add elide 2.2 3.4
     .t tag add elide 4.0 4.1
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     .t count -displayindices 2.0 4.2
 } -cleanup {
@@ -2346,11 +2346,11 @@
     .t tag add elide 2.2 3.4
     .t tag add elide 4.0 4.1
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     .t count -displaychars 2.0 3.0
 } -cleanup {
@@ -2370,11 +2370,11 @@
     .t tag add elide 2.2 3.4
     .t tag add elide 4.0 4.1
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     .t count -displaychars 2.2 3.0
 } -cleanup {
@@ -2395,11 +2395,11 @@
     .t tag add elide 4.0 4.1
     .t mark set a 2.2
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3, but 'a' is automatically moved to 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     .t count -displaychars a 3.0
 } -cleanup {
@@ -2419,11 +2419,11 @@
     .t tag add elide 2.2 3.4
     .t tag add elide 4.0 4.1
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     .t count -displaychars 2.0 4.2
 } -cleanup {
@@ -2443,11 +2443,11 @@
     .t tag add elide 2.2 3.4
     .t tag add elide 4.0 4.1
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     .t count -displaychars 2.0 4.2
     list [.t count -indices 2.2 3.0] [.t count 2.2 3.0]
@@ -2469,11 +2469,11 @@
     .t tag add elide 4.0 4.1
     .t mark set a 2.2
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3, but 'a' is automatically moved to 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     list [.t count -indices a 3.0] [.t count a 3.0]
 } -cleanup {
@@ -2493,11 +2493,11 @@
     .t tag add elide 2.2 3.4
     .t tag add elide 4.0 4.1
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     .t count -displaychars 2.0 4.2
     .t count -indices 2.0 4.2
@@ -2518,11 +2518,11 @@
     .t tag add elide 2.2 3.4
     .t tag add elide 4.0 4.1
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     .t count -displaychars 2.0 4.2
     .t count -chars 2.2 3.0
@@ -2544,11 +2544,11 @@
     .t tag add elide 4.0 4.1
     .t mark set a 2.2
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3, but 'a' is automatically moved to 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     .t count -chars a 3.0
 } -cleanup {
@@ -2568,11 +2568,11 @@
     .t tag add elide 2.2 3.4
     .t tag add elide 4.0 4.1
 # Create one visible and one invisible window
     frame .t.w1
     frame .t.w2
-# Creating this window here means that the elidden text
+# Creating this window here means that the elided text
 # now starts at 2.3
     .t window create 2.1 -window .t.w1
     .t window create 3.1 -window .t.w2
     .t count -displaychars 2.0 4.2
     .t count -chars 2.0 4.2
@@ -7490,14 +7490,14 @@
     # the following delete shall not crash
     # (it did before fixing bug 1630262)
     .pt delete 2.0 3.0
     # moreover -startline shall be correct
     # (was wrong before fixing bug 1630262)
-    lappend res [.t cget -start] [.pt cget -start]
+    lappend res [.t cget -start] [.pt cget -start] [.t get @0,0 "@0,0 lineend"]
 } -cleanup {
     destroy .pt
-} -result {4 3}
+} -result {4 3 {Line 5}}
 
 test text-32.4 {peer widget -start, -endline and deletion (bug 1630262)} -setup {
     destroy .t .pt
     set res {}
 } -body {

Index: tests/textBTree.test
==================================================================
--- tests/textBTree.test
+++ tests/textBTree.test
@@ -3,11 +3,11 @@
 # several file with additional tests for other features of text widgets.
 # This file is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1992-1994 The Regents of the University of California.
 # Copyright © 1994 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -255,10 +255,72 @@
     .t delete 1.0 100000.0
     .t insert 1.0 "Line 1\nLine 2\nLine 3"
     .t delete 3.2 3.2
     .t get 1.0 1000000.0
 } -result "Line 1\nLine 2\nLine 3\n"
+test btree-2.22 {deleting into beginning of elided range} -setup {
+    .t delete 1.0 end
+} -body {
+    for {set n 1} {$n <= 10} {incr n} {
+        .t insert end "Line $n\n"
+    }
+    .t tag configure Elided -elide 1
+    .t tag add Elided 6.0 end
+    .t delete 5.0 "5.0 + 8 chars"
+    .t get 4.0 7.0
+} -cleanup {
+    .t tag delete Elided
+    .t delete 1.0 end
+} -result "Line 4\nine 6\nLine 7\n"
+test btree-2.23 {deleting from within elided range} -body {
+    for {set n 1} {$n <= 10} {incr n} {
+        .t insert end "Line $n\n"
+    }
+    .t tag configure Elided -elide 1
+    .t tag add Elided 6.0 8.0
+    .t delete 7.0 9.0
+    .t get 6.0 8.0
+} -cleanup {
+    .t tag delete Elided
+    .t delete 1.0 end
+} -result "Line 6\nLine 9\n"
+test btree-2.24 {deleting whole elided range} -body {
+    for {set n 1} {$n <= 10} {incr n} {
+        .t insert end "Line $n\n"
+    }
+    .t tag configure Elided -elide 1
+    .t tag add Elided 6.0 8.0
+    .t delete 5.0 9.0
+    .t get 4.0 6.0
+} -cleanup {
+    .t tag delete Elided
+    .t delete 1.0 end
+} -result "Line 4\nLine 9\n"
+test btree-2.25 {deleting several elided ranges} -body {
+    for {set n 1} {$n <= 10} {incr n} {
+        .t insert end "Line $n\n"
+    }
+    .t tag configure Elided -elide 1
+    .t tag add Elided 6.0 6.2 6.4 6.5 7.2 7.6
+    .t delete 5.0 9.0
+    .t get 4.0 7.0
+} -cleanup {
+    .t tag delete Elided
+    .t delete 1.0 end
+} -result "Line 4\nLine 9\nLine 10\n"
+test btree-2.26 {deleting first char of elided range} -body {
+    for {set n 1} {$n <= 10} {incr n} {
+        .t insert end "Line $n\n"
+    }
+    .t tag configure Elided -elide 1
+    .t tag add Elided 6.0 end
+    .t delete 6.0 6.1
+    .t get 5.0 7.0
+} -cleanup {
+    .t tag delete Elided
+    .t delete 1.0 end
+} -result "Line 5\nine 6\n"
 
 
 test btree-3.1 {inserting with tags} -body {
     setup
     .t insert 1.0 XXX

Index: tests/textDisp.test
==================================================================
--- tests/textDisp.test
+++ tests/textDisp.test
@@ -1,41 +1,31 @@
 # This file is a Tcl script to test the code in the file tkTextDisp.c.
 # This file is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 namespace import -force tcltest::test
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
-testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
-
-# Platform specific procedure for updating the text widget.
-
-if {[tk windowingsystem] == "aqua"} {
-    proc updateText {} {
-	update idletasks
-    }
-    proc delay {} {
-	update idletasks
-	after 100
-	update idletasks
-    }
-} else {
-    proc updateText {} {
-	update
-    }
-    proc delay {} {
-	update
-	after 100
-	update
-    }
+# Procedures for updating the text widget.  These are isolated here
+# to allow for variations between platforms, but are currently the
+# same for all platforms (see ticket [bfea11a916]).  The delay
+# procedure needs to wait long enough for the asynchronous updates
+# performed by the text widget to run.
+
+proc updateText {} {
+     update
+}
+proc delay {} {
+     update
+     after 100
+     update
 }
 
 # The procedure below is used as the scrolling command for the text;
 # it just saves the scrolling information in a variable "scrollInfo".
 
@@ -47,17 +37,32 @@
 # The procedure below is used to generate errors during scrolling commands.
 
 proc scrollError args {
     error "scrolling error"
 }
+
+# Return 1 if the two given lists are the same, otherwise return the two lists.
+# This is used to compare a test actual result with a test expected result.
+
+proc lequal {res expected} {
+    if {[llength $res] != [llength $expected]} {
+        return [list "Lengths differ"  result: $res - expected: $expected]
+    }
+    for {set i 0} {$i < [llength $res]} {incr i} {
+        if {[lindex $res $i] ne [lindex $expected $i]} {
+	    return [list result: $res - expected: $expected]
+	}
+    }
+    return 1
+}
 
 # Create entries in the option database to be sure that geometry options
-# like border width have predictable values.
-set twbw 2
-set twht 2
-option add *Text.borderWidth $twbw
-option add *Text.highlightThickness $twht
+# like border width have selected values.
+option add *Text.borderWidth 2         ; # tests work with [1-3]
+option add *Text.highlightThickness 2  ; # tests work with [0-5]
+option add *Text.padX 1  ; # same padding in x and y, see proc bo; tests work with [0-4]
+option add *Text.padY 1  ; # same padding in x and y, see proc bo; tests work with [0-4]
 
 # The frame .f is needed to make sure that the overall window is always
 # fairly wide, even if the text window is very narrow.  This is needed
 # because some window managers don't allow the overall width of a window
 # to get very narrow.
@@ -73,37 +78,77 @@
 if {[tk windowingsystem] eq "aqua"} {
    set fixedFont {Courier -12}
 } else {
   set fixedFont {"Courier New" -12}
 }
-# 15 on XP, 13 on Solaris 8
 set fixedHeight [font metrics $fixedFont -linespace]
-# 7 on all platforms
 set fixedWidth [font measure $fixedFont m]
-# 12 on XP
 set fixedAscent [font metrics $fixedFont -ascent]
-set fixedDiff [expr {$fixedHeight - 13}] ;# 2 on XP
-
-set varFont {Times -14}
-# 16 on XP, 15 on Solaris 8
-set varHeight [font metrics $varFont -linespace]
-# 13 on XP
-set varAscent [font metrics $varFont -ascent]
-set varDiff [expr {$varHeight - 15}] ;# 1 on XP
-
-set bigFont {Helvetica -24}
-# 27 on XP, 27 on Solaris 8
+
+set bigFont {Helvetica -24}  ; # note: not a fixed-width font!
 set bigHeight [font metrics $bigFont -linespace]
-# 21 on XP
 set bigAscent [font metrics $bigFont -ascent]
+
 set ascentDiff [expr {$bigAscent - $fixedAscent}]
+set heightDiff [expr {$bigHeight - $fixedHeight}]
 
+# On Windows at least, the tests do work with {Courier -10}, {Courier -12} or {Courier -14} as fixedFont.
+# Warn the user if the actual font size is too different from what was requested.
+if {[font metrics [font actual $fixedFont] -fixed] != 1} {
+    puts "---> Warning: the font actually used by the tests, which is \"[font actual $fixedFont]\",\
+does not seem to be a fixed-width font as expected. If this is really the case, many upcoming\
+tests will fail."
+}
+if {$fixedHeight < 12 || $fixedHeight > 17} {
+    puts "---> Warning: the font actually used by the tests, which is \"[font actual $fixedFont]\",\
+is $fixedHeight pixels height while the tests expect between 12 and 17 (inclusive) pixels.\
+Some of the upcoming tests will probably fail."
+}
+if {$fixedWidth < 6 || $fixedWidth > 8} {
+    puts "---> Warning: the font actually used by the tests, which is \"[font actual $fixedFont]\",\
+is $fixedWidth pixels in width while the tests expect between 6 and 8 (inclusive) pixels.\
+Some of the upcoming tests will probably fail."
+}
+
+# Option  -width 20  (characters) below is a fundamental assumption of many
+# upcoming tests when wrapping enters in play
+# Also  -height 10  (lines) is an important assumption
 text .t -font $fixedFont -width 20 -height 10 -yscrollcommand scroll
 pack .t -expand 1 -fill both
 .t tag configure big -font $bigFont
 .t debug on
 wm geometry . {}
+
+# full border size of the text widget, i.e. first x or y coordinate inside the text widget
+# warning:  -padx  is supposed to be the same as  -pady  (same border size horizontally and
+# vertically around the widget)
+proc bo {{w .t}} {
+    return [expr {[$w cget -borderwidth] + [$w cget -highlightthickness] + [$w cget -padx]}]
+}
+
+# x-width of $n chars, fixed width font
+proc xw {n} {
+    global fixedWidth
+    return [expr {$n * $fixedWidth}]
+}
+# x-coordinate of the first pixel of $n-th char (count starts at zero), left justified
+proc xchar {n {w .t}} {
+    return [expr {[bo $w] + [xw $n]}]
+}
+# x-coordinate in widget $w of the first pixel of $n-th char counted from the right, right justified
+proc xcharr {n {w .t}} {
+    return [expr {[winfo width $w] - [bo $w] - [xw $n]}]
+}
+# y-coordinate of the first pixel of $l-th display line (count starts at 1)
+proc yline {l {w .t}} {
+    global fixedHeight
+    return [expr {[bo $w] + ($l - 1) * $fixedHeight}]
+}
+# x-pixels of empty space in widget $w on a line containing $n chars
+proc xe {n {w .t}} {
+    return [expr {[winfo width $w] - (2 * [bo $w]) - [xw $n]}]
+}
 
 # The statements below reset the main window;  it's needed if the window
 # manager is mwm to make mwm forget about a previous minimum size setting.
 
 wm withdraw .
@@ -238,13 +283,13 @@
     lappend x [lindex [.t bbox 1.2] 0]
     .t tag configure z -tabs 30
     .t tag raise x
     update idletasks
     lappend x [lindex [.t bbox 1.2] 0]
-} [list 75 55 55]
+} [list [expr {[bo]+70}] [expr {[bo]+50}] [expr {[bo]+50}]]
 .t tag delete x y z
-test textDisp-1.2 {GetStyle procedure, wrapmode} {textfonts} {
+test textDisp-1.2 {GetStyle procedure, wrapmode} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "abcd\nefg hijkl mnop qrstuv wxyz"
     .t tag configure x -wrap word
     .t tag configure y -wrap none
@@ -253,152 +298,190 @@
     set result [list [.t bbox 2.20]]
     .t tag add x 2.0 2.1
     lappend result [.t bbox 2.20]
     .t tag add y 1.end 2.2
     lappend result [.t bbox 2.20]
-} [list [list 5 [expr {5+2*$fixedHeight}] 7 $fixedHeight] [list 40 [expr {5+2*$fixedHeight}] 7 $fixedHeight] {}]
+} [list [list [xchar 0] [yline 3] $fixedWidth $fixedHeight] \
+        [list [xchar 5] [yline 3] $fixedWidth $fixedHeight] \
+	    {}]
 .t tag delete x y
 
 test textDisp-2.1 {LayoutDLine, basics} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "This is some sample text for testing."
     list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list [expr {5 + $fixedWidth * 19}] 5 $fixedWidth $fixedHeight] [list 5 [expr {5 + $fixedHeight}] $fixedWidth $fixedHeight]]
-test textDisp-2.2 {LayoutDLine, basics} {textfonts} {
+} [list [list [xchar 19] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-2.2 {LayoutDLine, basics} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "This isx some sample text for testing."
     list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 138 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-2.3 {LayoutDLine, basics} {textfonts} {
+} [list [list [xchar 19] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-2.3 {LayoutDLine, basics} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "This isxxx some sample text for testing."
     list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 138 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-2.4 {LayoutDLine, word wrap} {textfonts} {
+} [list [list [xchar 19] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-2.4 {LayoutDLine, word wrap} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "This is some sample text for testing."
     list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 138 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-2.5 {LayoutDLine, word wrap} {textfonts} {
+} [list [list [xchar 19] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-2.5 {LayoutDLine, word wrap} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "This isx some sample text for testing."
     list [.t bbox 1.13] [.t bbox 1.19] [.t bbox 1.20] [.t bbox 1.21]
-} [list [list 96 5 $fixedWidth $fixedHeight] [list 138 5 $fixedWidth $fixedHeight] [list 145 5 0  $fixedHeight] [list 5 [expr {$fixedDiff + 18}] $fixedWidth $fixedHeight]]
-test textDisp-2.6 {LayoutDLine, word wrap} failsOnUbuntu {
+} [list [list [xchar 13] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 19] [yline 1] $fixedWidth $fixedHeight] \
+	    [list [xchar 20] [yline 1] 0  $fixedHeight] \
+	    [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-2.6 {LayoutDLine, word wrap} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "This isxxx some sample text for testing."
     list [.t bbox 1.15] [.t bbox 1.16]
-} [list [list 110 5 35 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-2.7 {LayoutDLine, marks and tags} {textfonts} {
+} [list [list [xchar 15] [yline 1] [xe 15] $fixedHeight] \
+        [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-2.7 {LayoutDLine, marks and tags} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "This isxxx some sample text for testing."
     .t tag add foo 1.4 1.6
     .t mark set insert 1.8
     list [.t bbox 1.2] [.t bbox 1.5] [.t bbox 1.11]
-} [list [list 19 5 7 $fixedHeight] [list 40 5 7 $fixedHeight] [list 82 5 7 $fixedHeight]]
+} [list [list [xchar 2] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 5] [yline 1] $fixedWidth $fixedHeight] \
+	    [list [xchar 11] [yline 1] $fixedWidth $fixedHeight]]
 foreach m [.t mark names] {
     catch {.t mark unset $m}
 }
-scan [wm geom .] %dx%d width height
-test textDisp-2.8 {LayoutDLine, extra chunk at end of dline} {textfonts} {
+test textDisp-2.8 {LayoutDLine, extra chunk at end of dline} -setup {
+    scan [wm geom .] %dx%d width height
+} -body {
     wm geom . [expr {$width+1}]x$height
     updateText
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "This isxx some sample text for testing."
     .t mark set foo 1.20
     list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 138 5 8 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-wm geom . {}
-updateText
-test textDisp-2.9 {LayoutDLine, marks and tags} {textfonts} {
+} -cleanup {
+    wm geom . {}
+    updateText
+} -result [list [list [xchar 19] [yline 1] [expr {$fixedWidth+1}] $fixedHeight] \
+                [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-2.9 {LayoutDLine, marks and tags} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "This is a very_very_long_word_that_wraps."
     list [.t bbox 1.9] [.t bbox 1.10] [.t bbox 1.25]
-} [list [list 68 5 77 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 110 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-2.10 {LayoutDLine, marks and tags} {textfonts} {
+} [list [list [xchar 9] [yline 1] [xe 9] $fixedHeight] \
+        [list [xchar 0] [yline 2] $fixedWidth $fixedHeight] \
+	    [list [xchar 15] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-2.10 {LayoutDLine, marks and tags} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "This is a very_very_long_word_that_wraps."
     .t tag add foo 1.13
     .t tag add foo 1.15
     .t tag add foo 1.17
     .t tag add foo 1.19
     list [.t bbox 1.9] [.t bbox 1.10] [.t bbox 1.25]
-} [list [list 68 5 77 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 110 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-2.11 {LayoutDLine, newline width} {textfonts} {
+} [list [list [xchar 9] [yline 1] [xe 9] $fixedHeight] \
+        [list [xchar 0] [yline 2] $fixedWidth $fixedHeight] \
+	    [list [xchar 15] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-2.11 {LayoutDLine, newline width} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "a\nbb\nccc\ndddd"
     list [.t bbox 2.2] [.t bbox 3.3]
-} [list [list 19 [expr {$fixedDiff + 18}] 126 $fixedHeight] [list 26 [expr {2*$fixedDiff + 31}] 119 $fixedHeight]]
-test textDisp-2.12 {LayoutDLine, justification} {textfonts} {
+} [list [list [xchar 2] [yline 2] [xe 2] $fixedHeight] \
+        [list [xchar 3] [yline 3] [xe 3] $fixedHeight]]
+test textDisp-2.12 {LayoutDLine, justification} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "\na\nbb\nccc\ndddd"
     .t tag configure x -justify center
     .t tag add x 1.0 end
     .t tag add y 3.0 3.2
     list [.t bbox 1.0] [.t bbox 2.0] [.t bbox 4.0] [.t bbox 4.2]
-} [list [list 75 5 70 $fixedHeight] [list 71 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 64 [expr {3*$fixedDiff + 44}] 7 $fixedHeight] [list 78 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
-test textDisp-2.13 {LayoutDLine, justification} {textfonts} {
+} [list [list [expr {[bo]+[xe 0]/2}] [yline 1] [expr {[xe 0]-[xe 0]/2}] $fixedHeight] \
+        [list [expr {[bo]+[xe 1]/2}] [yline 2] $fixedWidth $fixedHeight] \
+        [list [expr {[bo]+[xe 3]/2}] [yline 4] $fixedWidth $fixedHeight] \
+        [list [expr {[bo]+[xe 3]/2+[xw 2]}] [yline 4] $fixedWidth $fixedHeight]]
+test textDisp-2.13 {LayoutDLine, justification} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "\na\nbb\nccc\ndddd"
     .t tag configure x -justify right
     .t tag add x 1.0 end
     .t tag add y 3.0 3.2
     list [.t bbox 1.0] [.t bbox 2.0] [.t bbox 4.0] [.t bbox 4.2]
-} [list [list 145 5 0 $fixedHeight] [list 138 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 124 [expr {3*$fixedDiff + 44}] 7 $fixedHeight] [list 138 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
-test textDisp-2.14 {LayoutDLine, justification} {textfonts} {
+} [list [list [xcharr 0] [yline 1] 0 $fixedHeight] \
+        [list [xcharr 1] [yline 2] $fixedWidth $fixedHeight] \
+        [list [xcharr 3] [yline 4] $fixedWidth $fixedHeight] \
+        [list [xcharr 1] [yline 4] $fixedWidth $fixedHeight]]
+test textDisp-2.14 {LayoutDLine, justification} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "\na\nbb\nccc\ndddd"
     .t tag configure x -justify center
     .t tag add x 2.0 3.1
     .t tag configure y -justify right
     .t tag add y 3.0 4.0
     .t tag raise y
     list [.t bbox 2.0] [.t bbox 3.0] [.t bbox 3.end] [.t bbox 4.0]
-} [list [list 71 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 131 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 145 [expr {2*$fixedDiff + 31}] 0 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
-test textDisp-2.15 {LayoutDLine, justification} {textfonts} {
+} [list [list [expr {[bo]+[xe 1]/2}] [yline 2] $fixedWidth $fixedHeight] \
+        [list [xcharr 2] [yline 3] $fixedWidth $fixedHeight] \
+        [list [xcharr 0] [yline 3] 0 $fixedHeight] \
+        [list [xchar 0] [yline 4] $fixedWidth $fixedHeight]]
+test textDisp-2.15 {LayoutDLine, justification} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "\na\nbb\nccc\ndddd"
     .t tag configure x -justify center
     .t tag add x 2.0 3.1
     .t tag configure y -justify right
     .t tag add y 3.0 4.0
     .t tag lower y
     list [.t bbox 2.0] [.t bbox 3.0] [.t bbox 3.end] [.t bbox 4.0]
-} [list [list 71 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 68 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 82 [expr {2*$fixedDiff + 31}] 63 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
-test textDisp-2.16 {LayoutDLine, justification} {textfonts} {
+} [list [list [expr {[bo]+[xe 1]/2}] [yline 2] $fixedWidth $fixedHeight] \
+        [list [expr {[bo]+[xe 2]/2}] [yline 3] $fixedWidth $fixedHeight] \
+        [list [expr {[bo]+[xe 2]/2+[xw 2]}] [yline 3] [expr {[xe 2]/2}] $fixedHeight] \
+        [list [xchar 0] [yline 4] $fixedWidth $fixedHeight]]
+test textDisp-2.16 {LayoutDLine, justification} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "Lots of long words, enough to force word wrap\nThen\nmore lines"
     .t tag configure x -justify center
     .t tag add x 1.1 1.20
     .t tag add x 1.21 1.end
     list [.t bbox 1.0] [.t bbox 1.20] [.t bbox 1.41] [.t bbox 2.0]
-} [list [list 5 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 61 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
-test textDisp-2.17 {LayoutDLine, justification} {textfonts} {
+} [list [list [xchar 0] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 0] [yline 2] $fixedWidth $fixedHeight] \
+        [list [expr {[bo]+[xe 4]/2}] [yline 3] $fixedWidth $fixedHeight] \
+        [list [xchar 0] [yline 4] $fixedWidth $fixedHeight]]
+test textDisp-2.17 {LayoutDLine, justification} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "Lots of very long words, enough to force word wrap\nThen\nmore lines"
     .t tag configure x -justify center
     .t tag add x 1.18
     list [.t bbox 1.0] [.t bbox 1.18] [.t bbox 1.35] [.t bbox 2.0]
-} [list [list 5 5 7 $fixedHeight] [list 15 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
-test textDisp-2.18 {LayoutDLine, justification} {textfonts} {
+} [list [list [xchar 0] [yline 1] $fixedWidth $fixedHeight] \
+        [list [expr {[bo]+[xe 17]/2}] [yline 2] $fixedWidth $fixedHeight] \
+        [list [xchar 0] [yline 3] $fixedWidth $fixedHeight] \
+        [list [xchar 0] [yline 4] $fixedWidth $fixedHeight]]
+test textDisp-2.18 {LayoutDLine, justification} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert 1.0 "Lots of long words, enough to extend out of the window\n"
     .t insert end "Then\nmore lines\nThat are shorter"
     .t tag configure x -justify center
@@ -405,43 +488,57 @@
     .t tag configure y -justify right
     .t tag add x 2.0
     .t tag add y 3.0
     .t xview scroll 5 units
     list [.t bbox 2.0] [.t bbox 3.0]
-} [list [list 26 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 40 [expr {2*$fixedDiff + 31}] 7 $fixedHeight]]
+} [list [list [expr {[bo]+[xe 4]/2-[xw 5]}] [yline 2] $fixedWidth $fixedHeight] \
+        [list [expr {[xcharr 10]-[xw 5]}] [yline 3] $fixedWidth $fixedHeight]]
 .t tag delete x
 .t tag delete y
-test textDisp-2.19 {LayoutDLine, margins} {textfonts} {
+test textDisp-2.19 {LayoutDLine, margins} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "Lots of long words, enough to force word wrap\nThen\nmore lines"
-    .t tag configure x -lmargin1 20 -lmargin2 40 -rmargin 15
+    # margins in pixels depend on the font width for more flexibility
+    set lm1 [expr {3*$fixedWidth}]
+    set lm2 [expr {2*$lm1}]
+    set rm [expr {2*$fixedWidth}]
+    .t tag configure x -lmargin1 $lm1 -lmargin2 $lm2 -rmargin $rm
     .t tag add x 1.0 end
-    list [.t bbox 1.0] [.t bbox 1.12] [.t bbox 1.13] [.t bbox 2.0]
-} [list [list 25 5 7 $fixedHeight] [list 109 5 36 $fixedHeight] [list 45 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 25 [expr {5*$fixedDiff + 70}] 7 $fixedHeight]]
-test textDisp-2.20 {LayoutDLine, margins} {textfonts} {
+    set expected [list [list [expr {[bo]+$lm1}] [yline 1] $fixedWidth $fixedHeight] \
+                       [list [expr {[bo]+$lm1+[xw 12]}] [yline 1] [expr {[xe 12]-$lm1}] $fixedHeight] \
+                       [list [expr {[bo]+$lm2}] [yline 2] $fixedWidth $fixedHeight] \
+                       [list [expr {[bo]+$lm1}] [yline 6] $fixedWidth $fixedHeight]]
+    lequal [list [.t bbox 1.0] [.t bbox 1.12] [.t bbox 1.13] [.t bbox 2.0]] $expected
+} {1}
+test textDisp-2.20 {LayoutDLine, margins} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "Lots of long words, enough to force word wrap\nThen\nmore lines"
     .t tag configure x -lmargin1 20 -lmargin2 10 -rmargin 3
     .t tag configure y -lmargin1 15 -lmargin2 5 -rmargin 0
     .t tag raise y
     .t tag add x 1.0 end
     .t tag add y 1.13
     list [.t bbox 1.0] [.t bbox 1.13] [.t bbox 1.30] [.t bbox 2.0]
-} [list [list 25 5 7 $fixedHeight] [list 10 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 15 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 25 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
-test textDisp-2.21 {LayoutDLine, margins} {textfonts} {
+} [list [list [expr {[bo]+20}] [yline 1] $fixedWidth $fixedHeight] \
+        [list [expr {[bo]+5}] [yline 2] $fixedWidth $fixedHeight] \
+        [list [expr {[bo]+10}] [yline 3] $fixedWidth $fixedHeight] \
+        [list [expr {[bo]+20}] [yline 4] $fixedWidth $fixedHeight]]
+test textDisp-2.21 {LayoutDLine, margins} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "Sample text"
     .t tag configure x -lmargin1 80 -lmargin2 80 -rmargin 100
     .t tag add x 1.0 end
     list [.t bbox 1.0] [.t bbox 1.1] [.t bbox 1.2]
-} [list [list 85 5 60 $fixedHeight] [list 85 [expr {$fixedDiff + 18}] 60 $fixedHeight] [list 85 [expr {2*$fixedDiff + 31}] 60 $fixedHeight]]
+} [list [list [expr {[bo]+80}] [yline 1] [expr {[xe 0]-80}] $fixedHeight] \
+        [list [expr {[bo]+80}] [yline 2] [expr {[xe 0]-80}] $fixedHeight] \
+        [list [expr {[bo]+80}] [yline 3] [expr {[xe 0]-80}] $fixedHeight]]
 .t tag delete x
 .t tag delete y
-test textDisp-2.22 {LayoutDLine, spacing options} {textfonts} {
+test textDisp-2.22 {LayoutDLine, spacing options} {
     .t configure -wrap word
     .t delete 1.0 end
     .t tag delete x y
     .t insert end "Short line\nLine 2 is long enough "
     .t insert end "to wrap around a couple of times"
@@ -464,11 +561,11 @@
     set i [.t dlineinfo 3.0]
     set b4 [expr {[lindex $i 1] + [lindex $i 4] - $b4}]
     list $b1 $b2 $b3 $b4
 } [list 2 7 10 15]
 .t configure -spacing1 0 -spacing2 0 -spacing3 0
-test textDisp-2.23 {LayoutDLine, spacing options} {textfonts} {
+test textDisp-2.23 {LayoutDLine, spacing options} {
     .t configure -wrap word
     .t delete 1.0 end
     .t tag delete x y
     .t insert end "Short line\nLine 2 is long enough "
     .t insert end "to wrap around a couple of times"
@@ -496,89 +593,104 @@
     set i [.t dlineinfo 3.0]
     set b4 [expr {[lindex $i 1] + [lindex $i 4] - $b4}]
     list $b1 $b2 $b3 $b4
 } [list 1 5 13 16]
 .t configure -spacing1 0 -spacing2 0 -spacing3 0
-test textDisp-2.24 {LayoutDLine, tabs, saving from first chunk} {textfonts} {
+test textDisp-2.24 {LayoutDLine, tabs, saving from first chunk} {
     .t delete 1.0 end
     .t tag delete x y
     .t tag configure x -tabs 70
     .t tag configure y -tabs 80
     .t insert 1.0 "ab\tcde"
     .t tag add x 1.0 end
     .t tag add y 1.1 end
     lindex [.t bbox 1.3] 0
-} 75
-test textDisp-2.25 {LayoutDLine, tabs, breaking chunks at tabs} {textfonts} {
+} [expr {[bo]+70}]
+test textDisp-2.25 {LayoutDLine, tabs, breaking chunks at tabs} {
     .t delete 1.0 end
     .t tag delete x
-    .t tag configure x -tabs [list 30 60 90 120]
+    # compute a tab width allowing to let 4 tab stops (followed by a single char) on a single line
+    set tw [expr {([winfo width .t]-2*[bo]-$fixedWidth)/4}]
+    .t tag configure x -tabs [list $tw [expr {$tw*2}] [expr {$tw*3}] [expr {$tw*4}]]
     .t insert 1.0 "a\tb\tc\td\te"
     .t mark set dummy1 1.1
     .t mark set dummy2 1.2
     .t tag add x 1.0 end
-    list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0] \
-	    [lindex [.t bbox 1.6] 0] [lindex [.t bbox 1.8] 0]
-} [list 35 65 95 125]
-test textDisp-2.26 {LayoutDLine, tabs, breaking chunks at tabs} {textfonts} {
+    set expected [list [expr {[bo]+$tw}] [expr {[bo]+2*$tw}] [expr {[bo]+3*$tw}] [expr {[bo]+4*$tw}]]
+    set res [list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0] \
+	          [lindex [.t bbox 1.6] 0] [lindex [.t bbox 1.8] 0]]
+    lequal $res $expected
+} {1}
+# Next test is currently constrained to not run on mac (aqua) because on
+# aqua it fails due to wrong implementation of tabs with right justification
+# (the text is not rendered at all). This is a bug.
+test textDisp-2.26 {LayoutDLine, tabs, breaking chunks at tabs} {notAqua} {
     .t delete 1.0 end
     .t tag delete x
     .t tag configure x -tabs [list 30 60 90 120] -justify right
     .t insert 1.0 "a\tb\tc\td\te"
     .t mark set dummy1 1.1
     .t mark set dummy2 1.2
     .t tag add x 1.0 end
     list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0] \
-	    [lindex [.t bbox 1.6] 0] [lindex [.t bbox 1.8] 0]
-} [list 117 124 131 138]
-test textDisp-2.27 {LayoutDLine, tabs, calling AdjustForTab} {textfonts} {
+	     [lindex [.t bbox 1.6] 0] [lindex [.t bbox 1.8] 0]
+} [list [xcharr 4] [xcharr 3] [xcharr 2] [xcharr 1]]
+test textDisp-2.27 {LayoutDLine, tabs, calling AdjustForTab} {
     .t delete 1.0 end
     .t tag delete x
     .t tag configure x -tabs [list 30 60]
     .t insert 1.0 "a\tb\tcd"
     .t tag add x 1.0 end
     list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0]
-} [list 35 65]
-test textDisp-2.28 {LayoutDLine, tabs, running out of space in dline} {textfonts} {
+} [list [expr {[bo]+30}] [expr {[bo]+60}]]
+test textDisp-2.28 {LayoutDLine, tabs, running out of space in dline} {
     .t delete 1.0 end
     .t insert 1.0 "a\tb\tc\td"
     .t bbox 1.6
-} [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight]
-test textDisp-2.29 {LayoutDLine, tabs, running out of space in dline} {textfonts} {
+} [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]
+test textDisp-2.29 {LayoutDLine, tabs, running out of space in dline} {
     .t delete 1.0 end
     .t insert 1.0 "a\tx\tabcd"
     .t bbox 1.4
-} [list 117 5 7 $fixedHeight]
-test textDisp-2.30 {LayoutDLine, tabs, running out of space in dline} {textfonts} {
+} [list [xchar [expr {2*8}]] [yline 1] $fixedWidth $fixedHeight]
+test textDisp-2.30 {LayoutDLine, tabs, running out of space in dline} {
     .t delete 1.0 end
     .t insert 1.0 "a\tx\tabc"
     .t bbox 1.4
-} [list 117 5 7 $fixedHeight]
+} [list [xchar [expr {2*8}]] [yline 1] $fixedWidth $fixedHeight]
 
-test textDisp-3.1 {different character sizes} {textfonts} {
+test textDisp-3.1 {different character sizes} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert end "Some sample text, including both large\n"
     .t insert end "characters and\nsmall\n"
     .t insert end "abc\nd\ne\nfghij"
     .t tag add big 1.5 1.10
     .t tag add big 2.11 2.14
     list [.t bbox 1.1] [.t bbox 1.6] [.t dlineinfo 1.0] [.t dlineinfo 3.0]
-} [list [list 12 [expr {5+$ascentDiff}] 7 $fixedHeight] [list 52 5 13 27] [list 5 5 114 27 [font metrics $bigFont -ascent]] [list 5 [expr {2* $fixedDiff + 85}] 35 $fixedHeight [expr {$fixedDiff + 10}]]]
+} [list [list [xchar 1] [expr {[yline 1]+$ascentDiff}] $fixedWidth $fixedHeight] \
+        [list [expr {[xchar 5]+[font measure $bigFont s]}] [yline 1] [font measure $bigFont a] $bigHeight] \
+	[list [bo] [yline 1] [expr {[xw 5]+[font measure $bigFont sampl]+[xw 2]}] $bigHeight $bigAscent] \
+	[list [bo] [expr {[bo]+2*$bigHeight+2*$fixedHeight}] [xw 5] $fixedHeight $fixedAscent]]
 .t configure -wrap char
-test textDisp-4.1 {UpdateDisplayInfo, basic} {textfonts} {
+
+test textDisp-4.1 {UpdateDisplayInfo, basic} {
     .t delete 1.0 end
     .t insert end "Line 1\nLine 2\nLine 3\n"
     updateText
     .t delete 2.0 2.end
     updateText
     set res $tk_textRelayout
     .t insert 2.0 "New Line 2"
     updateText
     lappend res [.t bbox 1.0] [.t bbox 2.0] [.t bbox 3.0] $tk_textRelayout
-} [list 2.0 [list 5 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] 2.0]
-test textDisp-4.2 {UpdateDisplayInfo, re-use tail of text line} {textfonts} {
+} [list 2.0 \
+        [list [xchar 0] [yline 1] $fixedWidth $fixedHeight] \
+	[list [xchar 0] [yline 2] $fixedWidth $fixedHeight] \
+	[list [xchar 0] [yline 3] $fixedWidth $fixedHeight] \
+	2.0]
+test textDisp-4.2 {UpdateDisplayInfo, re-use tail of text line} {
     .t delete 1.0 end
     .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
     updateText
     .t mark set x 2.21
     .t delete 2.2
@@ -585,41 +697,54 @@
     updateText
     set res $tk_textRelayout
     .t insert 2.0 X
     updateText
     lappend res [.t bbox 2.0] [.t bbox x] [.t bbox 3.0] $tk_textRelayout
-} [list 2.0 2.20 [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 12 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight] {2.0 2.20}]
-test textDisp-4.3 {UpdateDisplayInfo, tail of text line shifts} {textfonts} {
+} [list 2.0 2.20 \
+        [list [xchar 0] [yline 2] $fixedWidth $fixedHeight] \
+	[list [xchar 1] [yline 3] $fixedWidth $fixedHeight] \
+	[list [xchar 0] [yline 4] $fixedWidth $fixedHeight] \
+	{2.0 2.20}]
+test textDisp-4.3 {UpdateDisplayInfo, tail of text line shifts} {
     .t delete 1.0 end
     .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
     updateText
     .t mark set x 2.21
     .t delete 2.2
     updateText
     list [.t bbox 2.0] [.t bbox x] [.t bbox 3.0] $tk_textRelayout
-} [list [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight] {2.0 2.20}]
+} [list [list [xchar 0] [yline 2] $fixedWidth $fixedHeight] \
+        [list [xchar 0] [yline 3] $fixedWidth $fixedHeight] \
+	[list [xchar 0] [yline 4] $fixedWidth $fixedHeight] \
+	{2.0 2.20}]
 .t mark unset x
-test textDisp-4.4 {UpdateDisplayInfo, wrap-mode "none"} {textfonts} {
+test textDisp-4.4 {UpdateDisplayInfo, wrap-mode "none"} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
     updateText
     list [.t bbox 2.0] [.t bbox 2.25] [.t bbox 3.0] $tk_textRelayout
-} [list [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] {} [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] {1.0 2.0 3.0}]
-test textDisp-4.5 {UpdateDisplayInfo, tiny window} {textfonts} {
-    if {$tcl_platform(platform) == "windows"} {
+} [list [list [xchar 0] [yline 2] $fixedWidth $fixedHeight] \
+        {} \
+	[list [xchar 0] [yline 3] $fixedWidth  $fixedHeight] \
+	{1.0 2.0 3.0}]
+test textDisp-4.5 {UpdateDisplayInfo, tiny window} {
+    if {[tk windowingsystem] == "win32"} {
 	wm overrideredirect . 1
     }
     wm geom . 103x$height
     updateText
     .t configure -wrap none
     .t delete 1.0 end
     .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
     updateText
     list [.t bbox 2.0] [.t bbox 2.1] [.t bbox 3.0] $tk_textRelayout
-} [list [list 5 [expr {$fixedDiff + 18}] 1 $fixedHeight] {} [list 5 [expr {2*$fixedDiff + 31}] 1 $fixedHeight] {1.0 2.0 3.0}]
-if {$tcl_platform(platform) == "windows"} {
+} [list [list [xchar 0] [yline 2] 1 $fixedHeight] \
+        {} \
+	[list [xchar 0] [yline 3] 1 $fixedHeight] \
+	{1.0 2.0 3.0}]
+if {[tk windowingsystem] == "win32"} {
     wm overrideredirect . 0
 }
 test textDisp-4.6 {UpdateDisplayInfo, tiny window} {
     # This test was failing on Windows because the title bar on .
     # was a certain minimum size and it was interfering with the size
@@ -626,11 +751,11 @@
     # requested.  The "overrideredirect" gets rid of the titlebar so
     # the toplevel can shrink to the appropriate size.  On Unix, setting
     # the overrideredirect on "." confuses the window manager and
     # causes subsequent tests to fail.
 
-    if {$tcl_platform(platform) == "windows"} {
+    if {[tk windowingsystem] == "win32"} {
 	wm overrideredirect . 1
     }
     frame .f2 -width 20 -height 100
     pack .f2 -before .f
     wm geom . 103x103
@@ -640,29 +765,26 @@
     .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
     updateText
     set x [list [.t bbox 1.0] [.t bbox 2.0] $tk_textRelayout]
     wm overrideredirect . 0
     updateText
-    set x
-} [list [list 5 5 1 1] {} 1.0]
+    set expected [list [list [xchar 0] [yline 1] 1 1] {} 1.0]
+    lequal $x $expected
+} {1}
 catch {destroy .f2}
 .t configure -borderwidth 0 -wrap char
 wm geom . {}
 updateText
-set bw [.t cget -borderwidth]
-set px [.t cget -padx]
-set py [.t cget -pady]
-set hlth [.t cget -highlightthickness]
 test textDisp-4.7 {UpdateDisplayInfo, filling in extra vertical space} {
     # This test was failing on Windows because the title bar on .
     # was a certain minimum size and it was interfering with the size
     # requested.  The "overrideredirect" gets rid of the titlebar so
     # the toplevel can shrink to the appropriate size.  On Unix, setting
     # the overrideredirect on "." confuses the window manager and
     # causes subsequent tests to fail.
 
-    if {$tcl_platform(platform) == "windows"} {
+    if {[tk windowingsystem] == "win32"} {
 	wm overrideredirect . 1
     }
     .t delete 1.0 end
     .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
     .t yview 1.0
@@ -672,27 +794,28 @@
     set x [list [.t index @0,0] $tk_textRelayout $tk_textRedraw]
     wm overrideredirect . 0
     updateText
     set x
 } {8.0 {16.0 17.0 15.0 14.0 13.0 12.0 11.0 10.0 9.0 8.0} {8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0}}
-test textDisp-4.8 {UpdateDisplayInfo, filling in extra vertical space} failsOnXQuarz {
+test textDisp-4.8 {UpdateDisplayInfo, filling in extra vertical space} {
     .t delete 1.0 end
     .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
     .t yview 16.0
     updateText
     .t delete 5.0 14.0
     updateText
     set x [list [.t index @0,0] $tk_textRelayout $tk_textRedraw]
 } {1.0 {5.0 4.0 3.0 2.0 1.0} {1.0 2.0 3.0 4.0 5.0 eof}}
-test textDisp-4.9 {UpdateDisplayInfo, filling in extra vertical space} {textfonts} {
+test textDisp-4.9 {UpdateDisplayInfo, filling in extra vertical space} {
     .t delete 1.0 end
     .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
     .t yview 16.0
     updateText
     .t delete 15.0 end
     list [.t bbox 7.0] [.t bbox 12.0]
-} [list [list [expr {$hlth + $px + $bw}] [expr {$hlth + $py + $bw + 2 * $fixedHeight}] $fixedWidth $fixedHeight] [list [expr {$hlth + $px + $bw}] [expr {$hlth + $py + $bw + 7 * $fixedHeight}] $fixedWidth $fixedHeight]]
+} [list [list [xchar 0] [yline 3] $fixedWidth $fixedHeight] \
+	[list [xchar 0] [yline 8] $fixedWidth $fixedHeight]]
 test textDisp-4.10 {UpdateDisplayInfo, filling in extra vertical space} {
     .t delete 1.0 end
     .t insert end "1\n2\n3\n4\n5\nLine 6 is such a long line that it wraps around.\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
     .t yview end
     updateText
@@ -735,11 +858,11 @@
     updateText
     .t yview scroll 3 units
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{11.0 12.0 13.0} {4.0 10.0 11.0 12.0 13.0}}
-test textDisp-4.14 {UpdateDisplayInfo, special handling for top/bottom lines} failsOnXQuarz {
+test textDisp-4.14 {UpdateDisplayInfo, special handling for top/bottom lines} {
     .t tag remove x 1.0 end
     .t yview 1.0
     updateText
     .t yview scroll 3 units
     updateText
@@ -759,43 +882,48 @@
     updateText
     .t yview scroll -2 units
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{2.0 3.0} {2.0 3.0}}
-test textDisp-4.17 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
+test textDisp-4.17 {UpdateDisplayInfo, horizontal scrolling} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
     .t insert end "\nLine 3\nLine 4"
     updateText
     .t xview scroll 3 units
     updateText
     list $tk_textRelayout $tk_textRedraw [.t bbox 2.0] [.t bbox 2.5] \
 	    [.t bbox 2.23]
-} [list {} {1.0 2.0 3.0 4.0} {} [list 17 [expr {$fixedDiff + 16}] 7 $fixedHeight] {}]
-test textDisp-4.18 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
+} [list {} {1.0 2.0 3.0 4.0} \
+        {} \
+        [list [expr {[xchar 5]-[xw 3]}] [yline 2] $fixedWidth $fixedHeight] \
+	{}]
+test textDisp-4.18 {UpdateDisplayInfo, horizontal scrolling} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
     .t insert end "\nLine 3\nLine 4"
     updateText
     .t xview scroll 100 units
     updateText
     list $tk_textRelayout $tk_textRedraw [.t bbox 2.25]
-} [list {} {1.0 2.0 3.0 4.0} [list 10 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-4.19 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
+} [list {} {1.0 2.0 3.0 4.0} \
+        [list [xcharr 19] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-4.19 {UpdateDisplayInfo, horizontal scrolling} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
     .t insert end "\nLine 3\nLine 4"
     updateText
     .t xview moveto 0
     .t xview scroll -10 units
     updateText
     list $tk_textRelayout $tk_textRedraw [.t bbox 2.5]
-} [list {} {1.0 2.0 3.0 4.0} [list 38 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-4.20 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
+} [list {} {1.0 2.0 3.0 4.0} \
+	[list [xchar 5] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-4.20 {UpdateDisplayInfo, horizontal scrolling} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
     .t insert end "\nLine 3\nLine 4"
     .t xview moveto 0.0
@@ -802,12 +930,13 @@
     .t xview scroll 100 units
     updateText
     .t delete 2.30 2.44
     updateText
     list $tk_textRelayout $tk_textRedraw [.t bbox 2.25]
-} [list 2.0 {1.0 2.0 3.0 4.0} [list 108 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-4.21 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
+} [list 2.0 {1.0 2.0 3.0 4.0} \
+        [list [xcharr 5] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-4.21 {UpdateDisplayInfo, horizontal scrolling} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
     .t insert end "\nLine 3\nLine 4"
     .t xview moveto .9
@@ -814,31 +943,34 @@
     updateText
     .t xview moveto .6
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{} {}}
-test textDisp-4.22 {UpdateDisplayInfo, no horizontal scrolling except for -wrap none} {textfonts} {
+test textDisp-4.22 {UpdateDisplayInfo, no horizontal scrolling except for -wrap none} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
     .t insert end "\nLine 3\nLine 4"
     .t xview scroll 25 units
     updateText
     .t configure -wrap word
     list [.t bbox 2.0] [.t bbox 2.16]
-} [list [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 10 [expr {2*$fixedDiff + 29}] 7 $fixedHeight]]
-test textDisp-4.23 {UpdateDisplayInfo, no horizontal scrolling except for -wrap none} {textfonts} {
+} [list [list [xchar 0] [yline 2] $fixedWidth $fixedHeight] \
+        [list [xchar 1] [yline 3] $fixedWidth $fixedHeight]]
+test textDisp-4.23 {UpdateDisplayInfo, no horizontal scrolling except for -wrap none} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
     .t insert end "\nLine 3\nLine 4"
     .t xview scroll 25 units
     updateText
     .t configure -wrap char
     list [.t bbox 2.0] [.t bbox 2.16]
-} [list [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 115 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-5.1 {DisplayDLine, handling of spacing} {textfonts} {
+} [list [list [xchar 0] [yline 2] $fixedWidth $fixedHeight] \
+	[list [xchar 16] [yline 2] $fixedWidth $fixedHeight]]
+
+test textDisp-5.1 {DisplayDLine, handling of spacing} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "abcdefghijkl\nmnopqrstuvwzyz"
     .t tag configure spacing -spacing1 8 -spacing3 2
     .t tag add spacing 1.0 end
@@ -851,17 +983,19 @@
     .t window create 2.1 -window .t.f3 -align bottom
     .t window create 2.10 -window .t.f4 -align baseline
     updateText
     list [winfo geometry .t.f1] [winfo geometry .t.f2] \
 	    [winfo geometry .t.f3] [winfo geometry .t.f4]
-} [list 10x4+24+11 10x4+55+[expr {$fixedDiff/2 + 15}] 10x4+10+[expr {2*$fixedDiff + 43}] 10x4+76+[expr {2*$fixedDiff + 40}]]
+} [list 10x4+[xchar 3]+[expr {[yline 1]+8}] \
+        10x4+[expr {[xchar 6]+10}]+[expr {[yline 1]+8+($fixedHeight-4)/2}] \
+	10x4+[xchar 1]+[expr {[yline 2]+8+2+8+($fixedHeight-4)}] \
+	10x4+[expr {[xchar 9]+10}]+[expr {[yline 2]+8+2+8+($fixedAscent-4)}]]
 .t tag delete spacing
 
 # Although the following test produces a useful result, its main
 # effect is to produce a core dump if Tk doesn't handle display
 # relayout that occurs during redisplay.
-
 test textDisp-5.2 {DisplayDLine, line resizes during display} {
     .t delete 1.0 end
     frame .t.f -width 20 -height 20 -bd 2 -relief raised
     bind .t.f <Configure> {.t.f configure -width 30 -height 30}
     .t window create insert -window .t.f
@@ -868,11 +1002,11 @@
     updateText
     list [winfo width .t.f] [winfo height .t.f]
 } [list 30 30]
 
 .t configure -wrap char
-test textDisp-6.1 {scrolling in DisplayText, scroll up} failsOnXQuarz {
+test textDisp-6.1 {scrolling in DisplayText, scroll up} {
     .t delete 1.0 end
     .t insert 1.0 "Line 1"
     foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
 	.t insert end "\nLine $i"
     }
@@ -916,11 +1050,12 @@
     .t insert 2.end "is so long that it wraps around, not once but three times"
     .t insert 4.end "is so long that it wraps"
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{2.0 2.20 2.40 2.60 4.0 4.20} {2.0 2.20 2.40 2.60 4.0 4.20 6.0}}
-test textDisp-6.5 {scrolling in DisplayText, scroll source obscured} {nonPortable} {
+test textDisp-6.5 {scrolling in DisplayText, scroll source obscured} {aquaKnownBug} {
+# constrained by aquaKnownBug until ticket [aad0231f07] is fixed
     .t configure -wrap char
     frame .f2 -bg red
     place .f2 -in .t -relx 0.5 -rely 0.5 -relwidth 0.5 -relheight 0.5
     .t delete 1.0 end
     .t insert 1.0 "Line 1 is so long that it wraps around, a couple of times"
@@ -931,27 +1066,29 @@
     .t delete 1.6 1.end
     updateText
     destroy .f2
     list $tk_textRelayout $tk_textRedraw
 } {{1.0 9.0 10.0} {1.0 4.0 5.0 9.0 10.0}}
-test textDisp-6.6 {scrolling in DisplayText, Expose events after scroll} {unix nonPortable} {
+test textDisp-6.6 {scrolling in DisplayText, Expose events after scroll} {aquaKnownBug} {
+# constrained by aquaKnownBug until ticket [aad0231f07] is fixed
     # this test depends on all of the expose events being handled at once
     .t configure -wrap char
     frame .f2 -bg #ff0000
     place .f2 -in .t -relx 0.2 -rely 0.5 -relwidth 0.5 -relheight 0.5
     .t configure -bd 2 -relief raised
     .t delete 1.0 end
-    .t insert 1.0 "Line 1 is so long that it wraps around, a couple of times"
+    # Line 1 must wrap exactly twice to get the expected result
+    .t insert 1.0 "Line 1 is so long that it occupies 3 display lines"
     foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
 	.t insert end "\nLine $i"
     }
     updateText
     .t delete 1.6 1.end
     destroy .f2
     updateText
     list $tk_textRelayout $tk_textRedraw
-} {{1.0 9.0 10.0} {borders 1.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0}}
+} {{1.0 9.0 10.0} {1.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0}}
 .t configure -bd 0
 test textDisp-6.7 {DisplayText, vertical scrollbar updates} {
     .t configure -wrap char
     .t delete 1.0 end
     updateText
@@ -982,11 +1119,11 @@
     .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
     .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
     updateText
     set scrollInfo
 } [list 0.0 [expr {4.0/11}]]
-test textDisp-6.10 {DisplayText, redisplay embedded windows after scroll.} {aqua} {
+test textDisp-6.10 {DisplayText, redisplay embedded windows after scroll} {aqua} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "Line 1"
     foreach i {2 3 4} {
 	.t insert end "\nLine $i"
@@ -1005,81 +1142,85 @@
     updateText
     list $tk_textEmbWinDisplay
 } {{4.0 6.0}}
 
 
-# The following group of tests is marked non-portable because
-# they result in a lot of extra redisplay under Ultrix.  I don't
-# know why this is so.
-
 .t configure -bd 2 -relief raised -wrap char
 .t delete 1.0 end
 .t insert 1.0 "Line 1 is so long that it wraps around, a couple of times"
 foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
     .t insert end "\nLine $i"
 }
-test textDisp-7.1 {TkTextRedrawRegion} {nonPortable} {
+test textDisp-7.1 {TkTextRedrawRegion} {aquaKnownBug} {
+# constrained by aquaKnownBug until ticket [aad0231f07] is fixed
     frame .f2 -bg #ff0000
     place .f2 -in .t -relx 0.2 -relwidth 0.6 -rely 0.22 -relheight 0.55
     updateText
     destroy .f2
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{} {1.40 2.0 3.0 4.0 5.0 6.0}}
-test textDisp-7.2 {TkTextRedrawRegion} {nonPortable} {
+test textDisp-7.2 {TkTextRedrawRegion} {aquaKnownBug} {
+# constrained by aquaKnownBug until ticket [aad0231f07] is fixed
     frame .f2 -bg #ff0000
     place .f2 -in .t -relx 0 -relwidth 0.5 -rely 0 -relheight 0.5
     updateText
     destroy .f2
     updateText
     list $tk_textRelayout $tk_textRedraw
-} {{} {borders 1.0 1.20 1.40 2.0 3.0}}
-test textDisp-7.3 {TkTextRedrawRegion} {nonPortable} {
+} {{} {1.0 1.20 1.40 2.0 3.0}}
+test textDisp-7.3 {TkTextRedrawRegion} {aquaKnownBug} {
+# constrained by aquaKnownBug until ticket [aad0231f07] is fixed
     frame .f2 -bg #ff0000
     place .f2 -in .t -relx 0.5 -relwidth 0.5 -rely 0.5 -relheight 0.5
     updateText
     destroy .f2
     updateText
     list $tk_textRelayout $tk_textRedraw
-} {{} {borders 4.0 5.0 6.0 7.0 8.0}}
-test textDisp-7.4 {TkTextRedrawRegion} {nonPortable} {
-    frame .f2 -bg #ff0000
+} {{} {4.0 5.0 6.0 7.0 8.0}}
+test textDisp-7.4 {TkTextRedrawRegion} {aquaKnownBug} {
+ # constrained by aquaKnownBug until ticket [aad0231f07] is fixed
+   frame .f2 -bg #ff0000
     place .f2 -in .t -relx 0.4 -relwidth 0.2 -rely 0 -relheight 0.2 \
 	    -bordermode ignore
     updateText
     destroy .f2
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{} {borders 1.0 1.20}}
-test textDisp-7.5 {TkTextRedrawRegion} {nonPortable} {
+test textDisp-7.5 {TkTextRedrawRegion} {aquaKnownBug} {
+# constrained by aquaKnownBug until ticket [aad0231f07] is fixed
     frame .f2 -bg #ff0000
     place .f2 -in .t -relx 0.4 -relwidth 0.2 -rely 1.0 -relheight 0.2 \
 	    -anchor s -bordermode ignore
     updateText
     destroy .f2
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{} {borders 7.0 8.0}}
-test textDisp-7.6 {TkTextRedrawRegion} {nonPortable} {
+test textDisp-7.6 {TkTextRedrawRegion} {aquaKnownBug} {
+# constrained by aquaKnownBug until ticket [aad0231f07] is fixed
     frame .f2 -bg #ff0000
     place .f2 -in .t -relx 0 -relwidth 0.2 -rely 0.55 -relheight 0.2 \
 	    -anchor w -bordermode ignore
     updateText
     destroy .f2
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{} {borders 3.0 4.0 5.0}}
-test textDisp-7.7 {TkTextRedrawRegion} {nonPortable} {
+test textDisp-7.7 {TkTextRedrawRegion} {aquaKnownBug} {
+# constrained by aquaKnownBug until ticket [aad0231f07] is fixed
     frame .f2 -bg #ff0000
     place .f2 -in .t -relx 1.0 -relwidth 0.2 -rely 0.55 -relheight 0.2 \
 	    -anchor e -bordermode ignore
     updateText
     destroy .f2
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{} {borders 3.0 4.0 5.0}}
-test textDisp-7.8 {TkTextRedrawRegion} {nonPortable} {
+test textDisp-7.8 {TkTextRedrawRegion} {aquaKnownBug} {
+# constrained by aquaKnownBug until ticket [aad0231f07] is fixed
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\n"
     frame .f2 -bg #ff0000
     place .f2 -in .t -relx 0.0 -relwidth 0.4 -rely 0.35 -relheight 0.4 \
 	    -anchor nw -bordermode ignore
@@ -1088,11 +1229,11 @@
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{} {borders 4.0 5.0 6.0 7.0 eof}}
 .t configure -bd 0
 
-test textDisp-8.1 {TkTextChanged: redisplay whole lines} {textfonts} {
+test textDisp-8.1 {TkTextChanged: redisplay whole lines} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2 is so long that it wraps around, two times"
     foreach i {3 4 5 6 7 8 9 10 11 12 13 14 15} {
 	.t insert end "\nLine $i"
@@ -1099,11 +1240,11 @@
     }
     updateText
     .t delete 2.36 2.38
     updateText
     list $tk_textRelayout $tk_textRedraw [.t bbox 2.32]
-} [list {2.0 2.18 2.38} {2.0 2.18 2.38} [list 101 [expr {2*$fixedDiff + 29}] 7 $fixedHeight]]
+} [list {2.0 2.18 2.38} {2.0 2.18 2.38} [list [xchar 14] [yline 3] $fixedWidth $fixedHeight]]
 .t configure -wrap char
 test textDisp-8.2 {TkTextChanged, redisplay whole lines} {
     .t delete 1.0 end
     .t insert 1.0 "Line 1 is so long that it wraps around, two times"
     foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
@@ -1156,11 +1297,11 @@
     updateText
     .t delete 1.41 1.44
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{1.0 1.20 1.40} {1.0 1.20 1.40}}
-test textDisp-8.7 {TkTextChanged} failsOnXQuarz {
+test textDisp-8.7 {TkTextChanged} {
     .t delete 1.0 end
     .t insert 1.0 "Line 1 is so long that it wraps around, two times"
     foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
 	.t insert end "\nLine $i"
     }
@@ -1178,11 +1319,11 @@
     updateText
     .t delete 2.2
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {2.0 2.0}
-test textDisp-8.9 {TkTextChanged} failsOnXQuarz {
+test textDisp-8.9 {TkTextChanged} {
     .t delete 1.0 end
     .t insert 1.0 "Line 1 is so long that it wraps around, two times"
     foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
 	.t insert end "\nLine $i"
     }
@@ -1189,11 +1330,11 @@
     updateText
     .t delete 2.0 3.0
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{2.0 8.0} {2.0 8.0}}
-test textDisp-8.10 {TkTextChanged} failsOnUbuntu {
+test textDisp-8.10 {TkTextChanged} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
     .t tag add big 2.19
     updateText
@@ -1249,29 +1390,33 @@
     .t insert 3.0 ""
     .t delete 1.0 2.0
     update idletasks
 } {}
 
-test textDisp-9.1 {TkTextRedrawTag} failsOnUbuntu {
+test textDisp-9.1 {TkTextRedrawTag} -body {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
     updateText
     .t tag add big 2.2 2.4
     updateText
-    list $tk_textRelayout $tk_textRedraw
-} {{2.0 2.18} {2.0 2.18}}
-test textDisp-9.2 {TkTextRedrawTag} {textfonts} {
+   list $tk_textRelayout $tk_textRedraw
+# glob matching is to have some tolerance on actually used font size
+# while still testing what we want to test
+} -match glob -result {{2.0 2.1[78]} {2.0 2.1[78]}}
+test textDisp-9.2 {TkTextRedrawTag} -body {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
     updateText
     .t tag add big 1.2 2.4
     updateText
     list $tk_textRelayout $tk_textRedraw
-} {{1.0 2.0 2.17} {1.0 2.0 2.17}}
-test textDisp-9.3 {TkTextRedrawTag} failsOnUbuntu {
+# glob matching is to have some tolerance on actually used font size
+# while still testing what we want to test
+}  -match glob -result {{1.0 2.0 2.1[678]} {1.0 2.0 2.1[678]}}
+test textDisp-9.3 {TkTextRedrawTag} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
     updateText
     .t tag add big 2.2 2.4
@@ -1278,11 +1423,11 @@
     updateText
     .t tag remove big 1.0 end
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{2.0 2.20} {2.0 2.20 eof}}
-test textDisp-9.4 {TkTextRedrawTag} failsOnUbuntu {
+test textDisp-9.4 {TkTextRedrawTag} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
     updateText
     .t tag add big 2.2 2.20
@@ -1289,22 +1434,26 @@
     updateText
     .t tag remove big 1.0 end
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{2.0 2.20} {2.0 2.20 eof}}
-test textDisp-9.5 {TkTextRedrawTag} {failsOnUbuntu failsOnXQuarz} {
-    .t configure -wrap char
+test textDisp-9.5 {TkTextRedrawTag} -setup {
+    .t configure -wrap char -height [expr {[.t cget -height]+10}]
+} -body {
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
     updateText
     .t tag add big 2.2 2.end
     updateText
     .t tag remove big 1.0 end
     updateText
     list $tk_textRelayout $tk_textRedraw
-} {{2.0 2.20} {2.0 2.20 eof}}
-test textDisp-9.6 {TkTextRedrawTag} failsOnUbuntu {
+} -cleanup {
+    .t configure -height [expr {[.t cget -height]-10}]
+    updateText
+} -result {{2.0 2.20} {2.0 2.20 eof}}
+test textDisp-9.6 {TkTextRedrawTag} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap"
     updateText
     .t tag add big 2.2 3.5
@@ -1311,40 +1460,44 @@
     updateText
     .t tag remove big 1.0 end
     updateText
     list $tk_textRelayout $tk_textRedraw
 } {{2.0 2.20 3.0 3.20} {2.0 2.20 3.0 3.20 eof}}
-test textDisp-9.7 {TkTextRedrawTag} failsOnUbuntu {
+test textDisp-9.7 {TkTextRedrawTag} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
     .t tag add big 2.19
     updateText
     .t tag remove big 2.19
     updateText
     set tk_textRedraw
 } {2.0 2.20 eof}
-test textDisp-9.8 {TkTextRedrawTag} {textfonts} {
+test textDisp-9.8 {TkTextRedrawTag} -body {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
     .t tag add big 1.0 2.0
     updateText
     .t tag add big 2.0 2.5
     updateText
     set tk_textRedraw
-} {2.0 2.17}
-test textDisp-9.9 {TkTextRedrawTag} {textfonts} {
+# glob matching is to have some tolerance on actually used font size
+# while still testing what we want to test
+} -match glob -result {2.0 2.1[678]}
+test textDisp-9.9 {TkTextRedrawTag} -body {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
     .t tag add big 1.0 2.0
     updateText
     .t tag add big 1.5 2.5
     updateText
     set tk_textRedraw
-} {2.0 2.17}
+# glob matching is to have some tolerance on actually used font size
+# while still testing what we want to test
+} -match glob -result {2.0 2.1[678]}
 test textDisp-9.10 {TkTextRedrawTag} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
     .t tag add big 1.0 2.0
@@ -1451,11 +1604,11 @@
 test textDisp-11.1 {TkTextSetYView} {
     .t yview 30.0
     updateText
     .t index @0,0
 } {30.0}
-test textDisp-11.2 {TkTextSetYView} failsOnXQuarz {
+test textDisp-11.2 {TkTextSetYView} {
     .t yview 30.0
     updateText
     .t yview 32.0
     updateText
     list [.t index @0,0] $tk_textRedraw
@@ -1465,11 +1618,11 @@
     updateText
     .t yview 28.0
     updateText
     list [.t index @0,0] $tk_textRedraw
 } {28.0 {28.0 29.0}}
-test textDisp-11.4 {TkTextSetYView} failsOnXQuarz {
+test textDisp-11.4 {TkTextSetYView} {
     .t yview 30.0
     updateText
     .t yview 31.4
     updateText
     list [.t index @0,0] $tk_textRedraw
@@ -1496,19 +1649,19 @@
     set tk_textRedraw {}
     .t yview -pickplace 26.0
     updateText
     list [.t index @0,0] $tk_textRedraw
 } {21.0 {21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0}}
-test textDisp-11.8 {TkTextSetYView} failsOnXQuarz {
+test textDisp-11.8 {TkTextSetYView} {
     .t yview 30.0
     updateText
     set tk_textRedraw {}
     .t yview -pickplace 41.0
     updateText
     list [.t index @0,0] $tk_textRedraw
 } {32.0 {40.0 41.0}}
-test textDisp-11.9 {TkTextSetYView} failsOnXQuarz {
+test textDisp-11.9 {TkTextSetYView} {
     .t yview 30.0
     updateText
     set tk_textRedraw {}
     .t yview -pickplace 43.0
     updateText
@@ -1528,11 +1681,11 @@
     set tk_textRedraw {}
     .t yview 197.0
     updateText
     list [.t index @0,0] $tk_textRedraw
 } {191.0 {191.0 192.0 193.0 194.0 195.0 196.0}}
-test textDisp-11.12 {TkTextSetYView, wrapped line is off-screen} failsOnXQuarz {
+test textDisp-11.12 {TkTextSetYView, wrapped line is off-screen} {
     .t insert 10.0 "Long line with enough text to wrap\n"
     .t yview 1.0
     updateText
     set tk_textRedraw {}
     .t see 10.30
@@ -1666,10 +1819,25 @@
     wm geometry .top 200x[expr {$lineheight / 2}]
     updateText
     .top.t see 1.0
     .top.t index @0,[expr {$lineheight - 2}]
 } {1.0}
+test textDisp-11.22 {TkTextSetYView, peer has -startline} {
+    .top.t delete 1.0 end
+    for {set i 1} {$i <= 50} {incr i} {
+        .top.t insert end "Line $i\n"
+    }
+    pack [.top.t peer create .top.p] -side left
+    pack [scrollbar .top.sb -command {.top.p yview}] -side left -fill y
+    .top.p configure -startline 5 -endline 35 -yscrollcommand {.top.sb set}
+    updateText
+    .top.p yview moveto 0
+    updateText
+    set res [.top.p get @0,0 "@0,0 lineend"]
+    destroy .top.p
+    set res
+} {Line 5}
 
 .t configure -wrap word
 .t delete 50.0 51.0
 .t insert 50.0 "This is a long line, one that will wrap around twice.\n"
 test textDisp-12.1 {MeasureUp} {
@@ -1748,11 +1916,11 @@
     .t see 30.50
     set x [.t index @0,0]
     .t configure -wrap none
     set x
 } {27.0}
-test textDisp-13.7 {TkTextSeeCmd procedure} {textfonts} {
+test textDisp-13.7 {TkTextSeeCmd procedure} {
     .t xview moveto 0
     .t yview moveto 0
     .t tag add sel 30.20
     .t tag add sel 30.40
     updateText
@@ -1764,12 +1932,15 @@
     lappend x [.t bbox 30.39]
     .t see 30.38
     lappend x [.t bbox 30.38]
     .t see 30.20
     lappend x [.t bbox 30.20]
-} [list [list 73 [expr {5*$fixedDiff + 68}] 7 $fixedHeight] [list 3 [expr {5*$fixedDiff + 68}] 7 $fixedHeight] [list 3 [expr {5*$fixedDiff + 68}] 7 $fixedHeight] [list 73 [expr {5*$fixedDiff + 68}] 7 $fixedHeight]]
-test textDisp-13.8 {TkTextSeeCmd procedure} {textfonts} {
+} [list [list [xchar 10] [yline 6] $fixedWidth $fixedHeight] \
+	[list [xchar 0] [yline 6] $fixedWidth $fixedHeight] \
+	[list [xchar 0] [yline 6] $fixedWidth $fixedHeight] \
+	[list [xchar 10] [yline 6] $fixedWidth $fixedHeight]]
+test textDisp-13.8 {TkTextSeeCmd procedure} {
     .t xview moveto 0
     .t yview moveto 0
     .t tag add sel 30.20
     .t tag add sel 30.50
     updateText
@@ -1779,12 +1950,20 @@
     lappend x [.t bbox 30.60]
     .t see 30.65
     lappend x [.t bbox 30.65]
     .t see 30.90
     lappend x [.t bbox 30.90]
-} [list [list 73 [expr {9*$fixedDiff/2 + 64}] 7 $fixedHeight] [list 136 [expr {9*$fixedDiff/2 + 64}] 7 $fixedHeight] [list 136 [expr {9*$fixedDiff/2 + 64}] 7 $fixedHeight] [list 73 [expr {9*$fixedDiff/2 + 64}] 7 $fixedHeight]]
-test textDisp-13.9 {TkTextSeeCmd procedure} {textfonts} {
+    # contrary to textDisp-13.7 above there is no yview command in this test
+    # therefore take into account that the top line is partially hidden
+    set y [expr {[yline 6] + [lindex [.t bbox @0,0] 1] - [bo]}]
+    set expected [list [list [xchar 10] $y $fixedWidth $fixedHeight] \
+                       [list [xchar 19] $y $fixedWidth $fixedHeight] \
+                       [list [xchar 19] $y $fixedWidth $fixedHeight] \
+                       [list [xchar 10] $y $fixedWidth $fixedHeight]]
+    lequal $x $expected
+} {1}
+test textDisp-13.9 {TkTextSeeCmd procedure} {
     wm geom . [expr {$width-2}]x$height
     .t xview moveto 0
     .t yview moveto 0
     .t tag add sel 30.20
     .t tag add sel 30.50
@@ -1795,12 +1974,20 @@
     lappend x [.t bbox 30.60]
     .t see 30.65
     lappend x [.t bbox 30.65]
     .t see 30.90
     lappend x [.t bbox 30.90]
-} [list [list 74 [expr {9*$fixedDiff/2 + 66}] 7 $fixedHeight] [list 138 [expr {9*$fixedDiff/2 + 66}] 7 $fixedHeight] [list 138 [expr {9*$fixedDiff/2 + 66}] 7 $fixedHeight] [list 74 [expr {9*$fixedDiff/2 + 66}] 7 $fixedHeight]]
-test textDisp-13.10 {TkTextSeeCmd procedure} {} {
+    # contrary to textDisp-13.7 above there is no yview command in this test
+    # therefore take into account that the top line is partially hidden
+    set y [expr {[yline 6] + [lindex [.t bbox @0,0] 1] - [bo]}]
+    set expected [list [list [expr {[bo]+round([winfo width .t]-2*[bo])/2}] $y $fixedWidth $fixedHeight] \
+                       [list [xcharr 1] $y $fixedWidth $fixedHeight] \
+                       [list [xcharr 1] $y $fixedWidth $fixedHeight] \
+                       [list [expr {[bo]+round([winfo width .t]-2*[bo])/2}] $y $fixedWidth $fixedHeight]]
+    lequal $x $expected
+} {1}
+test textDisp-13.10 {TkTextSeeCmd procedure} {
     # SF Bug 641778
     set w .tsee
     destroy $w
     text $w -font {Helvetica 8 normal} -bd 16
     $w insert end Hello
@@ -1815,11 +2002,10 @@
     # this character
     toplevel .top2
     pack [text .top2.t2 -wrap none]
     for {set i 1} {$i < 5} {incr i} {
         .top2.t2 insert end [string repeat "Line $i: éèàçù" 5]\n
-
     }
     wm geometry .top2 300x200+0+0
     updateText
     .top2.t2 see "1.0 lineend"
     updateText
@@ -1869,34 +2055,34 @@
     list [catch {.t xview moveto a b} msg] $msg
 } {1 {wrong # args: should be ".t xview moveto fraction"}}
 test textDisp-14.6 {TkTextXviewCmd procedure} {
     list [catch {.t xview moveto a} msg] $msg
 } {1 {expected floating-point number but got "a"}}
-test textDisp-14.7 {TkTextXviewCmd procedure} failsOnUbuntu {
+test textDisp-14.7 {TkTextXviewCmd procedure} {
     .t delete 1.0 end
     .t insert end xxxxxxxxx\n
-    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
+    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n" ; # 56 chars on this line
     .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
     .t xview moveto .3
     .t xview
-} [list [expr {118.0/392}] [expr {258.0/392}]]
+} [list [expr {round(0.3*(56*$fixedWidth))/(56.0*$fixedWidth)}] [expr {round(0.3*(56*$fixedWidth)+20*$fixedWidth)/(56.0*$fixedWidth)}]]
 test textDisp-14.8 {TkTextXviewCmd procedure} {
     .t delete 1.0 end
     .t insert end xxxxxxxxx\n
-    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
+    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n" ; # 56 chars on this line
     .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
     .t xview moveto -.4
     .t xview
-} [list 0.0 [expr {5.0/14}]]
+} [list 0.0 [expr {20.0/56}]]
 test textDisp-14.9 {TkTextXviewCmd procedure} {
     .t delete 1.0 end
     .t insert end xxxxxxxxx\n
-    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
+    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n" ; # 56 chars on this line
     .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
     .t xview m 1.4
     .t xview
-} [list [expr {9.0/14}] 1.0]
+} [list [expr {(56.0-20)/56}] 1.0]
 test textDisp-14.10 {TkTextXviewCmd procedure} {
     list [catch {.t xview scroll a} msg] $msg
 } {1 {wrong # args: should be ".t xview scroll number pages|pixels|units"}}
 test textDisp-14.11 {TkTextXviewCmd procedure} {
     list [catch {.t xview scroll a b c} msg] $msg
@@ -2028,18 +2214,24 @@
 for {set i 2} {$i <= 200} {incr i} {
     .t insert end "\nLine $i"
 }
 .t tag add big 100.0 105.0
 .t insert 151.end { has a lot of extra text, so that it wraps around on the screen several times over.}
-.t insert 153.end { also has enoug extra text to wrap.}
+.t insert 153.end { also has largely enough extra text to wrap.}
 updateText
-.t count -update -ypixels 1.0 end
+set totpix [.t count -update -ypixels 1.0 end]
+# check that the wrapping lines wrap exactly 6 times in total (4 times for line 151, and twice for line 153),
+# this is an assumption of the upcoming tests
+if {[expr {double(($totpix-5*$heightDiff)/$fixedHeight)}] != 206.0} {
+    puts "---> Warning: the font actually used by the tests, which is \"[font actual [.t cget -font]]\",\
+is too different from the requested \"[.t cget -font]\". Some of the upcoming tests will probably fail."
+}
 test textDisp-16.1 {TkTextYviewCmd procedure} {
     .t yview 21.0
     set x [.t yview]
     .t yview 1.0
-    list [expr {int([lindex $x 0]*100)}] [expr {int ([lindex $x 1] * 100)}]
+    list [expr {int([lindex $x 0]*100)}] [expr {int([lindex $x 1]*100)}]
 } {9 14}
 test textDisp-16.2 {TkTextYviewCmd procedure} {
     list [catch {.t yview 2 3} msg] $msg
 } {1 {bad option "2": must be moveto or scroll}}
 test textDisp-16.3 {TkTextYviewCmd procedure} {
@@ -2069,11 +2261,11 @@
     list [catch {.t yview moveto a b} msg] $msg
 } {1 {wrong # args: should be ".t yview moveto fraction"}}
 test textDisp-16.10 {TkTextYviewCmd procedure, "moveto" option} {
     list [catch {.t yview moveto gorp} msg] $msg
 } {1 {expected floating-point number but got "gorp"}}
-test textDisp-16.11 {TkTextYviewCmd procedure, "moveto" option} failsOnUbuntu {
+test textDisp-16.11 {TkTextYviewCmd procedure, "moveto" option} {
     .t yview moveto 0.5
     .t index @0,0
 } {103.0}
 test textDisp-16.12 {TkTextYviewCmd procedure, "moveto" option} {
     .t yview moveto -1
@@ -2081,29 +2273,58 @@
 } {1.0}
 test textDisp-16.13 {TkTextYviewCmd procedure, "moveto" option} {
     .t yview moveto 1.1
     .t index @0,0
 } {191.0}
-test textDisp-16.14 {TkTextYviewCmd procedure, "moveto" option} failsOnUbuntu {
+test textDisp-16.14 {TkTextYviewCmd procedure, "moveto" option} {
+    # y move to 3/4 of text widget content height
+    .t yview moveto .75
+    # target y position is inside line 151, which wraps 4 times
+    # exactly which display line depends on actual font size
+    set ytargetline [expr {150*$fixedHeight+5*$heightDiff}]
+    set expected 151.0
+    while {[expr {$ytargetline+$fixedHeight}] <= [expr {round(0.75*$totpix)}]} {
+        incr ytargetline $fixedHeight
+	set expected [.t index "$expected + 1 display line"]
+    }
+    lequal [.t index @0,0] $expected
+} {1}
+test textDisp-16.15 {TkTextYviewCmd procedure, "moveto" option} {
+    # y move to 3/4 of text widget content height plus just one line height minus one pixel
+    .t yview moveto .75
+    set pixtonextline [expr {-[bo] + [lindex [.t bbox @0,0] 1] + [lindex [.t bbox @0,0] 3]}]
+    .t yview moveto [expr {0.75 + ($pixtonextline-1)/double($totpix)}]
+    # target y position is inside line 151, which wraps 4 times
+    # exactly which display line depends on actual font size
+    set ytargetline [expr {150*$fixedHeight+5*$heightDiff}]
+    set expected 151.0
+    while {[expr {$ytargetline+$fixedHeight}] <= [expr {round(0.75*$totpix + ($pixtonextline-1))}]} {
+        incr ytargetline $fixedHeight
+	set expected [.t index "$expected + 1 display line"]
+    }
+    lequal [.t index @0,0] $expected
+} {1}
+test textDisp-16.16 {TkTextYviewCmd procedure, "moveto" option} {
+    # y move to 3/4 of text widget content height plus exactly one line height
     .t yview moveto .75
-    .t index @0,0
-} {151.60}
-test textDisp-16.15 {TkTextYviewCmd procedure, "moveto" option} failsOnUbuntu {
-    .t yview moveto .752
-    .t index @0,0
-} {151.60}
-test textDisp-16.16 {TkTextYviewCmd procedure, "moveto" option} textfonts {
-    set count [expr {5 * $bigHeight + 150 * $fixedHeight}]
-    set extra [expr {0.04 * double($fixedDiff * 150) / double($count)}]
-    .t yview moveto [expr {.753 - $extra}]
-    .t index @0,0
-} {151.60}
-test textDisp-16.17 {TkTextYviewCmd procedure, "moveto" option} failsOnUbuntu {
+    set pixtonextline [expr {-[bo] + [lindex [.t bbox @0,0] 1] + [lindex [.t bbox @0,0] 3]}]
+    .t yview moveto [expr {0.75 + $pixtonextline/double($totpix)}]
+    # target y position is inside line 151, which wraps 4 times
+    # exactly which display line depends on actual font size
+    set ytargetline [expr {150*$fixedHeight+5*$heightDiff}]
+    set expected 151.0
+    while {[expr {$ytargetline+$fixedHeight}] <= [expr {round(0.75*$totpix + $pixtonextline)}]} {
+        incr ytargetline $fixedHeight
+	set expected [.t index "$expected + 1 display line"]
+    }
+    lequal [.t index @0,0] $expected
+} {1}
+test textDisp-16.17 {TkTextYviewCmd procedure, "moveto" option} {
     .t yview moveto .755
     .t index @0,0
 } {151.80}
-test textDisp-16.18 {TkTextYviewCmd procedure, "moveto" roundoff} {textfonts} {
+test textDisp-16.18 {TkTextYviewCmd procedure, "moveto" roundoff} {
     catch {destroy .top1}
     toplevel .top1
     wm geometry .top1 +0+0
     text .top1.t -height 3 -width 4 -wrap none -setgrid 1 -padx 6 \
 	-spacing3 6
@@ -2146,21 +2367,28 @@
     .t yview 5.0
     updateText
     .t yview scroll -3 pa
     .t index @0,0
 } {1.0}
-test textDisp-16.25 {TkTextYviewCmd procedure, "scroll" option, back pages} {
+test textDisp-16.25 {TkTextYviewCmd procedure, "scroll" option, back pages} -setup {
+    # this frame is needed because some window managers don't allow the overall
+    # height of a window to get very narrow, triggering false test failure
+    frame .f2 -height 20
+    pack .f2 -side top
+} -body {
     .t configure -height 1
     updateText
     .t yview 50.0
     updateText
     .t yview scroll -1 pages
     set x [.t index @0,0]
     .t configure -height 10
     updateText
     set x
-} {49.0}
+} -cleanup {
+    destroy .f2
+} -result {49.0}
 test textDisp-16.26 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
     .t yview 50.0
     updateText
     .t yview scroll 1 pages
     .t index @0,0
@@ -2169,20 +2397,21 @@
     .t yview 50.0
     updateText
     .t yview scroll 2 pages
     .t index @0,0
 } {66.0}
-test textDisp-16.28 {TkTextYviewCmd procedure, "scroll" option, forward pages} {textfonts} {
+test textDisp-16.28 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
     .t yview 98.0
     updateText
+    # The man page does not say it but the code does: scrolling 1 page actually uses the
+    # window height minus two lines, so that there's some overlap between adjacent pages.
+    # Note: it's a bit tricky but we only need to subtract one [bo] from [winfo height .t] here
+    # because the origin of @x,y coordinates is at borderwidth start, not at text area start.
+    set expected [.t index @0,[expr {[winfo height .t]-[bo]-2*$fixedHeight}]]
     .t yview scroll 1 page
-    set res [expr {int([.t index @0,0])}]
-    if {$fixedDiff > 1} {
-	incr res -1
-    }
-    set res
-} 102
+    lequal [.t index @0,0] $expected
+} {1}
 test textDisp-16.29 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
     .t configure -height 1
     updateText
     .t yview 50.0
     updateText
@@ -2259,20 +2488,20 @@
     list [catch {.t yview scroll 1.3blah pixels} msg] $msg
 } {1 {bad screen distance "1.3blah"}}
 test textDisp-16.39 {TkTextYviewCmd procedure} {
     list [catch {.t yview scroll 1.3i pixels} msg] $msg
 } {0 {}}
-test textDisp-16.40 {text count -xpixels} failsOnUbuntu {
+test textDisp-16.40 {text count -xpixels} {
     set res {}
     lappend res [.t count -xpixels 1.0 1.5] \
       [.t count -xpixels 1.5 1.0] \
       [.t count -xpixels 1.0 13.0] \
       [.t count -xpixels 1.0 "1.0 displaylineend"] \
       [.t count -xpixels 1.0 "1.0 lineend"] \
       [.t count -xpixels 1.0 "1.0 displaylineend"] \
       [.t count -xpixels 1.0 end]
-} {35 -35 0 42 42 42 0}
+} [list [expr {5*$fixedWidth}] [expr {-5*$fixedWidth}] 0 [expr {6*$fixedWidth}] [expr {6*$fixedWidth}] [expr {6*$fixedWidth}] 0]
 test textDisp-16.41 {text count -xpixels with indices in elided lines} {
     set res {}
     .t delete 1.0 end
     for {set i 1} {$i < 40} {incr i} {
         .t insert end [string repeat "Line $i" 20]
@@ -2354,56 +2583,95 @@
 test textDisp-17.4 {TkTextScanCmd procedure} {
     list [catch {.t scan stupid -2 bogus} msg] $msg
 } {1 {expected integer but got "bogus"}}
 test textDisp-17.5 {TkTextScanCmd procedure} {
     list [catch {.t scan stupid 123 456} msg] $msg
-} {1 {bad scan option "stupid": must be mark or dragto}}
-test textDisp-17.6 {TkTextScanCmd procedure} {textfonts} {
+} {1 {bad scan option "stupid": must be dragto or mark}}
+test textDisp-17.6 {TkTextScanCmd procedure} {
     .t yview 1.0
     .t xview moveto 0
+    updateText
+    set expected [.t index @[expr {[bo]+50}],[expr {[bo]+50}]]
     .t scan mark 40 60
     .t scan dragto 35 55
-    .t index @0,0
-} {4.7}
-test textDisp-17.7 {TkTextScanCmd procedure} {textfonts} {
+    updateText
+    lequal [.t index @0,0] $expected
+} {1}
+test textDisp-17.7 {TkTextScanCmd procedure} {
+    # 1st result
+    .t yview 1.0
+    .t xview moveto 0
+    updateText
+    set expected [.t index @[expr {[bo]+20*$fixedWidth-50}],[expr {[bo]+9*$fixedHeight-50}]]
     .t yview 10.0
+    .t xview scroll 20 units
+    updateText
+    .t scan mark -10 60
+    .t scan dragto -5 65
+    updateText
+    set x [.t index @0,0]
+    # 2nd result
+    .t yview 1.0
     .t xview moveto 0
+    updateText
+    lappend expected [.t index @[expr {[bo]+20*$fixedWidth-50-50}],[expr {[bo]+9*$fixedHeight-50-70}]]
+    .t yview 10.0
     .t xview scroll 20 units
+    updateText
     .t scan mark -10 60
     .t scan dragto -5 65
-    .t index @0,0
-    set x [.t index @0,0]
-    .t scan dragto 0 [expr {70 + $fixedDiff}]
-    list $x [.t index @0,0]
-} {6.12 2.5}
-test textDisp-17.8 {TkTextScanCmd procedure} {textfonts} {
+    updateText
+    .t scan dragto 0 72
+    updateText
+    lequal [list $x [.t index @0,0]] $expected
+} {1}
+test textDisp-17.8 {TkTextScanCmd procedure} {
     .t yview 1.0
     .t xview moveto 0
+    updateText
+    set expected [.t index @[expr {[bo]+50}],[expr {[bo]+50}]]
     .t scan mark 0 60
     .t scan dragto 30 100
+    updateText
     .t scan dragto 25 95
-    .t index @0,0
-} {4.7}
-test textDisp-17.9 {TkTextScanCmd procedure} {textfonts} {
+    updateText
+    lequal [.t index @0,0] $expected
+} {1}
+test textDisp-17.9 {TkTextScanCmd procedure} {
     .t yview end
     .t xview moveto 0
+    updateText
+    # this brings us at lower right corner of the text
     .t xview scroll 100 units
+    updateText
+    # this does not trigger any scroll, we're already at the corner
     .t scan mark 90 60
     .t scan dragto 10 0
+    updateText
+    set expected [.t index @[expr {[winfo width .t]-[bo]-40}],[expr {[winfo height .t]-[bo]-50}]]
+    set expected [.t index "$expected - [.t cget -height] lines - [.t cget -width] chars"]
     .t scan dragto 14 5
-    .t index @0,0
-} {18.44}
+    updateText
+    lequal [.t index @0,0] $expected
+} {1}
 .t configure -wrap word
-test textDisp-17.10 {TkTextScanCmd procedure, word wrapping} {textfonts} {
+test textDisp-17.10 {TkTextScanCmd procedure, word wrapping} {
     .t yview 10.0
+    updateText
+    set origin [.t index @0,0]
+    set expected [.t index "$origin - [expr {int(ceil(50.0/$fixedHeight))}] display lines"]
     .t scan mark -10 60
     .t scan dragto -5 65
+    updateText
     set x [.t index @0,0]
-    .t scan dragto 0 [expr {70 + $fixedDiff}]
-    list $x [.t index @0,0]
-} {9.0 8.0}
+    lappend expected [.t index "$origin - [expr {int(ceil((50.0+70.0)/$fixedHeight))}] display lines"]
+    .t scan dragto 0 72
+    updateText
+    lequal [list $x [.t index @0,0]] $expected
+} {1}
 .t configure -xscrollcommand scroll -yscrollcommand {}
+
 test textDisp-18.1 {GetXView procedure} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert end xxxxxxxxx\n
     .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
@@ -2499,10 +2767,11 @@
     invoked from within
 "scrollError 0.0 1.0"
     (horizontal scrolling command executed by text)}}
 catch {rename bgerror {}}
 catch {rename bogus {}}
+
 .t configure -xscrollcommand {} -yscrollcommand scroll
 test textDisp-19.1 {GetYView procedure} {
     .t configure -wrap char
     .t delete 1.0 end
     updateText
@@ -2571,11 +2840,11 @@
     .t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
     .t yview 2.26
     updateText
     set x $scrollInfo
 } {0.125 0.75}
-test textDisp-19.8 {GetYView procedure} failsOnUbuntu {
+test textDisp-19.8 {GetYView procedure} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "Line 1"
     foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
 	.t insert end "\nLine $i"
@@ -2782,11 +3051,11 @@
     scan [wm geom .top] %dx%d twidth theight
     wm geom .top ${twidth}x[expr {$theight - 3}]
     updateText
     .top.t yview
 } [list 0.0 [expr {(5.0 * $fixedHeight - 3.0)/ (5.0 * $fixedHeight)}]]
-test textDisp-19.13 {GetYView procedure, partially visible last line} {textfonts} {
+test textDisp-19.13 {GetYView procedure, partially visible last line} {
     catch {destroy .top}
     toplevel .top
     wm geometry .top +0+0
     text .top.t -width 40 -height 5 -font $fixedFont
     pack .top.t -expand yes -fill both
@@ -2859,31 +3128,36 @@
     .t insert end "times with a little bit left on the last line."
     # Need to update so everything is calculated.
     updateText
     .t count -update -ypixels 1.0 end
     updateText
-    set res {}
-    lappend res \
+    set res [list \
       [.t count -ypixels 1.0 end] \
       [.t count -update -ypixels 1.0 end] \
       [.t count -ypixels 15.0 16.0] \
       [.t count -ypixels 15.0 "16.0 displaylineend +1c"] \
       [.t count -ypixels 16.0 "16.0 displaylineend +1c"] \
-      [.t count -ypixels "16.0 +1 displaylines" "16.0 +4 displaylines +3c"]
-} [list [expr {260 + 20 * $fixedDiff}] [expr {260 + 20 * $fixedDiff}] $fixedHeight [expr {2*$fixedHeight}] $fixedHeight [expr {3*$fixedHeight}]]
-test textDisp-19.17 {count -ypixels with indices in elided lines} {failsOnUbuntu failsOnXQuarz} {
+      [.t count -ypixels "16.0 +1 displaylines" "16.0 +4 displaylines +3c"] ]
+} [list [expr {20 * $fixedHeight}] \
+        [expr {20 * $fixedHeight}] \
+	$fixedHeight \
+	[expr {2*$fixedHeight}] \
+	$fixedHeight \
+	[expr {3*$fixedHeight}]]
+test textDisp-19.17 {count -ypixels with indices in elided lines} {
     .t configure -wrap none
     .t delete 1.0 end
     for {set i 1} {$i < 100} {incr i} {
         .t insert end [string repeat "Line $i" 20]
         .t insert end "\n"
     }
     .t tag add hidden 5.15 20.15
     .t tag configure hidden -elide true
-    set res {}
-    update
-    lappend res \
+    updateText
+    .t count -update -ypixels 1.0 end
+    updateText
+    set res [list \
       [.t count -ypixels 1.0 6.0] \
       [.t count -ypixels 2.0 7.5] \
       [.t count -ypixels 5.0 8.5] \
       [.t count -ypixels 6.1 6.2] \
       [.t count -ypixels 6.1 18.8] \
@@ -2891,27 +3165,35 @@
       [.t count -ypixels 5.2 20.60] \
       [.t count -ypixels 20.60 20.70] \
       [.t count -ypixels 5.0 25.0] \
       [.t count -ypixels 25.0 5.0] \
       [.t count -ypixels 25.4 27.50] \
-      [.t count -ypixels 35.0 38.0]
+      [.t count -ypixels 35.0 38.0] ]
     .t yview 35.0
     lappend res [.t count -ypixels 5.0 25.0]
-} [list [expr {4 * $fixedHeight}] [expr {3 * $fixedHeight}] 0 0 0 0 0 0 [expr {5 * $fixedHeight}] [expr {- 5 * $fixedHeight}] [expr {2 * $fixedHeight}] [expr {3 * $fixedHeight}] [expr {5 * $fixedHeight}]]
-test textDisp-19.18 {count -ypixels with indices in elided lines} {failsOnUbuntu failsOnXQuarz} {
+} [list [expr {4 * $fixedHeight}] \
+        [expr {3 * $fixedHeight}] \
+	0 0 0 0 0 0 \
+	[expr {5 * $fixedHeight}] \
+	[expr {- 5 * $fixedHeight}] \
+	[expr {2 * $fixedHeight}] \
+	[expr {3 * $fixedHeight}] \
+	[expr {5 * $fixedHeight}]]
+test textDisp-19.18 {count -ypixels with indices in elided lines} {
     .t configure -wrap none
     .t delete 1.0 end
     for {set i 1} {$i < 100} {incr i} {
         .t insert end [string repeat "Line $i" 20]
         .t insert end "\n"
     }
     .t tag add hidden 5.15 20.15
     .t tag configure hidden -elide true
     .t yview 35.0
-    set res {}
-    update
-    lappend res [.t count -ypixels 5.0 25.0]
+    updateText
+    .t count -update -ypixels 1.0 end
+    updateText
+    set res [.t count -ypixels 5.0 25.0]
     .t yview scroll [expr {- 15 * $fixedHeight}] pixels
     updateText
     lappend res [.t count -ypixels 5.0 25.0]
 } [list [expr {5 * $fixedHeight}] [expr {5 * $fixedHeight}]]
 test textDisp-19.19 {count -ypixels with indices in elided lines} {
@@ -2933,56 +3215,73 @@
     .t insert end "\nLine $i"
 }
 .t configure -wrap word
 .t delete 50.0 51.0
 .t insert 50.0 "This is a long line, one that will wrap around twice.\n"
-test textDisp-20.1 {FindDLine} failsOnUbuntu {
+test textDisp-20.1 {FindDLine} {
     .t yview 48.0
     list [.t dlineinfo 46.0] [.t dlineinfo 47.0] [.t dlineinfo 49.0] \
 	    [.t dlineinfo 58.0]
-} [list {} {} [list 3 [expr {$fixedDiff + 16}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
-test textDisp-20.2 {FindDLine} failsOnUbuntu {
+} [list {} {} [list [bo] [yline 2] [xw 7] $fixedHeight $fixedAscent] {}]
+test textDisp-20.2 {FindDLine} {
     .t yview 100.0
     .t yview -pickplace 53.0
-    list [.t dlineinfo 50.0] [.t dlineinfo 50.14] [.t dlineinfo 50.21]
-} [list [list 3 [expr {-1 - $fixedDiff/2}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {-1 - $fixedDiff/2}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {12 + $fixedDiff/2}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
-test textDisp-20.3 {FindDLine} failsOnUbuntu {
+    set centlineY [lindex [.t bbox 53.0] 1]
+    set expectedY [expr {$centlineY - int(($centlineY-[bo])/$fixedHeight)*$fixedHeight - $fixedHeight}]
+    set expected [list [list [bo] $expectedY [xw 20] $fixedHeight $fixedAscent] \
+                       [list [bo] $expectedY [xw 20] $fixedHeight $fixedAscent] \
+	               [list [bo] [expr {$expectedY+$fixedHeight}] [xw 19] $fixedHeight $fixedAscent]]
+    set res [list [.t dlineinfo 50.0] [.t dlineinfo 50.14] [.t dlineinfo 50.21]]
+    lequal $res $expected
+} {1}
+test textDisp-20.3 {FindDLine} {
     .t yview 100.0
     .t yview 49.0
     list [.t dlineinfo 50.0] [.t dlineinfo 50.24] [.t dlineinfo 57.0]
-} [list [list 3 [expr {$fixedDiff + 16}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {2*$fixedDiff + 29}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
-test textDisp-20.4 {FindDLine} failsOnUbuntu {
+} [list [list [bo] [yline 2] [xw 20] $fixedHeight $fixedAscent] \
+        [list [bo] [yline 3] [xw 19] $fixedHeight $fixedAscent] \
+	{}]
+test textDisp-20.4 {FindDLine} {
     .t yview 100.0
     .t yview 42.0
     list [.t dlineinfo 50.0] [.t dlineinfo 50.24] [.t dlineinfo 50.40]
-} [list [list 3 [expr {8*$fixedDiff + 107}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {9*$fixedDiff + 120}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
+} [list [list [bo] [yline 9] [xw 20] $fixedHeight $fixedAscent] \
+        [list [bo] [yline 10] [xw 19] $fixedHeight $fixedAscent] \
+	{}]
 .t config -wrap none
-test textDisp-20.5 {FindDLine} failsOnUbuntu {
+test textDisp-20.5 {FindDLine} {
     .t yview 100.0
     .t yview 48.0
     list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 50.40]
-} [list [list 3 [expr {3+2*$fixedHeight}] 371 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {3+2*$fixedHeight}] 371 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {3+2*$fixedHeight}] 371 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
+} [list [list [bo] [yline 3] [xw 53] $fixedHeight $fixedAscent] \
+        [list [bo] [yline 3] [xw 53] $fixedHeight $fixedAscent] \
+	[list [bo] [yline 3] [xw 53] $fixedHeight $fixedAscent]]
 
 .t config -wrap word
-test textDisp-21.1 {TkTextPixelIndex} {textfonts} {
+test textDisp-21.1 {TkTextPixelIndex} {
     .t yview 48.0
-    list [.t index @-10,-10] [.t index @6,6] [.t index @22,6] \
-	    [.t index @102,6] [.t index @38,[expr {$fixedHeight * 4 + 3}]] [.t index @44,67]
-} {48.0 48.0 48.2 48.7 50.45 50.45}
+    set off [expr {[bo]+3}]
+    list [.t index @-10,-10] [.t index @$off,$off] [.t index @[expr {[xchar 2]+2}],$off] \
+	    [.t index @[expr {[xchar 14]+1}],$off] [.t index @[xchar 5],[yline 5]]
+} {48.0 48.0 48.2 48.7 50.45}
 .t insert end \n
-test textDisp-21.2 {TkTextPixelIndex} {textfonts} {
+test textDisp-21.2 {TkTextPixelIndex} {
     .t yview 195.0
-    list [.t index @11,[expr {$fixedHeight * 5 + 5}]] [.t index @11,[expr {$fixedHeight * 6 + 5}]] [.t index @11,[expr {$fixedHeight * 7 + 5}]] \
-	    [.t index @11,1002]
+    set off [expr {[xchar 1]+1}]
+    list [.t index @$off,[expr {[yline 6]+2}]] \
+         [.t index @$off,[expr {[yline 7]+2}]] \
+	 [.t index @$off,[expr {[yline 8]+2}]] \
+	 [.t index @$off,1002]
 } {197.1 198.1 199.1 201.0}
-test textDisp-21.3 {TkTextPixelIndex, horizontal scrolling} {textfonts} {
+test textDisp-21.3 {TkTextPixelIndex, horizontal scrolling} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert end "12345\n"
     .t insert end "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
     .t xview scroll 2 units
-    list [.t index @-5,7] [.t index @5,7] [.t index @33,20]
+    set off [expr {[yline 1]+4}]
+    list [.t index @-5,$off] [.t index @[expr {[xchar 1]-2}],$off] [.t index @[expr {[xchar 4]+2}],[expr {[yline 2]+2}]]
 } {1.2 1.2 2.6}
 test textDisp-21.4 {count -displaylines regression} {
     set message {
    QOTW:  "C/C++, which is used by 16% of users, is the most popular programming language, but Tcl, used by 0%, seems to be the language of choice for the highest scoring users."
 (new line)
@@ -3016,70 +3315,100 @@
 .t configure -wrap word
 .t delete 50.0 51.0
 .t insert 50.0 "This is a long line, one that will wrap around twice.\n"
 updateText
 .t tag add x 50.1
-test textDisp-22.1 {TkTextCharBbox} {textfonts} {
+test textDisp-22.1 {TkTextCharBbox} {
     .t config -wrap word
     .t yview 48.0
     list [.t bbox 47.2] [.t bbox 48.0] [.t bbox 50.5] [.t bbox 50.40] \
 	    [.t bbox 58.0]
-} [list {} [list 3 3 7 $fixedHeight] [list 38 [expr {3+2*$fixedHeight}] 7 $fixedHeight] [list 3 [expr {3+4*$fixedHeight}] 7 $fixedHeight] {}]
-test textDisp-22.2 {TkTextCharBbox} {textfonts} {
+} [list {} \
+        [list [xchar 0] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 5] [yline 3] $fixedWidth $fixedHeight] \
+	[list [xchar 0] [yline 5] $fixedWidth $fixedHeight] \
+	{}]
+test textDisp-22.2 {TkTextCharBbox} {
     .t config -wrap none
     .t yview 48.0
     list [.t bbox 50.5] [.t bbox 50.40] [.t bbox 57.0]
-} [list [list 38 [expr {3+2*$fixedHeight}] 7 $fixedHeight] {} [list 3 [expr {3+9*$fixedHeight}] 7 $fixedHeight]]
-test textDisp-22.3 {TkTextCharBbox, cut-off lines} {textfonts} {
+} [list [list [xchar 5] [yline 3] $fixedWidth $fixedHeight] \
+        {} \
+	[list [xchar 0] [yline 10] $fixedWidth $fixedHeight]]
+test textDisp-22.3 {TkTextCharBbox, cut-off lines} {
+    wm geometry . {}
+    updateText
+    scan [wm geom .] %dx%d oriWidth oriHeight
     .t config -wrap char
     .t yview 10.0
     wm geom . ${width}x[expr {$height-1}]
     updateText
-    list [.t bbox 19.1] [.t bbox 20.1]
-} [list [list 10 [expr {3+9*$fixedHeight}] 7 $fixedHeight] [list 10 [expr {3+10*$fixedHeight}] 7 3]]
-test textDisp-22.4 {TkTextCharBbox, cut-off lines} {textfonts} {
+    set expected [list [list [xchar 1] [yline 10] $fixedWidth $fixedHeight] \
+                       [list [xchar 1] [yline 11] $fixedWidth [expr {($height-1)-$oriHeight}]]]
+    lequal [list [.t bbox 19.1] [.t bbox 20.1]] $expected
+} {1}
+test textDisp-22.4 {TkTextCharBbox, cut-off lines} {
+    wm geometry . {}
+    updateText
+    scan [wm geom .] %dx%d oriWidth oriHeight
     .t config -wrap char
     .t yview 10.0
     wm geom . ${width}x[expr {$height+1}]
     updateText
-    list [.t bbox 19.1] [.t bbox 20.1]
-} [list [list 10 [expr {3+9*$fixedHeight}] 7 $fixedHeight] [list 10 [expr {3+10*$fixedHeight}] 7 5]]
-test textDisp-22.5 {TkTextCharBbox, cut-off char} {textfonts} {
+    set expected [list [list [xchar 1] [yline 10] $fixedWidth $fixedHeight] \
+                       [list [xchar 1] [yline 11] $fixedWidth [expr {($height+1)-$oriHeight}]]]
+    lequal [list [.t bbox 19.1] [.t bbox 20.1]] $expected
+} {1}
+test textDisp-22.5 {TkTextCharBbox, cut-off char} {
+    wm geometry . {}
+    updateText
     .t config -wrap none
     .t yview 10.0
-    wm geom . [expr {$width-95}]x$height
+    wm geom . [expr {$width-(20-7)*$fixedWidth}]x$height
     updateText
     .t bbox 15.6
-} [list 45 [expr {3+5*$fixedHeight}] 7 $fixedHeight]
-test textDisp-22.6 {TkTextCharBbox, line visible but not char} {textfonts} {
+} [list [xchar 6] [yline 6] $fixedWidth $fixedHeight]
+test textDisp-22.6 {TkTextCharBbox, line visible but not char} {
+    wm geometry . {}
+    updateText
+    scan [wm geom .] %dx%d oriWidth oriHeight
     .t config -wrap char
     .t yview 10.0
     .t tag add big 20.2 20.5
     wm geom . ${width}x[expr {$height+3}]
     updateText
-    list [.t bbox 19.1] [.t bbox 20.1] [.t bbox 20.2]
-} [list [list 10 [expr {3+9*$fixedHeight}] 7 $fixedHeight] {} [list 17 [expr {3+10*$fixedHeight}] 14 7]]
+    set expected [list [list [xchar 1] [yline 10] $fixedWidth $fixedHeight] \
+                       {} \
+	               [list [xchar 2] [yline 11] [font measure $bigFont "n"] [expr {($height+3)-$oriHeight}]]]
+    lequal [list [.t bbox 19.1] [.t bbox 20.1] [.t bbox 20.2]] $expected
+} {1}
 wm geom . {}
 updateText
-test textDisp-22.7 {TkTextCharBbox, different character sizes} {textfonts} {
+test textDisp-22.7 {TkTextCharBbox, different character sizes} {
     .t config -wrap char
     .t yview 10.0
     .t tag add big 12.2 12.5
     updateText
     list [.t bbox 12.1] [.t bbox 12.2]
-} [list [list 10 [expr {3 + 2*$fixedHeight + $ascentDiff}] 7 $fixedHeight] [list 17 [expr {3+ 2*$fixedHeight}] 14 27]]
+} [list [list [xchar 1] [expr {[yline 3]+$ascentDiff}] $fixedWidth $fixedHeight] \
+        [list [xchar 2] [yline 3] [font measure $bigFont "n"] $bigHeight]]
 .t tag remove big 1.0 end
-test textDisp-22.8 {TkTextCharBbox, horizontal scrolling} {textfonts} {
+test textDisp-22.8 {TkTextCharBbox, horizontal scrolling} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert end "12345\n"
     .t insert end "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
     .t xview scroll 4 units
     list [.t bbox 1.3] [.t bbox 1.4] [.t bbox 2.3] [.t bbox 2.4] \
 	    [.t bbox 2.23] [.t bbox 2.24]
-} [list {} [list 3 3 7 $fixedHeight] {} [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 136 [expr {$fixedDiff + 16}] 7 $fixedHeight] {}]
-test textDisp-22.9 {TkTextCharBbox, handling of spacing} {textfonts} {
+} [list {} \
+        [list [xchar 0] [yline 1] $fixedWidth $fixedHeight] \
+	{} \
+	[list [xchar 0] [yline 2] $fixedWidth $fixedHeight] \
+	[list [xchar 19] [yline 2] $fixedWidth $fixedHeight] \
+	{}]
+test textDisp-22.9 {TkTextCharBbox, handling of spacing} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "abcdefghijkl\nmnopqrstuvwzyz"
     .t tag configure spacing -spacing1 8 -spacing3 2
     .t tag add spacing 1.0 end
@@ -3092,13 +3421,18 @@
     .t window create 2.1 -window .t.f3 -align bottom
     .t window create 2.10 -window .t.f4 -align baseline
     updateText
     list [.t bbox .t.f1] [.t bbox .t.f2] [.t bbox .t.f3] [.t bbox .t.f4] \
 	    [.t bbox 1.1] [.t bbox 2.9]
-} [list [list 24 11 10 4] [list 55 [expr {$fixedDiff/2 + 15}] 10 4] [list 10 [expr {2*$fixedDiff + 43}] 10 4] [list 76 [expr {2*$fixedDiff + 40}] 10 4] [list 10 11 7 $fixedHeight] [list 69 [expr {$fixedDiff + 34}] 7 $fixedHeight]]
+} [list [list [xchar 3] [expr {[yline 1]+8}] 10 4] \
+        [list [expr {[xchar 3]+10+[xw 3]}] [expr {[yline 1]+8+($fixedHeight-4)/2}] 10 4] \
+	[list [xchar 1] [expr {[yline 2]+8+2+8+($fixedHeight-4)}] 10 4] \
+	[list [expr {[xchar 1]+10+[xw 8]}] [expr {[yline 2]+8+2+8+($fixedAscent-4)}] 10 4] \
+	[list [xchar 1] [expr {[yline 1]+8}] $fixedWidth $fixedHeight] \
+	[list [expr {[xchar 1]+10+[xw 7]}] [expr {[yline 2]+8+2+8}] $fixedWidth $fixedHeight]]
 .t tag delete spacing
-test textDisp-22.10 {TkTextCharBbox, handling of elided lines} {textfonts} {
+test textDisp-22.10 {TkTextCharBbox, handling of elided lines} {
     .t configure -wrap char
     .t delete 1.0 end
     for {set i 1} {$i < 10} {incr i} {
         .t insert end "Line $i - Line [format %c [expr {64+$i}]]\n"
     }
@@ -3117,11 +3451,11 @@
         [expr {[lindex [.t bbox 6.15] 0] - [lindex [.t bbox 6.8] 0]}] \
         [expr {[lindex [.t bbox 7.0]  0] - [lindex [.t bbox 6.8] 0]}] \
         [expr {[lindex [.t bbox 7.1]  0] - [lindex [.t bbox 6.8] 0]}] \
         [expr {[lindex [.t bbox 7.12] 0] - [lindex [.t bbox 6.8] 0]}]
 } [list 0 0 0 0 0 0 0 0 0 0 0]
-test textDisp-22.11 {TkTextCharBbox, handling of wrapped elided lines} {textfonts} {
+test textDisp-22.11 {TkTextCharBbox, handling of wrapped elided lines} {
     .t configure -wrap char
     .t delete 1.0 end
     for {set i 1} {$i < 10} {incr i} {
         .t insert end "Line $i - Line _$i - Lines .$i - Line [format %c [expr {64+$i}]]\n"
     }
@@ -3140,57 +3474,74 @@
 }
 .t configure -wrap word
 .t delete 50.0 51.0
 .t insert 50.0 "This is a long line, one that will wrap around twice.\n"
 updateText
-test textDisp-23.1 {TkTextDLineInfo} {textfonts} {
+test textDisp-23.1 {TkTextDLineInfo} {
     .t config -wrap word
     .t yview 48.0
     list [.t dlineinfo 47.3] [.t dlineinfo 48.0] [.t dlineinfo 50.40] \
 	    [.t dlineinfo 56.0]
-} [list {} [list 3 3 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {4*$fixedDiff + 55}] 91 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
-test textDisp-23.2 {TkTextDLineInfo} {textfonts} {
-    .t config -bd 4 -wrap word
+} [list {} \
+        [list [bo] [yline 1] [xw 7] $fixedHeight $fixedAscent] \
+	[list [bo] [yline 5] [xw 13] $fixedHeight $fixedAscent] \
+	{}]
+.t config -bd 4
+test textDisp-23.2 {TkTextDLineInfo} {
+    .t config -wrap word
     updateText
     .t yview 48.0
     .t dlineinfo 50.40
-} [list 7 [expr {4*$fixedDiff + 59}] 91 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]
+} [list [bo] [yline 5] [xw 13] $fixedHeight $fixedAscent]
 .t config -bd 0
-test textDisp-23.3 {TkTextDLineInfo} {textfonts} {
+test textDisp-23.3 {TkTextDLineInfo} {
     .t config -wrap none
     updateText
     .t yview 48.0
     list [.t dlineinfo 50.40] [.t dlineinfo 57.3]
-} [list [list 3 [expr {2*$fixedDiff + 29}] 371 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {9*$fixedDiff + 120}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
-test textDisp-23.4 {TkTextDLineInfo, cut-off lines} {textfonts} {
+} [list [list [bo] [yline 3] [xw 53] $fixedHeight $fixedAscent] \
+        [list [bo] [yline 10] [xw 7] $fixedHeight $fixedAscent]]
+test textDisp-23.4 {TkTextDLineInfo, cut-off lines} {
+    wm geometry . {}
+    updateText
+    scan [wm geom .] %dx%d oriWidth oriHeight
     .t config -wrap char
     .t yview 10.0
     wm geom . ${width}x[expr {$height-1}]
     updateText
-    list [.t dlineinfo 19.0] [.t dlineinfo 20.0]
-} [list [list 3 [expr {9*$fixedDiff + 120}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {10*$fixedDiff + 133}] 49 3 [expr {$fixedDiff + 10}]]]
-test textDisp-23.5 {TkTextDLineInfo, cut-off lines} {textfonts} {
+    set expected [list [list [bo] [yline 10] [xw 7] $fixedHeight $fixedAscent] \
+                       [list [bo] [yline 11] [xw 7] [expr {($height-1)-$oriHeight}] $fixedAscent]]
+    lequal [list [.t dlineinfo 19.0] [.t dlineinfo 20.0]] $expected
+} {1}
+test textDisp-23.5 {TkTextDLineInfo, cut-off lines} {
+    wm geometry . {}
+    updateText
+    scan [wm geom .] %dx%d oriWidth oriHeight
     .t config -wrap char
     .t yview 10.0
     wm geom . ${width}x[expr {$height+1}]
     updateText
-    list [.t dlineinfo 19.0] [.t dlineinfo 20.0]
-} [list [list 3 [expr {9*$fixedDiff + 120}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {10*$fixedDiff + 133}] 49 5 [expr {$fixedDiff + 10}]]]
+    set expected [list [list [bo] [yline 10] [xw 7] $fixedHeight $fixedAscent] \
+                       [list [bo] [yline 11] [xw 7] [expr {($height+1)-$oriHeight}] $fixedAscent]]
+    lequal [list [.t dlineinfo 19.0] [.t dlineinfo 20.0]] $expected
+} {1}
 wm geom . {}
 updateText
-test textDisp-23.6 {TkTextDLineInfo, horizontal scrolling} {textfonts} {
+test textDisp-23.6 {TkTextDLineInfo, horizontal scrolling} {
     .t config -wrap none
     .t delete 1.0 end
     .t insert end "First line\n"
     .t insert end "Second line is a very long one that doesn't all fit.\n"
     .t insert end "Third"
     .t xview scroll 6 units
     updateText
     list [.t dlineinfo 1.0] [.t dlineinfo 2.0] [.t dlineinfo 3.0]
-} [list [list -39 3 70 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list -39 [expr {$fixedDiff + 16}] 364 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list -39 [expr {2*$fixedDiff + 29}] 35 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
+} [list [list [expr {[xw -6]+[bo]}] [yline 1] [xw 10] $fixedHeight $fixedAscent] \
+        [list [expr {[xw -6]+[bo]}] [yline 2] [xw 52] $fixedHeight $fixedAscent] \
+	[list [expr {[xw -6]+[bo]}] [yline 3] [xw 5] $fixedHeight $fixedAscent]]
 .t xview moveto 0
-test textDisp-23.7 {TkTextDLineInfo, centering} {textfonts} {
+test textDisp-23.7 {TkTextDLineInfo, centering} {
     .t config -wrap word
     .t delete 1.0 end
     .t insert end "First line\n"
     .t insert end "Second line is a very long one that doesn't all fit.\n"
     .t insert end "Third"
@@ -3197,263 +3548,360 @@
     .t tag configure x -justify center
     .t tag configure y -justify right
     .t tag add x 1.0
     .t tag add y 3.0
     list [.t dlineinfo 1.0] [.t dlineinfo 2.0] [.t dlineinfo 3.0]
-} [list [list 38 3 70 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {$fixedDiff + 16}] 119 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 108 [expr {4*$fixedDiff + 55}] 35 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
+} [list [list [expr {[bo]+[xe 10]/2}] [yline 1] [xw 10] $fixedHeight $fixedAscent] \
+        [list [bo] [yline 2] [xw 17] $fixedHeight $fixedAscent] \
+	[list [xcharr 5] [yline 5] [xw 5] $fixedHeight $fixedAscent]]
 .t tag delete x y
 
-test textDisp-24.1 {TkTextCharLayoutProc} {textfonts} {
+test textDisp-24.1 {TkTextCharLayoutProc} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
     list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 136 3 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-24.2 {TkTextCharLayoutProc} {textfonts} {
+} [list [list [xchar 19] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-24.2 {TkTextCharLayoutProc} {
+    wm geometry . {}
+    updateText
+    scan [wm geom .] %dx%d oriWidth oriHeight
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
-    wm geom . [expr {$width+1}]x$height
+    # be tolerant about borderwidth et al. - don't let another char fit on the line
+    set wi $width
+    while {$wi+1-$oriWidth >= $fixedWidth} {
+        incr wi -$fixedWidth
+    }
+    wm geom . [expr {$wi+1}]x$height
     updateText
-    list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 136 3 12 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-24.3 {TkTextCharLayoutProc} {textfonts} {
+    set expected [list [list [xchar 19] [yline 1] [expr {$fixedWidth+($wi+1-$oriWidth)}] $fixedHeight] \
+                       [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+    lequal [list [.t bbox 1.19] [.t bbox 1.20]] $expected
+} {1}
+test textDisp-24.3 {TkTextCharLayoutProc} {
+    wm geometry . {}
+    updateText
+    scan [wm geom .] %dx%d oriWidth oriHeight
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
     wm geom . [expr {$width-1}]x$height
     updateText
-    list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 136 3 10 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-24.4 {TkTextCharLayoutProc, newline not visible} {textfonts} {
+    set expected [list [list [xchar 19] [yline 1] [expr {$fixedWidth+($width-1-$oriWidth)}] $fixedHeight] \
+                       [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+    lequal [list [.t bbox 1.19] [.t bbox 1.20]] $expected
+} {1}
+test textDisp-24.4 {TkTextCharLayoutProc, newline not visible} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 01234567890123456789\n012345678901234567890
     wm geom . {}
     updateText
     list [.t bbox 1.19] [.t bbox 1.20] [.t bbox 2.20]
-} [list [list 136 3 7 $fixedHeight] [list 143 3 0 $fixedHeight] [list 3 [expr {2*$fixedDiff + 29}] 7 $fixedHeight]]
-test textDisp-24.5 {TkTextCharLayoutProc, char doesn't fit, newline not visible} {unix textfonts} {
+} [list [list [xchar 19] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 20] [yline 1] 0 $fixedHeight] \
+	[list [xchar 0] [yline 3] $fixedWidth $fixedHeight]]
+test textDisp-24.5 {TkTextCharLayoutProc, char doesn't fit, newline not visible} {nonwin} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 0\n1\n
-    wm geom . 110x$height
+    # set text widget width to 1-char width minus [bo] pixels
+    # note: windows refuses to shrink enough therefore the constraint
+    set wi [expr {[winfo width .f]+[bo]+[xw 1]}]
+    wm geom . ${wi}x$height
     updateText
     list [.t bbox 1.0] [.t bbox 1.1] [.t bbox 2.0]
-} [list [list 3 3 4 $fixedHeight] [list 7 3 0 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 4 $fixedHeight]]
-test textDisp-24.6 {TkTextCharLayoutProc, line ends with space} {textfonts} {
+} [list [list [xchar 0] [yline 1] [expr {$fixedWidth-[bo]}] $fixedHeight] \
+        [list [expr {[xchar 1]-[bo]}] [yline 1] 0 $fixedHeight] \
+	[list [xchar 0] [yline 2] [expr {$fixedWidth-[bo]}] $fixedHeight]]
+test textDisp-24.6 {TkTextCharLayoutProc, line ends with space} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "a b c d e f g h i j k l m n o p"
     wm geom . {}
     updateText
     list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 136 3 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-24.7 {TkTextCharLayoutProc, line ends with space} {textfonts} {
+} [list [list [xchar 19] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-24.7 {TkTextCharLayoutProc, line ends with space} {
+    wm geometry . {}
+    updateText
+    scan [wm geom .] %dx%d oriWidth oriHeight
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "a b c d e f g h i j k l m n o p"
-    wm geom . [expr {$width+1}]x$height
+    # be tolerant about borderwidth et al. - don't let another char fit on the line
+    set wi $width
+    while {$wi+1-$oriWidth >= $fixedWidth} {
+        incr wi -$fixedWidth
+    }
+    wm geom . [expr {$wi+1}]x$height
     updateText
-    list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 136 3 12 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-24.8 {TkTextCharLayoutProc, line ends with space} {textfonts} {
+    set expected [list [list [xchar 19] [yline 1] [expr {$fixedWidth+($wi+1-$oriWidth)}] $fixedHeight] \
+                       [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+    lequal [list [.t bbox 1.19] [.t bbox 1.20]] $expected
+} {1}
+test textDisp-24.8 {TkTextCharLayoutProc, line ends with space} {
+    wm geometry . {}
+    updateText
+    scan [wm geom .] %dx%d oriWidth oriHeight
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "a b c d e f g h i j k l m n o p"
     wm geom . [expr {$width-1}]x$height
     updateText
-    list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 136 3 10 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-24.9 {TkTextCharLayoutProc, line ends with space} {textfonts} {
+    set expected [list [list [xchar 19] [yline 1] [expr {$fixedWidth+($width-1-$oriWidth)}] $fixedHeight] \
+                       [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+    lequal [list [.t bbox 1.19] [.t bbox 1.20]] $expected
+} {1}
+test textDisp-24.9 {TkTextCharLayoutProc, line ends with space} {
+    wm geometry . {}
+    updateText
+    scan [wm geom .] %dx%d oriWidth oriHeight
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "a b c d e f g h i j k l m n o p"
     wm geom . [expr {$width-6}]x$height
     updateText
-    list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 136 3 5 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-24.10 {TkTextCharLayoutProc, line ends with space} {textfonts} {
+    set expected [list [list [xchar 19] [yline 1] [expr {$fixedWidth+($width-6-$oriWidth)}] $fixedHeight] \
+                       [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+    lequal [list [.t bbox 1.19] [.t bbox 1.20]] $expected
+} {1}
+test textDisp-24.10 {TkTextCharLayoutProc, line ends with space} {
+    wm geometry . {}
+    updateText
+    scan [wm geom .] %dx%d oriWidth oriHeight
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "a b c d e f g h i j k l m n o p"
     wm geom . [expr {$width-7}]x$height
     updateText
-    list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 136 3 4 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-24.11 {TkTextCharLayoutProc, line ends with space that doesn't quite fit} {textfonts} {
+    set expected [list [list [xchar 19] [yline 1] [expr {$fixedWidth+($width-7-$oriWidth)}] $fixedHeight] \
+                       [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+    lequal [list [.t bbox 1.19] [.t bbox 1.20]] $expected
+} {1}
+test textDisp-24.11 {TkTextCharLayoutProc, line ends with space that doesn't quite fit} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "01234567890123456789 \nabcdefg"
-    wm geom . [expr {$width-2}]x$height
+    # set text widget width to 2 pixels more than 20-char width
+    set wi [expr {[winfo width .f]+2*[bo]+[xw 20]+2}]
+    wm geom . ${wi}x$height
     updateText
-    set result {}
-    lappend result [.t bbox 1.21] [.t bbox 2.0]
+    set result [list [.t bbox 1.21] [.t bbox 2.0]]
     .t mark set insert 1.21
     lappend result [.t bbox 1.21] [.t bbox 2.0]
-} [list [list 145 3 0 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 145 3 0 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-24.12 {TkTextCharLayoutProc, tab causes wrap} {textfonts} {
+} [list [list [expr {[xchar 20]+2}] [yline 1] 0 $fixedHeight] \
+        [list [xchar 0] [yline 2] $fixedWidth $fixedHeight] \
+	[list [expr {[xchar 20]+2}] [yline 1] 0 $fixedHeight] \
+	[list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+wm geom . {}
+updateText
+test textDisp-24.12 {TkTextCharLayoutProc, tab causes wrap} {
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "abcdefghi"
     .t mark set insert 1.4
     .t insert insert \t\t\t
-    list [.t bbox {insert -1c}] [.t bbox insert]
-} [list [list 115 3 30 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-24.13 {TkTextCharLayoutProc, -wrap none} {textfonts} {
+    set expected [list [list [expr {[xchar 0]+2*8*$fixedWidth}] [yline 1] [expr {[winfo width .t]-([xchar 0]+2*8*$fixedWidth)-[bo]}] $fixedHeight] \
+                       [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+    lequal [list [.t bbox {insert -1c}] [.t bbox insert]] $expected
+} {1}
+test textDisp-24.13 {TkTextCharLayoutProc, -wrap none} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
     wm geom . {}
     updateText
     list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 136 3 7 $fixedHeight] {}]
-test textDisp-24.14 {TkTextCharLayoutProc, -wrap none} {textfonts} {
+} [list [list [xchar 19] [yline 1] $fixedWidth $fixedHeight] {}]
+test textDisp-24.14 {TkTextCharLayoutProc, -wrap none} {
+    wm geometry . {}
+    updateText
+    scan [wm geom .] %dx%d oriWidth oriHeight
     .t configure -wrap none
     .t delete 1.0 end
     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
     wm geom . [expr {$width+1}]x$height
     updateText
-    list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 136 3 7 $fixedHeight] [list 143 3 5 $fixedHeight]]
-test textDisp-24.15 {TkTextCharLayoutProc, -wrap none} {textfonts} {
+    set expected [list [list [xchar 19] [yline 1] $fixedWidth $fixedHeight] \
+                       [list [xchar 20] [yline 1] [expr {$width+1-$oriWidth}] $fixedHeight]]
+    lequal [list [.t bbox 1.19] [.t bbox 1.20]] $expected
+} {1}
+test textDisp-24.15 {TkTextCharLayoutProc, -wrap none} {
+    wm geometry . {}
+    updateText
+    scan [wm geom .] %dx%d oriWidth oriHeight
     .t configure -wrap none
     .t delete 1.0 end
     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
     wm geom . [expr {$width-1}]x$height
     updateText
-    list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 136 3 7 $fixedHeight] [list 143 3 3 $fixedHeight]]
-test textDisp-24.16 {TkTextCharLayoutProc, no chars fit} {textfonts} {
-    if {$tcl_platform(platform) == "windows"} {
+    set expected [list [list [xchar 19] [yline 1] $fixedWidth $fixedHeight] \
+                       [list [xchar 20] [yline 1] [expr {$width-1-$oriWidth}] $fixedHeight]]
+    lequal [list [.t bbox 1.19] [.t bbox 1.20]] $expected
+} {1}
+test textDisp-24.16 {TkTextCharLayoutProc, no chars fit} {
+    if {[tk windowingsystem] == "win32"} {
 	wm overrideredirect . 1
     }
     .t configure -wrap char
     .t delete 1.0 end
     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
-    wm geom . 103x$height
+    # set text widget width to [bo] pixels (no chars fit in the widget at all)
+    set wi [expr {[winfo width .f]+[bo]}]
+    wm geom . ${wi}x$height
     updateText
     list [.t bbox 1.0] [.t bbox 1.1] [.t bbox 1.2]
-} [list [list 3 3 1 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 1 $fixedHeight] [list 3 [expr {2*$fixedDiff + 29}] 1 $fixedHeight]]
-if {$tcl_platform(platform) == "windows"} {
+} [list [list [xchar 0] [yline 1] 1 $fixedHeight] \
+        [list [xchar 0] [yline 2] 1 $fixedHeight] \
+	[list [xchar 0] [yline 3] 1 $fixedHeight]]
+if {[tk windowingsystem] == "win32"} {
     wm overrideredirect . 0
 }
-test textDisp-24.17 {TkTextCharLayoutProc, -wrap word} {textfonts} {
+test textDisp-24.17 {TkTextCharLayoutProc, -wrap word} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "This is a line that wraps around"
     wm geom . {}
     updateText
     list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list 136 3 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-24.18 {TkTextCharLayoutProc, -wrap word} {textfonts} {
+} [list [list [xchar 19] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-24.18 {TkTextCharLayoutProc, -wrap word} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "xxThis is a line that wraps around"
     wm geom . {}
     updateText
-    list [.t bbox 1.15] [.t bbox 1.16] [.t bbox 1.17]
-} [list [list 108 3 7 $fixedHeight] [list 115 3 28 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
-test textDisp-24.19 {TkTextCharLayoutProc, -wrap word} {textfonts} {
+    list [.t bbox 1.15] [.t bbox 1.16] [.t bbox 1.17] [.t bbox 1.21]
+} [list [list [xchar 15] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 16] [yline 1] [xe 16] $fixedHeight] \
+	[list [xchar 0] [yline 2] $fixedWidth $fixedHeight] \
+	[list [xchar 4] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-24.19 {TkTextCharLayoutProc, -wrap word} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "xxThis is a line that wraps around"
     wm geom . {}
     updateText
     list [.t bbox 1.14] [.t bbox 1.15] [.t bbox 1.16]
-} [list [list 101 3 7 $fixedHeight] [list 108 3 7 $fixedHeight] [list 115 3 28 $fixedHeight]]
-test textDisp-24.20 {TkTextCharLayoutProc, vertical offset} {textfonts} {
+} [list [list [xchar 14] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar 15] [yline 1] $fixedWidth $fixedHeight] \
+	[list [xchar 16] [yline 1] [xe 16] $fixedHeight]]
+test textDisp-24.20 {TkTextCharLayoutProc, vertical offset} {
     .t configure -wrap none
     .t delete 1.0 end
     .t insert 1.0 "Line 1\nLine 2\nLine 3"
     set result {}
     lappend result [.t bbox 2.1] [.t dlineinfo 2.1]
     .t tag configure up -offset 6
     .t tag add up 2.1
     lappend result [.t bbox 2.1] [.t dlineinfo 2.1]
-    .t tag configure  up -offset -2
+    .t tag configure up -offset -2
     lappend result [.t bbox 2.1] [.t dlineinfo 2.1]
     .t tag delete up
     set result
-} [list [list 10 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 42 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 10 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 42 [expr {$fixedDiff + 19}] [expr {$fixedDiff + 16}]] [list 10 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 42 [expr {$fixedDiff + 15}] [expr {$fixedDiff + 10}]]]
+} [list [list [xchar 1] [yline 2] $fixedWidth $fixedHeight] \
+        [list [bo] [yline 2] [xw 6] $fixedHeight $fixedAscent] \
+	[list [xchar 1] [yline 2] $fixedWidth $fixedHeight] \
+        [list [bo] [yline 2] [xw 6] [expr {$fixedHeight+6}] [expr {$fixedAscent+6}]] \
+	[list [xchar 1] [expr {[yline 2]+2}] $fixedWidth $fixedHeight] \
+        [list [bo] [yline 2] [xw 6] [expr {$fixedHeight+2}] $fixedAscent]]
 .t configure -width 30
 updateText
-test textDisp-24.21 {TkTextCharLayoutProc, word breaks} {textfonts} {
+test textDisp-24.21 {TkTextCharLayoutProc, word breaks} {
     .t configure -wrap word
     .t delete 1.0 end
     .t insert 1.0 "Sample text xxxxxxx yyyyy zzzzzzz qqqqq rrrr ssss tt u vvvvv"
     frame .t.f -width 30 -height 20 -bg black
     .t window create 1.36 -window .t.f
     .t bbox 1.26
-} [list 3 [expr {$fixedDiff/2 + 19}] 7 $fixedHeight]
-test textDisp-24.22 {TkTextCharLayoutProc, word breaks} {textfonts} {
+} [list [xchar 0] [expr {[yline 2]+(20-$fixedHeight)/2}] $fixedWidth $fixedHeight]
+test textDisp-24.22 {TkTextCharLayoutProc, word breaks} {
     .t configure -wrap word
     .t delete 1.0 end
     frame .t.f -width 30 -height 20 -bg black
     .t insert 1.0 "Sample text xxxxxxx yyyyyyy"
     .t window create end -window .t.f
     .t insert end "zzzzzzz qqqqq rrrr ssss tt u vvvvv"
-    .t bbox 1.28
-} [list 33 [expr {$fixedDiff/2 + 19}] 7 $fixedHeight]
-test textDisp-24.23 {TkTextCharLayoutProc, word breaks} {textfonts} {
+   .t bbox 1.28
+} [list [expr {[bo]+30}] [expr {[yline 2]+(20-$fixedHeight)/2}] $fixedWidth $fixedHeight]
+test textDisp-24.23 {TkTextCharLayoutProc, word breaks} {
     .t configure -wrap word
     .t delete 1.0 end
-    frame .t.f -width 30 -height 20 -bg black
+    frame .t.f -width 50 -height 20 -bg black
     .t insert 1.0 "Sample text xxxxxxx yyyyyyy "
     .t insert end "zzzzzzz qqqqq rrrr ssss tt"
     .t window create end -window .t.f
     .t insert end "u vvvvv"
     .t bbox .t.f
-} [list 3 [expr {2*$fixedDiff + 29}] 30 20]
+} [list [xchar 0] [yline 3] 50 20]
 catch {destroy .t.f}
 .t configure -width 20
 updateText
-test textDisp-24.24 {TkTextCharLayoutProc, justification and tabs} {textfonts} {
+# Next test is currently constrained to not run on mac (aqua) because on
+# aqua it fails due to wrong implementation of tabs with right justification
+# (the text is not rendered at all). This is a bug.
+test textDisp-24.24 {TkTextCharLayoutProc, justification and tabs} notAqua {
     .t delete 1.0 end
     .t tag configure x -justify center
     .t insert 1.0 aa\tbb\tcc\tdd\t
     .t tag add x 1.0 end
     list [.t bbox 1.0] [.t bbox 1.10]
-} [list [list 45 3 7 $fixedHeight] [list 94 3 7 $fixedHeight]]
-test textDisp-24.25 {TkTextCharLayoutProc, justification and tabs} -constraints {textfonts failsOnXQuarz} -setup {
+} [list [list [expr {[bo]+[xe 8]/2}] [yline 1] $fixedWidth $fixedHeight] \
+        [list [expr {[bo]+[xe 8]/2+[xw 7]}] [yline 1] $fixedWidth $fixedHeight]]
+test textDisp-24.25 {TkTextCharLayoutProc, justification and tabs} -setup {
     text .tt -tabs {40 right} -wrap none -font $fixedFont
     pack .tt
 } -body {
     .tt insert end \t9\n\t99\n\t999
     updateText
-    list [.tt bbox 1.1] [.tt bbox 2.2] [.tt bbox 3.3]
+    set expected [list [list [expr {[bo .tt]+40-$fixedWidth}] [yline 1 .tt] $fixedWidth $fixedHeight] \
+                       [list [expr {[bo .tt]+40-$fixedWidth}] [yline 2 .tt] $fixedWidth $fixedHeight] \
+                       [list [expr {[bo .tt]+40-$fixedWidth}] [yline 3 .tt] $fixedWidth $fixedHeight]]
+    lequal [list [.tt bbox 1.1] [.tt bbox 2.2] [.tt bbox 3.3]] $expected
 } -cleanup {
     destroy .tt
-} -result [list [list 38 5 7 $fixedHeight] [list 38 20 7 $fixedHeight] [list 38 35 7 $fixedHeight]]
+} -result {1}
 
-.t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 \
+.t configure -width 40 -bd 0 -relief flat -highlightthickness 0 \
     -tabs 100
 updateText
-test textDisp-25.1 {CharBboxProc procedure, check tab width} {textfonts} {
+test textDisp-25.1 {CharBboxProc procedure, check tab width} {
     .t delete 1.0 end
     .t insert 1.0 abc\td\tfgh
     list [.t bbox 1.3] [.t bbox 1.5] [.t bbox 1.6]
-} [list [list 21 1 79 $fixedHeight] [list 107 1 93 $fixedHeight] [list 200 1 7 $fixedHeight]]
+} [list [list [xchar 3] [yline 1] [expr {100-3*$fixedWidth}] $fixedHeight] \
+        [list [expr {[bo]+100+$fixedWidth}] [yline 1] [expr {200-(100+$fixedWidth)}] $fixedHeight] \
+	[list [expr {[bo]+200}] [yline 1] $fixedWidth $fixedHeight]]
 
-.t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 \
+.t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 -pady 0 \
 	-tabs {}
 updateText
-test textDisp-26.1 {AdjustForTab procedure, no tabs} {textfonts} {
+test textDisp-26.1 {AdjustForTab procedure, no tabs} {
     .t delete 1.0 end
     .t insert 1.0 a\tbcdefghij\tc\td
     list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.12] 0] \
 	    [lindex [.t bbox 1.14] 0]
-} [list 56 126 168]
-test textDisp-26.1.2 {AdjustForTab procedure, no tabs} {textfonts} {
+} [list [expr {[bo]+8*$fixedWidth}] \
+        [expr {[bo]+2*8*$fixedWidth+2*$fixedWidth}] \
+	[expr {[bo]+3*8*$fixedWidth}]]
+test textDisp-26.1.2 {AdjustForTab procedure, no tabs} {
     .t delete 1.0 end
     .t insert 1.0 a\tbcdefghij\tc\td
     .t configure -tabstyle wordprocessor
     set res [list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.12] 0] \
       [lindex [.t bbox 1.14] 0]]
     .t configure -tabstyle tabular
     set res
-} [list 56 168 224]
+} [list [expr {[bo]+8*$fixedWidth}] \
+        [expr {[bo]+3*8*$fixedWidth}] \
+	[expr {[bo]+4*8*$fixedWidth}]]
 test textDisp-26.2 {AdjustForTab procedure, not enough tabs specified} {
     .t delete 1.0 end
     .t insert 1.0 a\tb\tc\td
     .t tag delete x
     .t tag configure x -tabs 40
@@ -3560,40 +4008,51 @@
     button .b -text "="
     .t window create 1.3 -window .b
     updateText
     lindex [.t bbox 1.5] 0
 } 120
-test textDisp-26.13 {AdjustForTab procedure, not enough space} {textfonts} {
+test textDisp-26.13 {AdjustForTab procedure, not enough space} {
     .t delete 1.0 end
     .t insert 1.0 "abc\txyz\tqrs\txyz\t0"
     .t tag delete x
-    .t tag configure x -tabs {10 30 center 50 right 120}
+    set t1 [expr {   $fixedWidth+3}]
+    set t2 [expr { 4*$fixedWidth+2}]
+    set t3 [expr { 7*$fixedWidth+1}]
+    set t4 [expr {17*$fixedWidth+1}]
+    .t tag configure x -tabs "$t1 $t2 center $t3 right $t4"
     .t tag add x 1.0 end
-    list [lindex [.t bbox 1.4] 0] [lindex [.t bbox 1.8] 0] \
-	    [lindex [.t bbox 1.12] 0] [lindex [.t bbox 1.16] 0]
-} [list 28 56 84 120]
-test textDisp-26.13.2 {AdjustForTab procedure, not enough space} {textfonts} {
+    set expected [list [xchar 4] [xchar 8] [xchar 12] $t4]
+    set res [list [lindex [.t bbox 1.4] 0] [lindex [.t bbox 1.8] 0] \
+            [lindex [.t bbox 1.12] 0] [lindex [.t bbox 1.16] 0]]
+    lequal $res $expected
+} {1}
+test textDisp-26.13.2 {AdjustForTab procedure, not enough space} {
     .t delete 1.0 end
     .t insert 1.0 "abc\txyz\tqrs\txyz\t0"
     .t tag delete x
-    .t tag configure x -tabs {10 30 center 50 right 120} -tabstyle wordprocessor
+    set t1 [expr {   $fixedWidth+3}]
+    set t2 [expr { 4*$fixedWidth+2}]
+    set t3 [expr { 7*$fixedWidth+1}]
+    set t4 [expr {17*$fixedWidth+1}]
+    .t tag configure x -tabs "$t1 $t2 center $t3 right $t4" -tabstyle wordprocessor
     .t tag add x 1.0 end
+    set expected [list [xchar 4] [xchar 8] $t4 [expr {$t4+($t4-$t3)}]]
     set res [list [lindex [.t bbox 1.4] 0] [lindex [.t bbox 1.8] 0] \
       [lindex [.t bbox 1.12] 0] [lindex [.t bbox 1.16] 0]]
     .t tag configure x -tabstyle tabular
-    set res
-} [list 28 56 120 190]
-test textDisp-26.14 {AdjustForTab procedure, not enough space} {textfonts} {
+    lequal $res $expected
+} {1}
+test textDisp-26.14 {AdjustForTab procedure, not enough space} {
     .t delete 1.0 end
     .t insert end "a \tb \tc \td \te \tf \tg\n"
     .t insert end "Watch the \tX and the \t\t\tY\n"
     .t tag configure moop -tabs [expr {8*$fixedWidth}]
     .t insert end "Watch the \tX and the \t\t\tY\n" moop
     list [lindex [.t bbox 2.11] 0] [lindex [.t bbox 2.24] 0] \
 	    [lindex [.t bbox 3.11] 0] [lindex [.t bbox 3.24] 0]
-} [list 77 224 77 224]
-test textDisp-26.14.2 {AdjustForTab procedure, not enough space} {textfonts} {
+} [list [xchar 11] [xchar 32] [xchar 11] [xchar 32]]
+test textDisp-26.14.2 {AdjustForTab procedure, not enough space} {
     .t delete 1.0 end
     .t configure -tabstyle wordprocessor
     .t insert end "a \tb \tc \td \te \tf \tg\n"
     .t insert end "Watch the \tX and the \t\t\tY\n"
     .t tag configure moop -tabs [expr {8*$fixedWidth}]
@@ -3600,69 +4059,94 @@
     .t insert end "Watch the \tX and the \t\t\tY\n" moop
     set res [list [lindex [.t bbox 2.11] 0] [lindex [.t bbox 2.24] 0] \
       [lindex [.t bbox 3.11] 0] [lindex [.t bbox 3.24] 0]]
     .t configure -tabstyle tabular
     set res
-} [list 112 56 112 56]
+} [list [xchar 16] [xchar 8] [xchar 16] [xchar 8]]
 
 .t configure -width 20 -bd 2 -highlightthickness 2 -relief sunken -tabs {} \
 	-wrap char
 updateText
-test textDisp-27.1 {SizeOfTab procedure, old-style tabs} {textfonts} {
+test textDisp-27.1 {SizeOfTab procedure, old-style tabs} {
     .t delete 1.0 end
     .t insert 1.0 a\tbcdefghij\tc\td
     list [.t bbox 1.2] [.t bbox 1.10] [.t bbox 1.12]
-} [list [list 60 5 7 $fixedHeight] [list 116 5 7 $fixedHeight] [list 130 5 7 $fixedHeight]]
-test textDisp-27.1.1 {SizeOfTab procedure, old-style tabs} {textfonts} {
+} [list [list [xchar 8] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar [expr {8+8}]] [yline 1] $fixedWidth $fixedHeight] \
+	[list [xchar [expr {8+8+1+1}]] [yline 1] $fixedWidth $fixedHeight]]
+test textDisp-27.1.1 {SizeOfTab procedure, old-style tabs} {
     .t delete 1.0 end
     .t insert 1.0 a\tbcdefghij\tc\td
     .t configure -tabstyle wordprocessor
     set res [list [.t bbox 1.2] [.t bbox 1.10] [.t bbox 1.12]]
     .t configure -tabstyle tabular
     set res
-} [list [list 60 5 7 $fixedHeight] [list 116 5 7 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-27.2 {SizeOfTab procedure, choosing tabX and alignment} {textfonts} {
-    .t delete 1.0 end
-    .t insert 1.0 a\tbcd
-    .t tag delete x
-    .t tag configure x -tabs 120
-    .t tag add x 1.0 end
-    list [.t bbox 1.3] [.t bbox 1.4]
-} [list [list 131 5 13 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-27.3 {SizeOfTab procedure, choosing tabX and alignment} {textfonts} {
-    .t delete 1.0 end
-    .t insert 1.0 a\t\t\tbcd
-    .t tag delete x
-    .t tag configure x -tabs 40
-    .t tag add x 1.0 end
-    list [.t bbox 1.5] [.t bbox 1.6]
-} [list [list 131 5 13 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-27.4 {SizeOfTab procedure, choosing tabX and alignment} {textfonts} {
-    .t delete 1.0 end
-    .t insert 1.0 a\t\t\tbcd
-    .t tag delete x
-    .t tag configure x -tabs {20 center 70 left}
-    .t tag add x 1.0 end
-    list [.t bbox 1.5] [.t bbox 1.6]
-} [list [list 131 5 13 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-27.5 {SizeOfTab procedure, center alignment} {textfonts} {
-    .t delete 1.0 end
-    .t insert 1.0 a\txyzzyabc
-    .t tag delete x
-    .t tag configure x -tabs {120 center}
-    .t tag add x 1.0 end
-    list [.t bbox 1.6] [.t bbox 1.7]
-} [list [list 135 5 9 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-27.6 {SizeOfTab procedure, center alignment} {textfonts} {
-    .t delete 1.0 end
-    .t insert 1.0 a\txyzzyabc
-    .t tag delete x
-    .t tag configure x -tabs {150 center}
-    .t tag add x 1.0 end
-    list [.t bbox 1.6] [.t bbox 1.7]
-} [list [list 32 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 39 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-27.7 {SizeOfTab procedure, center alignment, wrap -none (potential numerical problems)} {textfonts} {
+} [list [list [xchar 8] [yline 1] $fixedWidth $fixedHeight] \
+        [list [xchar [expr {8+8}]] [yline 1] $fixedWidth $fixedHeight] \
+	[list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-27.2 {SizeOfTab procedure, choosing tabX and alignment} {
+    .t delete 1.0 end
+    .t insert 1.0 a\tbcd
+    .t tag delete x
+    # compute a tab width such that the first display line is just not large enough
+    # to show the last char 'd', which then wraps on display line 2
+    set tw [expr {(20-2)*$fixedWidth-($fixedWidth-1)}]
+    .t tag configure x -tabs $tw
+    .t tag add x 1.0 end
+    set expected [list [list [expr {[bo]+$tw+[xw 1]}] [yline 1] [expr {[winfo width .t]-([bo]+$tw+[xw 1])-[bo]}] $fixedHeight] \
+                       [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+    lequal [list [.t bbox 1.3] [.t bbox 1.4]] $expected
+} {1}
+test textDisp-27.3 {SizeOfTab procedure, choosing tabX and alignment} {
+    .t delete 1.0 end
+    .t insert 1.0 a\t\t\tbcd
+    .t tag delete x
+    # compute a tab width such that the first display line is just not large enough
+    # to show the last char 'd', which then wraps on display line 2
+    set tw [expr {int(ceil(((20-2)*$fixedWidth-($fixedWidth-1))/3.0))}]
+    .t tag configure x -tabs $tw
+    .t tag add x 1.0 end
+    set expected [list [list [expr {[bo]+3*$tw+[xw 1]}] [yline 1] [expr {[winfo width .t]-([bo]+3*$tw+[xw 1])-[bo]}] $fixedHeight] \
+                       [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+    lequal [list [.t bbox 1.5] [.t bbox 1.6]] $expected
+} {1}
+test textDisp-27.4 {SizeOfTab procedure, choosing tabX and alignment} {
+    .t delete 1.0 end
+    .t insert 1.0 a\t\t\tbcd
+    .t tag delete x
+    # compute a tab width such that the first display line is just not large enough
+    # to show the last char 'd', which then wraps on display line 2
+    set tw [expr {int(ceil(((20-2)*$fixedWidth-($fixedWidth-1) + 20)/2.0))}]
+    .t tag configure x -tabs "20 center $tw left"
+    .t tag add x 1.0 end
+    set expected [list [list [expr {[bo]+$tw+($tw-20)+[xw 1]}] [yline 1] [expr {[winfo width .t]-([bo]+$tw+($tw-20)+[xw 1])-[bo]}] $fixedHeight] \
+                       [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+    lequal [list [.t bbox 1.5] [.t bbox 1.6]] $expected
+} {1}
+test textDisp-27.5 {SizeOfTab procedure, center alignment} {
+    .t delete 1.0 end
+    .t insert 1.0 a\txyzzyabc
+    .t tag delete x
+    # compute a tab width such that the last y on the first display line is the last displayed char
+    # while 'xyzzyabc' is centered at the tab stop; the 'abc" part of the line wraps on display line 2
+    set tw [expr {[winfo width .t]-2*[bo]-3*$fixedWidth+1}]
+    .t tag configure x -tabs "$tw center"
+    .t tag add x 1.0 end
+    set expected [list [list [expr {[bo]+$tw+round(1.5*$fixedWidth)}] [yline 1] [expr {[winfo width .t]-([bo]+$tw+round(1.5*$fixedWidth))-[bo]}] $fixedHeight] \
+                       [list [xchar 0] [yline 2] $fixedWidth $fixedHeight]]
+    lequal [list [.t bbox 1.6] [.t bbox 1.7]] $expected
+} {1}
+test textDisp-27.6 {SizeOfTab procedure, center alignment} {
+    .t delete 1.0 end
+    .t insert 1.0 a\txyzzyabc
+    .t tag delete x
+    .t tag configure x -tabs "[expr {round(21.4*$fixedWidth)}] center"
+    .t tag add x 1.0 end
+    list [.t bbox 1.6] [.t bbox 1.7]
+} [list [list [xchar 4] [yline 2] $fixedWidth $fixedHeight] \
+        [list [xchar 5] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-27.7 {SizeOfTab procedure, center alignment, wrap -none (potential numerical problems)} {
     .t delete 1.0 end
     set cm [winfo fpixels .t 1c]
     .t configure -tabs {1c 2c center 3c 4c 5c 6c 7c 8c} -wrap none -width 40
     .t insert 1.0 a\tb\tc\td\te\n012345678934567890a\tbb\tcc\tdd
     set width [expr {$fixedWidth * 19}]
@@ -3669,20 +4153,20 @@
     set tab $cm
     while {$tab < $width} {
 	set tab [expr {$tab + $cm}]
     }
     # Now we've calculated to the end of the tab after 'a', add one
-    # more for 'bb\t' and we're there, with 4 for the border.  Since
+    # more for 'bb\t' and we're there, with some pixels for the border.  Since
     # Tk_GetPixelsFromObj uses the standard 'int(0.5 + float)' rounding,
     # so must we.
-    set tab [expr {4 + int(0.5 + $tab + $cm)}]
+    set tab [expr {[bo] + int(0.5 + $tab + $cm)}]
     updateText
     set res [.t bbox 2.23]
-    lset res 0 [expr {[lindex $res 0] - $tab}]
-    set res
-} [list -28 [expr {$fixedDiff + 18}] 7 $fixedHeight]
-test textDisp-27.7.1 {SizeOfTab procedure, center alignment, wrap -none (potential numerical problems)} {textfonts} {
+    set expected [list [expr {[xchar 23]-$tab}] [yline 2] $fixedWidth $fixedHeight]
+    lequal [lset res 0 [expr {[lindex $res 0] - $tab}]] $expected
+} {1}
+test textDisp-27.7.1 {SizeOfTab procedure, center alignment, wrap -none (potential numerical problems)} {
     .t delete 1.0 end
     .t configure -tabstyle wordprocessor
     set cm [winfo fpixels .t 1c]
     .t configure -tabs {1c 2c center 3c 4c 5c 6c 7c 8c} -wrap none -width 40
     .t insert 1.0 a\tb\tc\td\te\n012345678934567890a\tbb\tcc\tdd
@@ -3690,20 +4174,19 @@
     set tab $cm
     while {$tab < $width} {
 	set tab [expr {$tab + $cm}]
     }
     # Now we've calculated to the end of the tab after 'a', add one
-    # more for 'bb\t' and we're there, with 4 for the border.  Since
+    # more for 'bb\t' and we're there, with some pixels for the border.  Since
     # Tk_GetPixelsFromObj uses the standard 'int(0.5 + float)' rounding,
     # so must we.
-    set tab [expr {4 + int(0.5 + $tab + $cm)}]
+    set tab [expr {[bo] + int(0.5 + $tab + $cm)}]
     updateText
     set res [.t bbox 2.23]
     .t configure -tabstyle tabular
     lset res 0 [expr {[lindex $res 0] - $tab}]
-    set res
-} [list 0 [expr {$fixedDiff + 18}] 7 $fixedHeight]
+} [list 0 [yline 2] $fixedWidth $fixedHeight]
 test textDisp-27.7.2 {SizeOfTab procedure, fractional tab interpolation problem} {
     .t delete 1.0 end
     set interpolatetab {1c 2c}
     set precisetab {}
     for {set i 1} {$i < 20} {incr i} {
@@ -3720,48 +4203,53 @@
     expr {[lindex $res 0] - [lindex [.t bbox 1.20] 0]}
 } 0
 
 .t configure -wrap char -tabs {} -width 20
 updateText
-test textDisp-27.8 {SizeOfTab procedure, right alignment} {textfonts} {
+test textDisp-27.8 {SizeOfTab procedure, right alignment} {
     .t delete 1.0 end
     .t insert 1.0 a\t\txyzzyabc
     .t tag delete x
-    .t tag configure x -tabs {100 left 140 right}
+    .t tag configure x -tabs "[expr {14.3*$fixedWidth}] left [expr {[.t cget -width]*$fixedWidth}] right"
     .t tag add x 1.0 end
     list [.t bbox 1.6] [.t bbox 1.7]
-} [list [list 137 5 7 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-27.9 {SizeOfTab procedure, left alignment} {textfonts} {
+} [list [list [xcharr 1] [yline 1] $fixedWidth $fixedHeight] \
+        [list [bo] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-27.9 {SizeOfTab procedure, left alignment} {
     .t delete 1.0 end
     .t insert 1.0 a\txyzzyabc
     .t tag delete x
-    .t tag configure x -tabs 120
+    .t tag configure x -tabs "[expr {17.14*$fixedWidth}]"
     .t tag add x 1.0 end
     list [.t bbox 1.3] [.t bbox 1.4]
-} [list [list 131 5 13 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-27.10 {SizeOfTab procedure, numeric alignment} {textfonts} {
+} [list [list [expr {round([bo]+17.14*$fixedWidth+$fixedWidth)}] [yline 1] [expr {[winfo width .t]-round([bo]+17.14*$fixedWidth+$fixedWidth)-[bo]}] $fixedHeight] \
+        [list [bo] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-27.10 {SizeOfTab procedure, numeric alignment} {
     .t delete 1.0 end
     .t insert 1.0 a\t123.4
     .t tag delete x
-    .t tag configure x -tabs {120 numeric}
+    .t tag configure x -tabs "[expr {17.14*$fixedWidth}] numeric"
     .t tag add x 1.0 end
     list [.t bbox 1.3] [.t bbox 1.4]
-} [list [list 117 5 27 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
-test textDisp-27.11 {SizeOfTab procedure, making tabs at least as wide as a space} {textfonts} {
+} [list [list [expr {round([bo]+17.14*$fixedWidth-$fixedWidth)}] [yline 1] [expr {[winfo width .t]-round([bo]+17.14*$fixedWidth-$fixedWidth)-[bo]}] $fixedHeight] \
+        [list [bo] [yline 2] $fixedWidth $fixedHeight]]
+test textDisp-27.11 {SizeOfTab procedure, making tabs at least as wide as a space} {
     .t delete 1.0 end
     .t insert 1.0 abc\tdefghijklmnopqrst
     .t tag delete x
-    .t tag configure x -tabs 120
+    .t tag configure x -tabs "[expr {17.14*$fixedWidth}]"
     .t tag add x 1.0 end
     list [.t bbox 1.5] [.t bbox 1.6]
-} [list [list 131 5 13 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
+} [list [list [expr {round([bo]+17.14*$fixedWidth+$fixedWidth)}] [yline 1] [expr {[winfo width .t]-round([bo]+17.14*$fixedWidth+$fixedWidth)-[bo]}] $fixedHeight] \
+        [list [bo] [yline 2] $fixedWidth $fixedHeight]]
 
 proc bizarre_scroll args {
     .t2.t delete 5.0 end
 }
-test textDisp-28.1 {"yview" option with bizarre scroll command} {
+test textDisp-28.1 {"yview" option with bizarre scroll command} -setup {
     catch {destroy .t2}
+} -body {
     toplevel .t2
     text .t2.t -width 40 -height 4
     .t2.t insert end "1\n2\n3\n4\n5\n6\n7\n8\n"
     pack .t2.t
     wm geometry .t2 +0+0
@@ -3769,14 +4257,17 @@
     .t2.t configure -yscrollcommand bizarre_scroll
     .t2.t yview 100.0
     set result [.t2.t index @0,0]
     updateText
     lappend result [.t2.t index @0,0]
-} {6.0 1.0}
+} -cleanup {
+    destroy .t2
+} -result {6.0 1.0}
 
-test textDisp-29.1 {miscellaneous: lines wrap but are still too long} {textfonts} {
+test textDisp-29.1 {miscellaneous: lines wrap but are still too long} -setup {
     catch {destroy .t2}
+} -body {
     toplevel .t2
     wm geometry .t2 +0+0
     text .t2.t -width 20 -height 10 -font $fixedFont \
 	    -wrap char -xscrollcommand ".t2.s set"
     pack .t2.t -side top
@@ -3784,14 +4275,20 @@
     pack .t2.s -side bottom -fill x
     .t2.t insert end 123
     frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
     .t2.t window create 1.1 -window .t2.t.f
     updateText
-    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
-} [list [list 0.0 [expr {20.0*$fixedWidth/300}]] 300x50+[expr {$twbw + $twht + 1}]+[expr {$twbw + $twht + $fixedHeight + 1}] [list [expr {$twbw + $twht + $fixedWidth + 1}] [expr {$twbw + $twht + $fixedHeight + 50 + 1}] $fixedWidth $fixedHeight]]
-test textDisp-29.2 {miscellaneous: lines wrap but are still too long} {textfonts} {
+    set expected [list [list 0.0 [expr {20.0*$fixedWidth/300}]] \
+                       300x50+[bo .t2.t]+[yline 2 .t2.t] \
+	               [list [xchar 1 .t2.t] [expr {[yline 2 .t2.t]+50}] $fixedWidth $fixedHeight]]
+    lequal [list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]] $expected
+} -cleanup {
+    destroy .t2
+} -result {1}
+test textDisp-29.2 {miscellaneous: lines wrap but are still too long} -setup {
     catch {destroy .t2}
+} -body {
     toplevel .t2
     wm geometry .t2 +0+0
     text .t2.t -width 20 -height 10 -font $fixedFont \
 	    -wrap char -xscrollcommand ".t2.s set"
     pack .t2.t -side top
@@ -3801,14 +4298,20 @@
     frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
     .t2.t window create 1.1 -window .t2.t.f
     updateText
     .t2.t xview scroll 1 unit
     updateText
-    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
-} [list [list [expr {1.0*$fixedWidth/300}] [expr {21.0*$fixedWidth/300}]] 300x50+[expr {$twbw + $twht + 1 - $fixedWidth}]+[expr {$twbw + $twht + $fixedHeight + 1}] [list [expr {$twbw + $twht + $fixedWidth + 1 - $fixedWidth}] [expr {$twbw + $twht + $fixedHeight + 50 + 1}] $fixedWidth $fixedHeight]]
-test textDisp-29.2.1 {miscellaneous: lines wrap but are still too long} {textfonts} {
+    set expected [list [list [expr {1.0*$fixedWidth/300}] [expr {21.0*$fixedWidth/300}]] \
+                       300x50+[expr {[bo .t2.t]-$fixedWidth}]+[yline 2 .t2.t] \
+	               [list [expr {[bo .t2.t]-$fixedWidth+$fixedWidth}] [expr {[yline 2 .t2.t]+50}] $fixedWidth $fixedHeight]]
+    lequal [list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]] $expected
+} -cleanup {
+    destroy .t2
+} -result {1}
+test textDisp-29.2.1 {miscellaneous: lines wrap but are still too long} -setup {
     catch {destroy .t2}
+} -body {
     toplevel .t2
     wm geometry .t2 +0+0
     text .t2.t -width 20 -height 10 -font $fixedFont \
 	    -wrap none -xscrollcommand ".t2.s set"
     pack .t2.t -side top
@@ -3818,13 +4321,16 @@
     .t2.t insert end [string repeat "abc" 30]
     updateText
     .t2.t xview scroll 5 unit
     updateText
     .t2.t xview
-} [list [expr {5.0/90}] [expr {25.0/90}]]
-test textDisp-29.2.2 {miscellaneous: lines wrap but are still too long} {textfonts} {
+} -cleanup {
+    destroy .t2
+} -result [list [expr {5.0/90}] [expr {25.0/90}]]
+test textDisp-29.2.2 {miscellaneous: lines wrap but are still too long} -setup {
     catch {destroy .t2}
+} -body {
     toplevel .t2
     wm geometry .t2 +0+0
     text .t2.t -width 20 -height 10 -font $fixedFont \
 	    -wrap char -xscrollcommand ".t2.s set"
     pack .t2.t -side top
@@ -3834,14 +4340,20 @@
     frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
     .t2.t window create 1.1 -window .t2.t.f
     updateText
     .t2.t xview scroll 2 unit
     updateText
-    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
-} [list [list [expr {2.0*$fixedWidth/300}] [expr {22.0*$fixedWidth/300}]] 300x50+[expr {$twbw + $twht + 1 - 2*$fixedWidth}]+[expr {$twbw + $twht + $fixedHeight + 1}] {}]
-test textDisp-29.2.3 {miscellaneous: lines wrap but are still too long} {textfonts} {
+    set expected [list [list [expr {2.0*$fixedWidth/300}] [expr {22.0*$fixedWidth/300}]] \
+                       300x50+[expr {[bo .t2.t]-2*$fixedWidth}]+[yline 2 .t2.t] \
+	               {}]
+    lequal [list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]] $expected
+} -cleanup {
+    destroy .t2
+} -result {1}
+test textDisp-29.2.3 {miscellaneous: lines wrap but are still too long} -setup {
     catch {destroy .t2}
+} -body {
     toplevel .t2
     wm geometry .t2 +0+0
     text .t2.t -width 20 -height 10 -font $fixedFont \
 	    -wrap char -xscrollcommand ".t2.s set"
     pack .t2.t -side top
@@ -3851,14 +4363,20 @@
     frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
     .t2.t window create 1.1 -window .t2.t.f
     updateText
     .t2.t xview scroll 7 pixels
     updateText
-    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
-} [list [list [expr {7.0/300}] [expr {(20.0*$fixedWidth + 7)/300}]] 300x50+[expr {$twbw + $twht + 1 - 7}]+[expr {$twbw + $twht + $fixedHeight + 1}] [list [expr {$twbw + $twht + $fixedWidth + 1 - 7}] [expr {$twbw + $twht + $fixedHeight + 50 + 1}] $fixedWidth $fixedHeight]]
-test textDisp-29.2.4 {miscellaneous: lines wrap but are still too long} {textfonts} {
+    set expected [list [list [expr {7.0/300}] [expr {(20.0*$fixedWidth+7)/300}]] \
+                       300x50+[expr {[bo .t2.t]-7}]+[yline 2 .t2.t] \
+	               [list [expr {[bo .t2.t]+$fixedWidth-7}] [expr {[yline 2 .t2.t]+50}] $fixedWidth $fixedHeight]]
+    lequal [list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]] $expected
+} -cleanup {
+    destroy .t2
+} -result {1}
+test textDisp-29.2.4 {miscellaneous: lines wrap but are still too long} -setup {
     catch {destroy .t2}
+} -body {
     toplevel .t2
     wm geometry .t2 +0+0
     text .t2.t -width 20 -height 10 -font $fixedFont \
 	    -wrap char -xscrollcommand ".t2.s set"
     pack .t2.t -side top
@@ -3868,14 +4386,20 @@
     frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
     .t2.t window create 1.1 -window .t2.t.f
     updateText
     .t2.t xview scroll 17 pixels
     updateText
-    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
-} [list [list [expr {17.0/300}] [expr {(20.0*$fixedWidth + 17)/300}]] 300x50+[expr {$twbw + $twht + 1 - 17}]+[expr {$twbw + $twht + $fixedHeight + 1}] {}]
-test textDisp-29.2.5 {miscellaneous: can show last character} {
+    set expected [list [list [expr {17.0/300}] [expr {(20.0*$fixedWidth+17)/300}]] \
+                       300x50+[expr {[bo .t2.t]-17}]+[yline 2 .t2.t] \
+	               {}]
+    lequal [list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]] $expected
+} -cleanup {
+    destroy .t2
+} -result {1}
+test textDisp-29.2.5 {miscellaneous: can show last character} -setup {
     catch {destroy .t2}
+} -body {
     toplevel .t2
     wm geometry .t2 121x141+200+200
     text .t2.t -width 5 -height 5 -font {Arial 10} \
       -wrap none -xscrollcommand ".t2.s set" \
       -bd 2 -highlightthickness 0 -padx 1
@@ -3891,19 +4415,21 @@
     set xd [expr {[lindex $xv 1] - [lindex $xv 0]}]
     .t2.t xview moveto [expr {1.0-$xd}]
     set iWidth [lindex [.t2.t bbox end-2c] 2]
     .t2.t xview scroll 2 units
     set iWidth2 [lindex [.t2.t bbox end-2c] 2]
-
     if {($iWidth == $iWidth2) && $iWidth >= 2} {
 	set result "correct"
     } else {
 	set result "last character is not completely visible when it should be"
     }
-} {correct}
-test textDisp-29.3 {miscellaneous: lines wrap but are still too long} {textfonts} {
+} -cleanup {
+    destroy .t2
+} -result {correct}
+test textDisp-29.3 {miscellaneous: lines wrap but are still too long} -setup {
     catch {destroy .t2}
+} -body {
     toplevel .t2
     wm geometry .t2 +0+0
     text .t2.t -width 20 -height 10 -font $fixedFont \
 	    -wrap char -xscrollcommand ".t2.s set"
     pack .t2.t -side top
@@ -3913,45 +4439,67 @@
     frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
     .t2.t window create 1.1 -window .t2.t.f
     updateText
     .t2.t xview scroll 200 units
     updateText
-    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
-} [list [list [expr {16.0/30}] 1.0] 300x50+-155+[expr {$fixedDiff + 18}] {}]
-test textDisp-30.1 {elidden text joining multiple logical lines} {
-    .t2.t delete 1.0 end
-    .t2.t insert 1.0 "1111\n2222\n3333"
-    .t2.t tag configure elidden -elide 1 -background red
-    .t2.t tag add elidden 1.2 3.2
-    .t2.t count -displaylines 1.0 end
-} 1
-test textDisp-30.2 {elidden text joining multiple logical lines} {
-    .t2.t delete 1.0 end
-    .t2.t insert 1.0 "1111\n2222\n3333"
-    .t2.t tag configure elidden -elide 1 -background red
-    .t2.t tag add elidden 1.2 2.2
-    .t2.t count -displaylines 1.0 end
-} 2
+    set expected [list [list [expr {double(300-20*$fixedWidth)/300}] 1.0] \
+                       300x50+[expr {-(300-20*$fixedWidth-[bo .t2.t])}]+[yline 2 .t2.t] \
+	               {}]
+    lequal [list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]] $expected
+} -cleanup {
+    destroy .t2
+} -result {1}
+
+test textDisp-30.1 {elided text joining multiple logical lines} -setup {
+    catch {destroy .t2}
+} -body {
+    toplevel .t2
+    text .t2.t -width 20 -height 10 -font $fixedFont
+    pack .t2.t -side top
+    .t2.t delete 1.0 end
+    .t2.t insert 1.0 "1111\n2222\n3333"
+    .t2.t tag configure elided -elide 1 -background red
+    .t2.t tag add elided 1.2 3.2
+    updateText
+    .t2.t count -update -displaylines 1.0 end
+} -cleanup {
+    destroy .t2
+} -result {1}
+test textDisp-30.2 {elided text joining multiple logical lines} -setup {
+    catch {destroy .t2}
+} -body {
+    toplevel .t2
+    text .t2.t -width 20 -height 10 -font $fixedFont
+    pack .t2.t -side top
+    .t2.t delete 1.0 end
+    .t2.t insert 1.0 "1111\n2222\n3333"
+    .t2.t tag configure elided -elide 1 -background red
+    .t2.t tag add elided 1.2 2.2
+    updateText
+    .t2.t count -update -displaylines 1.0 end
+} -cleanup {
+    destroy .t2
+} -result {2}
 catch {destroy .t2}
 
 .t configure -height 1
 updateText
 
-test textDisp-31.1 {line embedded window height update} failsOnUbuntu {
+test textDisp-31.1 {line embedded window height update} {
     set res {}
     .t delete 1.0 end
     .t insert end "abcd\nefgh\nijkl\nmnop\nqrst\nuvwx\nyx"
-    frame .t.f -background red -width 100 -height 100
+    frame .t.f -background red -width 50 -height 100
     .t window create 3.0 -window .t.f
     lappend res [.t count -update -ypixels 1.0 end]
     .t.f configure -height 10
     lappend res [.t count -ypixels 1.0 end]
     lappend res [.t count -update -ypixels 1.0 end]
-    set res
-} [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 6}] [expr {$fixedHeight * 7}]]
-
-test textDisp-31.2 {line update index shifting} failsOnUbuntu {
+} [list [expr {100+$fixedHeight*6}] \
+        [expr {100+$fixedHeight*6}] \
+	[expr {$fixedHeight*7}]]
+test textDisp-31.2 {line update index shifting} {
     set res {}
     .t.f configure -height 100
     updateText
     lappend res [.t count -update -ypixels 1.0 end]
     .t.f configure -height 10
@@ -3961,14 +4509,16 @@
     lappend res [.t count -update -ypixels 1.0 end]
     .t.f configure -height 100
     .t delete 1.0 3.0
     lappend res [.t count -ypixels 1.0 end]
     lappend res [.t count -update -ypixels 1.0 end]
-    set res
-} [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]]
-
-test textDisp-31.3 {line update index shifting} failsOnUbuntu {
+} [list [expr {100+$fixedHeight*6}] \
+        [expr {100+$fixedHeight*8}] \
+	[expr {$fixedHeight*9}] \
+	[expr {$fixedHeight*7}] \
+	[expr {100+$fixedHeight*6}]]
+test textDisp-31.3 {line update index shifting} {
     # Should do exactly the same as the above, as long
     # as we are correctly tagging the correct lines for
     # recalculation.  The 'update' and 'delay' must be
     # long enough to ensure all asynchronous updates
     # have been performed.
@@ -3986,12 +4536,15 @@
     .t delete 1.0 3.0
     lappend res [.t count -ypixels 1.0 end]
     delay
     lappend res [.t count -ypixels 1.0 end]
     set res
-} [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]]
-
+} [list [expr {100+$fixedHeight*6}] \
+        [expr {100+$fixedHeight*8}] \
+	[expr {$fixedHeight*9}] \
+	[expr {$fixedHeight*7}] \
+	[expr {100+$fixedHeight*6}]]
 test textDisp-31.4 {line embedded image height update} {
     set res {}
     image create photo textest -height 100 -width 10
     .t delete 3.0
     .t image create 3.0 -image textest
@@ -3999,13 +4552,14 @@
     lappend res [.t count -update -ypixels 1.0 end]
     textest configure -height 10
     lappend res [.t count -ypixels 1.0 end]
     lappend res [.t count -update -ypixels 1.0 end]
     set res
-} [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 6}] [expr {$fixedHeight * 7}]]
-
-test textDisp-31.5 {line update index shifting} failsOnUbuntu {
+} [list [expr {100+$fixedHeight*6}] \
+        [expr {100+$fixedHeight*6}] \
+	[expr {$fixedHeight*7}]]
+test textDisp-31.5 {line update index shifting} {
     set res {}
     textest configure -height 100
     updateText
     lappend res [.t count -update -ypixels 1.0 end]
     textest configure -height 10
@@ -4016,13 +4570,16 @@
     textest configure -height 100
     .t delete 1.0 3.0
     lappend res [.t count -ypixels 1.0 end]
     lappend res [.t count -update -ypixels 1.0 end]
     set res
-} [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]]
-
-test textDisp-31.6 {line update index shifting} failsOnUbuntu {
+} [list [expr {100+$fixedHeight*6}] \
+        [expr {100+$fixedHeight*8}] \
+	[expr {$fixedHeight*9}] \
+	[expr {$fixedHeight*7}] \
+	[expr {100+$fixedHeight*6}]]
+test textDisp-31.6 {line update index shifting} {
     # Should do exactly the same as the above, as long
     # as we are correctly tagging the correct lines for
     # recalculation.  The 'update' and 'delay' must be
     # long enough to ensure all asynchronous updates
     # have been performed.
@@ -4039,12 +4596,15 @@
     .t delete 1.0 3.0
     lappend res [.t count -ypixels 1.0 end]
     delay
     lappend res [.t count -ypixels 1.0 end]
     set res
-} [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]]
-
+} [list [expr {100+$fixedHeight*6}] \
+        [expr {100+$fixedHeight*8}] \
+	[expr {$fixedHeight*9}] \
+	[expr {$fixedHeight*7}] \
+	[expr {100+$fixedHeight*6}]]
 test textDisp-31.7 {line update index shifting, elided} {
     # The 'update' and 'delay' must be long enough to ensure all
     # asynchronous updates have been performed.
     set res {}
     .t delete 1.0 end
@@ -4060,11 +4620,16 @@
     .t delete 1.0 3.0
     lappend res [.t count -ypixels 1.0 end]
     delay
     lappend res [.t count -ypixels 1.0 end]
     set res
-} [list [expr {$fixedHeight * 1}] [expr {$fixedHeight * 3}] [expr {$fixedHeight * 3}] [expr {$fixedHeight * 2}] [expr {$fixedHeight * 1}] [expr {$fixedHeight * 1}]]
+} [list [expr {$fixedHeight*1}] \
+        [expr {$fixedHeight*3}] \
+	[expr {$fixedHeight*3}] \
+	[expr {$fixedHeight*2}] \
+	[expr {$fixedHeight*1}] \
+	[expr {$fixedHeight*1}]]
 
 test textDisp-32.0 {everything elided} {
     # Must not crash
     pack [text .tt]
     .tt insert 0.0 HELLO
@@ -4189,10 +4754,24 @@
     updateText
 } -cleanup {
     image delete $img
     destroy .tt
 }
+test textDisp-32.4 {Button-1 click with elided lines - Bug 18371b7ce7} -setup {
+    pack [text .tt -borderwidth 0 -highlightthickness 0]
+    for {set n 1} {$n <= 5} {incr n} {
+	.tt insert end "Line $n\n"
+    }
+    .tt tag configure Elided -elide 1
+    .tt tag add Elided 1.2 4.0
+    update
+} -body {
+    event generate .tt <Button-1> -x 1 -y 1
+    .tt index insert
+} -cleanup {
+    destroy .tt
+} -result {1.0}
 
 test textDisp-33.0 {one line longer than fits in the widget} {
     pack [text .tt -wrap char]
     updateText
     .tt insert 1.0 [string repeat "more wrap + " 300]
@@ -4205,10 +4784,11 @@
     pack [text .tt -wrap char]
     updateText
     .tt insert 1.0 [string repeat "more wrap + " 300]
     updateText
     .tt yview "1.0 +1 displaylines"
+    updateText
     if {[lindex [.tt yview] 0] > 0.1} {
 	set result "window should be scrolled to the top"
     } else {
 	set result "ok"
     }
@@ -4226,25 +4806,20 @@
     set tk_textHeightCalc
 } {1.0}
 test textDisp-33.3 {one line longer than fits in the widget} {
     destroy .tt
     pack [text .tt -wrap char]
-    .tt debug 1
     set tk_textHeightCalc ""
     .tt insert 1.0 [string repeat "more wrap + " 300]
     updateText
-    .tt count -update -ypixels 1.0 end
-    updateText
+    .tt sync
     # Each line should have been recalculated just once
-    .tt debug 0
     expr {[llength $tk_textHeightCalc] == [.tt count -displaylines 1.0 end]}
 } 1
 test textDisp-33.4 {one line longer than fits in the widget} {
     destroy .tt
     pack [text .tt -wrap char]
-    .tt debug 1
-    set tk_textHeightCalc ""
     .tt insert 1.0 [string repeat "more wrap + " 300]
     updateText
     set idx [.tt index "1.0 + 1 displaylines"]
     .tt yview $idx
     if {[lindex [.tt yview] 0] > 0.1} {
@@ -4251,11 +4826,10 @@
 	set result "window should be scrolled to the top"
     } else {
 	set result "ok"
     }
     set idx [.tt index "1.0 + 1 displaylines"]
-    .tt debug 0
     set result
 } {ok}
 destroy .tt
 test textDisp-33.5 {bold or italic fonts} win {
     destroy .tt
@@ -4288,11 +4862,10 @@
         append txt "Line $i\n"
     }
     set result {}
 } -body {
     .t1 insert end $txt
-    .t1 debug 1
     set ge [winfo geometry .]
     scan $ge "%dx%d+%d+%d" width height left top
     updateText
     .t1 sync
     set negative 0
@@ -4310,10 +4883,15 @@
     destroy .t1
 } -result 0
 
 test textDisp-35.1 {Init value of charHeight - Dancing scrollbar bug 1499165} -setup {
     pack [text .t1] -fill both -expand y -side left
+    # We don't want debug for this test case, because it takes some hours
+    # if valgrind check is fully enabled. In this test case only the scrollbar
+    # behavior is relevant, all other involved functions (insert, see, ...) are
+    # already tested with debug mode in other test cases.
+    .t debug off
     .t insert end "[string repeat a\nb\nc\n 500000]THE END\n"
     set res {}
 } -body {
     .t see 10000.0
     after 300 {set fr1 [.t yview] ; set done 1}
@@ -4321,14 +4899,31 @@
     after 300 {set fr2 [.t yview] ; set done 1}
     vwait done
     lappend res [expr {[lindex $fr1 0] == [lindex $fr2 0]}]
     lappend res [expr {[lindex $fr1 1] == [lindex $fr2 1]}]
 } -cleanup {
+    .t debug on ;# re-enable debugging
     destroy .t1
 } -result {1 1}
+
+test textDisp-36.1 {Display bug with 'yview insert'} -constraints {knownBug} -setup {
+   text .t1 -font $fixedFont -width 20 -height 3 -wrap word
+   pack .t1
+   .t1 delete 1.0 end
+   .t1 tag configure elide -elide 1
+   .t1 insert end "Line 1\nThis line is wrapping around two times."
+} -body {
+   .t1 tag add elide 1.3 2.0
+   .t1 yview insert
+   updateText
+   # wish now panics: "CalculateDisplayLineHeight called with bad indexPtr"
+   .t1 yview scroll -1 pixels
+} -cleanup {
+    destroy .t1
+} -result {}
 
 deleteWindows
 option clear
 
 # cleanup
 cleanupTests
 return

Index: tests/textImage.test
==================================================================
--- tests/textImage.test
+++ tests/textImage.test
@@ -2,11 +2,11 @@
 #
 # This file contains a collection of tests for one or more of the Tcl
 # built-in commands.  Sourcing this file into Tcl runs the tests and
 # generates output for errors.  No output means no errors were found.
 #
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv

Index: tests/textIndex.test
==================================================================
--- tests/textIndex.test
+++ tests/textIndex.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test the code in the file tkTextIndex.c.
 # This file is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
@@ -266,11 +266,11 @@
     set result [list [.t index z.first] [.t index z.last]]
     .t tag delete z
     set result
 } {1.0 1.1}
 
-test textIndex-5.1 {TkTextGetIndex, "@"} {nonPortable fonts} {
+test textIndex-5.1 {TkTextGetIndex, "@"} {fonts} {
     .t index @12,9
 } 1.1
 test textIndex-5.2 {TkTextGetIndex, "@"} {fonts} {
     .t index @-2,7
 } 1.0
@@ -752,10 +752,11 @@
 set str [string repeat "hello " 20]
 
 .t insert end "$str one two three four five six seven height nine ten\n"
 .t insert end "$str one two three four five six seven height nine ten\n"
 .t insert end "$str one two three four five six seven height nine ten\n"
+updateText
 
 test textIndex-19.1 {Display lines} {
     .t index "2.7 displaylinestart"
 } {2.0}
 
@@ -831,10 +832,22 @@
     .txt insert HISTORY "\n" {NICK NICK-tick}
     # Must not crash
     .txt index "2.0 - 2 display lines"
     destroy .txt .sbar
 } {}
+
+test textIndex-19.14 {Display lines with elided lines} {
+    catch {destroy .t}
+    pack [text .t]
+    for {set n 1} {$n <= 1000} {incr n} {
+	.t insert end "Line $n\n"
+    }
+    .t tag configure Elided -elide 1
+    .t tag add Elided 6.0 951.0
+    update
+    set res [.t index "951.0 + 1 displaylines"]
+} {952.0}
 
 proc text_test_word {startend chars start} {
     destroy .t
     text .t
     .t insert end $chars
@@ -961,11 +974,48 @@
     # then this used to crash Tk:
     .t2 see end
     focus -force .t2   ; # to see the cursor blink
     destroy .t2
 } {}
+
+test textIndex-26.1 {GetIndex restricts the returned index to -starline/-endline in peers, bug [34db75c0ac]} {
+    set res {}
+    pack [text .t2]
+    .t2 insert end "line 1\nline 2\nline 3\nline 4\nline 5\nline 6\n"
+    pack [.t2 peer create .p2 -startline 2 -endline 3]
+    lappend res [.p2 index "end"]
+    lappend res [.p2 index "end lineend"]
+    lappend res [.p2 index "end display lineend"]
+    destroy .t2 .p2
+    set res
+} {2.0 2.0 2.0}
+test textIndex-26.2 {GetIndex errors out if mark, image, window, or tag is outside peer -starline/-endline, bug [34db75c0ac]} {
+    set res {}
+    pack [text .t2]
+    .t2 insert end "line 1\nline 2\nline 3\nline 4\nline 5\nline 6\n"
+    pack [.t2 peer create .p2 -startline 2 -endline 3]
+    .p2 configure -startline 3 -endline {}
+    .t2 mark set mymark 1.0
+    catch {.p2 index mymark} msg
+    lappend res [.t2 index mymark] $msg
+    image create photo redsquare -width 5 -height 5
+    redsquare put red -to 0 0 4 4
+    .t2 image create 1.0 -image redsquare
+    catch {.p2 index redsquare} msg
+    lappend res [.t2 index redsquare] $msg
+    frame .f -width 10 -height 10 -bg blue
+    .t2 window create 1.2 -window .f
+    catch {.p2 index .f} msg
+    lappend res [.t2 index .f] $msg
+    .t2 tag add mytag 1.3
+    catch {.p2 index mytag.first} msg
+    lappend res [.t2 index mytag.first] $msg
+    destroy .t2 .p2
+    set res
+} {1.0 {bad text index "mymark"} 1.0 {bad text index "redsquare"} 1.2\
+   {bad text index ".f"} 1.3 {text doesn't contain any characters tagged with "mytag"}}
 
 # cleanup
 rename textimage {}
 catch {destroy .t}
 cleanupTests
 return

Index: tests/textMark.test
==================================================================
--- tests/textMark.test
+++ tests/textMark.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test the code in the file tkTextMark.c.
 # This file is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 tcltest::configure {*}$argv
@@ -180,10 +180,21 @@
   .t configure -startline 5 -endline 5
   set res [.t index insert]
 } -cleanup {
   .t configure -startline {} -endline {}
 } -result {1.0}
+test textMark-6.6 {attempt to move the insert mark beyond peer -endline - bug 34db75c0ac} -body {
+  .t peer create .p -startline 1 -endline 2
+  pack .p
+  update
+  .p mark set insert 1.2
+  focus -force .p
+  event generate .p <<NextLine>>  ; # shall not error out
+  set res [.p index insert]
+} -cleanup {
+  destroy .p
+} -result {1.9}
 
 test textMark-7.1 {MarkFindNext - invalid mark name} -body {
     .t mark next bogus
 } -returnCodes error -result {bad text index "bogus"}
 test textMark-7.2 {MarkFindNext - marks at same location} -body {

Index: tests/textTag.test
==================================================================
--- tests/textTag.test
+++ tests/textTag.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test the code in the file tkTextTag.c.
 # This file is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv
@@ -24,11 +24,11 @@
     [font actual  $textWidgetFont -size] == 12 &&
     [font metrics $bigFont -fixed] &&
     [font actual  $bigFont -size] == 24 }
 ]
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnUbuntuNoXft [expr {[testConstraint failsOnUbuntu] || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))}]
 
 destroy .t
 text .t -width 20 -height 10
 
@@ -178,11 +178,11 @@
 } -result {on}
 test textTag-1.21 {configuration options} -body {
     .t tag configure x -overstrike stupid
 } -cleanup {
     .t tag configure x -overstrike [lindex [.t tag configure x -overstrike] 3]
-} -returnCodes error -result {expected boolean value but got "stupid"}
+} -returnCodes error -result {expected boolean value or "" but got "stupid"}
 test textTag-1.21a {tag configuration options} -body {
     .t tag configure x -overstrikefg red
     .t tag cget x -overstrikefg
 } -cleanup {
     .t tag configure x -overstrikefg [lindex [.t tag configure x -overstrikefg] 3]
@@ -299,11 +299,11 @@
 } -result {no}
 test textTag-1.35 {configuration options} -body {
     .t tag configure x -underline stupid
 } -cleanup {
     .t tag configure x -underline [lindex [.t tag configure x -underline] 3]
-} -returnCodes error -result {expected boolean value but got "stupid"}
+} -returnCodes error -result {expected boolean value or "" but got "stupid"}
 test textTag-1.36 {tag configuration options} -body {
     .t tag configure x -underlinefg red
     .t tag cget x -underlinefg
 } -cleanup {
     .t tag configure x -underlinefg [lindex [.t tag configure x -underlinefg] 3]
@@ -530,17 +530,17 @@
 } -result {-overstrikefg {} {} {} lightgreen}
 test textTag-5.6 {TkTextTagCmd - "configure" option} -body {
     .t tag configure x -overstrike foo
 } -cleanup {
     .t tag delete x
-} -returnCodes error -result {expected boolean value but got "foo"}
+} -returnCodes error -result {expected boolean value or "" but got "foo"}
 test textTag-5.7 {TkTextTagCmd - "configure" option} -body {
     .t tag delete x
     .t tag configure x -underline stupid
 } -cleanup {
     .t tag delete x
-} -returnCodes error -result {expected boolean value but got "stupid"}
+} -returnCodes error -result {expected boolean value or "" but got "stupid"}
 test textTag-5.8 {TkTextTagCmd - "configure" option} -body {
     .t tag delete x
     .t tag configure x -justify left
     .t tag configure x -justify
 } -cleanup {
@@ -1235,11 +1235,12 @@
 .t configure -font $curFont -wrap $curWrap
 
 test textTag-15.1 {TkTextBindProc} -setup {
     .t tag delete x y
     wm geometry . +200+200 ; update
-    event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
+    event generate {} <Motion> -warp 1 -x 5 -y 5
+    controlPointerWarpTiming
 } -body {
     bind .t <ButtonRelease> {lappend x up}
     .t tag bind x <ButtonRelease> {lappend x x-up}
     .t tag bind y <ButtonRelease> {lappend x y-up}
     set x {}
@@ -1261,11 +1262,12 @@
 } -result {x-up up up y-up up}
 
 test textTag-15.2 {TkTextBindProc} -setup {
     .t tag delete x y
     wm geometry . +200+200 ; update
-    event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
+    event generate {} <Motion> -warp 1 -x 5 -y 5
+    controlPointerWarpTiming
 } -body {
     .t tag bind x <Enter> {lappend x x-enter}
     .t tag bind x <Button> {lappend x x-down}
     .t tag bind x <ButtonRelease> {lappend x x-up}
     .t tag bind x <Leave> {lappend x x-leave}
@@ -1290,11 +1292,12 @@
 } -result {x-enter | x-down | | x-up x-leave y-enter}
 
 test textTag-15.3 {TkTextBindProc} -setup {
     .t tag delete x y
     wm geometry . +200+200 ; update
-    event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
+    event generate {} <Motion> -warp 1 -x 5 -y 5
+    controlPointerWarpTiming
 } -body {
     .t tag bind x <Enter> {lappend x x-enter}
     .t tag bind x <Button-1> {lappend x x-down}
     .t tag bind x <ButtonRelease-1> {lappend x x-up}
     .t tag bind x <Leave> {lappend x x-leave}
@@ -1320,15 +1323,34 @@
     return $x
 } -cleanup {
     .t tag delete x y
 } -result {x-enter | x-down | | | x-up | x-leave y-enter}
 
+test textTag-15.4 {TkTextBindProc, key event with mouse outside the widget} -setup {
+    .t tag delete {*}[.t tag names]
+    wm geometry . +200+200 ; update
+} -body {
+    set res {}
+    .t tag add tag1 1.0 end
+    .t tag bind tag1 <Key> {lappend res %K}
+    .t mark set insert 1.2
+    update
+    event generate .t <Motion> -warp 1 -x -50 -y -50
+    controlPointerWarpTiming
+    focus -force .t
+    event generate .t <Key> -keysym a
+    set res
+} -cleanup {
+    .t tag delete tag1
+} -result {a}
+
 
 test textTag-16.1 {TkTextPickCurrent procedure} -setup {
     .t tag delete {*}[.t tag names]
     wm geometry . +200+200 ; update
-    event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
+    event generate {} <Motion> -warp 1 -x 5 -y 5
+    controlPointerWarpTiming
 } -body {
     event gen .t <ButtonRelease-1> -state 0x100 -x $x1 -y $y1
     set x [.t index current]
     event gen .t <Motion> -x $x2 -y $y2
     lappend x [.t index current]
@@ -1347,14 +1369,17 @@
 test textTag-16.2 {TkTextPickCurrent procedure} -constraints {
     haveFontSizes failsOnUbuntuNoXft
 } -setup {
     .t tag delete {*}[.t tag names]
     wm geometry . +200+200 ; update
-    event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
+    event generate {} <Motion> -warp 1 -x 5 -y 5
+    controlPointerWarpTiming
     .t configure -font $textWidgetFont -wrap none
 } -body {
     .t tag configure big -font $bigFont
+    # update needed here to stabilize the test
+    update
     event gen .t <ButtonRelease-1> -state 0x100 -x $x4 -y $y4
     event gen .t <Motion> -x $x5 -y $y5
     set x [.t index current]
     .t tag add big 3.0
     update
@@ -1367,11 +1392,12 @@
 test textTag-16.3 {TkTextPickCurrent procedure} -setup {
     foreach i {a b c d} {
         .t tag remove $i 1.0 end
     }
     wm geometry . +200+200 ; update
-    event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
+    event generate {} <Motion> -warp 1 -x 5 -y 5
+    controlPointerWarpTiming
 } -body {
     foreach i {a b c d} {
         .t tag bind $i <Enter> "lappend x enter-$i"
         .t tag bind $i <Leave> "lappend x leave-$i"
     }
@@ -1395,11 +1421,12 @@
 test textTag-16.4 {TkTextPickCurrent procedure} -setup {
     foreach i {a b c d} {
         .t tag remove $i 1.0 end
     }
     wm geometry . +200+200 ; update
-    event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
+    event generate {} <Motion> -warp 1 -x 5 -y 5
+    controlPointerWarpTiming
 } -body {
     foreach i {a b c d} {
         .t tag bind $i <Enter> "lappend x enter-$i"
         .t tag bind $i <Leave> "lappend x leave-$i"
     }
@@ -1424,11 +1451,12 @@
 } -setup {
     foreach i {big a b c d} {
         .t tag remove $i 1.0 end
     }
     wm geometry . +200+200 ; update
-    event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
+    event generate {} <Motion> -warp 1 -x 5 -y 5
+    controlPointerWarpTiming
     .t configure -font $textWidgetFont -wrap none
 } -body {
     .t tag configure big -font $bigFont
     event gen .t <Motion> -x $x4 -y $y4
     .t tag bind a <Enter> {.t tag add big 3.0 3.2}
@@ -1445,11 +1473,12 @@
 } -setup {
     foreach i {big a b c d} {
         .t tag remove $i 1.0 end
     }
     wm geometry . +200+200 ; update
-    event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
+    event generate {} <Motion> -warp 1 -x 5 -y 5
+    controlPointerWarpTiming
     .t configure -font $textWidgetFont -wrap none
 } -body {
     .t tag configure big -font $bigFont
     event gen .t <Motion> -x $x4 -y $y4
     .t tag bind a <Enter> {.t tag add big 3.0 3.2}
@@ -1467,11 +1496,12 @@
 } -setup {
     foreach i {big a b c d} {
         .t tag remove $i 1.0 end
     }
     wm geometry . +200+200 ; update
-    event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
+    event generate {} <Motion> -warp 1 -x 5 -y 5
+    controlPointerWarpTiming
     .t configure -font $textWidgetFont -wrap none
 } -body {
     .t tag configure big -font $bigFont
     .t tag bind a <Enter> {.t tag add big 3.0 3.2}
     .t tag add a 3.2
@@ -1500,11 +1530,12 @@
 
 
 test textTag-18.1 {TkTextPickCurrent tag bindings} -setup {
     destroy .t
     wm geometry . +200+200 ; update
-    event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
+    event generate {} <Motion> -warp 1 -x 5 -y 5
+    controlPointerWarpTiming
 } -body {
     text .t -width 30 -height 4 -relief sunken -borderwidth 10 \
       -highlightthickness 10 -pady 2
     pack .t
     update ; # map the window, otherwise -warp can't be done
@@ -1517,21 +1548,25 @@
     bind .t <Leave> {lappend res Leave}
 
     set res {}
     # Bindings must not trigger on the widget border, only over
     # the actual tagged characters themselves.
+    # Note that we don't need to call controlPointerWarpTiming
+    # in the following six calls because we're not checking that
+    # the mouse pointer has actually moved but rather that the
+    # tag binding mechanism of the text widget correctly triggers.
     event gen .t <Motion> -warp 1 -x 0 -y 0 ; update
     event gen .t <Motion> -warp 1 -x 10 -y 10 ; update
     event gen .t <Motion> -warp 1 -x 25 -y 25 ; update
     event gen .t <Motion> -warp 1 -x 20 -y 20 ; update
     event gen .t <Motion> -warp 1 -x 10 -y 10 ; update
     event gen .t <Motion> -warp 1 -x 25 -y 25 ; update
-    return $res
+    set res
 } -cleanup {
     destroy .t
 } -result {Enter {25 25 tag-Enter} {20 20 tag-Leave} {25 25 tag-Enter}}
 
 destroy .t
 
 # cleanup
 cleanupTests
 return

Index: tests/textWind.test
==================================================================
--- tests/textWind.test
+++ tests/textWind.test
@@ -1,19 +1,25 @@
 # This file is a Tcl script to test the code in the file tkTextWind.c.
 # This file is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1995 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 tcltest::configure {*}$argv
 tcltest::loadTestedCommands
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+# Procedure for updating the text widget.  This is isolated here
+# to allow for variations between platforms, but is currently the
+# same for all platforms (see ticket [bfea11a916]).
+
+proc updateText {} {
+     update
+}
 
 deleteWindows
 
 set fixedFont {"Courier" -12}
 set fixedHeight [font metrics $fixedFont -linespace]
@@ -24,11 +30,11 @@
 set tWidth 30
 set tHeight 6
 text .t -width $tWidth -height $tHeight -bd 2 -highlightthickness 2 \
         -font $fixedFont
 pack .t -expand 1 -fill both
-update
+updateText
 .t debug on
 
 set color [expr {[winfo depth .t] > 1 ? "green" : "black"}]
 
 wm geometry . {}
@@ -60,11 +66,11 @@
 } -body {
     .t insert end "This is the first line"
     .t insert end "\nAnd this is a second line, which wraps around"
     frame .f -width 3 -height 3 -bg $color
     .t window create 2.2 -window .f
-    update
+    updateText
     list [winfo ismapped .f] [winfo geom .f] [.t bbox .f] \
         [.t window configure .f -window]
 } -result [list \
     1 \
     3x3+[expr {$padx+2*$fixedWidth}]+[expr {$pady+$fixedHeight+(($fixedHeight-3)/2)}] \
@@ -76,11 +82,11 @@
 } -body {
     .t insert end "This is the first line"
     .t insert end "\nAnd this is a second line, which wraps around"
     frame .f -width 3 -height 3 -bg $color
     .t window create 2.2 -window .f -align top
-    update
+    updateText
     list [winfo ismapped .f] [winfo geom .f] [.t bbox .f] \
         [.t window configure .f -align]
 } -result [list \
     1 \
     3x3+[expr {$padx+2*$fixedWidth}]+[expr {$pady+$fixedHeight}] \
@@ -102,11 +108,11 @@
     .t insert end "This is the first line"
     .t insert end "\nAnd this is a second line, which wraps around"
     # the window .f should be wider than the fixed width
     frame .f -width 10 -height 20 -bg $color
     .t window create 2.2 -window .f -padx 5
-    update
+    updateText
     list [winfo geom .f] [.t window configure .f -padx] [.t bbox 2.3]
 } -result [list \
     10x20+[expr {$padx+2*$fixedWidth+5}]+[expr {$pady+$fixedHeight}] \
     {-padx {} {} 0 5} \
     [list [expr {$padx+2*$fixedWidth+10+2*5}] [expr {$pady+$fixedHeight+((20-$fixedHeight)/2)}] $fixedWidth $fixedHeight]]
@@ -116,11 +122,11 @@
 } -body {
     .t insert end "This is the first line"
     .t insert end "\nAnd this is a second line, which wraps around"
     frame .f -width 10 -height 20 -bg $color
     .t window create 2.2 -window .f -pady 4
-    update
+    updateText
     list [winfo geom .f] [.t window configure .f -pady] [.t bbox 2.31]
 } -result [list \
     10x20+[expr {$padx+2*$fixedWidth}]+[expr {$pady+$fixedHeight+4}] \
     {-pady {} {} 0 4} \
     [list [expr {$padx+2*$fixedWidth}] [expr {$pady+$fixedHeight+20+2*4}] $fixedWidth $fixedHeight]]
@@ -130,11 +136,11 @@
 } -body {
     .t insert end "This is the first line"
     .t insert end "\nAnd this is a second line, which wraps around"
     frame .f -width 5 -height 5 -bg $color
     .t window create 2.2 -window .f -stretch 1
-    update
+    updateText
     list [winfo geom .f] [.t window configure .f -stretch]
 } -result [list \
     5x$fixedHeight+[expr {$padx+2*$fixedWidth}]+[expr {$pady+$fixedHeight}] \
     {-stretch {} {} 0 1}]
 
@@ -193,11 +199,11 @@
 } -body {
     .t insert end "This is the first line"
     .t insert end "\nAnd this is a second line, which wraps around"
     frame .f -width 10 -height 6 -bg $color
     .t window create 2.2 -window .f -align baseline -padx 1 -pady 2 -create foo
-    update
+    updateText
     .t window configure .f
 } -cleanup {
     destroy .f
 } -result  {{-align {} {} center baseline} {-create {} {} {} foo} {-padx {} {} 0 1} {-pady {} {} 0 2} {-stretch {} {} 0 0} {-window {} {} {} .f}}
 test textWind-2.12 {TkTextWindowCmd procedure} -setup {
@@ -209,11 +215,11 @@
 } -body {
     .t insert end "This is the first line"
     .t insert end "\nAnd this is a second line, which wraps around"
     frame .f -width 10 -height 6 -bg $color
     .t window create 2.2 -window .f -align baseline -padx 1 -pady 2 -create foo
-    update
+    updateText
     list [.t window configure .f -padx 33] [.t window configure .f -padx]
 } -cleanup {
     destroy .f
 } -result {{} {-padx {} {} 0 33}}
 test textWind-2.13 {TkTextWindowCmd procedure} -setup {
@@ -225,11 +231,11 @@
 } -body {
     .t insert end "This is the first line"
     .t insert end "\nAnd this is a second line, which wraps around"
     frame .f -width 10 -height 6 -bg $color
     .t window create 2.2 -window .f -align baseline -padx 1 -pady 2
-    update
+    updateText
     list [.t window configure .f -padx 14 -pady 15] \
         [.t window configure .f -padx] [.t window configure .f -pady]
 } -cleanup {
     destroy .f
 } -result {{} {-padx {} {} 0 14} {-pady {} {} 0 15}}
@@ -340,13 +346,13 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 10 -height 20 -bg $color
     .t window create 1.3 -window .f
-    update
+    updateWidgets
     .t window configure 1.3 -window {}
-    update
+    updateWidgets
     .t index .f
 } -cleanup {
     destroy .f
 } -returnCodes error -result {bad text index ".f"}
 
@@ -354,29 +360,29 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 10 -height 20 -bg $color
     .t window create 1.3 -window .f
-    update
+    updateWidgets
+    set res [winfo ismapped .f]
     .t window configure 1.3 -window {}
-    update
-    catch {.t index .f}
-    list [winfo ismapped .f] [.t bbox 1.4]
+    updateWidgets
+    lappend res [winfo ismapped .f] [.t bbox 1.4]
 } -cleanup {
     destroy .f
-} -result [list 0 \
+} -result [list 1 0 \
     [list [expr {$padx+3*$fixedWidth}] $pady $fixedWidth $fixedHeight]]
 
 test textWind-3.4 {EmbWinConfigure procedure} -setup {
     destroy .t.f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .t.f -width 10 -height 20 -bg $color
     .t window create 1.3 -window .t.f
-    update
+    updateWidgets
     .t window configure 1.3 -window {}
-    update
+    updateWidgets
     .t index .t.f
 } -cleanup {
     destroy .t.f
 } -returnCodes error -result {bad text index ".t.f"}
 
@@ -384,29 +390,29 @@
     destroy .t.f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .t.f -width 10 -height 20 -bg $color
     .t window create 1.3 -window .t.f
-    update
+    updateWidgets
+    set res [winfo ismapped .t.f]
     .t window configure 1.3 -window {}
-    update
-    catch {.t index .t.f}
-    list [winfo ismapped .t.f] [.t bbox 1.4]
+    updateWidgets
+    lappend res [winfo ismapped .t.f] [.t bbox 1.4]
 } -cleanup {
     destroy .t.f
-} -result [list 0 \
+} -result [list 1 0 \
     [list [expr {$padx+3*$fixedWidth}] $pady $fixedWidth $fixedHeight]]
 
 test textWind-3.6 {EmbWinConfigure procedure} -setup {
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 10 -height 20 -bg $color
     .t window create 1.3
-    update
+    updateWidgets
     .t window configure 1.3 -window .f
-    update
+    waitForMap .f
     list [catch {.t index .f} msg] $msg [winfo ismapped .f] [.t bbox 1.4]
 } -cleanup {
     destroy .f
 } -result [list 0 1.3 1 \
     [list [expr {$padx+3*$fixedWidth+10}] [expr {$pady+((20-$fixedHeight)/2)}] $fixedWidth $fixedHeight]]
@@ -457,11 +463,11 @@
     # a window away from itself.
     .t insert 1.0 "Some sample text"
     button .t.b -text "Hello!"
     .t window create 1.4 -window .t.b
     .t window create 1.6 -window .t.b
-    update
+    updateText
     .t index .t.b
 } -result {1.6}
 
 
 .t delete 1.0 end
@@ -498,11 +504,11 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 10 -height 20 -bg $color
     .t window create 1.2 -window .f
-    update
+    updateText
     destroy .f
     .t index .f
 } -returnCodes error -result {bad text index ".f"}
 
 test textWind-5.2 {EmbWinStructureProc procedure} -setup {
@@ -510,11 +516,11 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 10 -height 20 -bg $color
     .t window create 1.2 -window .f
-    update
+    updateText
     destroy .f
     catch {.t index .f}
     list [.t bbox 1.2] [.t bbox 1.3]
 } -result [list \
     [list [expr {$padx+2*$fixedWidth}] [expr {$pady+($fixedHeight/2)}] 0 0] \
@@ -526,11 +532,11 @@
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 10 -height 20 -bg $color
     .t window create 1.2 -align bottom
     .t window configure 1.2 -window .f
-    update
+    updateText
     destroy .f
     .t index .f
 } -returnCodes error -result {bad text index ".f"}
 
 test textWind-5.4 {EmbWinStructureProc procedure} -setup {
@@ -538,11 +544,11 @@
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 10 -height 20 -bg $color
     .t window create 1.2 -align bottom
     .t window configure 1.2 -window .f
-    update
+    updateText
     destroy .f
     catch {.t index .f}
     list [.t bbox 1.2] [.t bbox 1.3]
 } -result [list \
     [list [expr {$padx+2*$fixedWidth}] [expr {$pady+$fixedHeight}] 0 0] \
@@ -552,14 +558,14 @@
     .t delete 1.0 end
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     .t window create 1.2 -create {frame .f -width 10 -height 20 -bg $color}
-    update
+    updateText
     .t window configure 1.2 -create {frame .f -width 20 -height 10 -bg $color}
     destroy .f
-    update
+    updateText
     list [catch {.t index .f} msg] $msg [.t bbox 1.2] [.t bbox 1.3]
 } -result [list 0 1.2 \
     [list [expr {$padx+2*$fixedWidth}] [expr {$pady+(($fixedHeight-10)/2)}] 20 10] \
     [list [expr {$padx+2*$fixedWidth+20}] $pady $fixedWidth $fixedHeight]]
 
@@ -589,13 +595,13 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 10 -height 20 -bg $color
     .t window create 1.2 -window .f
-    update
+    updateText
     place .f -in .t -x 100 -y 50
-    update
+    updateText
     list [winfo geom .f] [.t bbox 1.2]
 } -cleanup {
     destroy .f
 } -result [list \
     10x20+[expr {$padx+100}]+[expr {$pady+50}] \
@@ -606,13 +612,13 @@
     destroy .t.f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .t.f -width 10 -height 20 -bg $color
     .t window create 1.2 -window .t.f
-    update
+    updateText
     place .t.f -x 100 -y 50
-    update
+    updateText
     list [winfo geom .t.f] [.t bbox 1.2]
 } -cleanup {
     destroy .t.f
 } -result [list \
     10x20+[expr {$padx+100}]+[expr {$pady+50}] \
@@ -668,11 +674,11 @@
 } -body {
     .t insert 1.0 "Some sample text"
     .t window create 1.5 -create {
         frame .f -width 10 -height 20 -bg $color
     }
-    update
+    updateText
     list [winfo exists .f] [winfo width .f] [winfo height .f] [.t index .f]
 } -cleanup {
     destroy .f
 } -result {1 10 20 1.5}
 
@@ -686,11 +692,11 @@
     .t insert 1.0 "Some sample text"
     .t window create 1.5 -create {
         error "couldn't create window"
     }
     set msg xyzzy
-    update
+    updateText
     list $msg [.t bbox 1.5]
 } -cleanup {
     rename bgerror {}
 } -result [list \
     {{couldn't create window}} \
@@ -706,11 +712,11 @@
     .t insert 1.0 "Some sample text"
     .t window create 1.5 -create {
         concat gorp
     }
     set msg xyzzy
-    update
+    updateText
     list $msg [.t bbox 1.5]
 } -cleanup {
     rename bgerror {}
 } -result [list \
     {{bad window path name "gorp"}} \
@@ -732,11 +738,11 @@
             frame .t.f.f -width 10 -height 20 -bg $color
         }
     }
     set count 0
     while {([llength $msg] < 2) && ($count < 100)} {
-        update
+        updateText
         incr count
         .t bbox 1.5
         after 10
     }
     lappend msg [.t bbox 1.5] [winfo exists .t.f.f]
@@ -762,11 +768,11 @@
     set msg {}
     .t window create 1.5 -create {
         frame .t.f
         frame .t.f.f -width 10 -height 20 -bg $color
     }
-    update idletasks
+    updateText
     lappend msg [winfo exists .t.f.f]
 } -cleanup {
     destroy .t.f
     rename bgerror {}
 } -result {{{can't embed .t.f.f relative to .t}} 1}
@@ -779,24 +785,24 @@
             lappend msg $args
         }
     }
 } -body {
     .t insert 1.0 "Some sample text"
-    update
+    updateText
     .t window create 1.5 -create {
         concat .t
     }
     set msg {}
-    update
+    updateText
     lappend msg [.t bbox 1.5]
 } -cleanup {
     rename bgerror {}
 } -result [list \
     {{can't embed .t relative to .t}} \
     [list [expr {$padx+5*$fixedWidth}] [expr {$pady+($fixedHeight/2)}] 0 0]]
 
-test textWind-10.7 {EmbWinLayoutProc procedure, error in creating window} -constraints failsOnUbuntu -setup {
+test textWind-10.7 {EmbWinLayoutProc procedure, error in creating window} -setup {
     .t delete 1.0 end
     destroy .t2
     proc bgerror args {
         global msg
 	lappend msg $args
@@ -807,11 +813,11 @@
         toplevel .t2 -width 100 -height 150
         wm geom .t2 +0+0
         concat .t2
     }
     set msg {}
-    update
+    update idletasks ; after 100 ; update
     lappend msg [.t bbox 1.5]
 } -cleanup {
     rename bgerror {}
 } -result [list \
     {{can't embed .t2 relative to .t}} {{window name "t2" already exists in parent}} \
@@ -830,13 +836,13 @@
         toplevel .t2 -width 100 -height 150
         wm geom .t2 +0+0
         concat .t2
     }
     set msg {}
-    update
+    updateText
     set i 0
-    while {[llength $msg] == 1 && [incr i] < 200} { update }
+    while {[llength $msg] == 1 && [incr i] < 200} { updateText }
     return $msg
 } -cleanup {
     destroy .t2
     rename bgerror {}
 } -result {{{can't embed .t2 relative to .t}} {{window name "t2" already exists in parent}}}
@@ -846,13 +852,13 @@
     destroy .t.b
 } -body {
     .t insert 1.0 ABCDEFGHIJKLMNOP
     button .t.b -text "Hello!"
     .t window create 1.5 -window .t.b
-    update
+    updateText
     .t window create 1.3 -create {concat .t.b}
-    update
+    updateText
     .t index .t.b
 } -cleanup {
     destroy .t.b
 } -result {1.3}
 
@@ -877,11 +883,11 @@
 } -body {
     .t configure -wrap char
     .t insert 1.0 "Some sample text"
     frame .f -width [expr {($tWidth-12)*$fixedWidth}] -height 20 -bg $color -bd 2 -relief raised
     .t window create 1.12 -window .f
-    update
+    updateText
     list [.t bbox .f] [.t bbox 1.13]
 } -cleanup {
     destroy .f
 } -result [list \
     [list [expr {$padx+12*$fixedWidth}] $pady [expr {$tWidth*$fixedWidth-12*$fixedWidth}] 20] \
@@ -893,11 +899,11 @@
 } -body {
     .t configure -wrap char
     .t insert 1.0 "Some sample text"
     frame .f -width [expr {($tWidth-12)*$fixedWidth+1}] -height 20 -bg $color -bd 2 -relief raised
     .t window create 1.12 -window .f
-    update
+    updateText
     list [.t bbox .f] [.t bbox 1.13]
 } -cleanup {
     destroy .f
 } -result [list \
     [list $padx [expr {$pady+$fixedHeight}] [expr {($tWidth-12)*$fixedWidth+1}] 20] \
@@ -909,11 +915,11 @@
 } -body {
     .t configure -wrap none
     .t insert 1.0 "Some sample text"
     frame .f -width [expr {($tWidth-12)*$fixedWidth+5}] -height 20 -bg $color -bd 2 -relief raised
     .t window create 1.12 -window .f
-    update
+    updateText
     list [.t bbox .f] [.t bbox 1.13]
 } -cleanup {
     destroy .f
 } -result [list \
     [list [expr {$padx+12*$fixedWidth}] $pady [expr {$tWidth*$fixedWidth-12*$fixedWidth}] 20] \
@@ -925,11 +931,11 @@
 } -body {
     .t configure -wrap none
     .t insert 1.0 "Some sample text"
     frame .f -width [expr {($tWidth-12)*$fixedWidth+5}] -height 220 -bg $color -bd 2 -relief raised
     .t window create 1.12 -window .f
-    update
+    updateText
     list [.t bbox .f] [.t bbox 1.13]
 } -cleanup {
     destroy .f
 } -result [list \
     [list [expr {$padx+12*$fixedWidth}] $pady [expr {$tWidth*$fixedWidth-12*$fixedWidth}] [expr {$tHeight*$fixedHeight}]] \
@@ -941,11 +947,11 @@
 } -body {
     .t configure -wrap char
     .t insert 1.0 "Some sample text"
     frame .f -width 250 -height 220 -bg $color -bd 2 -relief raised
     .t window create 1.12 -window .f
-    update
+    updateText
     list [.t bbox .f] [.t bbox 1.13]
 } -cleanup {
     destroy .f
 } -result [list \
     [list $padx [expr {$pady+$fixedHeight}] [expr {$tWidth*$fixedWidth}] [expr {($tHeight-1)*$fixedHeight}]] \
@@ -962,11 +968,11 @@
     .t insert 1.0 "Some sample text"
     pack forget .t
     place .t -x 30 -y 50
     frame .f -width 30 -height 20 -bg $color
     .t window create 1.12 -window .f
-    update ; after 100 ; update
+    update
     winfo geom .f
 } -cleanup {
     destroy .f
     place forget .t
 } -result [list 30x20+[expr {$padx+30+12*$fixedWidth}]+[expr {$pady+50}]]
@@ -982,11 +988,11 @@
     .t insert 1.0 "Some sample text"
     pack forget .t
     place .t -x 30 -y 50
     frame .t.f -width 30 -height 20 -bg $color
     .t window create 1.12 -window .t.f
-    update ; after 100 ; update
+    update
     winfo geom .t.f
 } -cleanup {
     destroy .t.f
     place forget .t
     pack .t
@@ -1028,11 +1034,11 @@
     frame .f2 -width 40 -height 10 -bg $color
     .t window create end -window .f2
     .t insert end " with junk after it."
     .t xview moveto 0
     .t xview scroll 5 units
-    update
+    updateText
     list [winfo ismapped .f] [winfo geom .f] [.t bbox .f] [winfo ismapped .f2]
 } -cleanup {
     destroy .f .f2
 } -result [list 1 \
     30x20+[expr {$padx+14*$fixedWidth}]+[expr {$pady+$fixedHeight}] \
@@ -1049,14 +1055,14 @@
     .t window create end -window .f
     .t insert end " and second here: "
     frame .f2 -width 40 -height 10 -bg $color
     .t window create end -window .f2
     .t insert end " with junk after it."
-    update
+    updateText
     .t xview moveto 0
     .t xview scroll 25 units
-    update
+    updateText
     list [winfo ismapped .f] [winfo ismapped .f2] [winfo geom .f2] [.t bbox .f2]
 } -cleanup {
   destroy .f .f2
   .t configure -wrap char
 } -result [list 0 1 \
@@ -1071,23 +1077,23 @@
     frame .f -width 30 -height 20 -bg $color
     .t window create 1.2 -window .f
     bind .f <Map> {lappend x mapped}
     bind .f <Unmap> {lappend x unmapped}
     set x created
-    update
+    updateText
     lappend x modified
     .t delete 1.0
-    update
+    updateText
     lappend x replaced
     .t window configure .f -window {}
     .t delete 1.1
     .t window create 1.4 -window .f
-    update
+    updateText
     lappend x off-screen
     .t configure -wrap none
     .t insert 1.0 "Enough text to make the line run off-screen"
-    update
+    updateText
     return $x
 } -cleanup {
     destroy .f
 } -result {created mapped modified replaced unmapped mapped off-screen unmapped}
 
@@ -1097,11 +1103,11 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 5 -height 5 -bg $color
     .t window create 1.2 -window .f -align top -padx 2 -pady 1
-    update
+    updateText
     list [winfo geom .f] [.t bbox .f]
 } -cleanup {
     destroy .f
 } -result [list \
     5x5+[expr {$padx+2*$fixedWidth+2}]+[expr {$pady+1}] \
@@ -1112,11 +1118,11 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 5 -height 5 -bg $color
     .t window create 1.2 -window .f -align center -padx 2 -pady 1
-    update
+    updateText
     list [winfo geom .f] [.t bbox .f]
 } -cleanup {
     destroy .f
 } -result [list \
     5x5+[expr {$padx+2*$fixedWidth+2}]+[expr {$pady+1+(($fixedHeight-7)/2)}] \
@@ -1127,11 +1133,11 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 5 -height 5 -bg $color
     .t window create 1.2 -window .f -align baseline -padx 2 -pady 1
-    update
+    updateText
     list [winfo geom .f] [.t bbox .f]
 } -cleanup {
     destroy .f
 } -result [list \
     5x5+[expr {$padx+2*$fixedWidth+2}]+[expr {$pady+1+($fixedAscent-6)}] \
@@ -1142,11 +1148,11 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 5 -height 5 -bg $color
     .t window create 1.2 -window .f -align bottom -padx 2 -pady 1
-    update
+    updateText
     list [winfo geom .f] [.t bbox .f]
 } -cleanup {
     destroy .f
 } -result [list \
     5x5+[expr {$padx+2*$fixedWidth+2}]+[expr {$pady+1+($fixedHeight-7)}] \
@@ -1157,11 +1163,11 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 5 -height 5 -bg $color
     .t window create 1.2 -window .f -align top -padx 2 -pady 1 -stretch 1
-    update
+    updateText
     list [winfo geom .f] [.t bbox .f]
 } -cleanup {
     destroy .f
 } -result [list \
     5x[expr {$fixedHeight-2}]+[expr {$padx+2*$fixedWidth+2}]+[expr {$pady+1}] \
@@ -1172,11 +1178,11 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 5 -height 5 -bg $color
     .t window create 1.2 -window .f -align center -padx 2 -pady 1 -stretch 1
-    update
+    updateText
     list [winfo geom .f] [.t bbox .f]
 } -cleanup {
     destroy .f
 } -result [list \
     5x[expr {$fixedHeight-2}]+[expr {$padx+2*$fixedWidth+2}]+[expr {$pady+1}] \
@@ -1187,11 +1193,11 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 5 -height 5 -bg $color
     .t window create 1.2 -window .f -align baseline -padx 2 -pady 1 -stretch 1
-    update
+    updateText
     list [winfo geom .f] [.t bbox .f]
 } -cleanup {
     destroy .f
 } -result [list \
     5x[expr {$fixedAscent-1}]+[expr {$padx+2*$fixedWidth+2}]+[expr {$pady+1}] \
@@ -1202,11 +1208,11 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 5 -height 5 -bg $color
     .t window create 1.2 -window .f -align bottom -padx 2 -pady 1 -stretch 1
-    update
+    updateText
     list [winfo geom .f] [.t bbox .f]
 } -cleanup {
     destroy .f
 } -result [list \
     5x[expr {$fixedHeight-2}]+[expr {$padx+2*$fixedWidth+2}]+[expr {$pady+1}] \
@@ -1219,11 +1225,11 @@
     .t configure -spacing1 5 -spacing3 2
     .t delete 1.0 end
     .t insert 1.0 "Some sample text"
     frame .f -width 5 -height 5 -bg $color
     .t window create 1.2 -window .f -align center -padx 2 -pady 1
-    update
+    updateText
     list [winfo geom .f] [.t bbox .f]
 } -cleanup {
     .t configure -spacing1 0 -spacing3 0
     destroy .f
 } -result [list \
@@ -1236,18 +1242,18 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 30 -height 20 -bg $color
     .t window create 1.2 -window .f
-    update
+    updateText
     bind .f <Unmap> {lappend x unmapped}
     set x modified
     .t insert 1.0 x
     lappend x removed
     .t window configure .f -window {}
     lappend x updated
-    update
+    updateText
     return $x
 } -cleanup {
     destroy .f
 } -result {modified removed unmapped updated}
 
@@ -1256,18 +1262,18 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text"
     frame .f -width 30 -height 20 -bg $color
     .t window create 1.2 -window .f
-    update
+    updateText
     bind .f <Unmap> {lappend x unmapped}
     set x modified
     .t insert 1.0 x
     lappend x deleted
     .t delete .f
     lappend x updated
-    update
+    updateText
     return $x
 } -cleanup {
     destroy .f
 } -result {modified deleted updated}
 
@@ -1276,14 +1282,14 @@
     destroy .f
 } -body {
     .t insert 1.0 "Some sample text\nAnother line\n3\n4\n5\n6\n7\n8\n9"
     frame .f -width 30 -height 20 -bg $color
     .t window create 1.2 -window .f
-    update
+    updateText
     .t yview 2.0
     set result [winfo ismapped .f]
-    update ; after 10
+    updateText ; after 10
     list $result [winfo ismapped .f]
 } -cleanup {
     destroy .f
 } -result {1 0}
 
@@ -1292,14 +1298,14 @@
     destroy .t.f
 } -body {
     .t insert 1.0 "Some sample text\nAnother line\n3\n4\n5\n6\n7\n8\n9"
     frame .t.f -width 30 -height 20 -bg $color
     .t window create 1.2 -window .t.f
-    update
+    updateText
     .t yview 2.0
     set result [winfo ismapped .t.f]
-    update
+    updateText
     list $result [winfo ismapped .t.f]
 } -cleanup {
     destroy .t.f
 } -result {1 0}
 
@@ -1333,13 +1339,13 @@
 } -body {
     .t configure -wrap none
     .t insert 1.0 "Some sample text"
     frame .f -width 30 -height 20 -bg $color
     .t window create 1.6 -window .f
-    update
+    updateText
     pack forget .t
-    update
+    updateText
     winfo ismapped .f
 } -cleanup {
     pack .t
 } -result 0
 
@@ -1350,16 +1356,16 @@
     .t configure -spacing1 0 -spacing2 0 -spacing3 0 \
         -wrap none
     .t insert 1.0 "Some sample text"
     frame .f -width 30 -height 20 -bg $color
     .t window create 1.6 -window .f
-    update
+    updateText
     set result {}
     lappend result [winfo geom .f] [.t bbox .f]
     frame .f2 -width 150 -height 30 -bd 2 -relief raised
     pack .f2 -before .t
-    update
+    updateText
     lappend result [winfo geom .f] [.t bbox .f]
 } -cleanup {
     destroy .f .f2
 } -result [list \
     30x20+[expr {$padx+6*$fixedWidth}]+$pady \
@@ -1371,13 +1377,13 @@
     .t delete 1.0 end
 } -body {
     .t configure -wrap none
     .t insert 1.0 "Some sample text"
     .t window create 1.6
-    update
+    updateText
     pack forget .t
-    update
+    updateText
 } -cleanup {
     pack .t
 } -result {}
 
 test textWind-16.4 {EmbWinTextStructureProc procedure} -setup {
@@ -1386,13 +1392,13 @@
     .t configure -spacing1 0 -spacing2 0 -spacing3 0 \
         -wrap none
     .t insert 1.0 "Some sample text"
     frame .t.f -width 30 -height 20 -bg $color
     .t window create 1.6 -window .t.f
-    update
+    updateText
     pack forget .t
-    update
+    updateText
     list [winfo ismapped .t.f] [.t bbox .t.f]
 } -cleanup {
     pack .t
 } -result [list 1 [list [expr {$padx+6*$fixedWidth}] $pady 30 20]]
 
@@ -1404,11 +1410,11 @@
     .t insert end "Line 1"
     frame .f -width 20 -height 10 -bg blue
     .t window create 1.3 -window .f
     toplevel .tt
     pack [.t peer create .tt.t]
-    update ; update
+    updateText
     destroy .t .tt
     winfo exists .f
 } -result 0
 
 test textWind-17.2 {peer widgets and embedded windows} -setup {
@@ -1418,14 +1424,14 @@
     .t insert end "Line 1\nLine 2"
     frame .f -width 20 -height 10 -bg blue
     .t window create 1.4 -window .f
     toplevel .tt
     pack [.t peer create .tt.t]
-    update ; update
+    updateText
     destroy .t
     .tt.t insert 1.0 "foo"
-    update
+    updateText
     destroy .tt
 } -result {}
 
 test textWind-17.3 {peer widget and -create} -setup {
     destroy .t .tt
@@ -1433,13 +1439,13 @@
     pack [text .t]
     .t delete 1.0 end
     .t insert 1.0 "Some sample text"
     toplevel .tt
     pack [.t peer create .tt.t]
-    update ; update
+    updateText
     .t window create 1.2 -create {frame %W.f -width 10 -height 20 -bg blue}
-    update
+    updateText
     destroy .t .tt
 } -result {}
 
 test textWind-17.4 {peer widget deleted one window shouldn't delete others} -setup {
     destroy .t .tt
@@ -1449,14 +1455,14 @@
     .t delete 1.0 end
     .t insert 1.0 "Some sample text"
     toplevel .tt
     pack [.t peer create .tt.t]
     .t window create 1.2 -create {frame %W.f -width 10 -height 20 -bg blue}
-    update ; update
+    updateText
     destroy .tt
     lappend res [.t get 1.2]
-    update
+    updateText
     lappend res [.t get 1.2]
 } -cleanup {
     destroy .t
 } -result {{} {}}
 
@@ -1467,11 +1473,11 @@
     .t delete 1.0 end
     .t insert 1.0 "Some sample text"
     toplevel .tt
     pack [.t peer create .tt.t]
     .t window create 1.2 -create {frame %W.f -width 10 -height 20 -bg blue}
-    update ; update
+    updateText
     list [.t window cget 1.2 -window] [.tt.t window cget 1.2 -window]
 } -cleanup {
     destroy .tt .t
 } -result {.t.f .tt.t.f}
 
@@ -1482,11 +1488,11 @@
     .t delete 1.0 end
     .t insert 1.0 "Some sample text"
     toplevel .tt
     pack [.t peer create .tt.t]
     .t window create 1.2 -create {frame %W.f -width 10 -height 20 -bg blue}
-    update ; update
+    updateText
     list [.t window configure 1.2 -window] \
         [.tt.t window configure 1.2 -window]
 } -cleanup {
     destroy .tt .t
 }  -result {{-window {} {} {} .t.f} {-window {} {} {} .tt.t.f}}
@@ -1498,11 +1504,11 @@
     .t delete 1.0 end
     .t insert 1.0 "Some sample text"
     toplevel .tt
     pack [.t peer create .tt.t]
     .t window create 1.2 -window [frame .t.f -width 10 -height 20 -bg blue]
-    update ; update
+    updateText
     list [.t window cget 1.2 -window] [.tt.t window cget 1.2 -window]
 } -cleanup {
     destroy .tt .t
 }  -result {.t.f {}}
 
@@ -1513,11 +1519,11 @@
     .t delete 1.0 end
     .t insert 1.0 "Some sample text"
     toplevel .tt
     pack [.t peer create .tt.t]
     .t window create 1.2 -window [frame .t.f -width 10 -height 20 -bg blue]
-    update ; update
+    updateText
     list [.t window configure 1.2 -window] \
         [.tt.t window configure 1.2 -window]
 } -cleanup {
     destroy .tt .t
 }  -result {{-window {} {} {} .t.f} {-window {} {} {} {}}}
@@ -1529,58 +1535,121 @@
     .t delete 1.0 end
     .t insert 1.0 "Some sample text"
     toplevel .tt
     pack [.t peer create .tt.t]
     .t window create 1.2 -window [frame .t.f -width 10 -height 20 -bg blue]
-    update ; update
+    updateText
     .tt.t window configure 1.2 -window [frame .tt.t.f -width 10 -height 20 -bg red]
     list [.t window configure 1.2 -window] [.tt.t window configure 1.2 -window]
 } -cleanup {
     destroy .tt .t
 }  -result {{-window {} {} {} .t.f} {-window {} {} {} .tt.t.f}}
 
 test textWind-17.10 {peer widget window configuration} -setup {
     destroy .t .tt
 } -body {
+    set res {}
     pack [text .t]
     .t delete 1.0 end
     .t insert 1.0 "Some sample text"
     toplevel .tt
     pack [.t peer create .tt.t]
+    updateText
     .t window create 1.2 -window [frame .t.f -width 10 -height 20 -bg blue]
-    .tt.t window create 1.2 -window [frame .tt.t.f -width 25 -height 20 -bg blue]
-    update ; update
-    .t window configure 1.2 -create \
-      {destroy %W.f ; frame %W.f -width 50 -height 7 -bg red}
-    .tt.t window configure 1.2 -window {}
+    updateText
+    # There is a blue window in the main widget .t but not in the peer .tt.t
+    lappend res [.t window cget 1.2 -window]
+    lappend res [.tt.t window cget 1.2 -window]
+    # Insert a green window in the peer. Warning: the blue window previously
+    # inserted in .t at index 1.2 will now be found in .t at index 1.3
+    # The underlying linked segments are common in a text widget and its peers.
+    .tt.t window create 1.2 -window [frame .tt.t.f -width 25 -height 20 -bg green]
+    updateText
+    lappend res [.t window cget 1.2 -window]
+    lappend res [.t window cget 1.3 -window]
+    # In the peer, the green window still is at 1.2, and there is no window at 1.3
+    lappend res [.tt.t window cget 1.2 -window]
+    lappend res [.tt.t window cget 1.3 -window]
+    # Insert a red window in .t at index 1.2. This replaces the blue window originally at 1.2
+    # in .t, because the green window inserted in the peer is not visible from .t, therefore
+    # the embedded window found at index 1.2 in .t is the one originally at 1.2 in .t, i.e.
+    # the blue one
+    .t window configure 1.2 -create {destroy %W.f ; update ; frame %W.f -width 50 -height 7 -bg red}
+    updateText
+    # The main widget .t still has a window named .t.f at 1.2. This is NOT the blue
+    # frame but the red frame from the -create script, which bears the same name.
+    lappend res [.t window cget 1.2 -window]
+    # The peer still has its green .tt.t.f at 1.2
+    lappend res [.tt.t window cget 1.2 -window]
+    # When removing the -window option the create script plays, therefore .t still has
+    # the red frame .t.f at 1.2
     .t window configure 1.2 -window {}
-    set res [list [.t window configure 1.2 -window] \
-        [.tt.t window configure 1.2 -window]]
-    update
-    lappend res [.t window configure 1.2 -window] \
-        [.tt.t window configure 1.2 -window]
+    updateText
+    lappend res [.t window cget 1.2 -window]
+    # The -create script associated to index 1.2 applies to all peers (that's the reason
+    # why the manual states that "If multiple peer widgets are in use, it is usually simpler
+    # to use the -create option if embedded windows are desired in each peer."). Therefore
+    # when removing the -window option in the peer, the -create script is run, which replaces
+    # the green frame by the red one named as per the -create script, i.e. .tt.t.f
+    .tt.t window configure 1.2 -window {}
+    updateText
+    lappend res [.tt.t window cget 1.2 -window]
 } -cleanup {
     destroy .tt .t
-}  -result {{-window {} {} {} {}} {-window {} {} {} {}} {-window {} {} {} .t.f} {-window {} {} {} .tt.t.f}}
+}  -result {.t.f {} {} .t.f .tt.t.f {} .t.f .tt.t.f .t.f .tt.t.f}
 
 test textWind-18.1 {embedded window deletion triggered by a script bound to <Map>} -setup {
     catch {destroy .t .f .f2}
 } -body {
     pack [text .t]
     for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"}
     .t window create end -window [frame .f -background red -width 80 -height 80]
     .t window create end -window [frame .f2 -background blue -width 80 -height 80]
     bind .f <Map> {.t delete .f}
-    update
+    updateText
     # this shall not crash (bug 1501749)
     after 100 {.t yview end}
     tkwait visibility .f2
-    update
+    after 200
+    updateText
 } -cleanup {
     destroy .t .f .f2
 } -result {}
+
+test textWind-18.2 {text widget deletion triggered by a script bound to embedded window mapping} -setup {
+    catch {destroy .t .f}
+} -body {
+    pack [text .t]
+    for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"}
+    .t window create end -window [frame .f -background red -width 80 -height 80]
+    bind .f <Map> {destroy .t}
+    updateText
+    # this shall not crash (bug 1501749)
+    after 100 {.t yview end}
+    tkwait window .t
+} -cleanup {
+    destroy .t .f
+} -result {}
+
+test textWind-18.3 {embedded window destruction in cascade} -setup {
+    catch {destroy .t .f}
+    set x 0
+} -body {
+    pack [text .t]
+    button .t.b1
+    .t window create 1.0 -window .t.b1
+    bind .t.b1 <Destroy> {destroy .t.b2 ; set x 1}
+    button .t.b2
+    .t window create 2.0 -window .t.b2
+    updateText
+    # this shall not crash (bug 54fe7a5e71)
+    after 100 {.t delete 1.0 end}
+    tkwait variable x
+} -cleanup {
+    destroy .t .f
+} -result {}
 
 option clear
 
 # cleanup
 cleanupTests
 return

Index: tests/tk.test
==================================================================
--- tests/tk.test
+++ tests/tk.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test the tk command.
 # It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # Copyright © 2002 ActiveState Corporation.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
@@ -15,11 +15,11 @@
 test tk-1.1 {tk command: general} -body {
     tk
 } -returnCodes error -result {wrong # args: should be "tk subcommand ?arg ...?"}
 test tk-1.2 {tk command: general} -body {
     tk xyz
-} -returnCodes error -result {unknown or ambiguous subcommand "xyz": must be appname, busy, caret, fontchooser, inactive, scaling, useinputmethods, or windowingsystem}
+} -returnCodes error -result {unknown or ambiguous subcommand "xyz": must be appname, busy, caret, fontchooser, inactive, print, scaling, sysnotify, systray, useinputmethods, or windowingsystem}
 
 # Value stored to restore default settings after 2.* tests
 set appname [tk appname]
 test tk-2.1 {tk command: appname} -body {
     tk appname xyz abc
@@ -157,11 +157,11 @@
 test tk-6.5 {tk inactive} -body {
     tk inactive reset
     update
     after 100
     set i [tk inactive]
-    expr {$i < 0 || ( $i > 90 && $i < 200 )}
+    expr {$i < 0 || ( $i > 90 && $i < 300 )}
 } -result 1
 
 test tk-7.1 {tk inactive in a safe interpreter} -body {
 # tk inactive in safe interpreters
     safe::interpCreate foo

Index: tests/ttk/all.tcl
==================================================================
--- tests/ttk/all.tcl
+++ tests/ttk/all.tcl
@@ -2,16 +2,16 @@
 #
 # This file contains a top-level script to run all of the ttk
 # tests.  Execute it by invoking "source all.tcl" when running tktest
 # in this directory.
 #
-# Copyright © 2007 by the Tk developers.
+# Copyright © 2007 the Tk developers.
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
-package require Tk ;# This is the Tk test suite; fail early if no Tk!
+package require tk ;# This is the Tk test suite; fail early if no Tk!
 package require tcltest 2.2
 tcltest::configure {*}$argv
 tcltest::configure -testdir [file normalize [file dirname [info script]]]
 tcltest::configure -loadfile \
     [file join [file dirname [tcltest::testsDirectory]] constraints.tcl]

Index: tests/ttk/checkbutton.test
==================================================================
--- tests/ttk/checkbutton.test
+++ tests/ttk/checkbutton.test
@@ -1,10 +1,10 @@
 #
 # ttk::checkbutton widget tests.
 #
 
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 test checkbutton-1.1 "Checkbutton check" -body {
@@ -69,6 +69,20 @@
     .cbev invoke
 } -cleanup {
     destroy .cbev
 } -result {}
 
+test checkbutton-2.1 "style command" -body {
+    ttk::checkbutton .w
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {{} TCheckbutton TCheckbutton}
+test checkbutton-2.2 "style command" -body {
+    ttk::style configure customStyle.TCheckbutton
+    ttk::checkbutton .w -style customStyle.TCheckbutton
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {customStyle.TCheckbutton customStyle.TCheckbutton TCheckbutton}
+
 tcltest::cleanupTests

Index: tests/ttk/combobox.test
==================================================================
--- tests/ttk/combobox.test
+++ tests/ttk/combobox.test
@@ -1,10 +1,10 @@
 #
 # ttk::combobox widget tests
 #
 
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 test combobox-1.0 "Combobox tests -- setup" -body {
@@ -19,12 +19,12 @@
     destroy .cb
 }
 
 test combobox-2.0 "current command" -body {
     ttk::combobox .cb -values [list a b c d e a]
-    .cb current
-} -result -1
+    expr {[.cb current]<0}
+} -result 1
 
 test combobox-2.1 "current -- set index" -body {
     .cb current 5
     .cb get
 } -result a
@@ -39,12 +39,12 @@
     .cb current
 } -result 1
 
 test combobox-2.4 "current -- value not in list" -body {
     .cb set "z"
-    .cb current
-} -result -1
+    expr {[.cb current]<0}
+} -result 1
 
 test combobox-2.5 "current -- set to end index" -body {
     .cb configure -values [list a b c d e thelastone]
     .cb current end
     .cb get
@@ -51,30 +51,48 @@
 } -result thelastone
 
 test combobox-2.6 "current -- set to unknown index" -body {
     .cb configure -values [list a b c d e]
     .cb current notanindex
-} -returnCodes error -result {Incorrect index notanindex}
+} -returnCodes error -result {bad index "notanindex"}
+
+test combobox-2.7 {current -- set to 0 index when empty [bug 924835c36d]} -body {
+    .cb configure -values {}
+    .cb current 0
+} -returnCodes error -result {index "0" out of range}
+
+test combobox-2.8 "current -- set to end index in an empty combobox" -body {
+    .cb configure -values {}
+    .cb current end
+} -returnCodes error -result {index "end" out of range}
 
 test combobox-2.end "Cleanup" -body { destroy .cb }
 
 test combobox-3 "Read postoffset value dynamically from current style" -body {
     ttk::combobox .cb -values [list a b c] -style "DerivedStyle.TCombobox"
     pack .cb -expand true -fill both
+    update idletasks
     ttk::style configure DerivedStyle.TCombobox -postoffset [list 25 0 0 0]
+    if {[tk windowingsystem] == "aqua"} {
+	after 500 {
+	    pressbutton [expr {[winfo rootx .cb] + 25}] [expr {[winfo rooty .cb] + 25}]
+	}
+    }
     ttk::combobox::Post .cb
     expr {[winfo rootx .cb.popdown] - [winfo rootx .cb]}
 } -result 25 -cleanup {
     destroy .cb
 }
 
-test combobox-1890211 "ComboboxSelected event after listbox unposted" -body {
+test combobox-1890211 "ComboboxSelected event after listbox unposted" \
+    -constraints {notAqua} -body {
     # whitebox test...
     pack [ttk::combobox .cb -values [list a b c]]
+    update idletasks
     set result [list]
     bind .cb <<ComboboxSelected>> {
-    	lappend result Event [winfo ismapped .cb.popdown] [.cb get]
+	lappend result Event [winfo ismapped .cb.popdown] [.cb get]
     }
     lappend result Start 0 [.cb get]
     ttk::combobox::Post .cb
     lappend result Post [winfo ismapped .cb.popdown] [.cb get]
     .cb.popdown.f.l selection clear 0 end; .cb.popdown.f.l selection set 1
@@ -84,6 +102,20 @@
     set result
 } -result [list Start 0 {} Post 1 {} Select 0 b Event 0 b] -cleanup {
     destroy .cb
 }
 
+test combobox-4.1 "style command" -body {
+    ttk::combobox .w
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {{} TCombobox TCombobox}
+test combobox-4.2 "style command" -body {
+    ttk::style configure customStyle.TCombobox
+    ttk::combobox .w -style customStyle.TCombobox
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {customStyle.TCombobox customStyle.TCombobox TCombobox}
+
 tcltest::cleanupTests

Index: tests/ttk/entry.test
==================================================================
--- tests/ttk/entry.test
+++ tests/ttk/entry.test
@@ -1,15 +1,16 @@
 #
 # Tile package: entry widget tests
 #
 
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
+testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 variable scrollInfo
 proc scroll args {
     global scrollInfo
     set scrollInfo $args
@@ -63,32 +64,38 @@
     .e insert end abcde
     .e icursor 3
     .e delete 0 end
     .e index insert
 } -result 0
+
+test entry-1.8 "Index is between 0 and end" -constraints deprecated -body {
+    .e delete 0 end
+    .e insert end abcde
+    set res [list [.e index -1] [.e index -4] [.e index 999]]
+} -result {0 0 5}
 
 test entry-1.done "Cleanup" -body { destroy .e }
 
 # Scrollbar tests.
 
 test entry-2.1 "Create entry before scrollbar" -body {
     pack [ttk::entry .te -xscrollcommand [list .tsb set]] \
 	-expand true -fill both
     pack [ttk::scrollbar .tsb -orient horizontal -command [list .te xview]] \
-    	-expand false -fill x
+	-expand false -fill x
 }  -cleanup {destroy .te .tsb}
 
-test entry-2.1.1 "Create entry before scrollbar - scrollbar catches up" -constraints failsOnUbuntu -body {
+test entry-2.1.1 "Create entry before scrollbar - scrollbar catches up" -constraints {failsOnUbuntu failsOnXQuarz} -body {
     pack [ttk::entry .te -xscrollcommand [list .tsb set]] \
 	-expand true -fill both
     .te insert end [string repeat "abc" 50]
     catch {update} ; # error triggers because the -xscrollcommand callback
                      # errors out: invalid command name ".tsb"
     pack [ttk::scrollbar .tsb -orient horizontal -command [list .te xview]] \
-    	-expand false -fill x
+	-expand false -fill x
     update ; # no error
-    lappend res [expr [lindex [.tsb get] 1] < 1] ; # scrollbar did update
+    set res [expr [lindex [.tsb get] 1] < 1] ; # scrollbar did update
 } -result 1 -cleanup {destroy .te .tsb}
 
 test entry-2.2 "Initial scroll position" -body {
     ttk::entry .e -font fixed -width 5 -xscrollcommand scroll
     .e insert end "0123456789"
@@ -307,11 +314,11 @@
 # For 8.2a, -result {} would also be sensible.
 
 test entry-9.1 "Index range invariants" -setup {
     # See bug#1721532 for discussion
     proc entry-9.1-trace {n1 n2 op} {
-    	set ::V NO!
+	set ::V NO!
     }
     variable V
     trace add variable V write entry-9.1-trace
     ttk::entry .e -textvariable V
 } -body {
@@ -367,6 +374,20 @@
     lappend res [.e state]
 } -result {invalid invalid} -cleanup {
     destroy .e
 }
 
+test entry-12.1 "style command" -body {
+    ttk::entry .w
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {{} TEntry TEntry}
+test entry-12.2 "style command" -body {
+    ttk::style configure customStyle.TEntry
+    ttk::entry .w -style customStyle.TEntry
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {customStyle.TEntry customStyle.TEntry TEntry}
+
 tcltest::cleanupTests

Index: tests/ttk/image.test
==================================================================
--- tests/ttk/image.test
+++ tests/ttk/image.test
@@ -1,6 +1,6 @@
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 test image-1.1 "Bad image element" -body {

Index: tests/ttk/labelframe.test
==================================================================
--- tests/ttk/labelframe.test
+++ tests/ttk/labelframe.test
@@ -1,6 +1,6 @@
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 test labelframe-1.0 "Setup" -body {
@@ -94,18 +94,18 @@
 } -result [list 1 labelframe]
 
 test labelframe-4.4 "Re-manage nonchild content" -body {
     pack .cb -side right
     list [update; winfo viewable .cb] \
-    	[winfo manager .cb] \
+	[winfo manager .cb] \
 	[.lf cget -labelwidget]
 } -result [list 1 pack {}]
 
 test labelframe-4.5 "Re-add nonchild content" -body {
     .lf configure -labelwidget .cb
     list [update; winfo viewable .cb] \
-    	[winfo manager .cb] \
+	[winfo manager .cb] \
 	[.lf cget -labelwidget]
 } -result [list 1 labelframe .cb]
 
 test labelframe-4.6 "Destroy nonchild content" -body {
     destroy .cb
@@ -126,6 +126,20 @@
     winfo children .t
 } -cleanup {
     destroy .t
 } -result [list .t.x1 .t.lf .t.lb .t.x2]
 
+test labelframe-7.1 "style command" -body {
+    ttk::labelframe .w
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {{} TLabelframe TLabelframe}
+test labelframe-7.2 "style command" -body {
+    ttk::style configure customStyle.TLabelframe
+    ttk::labelframe .w -style customStyle.TLabelframe
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {customStyle.TLabelframe customStyle.TLabelframe TLabelframe}
+
 tcltest::cleanupTests

Index: tests/ttk/layout.test
==================================================================
--- tests/ttk/layout.test
+++ tests/ttk/layout.test
@@ -1,6 +1,6 @@
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 test layout-1.1 "Size computations for mixed-orientation layouts" -body {

Index: tests/ttk/notebook.test
==================================================================
--- tests/ttk/notebook.test
+++ tests/ttk/notebook.test
@@ -1,6 +1,6 @@
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 test notebook-1.0 "Setup" -body {
@@ -65,14 +65,15 @@
     .nb tab .nb.foo -text "Changed Foo"
     .nb tab .nb.foo -text
 } -result "Changed Foo"
 
 test notebook-2.5 "tab - get all options" -body {
+    .nb tab .nb.foo -underline 0
     .nb tab .nb.foo
 } -result [list \
     -padding 0 -sticky nsew \
-    -state normal -text "Changed Foo" -image "" -compound {} -underline -1]
+    -state normal -text "Changed Foo" -image "" -compound {} -underline 0]
 
 test notebook-4.1 "Test .nb index end" -body {
     .nb index end
 } -result 2
 
@@ -395,11 +396,11 @@
 } -result 4
 
 test notebook-7.8a "move tabs - current tab undisturbed - exhaustive" -body {
     .nb select .nb.f0
     foreach i {0 1 2 3 4} {
-    	.nb insert $i .nb.f$i
+	.nb insert $i .nb.f$i
     }
 
     foreach i {0 1 2 3 4} {
 	.nb select .nb.f$i
 	foreach j {0 1 2 3 4} {
@@ -452,11 +453,11 @@
 test notebook-1817596-2 "error in insert should have no effect" -body {
     pack [ttk::notebook .nb]
     .nb insert end [ttk::label .nb.l1]
     .nb insert end [ttk::label .nb.l2]
     list \
-    	[catch { .nb insert .l2 0 -badoption badvalue } err] \
+	[catch { .nb insert .l2 0 -badoption badvalue } err] \
 	[.nb tabs] \
 } -result [list 1 [list .nb.l1 .nb.l2]] -cleanup { destroy .nb }
 
 test notebook-1817596-3 "insert/configure" -body {
     pack [ttk::notebook .nb]
@@ -510,6 +511,20 @@
     destroy .nb
     update
     set ::history
 } -result [list DESTROY .nb.frame1 DESTROY .nb.frame2 DESTROY .nb.frame3]
 
+test notebook-8.1 "style command" -body {
+    ttk::notebook .w
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {{} TNotebook TNotebook}
+test notebook-8.2 "style command" -body {
+    ttk::style configure customStyle.TNotebook
+    ttk::notebook .w -style customStyle.TNotebook
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {customStyle.TNotebook customStyle.TNotebook TNotebook}
+
 tcltest::cleanupTests

Index: tests/ttk/panedwindow.test
==================================================================
--- tests/ttk/panedwindow.test
+++ tests/ttk/panedwindow.test
@@ -1,6 +1,6 @@
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 proc propagate-geometry {} { update idletasks }
@@ -154,11 +154,11 @@
 #
 proc checkorder {winlist} {
     set pos -1
     set positions [list]
     foreach win $winlist {
-    	lappend positions [set nextpos [winfo y $win]]
+	lappend positions [set nextpos [winfo y $win]]
 	if {$nextpos <= $pos} {
 	    error "window $win out of order ($positions)"
 	}
 	set pos $nextpos
     }
@@ -201,11 +201,11 @@
 #
 proc sashpositions {pw} {
     set positions [list]
     set npanes [llength [winfo children $pw]]
     for {set i 0} {$i < $npanes - 1} {incr i} {
-    	lappend positions [$pw sashpos $i]
+	lappend positions [$pw sashpos $i]
     }
     return $positions
 }
 
 test paned-sashpos-setup "Setup for sash position test" -body {
@@ -287,6 +287,24 @@
     list [winfo reqwidth .pw] [winfo reqheight .pw] [.pw sashpos 0]
 } -result [list 100 155 100]
 
 test paned-propagation-cleanup "Clean up." -body { destroy .pw }
 
+test panedwindow-6.1 "style command" -body {
+    # Contrary to ttk::scrollbar, ttk::progressbar and ttk::scale,
+    # ttk::panedwindow has same style TPanedwindow whatever -orient is
+    ttk::panedwindow .wv  ; # default is  -orient vertical
+    ttk::panedwindow .wh -orient horizontal
+    list [.wv cget -style] [.wv style] [winfo class .wv]\
+         [.wh cget -style] [.wh style] [winfo class .wh]
+} -cleanup {
+    destroy .wv .wh
+} -result {{} TPanedwindow TPanedwindow {} TPanedwindow TPanedwindow}
+test panedwindow-6.2 "style command" -body {
+    ttk::style configure customStyle.TPanedwindow
+    ttk::panedwindow .w -style customStyle.TPanedwindow
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {customStyle.TPanedwindow customStyle.TPanedwindow TPanedwindow}
+
 tcltest::cleanupTests

Index: tests/ttk/progressbar.test
==================================================================
--- tests/ttk/progressbar.test
+++ tests/ttk/progressbar.test
@@ -1,6 +1,6 @@
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 
@@ -120,6 +120,22 @@
 } -cleanup {
     unset res thefont
     destroy .p
 } -result {{-anchor e} {-foreground green} {-justify center} {-text {Cannot be seen}} {-wraplength 250}}
 
+test progressbar-4.1 "style command" -body {
+    ttk::progressbar .wh  ; # default is  -orient horizontal
+    ttk::progressbar .wv -orient vertical
+    list [.wh cget -style] [.wh style] [winfo class .wh]\
+         [.wv cget -style] [.wv style] [winfo class .wv]
+} -cleanup {
+    destroy .wh .wv
+} -result {{} Horizontal.TProgressbar TProgressbar {} Vertical.TProgressbar TProgressbar}
+test progressbar-4.2 "style command" -body {
+    ttk::style configure customStyle.Vertical.TProgressbar
+    ttk::progressbar .w -orient vertical -style customStyle.Vertical.TProgressbar
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {customStyle.Vertical.TProgressbar Vertical.customStyle.Vertical.TProgressbar TProgressbar}
+
 tcltest::cleanupTests

Index: tests/ttk/radiobutton.test
==================================================================
--- tests/ttk/radiobutton.test
+++ tests/ttk/radiobutton.test
@@ -1,17 +1,17 @@
 #
 # ttk::radiobutton widget tests.
 #
 
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 test radiobutton-1.1 "Radiobutton check" -body {
     pack \
-    	[ttk::radiobutton .rb1 -text "One" -variable choice -value 1] \
+	[ttk::radiobutton .rb1 -text "One" -variable choice -value 1] \
 	[ttk::radiobutton .rb2 -text "Two" -variable choice -value 2] \
 	[ttk::radiobutton .rb3 -text "Three" -variable choice -value 3] \
 	;
 }
 test radiobutton-1.2 "Radiobutton invoke" -body {
@@ -44,6 +44,20 @@
 test radiobutton-1.8 "Reset radiobutton variable" -body {
     set ::choice 2
     list [info exists ::choice] [.rb1 instate alternate] [.rb2 instate alternate]
 } -result {1 0 0}
 
+test radiobutton-2.1 "style command" -body {
+    ttk::radiobutton .w
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {{} TRadiobutton TRadiobutton}
+test radiobutton-2.2 "style command" -body {
+    ttk::style configure customStyle.TRadiobutton
+    ttk::radiobutton .w -style customStyle.TRadiobutton
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {customStyle.TRadiobutton customStyle.TRadiobutton TRadiobutton}
+
 tcltest::cleanupTests

ADDED   tests/ttk/scale.test
Index: tests/ttk/scale.test
==================================================================
--- /dev/null
+++ tests/ttk/scale.test
@@ -0,0 +1,53 @@
+package require tk
+package require tcltest 2.2
+namespace import -force tcltest::*
+loadTestedCommands
+
+test scale-1.0 "Self-destruction" -body {
+    trace variable v w { destroy .s ;# }
+    ttk::scale .s -variable v
+    pack .s ; update
+    .s set 1 ; update
+} -returnCodes error -match glob -result "*"
+
+test scale-2.1 "-state option" -setup {
+    ttk::scale .s
+    set res ""
+} -body {
+    # defaults
+    lappend res [.s instate disabled] [.s cget -state]
+    # set -state: instate returns accordingly
+    .s configure -state disabled
+    lappend res [.s instate disabled] [.s cget -state]
+    # back to normal
+    .s configure -state normal
+    lappend res [.s instate disabled] [.s cget -state]
+    # use state command: -state does NOT reflect it
+    .s state disabled
+    lappend res [.s instate disabled] [.s cget -state]
+    # further use state command
+    .s state readonly
+    lappend res [.s state] [.s cget -state]
+} -cleanup {
+    destroy .s
+    unset -nocomplain res
+} -result {0 normal 1 disabled 0 normal 1 normal {disabled readonly} normal}
+
+test scale-3.1 "style command" -body {
+    ttk::scale .wh  ; # default is  -orient horizontal
+    ttk::scale .wv -orient vertical
+    list [.wh cget -style] [.wh style] [winfo class .wh] \
+         [.wv cget -style] [.wv style] [winfo class .wv]
+} -cleanup {
+    destroy .wh .wv
+} -result {{} Horizontal.TScale TScale {} Vertical.TScale TScale}
+test scale-3.2 "style command" -body {
+    ttk::style configure customStyle.Vertical.TScale
+    ttk::scale .w -orient vertical -style customStyle.Vertical.TScale
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {customStyle.Vertical.TScale Vertical.customStyle.Vertical.TScale TScale}
+
+tcltest::cleanupTests
+

Index: tests/ttk/scrollbar.test
==================================================================
--- tests/ttk/scrollbar.test
+++ tests/ttk/scrollbar.test
@@ -1,6 +1,6 @@
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 testConstraint coreScrollbar [expr {[tk windowingsystem] eq "aqua"}]
@@ -26,11 +26,11 @@
 test scrollbar-swapout-2 "... regardless of whether -style ..." \
 -constraints {
     coreScrollbar
 } -body {
     ttk::style layout Vertical.Custom.TScrollbar \
-    	[ttk::style layout Vertical.TScrollbar] ; # See #1833339
+	[ttk::style layout Vertical.TScrollbar] ; # See #1833339
     ttk::scrollbar .sb -command "yadda" -style Custom.TScrollbar
     list [winfo class .sb] [.sb cget -command] [.sb cget -style]
 } -result [list TScrollbar yadda Custom.TScrollbar] -cleanup {
     destroy .sb
 }
@@ -82,11 +82,11 @@
     event generate .s <MouseWheel> -delta -120
     after 200 {set eventprocessed 1} ; vwait eventprocessed
     .t index @0,0
 } -cleanup {
     destroy .t .s
-} -result {5.0}
+} -result {4.0}
 
 test scrollbar-10.2.1 {<Shift-MouseWheel> event on horizontal scrollbar} -setup {
     destroy .t .s
 } -body {
     pack [text .t -xscrollcommand {.s set} -wrap none] -side top
@@ -97,11 +97,11 @@
     event generate .s <Shift-MouseWheel> -delta -120
     after 200 {set eventprocessed 1} ; vwait eventprocessed
     .t index @0,0
 } -cleanup {
     destroy .t .s
-} -result {1.4}
+} -result {1.3}
 test scrollbar-10.2.2 {<MouseWheel> event on horizontal scrollbar} -setup {
     destroy .t .s
 } -body {
     pack [text .t -xscrollcommand {.s set} -wrap none] -side top
     for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "}
@@ -111,43 +111,25 @@
     event generate .s <MouseWheel> -delta -120
     after 200 {set eventprocessed 1} ; vwait eventprocessed
     .t index @0,0
 } -cleanup {
     destroy .t .s
-} -result {1.4}
-
-#
-# Scale tests:
-#
-
-test scale-1.0 "Self-destruction" -body {
-    trace variable v w { destroy .s ;# }
-    ttk::scale .s -variable v
-    pack .s ; update
-    .s set 1 ; update
-} -returnCodes error -match glob -result "*"
-
-test scale-2.1 "-state option" -setup {
-    ttk::scale .s
-    set res ""
-} -body {
-    # defaults
-    lappend res [.s instate disabled] [.s cget -state]
-    # set -state: instate returns accordingly
-    .s configure -state disabled
-    lappend res [.s instate disabled] [.s cget -state]
-    # back to normal
-    .s configure -state normal
-    lappend res [.s instate disabled] [.s cget -state]
-    # use state command: -state does NOT reflect it
-    .s state disabled
-    lappend res [.s instate disabled] [.s cget -state]
-    # further use state command
-    .s state readonly
-    lappend res [.s state] [.s cget -state]
-} -cleanup {
-    destroy .s
-    unset -nocomplain res
-} -result {0 normal 1 disabled 0 normal 1 normal {disabled readonly} normal}
+} -result {1.3}
+
+test scrollbar-11.1 "style command" -body {
+    ttk::scrollbar .wv  ; # default is  -orient vertical
+    ttk::scrollbar .wh -orient horizontal
+    list [.wv cget -style] [.wv style] [winfo class .wv] \
+         [.wh cget -style] [.wh style] [winfo class .wh]
+} -cleanup {
+    destroy .wv .wh
+} -result {{} Vertical.TScrollbar TScrollbar {} Horizontal.TScrollbar TScrollbar}
+test scrollbar-11.2 "style command" -body {
+    ttk::style configure customStyle.Horizontal.TScrollbar
+    ttk::scrollbar .w -orient horizontal -style customStyle.Horizontal.TScrollbar
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {customStyle.Horizontal.TScrollbar Horizontal.customStyle.Horizontal.TScrollbar TScrollbar}
 
 tcltest::cleanupTests
 

Index: tests/ttk/spinbox.test
==================================================================
--- tests/ttk/spinbox.test
+++ tests/ttk/spinbox.test
@@ -1,10 +1,10 @@
 #
 # ttk::spinbox widget tests
 #
 
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 test spinbox-1.0 "Spinbox tests -- setup" -body {
@@ -136,18 +136,22 @@
 } -cleanup {
     destroy .sb
 } -returnCodes error -result {bad validate "bogus": must be all, key, focus, focusin, focusout, or none}
 
 test spinbox-1.8.4 "-validate option: " -setup {
-    set ::spinbox_test {}
     ttk::spinbox .sb -from 0 -to 100
+    set ::spinbox_test {}
 } -body {
-    .sb configure -validate all -validatecommand {lappend ::spinbox_test %P}
+    .sb configure -validate all -validatecommand {set ::spinbox_test %P}
     pack .sb
+    update idletasks
     .sb set 50
     focus -force .sb
-    after 500 {set ::spinbox_wait 1} ; vwait ::spinbox_wait
+    set ::spinbox_wait 0
+    set timer [after 100 {set ::spinbox_wait 1}]
+    vwait ::spinbox_wait
+    after cancel $timer
     set ::spinbox_test
 } -cleanup {
     destroy .sb
 } -result 50
 
@@ -356,10 +360,24 @@
     event generate .sb <<Decrement>> ; lappend result [.sb get]
 } -result [list asdfasdf 000 asdfasdf 000] -cleanup {
     destroy .sb
 }
 
+test spinbox-5.1 "style command" -body {
+    ttk::spinbox .w
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {{} TSpinbox TSpinbox}
+test spinbox-5.2 "style command" -body {
+    ttk::style configure customStyle.TSpinbox
+    ttk::spinbox .w -style customStyle.TSpinbox
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {customStyle.TSpinbox customStyle.TSpinbox TSpinbox}
+
 tcltest::cleanupTests
 
 # Local variables:
 # mode: tcl
 # End:

Index: tests/ttk/treetags.test
==================================================================
--- tests/ttk/treetags.test
+++ tests/ttk/treetags.test
@@ -1,7 +1,7 @@
 
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 ### treeview tag invariants:
@@ -36,11 +36,11 @@
 }
 #
 ###
 
 test treetags-1.0 "Setup" -body {
-    set tv [ttk::treeview .tv]
+    set tv [ttk::treeview .tv -columns "A B C"]
     .tv insert {} end -id item1 -text "Item 1"
     pack .tv
 } -cleanup {
     treeConstraints $tv
 }
@@ -60,11 +60,11 @@
 
 test treetags-1.3 "tag has - test" -body {
     $tv insert {} end -id item2 -text "Item 2" -tags tag2
     set result [list]
     foreach item {item1 item2} {
-    	foreach tag {tag1 tag2 tag3} {
+	foreach tag {tag1 tag2 tag3} {
 	    lappend result $item $tag [$tv tag has $tag $item]
 	}
     }
     set result
 } -cleanup {
@@ -189,12 +189,64 @@
 test treetags-3.2 "tag configure - enumerate" -body {
     $tv tag configure tag1
 } -cleanup {
     treeConstraints $tv
 } -result [list \
-    -text {} -image {} -anchor {} -background red -foreground blue -font {} \
-]
+    -image {} -imageanchor {} -background red -stripedbackground {} -foreground blue -font {} -padding {} \
+                  ]
+test treetags-4.1 "tag cell add" -body {
+    $tv tag cell add _thetag
+} -returnCodes 1 -result {wrong # args: should be ".tv tag cell add tagName cells"}
+
+test treetags-4.2 "tag cell remove" -body {
+    $tv tag cell remove _thetag
+    $tv tag cell remove
+} -returnCodes 1 -result {wrong # args: should be ".tv tag cell remove tagName ?cells?"}
+
+test treetags-4.3 "tag cell has" -body {
+    $tv tag cell has _thetag
+    $tv tag cell has
+} -returnCodes 1 -result {wrong # args: should be ".tv tag cell has tagName ?cell?"}
+
+test treetags-4.3.1 "tag cell has" -body {
+    $tv tag cell add tag1 "item1 #2"
+    set res [$tv tag cell has tag1 "item1 #2"]
+    lappend res [$tv tag cell has tag1 "item1 #1"]
+    lappend res [$tv tag cell has tag1 "item1 #3"]
+    lappend res {*}[$tv tag cell has tag1]
+    $tv tag cell remove tag1 "item1 B"
+    lappend res {*}[$tv tag cell has tag1]
+    lappend res [$tv tag cell has tag1 "item1 #2"]
+} -result {1 0 0 {item1 B} 0}
+
+test treetags-4.4 "tag cell add" -body {
+    $tv tag cell add tag1 "item1 A"
+    $tv tag cell add tag1 "item1 #3"
+    $tv tag cell has tag1
+} -result {{item1 A} {item1 C}}
+
+test treetags-4.5 "tag cell add" -body {
+    $tv tag cell add tag2 "item1 A"
+    $tv tag cell add tag2 "item1 #2"
+    $tv tag cell has tag2
+} -result {{item1 A} {item1 B}}
+
+test treetags-4.6 "tag cell remove" -body {
+    $tv tag cell remove tag1 "item1 A"
+    $tv tag cell has tag1
+} -result {{item1 C}}
+
+test treetags-4.7 "tag cell remove" -body {
+    $tv tag cell remove tag2
+    $tv tag cell has tag2
+} -result {}
+
+test treetags-4.8 "tag delete with tagged cells" -body {
+    $tv tag cell add tag6 "item1 A"
+    $tv tag delete tag6
+    $tv tag cell has tag6
+} -result {}
 
 # The next test exercises tag resource management.
 # If options are not properly freed, the message:
 # Test file error: "Font times 20 still in cache."
 # will show up on stderr at program exit.
@@ -205,11 +257,11 @@
 
 test treetags-3.4 "stomp tags in tag binding procedure" -body {
     set result [list]
     $tv tag bind rm1 <<Remove>> { lappend ::result rm1 [%W focus] <<Remove>> }
     $tv tag bind rm2 <<Remove>> {
-    	lappend ::result rm2 [%W focus] <<Remove>>
+	lappend ::result rm2 [%W focus] <<Remove>>
 	%W item [%W focus] -tags {tag1}
     }
     $tv tag bind rm3 <<Remove>> { lappend ::result rm3 [%W focus] <<Remove>> }
 
     $tv item item1 -tags {rm1 rm2 rm3}

Index: tests/ttk/treeview.test
==================================================================
--- tests/ttk/treeview.test
+++ tests/ttk/treeview.test
@@ -1,11 +1,11 @@
 #
 # [7Jun2005] TO CHECK: [$tv see {}] -- shouldn't work (at least, shouldn't do
 # what it currently does)
 #
 
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 # consistencyCheck --
@@ -14,11 +14,11 @@
 #
 #	Since [$tv children] follows ->next links and [$tv index]
 #	follows ->prev links, this should cover all invariants.
 #
 proc consistencyCheck {tv {item {}}} {
-    set i 0;
+    set i 0
     foreach child [$tv children $item] {
 	assert {[$tv parent $child] == $item} "parent $child = $item"
 	assert {[$tv index $child] == $i} "index $child [$tv index $child]=$i"
 	incr i
 	consistencyCheck $tv $child
@@ -26,22 +26,47 @@
 }
 
 proc assert {expr {message ""}} {
     if {![uplevel 1 [list expr $expr]]} {
         set error "PANIC! PANIC! PANIC: $message ($expr failed)"
-    	puts stderr $error
+	puts stderr $error
 	error $error
     }
 }
 
-test treeview-0 "treeview test - setup" -body {
+proc tvSetup {} {
+    destroy .tv
     ttk::treeview .tv -columns {a b c}
     pack .tv -expand true -fill both
+    .tv column #0 -width 50
+    .tv column a -width 50
+    .tv column b -width 50
+    .tv column c -width 50
+    # Make sure everything is created and updated
+    tkwait visibility .tv
+    update
+    after 10
     update
+}
+proc tvSetupWithItems {} {
+    tvSetup
+    .tv insert {} end -id nn
+    .tv insert nn end -id nn.n1
+    .tv insert nn end -id nn.n2
+    .tv insert nn end -id nn.n3
+    for {set t 2} {$t < 100} {incr t} {
+        .tv insert {} end -id nn$t
+        if {$t % 3 == 0} {
+            .tv insert nn$t end -id nn$t.n1
+            .tv insert nn$t end -id nn$t.n2
+            .tv insert nn$t end -id nn$t.n3
+        }
+    }
 }
 
 test treeview-1.1 "columns" -body {
+    tvSetup
     .tv configure -columns {a b c}
 }
 
 test treeview-1.2 "Bad columns" -body {
     #.tv configure -columns {illegal "list"value}
@@ -52,15 +77,15 @@
     .tv configure -displaycolumns {a b d}
 } -returnCodes error -result "Invalid column index d"
 
 test treeview-1.4 "more bad displaycolumns" -body {
     .tv configure -displaycolumns {1 2 3}
-} -returnCodes error -result "Column index 3 out of bounds"
+} -returnCodes error -result {Column index "3" out of bounds}
 
 test treeview-1.5 "Don't forget to check negative numbers" -body {
-    .tv configure -displaycolumns {1 -2 3}
-} -returnCodes error -result "Column index -2 out of bounds"
+    .tv configure -displaycolumns {1 {} 3}
+} -returnCodes error -result {Column index "" out of bounds}
 
 # Item creation.
 #
 test treeview-2.1 "insert -- not enough args" -body {
     .tv insert
@@ -90,12 +115,10 @@
     .tv insert {} end -id lastnode
     consistencyCheck .tv
     .tv children {}
 } -result [list newnode lastnode]
 
-consistencyCheck .tv
-
 test treeview-2.9 "insert -- new node at beginning" -body {
     .tv insert {} 0 -id firstnode
     consistencyCheck .tv
     .tv children {}
 } -result [list firstnode newnode lastnode]
@@ -198,14 +221,14 @@
     .tv children {}
 } -result [list newfirstone firstnode anotherone onemore lastnode newlastone]
 
 test treeview-3.11 "Can't detach root item" -body {
     .tv detach [list {}]
+} -cleanup {
     update
     consistencyCheck .tv
 } -returnCodes error -result "Cannot detach root item"
-consistencyCheck .tv
 
 test treeview-3.12 "Reattach" -body {
     .tv move newnode {} end
     consistencyCheck .tv
     .tv children {}
@@ -300,11 +323,11 @@
     .tv set newnode #0 YYY
 } -returnCodes error -result "Display column #0 cannot be set"
 
 test treeview-5.7 "set illegal cell" -body {
     .tv set newnode 3 YY	;# 3 == current #columns
-} -returnCodes error -result "Column index 3 out of bounds"
+} -returnCodes error -result {Column index "3" out of bounds}
 
 test treeview-5.8 "set display columns" -body {
     .tv configure -displaycolumns [list 2 1 0]
     .tv set newnode #1 X
     .tv set newnode #2 Y
@@ -333,10 +356,22 @@
     set result [.tv set $newitem #1]
     .tv delete $newitem
     set result
 } -result {}
 
+test treeview-5.14 "set illegal height" -body {
+    # For now, -height can only be integer
+    .tv item newnode -height 1.5
+} -returnCodes 1 -result {expected integer but got "1.5"}
+
+test treeview-5.15 "set illegal height" -body {
+    .tv item newnode -height 0
+} -returnCodes 1 -result "Invalid item height 0"
+
+test treeview-5.16 "no change after illegal attempt" -body {
+    .tv item newnode -height
+} -result 1
 
 test treeview-6.1 "deletion - setup" -body {
     .tv insert {} end -id dtest
     foreach id [list a b c d e] {
 	.tv insert dtest end -id $id
@@ -348,12 +383,10 @@
     .tv delete b
     consistencyCheck .tv
     list [.tv exists b] [.tv children dtest]
 } -result [list 0 [list a c d e]]
 
-consistencyCheck .tv
-
 test treeview-6.2 "delete - duplicate items in list" -body {
     .tv delete [list a e a e]
     consistencyCheck .tv
     .tv children dtest
 } -result [list c d]
@@ -425,14 +458,14 @@
     list [.tv parent newnode] [.tv children newnode]
 } -result [list {} [list newnode.n1 newnode.n2 newnode.n3]]
 
 test treeview-7.6 "Replace children - illegal move" -body {
     .tv children newnode.n1 [list newnode.n1 newnode.n2 newnode.n3]
+} -cleanup {
+    consistencyCheck .tv
 } -returnCodes error -result "Cannot insert newnode.n1 as descendant of newnode.n1"
 
-consistencyCheck .tv
-
 test treeview-8.0 "Selection set" -body {
     .tv selection set [list newnode.n1 newnode.n3 newnode.n2]
     .tv selection
 } -result [list newnode.n1 newnode.n2 newnode.n3]
 
@@ -458,41 +491,132 @@
 
 test treeview-8.5 "Selection - bad operation" -body {
     .tv selection badop foo
 } -returnCodes error -match glob -result {bad selection operation "badop": must be *}
 
-test treeview-8.6 "Selection - <<TreeviewSelect>> on selection add" -body {
-    .tv selection set {}
-    bind .tv <<TreeviewSelect>> {set res 1}
-    set res 0
-    .tv selection add newnode.n1
-    update
-    set res
-} -result 1
-
-test treeview-8.7 "<<TreeviewSelect>> on selected item deletion" -body {
-    .tv selection set {}
-    .tv insert "" end -id selectedDoomed -text DeadItem
-    .tv insert "" end -id doomed -text AlsoDead
-    .tv selection add selectedDoomed
-    update
-    bind .tv <<TreeviewSelect>> {lappend res 1}
-    set res 0
-    .tv delete doomed
-    update
-    set res [expr {$res == 0}]
-    .tv delete selectedDoomed
-    update
-    set res
-} -result {1 1}
+test treeview-8.7 "<<TreeviewSelect>> when deleting items" -body {
+    .tv delete [.tv children {}]
+    .tv insert "" end -id myItem1 -text FirstItem
+    .tv insert "" end -id myItem2 -text SecondItem
+    .tv selection add myItem1
+    update
+    bind .tv <<TreeviewSelect>> {lappend res $val}
+    set res {}
+    set val 1
+    .tv delete myItem2  ; # no <<TreeviewSelect>> (selection unchanged)
+    update
+    set val 2
+    .tv delete myItem1  ; # <<TreeviewSelect>> triggers
+    update
+    set res
+} -cleanup {
+    bind .tv <<TreeviewSelect>> {}
+} -result {2}
+
+test treeview-8.8 "<<TreeviewSelect>> when setting the selection" -body {
+    .tv delete [.tv children {}]
+    .tv insert "" end -id myItem1 -text FirstItem
+    .tv insert "" end -id myItem2 -text SecondItem
+    update
+    bind .tv <<TreeviewSelect>> {lappend res $val}
+    set res {}
+    set val 1
+    .tv selection set ""       ; # no <<TreeviewSelect>> (selection unchanged)
+    update
+    set val 2
+    .tv selection set myItem1  ; # <<TreeviewSelect>> triggers
+    update
+    # Current implementation generates an event for this case
+    set val 3
+    .tv selection set myItem1  ; # (already selected)
+    update
+    set val 4
+    .tv selection set {myItem1 myItem2}  ; # <<TreeviewSelect>> triggers
+    update
+    set val 5
+    .tv selection set {myItem2}  ; # <<TreeviewSelect>> triggers
+    update
+    set res
+} -cleanup {
+    bind .tv <<TreeviewSelect>> {}
+} -result {2 3 4 5}
+
+test treeview-8.9 "<<TreeviewSelect>> when removing items from the selection" -body {
+    .tv delete [.tv children {}]
+    .tv insert "" end -id myItem1 -text FirstItem
+    .tv selection set myItem1
+    update
+    bind .tv <<TreeviewSelect>> {lappend res $val}
+    set res {}
+    set val 1
+    .tv selection remove ""       ; # no <<TreeviewSelect>> (selection unchanged)
+    update
+    set val 2
+    .tv selection remove myItem1  ; # <<TreeviewSelect>> triggers
+    update
+    set val 3
+    .tv selection remove myItem1  ; # no <<TreeviewSelect>> (selection unchanged)
+    update
+    set res
+} -cleanup {
+    bind .tv <<TreeviewSelect>> {}
+} -result {2}
+
+test treeview-8.10 "<<TreeviewSelect>> when adding items in the selection" -body {
+    .tv delete [.tv children {}]
+    .tv insert "" end -id myItem1 -text FirstItem
+    .tv insert "" end -id myItem2 -text SecondItem
+    .tv insert "" end -id myItem3 -text ThirdItem
+    update
+    bind .tv <<TreeviewSelect>> {lappend res $val}
+    set res {}
+    set val 1
+    .tv selection add myItem2  ; # <<TreeviewSelect>> triggers
+    update
+    set val 2
+    .tv selection add myItem2  ; # no <<TreeviewSelect>> (selection unchanged)
+    update
+    set val 3
+    .tv selection add myItem3  ; # <<TreeviewSelect>> triggers
+    update
+    set res
+} -cleanup {
+    bind .tv <<TreeviewSelect>> {}
+} -result {1 3}
+
+test treeview-8.11 "<<TreeviewSelect>> when toggling" -body {
+    .tv delete [.tv children {}]
+    .tv insert "" end -id myItem1 -text FirstItem
+    .tv insert "" end -id myItem2 -text SecondItem
+    .tv insert "" end -id myItem3 -text ThirdItem
+    update
+    bind .tv <<TreeviewSelect>> {lappend res $val}
+    set res {}
+    set val 1
+    .tv selection toggle ""  ; # no <<TreeviewSelect>> (selection unchanged)
+    update
+    set val 2
+    .tv selection toggle {myItem1 myItem3}  ; # <<TreeviewSelect>> triggers
+    update
+    set val 3
+    .tv selection toggle {myItem3 myItem2}  ; # <<TreeviewSelect>> triggers
+    update
+    set val 4
+    .tv selection toggle {myItem3 myItem2}  ; # <<TreeviewSelect>> triggers
+    update
+    set res
+} -cleanup {
+    bind .tv <<TreeviewSelect>> {}
+} -result {2 3 4}
 
 ### NEED: more tests for see/yview/scrolling
 
 proc scrollcallback {args} {
     set ::scrolldata $args
 }
 test treeview-9.0 "scroll callback - empty tree" -body {
+    tvSetup
     .tv configure -yscrollcommand scrollcallback
     .tv delete [.tv children {}]
     update
     set ::scrolldata
 } -result [list 0.0 1.0]
@@ -502,11 +626,14 @@
     for {set i 1} {$i < 100} {incr i} {
         .tree insert {} end -text $i
     }
 } -body {
     .tree yview scroll 5 units
-    .tree identify item 2 2
+    # This is sensitive to the exact layout of a tree.
+    # It assumes that (8,8) should be far enough in to be in the tree,
+    # while still being in the first item.
+    .tree identify item 8 8
 } -cleanup {
     destroy .tree
 } -result {I006}
 
 test treeview-9.2 {scrolling on see command - bug [14188104c3]} -setup {
@@ -560,10 +687,218 @@
     set after [lindex [.top.vs get] 1]
     expr $after < $before
 } -cleanup {
     destroy .top
 } -result 1
+
+test treeview-10.0 "See command" -setup {
+    # Setup common for all 10.* tests
+    ttk::style configure Treeview -rowheight 20
+    tvSetupWithItems
+    set ::baseBbY [lindex [.tv bbox nn "#1"] 1]
+    proc bbY {item} {
+        set bb [.tv bbox $item "#1"]
+        set y [lindex $bb 1]
+        if {$y eq ""} {return "_"}
+        return [expr {$y - $::baseBbY}]
+    }
+} -body {
+    set res ""
+    lappend res [bbY nn99]
+    .tv see nn99
+    lappend res [bbY nn99]
+    set res
+} -result {_ 180}
+
+test treeview-10.1 "See command, auto-open" -body {
+    set res ""
+    lappend res [bbY nn96]
+    # Not yet visible
+    lappend res [bbY nn96.n1]
+    .tv see nn96.n1
+    lappend res [bbY nn96.n1]
+    # Pushed out by the opening, not visible
+    lappend res [bbY nn99]
+    set res
+} -result {120 _ 140 _}
+
+test treeview-10.2 "See command, height" -setup {
+    .tv item nn34 -height 4
+    .tv item nn55 -height 30
+    .tv item nn76 -height 5
+} -body {
+    set res ""
+    lappend res [bbY nn34]
+    .tv see nn34
+    lappend res [bbY nn34]
+    .tv see nn33
+    lappend res [bbY nn34]
+
+    lappend res [bbY nn76]
+    .tv see nn76
+    lappend res [bbY nn76]
+
+    .tv see nn53
+    lappend res [bbY nn53]
+    # Partly visible
+    lappend res [bbY nn55]
+    .tv see nn55
+    # Scrolled to top
+    lappend res [bbY nn55]
+    set res
+} -result {_ 0 20 _ 100 0 40 0}
+
+test treeview-11.0 "Cellselection set rectangle" -setup {
+    # Setup common for all 11.* tests
+    tvSetupWithItems
+    .tv configure -columns {a b c d}
+    .tv configure -displaycolumns {a b c}
+} -body {
+    .tv cellselection set "nn.n3 #2" "nn.n1 a"
+    .tv cellselection
+} -result [list "nn.n1 a" "nn.n1 b" "nn.n2 a" "nn.n2 b" "nn.n3 a" "nn.n3 b"]
+
+test treeview-11.1 "Cellselection set" -body {
+    .tv cellselection set [list "nn.n1 a" "nn.n2 a" "nn.n3 #2" "nn.n2 d"]
+    .tv cellselection
+} -result [list "nn.n1 a" "nn.n2 a" "nn.n2 d" "nn.n3 b"]
+
+test treeview-11.2 "Cellselection add" -body {
+    .tv cellselection add "nn b"
+    .tv cellselection
+} -result [list "nn b" "nn.n1 a" "nn.n2 a" "nn.n2 d" "nn.n3 b"]
+
+test treeview-11.3 "Cellselection toggle" -body {
+    .tv cellselection toggle [list "nn.n2 a" "nn2 b" "nn2 #0"]
+    .tv cellselection
+} -result [list "nn b" "nn.n1 a" "nn.n2 d" "nn.n3 b" "nn2 b" "nn2 #0"]
+
+test treeview-11.4 "Cellselection remove" -body {
+    .tv cellselection remove [list "nn.n2 d" "nn b" "nn2 #0"]
+    .tv cellselection
+} -result [list "nn.n1 a" "nn.n3 b" "nn2 b"]
+
+test treeview-11.5 "Cellselection add rectangle" -body {
+    .tv cellselection add "nn a" "nn.n1 c"
+    .tv cellselection
+} -result [list \
+                   "nn a" "nn b" "nn c" \
+                   "nn.n1 a" "nn.n1 b" "nn.n1 c" \
+                   "nn.n3 b" \
+                   "nn2 b"]
+
+test treeview-11.6 "Cellselection toggle rectangle" -body {
+    .tv cellselection toggle "nn.n1 b" "nn.n3 c"
+    .tv cellselection
+} -result [list \
+                   "nn a" "nn b" "nn c" \
+                   "nn.n1 a" \
+                   "nn.n2 b" "nn.n2 c" \
+                   "nn.n3 c" \
+                   "nn2 b"]
+
+test treeview-11.7 "Cellselection remove rectangle" -body {
+    .tv cellselection remove "nn.n1 a" "nn.n3 b"
+    .tv cellselection
+} -result [list \
+                   "nn a" "nn b" "nn c" \
+                   "nn.n2 c" \
+                   "nn.n3 c" \
+                   "nn2 b"]
+
+test treeview-11.8 "Cellselection set rectangle" -body {
+    # This tests that "set" clears out all old selections
+    .tv cellselection set "nn b" "nn.n1 c"
+    .tv cellselection
+} -result [list "nn b" "nn c" "nn.n1 b" "nn.n1 c"]
+
+test treeview-11.9 "Cellselection - clear" -body {
+    .tv cellselection set {}
+    .tv cellselection
+} -result {}
+
+test treeview-11.10 "Cellselection - bad operation" -body {
+    .tv cellselection badop foo
+} -returnCodes 1 -match glob -result {bad cellselection operation "badop": must be *}
+
+test treeview-11.11 "Cellselection - <<TreeviewSelect>> on cellselection add" -body {
+    .tv cellselection set {}
+    bind .tv <<TreeviewSelect>> {set res 1}
+    set res 0
+    .tv cellselection add {"nn.n1 b"}
+    update
+    set res
+} -cleanup {
+    bind .tv <<TreeviewSelect>> {}
+} -result {1}
+
+test treeview-11.12 "<<TreeviewSelect>> on selected cell deletion" -body {
+    .tv cellselection set {}
+    .tv insert "" end -id selectedDoomed -text DeadItem
+    .tv insert "" end -id doomed -text AlsoDead
+    .tv cellselection add {"selectedDoomed c"}
+    .tv cellselection add {"doomed c"}
+    .tv cellselection remove {"doomed c"}
+    update
+    bind .tv <<TreeviewSelect>> {lappend res 1}
+    set res 0
+    .tv delete doomed
+    update
+    set res [expr {$res == 0}]
+    .tv delete selectedDoomed
+    update
+    set res
+} -cleanup {
+    bind .tv <<TreeviewSelect>> {}
+} -result {1 1}
+
+test treeview-11.13 "Cellselection - error" -body {
+    .tv cellselection set [list "apa a"]
+} -returnCodes 1 -match glob -result {Item apa not found}
+
+test treeview-11.14 "Cellselection - error" -body {
+    .tv cellselection set [list "nn xx "]
+} -returnCodes 1 -match glob -result {Invalid column index xx}
+
+test treeview-11.15 "Cellselection - error" -body {
+    .tv cellselection set "nn c" "nn d"
+} -returnCodes 1 -match glob -result {Cell id must be in a visible column}
+
+test treeview-11.16 "Cellselection - non visible" -body {
+    .tv cellselection set [list "nn d"]
+    .tv cellselection
+} -result {{nn d}}
+
+# Same as 8.8, but for cell selection
+test treeview-11.17 "<<TreeviewSelect>> when setting the selection" -body {
+    .tv delete [.tv children {}]
+    .tv insert "" end -id myItem1 -text FirstItem
+    .tv insert "" end -id myItem2 -text SecondItem
+    update
+    bind .tv <<TreeviewSelect>> {lappend res $val}
+    set res {}
+    set val 1
+    .tv cellselection set ""   ; # no <<TreeviewSelect>> (selection unchanged)
+    update
+    set val 2
+    .tv cellselection set "myItem1 a"  ; # <<TreeviewSelect>> triggers
+    update
+    # Current implementation generates an event for this case
+    set val 3
+    .tv cellselection set "myItem1 a"  ; # (already selected)
+    update
+    set val 4
+    .tv cellselection set {{myItem1 a} {myItem2 a}} ; # <<TreeviewSelect>>
+    update
+    set val 5
+    .tv cellselection set {myItem2 a}  ; # <<TreeviewSelect>> triggers
+    update
+    set res
+} -cleanup {
+    bind .tv <<TreeviewSelect>> {}
+} -result {2 3 4 5}
+
 
 ### identify tests:
 #
 proc identify* {tv comps args} {
     foreach {x y} $args {
@@ -589,15 +924,17 @@
 }
 
 test treeview-identify-setup "identify series - setup" -body {
     destroy .tv
     ttk::setTheme default
+    ttk::style configure Treeview -rowheight 20
     ttk::treeview .tv -columns [list A B C]
     .tv insert {} end -id branch -text branch -open true
-    .tv insert branch end -id item1 -text item1
+    .tv insert branch end -id item1 -text item1 -height 2
     .tv insert branch end -id item2 -text item2
     .tv insert branch end -id item3 -text item3
+    .tv insert {} end -id item4 -text item4
 
     .tv column #0 -width 50	;# 0-50
     .tv column A -width 50	;# 50-100
     .tv column B -width 50	;# 100-150
     .tv column C -width 50	;# 150-200 (plus slop for margins)
@@ -613,17 +950,17 @@
 
 test treeview-identify-2 "identify columns" -body {
     .tv configure -displaycolumns #all
     update idletasks
     columnids .tv [identify* .tv column 25 10  75 10  125 10  175 10]
-} -result [list {} A B C]
+} -result [list \#0 A B C]
 
 test treeview-identify-3 "reordered columns" -body {
     .tv configure -displaycolumns {B A C}
     update idletasks
     columnids .tv [identify* .tv column 25 10  75 10  125 10  175 10]
-} -result [list {} B A C]
+} -result [list \#0 B A C]
 
 test treeview-identify-4 "no tree column" -body {
     .tv configure -displaycolumns #all -show {headings}
     update idletasks
     identify* .tv {region column} 25 10  75 10  125 10  175 10
@@ -631,24 +968,24 @@
 
 # Item height in default theme is 20px
 test treeview-identify-5 "vertical scan - no headings" -body {
     .tv configure -displaycolumns #all -show {tree}
     update idletasks
-    identify* .tv {region item} 25 10  25 30  25 50  25 70  25 90
-} -result [list tree branch tree item1 tree item2 tree item3 nothing {}]
+    identify* .tv {region item} 25 10  25 30  25 70  25 90  25 110  25 130
+} -result [list tree branch tree item1 tree item2 tree item3 tree item4 nothing {}]
 
 test treeview-identify-6 "vertical scan - with headings" -body {
     .tv configure -displaycolumns #all -show {tree headings}
     update idletasks
-    identify* .tv {region item} 25 10  25 30  25 50  25 70  25 90
+    identify* .tv {region item} 25 10  25 30  25 50  25 90  25 110
 } -result [list heading {} tree branch tree item1 tree item2 tree item3]
 
 test treeview-identify-7 "vertical scan - headings, no tree" -body {
     .tv configure -displaycolumns #all -show {headings}
     update idletasks
-    identify* .tv {region item} 25 10  25 30  25 50  25 70  25 90
-} -result [list heading {} cell branch cell item1 cell item2 cell item3]
+    identify* .tv {region item cell} 25 10  25 30  25 50  75 90  25 110
+} -result [list heading {} {} cell branch {branch #1} cell item1 {item1 #1} cell item2 {item2 #2} cell item3 {item3 #1}]
 
 # In default theme, -indent and -itemheight both 20px
 # Disclosure element name is "Treeitem.indicator"
 set disclosure "*.indicator"
 test treeview-identify-8 "identify element" -body {
@@ -659,16 +996,24 @@
     update idletasks;
     identify* .tv {item element} 10 10  30 30  50 50
 } -match glob -result [list \
 	branch $disclosure branch2 $disclosure branch3 $disclosure]
 
+test treeview-identify-8.1 "identify element" -body {
+    .tv configure -show {tree headings}
+    update
+    identify* .tv element 1 1  10 10  25 25
+    # Heading elements are currently not reported
+} -result [list {} {} text]
+
 # See #2381555
 test treeview-identify-9 "identify works when horizontally scrolled" -setup {
     .tv configure -show {tree headings}
     foreach column {#0 A B C} {
 	.tv column $column -stretch 0 -width 50
     }
+    # Scrollable area is 200, visible is 100
     place .tv -x 0 -y 0 -width 100
 } -body {
     set result [list]
     foreach xoffs {0 50 100} {
 	.tv xview $xoffs ; update
@@ -677,21 +1022,183 @@
     set result
 } -result [list \
 	[list heading #0 heading #1] \
 	[list heading #1 heading #2] \
 	[list heading #2 heading #3] ]
+
+test treeview-identify-10 "identify works when horizontally scrolled" -setup {
+    .tv configure -show {tree headings}
+    .tv configure -titlecolumns 1
+    foreach column {"#0" A B C} {
+	.tv column $column -stretch 0 -width 50
+    }
+    # Scrollable area is 200, visible is 150
+    place .tv -x 0 -y 0 -width 150
+} -body {
+    set result [list]
+    foreach xoffs {0 25 50} {
+	.tv xview $xoffs
+        update
+	lappend result [identify* .tv {region column} 10 10 60 10]
+	lappend result [identify* .tv {region column} 10 50 60 50]
+    }
+    set result
+} -result [list \
+	[list heading #0 heading #1] [list tree #0 cell #1] \
+	[list heading #0 heading #1] [list tree #0 cell #1] \
+	[list heading #0 heading #2] [list tree #0 cell #2] ]
+
+# Hijack the setup above to check bbox too
+test treeview-identify-10b "bbox works when horizontally scrolled" -body {
+    # Establish a point of reference
+    .tv configure -titlecolumns 0
+    .tv xview 0
+    update
+    set base [lindex [.tv bbox branch "#0"] 0]
+    set result [list]
+    foreach tc {0 1 2 3} {
+        .tv configure -titlecolumns $tc
+        foreach xoffs {0 25 50} {
+            .tv xview $xoffs
+            update
+            # Extract x coordinate for each column
+            lappend result [expr {[lindex [.tv bbox branch "#0"] 0] - $base}]
+            lappend result [expr {[lindex [.tv bbox branch A   ] 0] - $base}]
+            lappend result [expr {[lindex [.tv bbox branch B   ] 0] - $base}]
+            lappend result [expr {[lindex [.tv bbox branch C   ] 0] - $base}]
+        }
+    }
+    set result
+} -result [list 0 50 100 150  -25 25  75 125   -50  0  50 100 \
+                0 50 100 150    0 25  75 125     0  0  50 100 \
+                0 50 100 150    0 50  75 125     0 50  50 100 \
+                0 50 100 150    0 50 100 125     0 50 100 101]
+
+# Followup to trigger crash that happened when title > display
+test treeview-identify-10c "title more than display" -body {
+    .tv configure -titlecolumns 10
+    .tv xview 0
+    update
+    set x1 [.tv xview]
+    # It shouldn't be possible to scroll
+    .tv xview 50
+    update
+    set x2 [.tv xview]
+    set result [list $x1 $x2]
+} -result {{0.0 1.0} {0.0 1.0}}
+
+
+test treeview-identify-11 "bbox supporting -height" -body {
+    .tv configure -titlecolumns 0
+    .tv xview 0
+    .tv item branch2 -open false
+    # Add extra items to make sure it scrolls
+    .tv insert {} end -id item5 -text item5
+    .tv insert {} end -id item6 -text item6
+    # Height needs to be big enough to show the items we measure
+    # and small enough to make scrolling happen.
+    .tv configure -height 6
+    pack .tv -side top
+    update
+    set base [lindex [.tv bbox branch A] 1]
+    set result {}
+    foreach yv {0 1} {
+        .tv yview $yv
+        update
+        foreach item {item1 item2 item3} {
+            set bb [.tv bbox $item A]
+            set y [lindex $bb 1]
+            if {$y eq ""} {
+                # This is to get a clearer error if this goes wrong
+                lappend result {}
+            } else {
+                lappend result [expr {$y - $base}]
+            }
+            lappend result [lindex $bb 3]
+        }
+    }
+    set result
+} -result [list 40 40 80 20 100 20  20 40 60 20 80 20]
 
 test treeview-identify-cleanup "identify - cleanup" -body {
     destroy .tv
 }
 
+
+test treeview-rowheight-1 "rowheight - setup" -body {
+    destroy .tv
+    ttk::setTheme default
+    # Test that style rowheight is in control
+    ttk::style configure Treeview -rowheight 73
+    tvSetupWithItems
+    lindex [.tv bbox nn a] 3
+} -result 73
+
+test treeview-rowheight-2 "rowheight change" -body {
+    # Reacts to style changes
+    ttk::style configure Treeview -rowheight 25
+    update
+    lindex [.tv bbox nn a] 3
+} -result 25
+
+test treeview-rowheight-3 "rowheight adapts to font" -body {
+    ttk::style configure Treeview -rowheight {}
+    ttk::style configure Treeview -font "Courier -20"
+    update
+    set baseline [lindex [.tv bbox nn a] 3]
+    ttk::style configure Treeview -font "Courier -50"
+    update
+    set after [lindex [.tv bbox nn a] 3]
+    set diff [expr {$after - $baseline}]
+    # We only want to check there is an increase,
+    # its exact magnitude does not matter
+    expr {0 < $diff ? "OK" : $diff}
+} -result OK
+
+test treeview-rowheight-3b "rowheight adapts to named font" -body {
+    ttk::style configure Treeview -rowheight {}
+    font create __tf -family Courier -size -20
+    ttk::style configure Treeview -font __tf
+    update
+    set baseline [lindex [.tv bbox nn a] 3]
+    font configure __tf -size -50
+    update
+    set after [lindex [.tv bbox nn a] 3]
+    set diff [expr {$after - $baseline}]
+    # We only want to check there is an increase,
+    # its exact magnitude does not matter
+    expr {0 < $diff ? "OK" : $diff}
+} -result OK
+
+test treeview-rowheight-4 "rowheight adapts to item padding" -body {
+    # Test that things from Item style is picked up.
+    ttk::style configure Item -padding "2 2 2 2"
+    update
+    set baseline [lindex [.tv bbox nn a] 3]
+    ttk::style configure Item -padding "2 3 2 5"
+    update
+    set after [lindex [.tv bbox nn a] 3]
+    set diff [expr {$after - $baseline}]
+} -result 4
+
+test treeview-rowheight-5 "rowheight adapts to cell padding" -body {
+    # Test that things from Cell style is picked up.
+    ttk::style configure Cell -padding "2 5 2 5"
+    update
+    set baseline [lindex [.tv bbox nn a] 3]
+    ttk::style configure Cell -padding "2 8 2 9"
+    update
+    set after [lindex [.tv bbox nn a] 3]
+    set diff [expr {$after - $baseline}]
+} -result 7
+
 ### NEED: tests for focus item, selection
 
 ### Misc. tests:
 
 destroy .tv
-test treeview-10.1 "Root node properly initialized (#1541739)" -setup {
+test treeview-1541739 "Root node properly initialized (#1541739)" -setup {
     ttk::treeview .tv
     .tv insert {} end -id a
     .tv see a
 } -cleanup {
     destroy .tv
@@ -832,7 +1339,122 @@
     lappend res [.tv column bar -width] [.tv column colA -width] \
                 [expr {[winfo width .tv] < $origTreeWidth}]
 } -cleanup {
     destroy .tv
 } -result {60 50 60 50 60 50 1}
+
+test treeview-bc602049ab "treeview with custom background does not change size when switching themes" -setup {
+    image create photo tvbg -data {
+	iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAnXAAAJ1wG
+	xbhe3AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAACJJREFUOI
+	1jPLF9+38GKgImaho2auCogaMGjho4auBQMhAAyR0DXUEyypsAAAAASUVORK5CYII=
+    }
+    ttk::style theme create foo-bc602049ab -parent clam -settings {
+      ttk::style element create Treeview.field image tvbg -width 0 -height 0
+    }
+    ttk::style theme use foo-bc602049ab
+    pack [ttk::treeview .tv]
+    update idletasks
+} -body {
+    set g1 [winfo geometry .tv]
+    ttk::style theme use foo-bc602049ab
+    update idletasks
+    set g2 [winfo geometry .tv]
+    expr {$g1 eq $g2 ? 1 : "$g1 --> $g2"}
+} -cleanup {
+    destroy .tv
+    image delete tvbg
+} -result {1}
+
+test treeview-column0-leak "Test for leak in tree column" -setup {
+    destroy .ttt
+    set heading [string range _Hej_ 1 3]
+} -body {
+    for {set t 0} {$t < 3} {incr t} {
+        ttk::treeview .tapa -columns "hej hopp"
+        .tapa heading #0 -text $heading
+        destroy .tapa
+    }
+    tcl::unsupported::representation $heading
+} -match glob -result {*refcount of 3,*}
+
+test treeview-11.1 "style command" -body {
+    ttk::treeview .w
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {{} Treeview Treeview}
+test treeview-11.2 "style command" -body {
+    ttk::style configure customStyle.Treeview
+    ttk::treeview .w -style customStyle.Treeview
+    list [.w cget -style] [.w style] [winfo class .w]
+} -cleanup {
+    destroy .w
+} -result {customStyle.Treeview customStyle.Treeview Treeview}
+
+test treeview-12.1 "tag bindings" -setup {
+    tvSetupWithItems
+    .tv tag configure t1 -background red
+    .tv tag configure t2 -background blue
+    .tv item nn -open 1
+    # Tags on item and cell to spot the difference
+    .tv tag add t1 "nn.n1"
+    .tv tag cell add t2 "nn.n1 a"
+    .tv tag cell add t2 "nn.n2 c"
+    update
+    proc cellEvent {item col} {
+        # Find midpoint of cell
+        lassign [.tv bbox $item $col] aX aY aW aH
+        set aX [expr {$aX + $aW / 2}]
+        set aY [expr {$aY + $aH / 2}]
+        event generate .tv <Button-1> -x $aX -y $aY
+    }
+} -body {
+    .tv tag bind t1 <Button-1> {lappend ::tagtest t1}
+    .tv tag bind t2 <Button-1> {lappend ::tagtest t2}
+    # Cell with both binds
+    set ::tagtest a
+    cellEvent nn.n1 a
+    # Cell with just item tag
+    lappend ::tagtest b
+    cellEvent nn.n1 b
+    # Cell with just cell tag
+    lappend ::tagtest c
+    cellEvent nn.n2 c
+    # Same tag on both cell and item should fire once
+    .tv tag cell add t1 "nn.n1 b"
+    lappend ::tagtest b
+    cellEvent nn.n1 b
+    # Break in first bind
+    .tv tag bind t1 <Button-1> {lappend ::tagtest t1;break}
+    lappend ::tagtest a
+    cellEvent nn.n1 a
+    set ::tagtest
+} -cleanup {
+    rename cellEvent {}
+    destroy .tv
+} -result {a t1 t2 b t1 c t2 b t1 a t1}
+test treeview-12.2 "tag bindings deletion on tag delete" -setup {
+    tvSetupWithItems
+    .tv tag bind nn.n1 <Button-1> {puts Triggered}
+} -body {
+    .tv tag delete nn.n1
+    .tv tag bind nn.n1
+} -cleanup {
+    destroy .tv
+} -result {}
+
+test treeview-13.1 "cell padding" -setup {
+    tvSetupWithItems
+} -body {
+    .tv tag cell add mytag "nn b"
+    set redcross [image create photo -format gif -data {R0lGODlhBwAHAIABAP8AAP///
+            yH5BAEKAAEALAAAAAAHAAcAAAIMBIKmsWrIXnLxuDMLADs=}]
+    .tv tag configure mytag -image $redcross
+    .tv tag configure mytag -imageanchor nw
+    .tv tag configure mytag -padding {2 4 6 8}
+    .tv tag configure mytag -padding
+} -cleanup {
+    destroy .tv
+} -result {2 4 6 8}
 
 tcltest::cleanupTests

Index: tests/ttk/ttk.test
==================================================================
--- tests/ttk/ttk.test
+++ tests/ttk/ttk.test
@@ -1,7 +1,7 @@
 
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 proc skip args {}
@@ -85,11 +85,11 @@
     set ::A
 } -result {it worked}
 
 test ttk-6.9 "Bad font spec in styles" -setup {
     ttk::style theme create badfont -settings {
-    	ttk::style configure . -font {Helvetica 12 Bogus}
+	ttk::style configure . -font {Helvetica 12 Bogus}
     }
     ttk::style theme use badfont
 } -cleanup {
     ttk::style theme use default
 } -body {
@@ -117,11 +117,11 @@
     unset OUCH
 } -body {
     list \
 	[catch { ttk::checkbutton .b -variable OUCH } msg] \
 	$msg \
-    	[winfo exists .b] \
+	[winfo exists .b] \
 	[info commands .b] \
 	;
 } -result [list 1 "widget has been destroyed" 0 {}]
 
 test ttk-selfdestruct-ok-1 "Intentional self-destruction" -body {
@@ -156,14 +156,14 @@
     foreach statespec {
 	{!active !disabled}
 	{!active disabled}
 	{active !disabled}
 	{active disabled}
-    	active
+	active
 	disabled
     } {
-    	lappend result [$w instate $statespec]
+	lappend result [$w instate $statespec]
     }
     set result
 }
 
 # NB: this will fail if the top-level window pops up underneath the cursor
@@ -295,11 +295,11 @@
     pack [ttk::button .tb1 -text "Ouch"]
     ttk::style theme use alt
     update;
     # As long as we haven't crashed, everything's OK
     ttk::style theme settings alt {
-    	ttk::style configure TButton -font TkDefaultFont
+	ttk::style configure TButton -font TkDefaultFont
     }
     ttk::style theme use default
     destroy .tb1
 }
 
@@ -438,10 +438,19 @@
     set TV Foo
     .tl configure -text Bar
     .tl cget -text
 } -cleanup { destroy .tl } -result "Foo"
 
+test ttk-9.9 "default for -justify" -body {
+    ttk::label .tl
+    .tl cget -justify
+} -cleanup { destroy .tl } -result "left"
+test ttk-9.10 "default for -anchor" -body {
+    ttk::label .tl
+    .tl cget -anchor
+} -cleanup { destroy .tl } -result "w"
+
 #
 # Frame widget tests:
 #
 
 test ttk-10.1 "ttk::frame -class resource" -body {
@@ -557,11 +566,11 @@
     destroy .tb1
 } -returnCodes error -result "*badstyle not found*" -match glob
 
 test ttk-13.5 "Custom layouts -- missing element definition" -body {
     ttk::style layout badstyle {
-    	NoSuchElement
+	NoSuchElement
     }
     ttk::button .tb1 -style badstyle
 } -cleanup {
     destroy .tb1
 } -result .tb1
@@ -652,11 +661,22 @@
 } -returnCodes error -result [wrong#args theme ?element?]
 
 test ttk-ensemble-5 "style element create: valid" -body {
      ttk::style element create plain.background from default
 } -returnCodes 0 -result ""
+
+test ttk-16.1 {ttk::style theme styles - no such theme} -body {
+    ttk::style theme styles noSuchTheme
+} -returnCodes 1 -result {theme "noSuchTheme" doesn't exist}
+test ttk-16.2 {ttk::style theme styles - theme exists} -body {
+    # simply check this produces a list with some style names,
+    # without checking exact content (not needed, and may vary
+    # depending on platform, versions, improvements...)
+    expr {[llength [ttk::style theme styles alt]] > 0}
+} -result 1
+
 
 eval destroy [winfo children .]
 
 tcltest::cleanupTests
 
 #*EOF*

Index: tests/ttk/validate.test
==================================================================
--- tests/ttk/validate.test
+++ tests/ttk/validate.test
@@ -1,11 +1,11 @@
 ##
 ## Entry widget validation tests
 ## Derived from core test suite entry-19.1 through entry-19.20
 ##
 
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 
 loadTestedCommands
 
@@ -76,58 +76,67 @@
     .e insert end d
     set ::vVals
 } -result {}
 
 test validate-1.8 {entry widget validation - vmode focus} -body {
+    set ::vVals {}
+    set timer [after 300 lappend ::vVals timeout]
     focus -force .e
-    # update necessary to process FocusIn event
-    update
+    vwait ::vVals
+    after cancel $timer
     set ::vVals
 } -result {.e -1 -1 abcd abcd {} focus focusin}
 
 test validate-1.9 {entry widget validation - vmode focus} -body {
+    set ::vVals {}
+    set timer [after 300 lappend ::vVals timeout]
     focus -force .
-    # update necessary to process FocusOut event
-    update
+    vwait ::vVals
+    after cancel $timer
     set ::vVals
 } -result {.e -1 -1 abcd abcd {} focus focusout}
 
 .e configure -validate all
 test validate-1.10 {entry widget validation - vmode all} -body {
+    set ::vVals {}
+    set timer [after 300 lappend ::vVals timeout]
     focus -force .e
-    # update necessary to process FocusIn event
-    update
+    vwait ::vVals
+    after cancel $timer
     set ::vVals
 } -result {.e -1 -1 abcd abcd {} all focusin}
 
 test validate-1.11 {entry widget validation} -body {
+    set ::vVals {}
+    set timer [after 300 lappend ::vVals timeout]
     focus -force .
-    # update necessary to process FocusOut event
-    update
+    vwait ::vVals
+    after cancel $timer
     set ::vVals
 } -result {.e -1 -1 abcd abcd {} all focusout}
 .e configure -validate focusin
 
 test validate-1.12 {entry widget validation} -body {
+    set ::vVals {}
+    set timer [after 300 lappend ::vVals timeout]
     focus -force .e
-    # update necessary to process FocusIn event
-    update
+    vwait ::vVals
+    after cancel $timer
     set ::vVals
 } -result {.e -1 -1 abcd abcd {} focusin focusin}
 
 test validate-1.13 {entry widget validation} -body {
     set ::vVals {}
     focus -force .
-    # update necessary to process FocusOut event
     update
     set ::vVals
 } -result {}
 .e configure -validate focuso
 
 test validate-1.14 {entry widget validation} -body {
+    set ::vVals {}
     focus -force .e
-    # update necessary to process FocusIn event
     update
     set ::vVals
 } -result {}
 
 test validate-1.15 {entry widget validation} -body {
@@ -227,11 +236,11 @@
 #
 
 test validate-3.0 "Setup" -body {
     set ::E "123"
     ttk::entry .e \
-    	-validatecommand {string is integer -strict %P} \
+	-validatecommand {string is integer -strict %P} \
 	-validate all \
 	-textvariable ::E \
 	;
     return [list [.e get] [.e state]]
 } -result [list 123 {}]

Index: tests/ttk/vsapi.test
==================================================================
--- tests/ttk/vsapi.test
+++ tests/ttk/vsapi.test
@@ -1,9 +1,9 @@
 # -*- tcl -*-
 #
 
-package require Tk
+package require tk
 package require tcltest 2.2
 namespace import -force tcltest::*
 loadTestedCommands
 
 testConstraint xpnative \

Index: tests/unixButton.test
==================================================================
--- tests/unixButton.test
+++ tests/unixButton.test
@@ -3,11 +3,11 @@
 # widgets defined in tkUnixButton.c).  It is organized in the standard
 # fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands

Index: tests/unixEmbed.test
==================================================================
--- tests/unixEmbed.test
+++ tests/unixEmbed.test
@@ -1,19 +1,19 @@
 # This file is a Tcl script to test out the procedures in the file
 # tkUnixEmbed.c.  It is organized in the standard fashion for Tcl
 # tests.
 #
 # Copyright © 1996-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 namespace import -force tcltest::test
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 namespace eval ::_test_tmp {}
 
 # ------------------------------------------------------------------------------
@@ -225,12 +225,12 @@
     testembed
 } -cleanup {
 	deleteWindows
 } -result {{XXX .f2 {} .t2} {XXX .f1 {} .t1}}
 
-# Can't think of any way to test the procedures TkpMakeWindow,
-# TkpMakeContainer, or EmbedErrorProc.
+# Can't think of any way to test the procedures Tk_MakeWindow,
+# Tk_MakeContainer, or EmbedErrorProc.
 
 
 test unixEmbed-2.1 {EmbeddedEventProc procedure} -constraints {
 	unix testembed notAqua
 } -setup {
@@ -1299,10 +1299,11 @@
     pack [button .embed.b -text "Emb Button" \
 	      -command {lappend result ".embed.b"}] -padx 30 -pady 30
     wm geometry .main 200x400+100+100
     update idletasks
     focus -force .main
+    after 100
     set x [expr {[winfo x .main ] + [winfo x .main.b] + 40}]
     set y [expr {[winfo y .main ] + [winfo y .main.b] + 38}]
     lappend result [winfo containing $x $y]
     after 200
     pressbutton $x $y

Index: tests/unixFont.test
==================================================================
--- tests/unixFont.test
+++ tests/unixFont.test
@@ -7,18 +7,18 @@
 # but there are no results that can be checked.  Some tests depend on the
 # fonts having or not having certain properties, which may not be valid
 # at all sites.
 #
 # Copyright © 1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnUbuntuNoXft [expr {[testConstraint failsOnUbuntu] || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))}]
 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 if {[tk windowingsystem] eq "x11"} {
     set xlsf [auto_execok xlsfonts]

Index: tests/unixMenu.test
==================================================================
--- tests/unixMenu.test
+++ tests/unixMenu.test
@@ -2,11 +2,11 @@
 # organized in the standard fashion for Tcl tests. This
 # file tests the Macintosh-specific features of the menu
 # system.
 #
 # Copyright © 1995-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 eval tcltest::configure $argv

Index: tests/unixSelect.test
==================================================================
--- tests/unixSelect.test
+++ tests/unixSelect.test
@@ -2,11 +2,11 @@
 #
 # This file contains a collection of tests for one or more of the Tcl
 # built-in commands.  Sourcing this file into Tcl runs the tests and
 # generates output for errors.  No output means no errors were found.
 #
-# Copyright © 1999 by Scriptics Corporation.
+# Copyright © 1999 Scriptics Corporation.
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
 package require tcltest 2.2

Index: tests/unixWm.test
==================================================================
--- tests/unixWm.test
+++ tests/unixWm.test
@@ -2,20 +2,20 @@
 # the window manager, including the "wm" command.  It is organized
 # in the standard fashion for Tcl tests.
 #
 # Copyright © 1992-1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
 
 namespace import -force ::tk::test:loadTkCommand
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 proc sleep ms {
     global x
     after $ms {set x 1}
@@ -31,28 +31,31 @@
 	wm geom $i 150x100+0+0
 	update
     }
 }
 
-# On macOS windows are not allowed to overlap the menubar at the top
-# of the screen.  So tests which move a window and then check whether
-# it got moved to the requested location should use a y coordinate
-# larger than the height of the menubar (normally 23 pixels).
+# On macOS windows are not allowed to overlap the menubar at the top of the
+# screen or the dock.  So tests which move a window and then check whether it
+# got moved to the requested location should use a y coordinate larger than the
+# height of the menubar (normally 23 pixels) and an x coordinate larger than the
+# width of the dock, if it happens to be on the left.
 
 if {[tk windowingsystem] eq "aqua"} {
     set mb [expr [menubarheight] + 1]
+    set X  100
     set Y0 $mb
     set Y2 [expr $mb + 2]
     set Y5 [expr $mb + 5]
 } else {
+    set X  20
     set Y0 0
     set Y2 2
     set Y5 5
 }
 
 set i 1
-foreach geom "+$Y0+80 +80+$Y0 +0+$Y0" {
+foreach geom "+$X+80 +80+$Y0 +$X+$Y0" {
     destroy .t
     test unixWm-1.$i {initial window position} unix {
 	toplevel .t -width 200 -height 150
 	wm geom .t $geom
 	update
@@ -102,11 +105,11 @@
     } $geom
     incr i
 }
 
 set i 1
-foreach geom "+20+80 +100+40 +0+$Y0" {
+foreach geom "+$X+80 +$X+40 +$X+$Y0" {
     test unixWm-4.$i {moving window while withdrawn} unix {
 	wm withdraw .t
 	update idletasks
 	wm geom .t $geom
 	update idletasks
@@ -186,31 +189,31 @@
     list [winfo ismapped .t] [wm state .t]
 } {0 iconic}
 
 destroy .t
 toplevel .t -width 200 -height 100
-wm geom .t +10+$Y0
+wm geom .t +100+$Y0
 wm minsize .t 1 1
 update
 test unixWm-6.1 {size changes} unix {
     .t config -width 180 -height 150
     update
     wm geom .t
-} 180x150+10+$Y0
+} 180x150+100+$Y0
 test unixWm-6.2 {size changes} unix {
     wm geom .t 250x60
     .t config -width 170 -height 140
     update
     wm geom .t
-} 250x60+10+$Y0
+} 250x60+100+$Y0
 test unixWm-6.3 {size changes} unix {
     wm geom .t 250x60
     .t config -width 170 -height 140
     wm geom .t {}
     update
     wm geom .t
-} 170x140+10+$Y0
+} 170x140+100+$Y0
 test unixWm-6.4 {size changes} {unix nonPortable userInteraction} {
     wm minsize .t 1 1
     update
     puts stdout "Please resize window \"t\" with the mouse (but don't move it!),"
     puts -nonewline stdout "then hit return: "
@@ -288,11 +291,11 @@
 test unixWm-8.3 {icon windows} unix {
     destroy .t
     toplevel .t -width 100 -height 30
     list [catch {wm iconwindow .t b c} msg] $msg
 } {1 {wrong # args: should be "wm iconwindow window ?pathName?"}}
-test unixWm-8.4 {icon windows} {unix failsOnUbuntu} {
+test unixWm-8.4 {icon windows} {unix failsOnUbuntu failsOnXQuarz} {
     destroy .t
     destroy .icon
     toplevel .t -width 100 -height 30
     wm geom .t +0+0
     update idletasks
@@ -633,11 +636,11 @@
     wm iconwindow .t .icon
     set result [list [catch {wm deiconify .icon} msg] $msg]
     destroy .icon
     set result
 } {1 {can't deiconify .icon: it is an icon for .t}}
-test unixWm-16.3 {Tk_WmCmd procedure, "deiconify" option} {unix failsOnUbuntu} {
+test unixWm-16.3 {Tk_WmCmd procedure, "deiconify" option} {unix failsOnUbuntu failsOnXQuarz} {
     wm iconify .t
     set result {}
     lappend result [winfo ismapped .t] [wm state .t]
     wm deiconify .t
     lappend result [winfo ismapped .t] [wm state .t]
@@ -852,11 +855,11 @@
     wm iconwindow .t .t2
     set result [list [catch {wm iconify .t2} msg] $msg]
     destroy .t2
     set result
 } {1 {can't iconify ".t2": it is an icon for ".t"}}
-test unixWm-23.5 {Tk_WmCmd procedure, "iconify" option} {unix failsOnUbuntu} {
+test unixWm-23.5 {Tk_WmCmd procedure, "iconify" option} {unix failsOnUbuntu failsOnXQuarz} {
     destroy .t2
     toplevel .t2
     wm geom .t2 +0+0
     update idletasks
     wm iconify .t2
@@ -863,11 +866,11 @@
     update idletasks
     set result [winfo ismapped .t2]
     destroy .t2
     set result
 } 0
-test unixWm-23.6 {Tk_WmCmd procedure, "iconify" option} {unix failsOnUbuntu} {
+test unixWm-23.6 {Tk_WmCmd procedure, "iconify" option} {unix failsOnUbuntu failsOnXQuarz} {
     destroy .t2
     toplevel .t2
     wm geom .t2 -0+0
     update idletasks
     set result [winfo ismapped .t2]
@@ -897,11 +900,11 @@
     list [catch {wm iconmask .t bogus} msg] $msg
 } {1 {bitmap "bogus" not defined}}
 
 test unixWm-25.1 {Tk_WmCmd procedure, "iconname" option} unix {
     list [catch {wm icon .t} msg] $msg
-} {1 {ambiguous option "icon": must be aspect, attributes, client, colormapwindows, command, deiconify, focusmodel, forget, frame, geometry, grid, group, iconbitmap, iconify, iconmask, iconname, iconphoto, iconposition, iconwindow, manage, maxsize, minsize, overrideredirect, positionfrom, protocol, resizable, sizefrom, stackorder, state, title, transient, or withdraw}}
+} {1 {ambiguous option "icon": must be aspect, attributes, client, colormapwindows, command, deiconify, focusmodel, forget, frame, geometry, grid, group, iconbadge, iconbitmap, iconify, iconmask, iconname, iconphoto, iconposition, iconwindow, manage, maxsize, minsize, overrideredirect, positionfrom, protocol, resizable, sizefrom, stackorder, state, title, transient, or withdraw}}
 test unixWm-25.2 {Tk_WmCmd procedure, "iconname" option} unix {
     list [catch {wm iconname .t 12 13} msg] $msg
 } {1 {wrong # args: should be "wm iconname window ?newName?"}}
 test unixWm-25.3 {Tk_WmCmd procedure, "iconname" option} {unix testwrapper} {
     set result {}
@@ -1225,13 +1228,13 @@
 } {{} program 0x8 user 0x2}
 test unixWm-34.3 {Tk_WmCmd procedure, "sizefrom" option} unix {
     list [catch {wm sizefrom .t none} msg]  $msg
 } {1 {bad argument "none": must be program or user}}
 if {[tk windowingsystem] == "aqua"} {
-    set result_35_1 {1 {bad argument "1": must be normal, iconic, withdrawn, or zoomed}}
+    set result_35_1 {1 {bad argument "1": must be iconic, normal, withdrawn, or zoomed}}
 } else {
-    set result_35_1 {1 {bad argument "1": must be normal, iconic, or withdrawn}}
+    set result_35_1 {1 {bad argument "1": must be iconic, normal, or withdrawn}}
 }
 test unixWm-35.1 {Tk_WmCmd procedure, "state" option} {unix notAqua} {
     list [catch {wm state .t 1} msg]  $msg
 } $result_35_1
 test unixWm-35.2 {Tk_WmCmd procedure, "state" option} unix {
@@ -1346,11 +1349,11 @@
     lappend result [wm state .t] [winfo ismapped .t]
 } {withdrawn 0 normal 1}
 
 test unixWm-39.1 {Tk_WmCmd procedure, miscellaneous} unix {
     list [catch {wm unknown .t} msg] $msg
-} {1 {bad option "unknown": must be aspect, attributes, client, colormapwindows, command, deiconify, focusmodel, forget, frame, geometry, grid, group, iconbitmap, iconify, iconmask, iconname, iconphoto, iconposition, iconwindow, manage, maxsize, minsize, overrideredirect, positionfrom, protocol, resizable, sizefrom, stackorder, state, title, transient, or withdraw}}
+} {1 {bad option "unknown": must be aspect, attributes, client, colormapwindows, command, deiconify, focusmodel, forget, frame, geometry, grid, group, iconbadge, iconbitmap, iconify, iconmask, iconname, iconphoto, iconposition, iconwindow, manage, maxsize, minsize, overrideredirect, positionfrom, protocol, resizable, sizefrom, stackorder, state, title, transient, or withdraw}}
 
 destroy .t .icon
 
 test unixWm-40.1 {Tk_SetGrid procedure, set grid dimensions before turning on grid} {unix nonPortable} {
     destroy .t
@@ -1362,18 +1365,18 @@
     wm geometry .t
 } {30x10+0+0}
 test unixWm-40.2 {Tk_SetGrid procedure, turning on grid when dimensions already set} unix {
     destroy .t
     toplevel .t
-    wm geometry .t 200x100+0+$Y0
+    wm geometry .t 200x100+100+$Y0
     listbox .t.l -height 20 -width 20
     pack .t.l -fill both -expand 1
     update
     .t.l configure -setgrid 1
     update
     wm geometry .t
-} "20x20+0+$Y0"
+} "20x20+100+$Y0"
 
 test unixWm-41.1 {ConfigureEvent procedure, internally generated size changes} unix {
     destroy .t
     toplevel .t -width 400 -height 150
     tkwait visibility .t
@@ -1434,11 +1437,11 @@
 } {configured: 130 200}
 
 # No tests for ReparentEvent or ComputeReparentGeometry; I can't figure
 # out how to exercise these procedures reliably.
 
-test unixWm-42.1 {WrapperEventProc procedure, map and unmap events} {unix failsOnUbuntu} {
+test unixWm-42.1 {WrapperEventProc procedure, map and unmap events} {unix failsOnUbuntu failsOnXQuarz} {
     destroy .t
     toplevel .t -width 400 -height 150
     wm geometry .t +0+0
     tkwait visibility .t
     set result {}
@@ -1861,11 +1864,11 @@
         update
         set x [winfo rootx .x]
         set y [winfo rooty .x]
     }
     set result [list [child eval {winfo containing [expr $x - 1]  [expr $y + 50]}] \
-	       	     [child eval {winfo containing $x [expr $y + 50]}]]
+	[child eval {winfo containing $x [expr $y + 50]}]]
     interp delete child
     set x [winfo rootx .t]
     set y [winfo rooty .t]
     lappend result [winfo containing [expr $x + 200] [expr $y + 49]] \
 	[winfo containing [expr $x + 200] [expr $y +50]]
@@ -1958,11 +1961,11 @@
 	    [winfo containing [expr $x + 150] $y] \
 	    [winfo containing [expr $x + 250] $y] \
 	    [winfo containing [expr $x + 350] $y] \
 	    [winfo containing [expr $x + 450] $y]
 } {.t .t.f .t.f.f .t {}}
-test unixWm-50.9 {Tk_CoordsToWindow procedure, unmapped windows} {unix failsOnUbuntu} {
+test unixWm-50.9 {Tk_CoordsToWindow procedure, unmapped windows} {unix failsOnUbuntu failsOnXQuarz} {
     destroy .t
     destroy .t2
     toplevel .t -width 200 -height 200 -bg green
     wm geometry .t +0+0
     tkwait visibility .t
@@ -2499,11 +2502,11 @@
 if {[tk windowingsystem] == "aqua"} {
     set result_60_1 {-alpha 1.0 -fullscreen 0 -modified 0 -notify 0\
 			 -titlepath {} -topmost 0 -transparent 0\
 			 -type unsupported}
 } else {
-    set result_60_1 {-alpha 1.0 -topmost 0 -zoomed 0 -fullscreen 0 -type {}}
+    set result_60_1 {-alpha 1.0 -fullscreen 0 -topmost 0 -type {} -zoomed 0}
 }
 test unixWm-60.1 {wm attributes - test} -constraints unix -body {
     destroy .t
     toplevel .t
     wm attributes .t

Index: tests/util.test
==================================================================
--- tests/util.test
+++ tests/util.test
@@ -1,11 +1,11 @@
 # This file is a Tcl script to test out the procedures in the file
 # tkUtil.c.  It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands

Index: tests/visual.test
==================================================================
--- tests/visual.test
+++ tests/visual.test
@@ -2,11 +2,11 @@
 # procedures in the file tkVisual.c.  It is organized in the standard
 # fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1995 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 tcltest::configure {*}$argv

Index: tests/winButton.test
==================================================================
--- tests/winButton.test
+++ tests/winButton.test
@@ -3,11 +3,11 @@
 # widgets defined in tkWinButton.c).  It is organized in the standard
 # fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 tcltest::configure {*}$argv

Index: tests/winClipboard.test
==================================================================
--- tests/winClipboard.test
+++ tests/winClipboard.test
@@ -4,12 +4,12 @@
 #
 # This file contains a collection of tests for one or more of the Tcl
 # built-in commands.  Sourcing this file into Tcl runs the tests and
 # generates output for errors.  No output means no errors were found.
 #
-# Copyright © 1997 by Sun Microsystems, Inc.
-# Copyright © 1998-2000 by Scriptics Corporation.
+# Copyright © 1997 Sun Microsystems, Inc.
+# Copyright © 1998-2000 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands

Index: tests/winDialog.test
==================================================================
--- tests/winDialog.test
+++ tests/winDialog.test
@@ -2,11 +2,11 @@
 # This file is a Tcl script to test the Windows specific behavior of
 # the common dialog boxes.  It is organized in the standard
 # fashion for Tcl tests.
 #
 # Copyright © 1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # Copyright © 1998-1999 ActiveState Corporation.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 tcltest::configure {*}$argv
@@ -589,11 +589,22 @@
         cd $cur
     }
     string equal $x [file join $dir testfile]
 } -result 1
 
-test winDialog-5.12.7 {tk_getOpenFile: initial directory: ~} -constraints {
+test winDialog-5.12.7 {tk_getOpenFile: initial directory: ~} -setup {
+    # Ensure there's at least one file in the home directory in CI environments
+    set makeEmpty [expr {![llength [glob -nocomplain -type f -directory ~ *]]}]
+    if {$makeEmpty} {
+	for {set i 1} {$i < 1000} {incr i} {
+	    # Technically a race condition...
+	    set actualFilename [format "~/tkWinDialog5_12_7_%03d" $i]
+	    if {![file exists $actualFilename]} break
+	}
+	close [open $actualFilename w]
+    }
+} -constraints {
     nt testwinevent
 } -body {
     set fn [file tail [lindex [glob -types f ~/*] 0]]
     unset -nocomplain x
     start {set x [tk_getOpenFile \
@@ -601,10 +612,14 @@
                       -initialfile $fn -title Foo]}
     then {
         Click ok
     }
     string equal $x [file normalize [file join ~ $fn]]
+} -cleanup {
+    if {$makeEmpty} {
+	file delete $actualFilename
+    }
 } -result 1
 
 test winDialog-5.12.8 {tk_getOpenFile: initial directory: .} -constraints {
     nt testwinevent
 } -body {

Index: tests/winFont.test
==================================================================
--- tests/winFont.test
+++ tests/winFont.test
@@ -5,11 +5,11 @@
 # programmatically (such as "does an underlined font appear to be
 # underlined?"); these tests attempt to exercise the code in question,
 # but there are no results that can be checked.
 #
 # Copyright © 1996-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 tcltest::configure {*}$argv

Index: tests/winMenu.test
==================================================================
--- tests/winMenu.test
+++ tests/winMenu.test
@@ -2,11 +2,11 @@
 # organized in the standard fashion for Tcl tests. This
 # file tests the Macintosh-specific features of the menu
 # system.
 #
 # Copyright © 1995-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 tcltest::configure {*}$argv

Index: tests/winSend.test
==================================================================
--- tests/winSend.test
+++ tests/winSend.test
@@ -2,11 +2,11 @@
 # other procedures in the file tkSend.c.  It is organized in the
 # standard fashion for Tcl tests.
 #
 # Copyright © 1994 Sun Microsystems, Inc.
 # Copyright © 1994-1996 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands

Index: tests/winWm.test
==================================================================
--- tests/winWm.test
+++ tests/winWm.test
@@ -3,20 +3,21 @@
 #
 # This file contains a collection of tests for one or more of the Tcl
 # built-in commands.  Sourcing this file into Tcl runs the tests and
 # generates output for errors.  No output means no errors were found.
 #
-# Copyright © 1996 by Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1996 Sun Microsystems, Inc.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 tcltest::configure {*}$argv
 tcltest::loadTestedCommands
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
+testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 test winWm-1.1 {TkWmMapWindow} -constraints win -setup {
     destroy .t
 } -body {
     toplevel .t
@@ -277,16 +278,15 @@
     destroy .t
 } -result 0
 test winWm-6.3 {wm attributes} -constraints win -setup {
     destroy .t
 } -body {
-    # This isn't quite the correct error message yet, but it works.
     toplevel .t
     wm attributes .t -foo
 } -cleanup {
     destroy .t
-} -returnCodes error -result {wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-fullscreen ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"}
+} -returnCodes error -result {bad attribute "-foo": must be -alpha, -disabled, -fullscreen, -toolwindow, -topmost, or -transparentcolor}
 
 test winWm-6.4 {wm attributes -alpha} -constraints win -setup {
     destroy .t
 } -body {
     # Expect this to return all 1.0 {} on pre-2K/XP
@@ -531,11 +531,11 @@
         rename winwm91$cmd {}
     }
     destroy .tx .t .sd
 } -result ok
 
-test winWm-9.2 "check wm forget for unmapped parent (#3205464,#2967911)" -constraints failsOnUbuntu -setup {
+test winWm-9.2 "check wm forget for unmapped parent (#3205464,#2967911)" -constraints {failsOnUbuntu failsOnXQuarz} -setup {
     destroy .t
     toplevel .t
     set winwm92 {}
     frame .t.f -background blue -height 200 -width 200
     frame .t.f.x -background red -height 100 -width 100

Index: tests/window.test
==================================================================
--- tests/window.test
+++ tests/window.test
@@ -1,10 +1,10 @@
 # This file is a Tcl script to test the procedures in the file
 # tkWindow.c.  It is organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1995 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 tcltest::configure {*}$argv
@@ -261,10 +261,42 @@
     }
     removeFile script
     list $error $msg
 } -result {0 YES}
 
+test window-2.12 {Test for ticket [9b6065d1fd] - restore Tcl [update] command} -constraints {
+    unixOrWin
+} -body {
+    set code [loadTkCommand]
+    append code {
+	after 1000 {set forever 1}
+	after 100 {destroy .}
+	after 200 {catch bell msg; puts "ringing the bell -> $msg"}
+	after 250 {update idletasks}
+	after 300 {update}
+	puts "waiting"
+	vwait forever
+	puts "done waiting"
+	catch {bell} msg
+	puts "bell -> $msg"
+	catch update msg
+	puts "update -> $msg"
+    }
+    set script [makeFile $code script]
+    if {[catch {exec [interpreter] $script -geometry 10x10+0+0} msg]} {
+        set error 1
+    } else {
+        set error 0
+    }
+    removeFile script
+    list $error $msg
+} -result {0 {waiting
+ringing the bell -> can't invoke "bell" command: application has been destroyed
+done waiting
+bell -> can't invoke "bell" command: application has been destroyed
+update -> }}
+
 
 test window-3.1 {Tk_MakeWindowExist procedure, stacking order and menubars} -constraints {
     unix testmenubar
 } -setup {
     destroy .t
@@ -338,14 +370,15 @@
     update
     # If stacking order isn't handled properly, generates an X error.
 } -cleanup {
     destroy .t
 } -result {}
+
 
 
 # cleanup
 cleanupTests
 return
 
 # Local variables:
 # mode: tcl
 # End:

Index: tests/winfo.test
==================================================================
--- tests/winfo.test
+++ tests/winfo.test
@@ -1,19 +1,19 @@
 # This file is a Tcl script to test out the "winfo" command.  It is
 # organized in the standard fashion for Tcl tests.
 #
 # Copyright © 1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
 tcltest::configure {*}$argv
 tcltest::loadTestedCommands
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 # eatColors --
 # Creates a toplevel window and allocates enough colors in it to
 # use up all the slots in the colormap.
@@ -292,11 +292,11 @@
     winfo viewable foo
 } -returnCodes error -result {bad window path name "foo"}
 test winfo-9.3 {"winfo viewable" command} -body {
     winfo viewable .
 } -result 1
-test winfo-9.4 {"winfo viewable" command} -constraints failsOnUbuntu -body {
+test winfo-9.4 {"winfo viewable" command} -constraints {failsOnUbuntu failsOnXQuarz} -body {
     wm iconify .
     winfo viewable .
 } -cleanup {
     wm deiconify .
 } -result 0

Index: tests/wm.test
==================================================================
--- tests/wm.test
+++ tests/wm.test
@@ -2,20 +2,85 @@
 # manager, including the "wm" command. It is organized in the standard fashion
 # for Tcl tests.
 #
 # Copyright © 1992-1994 The Regents of the University of California.
 # Copyright © 1994-1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # All rights reserved.
 
 # This file tests window manager interactions that work across platforms.
 # Window manager tests that only work on a specific platform should be placed
 # in unixWm.test or winWm.test.
 
 package require tcltest 2.2
 eval tcltest::configure $argv
 tcltest::loadTestedCommands
+
+image create photo icon -data {
+    iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAA
+    CBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/w
+    D/AP+gvaeTAAAACXBIWXMAArQNAAK0DQEdFIm+AAAJQElEQVRYw+WXW2xdV5nHf/ty7lc
+    f2/FxYsdOnMSNC0HTpDiRKJWAQjWCEQNUSEAFfUOiQqrEC2+IxwpemDLSzNBBCCQeQEKq
+    RJgBSikiuGlN22TqhsR27OPL8eWc43Pdt7X22osHHydOm4FBPM6Slr69paX9/32Xtb614
+    f/7MP6vC3O5f8L3G7HJyZPHBwfz5wrF7HQ6nRwxLTOhQuU4PW+z3eq9Xa+33rq9cms7k8
+    pHjvfS3w8wOfk52u1u8oHpiUff897JJ8+dO/nI6LHho6OjQ3ahkMYwTTZ2O2zXutS3G/7
+    ayubq7Vtr/7Ve2f7RytLam4ViXq1t/vRvB0ilPsjzz3+LZ5/9j7MzM5Nf/8hj5//5H97/
+    YNbK5hkfTFLMxAEQQvD766v0yBGIEBEEuPUGi9dv7lx77cb3Vm9vfqc0WNi9evUKWr/xL
+    h3rfuLj45+l0bjM7m768U98/OJ/fulLH/3wiemxeCafxRcKw7TJxKC+12RpbYdAx7HsOC
+    rSRNpg+sQQj1w8nS0N5h8JAvm+rWr99ZmZB2qWdZq9vWt/GWBm5im+9rUn6HRGPv7EE4/
+    ++2P/eOFkV0FkJTDQgCaXTbO1tcV2R2EmCxBJQixs2+R9EwV00MFAceJE2ZiZOT7VaTsP
+    LyxU5orFTK1cfphq9bX7A8zOfoV8Ps3c3NsXPvWpD37vc5//0ETNt8gNjDAzlsdAE0vli
+    TCRxEhnC2CaRIZNMmZiaonv9mh1PcrDJQZzCfK5OGNjQ8e2tvZO37y5+ctk0naq1fn7A4
+    yOnmd5uVp4/PGHn/vylz8xe+zoEIP5JAMpA0OHeK6DG4TEk2li8ThaQxRpIg0q6DGUNjg
+    6UuLYSInhYoYoigiCgHQ6TrGYnlpd3Q1ffvk3L128+ITe2Hj1XoBLl55menqcbDb1haee
+    evyrDz102tJaE7ctLBMqG1X23Ag7kcKOJzAADSilCVWEZdmMDaXJJCxSiRimaaK1RkqJ7
+    /uUSlk6Hed0oxG9HI9bm+Pjs2xsvIp5AKC15oUX/lA8f/7MF2dnz8YADMNASslypYqrUx
+    SHyqSy+f31hzaRZRpMDKVYr+7y4usVri1WWavWCWSIZZkYhoFSIRcuTI1MTAw9OTf33Tu
+    7zz54SCRinD17/Pzs7AMPFQqZPlTE8vo2DlmGhgbo12BffD/8SmukitiuNxHKoDwyzPJG
+    nTdXmtiWwdnRNCN5GxWGDA/nOH26/NGpqSfHgPU7AJcuPc0nP/kBrl698YGZmYmMEIJmx
+    6Hn+my0DUZGC6gIzEOnhu4Lh2GEbRocGyxRSO/7c3QgiRuEVOtdEvEQrSN8IVEq5MSJ4Y
+    lSKX3OMKJ14G4KnnnmM9bkZPk92VyKy3M3eentJjd3FUYyjxuEeELt7/NoP+eBVAipCFX
+    EsYE4xcydYFIeSHKynOXhUwM0mh32egH1tsdL16oo007kcskHs7kYly49fRcALqby+fQo
+    pklkZ4jHY3g6gQgjHF/QcgQdV+7DHJoGmnzSQuvD0QGlIsJQkU4luLXR4kgxxcRgjM1mQ
+    CyZHrv0sUe4JwKFXMmu7/VSXV9xaXqI0YzC8328QOJ4gq4raHQDGt2AtitwfIEbSAwibO
+    vdJ7pSCiElR3IxGh2X5Y0GV66v0wnAsq3MN5759L1FqKMoCkQoX19u0QkkD47lKSYiTh1
+    NoSLYafu0ehrTNNBaE2mNUop2z+DEUJKBbPxecSEIgoAoUjwwmmZpdZPlmuL4oIFWkbx8
+    rXIvQMfZ9p2e1xBCstOJcFe6nB1NcWokhW1ZHMkazK90qXXDfZFII0NFIBW/XQiZHraoN
+    bsU81mmjhbxfZ8gCAiCgELKQitJGCoIQ6SQO//2ze/fm4Kf/Px50dzr3Aoch1Ap2o4kn8
+    tgW/sHynAxzcVTBQYzFp4v6boBjidwfcFCpcmPf7/Oz+ZrvPBalb12D9/370DUGk1evr6
+    NacWIfD/yveDmXq3F3NxzdwH+5dkfUq8155rb9dA2QcqQcjFx57DRGgaySR47d4RHZ0pY
+    eh/C9QSOJ3EECGWw3fJZ323j+x6e5xH4Pgu3d6g0FMWUjdvu7bo9/5oK1d0IzM09hwhCG
+    rvNubXFylI2pum4AZXtDqEURFGE1hoNxGMW5ZyB22nS8wQ9r1+QvsDzBc1uQGW7jee6eN
+    4+RMfxMdHkYgatWmtur9ZaOnD8TgQMA27c+uH68s3KT8O9BoYBv3pjkxuVGo7Tw+1/MAh
+    83lreYm1P9r3fT4XjSVxf4voC1/NwHAfXdXFcB891KGVjhO2e16q3fzR2cjQwDPPeZrSx
+    8SqXL2/RqDU2EnH7I8dPjQ8v7Tqs1RwmSzEsQoQQSBHw1lKVha0AEUb4IiQQIb4I8YUkk
+    CHTQwa5WIjne9xY2mT+VouRfI7NxfVfrK8sfTuRSAavXP3Xd7fjavWPRq1+3TeiQTVcGn
+    h0oHwktlZzmBq0SNsRQgiuXLvNL/+nQU/aBFL1xSW+kAghEb5PEkE5q3Bdl7dv72LGCrT
+    Xdzf+9Nb8N5dXfrG6Wf1jeNDP3nkjigOFWm2xpvx0+tjI8LnMYMnMxQT5eIjruVye36LS
+    TRAqRSD3vZdCIqUgEj5R4CEDj2O5kMZei3rHoLXV6Sy88cp3Fhf/ew6IAAGE9wOIARmtw
+    9Tu7vKa1yY+Wiqeee+ZYdsi4HdvrjK/HiKUiZQhoZREQhDJAC18tPSIhEfouwSuQ9cx2V
+    xpNK/PX/n+4uKvXwQdAAHgA/J+AAaQABJRJOydnVsrzZ1O13eMcSuezC61LJzQRgY+KvC
+    JhI+WPpH0IAywIkEhaVIupAhdHS0t3F66Nv/iD9bW/nAFtAM4QA9wAXX3RnEvQBoYODSL
+    +fzEmalTsx+emjl3YWjsaMlMpcwg0ggZEimFoSNsI8JSCtF1wtpmdWt1aeGVSuW133leY
+    wNoA01gr297BzVwv/8CA0gBBaDYtzkw87ns6PhI+czM0JHjp/PFUjmZSmUM07RCKUPP6X
+    Vae/Vqfbdys1ZbvOX5ja2+ULcP0Opbt18H/G8Ah+shDWQPzVQ/RSnLTGRsO5U0TMuMVKj
+    C0PUjLd1+fgPAOxTybl9YcvdC9VcBDobV3x0JINm3MfYbmdX/hu57FfZFDgot6Fe8eqfw
+    3wLwzvVmX9jsvx8AHEAcnn91/BlySEFKTpuCtgAAABN0RVh0QXV0aG9yAHdhcnN6YXdpY
+    W5rYQy+S5cAAABYdEVYdENvcHlyaWdodABDQzAgUHVibGljIERvbWFpbiBEZWRpY2F0aW
+    9uIGh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL3B1YmxpY2RvbWFpbi96ZXJvLzEuMC/
+    G4735AAAAIXRFWHRDcmVhdGlvbiBUaW1lADIwMTAtMDMtMjlUMDg6MDg6MzD47LxwAAAA
+    JXRFWHRkYXRlOmNyZWF0ZQAyMDIxLTA4LTE1VDIwOjU0OjM5LTA0OjAwNBT3DQAAACV0R
+    Vh0ZGF0ZTptb2RpZnkAMjAyMS0wOC0xNVQyMDo1NDoxMS0wNDowMDSDBqsAAADIelRYdE
+    Rlc2NyaXB0aW9uAAAY042OwQqCQBCGn6B3GOy+Cl0qTAjEc1HRJVhWHXUrd2pmLXr7tDr
+    VpcMP838w/F+wxxxyprsgB2ALclAxtRAbaBirRdB4f5mHoTeuJlUxYoly8nRRxHW4HahO
+    30SvmI5Y+CCBF4dPhzg0CYwOLs45GdKfG+sKhBuy2H4xUlM1i76+BhcBwwirLj/bAlJqj
+    XXzP9UyxmuHzp8feiknLPW6Q/H9moy3yK1oqvROUE2yH99suX45PwEyf2MTOoCNrQAAAB
+    l0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABWdEVYdFNvdXJjZQBodHR
+    wczovL29wZW5jbGlwYXJ0Lm9yZy9kZXRhaWwvMzUyMzMvdGFuZ28taW5ldHJuZXQtd2Vi
+    LWJyb3dzZXItYnktd2Fyc3phd2lhbmth5nAuRgAAACB0RVh0VGl0bGUAdGFuZ28gaW5ld
+    HJuZXQgd2ViIGJyb3dzZXLyr62TAAAAAElFTkSuQmCC
+}
 
 wm deiconify .
 if {![winfo ismapped .]} {
     tkwait visibility .
 }
@@ -25,11 +90,11 @@
     toplevel .t -width 100 -height 50
     wm geom .t +0+0
     update
 }
 
-testConstraint failsOnUbuntu [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match linux $::env(TRAVIS_OS_NAME)]}]
+testConstraint failsOnUbuntu [expr {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}]
 testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }]
 
 # [raise] and [lower] may return before the window manager has completed the
 # operation. The raiseDelay procedure idles for a while to give the operation
 # a chance to complete.
@@ -57,11 +122,11 @@
     wm
 } -result {wrong # args: should be "wm option window ?arg ...?"}
 # Next test will fail every time set of subcommands is changed
 test wm-1.2 {Tk_WmObjCmd procedure, miscellaneous errors} -returnCodes error -body {
     wm foo
-} -result {bad option "foo": must be aspect, attributes, client, colormapwindows, command, deiconify, focusmodel, forget, frame, geometry, grid, group, iconbitmap, iconify, iconmask, iconname, iconphoto, iconposition, iconwindow, manage, maxsize, minsize, overrideredirect, positionfrom, protocol, resizable, sizefrom, stackorder, state, title, transient, or withdraw}
+} -result {bad option "foo": must be aspect, attributes, client, colormapwindows, command, deiconify, focusmodel, forget, frame, geometry, grid, group, iconbadge, iconbitmap, iconify, iconmask, iconname, iconphoto, iconposition, iconwindow, manage, maxsize, minsize, overrideredirect, positionfrom, protocol, resizable, sizefrom, stackorder, state, title, transient, or withdraw}
 test wm-1.3 {Tk_WmObjCmd procedure, miscellaneous errors} -returnCodes error -body {
     wm command
 } -result {wrong # args: should be "wm option window ?arg ...?"}
 test wm-1.4 {Tk_WmObjCmd procedure, miscellaneous errors} -returnCodes error -body {
     wm aspect bogus
@@ -126,25 +191,21 @@
 ### wm attributes ###
 test wm-attributes-1.1 {usage} -returnCodes error -body {
     wm attributes
 } -result {wrong # args: should be "wm option window ?arg ...?"}
 test wm-attributes-1.2.1 {usage} -constraints win -returnCodes error -body {
-    # This is the wrong error to output - unix has it right, but it's
-    # not critical.
     wm attributes . _
-} -result {wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-fullscreen ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"}
+} -result {bad attribute "_": must be -alpha, -disabled, -fullscreen, -toolwindow, -topmost, or -transparentcolor}
 test wm-attributes-1.2.2 {usage} -constraints win -returnCodes error -body {
     wm attributes . -alpha 1.0 -disabled
 } -result {wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-fullscreen ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"}
 test wm-attributes-1.2.3 {usage} -constraints win -returnCodes error -body {
-    # This is the wrong error to output - unix has it right, but it's
-    # not critical.
     wm attributes . -to
-} -result {wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-fullscreen ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"}
+} -result {bad attribute "-to": must be -alpha, -disabled, -fullscreen, -toolwindow, -topmost, or -transparentcolor}
 test wm-attributes-1.2.4 {usage} -constraints {unix notAqua} -returnCodes error -body {
     wm attributes . _
-} -result {bad attribute "_": must be -alpha, -topmost, -zoomed, -fullscreen, or -type}
+} -result {bad attribute "_": must be -alpha, -fullscreen, -topmost, -type, or -zoomed}
 test wm-attributes-1.2.5 {usage} -constraints aqua -returnCodes error -body {
     wm attributes . _
 } -result {bad attribute "_": must be -alpha, -fullscreen, -modified, -notify, -titlepath, -topmost, -transparent, or -type}
 
 
@@ -726,10 +787,83 @@
     lappend result [wm group .t]
     wm group .t {}
     lappend result [wm group .t]
 } -result [list {} . {}]
 
+
+### wm iconbadge ###
+test wm-iconbadge-1.1 {usage} -body {
+    wm iconbadge
+} -returnCodes error -result {wrong # args: should be "wm option window ?arg ...?"}
+test wm-iconbadge-1.2 {usage} -body {
+    frame .f
+    set ::tk::icons::base_icon(.f) icon
+    wm iconbadge .f icon
+} -cleanup {
+    destroy .f
+    unset ::tk::icons::base_icon(.f)
+} -returnCodes error -result {window ".f" isn't a top-level window}
+test wm-iconbadge-1.3 {::tk::icons::base_icon($win) must be set on X11} -constraints {
+    x11
+} -setup {
+    unset -nocomplain ::tk::icons::base_icon(.)
+} -body {
+    wm iconbadge . !
+} -returnCodes error -result {::tk::icons::base_icon(.) must be set on X11}
+test wm-iconbadge-1.4 {::tk::icons::base_icon($win) must be a Tk photo on X11} -constraints {
+    x11
+} -setup {
+    catch {image delete book}
+} -body {
+    set ::tk::icons::base_icon(.) book
+    wm iconbadge . 27
+} -returnCodes error -result {can't use "book" as iconphoto: not a photo image}
+test wm-iconbadge-1.5 {illegal badge number} -body {
+    image create photo book -data {
+        R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAAC
+        wAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IM
+        QCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc
+        0yv+DVSEUuFxIAOw==
+    }
+    set ::tk::icons::base_icon(.) book
+    wm iconbadge . illegal
+} -cleanup {
+    image delete book
+} -returnCodes error -result {can't use "illegal" as icon badge}
+test wm-iconbadge-1.6 {non-integer badge number} -body {
+    image create photo book -data {
+        R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAAC
+        wAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IM
+        QCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc
+        0yv+DVSEUuFxIAOw==
+    }
+    set ::tk::icons::base_icon(.) book
+    wm iconbadge . 3.2
+} -cleanup {
+    image delete book
+} -returnCodes error -result {can't use "3.2" as icon badge}
+test wm-iconbadge-1.7 {negative or zero badge number} -body {
+    image create photo book -data {
+        R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAAC
+        wAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IM
+        QCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc
+        0yv+DVSEUuFxIAOw==
+    }
+    set ::tk::icons::base_icon(.) book
+    wm iconbadge . 0
+} -cleanup {
+    image delete book
+} -returnCodes error -result {can't use "0" as icon badge}
+test wm-iconbadge-1.8 {usage, no need to call iconphoto on aqua or win32} -constraints {
+    aquaOrWin32
+} -body {
+    wm iconbadge . 3
+    wm iconbadge . 5000
+    wm iconbadge . !
+    wm iconbadge . ""
+} -result {}
+
 
 ### wm iconbitmap ###
 test wm-iconbitmap-1.1 {usage} -returnCodes error -body {
     wm iconbitmap
 } -result {wrong # args: should be "wm option window ?arg ...?"}
@@ -808,11 +942,11 @@
     wm iconify .t2
 } -returnCodes error -cleanup {
     destroy .t2 .r.f
 } -result {can't iconify ".t2": it is an embedded window}
 
-test wm-iconify-3.1 {iconify behavior} -constraints failsOnUbuntu -body {
+test wm-iconify-3.1 {iconify behavior} -constraints {failsOnUbuntu failsOnXQuarz} -body {
     toplevel .t2
     wm geom .t2 -0+0
     update idletasks
     set result [winfo ismapped .t2]
     wm iconify .t2
@@ -882,10 +1016,11 @@
     wm iconphoto . -default [image create photo -file {}]
 } -match {glob} -result {failed to create an iconphoto with image *}
 test wm-iconphoto-1.5.2 {usage} -constraints x11 -body {
     wm iconphoto . -default [image create photo -file {}]
 } -result {}
+
 
 # All other iconphoto tests are platform specific
 
 
 ### wm iconposition ###
@@ -1416,11 +1551,11 @@
     wm stackorder .
 } -result {.}
 
 deleteWindows
 
-test wm-stackorder-3.1 {unmapped toplevel} -constraints failsOnUbuntu -body {
+test wm-stackorder-3.1 {unmapped toplevel} -constraints {failsOnUbuntu failsOnXQuarz} -body {
     toplevel .t1 ; update
     toplevel .t2 ; update
     wm iconify .t1
     wm stackorder .
 } -cleanup {
@@ -1737,11 +1872,11 @@
     list [wm state .subject] [winfo ismapped .subject]
 } -cleanup {
     deleteWindows
 } -result {withdrawn 0}
 test wm-transient-4.2 {already mapped transient toplevel
-        is withdrawn if toplevel is iconic} -constraints failsOnUbuntu -body {
+        is withdrawn if toplevel is iconic} -constraints {failsOnUbuntu failsOnXQuarz} -body {
     toplevel .top
     raiseDelay
     wm iconify .top
     update idletasks
     toplevel .subject
@@ -1751,11 +1886,11 @@
     list [wm state .subject] [winfo ismapped .subject]
 } -cleanup {
     deleteWindows
 } -result {withdrawn 0}
 test wm-transient-4.3 {iconify/deiconify on the toplevel
-        does a withdraw/deiconify on the transient} -constraints failsOnUbuntu -setup {
+        does a withdraw/deiconify on the transient} -constraints {failsOnUbuntu failsOnXQuarz} -setup {
     set results [list]
 } -body {
     toplevel .top
     toplevel .subject
     update idletasks
@@ -2004,19 +2139,19 @@
     wm iconify .t
     wm state .t
 } -cleanup {
     deleteWindows
 } -result {iconic}
-test wm-state-2.8 {state change after map} -constraints failsOnUbuntu -body {
+test wm-state-2.8 {state change after map} -constraints {failsOnUbuntu failsOnXQuarz} -body {
     toplevel .t
     update
     wm state .t iconic
     wm state .t
 } -cleanup {
     deleteWindows
 } -result {iconic}
-test wm-state-2.9 {state change after map} -constraints failsOnUbuntu -body {
+test wm-state-2.9 {state change after map} -constraints {failsOnUbuntu failsOnXQuarz} -body {
     toplevel .t
     update
     wm iconify .t
     wm state .t
 } -cleanup {

Index: tests/xmfbox.test
==================================================================
--- tests/xmfbox.test
+++ tests/xmfbox.test
@@ -4,11 +4,11 @@
 #	when the tk_strictMotif flag is set. Because the file dialog
 #	runs in a modal loop, the only way to test it sufficiently is
 #	to call the internal Tcl procedures in xmfbox.tcl directly.
 #
 # Copyright © 1997 Sun Microsystems, Inc.
-# Copyright © 1998-1999 by Scriptics Corporation.
+# Copyright © 1998-1999 Scriptics Corporation.
 # Contributions from Don Porter, NIST, 2002.  (not subject to US copyright)
 # All rights reserved.
 
 package require tcltest 2.2
 namespace import ::tcltest::*
@@ -89,23 +89,23 @@
     cleanup
     file mkdir ./~nosuchuser1
     set x [tk::MotifFDialog_Create foo open {}]
     $::tk::dialog::file::foo(fEnt) delete 0 end
     $::tk::dialog::file::foo(fEnt) insert 0 [pwd]/~nosuchuser1
-    set kk [tk::MotifFDialog_InterpFilter $x]
-} -result "$testPWD/~nosuchuser1 *"
+    file normalize [file join {*}[tk::MotifFDialog_InterpFilter $x]]
+} -result "$testPWD/~nosuchuser1/*"
 
 test xmfbox-2.2 {tk::MotifFDialog_InterpFilter, ~ in file names} -constraints {
     unix
 } -body {
     cleanup
     close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
     set x [tk::MotifFDialog_Create foo open {}]
     $::tk::dialog::file::foo(fEnt) delete 0 end
     $::tk::dialog::file::foo(fEnt) insert 0 [pwd]/~nosuchuser1
-    set kk [tk::MotifFDialog_InterpFilter $x]
-} -result "$testPWD ./~nosuchuser1"
+    file normalize [file join {*}[tk::MotifFDialog_InterpFilter $x]]
+} -result "$testPWD/~nosuchuser1"
 
 test xmfbox-2.3 {tk::MotifFDialog_Update, ~ in file names} -constraints {
     unix
 } -body {
     cleanup
@@ -136,11 +136,11 @@
     set x [tk::MotifFDialog_Create foo open {}]
     set i [lsearch [$::tk::dialog::file::foo(fList) get 0 end] ~nosuchuser1]
     $::tk::dialog::file::foo(fList) selection clear 0 end
     $::tk::dialog::file::foo(fList) selection set $i
     tk::MotifFDialog_BrowseFList $x
-    $::tk::dialog::file::foo(sEnt) get
+    file normalize [$::tk::dialog::file::foo(sEnt) get]
 } -result "$testPWD/~nosuchuser1"
 
 test xmfbox-2.6 {tk::MotifFDialog_ActivateFList, ~ in file names} -constraints {
     unix
 } -body {
@@ -151,11 +151,11 @@
     $::tk::dialog::file::foo(fList) selection clear 0 end
     $::tk::dialog::file::foo(fList) selection set $i
     tk::MotifFDialog_BrowseFList $x
     tk::MotifFDialog_ActivateFList $x
     list $::tk::dialog::file::foo(selectPath) \
-	    $::tk::dialog::file::foo(selectFile) $tk::Priv(selectFilePath)
+	    $::tk::dialog::file::foo(selectFile) [file normalize $tk::Priv(selectFilePath)]
 } -result "$testPWD ~nosuchuser1 $testPWD/~nosuchuser1"
 
 # cleanup
 cleanup
 cleanupTests

Index: unix/Makefile.in
==================================================================
--- unix/Makefile.in
+++ unix/Makefile.in
@@ -110,11 +110,11 @@
 
 # The directory containing the Tcl library archive file appropriate
 # for this version of Tk:
 TCL_BIN_DIR		= @TCL_BIN_DIR@
 
-# The linker flags needed to link in the Tcl library (ex: -ltcl8.2)
+# The linker flags needed to link in the Tcl library (ex: -ltcl8.7)
 TCL_LIB_FLAG		= @TCL_LIB_FLAG@
 
 # Flag, 1: we're building a shared lib, 0 we're not
 TK_SHARED_BUILD		= @TK_SHARED_BUILD@
 
@@ -187,11 +187,11 @@
 #KEYSYM_FLAGS		= -DREDO_KEYSYM_LOOKUP
 
 # Tk does not used deprecated Tcl constructs so it should
 # compile fine with -DTCL_NO_DEPRECATED. To remove its own
 # set of deprecated code uncomment the second line.
-NO_DEPRECATED_FLAGS	= -DTCL_NO_DEPRECATED
+NO_DEPRECATED_FLAGS	=
 #NO_DEPRECATED_FLAGS	= -DTCL_NO_DEPRECATED -DTK_NO_DEPRECATED
 
 # Some versions of make, like SGI's, use the following variable to
 # determine which shell to use for executing commands:
 SHELL			= @SHELL@
@@ -245,10 +245,12 @@
 
 TK_STUB_LIB_FLAG	= @TK_STUB_LIB_FLAG@
 #TK_STUB_LIB_FLAG	= -ltkstub
 
 TK_LIB_FILE		= @TK_LIB_FILE@
+TK_LIB_FILE_TCL8	= @TK_LIB_FILE_TCL8@
+TK_LIB_FILE_TCL9	= @TK_LIB_FILE_TCL9@
 #TK_LIB_FILE		= libtk.a
 
 # Generic lib name used in rules that apply to tcl and tk
 LIB_FILE		= ${TK_LIB_FILE}
 
@@ -283,11 +285,11 @@
 # with cc, and the second is for use when running ld directly.
 CC_SEARCH_FLAGS	= @CC_SEARCH_FLAGS@
 LD_SEARCH_FLAGS	= @LD_SEARCH_FLAGS@
 
 # support for embedded libraries on Darwin / Mac OS X
-DYLIB_INSTALL_DIR	= ${LIB_RUNTIME_DIR}
+DYLIB_INSTALL_DIR	= $(libdir)
 
 # support for building the Aqua resource file
 TK_RSRC_FILE		= @TK_RSRC_FILE@
 WISH_RSRC_FILE		= @WISH_RSRC_FILE@
 REZ			= @REZ@
@@ -331,11 +333,11 @@
 
 CC_SWITCHES_NO_STUBS = -I${UNIX_DIR} -I${GENERIC_DIR} -I${BMAP_DIR} \
 ${@TK_WINDOWINGSYSTEM@_INCLUDES} ${CFLAGS} ${CFLAGS_WARNING} \
 ${SHLIB_CFLAGS} -I${TCL_GENERIC_DIR} -I${TCL_PLATFORM_DIR} ${AC_FLAGS} \
 ${PROTO_FLAGS} ${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS} ${KEYSYM_FLAGS} \
-${NO_DEPRECATED_FLAGS} @EXTRA_CC_SWITCHES@
+${NO_DEPRECATED_FLAGS} -DTCL_UTF_MAX=3 @EXTRA_CC_SWITCHES@
 
 CC_SWITCHES = $(CC_SWITCHES_NO_STUBS) @TCL_STUB_FLAGS@
 
 APP_CC_SWITCHES = $(CC_SWITCHES_NO_STUBS) @EXTRA_APP_CC_SWITCHES@
 
@@ -387,27 +389,26 @@
 STUB_OBJS = tkStubInit.o
 
 STUB_LIB_OBJS = tkStubLib.o ttkStubLib.o
 
 X11_OBJS = tkUnix.o tkUnix3d.o tkUnixButton.o tkUnixColor.o tkUnixConfig.o \
-	tkUnixCursor.o tkUnixDraw.o tkUnixEmbed.o tkUnixEvent.o \
+	tkUnixCursor.o tkUnixDraw.o tkUnixEmbed.o tkUnixEvent.o tkIcu.o \
 	tkUnixFocus.o  $(FONT_OBJS) tkUnixInit.o tkUnixKey.o tkUnixMenu.o \
 	tkUnixMenubu.o tkUnixScale.o tkUnixScrlbr.o tkUnixSelect.o \
-	tkUnixSend.o tkUnixWm.o tkUnixXId.o
+	tkUnixSend.o tkUnixSysNotify.o tkUnixSysTray.o tkUnixWm.o tkUnixXId.o
 
 AQUA_OBJS = tkMacOSXBitmap.o tkMacOSXButton.o tkMacOSXClipboard.o \
 	tkMacOSXColor.o tkMacOSXConfig.o tkMacOSXCursor.o tkMacOSXDebug.o \
 	tkMacOSXDialog.o tkMacOSXDraw.o tkMacOSXEmbed.o tkMacOSXEntry.o \
-	tkMacOSXEvent.o tkMacOSXFont.o tkMacOSXHLEvents.o tkMacOSXImage.o \
-	tkMacOSXInit.o tkMacOSXKeyboard.o tkMacOSXKeyEvent.o \
-	tkMacOSXMenu.o \
-	tkMacOSXMenubutton.o tkMacOSXMenus.o tkMacOSXMouseEvent.o \
-	tkMacOSXNotify.o tkMacOSXRegion.o tkMacOSXScrlbr.o tkMacOSXSend.o \
-	tkMacOSXServices.o tkMacOSXSubwindows.o tkMacOSXWindowEvent.o \
-	tkMacOSXWm.o tkMacOSXXStubs.o \
-	tkFileFilter.o tkMacWinMenu.o tkPointer.o tkUnix3d.o tkUnixScale.o \
-	xcolors.o xdraw.o xgc.o ximage.o xutil.o \
+	tkMacOSXEvent.o tkMacOSXFileTypes.o tkMacOSXFont.o tkMacOSXHLEvents.o \
+        tkMacOSXImage.o tkMacOSXInit.o tkMacOSXKeyboard.o tkMacOSXKeyEvent.o \
+	tkMacOSXMenu.o tkMacOSXMenubutton.o tkMacOSXMenus.o \
+        tkMacOSXMouseEvent.o tkMacOSXNotify.o tkMacOSXPrint.o tkMacOSXRegion.o \
+	tkMacOSXScrlbr.o tkMacOSXSend.o tkMacOSXServices.o \
+	tkMacOSXSubwindows.o tkMacOSXSysTray.o tkMacOSXWindowEvent.o tkMacOSXWm.o \
+	tkMacOSXXStubs.o tkFileFilter.o tkMacWinMenu.o tkPointer.o tkUnix3d.o \
+	tkUnixScale.o xcolors.o xdraw.o xgc.o ximage.o xutil.o \
 	ttkMacOSXTheme.o
 
 AQUA_TKTEST_OBJS = tkMacOSXTest.o
 
 OBJS =  $(GENERIC_OBJS) $(WIDG_OBJS) $(CANV_OBJS) $(IMAGE_OBJS) $(TEXT_OBJS) \
@@ -505,36 +506,36 @@
 	$(UNIX_DIR)/tkUnixButton.c $(UNIX_DIR)/tkUnixColor.c \
 	$(UNIX_DIR)/tkUnixConfig.c \
 	$(UNIX_DIR)/tkUnixCursor.c \
 	$(UNIX_DIR)/tkUnixDraw.c \
 	$(UNIX_DIR)/tkUnixEmbed.c $(UNIX_DIR)/tkUnixEvent.c \
-	$(UNIX_DIR)/tkUnixFocus.c \
+	$(UNIX_DIR)/tkUnixFocus.c $(GENERIC_DIR)/tkIcu.c \
 	$(UNIX_DIR)/tkUnixRFont.c \
 	$(UNIX_DIR)/tkUnixFont.c $(UNIX_DIR)/tkUnixInit.c \
 	$(UNIX_DIR)/tkUnixKey.c \
 	$(UNIX_DIR)/tkUnixMenu.c $(UNIX_DIR)/tkUnixMenubu.c \
 	$(UNIX_DIR)/tkUnixScale.c $(UNIX_DIR)/tkUnixScrlbr.c \
-	$(UNIX_DIR)/tkUnixSelect.c \
-	$(UNIX_DIR)/tkUnixSend.c $(UNIX_DIR)/tkUnixWm.c \
-	$(UNIX_DIR)/tkUnixXId.c
+	$(UNIX_DIR)/tkUnixSelect.c $(UNIX_DIR)/tkUnixSend.c \
+	$(UNIX_DIR)/tkUnixSysNotify $(UNIX_DIR)/tkUnixSysTray.c \
+	$(UNIX_DIR)/tkUnixWm.c $(UNIX_DIR)/tkUnixXId.c
 
 AQUA_SRCS = \
 	$(MAC_OSX_DIR)/tkMacOSXBitmap.c $(MAC_OSX_DIR)/tkMacOSXButton.c \
 	$(MAC_OSX_DIR)/tkMacOSXClipboard.c $(MAC_OSX_DIR)/tkMacOSXColor.c \
 	$(MAC_OSX_DIR)/tkMacOSXConfig.c $(MAC_OSX_DIR)/tkMacOSXCursor.c \
 	$(MAC_OSX_DIR)/tkMacOSXDebug.c $(MAC_OSX_DIR)/tkMacOSXDialog.c \
 	$(MAC_OSX_DIR)/tkMacOSXDraw.c $(MAC_OSX_DIR)/tkMacOSXEmbed.c \
 	$(MAC_OSX_DIR)/tkMacOSXEntry.c $(MAC_OSX_DIR)/tkMacOSXEvent.c \
-	$(MAC_OSX_DIR)/tkMacOSXFont.c $(MAC_OSX_DIR)/tkMacOSXHLEvents.c \
-	$(MAC_OSX_DIR)/tkMacOSXImage.c \
+	$(MAC_OSX_DIR)/tkMacOSXFont.c $(MAC_OSX_DIR)/tkMacOSXFileTypes.c\
+	$(MAC_OSX_DIR)/tkMacOSXHLEvents.c $(MAC_OSX_DIR)/tkMacOSXImage.c \
 	$(MAC_OSX_DIR)/tkMacOSXInit.c $(MAC_OSX_DIR)/tkMacOSXKeyboard.c \
 	$(MAC_OSX_DIR)/tkMacOSXKeyEvent.c \
 	$(MAC_OSX_DIR)/tkMacOSXMenu.c \
 	$(MAC_OSX_DIR)/tkMacOSXMenubutton.c $(MAC_OSX_DIR)/tkMacOSXMenus.c \
 	$(MAC_OSX_DIR)/tkMacOSXMouseEvent.c $(MAC_OSX_DIR)/tkMacOSXNotify.c \
 	$(MAC_OSX_DIR)/tkMacOSXRegion.c $(MAC_OSX_DIR)/tkMacOSXScrlbr.c \
-	$(MAC_OSX_DIR)/tkMacOSXServices.c \
+	$(MAC_OSX_DIR)/tkMacOSXServices.c $(MAC_OSX_DIR)/tkMacOSXSysTray.c \
 	$(MAC_OSX_DIR)/tkMacOSXSend.c $(MAC_OSX_DIR)/tkMacOSXSubwindows.c \
 	$(MAC_OSX_DIR)/tkMacOSXTest.c $(MAC_OSX_DIR)/tkMacOSXWindowEvent.c \
 	$(MAC_OSX_DIR)/tkMacOSXWm.c $(MAC_OSX_DIR)/tkMacOSXXStubs.c \
 	$(GENERIC_DIR)/tkFileFilter.c $(GENERIC_DIR)/tkMacWinMenu.c \
 	$(GENERIC_DIR)/tkPointer.c $(UNIX_DIR)/tkUnix3d.c \
@@ -541,10 +542,32 @@
 	$(UNIX_DIR)/tkUnixScale.c $(XLIB_DIR)/xcolors.c $(XLIB_DIR)/xdraw.c \
 	$(XLIB_DIR)/xgc.c $(XLIB_DIR)/ximage.c $(XLIB_DIR)/xutil.c \
 	$(TTK_DIR)/ttkMacOSXTheme.c
 
 SRCS = $(GENERIC_SRCS) $(@TK_WINDOWINGSYSTEM@_SRCS) @PLAT_SRCS@
+
+###
+# Tip 430 - ZipFS Modifications
+###
+
+TK_ZIP_FILE		= @TK_ZIP_FILE@
+TK_VFS_ROOT		= libtk.vfs
+TK_VFS_PATH		= ${TK_VFS_ROOT}/tk_library
+
+HOST_CC			= @CC_FOR_BUILD@
+HOST_EXEEXT		= @EXEEXT_FOR_BUILD@
+HOST_OBJEXT		= @OBJEXT_FOR_BUILD@
+ZIPFS_BUILD		= @ZIPFS_BUILD@
+NATIVE_ZIP		= @ZIP_PROG@
+ZIP_PROG_OPTIONS	= @ZIP_PROG_OPTIONS@
+ZIP_PROG_VFSSEARCH	= @ZIP_PROG_VFSSEARCH@
+SHARED_BUILD		= @SHARED_BUILD@
+INSTALL_LIBRARIES	= @INSTALL_LIBRARIES@
+INSTALL_MSGS		= @INSTALL_MSGS@
+
+ZIP_INSTALL_OBJS	= @ZIP_INSTALL_OBJS@
+
 
 AQUA_RESOURCES = \
 	$(MAC_OSX_DIR)/tkAboutDlg.r $(MAC_OSX_DIR)/tkMacOSXCursors.r \
 	$(MAC_OSX_DIR)/tkMacOSXXCursors.r
 
@@ -554,11 +577,12 @@
 
 AQUA_XLIB_HDRS = $(XLIB_DIR)/X11/*.h $(XLIB_DIR)/xbytes.h
 
 AQUA_PRIVATE_HDRS = $(MAC_OSX_DIR)/tkMacOSXPort.h $(MAC_OSX_DIR)/tkMacOSXInt.h
 
-X11_PRIVATE_HDRS = $(UNIX_DIR)/tkUnixPort.h $(UNIX_DIR)/tkUnixInt.h $(GENERIC_DIR)/tkIntXlibDecls.h
+X11_PRIVATE_HDRS = $(UNIX_DIR)/tkUnixPort.h $(UNIX_DIR)/tkUnixInt.h $(GENERIC_DIR)/tkIntXlibDecls.h \
+	$(UNIX_DIR)/tkUnixDefault.h
 
 # Currently private, eventually public
 TTK_HDRS = $(TTK_DIR)/ttkTheme.h $(TTK_DIR)/ttkDecls.h
 
 PUBLIC_HDRS = $(GENERIC_DIR)/tk.h $(GENERIC_DIR)/tkDecls.h \
@@ -581,15 +605,50 @@
 
 binaries: ${LIB_FILE} ${WISH_EXE}
 
 libraries:
 
+tkzipfile: ${TK_ZIP_FILE}
+
+${TK_ZIP_FILE}: ${ZIP_INSTALL_OBJS}
+	@rm -rf ${TK_VFS_ROOT}
+	@mkdir -p ${TK_VFS_PATH}
+	@echo "creating ${TK_VFS_PATH} (prepare compression)"
+	@if \
+	    ln -s $(TOP_DIR)/library/* ${TK_VFS_PATH}/; \
+	then : ; else \
+	    cp -a $(TOP_DIR)/library/* ${TK_VFS_PATH}; \
+	fi
+	rm -rf ${TK_VFS_PATH}/demos
+	@find ${TK_VFS_ROOT} -type d -empty -delete
+	@echo "creating ${TK_ZIP_FILE} from ${TK_VFS_PATH}"
+	-@if test "${ZIPFS_BUILD}" = "2" ; then \
+	    cp ${TCL_BIN_DIR}/tclsh ${TK_VFS_ROOT}/../${TK_ZIP_FILE} || cp ${TCL_BIN_DIR}/../bin/tclsh${TCLVERSION} ${TK_VFS_ROOT}/../${TK_ZIP_FILE}; \
+	    (zip=`(realpath '${NATIVE_ZIP}' || readlink -m '${NATIVE_ZIP}') 2>/dev/null || \
+		(echo '${NATIVE_ZIP}' | sed "s?^\./?$$(pwd)/?")`; \
+		cd ${TK_VFS_ROOT} && $$zip -J ../${TK_ZIP_FILE}) \
+	fi
+	@(zip=`(realpath '${NATIVE_ZIP}' || readlink -m '${NATIVE_ZIP}' || \
+	    echo '${NATIVE_ZIP}' | sed "s?^\./?$$(pwd)/?")  2>/dev/null`; \
+	    echo 'cd ${TK_VFS_ROOT} &&' $$zip '${ZIP_PROG_OPTIONS} ../${TK_ZIP_FILE} ${ZIP_PROG_VFSSEARCH}'; \
+	    cd ${TK_VFS_ROOT} && \
+	    $$zip ${ZIP_PROG_OPTIONS} ../${TK_ZIP_FILE} ${ZIP_PROG_VFSSEARCH} >/dev/null)
+
 # The following target is configured by autoconf to generate either
 # a shared library or non-shared library for Tk.
-${LIB_FILE}: ${STUB_LIB_FILE} @LIB_RSRC_FILE@ ${OBJS}
+${LIB_FILE}: ${STUB_LIB_FILE} @LIB_RSRC_FILE@ ${OBJS} ${TK_ZIP_FILE}
 	rm -f $@
 	@MAKE_LIB@
+	@if test "${ZIPFS_BUILD}" = "1" ; then \
+	    if test "x$(MACHER)" = "x" ; then \
+		cat ${TK_ZIP_FILE} >> ${LIB_FILE}; \
+	    else $(MACHER) append ${LIB_FILE} ${TK_ZIP_FILE} /tmp/macher_output; \
+	         mv /tmp/macher_output ${LIB_FILE}; chmod u+x ${LIB_FILE}; \
+	    fi; \
+	    ${NATIVE_ZIP} -A ${LIB_FILE} \
+	    || echo 'ignore zip-error by adjust sfx process (not executable?)'; \
+	fi
 
 ${STUB_LIB_FILE}: ${STUB_LIB_OBJS}
 	@if test "x${LIB_FILE}" = "xlibtk${MAJOR_VERSION}.${MINOR_VERSION}.dll"; then \
 	    (cd ${TOP_DIR}/win; ${MAKE} tk${MAJOR_VERSION}${MINOR_VERSION}.dll); \
 	    cp "${TOP_DIR}/win/tk${MAJOR_VERSION}${MINOR_VERSION}.dll" .; \
@@ -619,10 +678,19 @@
 
 
 ${WISH_EXE}: $(TK_STUB_LIB_FILE) $(WISH_OBJS) $(TK_LIB_FILE) @APP_RSRC_FILE@
 	${CC} ${CFLAGS} ${LDFLAGS} $(WISH_OBJS) @TK_BUILD_LIB_SPEC@ \
 		$(WISH_LIBS) $(CC_SEARCH_FLAGS) -o ${WISH_EXE}
+	@if test "${ZIPFS_BUILD}" = "2" ; then \
+	    if test "x$(MACHER)" = "x" ; then \
+		cat ${TK_ZIP_FILE} >> ${WISH_EXE}; \
+	    else $(MACHER) append ${WISH_EXE} ${TK_ZIP_FILE} /tmp/macher_output; \
+	         mv /tmp/macher_output ${LIB_FILE}; chmod u+x ${LIB_FILE}; \
+	    fi; \
+	    ${NATIVE_ZIP} -A ${WISH_EXE} \
+	    || echo 'ignore zip-error by adjust sfx process (not executable?)'; \
+	fi
 
 # Resetting the LIB_RUNTIME_DIR below is required so that
 # the generated tktest executable gets the build directory
 # burned into its ld search path. This keeps tktest from
 # picking up an already installed version of the Tcl or
@@ -696,11 +764,11 @@
 	$(SHELL_ENV) valgrind $(VALGRINDARGS) ./$(TKTEST_EXE) $(TEST_DIR)/all.tcl -geometry +0+0 -singleproc 1 $(TESTFLAGS)
 
 valgrindshell: $(TKTEST_EXE)
 	$(SHELL_ENV) valgrind $(VALGRINDARGS) ./$(TKTEST_EXE) $(SCRIPT)
 
-INSTALL_BASE_TARGETS = install-binaries install-libraries
+INSTALL_BASE_TARGETS = install-binaries ${INSTALL_LIBRARIES}
 INSTALL_DOC_TARGETS = install-doc
 INSTALL_DEV_TARGETS = install-headers
 INSTALL_DEMO_TARGETS = install-demos
 INSTALL_EXTRA_TARGETS = @EXTRA_INSTALL@
 INSTALL_TARGETS = $(INSTALL_BASE_TARGETS) $(INSTALL_DOC_TARGETS) $(INSTALL_DEV_TARGETS) \
@@ -725,32 +793,45 @@
 	    done;
 	@if test "x$(TK_SHARED_BUILD)" = "x1"; then \
 	    echo "Creating package index $(PKG_INDEX)"; \
 	    rm -f "$(PKG_INDEX)"; \
 	    (\
-	    echo "if {[catch {package present Tcl 8.6-}]} return";\
+	    echo "if {![package vsatisfies [package provide Tcl] 8.6-]} return";\
 	    relative=`echo | awk '{ORS=" "; split("$(TK_PKG_DIR)",a,"/"); for (f in a) {print ".."}}'`;\
 	    if test "x$(DLL_INSTALL_DIR)" != "x$(BIN_INSTALL_DIR)"; then \
-	    echo "package ifneeded Tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}$(TK_LIB_FILE)]] Tk]";\
+	    echo "if {[package vsatisfies [package provide Tcl] 9.0]} {";\
+	    echo "    package ifneeded tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}$(TK_LIB_FILE_TCL9)]]]";\
+	    echo "} else {";\
+	    echo "    package ifneeded tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}$(TK_LIB_FILE_TCL8)]]]";\
+	    echo "}";\
 	    else \
 	    echo "if {(\$$::tcl_platform(platform) eq \"unix\") && ([info exists ::env(DISPLAY)]";\
 	    echo "	|| ([info exists ::argv] && (\"-display\" in \$$::argv)))} {";\
-	    echo "    package ifneeded Tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}.. bin $(TK_LIB_FILE)]] Tk]";\
+	    echo "    if {[package vsatisfies [package provide Tcl] 9.0]} {";\
+	    echo "	package ifneeded tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}.. bin $(TK_LIB_FILE_TCL9)]]]";\
+	    echo "    } else {";\
+	    echo "	package ifneeded tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}.. bin $(TK_LIB_FILE_TCL8)]]]";\
+	    echo "    }";\
 	    echo "} else {";\
-	    echo "    package ifneeded Tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}.. bin tk${MAJOR_VERSION}${MINOR_VERSION}.dll]] Tk]";\
+	    echo "    if {[package vsatisfies [package provide Tcl] 9.0]} {";\
+	    echo "	package ifneeded tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}.. bin tcl9tk${MAJOR_VERSION}${MINOR_VERSION}.dll]]]";\
+	    echo "    } else {";\
+	    echo "	package ifneeded tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}.. bin tk${MAJOR_VERSION}${MINOR_VERSION}.dll]]]";\
+	    echo "    }";\
 	    echo "}";\
-	    fi \
+	    fi; \
+	    echo "package ifneeded Tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list package require -exact tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL)]"\
 	    ) > "$(PKG_INDEX)"; \
 	    fi
 	@echo "Installing $(LIB_FILE) to $(DLL_INSTALL_DIR)/"
 	@@INSTALL_LIB@
 	@chmod 555 "$(DLL_INSTALL_DIR)/$(LIB_FILE)"
 	@if test -f "tk${MAJOR_VERSION}${MINOR_VERSION}.dll"; then \
 	    $(INSTALL_LIBRARY) "tk${MAJOR_VERSION}${MINOR_VERSION}.dll" "$(DLL_INSTALL_DIR)";\
 	    chmod 555 "$(DLL_INSTALL_DIR)/tk${MAJOR_VERSION}${MINOR_VERSION}.dll";\
-	    $(INSTALL_LIBRARY) "../win/libtk${MAJOR_VERSION}${MINOR_VERSION}.a" "$(LIB_INSTALL_DIR)";\
-	    chmod 555 "$(LIB_INSTALL_DIR)/libtk${MAJOR_VERSION}${MINOR_VERSION}.a";\
+	    $(INSTALL_LIBRARY) "../win/libtk${MAJOR_VERSION}${MINOR_VERSION}.dll.a" "$(LIB_INSTALL_DIR)";\
+	    chmod 555 "$(LIB_INSTALL_DIR)/libtk${MAJOR_VERSION}${MINOR_VERSION}.dll.a";\
 	fi
 	@echo "Installing ${WISH_EXE} as $(BIN_INSTALL_DIR)/wish$(VERSION)${EXE_SUFFIX}"
 	@$(INSTALL_PROGRAM) ${WISH_EXE} "$(BIN_INSTALL_DIR)/wish$(VERSION)${EXE_SUFFIX}"
 	@echo "Installing tkConfig.sh to $(CONFIG_INSTALL_DIR)/"
 	@$(INSTALL_DATA) tkConfig.sh "$(CONFIG_INSTALL_DIR)/tkConfig.sh"
@@ -900,12 +981,14 @@
 	$(SHELL) config.status
 #tkConfig.h: $(UNIX_DIR)/tkConfig.h.in
 #	$(SHELL) config.status
 
 clean:
+	rm -rf *.vfs
 	rm -f *.a *.o libtk* core errs *~ \#* TAGS *.E a.out \
-		errors ${WISH_EXE} $(TKTEST_EXE) lib.exp Tk *.rsrc
+		errors ${WISH_EXE} $(TKTEST_EXE) lib.exp Tk *.rsrc \
+		 *.zip
 
 distclean: clean
 	rm -rf Makefile config.status config.cache config.log tkConfig.sh \
 		tkConfig.h *.plist Tk.framework tk.pc
 
@@ -1033,10 +1116,11 @@
 		-DCFG_RUNTIME_LIBDIR="\"$(libdir)\"" \
 		-DCFG_RUNTIME_BINDIR="\"$(bindir)\"" \
 		-DCFG_RUNTIME_SCRDIR="\"$(TK_LIBRARY)\"" \
 		-DCFG_RUNTIME_INCDIR="\"$(includedir)\"" \
 		-DCFG_RUNTIME_DOCDIR="\"$(mandir)\"" \
+		-DCFG_RUNTIME_DLLFILE="\"$(TK_LIB_FILE)\"" \
 		-DCFG_RUNTIME_DEMODIR="\"$(DEMO_INSTALL_DIR)\"" \
 		\
 		$(GENERIC_DIR)/tkPkgConfig.c
 
 tkPlace.o: $(GENERIC_DIR)/tkPlace.c
@@ -1052,12 +1136,12 @@
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkUtil.c
 
 tkVisual.o: $(GENERIC_DIR)/tkVisual.c
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkVisual.c
 
-tkWindow.o: $(GENERIC_DIR)/tkWindow.c
-	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkWindow.c
+tkWindow.o: $(GENERIC_DIR)/tkWindow.c tkUuid.h
+	$(CC) -c $(CC_SWITCHES) -I. $(GENERIC_DIR)/tkWindow.c
 
 tkButton.o: $(GENERIC_DIR)/tkButton.c
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkButton.c
 
 tkEntry.o: $(GENERIC_DIR)/tkEntry.c
@@ -1127,10 +1211,13 @@
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkRectOval.c
 
 tkTrig.o: $(GENERIC_DIR)/tkTrig.c
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTrig.c
 
+tkIcu.o: $(GENERIC_DIR)/tkIcu.c
+	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkIcu.c
+
 tkImage.o: $(GENERIC_DIR)/tkImage.c
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkImage.c
 
 tkImgBmap.o: $(GENERIC_DIR)/tkImgBmap.c
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkImgBmap.c
@@ -1157,11 +1244,11 @@
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkImgPhInstance.c
 
 tkOldTest.o: $(GENERIC_DIR)/tkOldTest.c
 	$(CC) -c $(APP_CC_SWITCHES) $(GENERIC_DIR)/tkOldTest.c
 
-tkTest.o: $(GENERIC_DIR)/tkTest.c
+tkTest.o: $(GENERIC_DIR)/tkTest.c tkUuid.h
 	$(CC) -c $(APP_CC_SWITCHES) $(GENERIC_DIR)/tkTest.c
 
 tkText.o: $(GENERIC_DIR)/tkText.c
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkText.c
 
@@ -1191,11 +1278,11 @@
 
 # Stub library binaries, these must be compiled for use in a shared library
 # even though they will be placed in a static archive
 
 tkStubLib.o: $(GENERIC_DIR)/tkStubLib.c
-	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkStubLib.c
+	$(CC) -c $(CC_SWITCHES) @CFLAGS_NOLTO@ $(GENERIC_DIR)/tkStubLib.c
 
 tkUndo.o: $(GENERIC_DIR)/tkUndo.c
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkUndo.c
 
 tkUnix.o: $(UNIX_DIR)/tkUnix.c
@@ -1258,10 +1345,16 @@
 	$(CC) -c $(CC_SWITCHES) $(UNIX_DIR)/tkUnixSelect.c
 
 tkUnixSend.o: $(UNIX_DIR)/tkUnixSend.c
 	$(CC) -c $(CC_SWITCHES) $(UNIX_DIR)/tkUnixSend.c
 
+tkUnixSysNotify.o: $(UNIX_DIR)/tkUnixSysNotify.c
+	$(CC) -c $(CC_SWITCHES) $(UNIX_DIR)/tkUnixSysNotify.c
+
+tkUnixSysTray.o: $(UNIX_DIR)/tkUnixSysTray.c
+	$(CC) -c $(CC_SWITCHES) $(UNIX_DIR)/tkUnixSysTray.c
+
 tkUnixWm.o: $(UNIX_DIR)/tkUnixWm.c
 	$(CC) -c $(CC_SWITCHES) $(UNIX_DIR)/tkUnixWm.c
 
 tkUnixXId.o: $(UNIX_DIR)/tkUnixXId.c
 	$(CC) -c $(CC_SWITCHES) $(UNIX_DIR)/tkUnixXId.c
@@ -1300,10 +1393,13 @@
 	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXEntry.c
 
 tkMacOSXEvent.o: $(MAC_OSX_DIR)/tkMacOSXEvent.c
 	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXEvent.c
 
+tkMacOSXFileTypes.o: $(MAC_OSX_DIR)/tkMacOSXFileTypes.c
+	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXFileTypes.c
+
 tkMacOSXFont.o: $(MAC_OSX_DIR)/tkMacOSXFont.c
 	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXFont.c
 
 tkMacOSXHLEvents.o: $(MAC_OSX_DIR)/tkMacOSXHLEvents.c
 	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXHLEvents.c
@@ -1334,10 +1430,13 @@
 	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXMouseEvent.c
 
 tkMacOSXNotify.o: $(MAC_OSX_DIR)/tkMacOSXNotify.c
 	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXNotify.c
 
+tkMacOSXPrint.o: $(MAC_OSX_DIR)/tkMacOSXPrint.c
+	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXPrint.c
+
 tkMacOSXRegion.o: $(MAC_OSX_DIR)/tkMacOSXRegion.c
 	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXRegion.c
 
 tkMacOSXScale.o: $(MAC_OSX_DIR)/tkMacOSXScale.c
 	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXScale.c
@@ -1364,10 +1463,13 @@
 	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXWm.c
 
 tkMacOSXXStubs.o: $(MAC_OSX_DIR)/tkMacOSXXStubs.c
 	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXXStubs.c
 
+tkMacOSXSysTray.o: $(MAC_OSX_DIR)/tkMacOSXSysTray.c
+	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXSysTray.c
+
 tkFileFilter.o: $(GENERIC_DIR)/tkFileFilter.c
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkFileFilter.c
 
 tkMacWinMenu.o: $(GENERIC_DIR)/tkMacWinMenu.c
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkMacWinMenu.c
@@ -1461,11 +1563,11 @@
 
 ttkStubInit.o: $(TTK_DIR)/ttkStubInit.c
 	$(CC) -c $(CC_SWITCHES) $(TTK_DIR)/ttkStubInit.c
 
 ttkStubLib.o: $(TTK_DIR)/ttkStubLib.c
-	$(CC) -c $(CC_SWITCHES) $(TTK_DIR)/ttkStubLib.c
+	$(CC) -c $(CC_SWITCHES) @CFLAGS_NOLTO@ $(TTK_DIR)/ttkStubLib.c
 
 ttkTagSet.o: $(TTK_DIR)/ttkTagSet.c
 	$(CC) -c $(CC_SWITCHES) $(TTK_DIR)/ttkTagSet.c
 
 ttkTheme.o: $(TTK_DIR)/ttkTheme.c
@@ -1483,10 +1585,15 @@
 ttkWidget.o: $(TTK_DIR)/ttkWidget.c
 	$(CC) -c $(CC_SWITCHES) $(TTK_DIR)/ttkWidget.c
 
 ttkMacOSXTheme.o: $(MAC_OSX_DIR)/ttkMacOSXTheme.c
 	$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/ttkMacOSXTheme.c
+
+tkUuid.h: $(TOP_DIR)/manifest.uuid
+	echo "#define TK_VERSION_UUID \\" >$@
+	cat $(TOP_DIR)/manifest.uuid >>$@
+	echo "" >>$@
 
 .c.o:
 	$(CC) -c $(CC_SWITCHES) $<
 
 #
@@ -1579,14 +1686,14 @@
 	cd $(MAC_OSX_DIR); autoconf
 $(UNIX_DIR)/tkConfig.h.in: $(MAC_OSX_DIR)/configure
 	cd $(MAC_OSX_DIR); autoheader; touch $@
 
 $(TOP_DIR)/manifest.uuid:
-	printf "git." >$(TOP_DIR)/manifest.uuid
-	git rev-parse HEAD >>$(TOP_DIR)/manifest.uuid
+	printf "git-" >$(TOP_DIR)/manifest.uuid
+	(cd $(TOP_DIR); git rev-parse HEAD >>$(TOP_DIR)/manifest.uuid || printf "unknown" >$(TOP_DIR)/manifest.uuid)
 
-dist:	$(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(MAC_OSX_DIR)/configure $(TOP_DIR)/doc/man.macros $(TOP_DIR)/manifest.uuid
+dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(MAC_OSX_DIR)/configure $(TOP_DIR)/doc/man.macros $(TOP_DIR)/manifest.uuid
 	rm -rf $(DISTDIR)
 	$(INSTALL_DATA_DIR) $(DISTDIR)/unix
 	$(DIST_INSTALL_DATA) $(TOP_DIR)/manifest.uuid $(DISTDIR)
 	$(DIST_INSTALL_DATA) $(UNIX_DIR)/*.c $(UNIX_DIR)/*.h $(DISTDIR)/unix
 	$(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(UNIX_DIR)/Makefile.in $(DISTDIR)/unix
@@ -1613,22 +1720,19 @@
 	rm -f $(DISTDIR)/generic/blt*.[ch]
 	$(INSTALL_DATA_DIR) $(DISTDIR)/generic/ttk
 	$(DIST_INSTALL_DATA) $(TTK_DIR)/*.[ch] $(TTK_DIR)/ttk.decls \
 		$(DISTDIR)/generic/ttk
 	$(INSTALL_DATA_DIR) $(DISTDIR)/win
-	$(DIST_INSTALL_DATA) $(TOP_DIR)/win/Makefile.in $(DISTDIR)/win
+	$(DIST_INSTALL_DATA) $(TOP_DIR)/win/*.in $(DISTDIR)/win
 	$(DIST_INSTALL_DATA) $(TOP_DIR)/win/configure.ac \
-		$(TOP_DIR)/win/tkConfig.sh.in \
 		$(TOP_DIR)/win/aclocal.m4 $(TOP_DIR)/win/tcl.m4 \
+		$(TOP_DIR)/win/*.[ch] $(TOP_DIR)/win/*.bat \
+		$(TOP_DIR)/win/*.vc $(TOP_DIR)/win/README \
+		$(TOP_DIR)/license.terms \
 		$(DISTDIR)/win
 	$(DIST_INSTALL_SCRIPT) $(TOP_DIR)/win/configure $(DISTDIR)/win
-	$(DIST_INSTALL_DATA) $(TOP_DIR)/win/*.[ch] $(TOP_DIR)/win/*.bat $(DISTDIR)/win
-	$(DIST_INSTALL_DATA) $(TOP_DIR)/win/*.vc $(DISTDIR)/win
-	$(DIST_INSTALL_DATA) $(TOP_DIR)/win/README $(DISTDIR)/win
-	$(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(DISTDIR)/win
 	$(INSTALL_DATA_DIR) $(DISTDIR)/win/rc
-	$(DIST_INSTALL_DATA) $(TOP_DIR)/win/wish.exe.manifest.in $(DISTDIR)/win/
 	$(DIST_INSTALL_DATA) $(TOP_DIR)/win/rc/*.{rc,cur,ico,bmp} $(DISTDIR)/win/rc
 	$(INSTALL_DATA_DIR) $(DISTDIR)/macosx
 	$(DIST_INSTALL_DATA) $(MAC_OSX_DIR)/GNUmakefile $(MAC_OSX_DIR)/README \
 		$(MAC_OSX_DIR)/*.icns $(MAC_OSX_DIR)/*.tiff \
 		$(MAC_OSX_DIR)/*.[ch] $(MAC_OSX_DIR)/*.in \
@@ -1635,14 +1739,10 @@
 		$(MAC_OSX_DIR)/*.ac $(MAC_OSX_DIR)/*.xcconfig \
 		$(MAC_OSX_DIR)/*.sdef \
 		$(DISTDIR)/macosx
 	$(DIST_INSTALL_SCRIPT) $(MAC_OSX_DIR)/configure $(DISTDIR)/macosx
 	$(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(DISTDIR)/macosx
-	$(INSTALL_DATA_DIR) $(DISTDIR)/macosx/Tk.xcode
-	$(DIST_INSTALL_DATA) $(MAC_OSX_DIR)/Tk.xcode/project.pbxproj \
-		$(MAC_OSX_DIR)/Tk.xcode/default.pbxuser \
-		$(DISTDIR)/macosx/Tk.xcode
 	$(INSTALL_DATA_DIR) $(DISTDIR)/macosx/Tk.xcodeproj
 	$(DIST_INSTALL_DATA) $(MAC_OSX_DIR)/Tk.xcodeproj/project.pbxproj \
 		$(MAC_OSX_DIR)/Tk.xcodeproj/default.pbxuser \
 		$(DISTDIR)/macosx/Tk.xcodeproj
 	$(INSTALL_DATA_DIR) $(DISTDIR)/compat
@@ -1698,10 +1798,13 @@
 	$(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(TEST_DIR)/*.{test,tcl} \
 		$(TEST_DIR)/README $(TEST_DIR)/*.{gif,png,ppm,xbm} \
 		$(TEST_DIR)/option.file* $(DISTDIR)/tests
 	$(INSTALL_DATA_DIR) $(DISTDIR)/tests/ttk
 	$(DIST_INSTALL_DATA) $(TEST_DIR)/ttk/*.{test,tcl} $(DISTDIR)/tests/ttk
+	cp -p $(TOP_DIR)/.travis.yml $(DISTDIR)
+	mkdir -p $(DISTDIR)/.github/workflows
+	cp -p $(TOP_DIR)/.github/workflows/*.yml $(DISTDIR)/.github/workflows
 
 alldist: dist
 	rm -f $(DISTROOT)/$(DISTNAME)-src.tar.gz $(DISTROOT)/$(ZIPNAME)
 	cd $(DISTROOT); tar cf $(DISTNAME)-src.tar $(DISTNAME); \
 		gzip -9 $(DISTNAME)-src.tar; zip -qr8 $(ZIPNAME) $(DISTNAME)

Index: unix/configure
==================================================================
--- unix/configure
+++ unix/configure
@@ -1,11 +1,12 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for tk 8.7.
+# Generated by GNU Autoconf 2.71 for tk 8.7.
 #
 #
-# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation,
+# Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
 # gives unlimited permission to copy, distribute and modify it.
 ## -------------------- ##
@@ -12,92 +13,91 @@
 ## M4sh Initialization. ##
 ## -------------------- ##
 
 # Be more Bourne compatible
 DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+as_nop=:
+if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1
+then :
   emulate sh
   NULLCMD=:
   # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
-else
+else $as_nop
   case `(set -o) 2>/dev/null` in #(
   *posix*) :
     set -o posix ;; #(
   *) :
      ;;
 esac
 fi
 
 
+
+# Reset variables that may have inherited troublesome values from
+# the environment.
+
+# IFS needs to be set, to space, tab, and newline, in precisely that order.
+# (If _AS_PATH_WALK were called with IFS unset, it would have the
+# side effect of setting IFS to empty, thus disabling word splitting.)
+# Quoting is to prevent editors from complaining about space-tab.
 as_nl='
 '
 export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='printf %s\n'
-  as_echo_n='printf %s'
-else
-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
-    as_echo_n='/usr/ucb/echo -n'
-  else
-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-    as_echo_n_body='eval
-      arg=$1;
-      case $arg in #(
-      *"$as_nl"*)
-	expr "X$arg" : "X\\(.*\\)$as_nl";
-	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-      esac;
-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-    '
-    export as_echo_n_body
-    as_echo_n='sh -c $as_echo_n_body as_echo'
-  fi
-  export as_echo_body
-  as_echo='sh -c $as_echo_body as_echo'
-fi
+IFS=" ""	$as_nl"
+
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# Ensure predictable behavior from utilities with locale-dependent output.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# We cannot yet rely on "unset" to work, but we need these variables
+# to be unset--not just set to an empty or harmless value--now, to
+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh).  This construct
+# also avoids known problems related to "unset" and subshell syntax
+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).
+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH
+do eval test \${$as_var+y} \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+
+# Ensure that fds 0, 1, and 2 are open.
+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi
+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi
+if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi
 
 # The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
+if ${PATH_SEPARATOR+false} :; then
   PATH_SEPARATOR=:
   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
       PATH_SEPARATOR=';'
   }
 fi
 
 
-# IFS
-# We need space, tab and new line, in precisely that order.  Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" ""	$as_nl"
-
 # Find who we are.  Look in the path if we contain no directory separator.
 as_myself=
 case $0 in #((
   *[\\/]* ) as_myself=$0 ;;
   *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    test -r "$as_dir$0" && as_myself=$as_dir$0 && break
   done
 IFS=$as_save_IFS
 
      ;;
 esac
@@ -105,34 +105,14 @@
 # in which case we are not to be found in the path.
 if test "x$as_myself" = x; then
   as_myself=$0
 fi
 if test ! -f "$as_myself"; then
-  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
   exit 1
 fi
 
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
 # Use a proper internal environment variable to ensure we don't fall
   # into an infinite loop, continuously re-executing ourselves.
   if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
     _as_can_reexec=no; export _as_can_reexec;
@@ -150,24 +130,26 @@
   * ) as_opts= ;;
 esac
 exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
 # Admittedly, this is quite paranoid, since all the known shells bail
 # out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-as_fn_exit 255
+printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
   fi
   # We don't want this to propagate to other subprocesses.
           { _as_can_reexec=; unset _as_can_reexec;}
 if test "x$CONFIG_SHELL" = x; then
-  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  as_bourne_compatible="as_nop=:
+if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1
+then :
   emulate sh
   NULLCMD=:
   # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '\${1+\"\$@\"}'='\"\$@\"'
   setopt NO_GLOB_SUBST
-else
+else \$as_nop
   case \`(set -o) 2>/dev/null\` in #(
   *posix*) :
     set -o posix ;; #(
   *) :
      ;;
@@ -183,61 +165,79 @@
 exitcode=0
 as_fn_success || { exitcode=1; echo as_fn_success failed.; }
 as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
 as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
 as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
-if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+if ( set x; as_fn_ret_success y && test x = \"\$1\" )
+then :
 
-else
+else \$as_nop
   exitcode=1; echo positional parameters were not saved.
 fi
 test x\$exitcode = x0 || exit 1
+blah=\$(echo \$(echo blah))
+test x\"\$blah\" = xblah || exit 1
 test -x / || exit 1"
   as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
   eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
   test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
 test \$(( 1 + 1 )) = 2 || exit 1"
-  if (eval "$as_required") 2>/dev/null; then :
+  if (eval "$as_required") 2>/dev/null
+then :
   as_have_required=yes
-else
+else $as_nop
   as_have_required=no
 fi
-  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null
+then :
 
-else
+else $as_nop
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 as_found=false
 for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
   as_found=:
   case $as_dir in #(
 	 /*)
 	   for as_base in sh bash ksh sh5; do
 	     # Try only shells that exist, to save several forks.
-	     as_shell=$as_dir/$as_base
+	     as_shell=$as_dir$as_base
 	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
-		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+		    as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null
+then :
   CONFIG_SHELL=$as_shell as_have_required=yes
-		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+		   if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null
+then :
   break 2
 fi
 fi
 	   done;;
        esac
   as_found=false
 done
-$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
-	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+IFS=$as_save_IFS
+if $as_found
+then :
+
+else $as_nop
+  if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+	      as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null
+then :
   CONFIG_SHELL=$SHELL as_have_required=yes
-fi; }
-IFS=$as_save_IFS
+fi
+fi
 
 
-      if test "x$CONFIG_SHELL" != x; then :
+      if test "x$CONFIG_SHELL" != x
+then :
   export CONFIG_SHELL
              # We cannot yet assume a decent shell, so we have to provide a
 # neutralization value for shells without unset; and this also
 # works around shells that cannot unset nonexistent variables.
 # Preserve -v and -x to the replacement shell.
@@ -251,22 +251,23 @@
   * ) as_opts= ;;
 esac
 exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
 # Admittedly, this is quite paranoid, since all the known shells bail
 # out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2
 exit 255
 fi
 
-    if test x$as_have_required = xno; then :
-  $as_echo "$0: This script requires a shell more modern than all"
-  $as_echo "$0: the shells that I found on your system."
-  if test x${ZSH_VERSION+set} = xset ; then
-    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
-    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+    if test x$as_have_required = xno
+then :
+  printf "%s\n" "$0: This script requires a shell more modern than all"
+  printf "%s\n" "$0: the shells that I found on your system."
+  if test ${ZSH_VERSION+y} ; then
+    printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later."
   else
-    $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
+    printf "%s\n" "$0: Please tell bug-autoconf@gnu.org about your system,
 $0: including any error possibly output before this
 $0: message. Then install a modern shell, or manually run
 $0: the script under such a shell if you do have one."
   fi
   exit 1
@@ -288,10 +289,11 @@
 as_fn_unset ()
 {
   { eval $1=; unset $1;}
 }
 as_unset=as_fn_unset
+
 
 # as_fn_set_status STATUS
 # -----------------------
 # Set $? to STATUS, without forking.
 as_fn_set_status ()
@@ -306,10 +308,18 @@
 {
   set +e
   as_fn_set_status $1
   exit $1
 } # as_fn_exit
+# as_fn_nop
+# ---------
+# Do nothing but, unlike ":", preserve the value of $?.
+as_fn_nop ()
+{
+  return $?
+}
+as_nop=as_fn_nop
 
 # as_fn_mkdir_p
 # -------------
 # Create "$as_dir" as a directory, including parents if necessary.
 as_fn_mkdir_p ()
@@ -320,20 +330,20 @@
   esac
   test -d "$as_dir" || eval $as_mkdir_p || {
     as_dirs=
     while :; do
       case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
       *) as_qdir=$as_dir;;
       esac
       as_dirs="'$as_qdir' $as_dirs"
       as_dir=`$as_dirname -- "$as_dir" ||
 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$as_dir" : 'X\(//\)[^/]' \| \
 	 X"$as_dir" : 'X\(//\)$' \| \
 	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
+printf "%s\n" X"$as_dir" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
 	    s//\1/
 	    q
 	  }
 	  /^X\(\/\/\)[^/].*/{
@@ -368,16 +378,17 @@
 # ----------------------
 # Append the text in VALUE to the end of the definition contained in VAR. Take
 # advantage of any shell optimizations that allow amortized linear growth over
 # repeated appends, instead of the typical quadratic growth present in naive
 # implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null
+then :
   eval 'as_fn_append ()
   {
     eval $1+=\$2
   }'
-else
+else $as_nop
   as_fn_append ()
   {
     eval $1=\$$1\$2
   }
 fi # as_fn_append
@@ -385,22 +396,31 @@
 # as_fn_arith ARG...
 # ------------------
 # Perform arithmetic evaluation on the ARGs, and store the result in the
 # global $as_val. Take advantage of shells that can avoid forks. The arguments
 # must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null
+then :
   eval 'as_fn_arith ()
   {
     as_val=$(( $* ))
   }'
-else
+else $as_nop
   as_fn_arith ()
   {
     as_val=`expr "$@" || test $? -eq 1`
   }
 fi # as_fn_arith
 
+# as_fn_nop
+# ---------
+# Do nothing but, unlike ":", preserve the value of $?.
+as_fn_nop ()
+{
+  return $?
+}
+as_nop=as_fn_nop
 
 # as_fn_error STATUS ERROR [LINENO LOG_FD]
 # ----------------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
@@ -408,13 +428,13 @@
 as_fn_error ()
 {
   as_status=$1; test $as_status -eq 0 && as_status=1
   if test "$4"; then
     as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
   fi
-  $as_echo "$as_me: error: $2" >&2
+  printf "%s\n" "$as_me: error: $2" >&2
   as_fn_exit $as_status
 } # as_fn_error
 
 if expr a : '\(a\)' >/dev/null 2>&1 &&
    test "X`expr 00001 : '.*\(...\)'`" = X001; then
@@ -437,11 +457,11 @@
 
 as_me=`$as_basename -- "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
 	 X"$0" : 'X\(//\)$' \| \
 	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
+printf "%s\n" X/"$0" |
     sed '/^.*\/\([^/][^/]*\)\/*$/{
 	    s//\1/
 	    q
 	  }
 	  /^X\/\(\/\/\)$/{
@@ -481,11 +501,11 @@
       s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
       t loop
       s/-\n.*//
     ' >$as_me.lineno &&
   chmod +x "$as_me.lineno" ||
-    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+    { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
 
   # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
   # already done that, so ensure we don't try to do so again and fall
   # in an infinite loop.  This has already happened in practice.
   _as_can_reexec=no; export _as_can_reexec
@@ -495,10 +515,14 @@
   . "./$as_me.lineno"
   # Exit status is that of the last command.
   exit
 }
 
+
+# Determine whether it's possible to make 'echo' print without a newline.
+# These variables are no longer used directly by Autoconf, but are AC_SUBSTed
+# for compatibility with existing Makefiles.
 ECHO_C= ECHO_N= ECHO_T=
 case `echo -n x` in #(((((
 -n*)
   case `echo 'xy\c'` in
   *c*) ECHO_T='	';;	# ECHO_T is single tab character.
@@ -507,10 +531,17 @@
        ECHO_T='	';;
   esac;;
 *)
   ECHO_N='-n';;
 esac
+
+# For backward compatibility with old third-party macros, we provide
+# the shell variables $as_echo and $as_echo_n.  New code should use
+# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively.
+as_echo='printf %s\n'
+as_echo_n='printf %s'
+
 
 rm -f conf$$ conf$$.exe conf$$.file
 if test -d conf$$.dir; then
   rm -f conf$$.dir/conf$$.file
 else
@@ -582,44 +613,40 @@
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
 # Factoring default headers for most tests.
 ac_includes_default="\
-#include <stdio.h>
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
+#include <stddef.h>
+#ifdef HAVE_STDIO_H
+# include <stdio.h>
+#endif
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
 #endif
 #ifdef HAVE_STRING_H
-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
-#  include <memory.h>
-# endif
 # include <string.h>
 #endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
 #ifdef HAVE_INTTYPES_H
 # include <inttypes.h>
 #endif
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
 #endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif"
 
+ac_header_c_list=
 ac_subst_vars='LTLIBOBJS
 REZ_FLAGS
 REZ
 APP_RSRC_FILE
 LIB_RSRC_FILE
@@ -653,22 +680,38 @@
 TK_STUB_LIB_SPEC
 TK_STUB_LIB_FLAG
 TK_STUB_LIB_FILE
 TK_LIB_SPEC
 TK_LIB_FLAG
+TK_LIB_FILE_TCL9
+TK_LIB_FILE_TCL8
 TK_LIB_FILE
 TK_YEAR
 TK_PATCH_LEVEL
 TK_MINOR_VERSION
 TK_MAJOR_VERSION
 TK_VERSION
 TK_DEMO_DIR
 DEMO_DIR
+INSTALL_MSGS
+INSTALL_LIBRARIES
+TK_ZIP_FILE
+ZIPFS_BUILD
+ZIP_INSTALL_OBJS
+ZIP_PROG_VFSSEARCH
+ZIP_PROG_OPTIONS
+ZIP_PROG
+MACHER_PROG
+EXEEXT_FOR_BUILD
+CC_FOR_BUILD
 UNIX_FONT_OBJS
 XFT_LIBS
 XFT_CFLAGS
 XMKMF
+EGREP
+GREP
+CPP
 LDFLAGS_DEFAULT
 CFLAGS_DEFAULT
 INSTALL_STUB_LIB
 DLL_INSTALL_DIR
 INSTALL_LIB
@@ -683,22 +726,20 @@
 STLIB_LD
 LD_SEARCH_FLAGS
 CC_SEARCH_FLAGS
 LDFLAGS_OPTIMIZE
 LDFLAGS_DEBUG
+CFLAGS_NOLTO
 CFLAGS_WARNING
 CFLAGS_OPTIMIZE
 CFLAGS_DEBUG
 LDAIX_SRC
 PLAT_SRCS
 PLAT_OBJS
 DL_OBJS
 DL_LIBS
 TCL_LIBS
-EGREP
-GREP
-CPP
 LIBOBJS
 AR
 RANLIB
 SHARED_BUILD
 OBJEXT
@@ -738,10 +779,11 @@
 htmldir
 infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
 datadir
 datarootdir
@@ -778,10 +820,11 @@
 enable_aqua
 with_x
 enable_xft
 enable_xss
 enable_framework
+enable_zipfs
 '
       ac_precious_vars='build_alias
 host_alias
 target_alias
 CC
@@ -827,10 +870,11 @@
 datarootdir='${prefix}/share'
 datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
 infodir='${datarootdir}/info'
 htmldir='${docdir}'
@@ -856,12 +900,10 @@
   *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
   *=)   ac_optarg= ;;
   *)    ac_optarg=yes ;;
   esac
 
-  # Accept the important Cygnus configure options, so we can diagnose typos.
-
   case $ac_dashdash$ac_option in
   --)
     ac_dashdash=yes ;;
 
   -bindir | --bindir | --bindi | --bind | --bin | --bi)
@@ -898,13 +940,13 @@
 
   -disable-* | --disable-*)
     ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
+      as_fn_error $? "invalid feature name: \`$ac_useropt'"
     ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
       *"
 "enable_$ac_useropt"
 "*) ;;
       *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
@@ -924,13 +966,13 @@
 
   -enable-* | --enable-*)
     ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
+      as_fn_error $? "invalid feature name: \`$ac_useropt'"
     ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
       *"
 "enable_$ac_useropt"
 "*) ;;
       *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
@@ -1078,10 +1120,19 @@
     psdir=$ac_optarg ;;
 
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
+
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
 
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
   | --sbi=* | --sb=*)
@@ -1128,13 +1179,13 @@
 
   -with-* | --with-*)
     ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
+      as_fn_error $? "invalid package name: \`$ac_useropt'"
     ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
       *"
 "with_$ac_useropt"
 "*) ;;
       *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
@@ -1144,13 +1195,13 @@
 
   -without-* | --without-*)
     ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
+      as_fn_error $? "invalid package name: \`$ac_useropt'"
     ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
       *"
 "with_$ac_useropt"
 "*) ;;
       *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
@@ -1190,13 +1241,13 @@
     eval $ac_envvar=\$ac_optarg
     export $ac_envvar ;;
 
   *)
     # FIXME: should be removed in autoconf 3.0.
-    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2
     expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+      printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2
     : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
     ;;
 
   esac
 done
@@ -1208,19 +1259,19 @@
 
 if test -n "$ac_unrecognized_opts"; then
   case $enable_option_checking in
     no) ;;
     fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
-    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+    *)     printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
   esac
 fi
 
 # Check all directory arguments for consistency.
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
   case $ac_val in
     */ )
@@ -1272,11 +1323,11 @@
   ac_confdir=`$as_dirname -- "$as_myself" ||
 $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$as_myself" : 'X\(//\)[^/]' \| \
 	 X"$as_myself" : 'X\(//\)$' \| \
 	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_myself" |
+printf "%s\n" X"$as_myself" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
 	    s//\1/
 	    q
 	  }
 	  /^X\(\/\/\)[^/].*/{
@@ -1369,10 +1420,11 @@
   --sbindir=DIR           system admin executables [EPREFIX/sbin]
   --libexecdir=DIR        program executables [EPREFIX/libexec]
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
   --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
   --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
@@ -1422,18 +1474,18 @@
   --enable-aqua=yes|no    use Aqua windowingsystem on Mac OS X (default: no)
   --enable-xft            use freetype/fontconfig/xft (default: on)
   --enable-xss            use XScreenSaver for activity timer (default: on)
   --enable-framework      package shared libraries in MacOSX frameworks
                           (default: off)
+  --enable-zipfs          build with Zipfs support (default: on)
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-tcl              directory containing tcl configuration
                           (tclConfig.sh)
-  --with-encoding         encoding for configuration values (default:
-                          iso8859-1)
+  --with-encoding         encoding for configuration values (default: utf-8)
   --with-x                use the X Window System
 
 Some influential environment variables:
   CC          C compiler command
   CFLAGS      C compiler flags
@@ -1462,13 +1514,13 @@
     ac_builddir=.
 
 case "$ac_dir" in
 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
 *)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'`
   # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
   case $ac_top_builddir_sub in
   "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
   *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
   esac ;;
 esac
@@ -1492,31 +1544,32 @@
     ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
 esac
 ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
 
     cd "$ac_dir" || { ac_status=$?; continue; }
-    # Check for guested configure.
+    # Check for configure.gnu first; this name is used for a wrapper for
+    # Metaconfig's "Configure" on case-insensitive file systems.
     if test -f "$ac_srcdir/configure.gnu"; then
       echo &&
       $SHELL "$ac_srcdir/configure.gnu" --help=recursive
     elif test -f "$ac_srcdir/configure"; then
       echo &&
       $SHELL "$ac_srcdir/configure" --help=recursive
     else
-      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+      printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2
     fi || ac_status=$?
     cd "$ac_pwd" || { ac_status=$?; break; }
   done
 fi
 
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
 tk configure 8.7
-generated by GNU Autoconf 2.69
+generated by GNU Autoconf 2.71
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 2021 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
   exit
 fi
@@ -1529,33 +1582,34 @@
 # --------------------------
 # Try to compile conftest.$ac_ext, and return whether this succeeded.
 ac_fn_c_try_compile ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
+  rm -f conftest.$ac_objext conftest.beam
   if { { ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_compile") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
     grep -v '^ *+' conftest.err >conftest.er1
     cat conftest.er1 >&5
     mv -f conftest.er1 conftest.err
   fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; } && {
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then :
+       } && test -s conftest.$ac_objext
+then :
   ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 	ac_retval=1
 fi
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
@@ -1567,36 +1621,37 @@
 # -----------------------
 # Try to link conftest.$ac_ext, and return whether this succeeded.
 ac_fn_c_try_link ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext conftest$ac_exeext
+  rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext
   if { { ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_link") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
     grep -v '^ *+' conftest.err >conftest.er1
     cat conftest.er1 >&5
     mv -f conftest.er1 conftest.err
   fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; } && {
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
 	 test -x conftest$ac_exeext
-       }; then :
+       }
+then :
   ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 	ac_retval=1
 fi
   # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
@@ -1607,203 +1662,39 @@
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_link
 
-# ac_fn_c_try_cpp LINENO
-# ----------------------
-# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_cpp ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } > conftest.i && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-    ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_cpp
-
-# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists, giving a warning if it cannot be compiled using
-# the include files in INCLUDES and setting the cache variable VAR
-# accordingly.
-ac_fn_c_check_header_mongrel ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if eval \${$3+:} false; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-else
-  # Is the header compilable?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
-$as_echo_n "checking $2 usability... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_header_compiler=yes
-else
-  ac_header_compiler=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
-$as_echo "$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
-$as_echo_n "checking $2 presence... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <$2>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  ac_header_preproc=yes
-else
-  ac_header_preproc=no
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
-$as_echo "$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
-  yes:no: )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
-$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-    ;;
-  no:yes:* )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
-$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
-$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
-$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
-$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-    ;;
-esac
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  eval "$3=\$ac_header_compiler"
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_mongrel
-
-# ac_fn_c_try_run LINENO
-# ----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
-# that executables *can* be run.
-ac_fn_c_try_run ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-       $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_retval=$ac_status
-fi
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_run
-
 # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
 # -------------------------------------------------------
 # Tests whether HEADER exists and can be compiled using the include files in
 # INCLUDES, setting the cache variable VAR accordingly.
 ac_fn_c_check_header_compile ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+printf %s "checking for $2... " >&6; }
+if eval test \${$3+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $4
 #include <$2>
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   eval "$3=yes"
-else
+else $as_nop
   eval "$3=no"
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
+	       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+printf "%s\n" "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_header_compile
 
 # ac_fn_c_check_func LINENO FUNC VAR
@@ -1810,32 +1701,26 @@
 # ----------------------------------
 # Tests whether FUNC exists, setting the cache variable VAR accordingly
 ac_fn_c_check_func ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+printf %s "checking for $2... " >&6; }
+if eval test \${$3+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 /* Define $2 to an innocuous variant, in case <limits.h> declares $2.
    For example, HP-UX 11i <limits.h> declares gettimeofday.  */
 #define $2 innocuous_$2
 
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $2 (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
+   which can conflict with char $2 (); below.  */
+
+#include <limits.h>
 #undef $2
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
@@ -1849,93 +1734,198 @@
 #if defined __stub_$2 || defined __stub___$2
 choke me
 #endif
 
 int
-main ()
+main (void)
 {
 return $2 ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   eval "$3=yes"
-else
+else $as_nop
   eval "$3=no"
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 fi
 eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
+	       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+printf "%s\n" "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_func
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that
+# executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf "%s\n" "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf "%s\n" "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+then :
+  ac_retval=0
+else $as_nop
+  printf "%s\n" "$as_me: program exited with status $ac_status" >&5
+       printf "%s\n" "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf "%s\n" "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } > conftest.i && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }
+then :
+  ac_retval=0
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
 
 # ac_fn_c_check_type LINENO TYPE VAR INCLUDES
 # -------------------------------------------
 # Tests whether TYPE exists after having included INCLUDES, setting cache
 # variable VAR accordingly.
 ac_fn_c_check_type ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+printf %s "checking for $2... " >&6; }
+if eval test \${$3+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   eval "$3=no"
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $4
 int
-main ()
+main (void)
 {
 if (sizeof ($2))
 	 return 0;
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $4
 int
-main ()
+main (void)
 {
 if (sizeof (($2)))
 	    return 0;
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
 
-else
+else $as_nop
   eval "$3=yes"
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
+	       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+printf "%s\n" "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_type
+ac_configure_args_raw=
+for ac_arg
+do
+  case $ac_arg in
+  *\'*)
+    ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+  esac
+  as_fn_append ac_configure_args_raw " '$ac_arg'"
+done
+
+case $ac_configure_args_raw in
+  *$as_nl*)
+    ac_safe_unquote= ;;
+  *)
+    ac_unsafe_z='|&;<>()$`\\"*?[ ''	' # This string ends in space, tab.
+    ac_unsafe_a="$ac_unsafe_z#~"
+    ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g"
+    ac_configure_args_raw=`      printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;;
+esac
+
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by tk $as_me 8.7, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+generated by GNU Autoconf 2.71.  Invocation command line was
 
-  $ $0 $@
+  $ $0$ac_configure_args_raw
 
 _ACEOF
 exec 5>>config.log
 {
 cat <<_ASUNAME
@@ -1964,12 +1954,16 @@
 
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    $as_echo "PATH: $as_dir"
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    printf "%s\n" "PATH: $as_dir"
   done
 IFS=$as_save_IFS
 
 } >&5
 
@@ -2000,11 +1994,11 @@
     -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
     -q | -quiet | --quiet | --quie | --qui | --qu | --q \
     | -silent | --silent | --silen | --sile | --sil)
       continue ;;
     *\'*)
-      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+      ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
     esac
     case $ac_pass in
     1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
     2)
       as_fn_append ac_configure_args1 " '$ac_arg'"
@@ -2035,15 +2029,17 @@
 # config.log.  We remove comments because anyway the quotes in there
 # would cause problems or look ugly.
 # WARNING: Use '\'' to represent an apostrophe within the trap.
 # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
 trap 'exit_status=$?
+  # Sanitize IFS.
+  IFS=" ""	$as_nl"
   # Save into config.log some information that might help in debugging.
   {
     echo
 
-    $as_echo "## ---------------- ##
+    printf "%s\n" "## ---------------- ##
 ## Cache variables. ##
 ## ---------------- ##"
     echo
     # The following way of writing the cache mishandles newlines in values,
 (
@@ -2050,12 +2046,12 @@
   for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
     eval ac_val=\$$ac_var
     case $ac_val in #(
     *${as_nl}*)
       case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
       BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
       *) { eval $ac_var=; unset $ac_var;} ;;
@@ -2075,51 +2071,51 @@
     esac |
     sort
 )
     echo
 
-    $as_echo "## ----------------- ##
+    printf "%s\n" "## ----------------- ##
 ## Output variables. ##
 ## ----------------- ##"
     echo
     for ac_var in $ac_subst_vars
     do
       eval ac_val=\$$ac_var
       case $ac_val in
-      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
       esac
-      $as_echo "$ac_var='\''$ac_val'\''"
+      printf "%s\n" "$ac_var='\''$ac_val'\''"
     done | sort
     echo
 
     if test -n "$ac_subst_files"; then
-      $as_echo "## ------------------- ##
+      printf "%s\n" "## ------------------- ##
 ## File substitutions. ##
 ## ------------------- ##"
       echo
       for ac_var in $ac_subst_files
       do
 	eval ac_val=\$$ac_var
 	case $ac_val in
-	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+	*\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
 	esac
-	$as_echo "$ac_var='\''$ac_val'\''"
+	printf "%s\n" "$ac_var='\''$ac_val'\''"
       done | sort
       echo
     fi
 
     if test -s confdefs.h; then
-      $as_echo "## ----------- ##
+      printf "%s\n" "## ----------- ##
 ## confdefs.h. ##
 ## ----------- ##"
       echo
       cat confdefs.h
       echo
     fi
     test "$ac_signal" != 0 &&
-      $as_echo "$as_me: caught signal $ac_signal"
-    $as_echo "$as_me: exit $exit_status"
+      printf "%s\n" "$as_me: caught signal $ac_signal"
+    printf "%s\n" "$as_me: exit $exit_status"
   } >&5
   rm -f core *.core core.conftest.* &&
     rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
     exit $exit_status
 ' 0
@@ -2129,89 +2125,392 @@
 ac_signal=0
 
 # confdefs.h avoids OS command line length limits that DEFS can exceed.
 rm -f -r conftest* confdefs.h
 
-$as_echo "/* confdefs.h */" > confdefs.h
+printf "%s\n" "/* confdefs.h */" > confdefs.h
 
 # Predefined preprocessor variables.
 
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_URL "$PACKAGE_URL"
-_ACEOF
+printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h
+
+printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h
+
+printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h
+
+printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h
+
+printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h
+
+printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h
 
 
 # Let the site file select an alternate cache file if it wants to.
 # Prefer an explicitly selected file to automatically selected ones.
-ac_site_file1=NONE
-ac_site_file2=NONE
 if test -n "$CONFIG_SITE"; then
-  # We do not want a PATH search for config.site.
-  case $CONFIG_SITE in #((
-    -*)  ac_site_file1=./$CONFIG_SITE;;
-    */*) ac_site_file1=$CONFIG_SITE;;
-    *)   ac_site_file1=./$CONFIG_SITE;;
-  esac
+  ac_site_files="$CONFIG_SITE"
 elif test "x$prefix" != xNONE; then
-  ac_site_file1=$prefix/share/config.site
-  ac_site_file2=$prefix/etc/config.site
+  ac_site_files="$prefix/share/config.site $prefix/etc/config.site"
 else
-  ac_site_file1=$ac_default_prefix/share/config.site
-  ac_site_file2=$ac_default_prefix/etc/config.site
+  ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
 fi
-for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+
+for ac_site_file in $ac_site_files
 do
-  test "x$ac_site_file" = xNONE && continue
-  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
-$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+  case $ac_site_file in #(
+  */*) :
+     ;; #(
+  *) :
+    ac_site_file=./$ac_site_file ;;
+esac
+  if test -f "$ac_site_file" && test -r "$ac_site_file"; then
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;}
     sed 's/^/| /' "$ac_site_file" >&5
     . "$ac_site_file" \
-      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+      || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "failed to load site script $ac_site_file
 See \`config.log' for more details" "$LINENO" 5; }
   fi
 done
 
 if test -r "$cache_file"; then
   # Some versions of bash will fail to source /dev/null (special files
   # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
   if test /dev/null != "$cache_file" && test -f "$cache_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
-$as_echo "$as_me: loading cache $cache_file" >&6;}
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+printf "%s\n" "$as_me: loading cache $cache_file" >&6;}
     case $cache_file in
       [\\/]* | ?:[\\/]* ) . "$cache_file";;
       *)                      . "./$cache_file";;
     esac
   fi
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
-$as_echo "$as_me: creating cache $cache_file" >&6;}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+printf "%s\n" "$as_me: creating cache $cache_file" >&6;}
   >$cache_file
 fi
 
+# Test code for whether the C compiler supports C89 (global declarations)
+ac_c_conftest_c89_globals='
+/* Does the compiler advertise C89 conformance?
+   Do not test the value of __STDC__, because some compilers set it to 0
+   while being otherwise adequately conformant. */
+#if !defined __STDC__
+# error "Compiler does not advertise C89 conformance"
+#endif
+
+#include <stddef.h>
+#include <stdarg.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7 src/conf.sh.  */
+struct buf { int x; };
+struct buf * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not \xHH hex character constants.
+   These do not provoke an error unfortunately, instead are silently treated
+   as an "x".  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously \x00 != x always comes out true, for an
+   array size at least.  It is necessary to write \x00 == 0 to get something
+   that is true only with -std.  */
+int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) '\''x'\''
+int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int),
+               int, int);'
+
+# Test code for whether the C compiler supports C89 (body of main).
+ac_c_conftest_c89_main='
+ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]);
+'
+
+# Test code for whether the C compiler supports C99 (global declarations)
+ac_c_conftest_c99_globals='
+// Does the compiler advertise C99 conformance?
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
+# error "Compiler does not advertise C99 conformance"
+#endif
+
+#include <stdbool.h>
+extern int puts (const char *);
+extern int printf (const char *, ...);
+extern int dprintf (int, const char *, ...);
+extern void *malloc (size_t);
+
+// Check varargs macros.  These examples are taken from C99 6.10.3.5.
+// dprintf is used instead of fprintf to avoid needing to declare
+// FILE and stderr.
+#define debug(...) dprintf (2, __VA_ARGS__)
+#define showlist(...) puts (#__VA_ARGS__)
+#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
+static void
+test_varargs_macros (void)
+{
+  int x = 1234;
+  int y = 5678;
+  debug ("Flag");
+  debug ("X = %d\n", x);
+  showlist (The first, second, and third items.);
+  report (x>y, "x is %d but y is %d", x, y);
+}
+
+// Check long long types.
+#define BIG64 18446744073709551615ull
+#define BIG32 4294967295ul
+#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
+#if !BIG_OK
+  #error "your preprocessor is broken"
+#endif
+#if BIG_OK
+#else
+  #error "your preprocessor is broken"
+#endif
+static long long int bignum = -9223372036854775807LL;
+static unsigned long long int ubignum = BIG64;
+
+struct incomplete_array
+{
+  int datasize;
+  double data[];
+};
+
+struct named_init {
+  int number;
+  const wchar_t *name;
+  double average;
+};
+
+typedef const char *ccp;
+
+static inline int
+test_restrict (ccp restrict text)
+{
+  // See if C++-style comments work.
+  // Iterate through items via the restricted pointer.
+  // Also check for declarations in for loops.
+  for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i)
+    continue;
+  return 0;
+}
+
+// Check varargs and va_copy.
+static bool
+test_varargs (const char *format, ...)
+{
+  va_list args;
+  va_start (args, format);
+  va_list args_copy;
+  va_copy (args_copy, args);
+
+  const char *str = "";
+  int number = 0;
+  float fnumber = 0;
+
+  while (*format)
+    {
+      switch (*format++)
+	{
+	case '\''s'\'': // string
+	  str = va_arg (args_copy, const char *);
+	  break;
+	case '\''d'\'': // int
+	  number = va_arg (args_copy, int);
+	  break;
+	case '\''f'\'': // float
+	  fnumber = va_arg (args_copy, double);
+	  break;
+	default:
+	  break;
+	}
+    }
+  va_end (args_copy);
+  va_end (args);
+
+  return *str && number && fnumber;
+}
+'
+
+# Test code for whether the C compiler supports C99 (body of main).
+ac_c_conftest_c99_main='
+  // Check bool.
+  _Bool success = false;
+  success |= (argc != 0);
+
+  // Check restrict.
+  if (test_restrict ("String literal") == 0)
+    success = true;
+  char *restrict newvar = "Another string";
+
+  // Check varargs.
+  success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234);
+  test_varargs_macros ();
+
+  // Check flexible array members.
+  struct incomplete_array *ia =
+    malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
+  ia->datasize = 10;
+  for (int i = 0; i < ia->datasize; ++i)
+    ia->data[i] = i * 1.234;
+
+  // Check named initializers.
+  struct named_init ni = {
+    .number = 34,
+    .name = L"Test wide string",
+    .average = 543.34343,
+  };
+
+  ni.number = 58;
+
+  int dynamic_array[ni.number];
+  dynamic_array[0] = argv[0][0];
+  dynamic_array[ni.number - 1] = 543;
+
+  // work around unused variable warnings
+  ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\''
+	 || dynamic_array[ni.number - 1] != 543);
+'
+
+# Test code for whether the C compiler supports C11 (global declarations)
+ac_c_conftest_c11_globals='
+// Does the compiler advertise C11 conformance?
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
+# error "Compiler does not advertise C11 conformance"
+#endif
+
+// Check _Alignas.
+char _Alignas (double) aligned_as_double;
+char _Alignas (0) no_special_alignment;
+extern char aligned_as_int;
+char _Alignas (0) _Alignas (int) aligned_as_int;
+
+// Check _Alignof.
+enum
+{
+  int_alignment = _Alignof (int),
+  int_array_alignment = _Alignof (int[100]),
+  char_alignment = _Alignof (char)
+};
+_Static_assert (0 < -_Alignof (int), "_Alignof is signed");
+
+// Check _Noreturn.
+int _Noreturn does_not_return (void) { for (;;) continue; }
+
+// Check _Static_assert.
+struct test_static_assert
+{
+  int x;
+  _Static_assert (sizeof (int) <= sizeof (long int),
+                  "_Static_assert does not work in struct");
+  long int y;
+};
+
+// Check UTF-8 literals.
+#define u8 syntax error!
+char const utf8_literal[] = u8"happens to be ASCII" "another string";
+
+// Check duplicate typedefs.
+typedef long *long_ptr;
+typedef long int *long_ptr;
+typedef long_ptr long_ptr;
+
+// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
+struct anonymous
+{
+  union {
+    struct { int i; int j; };
+    struct { int k; long int l; } w;
+  };
+  int m;
+} v1;
+'
+
+# Test code for whether the C compiler supports C11 (body of main).
+ac_c_conftest_c11_main='
+  _Static_assert ((offsetof (struct anonymous, i)
+		   == offsetof (struct anonymous, w.k)),
+		  "Anonymous union alignment botch");
+  v1.i = 2;
+  v1.w.k = 5;
+  ok |= v1.i != 5;
+'
+
+# Test code for whether the C compiler supports C11 (complete).
+ac_c_conftest_c11_program="${ac_c_conftest_c89_globals}
+${ac_c_conftest_c99_globals}
+${ac_c_conftest_c11_globals}
+
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_c_conftest_c89_main}
+  ${ac_c_conftest_c99_main}
+  ${ac_c_conftest_c11_main}
+  return ok;
+}
+"
+
+# Test code for whether the C compiler supports C99 (complete).
+ac_c_conftest_c99_program="${ac_c_conftest_c89_globals}
+${ac_c_conftest_c99_globals}
+
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_c_conftest_c89_main}
+  ${ac_c_conftest_c99_main}
+  return ok;
+}
+"
+
+# Test code for whether the C compiler supports C89 (complete).
+ac_c_conftest_c89_program="${ac_c_conftest_c89_globals}
+
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_c_conftest_c89_main}
+  return ok;
+}
+"
+
+as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H"
+as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H"
+as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H"
+as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H"
+as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H"
+as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H"
+as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H"
+as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H"
+as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H"
+as_fn_append ac_header_c_list " sys/time.h sys_time_h HAVE_SYS_TIME_H"
 # Check that the precious variables saved in the cache have kept the same
 # value.
 ac_cache_corrupted=false
 for ac_var in $ac_precious_vars; do
   eval ac_old_set=\$ac_cv_env_${ac_var}_set
@@ -2218,56 +2517,57 @@
   eval ac_new_set=\$ac_env_${ac_var}_set
   eval ac_old_val=\$ac_cv_env_${ac_var}_value
   eval ac_new_val=\$ac_env_${ac_var}_value
   case $ac_old_set,$ac_new_set in
     set,)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,set)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,);;
     *)
       if test "x$ac_old_val" != "x$ac_new_val"; then
 	# differences in whitespace do not lead to failure.
 	ac_old_val_w=`echo x $ac_old_val`
 	ac_new_val_w=`echo x $ac_new_val`
 	if test "$ac_old_val_w" != "$ac_new_val_w"; then
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
-$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+	  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
 	  ac_cache_corrupted=:
 	else
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
-$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+	  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
 	  eval $ac_var=\$ac_old_val
 	fi
-	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
-$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
-	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
-$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+printf "%s\n" "$as_me:   former value:  \`$ac_old_val'" >&2;}
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+printf "%s\n" "$as_me:   current value: \`$ac_new_val'" >&2;}
       fi;;
   esac
   # Pass precious variables to config.status.
   if test "$ac_new_set" = set; then
     case $ac_new_val in
-    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
     *) ac_arg=$ac_var=$ac_new_val ;;
     esac
     case " $ac_configure_args " in
       *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
       *) as_fn_append ac_configure_args " '$ac_arg'" ;;
     esac
   fi
 done
 if $ac_cache_corrupted; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
-$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file'
+	    and start over" "$LINENO" 5
 fi
 ## -------------------- ##
 ## Main body of script. ##
 ## -------------------- ##
 
@@ -2283,11 +2583,11 @@
 
 
 TK_VERSION=8.7
 TK_MAJOR_VERSION=8
 TK_MINOR_VERSION=7
-TK_PATCH_LEVEL="a4"
+TK_PATCH_LEVEL="a6"
 VERSION=${TK_VERSION}
 LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv"
 
 #--------------------------------------------------------------------
 # Find and load the tclConfig.sh file
@@ -2303,28 +2603,30 @@
     if test x"${no_tcl}" = x ; then
 	# we reset no_tcl in case something fails here
 	no_tcl=true
 
 # Check whether --with-tcl was given.
-if test "${with_tcl+set}" = set; then :
+if test ${with_tcl+y}
+then :
   withval=$with_tcl; with_tclconfig="${withval}"
 fi
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl configuration" >&5
-$as_echo_n "checking for Tcl configuration... " >&6; }
-	if ${ac_cv_c_tclconfig+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Tcl configuration" >&5
+printf %s "checking for Tcl configuration... " >&6; }
+	if test ${ac_cv_c_tclconfig+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 
 	    # First check to see if --with-tcl was specified.
 	    if test x"${with_tclconfig}" != x ; then
 		case "${with_tclconfig}" in
 		    */tclConfig.sh )
 			if test -f "${with_tclconfig}"; then
-			    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&5
-$as_echo "$as_me: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&2;}
+			    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&5
+printf "%s\n" "$as_me: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&2;}
 			    with_tclconfig="`echo "${with_tclconfig}" | sed 's!/tclConfig\.sh$!!'`"
 			fi ;;
 		esac
 		if test -f "${with_tclconfig}/tclConfig.sh" ; then
 		    ac_cv_c_tclconfig="`(cd "${with_tclconfig}"; pwd)`"
@@ -2410,26 +2712,26 @@
 	    TCL_BIN_DIR="# no Tcl configs found"
 	    as_fn_error $? "Can't find Tcl configuration definitions. Use --with-tcl to specify a directory containing tclConfig.sh" "$LINENO" 5
 	else
 	    no_tcl=
 	    TCL_BIN_DIR="${ac_cv_c_tclconfig}"
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${TCL_BIN_DIR}/tclConfig.sh" >&5
-$as_echo "found ${TCL_BIN_DIR}/tclConfig.sh" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found ${TCL_BIN_DIR}/tclConfig.sh" >&5
+printf "%s\n" "found ${TCL_BIN_DIR}/tclConfig.sh" >&6; }
 	fi
     fi
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for existence of ${TCL_BIN_DIR}/tclConfig.sh" >&5
-$as_echo_n "checking for existence of ${TCL_BIN_DIR}/tclConfig.sh... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for existence of ${TCL_BIN_DIR}/tclConfig.sh" >&5
+printf %s "checking for existence of ${TCL_BIN_DIR}/tclConfig.sh... " >&6; }
 
     if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: loading" >&5
-$as_echo "loading" >&6; }
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: loading" >&5
+printf "%s\n" "loading" >&6; }
 	. "${TCL_BIN_DIR}/tclConfig.sh"
     else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not find ${TCL_BIN_DIR}/tclConfig.sh" >&5
-$as_echo "could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6; }
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: could not find ${TCL_BIN_DIR}/tclConfig.sh" >&5
+printf "%s\n" "could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6; }
     fi
 
     # If the TCL_BIN_DIR is the build directory (not the install directory),
     # then set the common variable name to the value of the build variables.
     # For example, the variable TCL_LIB_SPEC will be set to the value
@@ -2487,15 +2789,16 @@
 Found config for Tcl ${TCL_VERSION}" "$LINENO" 5
 fi
 fi
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tclsh" >&5
-$as_echo_n "checking for tclsh... " >&6; }
-    if ${ac_cv_path_tclsh+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tclsh" >&5
+printf %s "checking for tclsh... " >&6; }
+    if test ${ac_cv_path_tclsh+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 	search_path=`echo ${PATH} | sed -e 's/:/ /g'`
 	for dir in $search_path ; do
 	    for j in `ls -r $dir/tclsh[8-9]* 2> /dev/null` \
 		    `ls -r $dir/tclsh* 2> /dev/null` ; do
@@ -2511,26 +2814,26 @@
 fi
 
 
     if test -f "$ac_cv_path_tclsh" ; then
 	TCLSH_PROG="$ac_cv_path_tclsh"
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $TCLSH_PROG" >&5
-$as_echo "$TCLSH_PROG" >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $TCLSH_PROG" >&5
+printf "%s\n" "$TCLSH_PROG" >&6; }
     else
 	# It is not an error if an installed version of Tcl can't be located.
 	TCLSH_PROG=""
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: No tclsh found on PATH" >&5
-$as_echo "No tclsh found on PATH" >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: No tclsh found on PATH" >&5
+printf "%s\n" "No tclsh found on PATH" >&6; }
     fi
 
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tclsh in Tcl build directory" >&5
-$as_echo_n "checking for tclsh in Tcl build directory... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tclsh in Tcl build directory" >&5
+printf %s "checking for tclsh in Tcl build directory... " >&6; }
     BUILD_TCLSH="${TCL_BIN_DIR}"/tclsh
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BUILD_TCLSH" >&5
-$as_echo "$BUILD_TCLSH" >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $BUILD_TCLSH" >&5
+printf "%s\n" "$BUILD_TCLSH" >&6; }
 
 
 
 #------------------------------------------------------------------------
 # Handle the --prefix=... option
@@ -2549,64 +2852,67 @@
 #------------------------------------------------------------------------
 # Compress and/or soft link the manpages?
 #------------------------------------------------------------------------
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use symlinks for manpages" >&5
-$as_echo_n "checking whether to use symlinks for manpages... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use symlinks for manpages" >&5
+printf %s "checking whether to use symlinks for manpages... " >&6; }
     # Check whether --enable-man-symlinks was given.
-if test "${enable_man_symlinks+set}" = set; then :
+if test ${enable_man_symlinks+y}
+then :
   enableval=$enable_man_symlinks; test "$enableval" != "no" && MAN_FLAGS="$MAN_FLAGS --symlinks"
-else
+else $as_nop
   enableval="no"
 fi
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enableval" >&5
-$as_echo "$enableval" >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enableval" >&5
+printf "%s\n" "$enableval" >&6; }
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to compress the manpages" >&5
-$as_echo_n "checking whether to compress the manpages... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to compress the manpages" >&5
+printf %s "checking whether to compress the manpages... " >&6; }
     # Check whether --enable-man-compression was given.
-if test "${enable_man_compression+set}" = set; then :
+if test ${enable_man_compression+y}
+then :
   enableval=$enable_man_compression; case $enableval in
 	    yes) as_fn_error $? "missing argument to --enable-man-compression" "$LINENO" 5;;
 	    no)  ;;
 	    *)   MAN_FLAGS="$MAN_FLAGS --compress $enableval";;
 	esac
-else
+else $as_nop
   enableval="no"
 fi
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enableval" >&5
-$as_echo "$enableval" >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enableval" >&5
+printf "%s\n" "$enableval" >&6; }
     if test "$enableval" != "no"; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for compressed file suffix" >&5
-$as_echo_n "checking for compressed file suffix... " >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for compressed file suffix" >&5
+printf %s "checking for compressed file suffix... " >&6; }
 	touch TeST
 	$enableval TeST
 	Z=`ls TeST* | sed 's/^....//'`
 	rm -f TeST*
 	MAN_FLAGS="$MAN_FLAGS --extension $Z"
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $Z" >&5
-$as_echo "$Z" >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $Z" >&5
+printf "%s\n" "$Z" >&6; }
     fi
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to add a package name suffix for the manpages" >&5
-$as_echo_n "checking whether to add a package name suffix for the manpages... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to add a package name suffix for the manpages" >&5
+printf %s "checking whether to add a package name suffix for the manpages... " >&6; }
     # Check whether --enable-man-suffix was given.
-if test "${enable_man_suffix+set}" = set; then :
+if test ${enable_man_suffix+y}
+then :
   enableval=$enable_man_suffix; case $enableval in
 	    yes) enableval="tk" MAN_FLAGS="$MAN_FLAGS --suffix $enableval";;
 	    no)  ;;
 	    *)   MAN_FLAGS="$MAN_FLAGS --suffix $enableval";;
 	esac
-else
+else $as_nop
   enableval="no"
 fi
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enableval" >&5
-$as_echo "$enableval" >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enableval" >&5
+printf "%s\n" "$enableval" >&6; }
 
 
 
 
 #------------------------------------------------------------------------
@@ -2616,36 +2922,50 @@
 # If the user did not set CFLAGS, set it now to keep
 # the AC_PROG_CC macro from adding "-g -O2".
 if test "${CFLAGS+set}" != "set" ; then
     CFLAGS=""
 fi
+
+
+
+
+
+
+
+
+
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -2652,40 +2972,45 @@
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
 fi
 if test -z "$ac_cv_prog_CC"; then
   ac_ct_CC=$CC
   # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_CC"; then
   ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -2692,24 +3017,24 @@
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+printf "%s\n" "$ac_ct_CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_CC" = x; then
     CC=""
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     CC=$ac_ct_CC
   fi
 else
@@ -2718,27 +3043,32 @@
 
 if test -z "$CC"; then
           if test -n "$ac_tool_prefix"; then
     # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -2745,45 +3075,50 @@
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
   fi
 fi
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   ac_prog_rejected=no
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
      fi
     ac_cv_prog_CC="cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -2795,22 +3130,22 @@
   if test $# != 0; then
     # We chose a different compiler from the bogus one.
     # However, it has the same basename, so the bogon will be chosen
     # first if we set CC to just the basename; use the full file name.
     shift
-    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+    ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@"
   fi
 fi
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
 fi
 if test -z "$CC"; then
@@ -2817,27 +3152,32 @@
   if test -n "$ac_tool_prefix"; then
   for ac_prog in cl.exe
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -2844,15 +3184,15 @@
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
     test -n "$CC" && break
   done
@@ -2861,27 +3201,32 @@
   ac_ct_CC=$CC
   for ac_prog in cl.exe
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_CC"; then
   ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -2888,15 +3233,15 @@
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+printf "%s\n" "$ac_ct_CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
   test -n "$ac_ct_CC" && break
 done
@@ -2904,56 +3249,160 @@
   if test "x$ac_ct_CC" = x; then
     CC=""
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args.
+set dummy ${ac_tool_prefix}clang; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}clang"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "clang", so it can be a program name with args.
+set dummy clang; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="clang"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+printf "%s\n" "$ac_ct_CC" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     CC=$ac_ct_CC
   fi
+else
+  CC="$ac_cv_prog_CC"
 fi
 
 fi
 
 
-test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "no acceptable C compiler found in \$PATH
 See \`config.log' for more details" "$LINENO" 5; }
 
 # Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
 set X $ac_compile
 ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
+for ac_option in --version -v -V -qversion -version; do
   { { ac_try="$ac_compiler $ac_option >&5"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_compiler $ac_option >&5") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
     sed '10a\
 ... rest of stderr output deleted ...
          10q' conftest.err >conftest.er1
     cat conftest.er1 >&5
   fi
   rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
 done
 
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
@@ -2961,13 +3410,13 @@
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
 # Try to create an executable without -o first, disregard a.out.
 # It will help us diagnose broken compilers, and finding out an intuition
 # of exeext.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-$as_echo_n "checking whether the C compiler works... " >&6; }
-ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+printf %s "checking whether the C compiler works... " >&6; }
+ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
 
 # The possible output files:
 ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
 
 ac_rmfiles=
@@ -2984,15 +3433,16 @@
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_link_default") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+then :
   # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
 # So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
 # in a Makefile.  We should not override ac_cv_exeext if it was cached,
 # so that the user can short-circuit this test for compilers unknown to
 # Autoconf.
@@ -3005,11 +3455,11 @@
     [ab].out )
 	# We found the default executable, but exeext='' is most
 	# certainly right.
 	break;;
     *.* )
-	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+	if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no;
 	then :; else
 	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
 	fi
 	# We set ac_cv_exeext here because the later test for it is not
 	# safe: cross compilers may not add the suffix if given an `-o'
@@ -3021,48 +3471,50 @@
 	break;;
   esac
 done
 test "$ac_cv_exeext" = no && ac_cv_exeext=
 
-else
+else $as_nop
   ac_file=''
 fi
-if test -z "$ac_file"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-$as_echo "$as_me: failed program was:" >&5
+if test -z "$ac_file"
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error 77 "C compiler cannot create executables
 See \`config.log' for more details" "$LINENO" 5; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
-$as_echo_n "checking for C compiler default output file name... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-$as_echo "$ac_file" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+printf %s "checking for C compiler default output file name... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+printf "%s\n" "$ac_file" >&6; }
 ac_exeext=$ac_cv_exeext
 
 rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
 ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
-$as_echo_n "checking for suffix of executables... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+printf %s "checking for suffix of executables... " >&6; }
 if { { ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_link") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+then :
   # If both `conftest.exe' and `conftest' are `present' (well, observable)
 # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
 # work properly (i.e., refer to `conftest.exe'), while it won't with
 # `rm'.
 for ac_file in conftest.exe conftest conftest.*; do
@@ -3072,28 +3524,28 @@
     *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
 	  break;;
     * ) break;;
   esac
 done
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+else $as_nop
+  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "cannot compute suffix of executables: cannot compile and link
 See \`config.log' for more details" "$LINENO" 5; }
 fi
 rm -f conftest conftest$ac_cv_exeext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
-$as_echo "$ac_cv_exeext" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+printf "%s\n" "$ac_cv_exeext" >&6; }
 
 rm -f conftest.$ac_ext
 EXEEXT=$ac_cv_exeext
 ac_exeext=$EXEEXT
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 FILE *f = fopen ("conftest.out", "w");
  return ferror (f) || fclose (f) != 0;
 
   ;
@@ -3101,63 +3553,64 @@
 }
 _ACEOF
 ac_clean_files="$ac_clean_files conftest.out"
 # Check that the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-$as_echo_n "checking whether we are cross compiling... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+printf %s "checking whether we are cross compiling... " >&6; }
 if test "$cross_compiling" != yes; then
   { { ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_link") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
   if { ac_try='./conftest$ac_cv_exeext'
   { { case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_try") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; }; then
     cross_compiling=no
   else
     if test "$cross_compiling" = maybe; then
 	cross_compiling=yes
     else
-	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run C compiled programs.
+	{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot run C compiled programs.
 If you meant to cross compile, use \`--host'.
 See \`config.log' for more details" "$LINENO" 5; }
     fi
   fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-$as_echo "$cross_compiling" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+printf "%s\n" "$cross_compiling" >&6; }
 
 rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
 ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
-$as_echo_n "checking for suffix of object files... " >&6; }
-if ${ac_cv_objext+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+printf %s "checking for suffix of object files... " >&6; }
+if test ${ac_cv_objext+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
@@ -3167,139 +3620,148 @@
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_compile") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+then :
   for ac_file in conftest.o conftest.obj conftest.*; do
   test -f "$ac_file" || continue;
   case $ac_file in
     *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
     *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
        break;;
   esac
 done
-else
-  $as_echo "$as_me: failed program was:" >&5
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "cannot compute suffix of object files: cannot compile
 See \`config.log' for more details" "$LINENO" 5; }
 fi
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
-$as_echo "$ac_cv_objext" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+printf "%s\n" "$ac_cv_objext" >&6; }
 OBJEXT=$ac_cv_objext
 ac_objext=$OBJEXT
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
-$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if ${ac_cv_c_compiler_gnu+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5
+printf %s "checking whether the compiler supports GNU C... " >&6; }
+if test ${ac_cv_c_compiler_gnu+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 #ifndef __GNUC__
        choke me
 #endif
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_compiler_gnu=yes
-else
+else $as_nop
   ac_compiler_gnu=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 ac_cv_c_compiler_gnu=$ac_compiler_gnu
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
-$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; }
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
 if test $ac_compiler_gnu = yes; then
   GCC=yes
 else
   GCC=
 fi
-ac_test_CFLAGS=${CFLAGS+set}
+ac_test_CFLAGS=${CFLAGS+y}
 ac_save_CFLAGS=$CFLAGS
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
-$as_echo_n "checking whether $CC accepts -g... " >&6; }
-if ${ac_cv_prog_cc_g+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+printf %s "checking whether $CC accepts -g... " >&6; }
+if test ${ac_cv_prog_cc_g+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_save_c_werror_flag=$ac_c_werror_flag
    ac_c_werror_flag=yes
    ac_cv_prog_cc_g=no
    CFLAGS="-g"
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_prog_cc_g=yes
-else
+else $as_nop
   CFLAGS=""
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
 
-else
+else $as_nop
   ac_c_werror_flag=$ac_save_c_werror_flag
 	 CFLAGS="-g"
 	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_prog_cc_g=yes
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
    ac_c_werror_flag=$ac_save_c_werror_flag
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
-$as_echo "$ac_cv_prog_cc_g" >&6; }
-if test "$ac_test_CFLAGS" = set; then
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+printf "%s\n" "$ac_cv_prog_cc_g" >&6; }
+if test $ac_test_CFLAGS; then
   CFLAGS=$ac_save_CFLAGS
 elif test $ac_cv_prog_cc_g = yes; then
   if test "$GCC" = yes; then
     CFLAGS="-g -O2"
   else
@@ -3310,133 +3772,185 @@
     CFLAGS="-O2"
   else
     CFLAGS=
   fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
-$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if ${ac_cv_prog_cc_c89+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+ac_prog_cc_stdc=no
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5
+printf %s "checking for $CC option to enable C11 features... " >&6; }
+if test ${ac_cv_prog_cc_c11+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_cv_prog_cc_c11=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_c_conftest_c11_program
+_ACEOF
+for ac_arg in '' -std=gnu11
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_prog_cc_c11=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam
+  test "x$ac_cv_prog_cc_c11" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+fi
+
+if test "x$ac_cv_prog_cc_c11" = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
+else $as_nop
+  if test "x$ac_cv_prog_cc_c11" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5
+printf "%s\n" "$ac_cv_prog_cc_c11" >&6; }
+     CC="$CC $ac_cv_prog_cc_c11"
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11
+  ac_prog_cc_stdc=c11
+fi
+fi
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5
+printf %s "checking for $CC option to enable C99 features... " >&6; }
+if test ${ac_cv_prog_cc_c99+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_cv_prog_cc_c99=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_c_conftest_c99_program
+_ACEOF
+for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99=
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_prog_cc_c99=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam
+  test "x$ac_cv_prog_cc_c99" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+fi
+
+if test "x$ac_cv_prog_cc_c99" = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
+else $as_nop
+  if test "x$ac_cv_prog_cc_c99" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
+printf "%s\n" "$ac_cv_prog_cc_c99" >&6; }
+     CC="$CC $ac_cv_prog_cc_c99"
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
+  ac_prog_cc_stdc=c99
+fi
+fi
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5
+printf %s "checking for $CC option to enable C89 features... " >&6; }
+if test ${ac_cv_prog_cc_c89+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_cv_prog_cc_c89=no
 ac_save_CC=$CC
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdio.h>
-struct stat;
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
-{
-  return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
-  char *s;
-  va_list v;
-  va_start (v,p);
-  s = g (p, va_arg (v,int));
-  va_end (v);
-  return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
-   function prototypes and stuff, but not '\xHH' hex character constants.
-   These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std is added to get
-   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
-   array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std.  */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
-   inside strings and character constants.  */
-#define FOO(x) 'x'
-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
-  ;
-  return 0;
-}
+$ac_c_conftest_c89_program
 _ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 do
   CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
+  if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_prog_cc_c89=$ac_arg
 fi
-rm -f core conftest.err conftest.$ac_objext
+rm -f core conftest.err conftest.$ac_objext conftest.beam
   test "x$ac_cv_prog_cc_c89" != "xno" && break
 done
 rm -f conftest.$ac_ext
 CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c89" in
-  x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
-  xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_c89"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
-$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c89" != xno; then :
-
+fi
+
+if test "x$ac_cv_prog_cc_c89" = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
+else $as_nop
+  if test "x$ac_cv_prog_cc_c89" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+printf "%s\n" "$ac_cv_prog_cc_c89" >&6; }
+     CC="$CC $ac_cv_prog_cc_c89"
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
+  ac_prog_cc_stdc=c89
+fi
 fi
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
-$as_echo_n "checking for inline... " >&6; }
-if ${ac_cv_c_inline+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
+printf %s "checking for inline... " >&6; }
+if test ${ac_cv_c_inline+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #ifndef __cplusplus
 typedef int foo_t;
-static $ac_kw foo_t static_foo () {return 0; }
-$ac_kw foo_t foo () {return 0; }
+static $ac_kw foo_t static_foo (void) {return 0; }
+$ac_kw foo_t foo (void) {return 0; }
 #endif
 
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_c_inline=$ac_kw
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
   test "$ac_cv_c_inline" != no && break
 done
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
-$as_echo "$ac_cv_c_inline" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
+printf "%s\n" "$ac_cv_c_inline" >&6; }
 
 case $ac_cv_c_inline in
   inline | yes) ;;
   *)
     case $ac_cv_c_inline in
@@ -3456,38 +3970,40 @@
 # If we're using GCC, see if the compiler understands -pipe.  If so, use it.
 # It makes compiling go faster.  (This is only a performance feature.)
 #------------------------------------------------------------------------
 
 if test -z "$no_pipe" && test -n "$GCC"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler understands -pipe" >&5
-$as_echo_n "checking if the compiler understands -pipe... " >&6; }
-if ${tcl_cv_cc_pipe+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the compiler understands -pipe" >&5
+printf %s "checking if the compiler understands -pipe... " >&6; }
+if test ${tcl_cv_cc_pipe+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -pipe"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_cc_pipe=yes
-else
+else $as_nop
   tcl_cv_cc_pipe=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 	CFLAGS=$hold_cflags
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_pipe" >&5
-$as_echo "$tcl_cv_cc_pipe" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_pipe" >&5
+printf "%s\n" "$tcl_cv_cc_pipe" >&6; }
     if test $tcl_cv_cc_pipe = yes; then
 	CFLAGS="$CFLAGS -pipe"
     fi
 fi
 
@@ -3496,56 +4012,48 @@
 #------------------------------------------------------------------------
 
 
 
 # Check whether --with-encoding was given.
-if test "${with_encoding+set}" = set; then :
+if test ${with_encoding+y}
+then :
   withval=$with_encoding; with_tcencoding=${withval}
 fi
 
 
     if test x"${with_tcencoding}" != x ; then
 
-cat >>confdefs.h <<_ACEOF
-#define TCL_CFGVAL_ENCODING "${with_tcencoding}"
-_ACEOF
-
-    else
-
-$as_echo "#define TCL_CFGVAL_ENCODING \"iso8859-1\"" >>confdefs.h
-
-    fi
-
-
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to build libraries" >&5
-$as_echo_n "checking how to build libraries... " >&6; }
-    # Check whether --enable-shared was given.
-if test "${enable_shared+set}" = set; then :
-  enableval=$enable_shared; tcl_ok=$enableval
-else
-  tcl_ok=yes
-fi
-
-
-    if test "${enable_shared+set}" = set; then
-	enableval="$enable_shared"
-	tcl_ok=$enableval
-    else
-	tcl_ok=yes
-    fi
-
-    if test "$tcl_ok" = "yes" ; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: shared" >&5
-$as_echo "shared" >&6; }
-	SHARED_BUILD=1
-    else
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: static" >&5
-$as_echo "static" >&6; }
-	SHARED_BUILD=0
-
-$as_echo "#define STATIC_BUILD 1" >>confdefs.h
+printf "%s\n" "#define TCL_CFGVAL_ENCODING \"${with_tcencoding}\"" >>confdefs.h
+
+    else
+
+printf "%s\n" "#define TCL_CFGVAL_ENCODING \"utf-8\"" >>confdefs.h
+
+    fi
+
+
+
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to build libraries" >&5
+printf %s "checking how to build libraries... " >&6; }
+    # Check whether --enable-shared was given.
+if test ${enable_shared+y}
+then :
+  enableval=$enable_shared; tcl_ok=$enableval
+else $as_nop
+  tcl_ok=yes
+fi
+
+    if test "$tcl_ok" = "yes" ; then
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: shared" >&5
+printf "%s\n" "shared" >&6; }
+	SHARED_BUILD=1
+    else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: static" >&5
+printf "%s\n" "static" >&6; }
+	SHARED_BUILD=0
+
+printf "%s\n" "#define STATIC_BUILD 1" >>confdefs.h
 
     fi
 
 
 
@@ -3556,27 +4064,32 @@
 #--------------------------------------------------------------------
 
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_RANLIB+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -3583,40 +4096,45 @@
 
 fi
 fi
 RANLIB=$ac_cv_prog_RANLIB
 if test -n "$RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
-$as_echo "$RANLIB" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+printf "%s\n" "$RANLIB" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
 fi
 if test -z "$ac_cv_prog_RANLIB"; then
   ac_ct_RANLIB=$RANLIB
   # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_RANLIB+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_RANLIB"; then
   ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_RANLIB="ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -3623,539 +4141,179 @@
 
 fi
 fi
 ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
 if test -n "$ac_ct_RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
-$as_echo "$ac_ct_RANLIB" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+printf "%s\n" "$ac_ct_RANLIB" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_RANLIB" = x; then
     RANLIB=":"
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     RANLIB=$ac_ct_RANLIB
   fi
 else
   RANLIB="$ac_cv_prog_RANLIB"
 fi
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
-$as_echo_n "checking how to run the C preprocessor... " >&6; }
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
-fi
-if test -z "$CPP"; then
-  if ${ac_cv_prog_CPP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-      # Double quotes because CPP needs to be expanded
-    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
-    do
-      ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
-else
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-  break
-fi
-
-    done
-    ac_cv_prog_CPP=$CPP
-
-fi
-  CPP=$ac_cv_prog_CPP
-else
-  ac_cv_prog_CPP=$CPP
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
-$as_echo "$CPP" >&6; }
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
-else
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
-$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if ${ac_cv_path_GREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$GREP"; then
-  ac_path_GREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in grep ggrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_GREP" || continue
-# Check for GNU ac_path_GREP and select it if it is found.
-  # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'GREP' >> "conftest.nl"
-    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_GREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_GREP="$ac_path_GREP"
-      ac_path_GREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_GREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_GREP"; then
-    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_GREP=$GREP
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
-$as_echo "$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-$as_echo_n "checking for egrep... " >&6; }
-if ${ac_cv_path_EGREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
-   then ac_cv_path_EGREP="$GREP -E"
-   else
-     if test -z "$EGREP"; then
-  ac_path_EGREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in egrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_EGREP" || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
-  # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'EGREP' >> "conftest.nl"
-    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_EGREP="$ac_path_EGREP"
-      ac_path_EGREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_EGREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_EGREP=$EGREP
-fi
-
-   fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-$as_echo "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if ${ac_cv_header_stdc+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_header_stdc=yes
-else
-  ac_cv_header_stdc=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then :
-  :
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
-		   (('a' <= (c) && (c) <= 'i') \
-		     || ('j' <= (c) && (c) <= 'r') \
-		     || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-	|| toupper (i) != TOUPPER (i))
-      return 2;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
-$as_echo "$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-$as_echo "#define STDC_HEADERS 1" >>confdefs.h
-
-fi
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-		  inttypes.h stdint.h unistd.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
+ac_header= ac_cache=
+for ac_item in $ac_header_c_list
+do
+  if test $ac_cache; then
+    ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default"
+    if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then
+      printf "%s\n" "#define $ac_item 1" >> confdefs.h
+    fi
+    ac_header= ac_cache=
+  elif test $ac_header; then
+    ac_cache=$ac_item
+  else
+    ac_header=$ac_item
+  fi
+done
+
+
+
+
+
+
+
+
+if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes
+then :
+
+printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
 
 
     # Step 0.a: Enable 64 bit support?
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if 64bit support is requested" >&5
-$as_echo_n "checking if 64bit support is requested... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if 64bit support is requested" >&5
+printf %s "checking if 64bit support is requested... " >&6; }
     # Check whether --enable-64bit was given.
-if test "${enable_64bit+set}" = set; then :
+if test ${enable_64bit+y}
+then :
   enableval=$enable_64bit; do64bit=$enableval
-else
+else $as_nop
   do64bit=no
 fi
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $do64bit" >&5
-$as_echo "$do64bit" >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $do64bit" >&5
+printf "%s\n" "$do64bit" >&6; }
 
     # Step 0.b: Enable Solaris 64 bit VIS support?
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if 64bit Sparc VIS support is requested" >&5
-$as_echo_n "checking if 64bit Sparc VIS support is requested... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if 64bit Sparc VIS support is requested" >&5
+printf %s "checking if 64bit Sparc VIS support is requested... " >&6; }
     # Check whether --enable-64bit-vis was given.
-if test "${enable_64bit_vis+set}" = set; then :
+if test ${enable_64bit_vis+y}
+then :
   enableval=$enable_64bit_vis; do64bitVIS=$enableval
-else
+else $as_nop
   do64bitVIS=no
 fi
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $do64bitVIS" >&5
-$as_echo "$do64bitVIS" >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $do64bitVIS" >&5
+printf "%s\n" "$do64bitVIS" >&6; }
     # Force 64bit on with VIS
-    if test "$do64bitVIS" = "yes"; then :
+    if test "$do64bitVIS" = "yes"
+then :
   do64bit=yes
 fi
 
     # Step 0.c: Check if visibility support is available. Do this here so
     # that platform specific alternatives can be used below if this fails.
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports visibility \"hidden\"" >&5
-$as_echo_n "checking if compiler supports visibility \"hidden\"... " >&6; }
-if ${tcl_cv_cc_visibility_hidden+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if compiler supports visibility \"hidden\"" >&5
+printf %s "checking if compiler supports visibility \"hidden\"... " >&6; }
+if test ${tcl_cv_cc_visibility_hidden+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 	    extern __attribute__((__visibility__("hidden"))) void f(void);
 	    void f(void) {}
 int
-main ()
+main (void)
 {
 f();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   tcl_cv_cc_visibility_hidden=yes
-else
+else $as_nop
   tcl_cv_cc_visibility_hidden=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 	CFLAGS=$hold_cflags
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_visibility_hidden" >&5
-$as_echo "$tcl_cv_cc_visibility_hidden" >&6; }
-    if test $tcl_cv_cc_visibility_hidden = yes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_visibility_hidden" >&5
+printf "%s\n" "$tcl_cv_cc_visibility_hidden" >&6; }
+    if test $tcl_cv_cc_visibility_hidden = yes
+then :
 
 
-$as_echo "#define MODULE_SCOPE extern __attribute__((__visibility__(\"hidden\")))" >>confdefs.h
+printf "%s\n" "#define MODULE_SCOPE extern __attribute__((__visibility__(\"hidden\")))" >>confdefs.h
 
 
-$as_echo "#define HAVE_HIDDEN 1" >>confdefs.h
+printf "%s\n" "#define HAVE_HIDDEN 1" >>confdefs.h
 
 
 fi
 
     # Step 0.d: Disable -rpath support?
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if rpath support is requested" >&5
-$as_echo_n "checking if rpath support is requested... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if rpath support is requested" >&5
+printf %s "checking if rpath support is requested... " >&6; }
     # Check whether --enable-rpath was given.
-if test "${enable_rpath+set}" = set; then :
+if test ${enable_rpath+y}
+then :
   enableval=$enable_rpath; doRpath=$enableval
-else
+else $as_nop
   doRpath=yes
 fi
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $doRpath" >&5
-$as_echo "$doRpath" >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $doRpath" >&5
+printf "%s\n" "$doRpath" >&6; }
 
     # Step 1: set the variable "system" to hold the name and version number
     # for the system.
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking system version" >&5
-$as_echo_n "checking system version... " >&6; }
-if ${tcl_cv_sys_version+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking system version" >&5
+printf %s "checking system version... " >&6; }
+if test ${tcl_cv_sys_version+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 	if test "${TEA_PLATFORM}" = "windows" ; then
 	    tcl_cv_sys_version=windows
 	else
 	    tcl_cv_sys_version=`uname -s`-`uname -r`
 	    if test "$?" -ne 0 ; then
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find uname command" >&5
-$as_echo "$as_me: WARNING: can't find uname command" >&2;}
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: can't find uname command" >&5
+printf "%s\n" "$as_me: WARNING: can't find uname command" >&2;}
 		tcl_cv_sys_version=unknown
 	    else
 		if test "`uname -s`" = "AIX" ; then
 		    tcl_cv_sys_version=AIX-`uname -v`.`uname -r`
 		fi
@@ -4164,57 +4322,57 @@
 		fi
 	    fi
 	fi
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_sys_version" >&5
-$as_echo "$tcl_cv_sys_version" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_sys_version" >&5
+printf "%s\n" "$tcl_cv_sys_version" >&6; }
     system=$tcl_cv_sys_version
 
 
     # Step 2: check for existence of -ldl library.  This is needed because
     # Linux can use either -ldl or -ldld for dynamic loading.
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
-$as_echo_n "checking for dlopen in -ldl... " >&6; }
-if ${ac_cv_lib_dl_dlopen+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+printf %s "checking for dlopen in -ldl... " >&6; }
+if test ${ac_cv_lib_dl_dlopen+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldl  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
 char dlopen ();
 int
-main ()
+main (void)
 {
 return dlopen ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_dl_dlopen=yes
-else
+else $as_nop
   ac_cv_lib_dl_dlopen=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
-$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
-if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes
+then :
   have_dl=yes
-else
+else $as_nop
   have_dl=no
 fi
 
 
     # Require ranlib early so we can override it in special cases below.
@@ -4234,49 +4392,55 @@
     UNSHARED_LIB_SUFFIX=""
     TCL_TRIM_DOTS='`echo ${VERSION} | tr -d .`'
     ECHO_VERSION='`echo ${VERSION}`'
     TCL_LIB_VERSIONS_OK=ok
     CFLAGS_DEBUG=-g
-    if test "$GCC" = yes; then :
+    if test "$GCC" = yes
+then :
 
 	CFLAGS_OPTIMIZE=-O2
 	CFLAGS_WARNING="-Wall -Wextra -Wshadow -Wundef -Wwrite-strings -Wpointer-arith"
 	case "${CC}" in
 	    *++|*++-*)
 		;;
 	    *)
-		CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -Wdeclaration-after-statement"
+		CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -fextended-identifiers"
 		;;
 	esac
 
 
-else
+else $as_nop
 
 	CFLAGS_OPTIMIZE=-O
 	CFLAGS_WARNING=""
 
 fi
     if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_AR+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$AR"; then
   ac_cv_prog_AR="$AR" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_AR="${ac_tool_prefix}ar"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -4283,40 +4447,45 @@
 
 fi
 fi
 AR=$ac_cv_prog_AR
 if test -n "$AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
-$as_echo "$AR" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+printf "%s\n" "$AR" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
 fi
 if test -z "$ac_cv_prog_AR"; then
   ac_ct_AR=$AR
   # Extract the first word of "ar", so it can be a program name with args.
 set dummy ar; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_AR+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_AR"; then
   ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_AR="ar"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -4323,24 +4492,24 @@
 
 fi
 fi
 ac_ct_AR=$ac_cv_prog_ac_ct_AR
 if test -n "$ac_ct_AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
-$as_echo "$ac_ct_AR" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+printf "%s\n" "$ac_ct_AR" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_AR" = x; then
     AR=""
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     AR=$ac_ct_AR
   fi
 else
@@ -4350,16 +4519,18 @@
     STLIB_LD='${AR} cr'
     LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
     PLAT_OBJS=""
     PLAT_SRCS=""
     LDAIX_SRC=""
-    if test "x${SHLIB_VERSION}" = x; then :
+    if test "x${SHLIB_VERSION}" = x
+then :
   SHLIB_VERSION="1.0"
 fi
     case $system in
 	AIX-*)
-	    if test "$GCC" != "yes"; then :
+	    if test "$GCC" != "yes"
+then :
 
 		# AIX requires the _r compiler when gcc isn't being used
 		case "${CC}" in
 		    *_r|*_r\ *)
 			# ok ...
@@ -4367,12 +4538,12 @@
 		    *)
 			# Make sure only first arg gets _r
 		    	CC=`echo "$CC" | sed -e 's/^\([^ ]*\)/\1_r/'`
 			;;
 		esac
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Using $CC for compiling with threads" >&5
-$as_echo "Using $CC for compiling with threads" >&6; }
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Using $CC for compiling with threads" >&5
+printf "%s\n" "Using $CC for compiling with threads" >&6; }
 
 fi
 	    LIBS="$LIBS -lc"
 	    SHLIB_CFLAGS=""
 	    SHLIB_SUFFIX=".so"
@@ -4383,18 +4554,20 @@
 	    # ldAix No longer needed with use of -bexpall/-brtl
 	    # but some extensions may still reference it
 	    LDAIX_SRC='$(UNIX_DIR)/ldAix'
 
 	    # Check to enable 64-bit flags for compiler/linker
-	    if test "$do64bit" = yes; then :
-
-		if test "$GCC" = yes; then :
-
-		    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5
-$as_echo "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;}
-
-else
+	    if test "$do64bit" = yes
+then :
+
+		if test "$GCC" = yes
+then :
+
+		    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5
+printf "%s\n" "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;}
+
+else $as_nop
 
 		    do64bit_ok=yes
 		    CFLAGS="$CFLAGS -q64"
 		    LDFLAGS_ARCH="-q64"
 		    RANLIB="${RANLIB} -X64"
@@ -4403,34 +4576,37 @@
 
 fi
 
 fi
 
-	    if test "`uname -m`" = ia64; then :
+	    if test "`uname -m`" = ia64
+then :
 
 		# AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC
 		SHLIB_LD="/usr/ccs/bin/ld -G -z text"
 		# AIX-5 has dl* in libc.so
 		DL_LIBS=""
-		if test "$GCC" = yes; then :
+		if test "$GCC" = yes
+then :
 
 		    CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
 
-else
+else $as_nop
 
 		    CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}'
 
 fi
 		LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
 
-else
+else $as_nop
 
-		if test "$GCC" = yes; then :
+		if test "$GCC" = yes
+then :
 
 		    SHLIB_LD='${CC} -shared -Wl,-bexpall'
 
-else
+else $as_nop
 
 		    SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bexpall -H512 -T512 -bnoentry"
 		    LDFLAGS="$LDFLAGS -brtl"
 
 fi
@@ -4451,47 +4627,47 @@
 	    #-----------------------------------------------------------
 	    # Check for inet_ntoa in -lbind, for BeOS (which also needs
 	    # -lsocket, even if the network functions are in -lnet which
 	    # is always linked to, for compatibility.
 	    #-----------------------------------------------------------
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ntoa in -lbind" >&5
-$as_echo_n "checking for inet_ntoa in -lbind... " >&6; }
-if ${ac_cv_lib_bind_inet_ntoa+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inet_ntoa in -lbind" >&5
+printf %s "checking for inet_ntoa in -lbind... " >&6; }
+if test ${ac_cv_lib_bind_inet_ntoa+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lbind  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
 char inet_ntoa ();
 int
-main ()
+main (void)
 {
 return inet_ntoa ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_bind_inet_ntoa=yes
-else
+else $as_nop
   ac_cv_lib_bind_inet_ntoa=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bind_inet_ntoa" >&5
-$as_echo "$ac_cv_lib_bind_inet_ntoa" >&6; }
-if test "x$ac_cv_lib_bind_inet_ntoa" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bind_inet_ntoa" >&5
+printf "%s\n" "$ac_cv_lib_bind_inet_ntoa" >&6; }
+if test "x$ac_cv_lib_bind_inet_ntoa" = xyes
+then :
   LIBS="$LIBS -lbind -lsocket"
 fi
 
 	    ;;
 	BSD/OS-2.1*|BSD/OS-3*)
@@ -4511,11 +4687,11 @@
 	    DL_LIBS="-ldl"
 	    LDFLAGS="$LDFLAGS -export-dynamic"
 	    CC_SEARCH_FLAGS=""
 	    LD_SEARCH_FLAGS=""
 	    ;;
-	CYGWIN_*)
+	CYGWIN_*|MINGW32_*|MSYS_*)
 	    SHLIB_CFLAGS="-fno-common"
 	    SHLIB_LD='${CC} -shared'
 	    SHLIB_SUFFIX=".dll"
 	    DL_OBJS="tclLoadDl.o"
 	    PLAT_OBJS='${CYGWIN_OBJS}'
@@ -4524,48 +4700,50 @@
 	    CC_SEARCH_FLAGS=""
 	    LD_SEARCH_FLAGS=""
 	    TCL_NEEDS_EXP_FILE=1
 	    TCL_EXPORT_FILE_SUFFIX='${VERSION}.dll.a'
 	    SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$@.a"
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Cygwin version of gcc" >&5
-$as_echo_n "checking for Cygwin version of gcc... " >&6; }
-if ${ac_cv_cygwin+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Cygwin version of gcc" >&5
+printf %s "checking for Cygwin version of gcc... " >&6; }
+if test ${ac_cv_cygwin+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 		#ifdef __CYGWIN__
 		    #error cygwin
 		#endif
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_cygwin=no
-else
+else $as_nop
   ac_cv_cygwin=yes
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cygwin" >&5
-$as_echo "$ac_cv_cygwin" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cygwin" >&5
+printf "%s\n" "$ac_cv_cygwin" >&6; }
 	    if test "$ac_cv_cygwin" = "no"; then
 		as_fn_error $? "${CC} is not a cygwin compiler." "$LINENO" 5
 	    fi
 	    do64bit_ok=yes
 	    if test "x${SHARED_BUILD}" = "x1"; then
-		echo "running cd ../win; ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args"
+		echo "running cd ../win; ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args --enable-64bit --host=x86_64-w64-mingw32"
 		# The eval makes quoting arguments work.
-		if cd ../win; eval ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args; cd ../unix
+		if cd ../win; eval ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args --enable-64bit --host=x86_64-w64-mingw32; cd ../unix
 		then :
 		else
 		    { echo "configure: error: configure failed for ../win" 1>&2; exit 1; }
 		fi
 	    fi
@@ -4585,113 +4763,115 @@
 	    SHLIB_CFLAGS="-fPIC"
 	    SHLIB_SUFFIX=".so"
 	    SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS} -shared'
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS="-lroot"
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ntoa in -lnetwork" >&5
-$as_echo_n "checking for inet_ntoa in -lnetwork... " >&6; }
-if ${ac_cv_lib_network_inet_ntoa+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inet_ntoa in -lnetwork" >&5
+printf %s "checking for inet_ntoa in -lnetwork... " >&6; }
+if test ${ac_cv_lib_network_inet_ntoa+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lnetwork  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
 char inet_ntoa ();
 int
-main ()
+main (void)
 {
 return inet_ntoa ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_network_inet_ntoa=yes
-else
+else $as_nop
   ac_cv_lib_network_inet_ntoa=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_network_inet_ntoa" >&5
-$as_echo "$ac_cv_lib_network_inet_ntoa" >&6; }
-if test "x$ac_cv_lib_network_inet_ntoa" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_network_inet_ntoa" >&5
+printf "%s\n" "$ac_cv_lib_network_inet_ntoa" >&6; }
+if test "x$ac_cv_lib_network_inet_ntoa" = xyes
+then :
   LIBS="$LIBS -lnetwork"
 fi
 
 	    ;;
 	HP-UX-*.11.*)
 	    # Use updated header definitions where possible
 
-$as_echo "#define _XOPEN_SOURCE_EXTENDED 1" >>confdefs.h
+printf "%s\n" "#define _XOPEN_SOURCE_EXTENDED 1" >>confdefs.h
 
 
-$as_echo "#define _XOPEN_SOURCE 1" >>confdefs.h
+printf "%s\n" "#define _XOPEN_SOURCE 1" >>confdefs.h
 
 	    LIBS="$LIBS -lxnet"               # Use the XOPEN network library
 
-	    if test "`uname -m`" = ia64; then :
+	    if test "`uname -m`" = ia64
+then :
 
 		SHLIB_SUFFIX=".so"
 
-else
+else $as_nop
 
 		SHLIB_SUFFIX=".sl"
 
 fi
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
-$as_echo_n "checking for shl_load in -ldld... " >&6; }
-if ${ac_cv_lib_dld_shl_load+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+printf %s "checking for shl_load in -ldld... " >&6; }
+if test ${ac_cv_lib_dld_shl_load+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldld  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
 char shl_load ();
 int
-main ()
+main (void)
 {
 return shl_load ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_dld_shl_load=yes
-else
+else $as_nop
   ac_cv_lib_dld_shl_load=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
-$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
-if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+printf "%s\n" "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = xyes
+then :
   tcl_ok=yes
-else
+else $as_nop
   tcl_ok=no
 fi
 
-	    if test "$tcl_ok" = yes; then :
+	    if test "$tcl_ok" = yes
+then :
 
 		SHLIB_CFLAGS="+z"
 		SHLIB_LD="ld -b"
 		DL_OBJS="tclLoadShl.o"
 		DL_LIBS="-ldld"
@@ -4699,47 +4879,51 @@
 		CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
 		LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
 		LD_LIBRARY_PATH_VAR="SHLIB_PATH"
 
 fi
-	    if test "$GCC" = yes; then :
+	    if test "$GCC" = yes
+then :
 
 		SHLIB_LD='${CC} -shared'
 		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
 
-else
+else $as_nop
 
 		CFLAGS="$CFLAGS -z"
 
 fi
 
 	    # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
 	    #CFLAGS="$CFLAGS +DAportable"
 
 	    # Check to enable 64-bit flags for compiler/linker
-	    if test "$do64bit" = "yes"; then :
+	    if test "$do64bit" = "yes"
+then :
 
-		if test "$GCC" = yes; then :
+		if test "$GCC" = yes
+then :
 
 		    case `${CC} -dumpmachine` in
 			hppa64*)
 			    # 64-bit gcc in use.  Fix flags for GNU ld.
 			    do64bit_ok=yes
 			    SHLIB_LD='${CC} -shared'
-			    if test $doRpath = yes; then :
+			    if test $doRpath = yes
+then :
 
 				CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
 fi
 			    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
 			    ;;
 			*)
-			    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5
-$as_echo "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;}
+			    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5
+printf "%s\n" "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;}
 			    ;;
 		    esac
 
-else
+else $as_nop
 
 		    do64bit_ok=yes
 		    CFLAGS="$CFLAGS +DD64"
 		    LDFLAGS_ARCH="+DD64"
 
@@ -4746,53 +4930,54 @@
 fi
 
 fi ;;
 	HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
 	    SHLIB_SUFFIX=".sl"
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
-$as_echo_n "checking for shl_load in -ldld... " >&6; }
-if ${ac_cv_lib_dld_shl_load+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+printf %s "checking for shl_load in -ldld... " >&6; }
+if test ${ac_cv_lib_dld_shl_load+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldld  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
 char shl_load ();
 int
-main ()
+main (void)
 {
 return shl_load ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_dld_shl_load=yes
-else
+else $as_nop
   ac_cv_lib_dld_shl_load=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
-$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
-if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+printf "%s\n" "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = xyes
+then :
   tcl_ok=yes
-else
+else $as_nop
   tcl_ok=no
 fi
 
-	    if test "$tcl_ok" = yes; then :
+	    if test "$tcl_ok" = yes
+then :
 
 		SHLIB_CFLAGS="+z"
 		SHLIB_LD="ld -b"
 		SHLIB_LD_LIBS=""
 		DL_OBJS="tclLoadShl.o"
@@ -4813,11 +4998,12 @@
   *" mkstemp.$ac_objext "* ) ;;
   *) LIBOBJS="$LIBOBJS mkstemp.$ac_objext"
  ;;
 esac
 
-	    if test $doRpath = yes; then :
+	    if test $doRpath = yes
+then :
 
 		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
 		LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
 fi
 	    ;;
@@ -4831,21 +5017,23 @@
   *" mkstemp.$ac_objext "* ) ;;
   *) LIBOBJS="$LIBOBJS mkstemp.$ac_objext"
  ;;
 esac
 
-	    if test $doRpath = yes; then :
+	    if test $doRpath = yes
+then :
 
 		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
 		LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
 fi
-	    if test "$GCC" = yes; then :
+	    if test "$GCC" = yes
+then :
 
 		CFLAGS="$CFLAGS -mabi=n32"
 		LDFLAGS="$LDFLAGS -mabi=n32"
 
-else
+else $as_nop
 
 		case $system in
 		    IRIX-6.3)
 			# Use to build 6.2 compatible binaries on 6.3.
 			CFLAGS="$CFLAGS -n32 -D_OLD_TERMIOS"
@@ -4868,26 +5056,29 @@
   *" mkstemp.$ac_objext "* ) ;;
   *) LIBOBJS="$LIBOBJS mkstemp.$ac_objext"
  ;;
 esac
 
-	    if test $doRpath = yes; then :
+	    if test $doRpath = yes
+then :
 
 		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
 		LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
 fi
 
 	    # Check to enable 64-bit flags for compiler/linker
 
-	    if test "$do64bit" = yes; then :
-
-	        if test "$GCC" = yes; then :
-
-	            { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported by gcc" >&5
-$as_echo "$as_me: WARNING: 64bit mode not supported by gcc" >&2;}
-
-else
+	    if test "$do64bit" = yes
+then :
+
+	        if test "$GCC" = yes
+then :
+
+	            { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported by gcc" >&5
+printf "%s\n" "$as_me: WARNING: 64bit mode not supported by gcc" >&2;}
+
+else $as_nop
 
 	            do64bit_ok=yes
 	            SHLIB_LD="ld -64 -shared -rdata_shared"
 	            CFLAGS="$CFLAGS -64"
 	            LDFLAGS_ARCH="-64"
@@ -4894,11 +5085,11 @@
 
 fi
 
 fi
 	    ;;
-	Linux*|GNU*|NetBSD-Debian)
+	Linux*|GNU*|NetBSD-Debian|DragonFly-*|FreeBSD-*)
 	    SHLIB_CFLAGS="-fPIC -fno-common"
 	    SHLIB_SUFFIX=".so"
 
 	    CFLAGS_OPTIMIZE="-O2"
 	    # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings
@@ -4908,51 +5099,71 @@
 
 	    SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS} -shared'
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS="-ldl"
 	    LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
-	    if test $doRpath = yes; then :
+
+	    case $system in
+	    DragonFly-*|FreeBSD-*)
+		if test "${TCL_THREADS}" = "1"
+then :
+
+		    # The -pthread needs to go in the LDFLAGS, not LIBS
+		    LIBS=`echo $LIBS | sed s/-pthread//`
+		    CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+		    LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
+fi
+	    ;;
+            esac
+
+	    if test $doRpath = yes
+then :
 
 		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
 fi
 	    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
-	    if test "`uname -m`" = "alpha"; then :
+	    if test "`uname -m`" = "alpha"
+then :
   CFLAGS="$CFLAGS -mieee"
 fi
-	    if test $do64bit = yes; then :
+	    if test $do64bit = yes
+then :
 
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts -m64 flag" >&5
-$as_echo_n "checking if compiler accepts -m64 flag... " >&6; }
-if ${tcl_cv_cc_m64+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if compiler accepts -m64 flag" >&5
+printf %s "checking if compiler accepts -m64 flag... " >&6; }
+if test ${tcl_cv_cc_m64+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 		    hold_cflags=$CFLAGS
 		    CFLAGS="$CFLAGS -m64"
 		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   tcl_cv_cc_m64=yes
-else
+else $as_nop
   tcl_cv_cc_m64=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 		    CFLAGS=$hold_cflags
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_m64" >&5
-$as_echo "$tcl_cv_cc_m64" >&6; }
-		if test $tcl_cv_cc_m64 = yes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_m64" >&5
+printf "%s\n" "$tcl_cv_cc_m64" >&6; }
+		if test $tcl_cv_cc_m64 = yes
+then :
 
 		    CFLAGS="$CFLAGS -m64"
 		    do64bit_ok=yes
 
 fi
@@ -4963,11 +5174,12 @@
 	    # functions like strtol()/strtoul(). The -fno-builtin flag should address
 	    # this problem but it does not work. The -fno-inline flag is kind
 	    # of overkill but it works. Disable inlining only when one of the
 	    # files in compat/*.c is being linked in.
 
-	    if test x"${USE_COMPAT}" != x; then :
+	    if test x"${USE_COMPAT}" != x
+then :
   CFLAGS="$CFLAGS -fno-inline"
 fi
 	    ;;
 	Lynx*)
 	    SHLIB_CFLAGS="-fPIC"
@@ -4975,11 +5187,12 @@
 	    CFLAGS_OPTIMIZE=-02
 	    SHLIB_LD='${CC} -shared'
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS="-mshared -ldl"
 	    LD_FLAGS="-Wl,--export-dynamic"
-	    if test $doRpath = yes; then :
+	    if test $doRpath = yes
+then :
 
 		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
 		LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
 fi
 	    ;;
@@ -4995,11 +5208,12 @@
 	    esac
 	    SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared'
 	    SHLIB_SUFFIX=".so"
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS=""
-	    if test $doRpath = yes; then :
+	    if test $doRpath = yes
+then :
 
 		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
 fi
 	    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
 	    SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
@@ -5019,48 +5233,23 @@
 	    SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared'
 	    SHLIB_SUFFIX=".so"
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS=""
 	    LDFLAGS="$LDFLAGS -export-dynamic"
-	    if test $doRpath = yes; then :
+	    if test $doRpath = yes
+then :
 
 		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
 fi
 	    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
 	    # The -pthread needs to go in the CFLAGS, not LIBS
 	    LIBS=`echo $LIBS | sed s/-pthread//`
 	    CFLAGS="$CFLAGS -pthread"
 	    LDFLAGS="$LDFLAGS -pthread"
 	    ;;
-	DragonFly-*|FreeBSD-*)
-	    # This configuration from FreeBSD Ports.
-	    SHLIB_LD="${CC} -shared"
-	    SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,-soname,\$@"
-	    SHLIB_SUFFIX=".so"
-	    DL_OBJS="tclLoadDl.o"
-	    DL_LIBS=""
-	    if test $doRpath = yes; then :
-
-		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
-		LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
-fi
-	    # The -pthread needs to go in the LDFLAGS, not LIBS
-	    LIBS=`echo $LIBS | sed s/-pthread//`
-	    CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-	    LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
-	    case $system in
-	    FreeBSD-3.*)
-		# Version numbers are dot-stripped by system policy.
-		TCL_TRIM_DOTS=`echo ${VERSION} | tr -d .`
-		UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
-		SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so'
-		TCL_LIB_VERSIONS_OK=nodots
-		;;
-	    esac
-	    ;;
 	Darwin-*)
-	    CFLAGS_OPTIMIZE="-Os"
+	    CFLAGS_OPTIMIZE="-O2"
 	    SHLIB_CFLAGS="-fno-common"
 	    # To avoid discrepancies between what headers configure sees during
 	    # preprocessing tests and compiling tests, move any -isysroot and
 	    # -mmacosx-version-min flags from CFLAGS to CPPFLAGS:
 	    CPPFLAGS="${CPPFLAGS} `echo " ${CFLAGS}" | \
@@ -5067,214 +5256,273 @@
 		awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
 		if ($i~/^(isysroot|mmacosx-version-min)/) print "-"$i}'`"
 	    CFLAGS="`echo " ${CFLAGS}" | \
 		awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \
 		if (!($i~/^(isysroot|mmacosx-version-min)/)) print "-"$i}'`"
-	    if test $do64bit = yes; then :
-
-		case `arch` in
-		    ppc)
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts -arch ppc64 flag" >&5
-$as_echo_n "checking if compiler accepts -arch ppc64 flag... " >&6; }
-if ${tcl_cv_cc_arch_ppc64+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-
-			    hold_cflags=$CFLAGS
-			    CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
-			    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  tcl_cv_cc_arch_ppc64=yes
-else
-  tcl_cv_cc_arch_ppc64=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-			    CFLAGS=$hold_cflags
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_arch_ppc64" >&5
-$as_echo "$tcl_cv_cc_arch_ppc64" >&6; }
-			if test $tcl_cv_cc_arch_ppc64 = yes; then :
-
-			    CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
-			    do64bit_ok=yes
-
-fi;;
-		    i386)
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts -arch x86_64 flag" >&5
-$as_echo_n "checking if compiler accepts -arch x86_64 flag... " >&6; }
-if ${tcl_cv_cc_arch_x86_64+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-
-			    hold_cflags=$CFLAGS
-			    CFLAGS="$CFLAGS -arch x86_64"
-			    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  tcl_cv_cc_arch_x86_64=yes
-else
-  tcl_cv_cc_arch_x86_64=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-			    CFLAGS=$hold_cflags
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_arch_x86_64" >&5
-$as_echo "$tcl_cv_cc_arch_x86_64" >&6; }
-			if test $tcl_cv_cc_arch_x86_64 = yes; then :
-
-			    CFLAGS="$CFLAGS -arch x86_64"
-			    do64bit_ok=yes
-
-fi;;
-		    *)
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Don't know how enable 64-bit on architecture \`arch\`" >&5
-$as_echo "$as_me: WARNING: Don't know how enable 64-bit on architecture \`arch\`" >&2;};;
-		esac
-
-else
-
-		# Check for combined 32-bit and 64-bit fat build
-		if echo "$CFLAGS " |grep -E -q -- '-arch (ppc64|x86_64) ' \
-		    && echo "$CFLAGS " |grep -E -q -- '-arch (ppc|i386) '; then :
+	    if test $do64bit = yes
+then :
+
+		case `arch` in
+		    ppc)
+			{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if compiler accepts -arch ppc64 flag" >&5
+printf %s "checking if compiler accepts -arch ppc64 flag... " >&6; }
+if test ${tcl_cv_cc_arch_ppc64+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+			    hold_cflags=$CFLAGS
+			    CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
+			    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  tcl_cv_cc_arch_ppc64=yes
+else $as_nop
+  tcl_cv_cc_arch_ppc64=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+			    CFLAGS=$hold_cflags
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_arch_ppc64" >&5
+printf "%s\n" "$tcl_cv_cc_arch_ppc64" >&6; }
+			if test $tcl_cv_cc_arch_ppc64 = yes
+then :
+
+			    CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
+			    do64bit_ok=yes
+
+fi;;
+		    i386|x86_64)
+			{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if compiler accepts -arch x86_64 flag" >&5
+printf %s "checking if compiler accepts -arch x86_64 flag... " >&6; }
+if test ${tcl_cv_cc_arch_x86_64+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+			    hold_cflags=$CFLAGS
+			    CFLAGS="$CFLAGS -arch x86_64"
+			    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  tcl_cv_cc_arch_x86_64=yes
+else $as_nop
+  tcl_cv_cc_arch_x86_64=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+			    CFLAGS=$hold_cflags
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_arch_x86_64" >&5
+printf "%s\n" "$tcl_cv_cc_arch_x86_64" >&6; }
+			if test $tcl_cv_cc_arch_x86_64 = yes
+then :
+
+			    CFLAGS="$CFLAGS -arch x86_64"
+			    do64bit_ok=yes
+
+fi;;
+		    arm64|arm64e)
+			{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if compiler accepts -arch arm64e flag" >&5
+printf %s "checking if compiler accepts -arch arm64e flag... " >&6; }
+if test ${tcl_cv_cc_arch_arm64e+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+			    hold_cflags=$CFLAGS
+			    CFLAGS="$CFLAGS -arch arm64e"
+			    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  tcl_cv_cc_arch_arm64e=yes
+else $as_nop
+  tcl_cv_cc_arch_arm64e=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+			    CFLAGS=$hold_cflags
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_arch_arm64e" >&5
+printf "%s\n" "$tcl_cv_cc_arch_arm64e" >&6; }
+			if test $tcl_cv_cc_arch_arm64e = yes
+then :
+
+			    CFLAGS="$CFLAGS -arch arm64e"
+			    do64bit_ok=yes
+
+fi;;
+		    *)
+			{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Don't know how enable 64-bit on architecture \`arch\`" >&5
+printf "%s\n" "$as_me: WARNING: Don't know how enable 64-bit on architecture \`arch\`" >&2;};;
+		esac
+
+else $as_nop
+
+		# Check for combined 32-bit and 64-bit fat build
+		if echo "$CFLAGS " |grep -E -q -- '-arch (ppc64|x86_64|arm64e) ' \
+		    && echo "$CFLAGS " |grep -E -q -- '-arch (ppc|i386) '
+then :
 
 		    fat_32_64=yes
 fi
 
 fi
 	    SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS}'
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ld accepts -single_module flag" >&5
-$as_echo_n "checking if ld accepts -single_module flag... " >&6; }
-if ${tcl_cv_ld_single_module+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if ld accepts -single_module flag" >&5
+printf %s "checking if ld accepts -single_module flag... " >&6; }
+if test ${tcl_cv_ld_single_module+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 		hold_ldflags=$LDFLAGS
 		LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module"
 		cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 int i;
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   tcl_cv_ld_single_module=yes
-else
+else $as_nop
   tcl_cv_ld_single_module=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 		LDFLAGS=$hold_ldflags
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_single_module" >&5
-$as_echo "$tcl_cv_ld_single_module" >&6; }
-	    if test $tcl_cv_ld_single_module = yes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_single_module" >&5
+printf "%s\n" "$tcl_cv_ld_single_module" >&6; }
+	    if test $tcl_cv_ld_single_module = yes
+then :
 
 		SHLIB_LD="${SHLIB_LD} -Wl,-single_module"
 
 fi
 	    SHLIB_SUFFIX=".dylib"
 	    DL_OBJS="tclLoadDyld.o"
 	    DL_LIBS=""
 	    LDFLAGS="$LDFLAGS -headerpad_max_install_names"
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ld accepts -search_paths_first flag" >&5
-$as_echo_n "checking if ld accepts -search_paths_first flag... " >&6; }
-if ${tcl_cv_ld_search_paths_first+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if ld accepts -search_paths_first flag" >&5
+printf %s "checking if ld accepts -search_paths_first flag... " >&6; }
+if test ${tcl_cv_ld_search_paths_first+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 		hold_ldflags=$LDFLAGS
 		LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
 		cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 int i;
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   tcl_cv_ld_search_paths_first=yes
-else
+else $as_nop
   tcl_cv_ld_search_paths_first=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 		LDFLAGS=$hold_ldflags
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_search_paths_first" >&5
-$as_echo "$tcl_cv_ld_search_paths_first" >&6; }
-	    if test $tcl_cv_ld_search_paths_first = yes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_search_paths_first" >&5
+printf "%s\n" "$tcl_cv_ld_search_paths_first" >&6; }
+	    if test $tcl_cv_ld_search_paths_first = yes
+then :
 
 		LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
 
 fi
-	    if test "$tcl_cv_cc_visibility_hidden" != yes; then :
+	    if test "$tcl_cv_cc_visibility_hidden" != yes
+then :
 
 
-$as_echo "#define MODULE_SCOPE __private_extern__" >>confdefs.h
+printf "%s\n" "#define MODULE_SCOPE __private_extern__" >>confdefs.h
 
 		tcl_cv_cc_visibility_hidden=yes
 
 fi
 	    CC_SEARCH_FLAGS=""
 	    LD_SEARCH_FLAGS=""
 	    LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
 
-$as_echo "#define MAC_OSX_TCL 1" >>confdefs.h
+printf "%s\n" "#define MAC_OSX_TCL 1" >>confdefs.h
 
 	    PLAT_OBJS='${MAC_OSX_OBJS}'
 	    PLAT_SRCS='${MAC_OSX_SRCS}'
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use CoreFoundation" >&5
-$as_echo_n "checking whether to use CoreFoundation... " >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use CoreFoundation" >&5
+printf %s "checking whether to use CoreFoundation... " >&6; }
 	    # Check whether --enable-corefoundation was given.
-if test "${enable_corefoundation+set}" = set; then :
+if test ${enable_corefoundation+y}
+then :
   enableval=$enable_corefoundation; tcl_corefoundation=$enableval
-else
+else $as_nop
   tcl_corefoundation=yes
 fi
 
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_corefoundation" >&5
-$as_echo "$tcl_corefoundation" >&6; }
-	    if test $tcl_corefoundation = yes; then :
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CoreFoundation.framework" >&5
-$as_echo_n "checking for CoreFoundation.framework... " >&6; }
-if ${tcl_cv_lib_corefoundation+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_corefoundation" >&5
+printf "%s\n" "$tcl_corefoundation" >&6; }
+	    if test $tcl_corefoundation = yes
+then :
+
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CoreFoundation.framework" >&5
+printf %s "checking for CoreFoundation.framework... " >&6; }
+if test ${tcl_cv_lib_corefoundation+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 		    hold_libs=$LIBS
-		    if test "$fat_32_64" = yes; then :
+		    if test "$fat_32_64" = yes
+then :
 
 			for v in CFLAGS CPPFLAGS LDFLAGS; do
 			    # On Tiger there is no 64-bit CF, so remove 64-bit
 			    # archs from CFLAGS et al. while testing for
 			    # presence of CF. 64-bit CF is disabled in
@@ -5285,83 +5533,90 @@
 		    LIBS="$LIBS -framework CoreFoundation"
 		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <CoreFoundation/CoreFoundation.h>
 int
-main ()
+main (void)
 {
 CFBundleRef b = CFBundleGetMainBundle();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   tcl_cv_lib_corefoundation=yes
-else
+else $as_nop
   tcl_cv_lib_corefoundation=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
-		    if test "$fat_32_64" = yes; then :
+		    if test "$fat_32_64" = yes
+then :
 
 			for v in CFLAGS CPPFLAGS LDFLAGS; do
 			    eval $v'="$hold_'$v'"'
 		        done
 fi
 		    LIBS=$hold_libs
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_lib_corefoundation" >&5
-$as_echo "$tcl_cv_lib_corefoundation" >&6; }
-		if test $tcl_cv_lib_corefoundation = yes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_lib_corefoundation" >&5
+printf "%s\n" "$tcl_cv_lib_corefoundation" >&6; }
+		if test $tcl_cv_lib_corefoundation = yes
+then :
 
 		    LIBS="$LIBS -framework CoreFoundation"
 
-$as_echo "#define HAVE_COREFOUNDATION 1" >>confdefs.h
+printf "%s\n" "#define HAVE_COREFOUNDATION 1" >>confdefs.h
 
 
-else
+else $as_nop
   tcl_corefoundation=no
 fi
-		if test "$fat_32_64" = yes -a $tcl_corefoundation = yes; then :
+		if test "$fat_32_64" = yes -a $tcl_corefoundation = yes
+then :
 
-		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit CoreFoundation" >&5
-$as_echo_n "checking for 64-bit CoreFoundation... " >&6; }
-if ${tcl_cv_lib_corefoundation_64+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+		    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for 64-bit CoreFoundation" >&5
+printf %s "checking for 64-bit CoreFoundation... " >&6; }
+if test ${tcl_cv_lib_corefoundation_64+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 			for v in CFLAGS CPPFLAGS LDFLAGS; do
 			    eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"'
 			done
 			cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <CoreFoundation/CoreFoundation.h>
 int
-main ()
+main (void)
 {
 CFBundleRef b = CFBundleGetMainBundle();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   tcl_cv_lib_corefoundation_64=yes
-else
+else $as_nop
   tcl_cv_lib_corefoundation_64=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 			for v in CFLAGS CPPFLAGS LDFLAGS; do
 			    eval $v'="$hold_'$v'"'
 			done
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_lib_corefoundation_64" >&5
-$as_echo "$tcl_cv_lib_corefoundation_64" >&6; }
-		    if test $tcl_cv_lib_corefoundation_64 = no; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_lib_corefoundation_64" >&5
+printf "%s\n" "$tcl_cv_lib_corefoundation_64" >&6; }
+		    if test $tcl_cv_lib_corefoundation_64 = no
+then :
 
 
-$as_echo "#define NO_COREFOUNDATION_64 1" >>confdefs.h
+printf "%s\n" "#define NO_COREFOUNDATION_64 1" >>confdefs.h
 
                         LDFLAGS="$LDFLAGS -Wl,-no_arch_warnings"
 
 fi
 
@@ -5371,48 +5626,52 @@
 	    ;;
 	OS/390-*)
 	    SHLIB_LD_LIBS=""
 	    CFLAGS_OPTIMIZE=""		# Optimizer is buggy
 
-$as_echo "#define _OE_SOCKETS 1" >>confdefs.h
+printf "%s\n" "#define _OE_SOCKETS 1" >>confdefs.h
 
 	    ;;
 	OSF1-V*)
 	    # Digital OSF/1
 	    SHLIB_CFLAGS=""
-	    if test "$SHARED_BUILD" = 1; then :
+	    if test "$SHARED_BUILD" = 1
+then :
 
-	        SHLIB_LD='ld -shared -expect_unresolved "*"'
+	        SHLIB_LD='${CC} -shared'
 
-else
+else $as_nop
 
-	        SHLIB_LD='ld -non_shared -expect_unresolved "*"'
+	        SHLIB_LD='${CC} -non_shared'
 
 fi
 	    SHLIB_SUFFIX=".so"
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS=""
-	    if test $doRpath = yes; then :
+	    if test $doRpath = yes
+then :
 
 		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
 		LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
 fi
-	    if test "$GCC" = yes; then :
+	    if test "$GCC" = yes
+then :
   CFLAGS="$CFLAGS -mieee"
-else
+else $as_nop
 
 		CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee"
 fi
 	    # see pthread_intro(3) for pthread support on osf1, k.furukawa
 	    CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE"
 	    CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64"
 	    LIBS=`echo $LIBS | sed s/-lpthreads//`
-	    if test "$GCC" = yes; then :
+	    if test "$GCC" = yes
+then :
 
 		LIBS="$LIBS -lpthread -lmach -lexc"
 
-else
+else $as_nop
 
 		CFLAGS="$CFLAGS -pthread"
 		LDFLAGS="$LDFLAGS -pthread"
 
 fi
@@ -5431,16 +5690,17 @@
 	    ;;
 	SCO_SV-3.2*)
 	    # Note, dlopen is available only on SCO 3.2.5 and greater. However,
 	    # this test works, since "uname -s" was non-standard in 3.2.4 and
 	    # below.
-	    if test "$GCC" = yes; then :
+	    if test "$GCC" = yes
+then :
 
 		SHLIB_CFLAGS="-fPIC -melf"
 		LDFLAGS="$LDFLAGS -melf -Wl,-Bexport"
 
-else
+else $as_nop
 
 		SHLIB_CFLAGS="-Kpic -belf"
 		LDFLAGS="$LDFLAGS -belf -Wl,-Bexport"
 
 fi
@@ -5457,27 +5717,28 @@
 
 	    # Note: If _REENTRANT isn't defined, then Solaris
 	    # won't define thread-safe library routines.
 
 
-$as_echo "#define _REENTRANT 1" >>confdefs.h
+printf "%s\n" "#define _REENTRANT 1" >>confdefs.h
 
 
-$as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h
+printf "%s\n" "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h
 
 
 	    SHLIB_CFLAGS="-KPIC"
 	    SHLIB_SUFFIX=".so"
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS="-ldl"
-	    if test "$GCC" = yes; then :
+	    if test "$GCC" = yes
+then :
 
 		SHLIB_LD='${CC} -shared'
 		CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
 		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
 
-else
+else $as_nop
 
 		SHLIB_LD="/usr/ccs/bin/ld -G -z text"
 		CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
 		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
 
@@ -5486,49 +5747,54 @@
 	SunOS-5*)
 	    # Note: If _REENTRANT isn't defined, then Solaris
 	    # won't define thread-safe library routines.
 
 
-$as_echo "#define _REENTRANT 1" >>confdefs.h
+printf "%s\n" "#define _REENTRANT 1" >>confdefs.h
 
 
-$as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h
+printf "%s\n" "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h
 
 
 	    SHLIB_CFLAGS="-KPIC"
 
 	    # Check to enable 64-bit flags for compiler/linker
-	    if test "$do64bit" = yes; then :
+	    if test "$do64bit" = yes
+then :
 
 		arch=`isainfo`
-		if test "$arch" = "sparcv9 sparc"; then :
-
-		    if test "$GCC" = yes; then :
-
-			if test "`${CC} -dumpversion | awk -F. '{print $1}'`" -lt 3; then :
-
-			    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC < 3.2 on $system" >&5
-$as_echo "$as_me: WARNING: 64bit mode not supported with GCC < 3.2 on $system" >&2;}
-
-else
+		if test "$arch" = "sparcv9 sparc"
+then :
+
+		    if test "$GCC" = yes
+then :
+
+			if test "`${CC} -dumpversion | awk -F. '{print $1}'`" -lt 3
+then :
+
+			    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC < 3.2 on $system" >&5
+printf "%s\n" "$as_me: WARNING: 64bit mode not supported with GCC < 3.2 on $system" >&2;}
+
+else $as_nop
 
 			    do64bit_ok=yes
 			    CFLAGS="$CFLAGS -m64 -mcpu=v9"
 			    LDFLAGS="$LDFLAGS -m64 -mcpu=v9"
 			    SHLIB_CFLAGS="-fPIC"
 
 fi
 
-else
+else $as_nop
 
 			do64bit_ok=yes
-			if test "$do64bitVIS" = yes; then :
+			if test "$do64bitVIS" = yes
+then :
 
 			    CFLAGS="$CFLAGS -xarch=v9a"
 			    LDFLAGS_ARCH="-xarch=v9a"
 
-else
+else $as_nop
 
 			    CFLAGS="$CFLAGS -xarch=v9"
 			    LDFLAGS_ARCH="-xarch=v9"
 
 fi
@@ -5535,26 +5801,28 @@
 			# Solaris 64 uses this as well
 			#LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH_64"
 
 fi
 
-else
-  if test "$arch" = "amd64 i386"; then :
+else $as_nop
+  if test "$arch" = "amd64 i386"
+then :
 
-		    if test "$GCC" = yes; then :
+		    if test "$GCC" = yes
+then :
 
 			case $system in
 			    SunOS-5.1[1-9]*|SunOS-5.[2-9][0-9]*)
 				do64bit_ok=yes
 				CFLAGS="$CFLAGS -m64"
 				LDFLAGS="$LDFLAGS -m64";;
 			    *)
-				{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5
-$as_echo "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;};;
+				{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5
+printf "%s\n" "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;};;
 			esac
 
-else
+else $as_nop
 
 			do64bit_ok=yes
 			case $system in
 			    SunOS-5.1[1-9]*|SunOS-5.[2-9][0-9]*)
 				CFLAGS="$CFLAGS -m64"
@@ -5564,86 +5832,93 @@
 				LDFLAGS="$LDFLAGS -xarch=amd64";;
 			esac
 
 fi
 
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported for $arch" >&5
-$as_echo "$as_me: WARNING: 64bit mode not supported for $arch" >&2;}
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported for $arch" >&5
+printf "%s\n" "$as_me: WARNING: 64bit mode not supported for $arch" >&2;}
 fi
 fi
 
 fi
 
 	    #--------------------------------------------------------------------
 	    # On Solaris 5.x i386 with the sunpro compiler we need to link
 	    # with sunmath to get floating point rounding control
 	    #--------------------------------------------------------------------
-	    if test "$GCC" = yes; then :
+	    if test "$GCC" = yes
+then :
   use_sunmath=no
-else
+else $as_nop
 
 		arch=`isainfo`
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use -lsunmath for fp rounding control" >&5
-$as_echo_n "checking whether to use -lsunmath for fp rounding control... " >&6; }
-		if test "$arch" = "amd64 i386" -o "$arch" = "i386"; then :
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use -lsunmath for fp rounding control" >&5
+printf %s "checking whether to use -lsunmath for fp rounding control... " >&6; }
+		if test "$arch" = "amd64 i386" -o "$arch" = "i386"
+then :
 
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+			{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
 			MATH_LIBS="-lsunmath $MATH_LIBS"
-			ac_fn_c_check_header_mongrel "$LINENO" "sunmath.h" "ac_cv_header_sunmath_h" "$ac_includes_default"
-if test "x$ac_cv_header_sunmath_h" = xyes; then :
+			ac_fn_c_check_header_compile "$LINENO" "sunmath.h" "ac_cv_header_sunmath_h" "$ac_includes_default"
+if test "x$ac_cv_header_sunmath_h" = xyes
+then :
 
 fi
-
 
 			use_sunmath=yes
 
-else
+else $as_nop
 
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+			{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 			use_sunmath=no
 
 fi
 
 fi
 	    SHLIB_SUFFIX=".so"
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS="-ldl"
-	    if test "$GCC" = yes; then :
+	    if test "$GCC" = yes
+then :
 
 		SHLIB_LD='${CC} -shared'
 		CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
 		LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
-		if test "$do64bit_ok" = yes; then :
+		if test "$do64bit_ok" = yes
+then :
 
-		    if test "$arch" = "sparcv9 sparc"; then :
+		    if test "$arch" = "sparcv9 sparc"
+then :
 
 			# We need to specify -static-libgcc or we need to
 			# add the path to the sparv9 libgcc.
 			SHLIB_LD="$SHLIB_LD -m64 -mcpu=v9 -static-libgcc"
 			# for finding sparcv9 libgcc, get the regular libgcc
 			# path, remove so name and append 'sparcv9'
 			#v9gcclibdir="`gcc -print-file-name=libgcc_s.so` | ..."
 			#CC_SEARCH_FLAGS="${CC_SEARCH_FLAGS},-R,$v9gcclibdir"
 
-else
-  if test "$arch" = "amd64 i386"; then :
+else $as_nop
+  if test "$arch" = "amd64 i386"
+then :
 
 			SHLIB_LD="$SHLIB_LD -m64 -static-libgcc"
 
 fi
 fi
 
 fi
 
-else
+else $as_nop
 
-		if test "$use_sunmath" = yes; then :
+		if test "$use_sunmath" = yes
+then :
   textmode=textoff
-else
+else $as_nop
   textmode=text
 fi
 		case $system in
 		    SunOS-5.[1-9][0-9]*|SunOS-5.[7-9])
 			SHLIB_LD="\${CC} -G -z $textmode \${LDFLAGS}";;
@@ -5662,86 +5937,94 @@
 	    SHLIB_SUFFIX=".so"
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS="-ldl"
 	    # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
 	    # that don't grok the -Bexport option.  Test that it does.
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld accepts -Bexport flag" >&5
-$as_echo_n "checking for ld accepts -Bexport flag... " >&6; }
-if ${tcl_cv_ld_Bexport+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld accepts -Bexport flag" >&5
+printf %s "checking for ld accepts -Bexport flag... " >&6; }
+if test ${tcl_cv_ld_Bexport+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 		hold_ldflags=$LDFLAGS
 		LDFLAGS="$LDFLAGS -Wl,-Bexport"
 		cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 int i;
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   tcl_cv_ld_Bexport=yes
-else
+else $as_nop
   tcl_cv_ld_Bexport=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 	        LDFLAGS=$hold_ldflags
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_Bexport" >&5
-$as_echo "$tcl_cv_ld_Bexport" >&6; }
-	    if test $tcl_cv_ld_Bexport = yes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_Bexport" >&5
+printf "%s\n" "$tcl_cv_ld_Bexport" >&6; }
+	    if test $tcl_cv_ld_Bexport = yes
+then :
 
 		LDFLAGS="$LDFLAGS -Wl,-Bexport"
 
 fi
 	    CC_SEARCH_FLAGS=""
 	    LD_SEARCH_FLAGS=""
 	    ;;
     esac
 
-    if test "$do64bit" = yes -a "$do64bit_ok" = no; then :
+    if test "$do64bit" = yes -a "$do64bit_ok" = no
+then :
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit support being disabled -- don't know magic for this platform" >&5
-$as_echo "$as_me: WARNING: 64bit support being disabled -- don't know magic for this platform" >&2;}
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: 64bit support being disabled -- don't know magic for this platform" >&5
+printf "%s\n" "$as_me: WARNING: 64bit support being disabled -- don't know magic for this platform" >&2;}
 
 fi
 
-    if test "$do64bit" = yes -a "$do64bit_ok" = yes; then :
+    if test "$do64bit" = yes -a "$do64bit_ok" = yes
+then :
 
 
-$as_echo "#define TCL_CFG_DO64BIT 1" >>confdefs.h
+printf "%s\n" "#define TCL_CFG_DO64BIT 1" >>confdefs.h
 
 
 fi
 
 
 
     # Step 4: disable dynamic loading if requested via a command-line switch.
 
     # Check whether --enable-load was given.
-if test "${enable_load+set}" = set; then :
+if test ${enable_load+y}
+then :
   enableval=$enable_load; tcl_ok=$enableval
-else
+else $as_nop
   tcl_ok=yes
 fi
 
-    if test "$tcl_ok" = no; then :
+    if test "$tcl_ok" = no
+then :
   DL_OBJS=""
 fi
 
-    if test "x$DL_OBJS" != x; then :
+    if test "x$DL_OBJS" != x
+then :
   BUILD_DLTEST="\$(DLTEST_TARGETS)"
-else
+else $as_nop
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Can't figure out how to do dynamic loading or shared libraries on this system." >&5
-$as_echo "$as_me: WARNING: Can't figure out how to do dynamic loading or shared libraries on this system." >&2;}
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Can't figure out how to do dynamic loading or shared libraries on this system." >&5
+printf "%s\n" "$as_me: WARNING: Can't figure out how to do dynamic loading or shared libraries on this system." >&2;}
 	SHLIB_CFLAGS=""
 	SHLIB_LD=""
 	SHLIB_SUFFIX=""
 	DL_OBJS="tclLoadNone.o"
 	DL_LIBS=""
@@ -5755,144 +6038,223 @@
 
     # If we're running gcc, then change the C flags for compiling shared
     # libraries to the right flags for gcc, instead of those for the
     # standard manufacturer compiler.
 
-    if test "$DL_OBJS" != "tclLoadNone.o" -a "$GCC" = yes; then :
+    if test "$DL_OBJS" != "tclLoadNone.o" -a "$GCC" = yes
+then :
 
 	case $system in
 	    AIX-*) ;;
 	    BSD/OS*) ;;
-	    CYGWIN_*) ;;
-	    HP_UX*) ;;
+	    CYGWIN_*|MINGW32_*|MSYS_*) ;;
+	    HP-UX*) ;;
 	    Darwin-*) ;;
 	    IRIX*) ;;
 	    Linux*|GNU*) ;;
 	    NetBSD-*|OpenBSD-*) ;;
-	    OSF1-V*) ;;
+	    OSF1-*) ;;
 	    SCO_SV-3.2*) ;;
 	    *) SHLIB_CFLAGS="-fPIC" ;;
 	esac
 fi
 
-    if test "$tcl_cv_cc_visibility_hidden" != yes; then :
+    if test "$tcl_cv_cc_visibility_hidden" != yes
+then :
 
 
-$as_echo "#define MODULE_SCOPE extern" >>confdefs.h
+printf "%s\n" "#define MODULE_SCOPE extern" >>confdefs.h
 
 
 fi
 
-    if test "$SHARED_LIB_SUFFIX" = ""; then :
+    if test "$SHARED_LIB_SUFFIX" = ""
+then :
 
 	SHARED_LIB_SUFFIX='${VERSION}${SHLIB_SUFFIX}'
 fi
-    if test "$UNSHARED_LIB_SUFFIX" = ""; then :
+    if test "$UNSHARED_LIB_SUFFIX" = ""
+then :
 
 	UNSHARED_LIB_SUFFIX='${VERSION}.a'
 fi
     DLL_INSTALL_DIR="\$(LIB_INSTALL_DIR)"
 
-    if test "${SHARED_BUILD}" = 1 -a "${SHLIB_SUFFIX}" != ""; then :
+    if test "${SHARED_BUILD}" = 1 -a "${SHLIB_SUFFIX}" != ""
+then :
 
         LIB_SUFFIX=${SHARED_LIB_SUFFIX}
         MAKE_LIB='${SHLIB_LD} -o $@ ${OBJS} ${LDFLAGS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
-        if test "${SHLIB_SUFFIX}" = ".dll"; then :
+        if test "${SHLIB_SUFFIX}" = ".dll"
+then :
 
             INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(BIN_INSTALL_DIR)/$(LIB_FILE)";if test -f $(LIB_FILE).a; then $(INSTALL_DATA) $(LIB_FILE).a "$(LIB_INSTALL_DIR)"; fi;'
             DLL_INSTALL_DIR="\$(BIN_INSTALL_DIR)"
 
-else
+else $as_nop
 
             INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(LIB_INSTALL_DIR)/$(LIB_FILE)"'
 
 fi
 
-else
+else $as_nop
 
         LIB_SUFFIX=${UNSHARED_LIB_SUFFIX}
 
-        if test "$RANLIB" = ""; then :
+        if test "$RANLIB" = ""
+then :
 
             MAKE_LIB='$(STLIB_LD) $@ ${OBJS}'
 
-else
+else $as_nop
 
             MAKE_LIB='${STLIB_LD} $@ ${OBJS} ; ${RANLIB} $@'
 
 fi
         INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(LIB_INSTALL_DIR)/$(LIB_FILE)"'
 
 fi
 
     # Stub lib does not depend on shared/static configuration
-    if test "$RANLIB" = ""; then :
+    if test "$RANLIB" = ""
+then :
 
         MAKE_STUB_LIB='${STLIB_LD} $@ ${STUB_LIB_OBJS}'
 
-else
+else $as_nop
 
         MAKE_STUB_LIB='${STLIB_LD} $@ ${STUB_LIB_OBJS} ; ${RANLIB} $@'
 
 fi
     INSTALL_STUB_LIB='$(INSTALL_LIBRARY) $(STUB_LIB_FILE) "$(LIB_INSTALL_DIR)/$(STUB_LIB_FILE)"'
 
     # Define TCL_LIBS now that we know what DL_LIBS is.
     # The trick here is that we don't want to change the value of TCL_LIBS if
     # it is already set when tclConfig.sh had been loaded by Tk.
-    if test "x${TCL_LIBS}" = x; then :
+    if test "x${TCL_LIBS}" = x
+then :
 
         TCL_LIBS="${DL_LIBS} ${LIBS} ${MATH_LIBS}"
 fi
 
 
-	# See if the compiler supports casting to a union type.
-	# This is used to stop gcc from printing a compiler
-	# warning when initializing a union member.
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cast to union support" >&5
-$as_echo_n "checking for cast to union support... " >&6; }
-if ${tcl_cv_cast_to_union+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    # See if the compiler supports casting to a union type.
+    # This is used to stop gcc from printing a compiler
+    # warning when initializing a union member.
+
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for cast to union support" >&5
+printf %s "checking for cast to union support... " >&6; }
+if test ${tcl_cv_cast_to_union+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
-		  union foo { int i; double d; };
-		  union foo f = (union foo) (int) 0;
+		union foo { int i; double d; };
+		union foo f = (union foo) (int) 0;
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_cast_to_union=yes
-else
+else $as_nop
   tcl_cv_cast_to_union=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cast_to_union" >&5
-$as_echo "$tcl_cv_cast_to_union" >&6; }
-	if test "$tcl_cv_cast_to_union" = "yes"; then
-
-$as_echo "#define HAVE_CAST_TO_UNION 1" >>confdefs.h
-
-	fi
-
-    ac_fn_c_check_header_mongrel "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default"
-if test "x$ac_cv_header_stdbool_h" = xyes; then :
-
-$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
-
-fi
-
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cast_to_union" >&5
+printf "%s\n" "$tcl_cv_cast_to_union" >&6; }
+    if test "$tcl_cv_cast_to_union" = "yes"; then
+
+printf "%s\n" "#define HAVE_CAST_TO_UNION 1" >>confdefs.h
+
+    fi
+    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -fno-lto"
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working -fno-lto" >&5
+printf %s "checking for working -fno-lto... " >&6; }
+if test ${ac_cv_nolto+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_nolto=yes
+else $as_nop
+  ac_cv_nolto=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_nolto" >&5
+printf "%s\n" "$ac_cv_nolto" >&6; }
+    CFLAGS=$hold_cflags
+    if test "$ac_cv_nolto" = "yes" ; then
+	CFLAGS_NOLTO="-fno-lto"
+    else
+	CFLAGS_NOLTO=""
+    fi
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the compiler understands -finput-charset" >&5
+printf %s "checking if the compiler understands -finput-charset... " >&6; }
+if test ${tcl_cv_cc_input_charset+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -finput-charset=UTF-8"
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  tcl_cv_cc_input_charset=yes
+else $as_nop
+  tcl_cv_cc_input_charset=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+	CFLAGS=$hold_cflags
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_input_charset" >&5
+printf "%s\n" "$tcl_cv_cc_input_charset" >&6; }
+    if test $tcl_cv_cc_input_charset = yes; then
+	CFLAGS="$CFLAGS -finput-charset=UTF-8"
+    fi
+
+    ac_fn_c_check_header_compile "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default"
+if test "x$ac_cv_header_stdbool_h" = xyes
+then :
+
+printf "%s\n" "#define HAVE_STDBOOL_H 1" >>confdefs.h
+
+fi
 
 
     # FIXME: This subst was left in only because the TCL_DL_LIBS
     # entry in tclConfig.sh uses it. It is not clear why someone
     # would use TCL_DL_LIBS instead of TCL_LIBS.
@@ -5919,13 +6281,12 @@
 
 
 
 
 
-cat >>confdefs.h <<_ACEOF
-#define TCL_SHLIB_EXT "${SHLIB_SUFFIX}"
-_ACEOF
+
+printf "%s\n" "#define TCL_SHLIB_EXT \"${SHLIB_SUFFIX}\"" >>confdefs.h
 
 
 
 
 
@@ -5933,445 +6294,441 @@
 
 
 
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for build with symbols" >&5
-$as_echo_n "checking for build with symbols... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for build with symbols" >&5
+printf %s "checking for build with symbols... " >&6; }
     # Check whether --enable-symbols was given.
-if test "${enable_symbols+set}" = set; then :
+if test ${enable_symbols+y}
+then :
   enableval=$enable_symbols; tcl_ok=$enableval
-else
+else $as_nop
   tcl_ok=no
 fi
 
 # FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
     if test "$tcl_ok" = "no"; then
 	CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
 	LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
 
-$as_echo "#define NDEBUG 1" >>confdefs.h
+printf "%s\n" "#define NDEBUG 1" >>confdefs.h
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 
-$as_echo "#define TCL_CFG_OPTIMIZED 1" >>confdefs.h
+printf "%s\n" "#define TCL_CFG_OPTIMIZED 1" >>confdefs.h
 
     else
 	CFLAGS_DEFAULT='$(CFLAGS_DEBUG)'
 	LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)'
 	if test "$tcl_ok" = "yes"; then
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (standard debugging)" >&5
-$as_echo "yes (standard debugging)" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes (standard debugging)" >&5
+printf "%s\n" "yes (standard debugging)" >&6; }
 	fi
     fi
 
 
 
     if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
 
-$as_echo "#define TCL_MEM_DEBUG 1" >>confdefs.h
+printf "%s\n" "#define TCL_MEM_DEBUG 1" >>confdefs.h
 
     fi
 
 
 
     if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
 	if test "$tcl_ok" = "all"; then
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled symbols mem debugging" >&5
-$as_echo "enabled symbols mem debugging" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: enabled symbols mem debugging" >&5
+printf "%s\n" "enabled symbols mem debugging" >&6; }
 	else
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled $tcl_ok debugging" >&5
-$as_echo "enabled $tcl_ok debugging" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: enabled $tcl_ok debugging" >&5
+printf "%s\n" "enabled $tcl_ok debugging" >&6; }
 	fi
     fi
 
 
 #--------------------------------------------------------------------
 #	Detect what compiler flags to set for 64-bit support.
 #--------------------------------------------------------------------
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for required early compiler flags" >&5
-$as_echo_n "checking for required early compiler flags... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for required early compiler flags" >&5
+printf %s "checking for required early compiler flags... " >&6; }
     tcl_flags=""
 
-    if ${tcl_cv_flag__isoc99_source+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    if test ${tcl_cv_flag__isoc99_source+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdlib.h>
 int
-main ()
+main (void)
 {
 char *p = (char *)strtoll; char *q = (char *)strtoull;
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_flag__isoc99_source=no
-else
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #define _ISOC99_SOURCE 1
 #include <stdlib.h>
 int
-main ()
+main (void)
 {
 char *p = (char *)strtoll; char *q = (char *)strtoull;
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_flag__isoc99_source=yes
-else
+else $as_nop
   tcl_cv_flag__isoc99_source=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
     if test "x${tcl_cv_flag__isoc99_source}" = "xyes" ; then
 
-$as_echo "#define _ISOC99_SOURCE 1" >>confdefs.h
+printf "%s\n" "#define _ISOC99_SOURCE 1" >>confdefs.h
 
 	tcl_flags="$tcl_flags _ISOC99_SOURCE"
     fi
 
 
-    if ${tcl_cv_flag__largefile64_source+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    if test ${tcl_cv_flag__largefile64_source+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/stat.h>
 int
-main ()
+main (void)
 {
 struct stat64 buf; int i = stat64("/", &buf);
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_flag__largefile64_source=no
-else
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #define _LARGEFILE64_SOURCE 1
 #include <sys/stat.h>
 int
-main ()
+main (void)
 {
 struct stat64 buf; int i = stat64("/", &buf);
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_flag__largefile64_source=yes
-else
+else $as_nop
   tcl_cv_flag__largefile64_source=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
     if test "x${tcl_cv_flag__largefile64_source}" = "xyes" ; then
 
-$as_echo "#define _LARGEFILE64_SOURCE 1" >>confdefs.h
+printf "%s\n" "#define _LARGEFILE64_SOURCE 1" >>confdefs.h
 
 	tcl_flags="$tcl_flags _LARGEFILE64_SOURCE"
     fi
 
 
-    if ${tcl_cv_flag__largefile_source64+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    if test ${tcl_cv_flag__largefile_source64+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/stat.h>
 int
-main ()
+main (void)
 {
 char *p = (char *)open64;
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_flag__largefile_source64=no
-else
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #define _LARGEFILE_SOURCE64 1
 #include <sys/stat.h>
 int
-main ()
+main (void)
 {
 char *p = (char *)open64;
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_flag__largefile_source64=yes
-else
+else $as_nop
   tcl_cv_flag__largefile_source64=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
     if test "x${tcl_cv_flag__largefile_source64}" = "xyes" ; then
 
-$as_echo "#define _LARGEFILE_SOURCE64 1" >>confdefs.h
+printf "%s\n" "#define _LARGEFILE_SOURCE64 1" >>confdefs.h
 
 	tcl_flags="$tcl_flags _LARGEFILE_SOURCE64"
     fi
 
     if test "x${tcl_flags}" = "x" ; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
-$as_echo "none" >&6; }
-    else
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${tcl_flags}" >&5
-$as_echo "${tcl_flags}" >&6; }
-    fi
-
-
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit integer type" >&5
-$as_echo_n "checking for 64-bit integer type... " >&6; }
-    if ${tcl_cv_type_64bit+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-
-	tcl_cv_type_64bit=none
-	# See if the compiler knows natively about __int64
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-__int64 value = (__int64) 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  tcl_type_64bit=__int64
-else
-  tcl_type_64bit="long long"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
+printf "%s\n" "none" >&6; }
+    else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${tcl_flags}" >&5
+printf "%s\n" "${tcl_flags}" >&6; }
+    fi
+
+
+
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for 64-bit integer type" >&5
+printf %s "checking for 64-bit integer type... " >&6; }
+    if test ${tcl_cv_type_64bit+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+	tcl_cv_type_64bit=none
 	# See if we could use long anyway  Note that we substitute in the
 	# type that is our current guess for a 64-bit type inside this check
 	# program, so it should be modified only carefully...
         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 switch (0) {
-            case 1: case (sizeof(${tcl_type_64bit})==sizeof(long)): ;
+            case 1: case (sizeof(long long)==sizeof(long)): ;
         }
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  tcl_cv_type_64bit=${tcl_type_64bit}
+if ac_fn_c_try_compile "$LINENO"
+then :
+  tcl_cv_type_64bit="long long"
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
     if test "${tcl_cv_type_64bit}" = none ; then
 
-$as_echo "#define TCL_WIDE_INT_IS_LONG 1" >>confdefs.h
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-    else
-
-cat >>confdefs.h <<_ACEOF
-#define TCL_WIDE_INT_TYPE ${tcl_cv_type_64bit}
-_ACEOF
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${tcl_cv_type_64bit}" >&5
-$as_echo "${tcl_cv_type_64bit}" >&6; }
-
+printf "%s\n" "#define TCL_WIDE_INT_IS_LONG 1" >>confdefs.h
+
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+    else
 	# Now check for auxiliary declarations
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct dirent64" >&5
-$as_echo_n "checking for struct dirent64... " >&6; }
-if ${tcl_cv_struct_dirent64+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct dirent64" >&5
+printf %s "checking for struct dirent64... " >&6; }
+if test ${tcl_cv_struct_dirent64+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/types.h>
 #include <dirent.h>
 int
-main ()
+main (void)
 {
 struct dirent64 p;
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_struct_dirent64=yes
-else
+else $as_nop
   tcl_cv_struct_dirent64=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_struct_dirent64" >&5
-$as_echo "$tcl_cv_struct_dirent64" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_struct_dirent64" >&5
+printf "%s\n" "$tcl_cv_struct_dirent64" >&6; }
 	if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
 
-$as_echo "#define HAVE_STRUCT_DIRENT64 1" >>confdefs.h
+printf "%s\n" "#define HAVE_STRUCT_DIRENT64 1" >>confdefs.h
 
 	fi
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DIR64" >&5
-$as_echo_n "checking for DIR64... " >&6; }
-if ${tcl_cv_DIR64+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for DIR64" >&5
+printf %s "checking for DIR64... " >&6; }
+if test ${tcl_cv_DIR64+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/types.h>
 #include <dirent.h>
 int
-main ()
+main (void)
 {
 struct dirent64 *p; DIR64 d = opendir64(".");
             p = readdir64(d); rewinddir64(d); closedir64(d);
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_DIR64=yes
-else
+else $as_nop
   tcl_cv_DIR64=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_DIR64" >&5
-$as_echo "$tcl_cv_DIR64" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_DIR64" >&5
+printf "%s\n" "$tcl_cv_DIR64" >&6; }
 	if test "x${tcl_cv_DIR64}" = "xyes" ; then
 
-$as_echo "#define HAVE_DIR64 1" >>confdefs.h
+printf "%s\n" "#define HAVE_DIR64 1" >>confdefs.h
 
 	fi
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct stat64" >&5
-$as_echo_n "checking for struct stat64... " >&6; }
-if ${tcl_cv_struct_stat64+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct stat64" >&5
+printf %s "checking for struct stat64... " >&6; }
+if test ${tcl_cv_struct_stat64+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/stat.h>
 int
-main ()
+main (void)
 {
 struct stat64 p;
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_struct_stat64=yes
-else
+else $as_nop
   tcl_cv_struct_stat64=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_struct_stat64" >&5
-$as_echo "$tcl_cv_struct_stat64" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_struct_stat64" >&5
+printf "%s\n" "$tcl_cv_struct_stat64" >&6; }
 	if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
 
-$as_echo "#define HAVE_STRUCT_STAT64 1" >>confdefs.h
+printf "%s\n" "#define HAVE_STRUCT_STAT64 1" >>confdefs.h
 
 	fi
 
-	for ac_func in open64 lseek64
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
+	ac_fn_c_check_func "$LINENO" "open64" "ac_cv_func_open64"
+if test "x$ac_cv_func_open64" = xyes
+then :
+  printf "%s\n" "#define HAVE_OPEN64 1" >>confdefs.h
 
 fi
-done
+ac_fn_c_check_func "$LINENO" "lseek64" "ac_cv_func_lseek64"
+if test "x$ac_cv_func_lseek64" = xyes
+then :
+  printf "%s\n" "#define HAVE_LSEEK64 1" >>confdefs.h
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for off64_t" >&5
-$as_echo_n "checking for off64_t... " >&6; }
-	if ${tcl_cv_type_off64_t+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+fi
+
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for off64_t" >&5
+printf %s "checking for off64_t... " >&6; }
+	if test ${tcl_cv_type_off64_t+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/types.h>
 int
-main ()
+main (void)
 {
 off64_t offset;
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_type_off64_t=yes
-else
+else $as_nop
   tcl_cv_type_off64_t=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
 			if test "x${tcl_cv_type_off64_t}" = "xyes" && \
 	        test "x${ac_cv_func_lseek64}" = "xyes" && \
 	        test "x${ac_cv_func_open64}" = "xyes" ; then
 
-$as_echo "#define HAVE_TYPE_OFF64_T 1" >>confdefs.h
+printf "%s\n" "#define HAVE_TYPE_OFF64_T 1" >>confdefs.h
 
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
 	else
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 	fi
     fi
 
 
 #--------------------------------------------------------------------
 #	Check endianness because we can optimize some operations
 #--------------------------------------------------------------------
 
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
-$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
-if ${ac_cv_c_bigendian+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
+printf %s "checking whether byte ordering is bigendian... " >&6; }
+if test ${ac_cv_c_bigendian+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_cv_c_bigendian=unknown
     # See if we're dealing with a universal compiler.
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #ifndef __APPLE_CC__
@@ -6378,11 +6735,12 @@
 	       not a universal capable compiler
 	     #endif
 	     typedef int dummy;
 
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
 
 	# Check for potential -arch flags.  It is not universal unless
 	# there are at least two -arch flags with different values.
 	ac_arch=
 	ac_prev=
@@ -6402,20 +6760,20 @@
 	 elif test "x$ac_word" = "x-arch"; then
 	   ac_prev=arch
 	 fi
        done
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
     if test $ac_cv_c_bigendian = unknown; then
       # See if sys/param.h defines the BYTE_ORDER macro.
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/types.h>
 	     #include <sys/param.h>
 
 int
-main ()
+main (void)
 {
 #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
 		     && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
 		     && LITTLE_ENDIAN)
 	      bogus endian macros
@@ -6423,111 +6781,117 @@
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   # It does; now see whether it defined to BIG_ENDIAN or not.
 	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/types.h>
 		#include <sys/param.h>
 
 int
-main ()
+main (void)
 {
 #if BYTE_ORDER != BIG_ENDIAN
 		 not big endian
 		#endif
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_c_bigendian=yes
-else
+else $as_nop
   ac_cv_c_bigendian=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
     fi
     if test $ac_cv_c_bigendian = unknown; then
       # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <limits.h>
 
 int
-main ()
+main (void)
 {
 #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
 	      bogus endian macros
 	     #endif
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   # It does; now see whether it defined to _BIG_ENDIAN or not.
 	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <limits.h>
 
 int
-main ()
+main (void)
 {
 #ifndef _BIG_ENDIAN
 		 not big endian
 		#endif
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_c_bigendian=yes
-else
+else $as_nop
   ac_cv_c_bigendian=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
     fi
     if test $ac_cv_c_bigendian = unknown; then
       # Compile a test program.
-      if test "$cross_compiling" = yes; then :
+      if test "$cross_compiling" = yes
+then :
   # Try to guess by grepping values from an object file.
 	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-short int ascii_mm[] =
+unsigned short int ascii_mm[] =
 		  { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
-		short int ascii_ii[] =
+		unsigned short int ascii_ii[] =
 		  { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
 		int use_ascii (int i) {
 		  return ascii_mm[i] + ascii_ii[i];
 		}
-		short int ebcdic_ii[] =
+		unsigned short int ebcdic_ii[] =
 		  { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
-		short int ebcdic_mm[] =
+		unsigned short int ebcdic_mm[] =
 		  { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
 		int use_ebcdic (int i) {
 		  return ebcdic_mm[i] + ebcdic_ii[i];
 		}
 		extern int foo;
 
 int
-main ()
+main (void)
 {
 return use_ascii (foo) == use_ebcdic (foo);
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then
 	      ac_cv_c_bigendian=yes
 	    fi
 	    if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
 	      if test "$ac_cv_c_bigendian" = unknown; then
@@ -6536,17 +6900,17 @@
 		# finding both strings is unlikely to happen, but who knows?
 		ac_cv_c_bigendian=unknown
 	      fi
 	    fi
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $ac_includes_default
 int
-main ()
+main (void)
 {
 
 	     /* Are we little or big endian?  From Harbison&Steele.  */
 	     union
 	     {
@@ -6558,32 +6922,33 @@
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
+if ac_fn_c_try_run "$LINENO"
+then :
   ac_cv_c_bigendian=no
-else
+else $as_nop
   ac_cv_c_bigendian=yes
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
     fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5
-$as_echo "$ac_cv_c_bigendian" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5
+printf "%s\n" "$ac_cv_c_bigendian" >&6; }
  case $ac_cv_c_bigendian in #(
    yes)
-     $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h
+     printf "%s\n" "#define WORDS_BIGENDIAN 1" >>confdefs.h
 ;; #(
    no)
       ;; #(
    universal)
 
-$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
+printf "%s\n" "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
 
      ;; #(
    *)
      as_fn_error $? "unknown endianness
  presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
@@ -6600,16 +6965,16 @@
 if test "$TCL_EXEC_PREFIX" != "$exec_prefix"; then
     LIB_RUNTIME_DIR="${LIB_RUNTIME_DIR}:${TCL_EXEC_PREFIX}/lib"
 fi
 
 if test "$TCL_PREFIX" != "$prefix"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING:
         Different --prefix selected for Tk and Tcl!
-        [package require Tk] may not work correctly in tclsh." >&5
-$as_echo "$as_me: WARNING:
+        [package require tk] may not work correctly in tclsh." >&5
+printf "%s\n" "$as_me: WARNING:
         Different --prefix selected for Tk and Tcl!
-        [package require Tk] may not work correctly in tclsh." >&2;}
+        [package require tk] may not work correctly in tclsh." >&2;}
 fi
 
 #--------------------------------------------------------------------
 #	Include sys/select.h if it exists and if it supplies things
 #	that appear to be useful and aren't already in sys/types.h.
@@ -6618,467 +6983,568 @@
 #	other systems like SCO UNIX have a sys/select.h that's
 #	pernicious.  If "fd_set" isn't defined anywhere then set a
 #	special flag.
 #--------------------------------------------------------------------
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fd_set in sys/types" >&5
-$as_echo_n "checking for fd_set in sys/types... " >&6; }
-if ${tcl_cv_type_fd_set+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fd_set in sys/types" >&5
+printf %s "checking for fd_set in sys/types... " >&6; }
+if test ${tcl_cv_type_fd_set+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/types.h>
 int
-main ()
+main (void)
 {
 fd_set readMask, writeMask;
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_type_fd_set=yes
-else
+else $as_nop
   tcl_cv_type_fd_set=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_type_fd_set" >&5
-$as_echo "$tcl_cv_type_fd_set" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_type_fd_set" >&5
+printf "%s\n" "$tcl_cv_type_fd_set" >&6; }
 tk_ok=$tcl_cv_type_fd_set
 if test $tk_ok = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fd_mask in sys/select" >&5
-$as_echo_n "checking for fd_mask in sys/select... " >&6; }
-if ${tcl_cv_grep_fd_mask+:} false; then :
-  $as_echo_n "(cached) " >&6
+    ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+printf %s "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test ${ac_cv_prog_CPP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+      # Double quotes because $CC needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <limits.h>
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"
+then :
+
+else $as_nop
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"
+then :
+  # Broken: success on invalid input.
+continue
+else $as_nop
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok
+then :
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+printf "%s\n" "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <limits.h>
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"
+then :
+
+else $as_nop
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"
+then :
+  # Broken: success on invalid input.
+continue
+else $as_nop
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok
+then :
+
+else $as_nop
+  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+printf %s "checking for grep that handles long lines and -e... " >&6; }
+if test ${ac_cv_path_GREP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in grep ggrep
+   do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  printf %s 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    printf "%s\n" 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+printf "%s\n" "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+printf %s "checking for egrep... " >&6; }
+if test ${ac_cv_path_EGREP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in egrep
+   do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  printf %s 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    printf "%s\n" 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
 else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+printf "%s\n" "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fd_mask in sys/select" >&5
+printf %s "checking for fd_mask in sys/select... " >&6; }
+if test ${tcl_cv_grep_fd_mask+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <sys/select.h>
 
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "fd_mask" >/dev/null 2>&1; then :
+  $EGREP "fd_mask" >/dev/null 2>&1
+then :
   tcl_cv_grep_fd_mask=present
-else
+else $as_nop
   tcl_cv_grep_fd_mask=missing
 fi
-rm -f conftest*
+rm -rf conftest*
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_grep_fd_mask" >&5
-$as_echo "$tcl_cv_grep_fd_mask" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_grep_fd_mask" >&5
+printf "%s\n" "$tcl_cv_grep_fd_mask" >&6; }
     if test $tcl_cv_grep_fd_mask = present; then
 
-$as_echo "#define HAVE_SYS_SELECT_H 1" >>confdefs.h
+printf "%s\n" "#define HAVE_SYS_SELECT_H 1" >>confdefs.h
 
 	tk_ok=yes
     fi
 fi
 if test $tk_ok = no; then
 
-$as_echo "#define NO_FD_SET 1" >>confdefs.h
+printf "%s\n" "#define NO_FD_SET 1" >>confdefs.h
 
 fi
 
 #------------------------------------------------------------------------------
 #       Find out all about time handling differences.
 #------------------------------------------------------------------------------
 
-for ac_header in sys/time.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_time_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_SYS_TIME_H 1
-_ACEOF
-
-fi
-
-done
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
-$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
-if ${ac_cv_header_time+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-#include <sys/time.h>
-#include <time.h>
-
-int
-main ()
-{
-if ((struct tm *) 0)
-return 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_header_time=yes
-else
-  ac_cv_header_time=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5
-$as_echo "$ac_cv_header_time" >&6; }
-if test $ac_cv_header_time = yes; then
-
-$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
-
-fi
+
 
 
 #--------------------------------------------------------------------
 #	Check for various typedefs and provide substitutes if
 #	they don't exist.
 #--------------------------------------------------------------------
 
 ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default"
-if test "x$ac_cv_type_mode_t" = xyes; then :
-
-else
-
-cat >>confdefs.h <<_ACEOF
-#define mode_t int
-_ACEOF
-
-fi
-
-ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default"
-if test "x$ac_cv_type_pid_t" = xyes; then :
-
-else
-
-cat >>confdefs.h <<_ACEOF
-#define pid_t int
-_ACEOF
-
-fi
+if test "x$ac_cv_type_mode_t" = xyes
+then :
+
+else $as_nop
+
+printf "%s\n" "#define mode_t int" >>confdefs.h
+
+fi
+
+
+  ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default
+"
+if test "x$ac_cv_type_pid_t" = xyes
+then :
+
+else $as_nop
+                                          cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+          #if defined _WIN64 && !defined __CYGWIN__
+          LLP64
+          #endif
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_pid_type='int'
+else $as_nop
+  ac_pid_type='__int64'
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
+printf "%s\n" "#define pid_t $ac_pid_type" >>confdefs.h
+
+
+fi
+
 
 ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
-if test "x$ac_cv_type_size_t" = xyes; then :
-
-else
-
-cat >>confdefs.h <<_ACEOF
-#define size_t unsigned int
-_ACEOF
-
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5
-$as_echo_n "checking for uid_t in sys/types.h... " >&6; }
-if ${ac_cv_type_uid_t+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "uid_t" >/dev/null 2>&1; then :
-  ac_cv_type_uid_t=yes
-else
-  ac_cv_type_uid_t=no
-fi
-rm -f conftest*
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5
-$as_echo "$ac_cv_type_uid_t" >&6; }
-if test $ac_cv_type_uid_t = no; then
-
-$as_echo "#define uid_t int" >>confdefs.h
-
-
-$as_echo "#define gid_t int" >>confdefs.h
-
-fi
-
-
-ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
-if test "x$ac_cv_type_intptr_t" = xyes; then :
-
-
-$as_echo "#define HAVE_INTPTR_T 1" >>confdefs.h
-
-else
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pointer-size signed integer type" >&5
-$as_echo_n "checking for pointer-size signed integer type... " >&6; }
-if ${tcl_cv_intptr_t+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-
-    for tcl_cv_intptr_t in "int" "long" "long long" none; do
-	if test "$tcl_cv_intptr_t" != none; then
-	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($tcl_cv_intptr_t))];
-test_array [0] = 0;
-return test_array [0];
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  tcl_ok=yes
-else
-  tcl_ok=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-	    test "$tcl_ok" = yes && break; fi
-    done
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_intptr_t" >&5
-$as_echo "$tcl_cv_intptr_t" >&6; }
-    if test "$tcl_cv_intptr_t" != none; then
-
-cat >>confdefs.h <<_ACEOF
-#define intptr_t $tcl_cv_intptr_t
-_ACEOF
-
-    fi
-
-fi
-
-ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
-if test "x$ac_cv_type_uintptr_t" = xyes; then :
-
-
-$as_echo "#define HAVE_UINTPTR_T 1" >>confdefs.h
-
-else
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pointer-size unsigned integer type" >&5
-$as_echo_n "checking for pointer-size unsigned integer type... " >&6; }
-if ${tcl_cv_uintptr_t+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-
-    for tcl_cv_uintptr_t in "unsigned int" "unsigned long" "unsigned long long" \
-	    none; do
-	if test "$tcl_cv_uintptr_t" != none; then
-	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($tcl_cv_uintptr_t))];
-test_array [0] = 0;
-return test_array [0];
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  tcl_ok=yes
-else
-  tcl_ok=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-	    test "$tcl_ok" = yes && break; fi
-    done
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_uintptr_t" >&5
-$as_echo "$tcl_cv_uintptr_t" >&6; }
-    if test "$tcl_cv_uintptr_t" != none; then
-
-cat >>confdefs.h <<_ACEOF
-#define uintptr_t $tcl_cv_uintptr_t
-_ACEOF
-
-    fi
+if test "x$ac_cv_type_size_t" = xyes
+then :
+
+else $as_nop
+
+printf "%s\n" "#define size_t unsigned int" >>confdefs.h
+
+fi
+
+
+ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "
+#include <stdint.h>
+
+"
+if test "x$ac_cv_type_intptr_t" = xyes
+then :
+
+printf "%s\n" "#define HAVE_INTPTR_T 1" >>confdefs.h
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "
+#include <stdint.h>
+
+"
+if test "x$ac_cv_type_uintptr_t" = xyes
+then :
+
+printf "%s\n" "#define HAVE_UINTPTR_T 1" >>confdefs.h
+
 
 fi
 
 
 #-------------------------------------------
 #     In OS/390 struct pwd has no pw_gecos field
 #-------------------------------------------
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pw_gecos in struct pwd" >&5
-$as_echo_n "checking pw_gecos in struct pwd... " >&6; }
-if ${tcl_cv_pwd_pw_gecos+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking pw_gecos in struct pwd" >&5
+printf %s "checking pw_gecos in struct pwd... " >&6; }
+if test ${tcl_cv_pwd_pw_gecos+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <pwd.h>
 int
-main ()
+main (void)
 {
 struct passwd pwd; (void)pwd.pw_gecos;
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_pwd_pw_gecos=yes
-else
+else $as_nop
   tcl_cv_pwd_pw_gecos=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_pwd_pw_gecos" >&5
-$as_echo "$tcl_cv_pwd_pw_gecos" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_pwd_pw_gecos" >&5
+printf "%s\n" "$tcl_cv_pwd_pw_gecos" >&6; }
 if test $tcl_cv_pwd_pw_gecos = yes; then
 
-$as_echo "#define HAVE_PW_GECOS 1" >>confdefs.h
+printf "%s\n" "#define HAVE_PW_GECOS 1" >>confdefs.h
 
 fi
 
 #--------------------------------------------------------------------
 #	On Mac OS X, we can build either with X11 or with Aqua
 #--------------------------------------------------------------------
 
 if test "`uname -s`" = "Darwin" ; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use Aqua" >&5
-$as_echo_n "checking whether to use Aqua... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use Aqua" >&5
+printf %s "checking whether to use Aqua... " >&6; }
     # Check whether --enable-aqua was given.
-if test "${enable_aqua+set}" = set; then :
+if test ${enable_aqua+y}
+then :
   enableval=$enable_aqua; tk_aqua=$enableval
-else
+else $as_nop
   tk_aqua=no
 fi
 
     if test $tk_aqua = yes -o $tk_aqua = cocoa; then
 	tk_aqua=yes
 	if test $tcl_corefoundation = no; then
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Aqua can only be used when CoreFoundation is available" >&5
-$as_echo "$as_me: WARNING: Aqua can only be used when CoreFoundation is available" >&2;}
-	    tk_aqua=no
-	fi
-	if test ! -d /System/Library/Frameworks/Cocoa.framework; then
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Aqua can only be used when Cocoa is available" >&5
-$as_echo "$as_me: WARNING: Aqua can only be used when Cocoa is available" >&2;}
-	    tk_aqua=no
-	fi
-	if test "`uname -r | awk -F. '{print $1}'`" -lt 9; then
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Aqua requires Mac OS X 10.5 or later" >&5
-$as_echo "$as_me: WARNING: Aqua requires Mac OS X 10.5 or later" >&2;}
-	    tk_aqua=no
-	fi
-    fi
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tk_aqua" >&5
-$as_echo "$tk_aqua" >&6; }
-    if test "$fat_32_64" = yes; then
-	if test $tk_aqua = no; then
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit X11" >&5
-$as_echo_n "checking for 64-bit X11... " >&6; }
-if ${tcl_cv_lib_x11_64+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-
-		for v in CFLAGS CPPFLAGS LDFLAGS; do
-		    eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"'
-		done
-		CPPFLAGS="$CPPFLAGS -I/usr/X11R6/include"
-		LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
-		cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <X11/Xlib.h>
-int
-main ()
-{
-XrmInitialize();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  tcl_cv_lib_x11_64=yes
-else
-  tcl_cv_lib_x11_64=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-		for v in CFLAGS CPPFLAGS LDFLAGS; do
-		    eval $v'="$hold_'$v'"'
-		done
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_lib_x11_64" >&5
-$as_echo "$tcl_cv_lib_x11_64" >&6; }
-	fi
-	# remove 64-bit arch flags from CFLAGS et al. for combined 32 & 64 bit
-	# fat builds if configuration does not support 64-bit.
-	if test "$tcl_cv_lib_x11_64" = no; then
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: Removing 64-bit architectures from compiler & linker flags" >&5
-$as_echo "$as_me: Removing 64-bit architectures from compiler & linker flags" >&6;}
-	    for v in CFLAGS CPPFLAGS LDFLAGS; do
-		eval $v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"'
-	    done
-	fi
-    fi
-    if test $tk_aqua = no; then
-	# check if weak linking whole libraries is possible.
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if ld accepts -weak-l flag" >&5
-$as_echo_n "checking if ld accepts -weak-l flag... " >&6; }
-if ${tcl_cv_ld_weak_l+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Aqua can only be used when CoreFoundation is available" >&5
+printf "%s\n" "$as_me: WARNING: Aqua can only be used when CoreFoundation is available" >&2;}
+	    tk_aqua=no
+	fi
+	if test ! -d /System/Library/Frameworks/Cocoa.framework; then
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Aqua can only be used when Cocoa is available" >&5
+printf "%s\n" "$as_me: WARNING: Aqua can only be used when Cocoa is available" >&2;}
+	    tk_aqua=no
+	fi
+	if test "`uname -r | awk -F. '{print $1}'`" -lt 9; then
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Aqua requires Mac OS X 10.5 or later" >&5
+printf "%s\n" "$as_me: WARNING: Aqua requires Mac OS X 10.5 or later" >&2;}
+	    tk_aqua=no
+	fi
+    fi
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tk_aqua" >&5
+printf "%s\n" "$tk_aqua" >&6; }
+    if test $tk_aqua = no; then
+	# check if weak linking whole libraries is possible.
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if ld accepts -weak-l flag" >&5
+printf %s "checking if ld accepts -weak-l flag... " >&6; }
+if test ${tcl_cv_ld_weak_l+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 	    hold_ldflags=$LDFLAGS
 	    LDFLAGS="$LDFLAGS -Wl,-weak-lm"
 	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <math.h>
 int
-main ()
+main (void)
 {
 double f = sin(1.0);
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   tcl_cv_ld_weak_l=yes
-else
+else $as_nop
   tcl_cv_ld_weak_l=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 	    LDFLAGS=$hold_ldflags
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_weak_l" >&5
-$as_echo "$tcl_cv_ld_weak_l" >&6; }
-    fi
-    for ac_header in AvailabilityMacros.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "AvailabilityMacros.h" "ac_cv_header_AvailabilityMacros_h" "$ac_includes_default"
-if test "x$ac_cv_header_AvailabilityMacros_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_AVAILABILITYMACROS_H 1
-_ACEOF
-
-fi
-
-done
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_weak_l" >&5
+printf "%s\n" "$tcl_cv_ld_weak_l" >&6; }
+    fi
+    ac_fn_c_check_header_compile "$LINENO" "AvailabilityMacros.h" "ac_cv_header_AvailabilityMacros_h" "$ac_includes_default"
+if test "x$ac_cv_header_AvailabilityMacros_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_AVAILABILITYMACROS_H 1" >>confdefs.h
+
+fi
 
     if test "$ac_cv_header_AvailabilityMacros_h" = yes; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if weak import is available" >&5
-$as_echo_n "checking if weak import is available... " >&6; }
-if ${tcl_cv_cc_weak_import+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if weak import is available" >&5
+printf %s "checking if weak import is available... " >&6; }
+if test ${tcl_cv_cc_weak_import+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 	    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
 	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -7090,38 +7556,40 @@
 		    #error MAC_OS_X_VERSION_MIN_REQUIRED < 1020
 		    #endif
 		    int rand(void) __attribute__((weak_import));
 
 int
-main ()
+main (void)
 {
 rand();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   tcl_cv_cc_weak_import=yes
-else
+else $as_nop
   tcl_cv_cc_weak_import=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 	    CFLAGS=$hold_cflags
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_weak_import" >&5
-$as_echo "$tcl_cv_cc_weak_import" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_weak_import" >&5
+printf "%s\n" "$tcl_cv_cc_weak_import" >&6; }
 	if test $tcl_cv_cc_weak_import = yes; then
 
-$as_echo "#define HAVE_WEAK_IMPORT 1" >>confdefs.h
+printf "%s\n" "#define HAVE_WEAK_IMPORT 1" >>confdefs.h
 
 	fi
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if Darwin SUSv3 extensions are available" >&5
-$as_echo_n "checking if Darwin SUSv3 extensions are available... " >&6; }
-if ${tcl_cv_cc_darwin_c_source+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if Darwin SUSv3 extensions are available" >&5
+printf %s "checking if Darwin SUSv3 extensions are available... " >&6; }
+if test ${tcl_cv_cc_darwin_c_source+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 	    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
 	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -7134,47 +7602,54 @@
 		    #endif
 		    #define _DARWIN_C_SOURCE 1
 		    #include <sys/cdefs.h>
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_cc_darwin_c_source=yes
-else
+else $as_nop
   tcl_cv_cc_darwin_c_source=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 	    CFLAGS=$hold_cflags
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_darwin_c_source" >&5
-$as_echo "$tcl_cv_cc_darwin_c_source" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_darwin_c_source" >&5
+printf "%s\n" "$tcl_cv_cc_darwin_c_source" >&6; }
 	if test $tcl_cv_cc_darwin_c_source = yes; then
 
-$as_echo "#define _DARWIN_C_SOURCE 1" >>confdefs.h
+printf "%s\n" "#define _DARWIN_C_SOURCE 1" >>confdefs.h
 
 	fi
     fi
 else
     tk_aqua=no
 fi
 
 if test $tk_aqua = yes; then
 
-$as_echo "#define MAC_OSX_TK 1" >>confdefs.h
+printf "%s\n" "#define MAC_OSX_TK 1" >>confdefs.h
 
-    LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit"
-    EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c'
+    LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit -framework QuartzCore -framework Security"
+    if test -d /System/Library/Frameworks/UserNotifications.framework; then
+        LIBS="$LIBS -framework UserNotifications"
+    fi
+    if test -d "/System/Library/Frameworks/UniformTypeIdentifiers.framework"; then
+        LIBS="$LIBS -framework UniformTypeIdentifiers"
+    fi
+    EXTRA_CC_SWITCHES='-x objective-c'
     TK_WINDOWINGSYSTEM=AQUA
     if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then
 
-$as_echo "#define TK_MAC_DEBUG 1" >>confdefs.h
+printf "%s\n" "#define TK_MAC_DEBUG 1" >>confdefs.h
 
     fi
 else
     #--------------------------------------------------------------------
     #	Locate the X11 header files and the X11 library archive.  Try
@@ -7184,16 +7659,17 @@
     #	autoconf macro will return an include directory that contains
     #	no include files, so double-check its result just to be safe.
     #--------------------------------------------------------------------
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for X" >&5
-$as_echo_n "checking for X... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for X" >&5
+printf %s "checking for X... " >&6; }
 
 
 # Check whether --with-x was given.
-if test "${with_x+set}" = set; then :
+if test ${with_x+y}
+then :
   withval=$with_x;
 fi
 
 # $have_x is `yes', `no', `disabled', or empty when we do not yet know.
 if test "x$with_x" = xno; then
@@ -7200,16 +7676,45 @@
   # The user explicitly disabled X.
   have_x=disabled
 else
   case $x_includes,$x_libraries in #(
     *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #(
-    *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    *,NONE | NONE,*) if test ${ac_cv_have_x+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   # One or both of the vars are not set, and there is no cached value.
-ac_x_includes=no ac_x_libraries=no
-rm -f -r conftest.dir
+ac_x_includes=no
+ac_x_libraries=no
+# Do we need to do anything special at all?
+ac_save_LIBS=$LIBS
+LIBS="-lX11 $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <X11/Xlib.h>
+int
+main (void)
+{
+XrmInitialize ()
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  # We can compile and link X programs with no special options.
+  ac_x_includes=
+  ac_x_libraries=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS="$ac_save_LIBS"
+# If that didn't work, only try xmkmf and file system searches
+# for native compilation.
+if test x"$ac_x_includes" = xno && test "$cross_compiling" = no
+then :
+  rm -f -r conftest.dir
 if mkdir conftest.dir; then
   cd conftest.dir
   cat >Imakefile <<'_ACEOF'
 incroot:
 	@echo incroot='${INCROOT}'
@@ -7244,11 +7749,11 @@
   fi
   cd ..
   rm -f -r conftest.dir
 fi
 
-# Standard set of common directories for X headers.
+  # Standard set of common directories for X headers.
 # Check X11 before X11Rn because it is often a symlink to the current release.
 ac_x_header_dirs='
 /usr/X11/include
 /usr/X11R7/include
 /usr/X11R6/include
@@ -7270,10 +7775,12 @@
 /usr/local/include/X11
 /usr/local/include/X11R7
 /usr/local/include/X11R6
 /usr/local/include/X11R5
 /usr/local/include/X11R4
+
+/opt/X11/include
 
 /usr/X386/include
 /usr/x386/include
 /usr/XFree86/include/X11
 
@@ -7292,14 +7799,15 @@
   # First, try using that file with no special directory specified.
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <X11/Xlib.h>
 _ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
+if ac_fn_c_try_cpp "$LINENO"
+then :
   # We can compile using X headers with no special include directory.
 ac_x_includes=
-else
+else $as_nop
   for ac_dir in $ac_x_header_dirs; do
   if test -r "$ac_dir/X11/Xlib.h"; then
     ac_x_includes=$ac_dir
     break
   fi
@@ -7316,24 +7824,25 @@
   LIBS="-lX11 $LIBS"
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <X11/Xlib.h>
 int
-main ()
+main (void)
 {
 XrmInitialize ()
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   LIBS=$ac_save_LIBS
 # We can link X programs with no special library path.
 ac_x_libraries=
-else
+else $as_nop
   LIBS=$ac_save_LIBS
-for ac_dir in `$as_echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
+for ac_dir in `printf "%s\n" "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
 do
   # Don't even attempt the hair of trying to link an X program!
   for ac_extension in a so sl dylib la dll; do
     if test -r "$ac_dir/libX11.$ac_extension"; then
       ac_x_libraries=$ac_dir
@@ -7340,57 +7849,60 @@
       break 2
     fi
   done
 done
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 fi # $ac_x_libraries = no
 
+fi
+# Record the results.
 case $ac_x_includes,$ac_x_libraries in #(
-  no,* | *,no | *\'*)
+  no,* | *,no | *\'*) :
     # Didn't find X, or a directory has "'" in its name.
-    ac_cv_have_x="have_x=no";; #(
-  *)
+    ac_cv_have_x="have_x=no" ;; #(
+  *) :
     # Record where we found X for the cache.
     ac_cv_have_x="have_x=yes\
 	ac_x_includes='$ac_x_includes'\
-	ac_x_libraries='$ac_x_libraries'"
+	ac_x_libraries='$ac_x_libraries'" ;;
 esac
 fi
 ;; #(
     *) have_x=yes;;
   esac
   eval "$ac_cv_have_x"
 fi # $with_x != no
 
 if test "$have_x" != yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_x" >&5
-$as_echo "$have_x" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_x" >&5
+printf "%s\n" "$have_x" >&6; }
   no_x=yes
 else
   # If each of the values was on the command line, it overrides each guess.
   test "x$x_includes" = xNONE && x_includes=$ac_x_includes
   test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
   # Update the cache value to reflect the command line values.
   ac_cv_have_x="have_x=yes\
 	ac_x_includes='$x_includes'\
 	ac_x_libraries='$x_libraries'"
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: libraries $x_libraries, headers $x_includes" >&5
-$as_echo "libraries $x_libraries, headers $x_includes" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: libraries $x_libraries, headers $x_includes" >&5
+printf "%s\n" "libraries $x_libraries, headers $x_includes" >&6; }
 fi
 
     not_really_there=""
     if test "$no_x" = ""; then
 	if test "$x_includes" = ""; then
 	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <X11/Xlib.h>
 _ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
+if ac_fn_c_try_cpp "$LINENO"
+then :
 
-else
+else $as_nop
   not_really_there="yes"
 fi
 rm -f conftest.err conftest.i conftest.$ac_ext
 	else
 	    if test ! -r $x_includes/X11/Xlib.h; then
@@ -7397,29 +7909,30 @@
 		not_really_there="yes"
 	    fi
 	fi
     fi
     if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for X11 header files" >&5
-$as_echo_n "checking for X11 header files... " >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for X11 header files" >&5
+printf %s "checking for X11 header files... " >&6; }
 	found_xincludes="no"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <X11/Xlib.h>
 _ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
+if ac_fn_c_try_cpp "$LINENO"
+then :
   found_xincludes="yes"
-else
+else $as_nop
   found_xincludes="no"
 fi
 rm -f conftest.err conftest.i conftest.$ac_ext
 	if test "$found_xincludes" = "no"; then
 	    dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/X11R6/include /usr/X11R5/include /usr/include/X11R5 /usr/include/X11R4 /usr/openwin/include /usr/X11/include /usr/sww/include"
 	    for i in $dirs ; do
 		if test -r $i/X11/Xlib.h; then
-		    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $i" >&5
-$as_echo "$i" >&6; }
+		    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $i" >&5
+printf "%s\n" "$i" >&6; }
 		    XINCLUDES=" -I$i"
 		    found_xincludes="yes"
 		    break
 		fi
 	    done
@@ -7429,23 +7942,23 @@
 	    XINCLUDES="-I$x_includes"
 	    found_xincludes="yes"
 	fi
     fi
     if test "$found_xincludes" = "no"; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: couldn't find any!" >&5
-$as_echo "couldn't find any!" >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: couldn't find any!" >&5
+printf "%s\n" "couldn't find any!" >&6; }
     fi
 
     if test "$no_x" = yes; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for X11 libraries" >&5
-$as_echo_n "checking for X11 libraries... " >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for X11 libraries" >&5
+printf %s "checking for X11 libraries... " >&6; }
 	XLIBSW=nope
 	dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/X11R6/lib /usr/X11R5/lib /usr/lib/X11R5 /usr/lib/X11R4 /usr/openwin/lib /usr/X11/lib /usr/sww/X11/lib"
 	for i in $dirs ; do
 	    if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl -o -r $i/libX11.dylib; then
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $i" >&5
-$as_echo "$i" >&6; }
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $i" >&5
+printf "%s\n" "$i" >&6; }
 		XLIBSW="-L$i -lX11"
 		x_libraries="$i"
 		break
 	    fi
 	done
@@ -7455,54 +7968,54 @@
 	else
 	    XLIBSW="-L$x_libraries -lX11"
 	fi
     fi
     if test "$XLIBSW" = nope ; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for XCreateWindow in -lXwindow" >&5
-$as_echo_n "checking for XCreateWindow in -lXwindow... " >&6; }
-if ${ac_cv_lib_Xwindow_XCreateWindow+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for XCreateWindow in -lXwindow" >&5
+printf %s "checking for XCreateWindow in -lXwindow... " >&6; }
+if test ${ac_cv_lib_Xwindow_XCreateWindow+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lXwindow  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
 char XCreateWindow ();
 int
-main ()
+main (void)
 {
 return XCreateWindow ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_Xwindow_XCreateWindow=yes
-else
+else $as_nop
   ac_cv_lib_Xwindow_XCreateWindow=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xwindow_XCreateWindow" >&5
-$as_echo "$ac_cv_lib_Xwindow_XCreateWindow" >&6; }
-if test "x$ac_cv_lib_Xwindow_XCreateWindow" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xwindow_XCreateWindow" >&5
+printf "%s\n" "$ac_cv_lib_Xwindow_XCreateWindow" >&6; }
+if test "x$ac_cv_lib_Xwindow_XCreateWindow" = xyes
+then :
   XLIBSW=-lXwindow
 fi
 
     fi
     if test "$XLIBSW" = nope ; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: could not find any!  Using -lX11." >&5
-$as_echo "could not find any!  Using -lX11." >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: could not find any!  Using -lX11." >&5
+printf "%s\n" "could not find any!  Using -lX11." >&6; }
 	XLIBSW=-lX11
     fi
 
     TK_WINDOWINGSYSTEM=X11
 fi
@@ -7547,41 +8060,44 @@
 #	   To get around this problem, check for both libraries together
 #	   if -lsocket doesn't work by itself.
 #--------------------------------------------------------------------
 
 if test $tk_aqua = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lXbsd" >&5
-$as_echo_n "checking for main in -lXbsd... " >&6; }
-if ${ac_cv_lib_Xbsd_main+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for main in -lXbsd" >&5
+printf %s "checking for main in -lXbsd... " >&6; }
+if test ${ac_cv_lib_Xbsd_main+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lXbsd  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 
 int
-main ()
+main (void)
 {
 return main ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_Xbsd_main=yes
-else
+else $as_nop
   ac_cv_lib_Xbsd_main=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xbsd_main" >&5
-$as_echo "$ac_cv_lib_Xbsd_main" >&6; }
-if test "x$ac_cv_lib_Xbsd_main" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xbsd_main" >&5
+printf "%s\n" "$ac_cv_lib_Xbsd_main" >&6; }
+if test "x$ac_cv_lib_Xbsd_main" = xyes
+then :
   LIBS="$LIBS -lXbsd"
 fi
 
 fi
 
@@ -7595,12 +8111,12 @@
 # Note: can't use ac_check_lib macro (at least, not in Autoconf 2.1)
 # because it can't deal with the "-" in the library name.
 #--------------------------------------------------------------------
 
 if test -d /usr/include/mit -a $tk_aqua = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking MIT X libraries" >&5
-$as_echo_n "checking MIT X libraries... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking MIT X libraries" >&5
+printf %s "checking MIT X libraries... " >&6; }
     tk_oldCFlags=$CFLAGS
     CFLAGS="$CFLAGS -I/usr/include/mit"
     tk_oldLibs=$LIBS
     LIBS="$LIBS -lX11-mit"
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -7607,31 +8123,32 @@
 /* end confdefs.h.  */
 
 	#include <X11/Xlib.h>
 
 int
-main ()
+main (void)
 {
 
 	XOpenDisplay(0);
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
 	XLIBSW="-lX11-mit"
 	XINCLUDES="-I/usr/include/mit"
 
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
     CFLAGS=$tk_oldCFlags
     LIBS=$tk_oldLibs
 fi
 
@@ -7638,103 +8155,102 @@
 #--------------------------------------------------------------------
 #	Check for freetype / fontconfig / Xft support.
 #--------------------------------------------------------------------
 
 if test $tk_aqua = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use xft" >&5
-$as_echo_n "checking whether to use xft... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use xft" >&5
+printf %s "checking whether to use xft... " >&6; }
     # Check whether --enable-xft was given.
-if test "${enable_xft+set}" = set; then :
+if test ${enable_xft+y}
+then :
   enableval=$enable_xft; enable_xft=$enableval
-else
+else $as_nop
   enable_xft="default"
 fi
 
     XFT_CFLAGS=""
     XFT_LIBS=""
     if test "$enable_xft" = "no" ; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_xft" >&5
-$as_echo "$enable_xft" >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_xft" >&5
+printf "%s\n" "$enable_xft" >&6; }
     else
 	found_xft="yes"
 			XFT_CFLAGS=`xft-config --cflags 2>/dev/null` || found_xft="no"
 	XFT_LIBS=`xft-config --libs 2>/dev/null` || found_xft="no"
 	if test "$found_xft" = "no" ; then
 	    found_xft=yes
 	    XFT_CFLAGS=`pkg-config --cflags xft fontconfig 2>/dev/null` || found_xft="no"
 	    XFT_LIBS=`pkg-config --libs xft fontconfig 2>/dev/null` || found_xft="no"
 	fi
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $found_xft" >&5
-$as_echo "$found_xft" >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $found_xft" >&5
+printf "%s\n" "$found_xft" >&6; }
 		if test "$found_xft" = "yes" ; then
 	    tk_oldCFlags=$CFLAGS
 	    CFLAGS="$CFLAGS $XINCLUDES $XFT_CFLAGS"
 	    tk_oldLibs=$LIBS
 	    LIBS="$tk_oldLIBS $XFT_LIBS $XLIBSW"
 	    ac_fn_c_check_header_compile "$LINENO" "X11/Xft/Xft.h" "ac_cv_header_X11_Xft_Xft_h" "#include <X11/Xlib.h>
 "
-if test "x$ac_cv_header_X11_Xft_Xft_h" = xyes; then :
+if test "x$ac_cv_header_X11_Xft_Xft_h" = xyes
+then :
 
-else
+else $as_nop
 
 		found_xft=no
 
 fi
-
 
 	    CFLAGS=$tk_oldCFlags
 	    LIBS=$tk_oldLibs
 	fi
 		if test "$found_xft" = "yes" ; then
 	    tk_oldCFlags=$CFLAGS
 	    CFLAGS="$CFLAGS $XINCLUDES $XFT_CFLAGS"
 	    tk_oldLibs=$LIBS
 	    LIBS="$tk_oldLIBS $XFT_LIBS $XLIBSW"
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XftFontOpen in -lXft" >&5
-$as_echo_n "checking for XftFontOpen in -lXft... " >&6; }
-if ${ac_cv_lib_Xft_XftFontOpen+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for XftFontOpen in -lXft" >&5
+printf %s "checking for XftFontOpen in -lXft... " >&6; }
+if test ${ac_cv_lib_Xft_XftFontOpen+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lXft  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
 char XftFontOpen ();
 int
-main ()
+main (void)
 {
 return XftFontOpen ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_Xft_XftFontOpen=yes
-else
+else $as_nop
   ac_cv_lib_Xft_XftFontOpen=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xft_XftFontOpen" >&5
-$as_echo "$ac_cv_lib_Xft_XftFontOpen" >&6; }
-if test "x$ac_cv_lib_Xft_XftFontOpen" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBXFT 1
-_ACEOF
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xft_XftFontOpen" >&5
+printf "%s\n" "$ac_cv_lib_Xft_XftFontOpen" >&6; }
+if test "x$ac_cv_lib_Xft_XftFontOpen" = xyes
+then :
+  printf "%s\n" "#define HAVE_LIBXFT 1" >>confdefs.h
 
   LIBS="-lXft $LIBS"
 
-else
+else $as_nop
 
 		found_xft=no
 
 fi
 
@@ -7744,47 +8260,47 @@
 		if test "$found_xft" = "yes" ; then
 	    tk_oldCFlags=$CFLAGS
 	    CFLAGS="$CFLAGS $XINCLUDES $XFT_CFLAGS"
 	    tk_oldLibs=$LIBS
 	    LIBS="$tk_oldLIBS $XFT_LIBS $XLIBSW -lfontconfig"
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FcFontSort in -lfontconfig" >&5
-$as_echo_n "checking for FcFontSort in -lfontconfig... " >&6; }
-if ${ac_cv_lib_fontconfig_FcFontSort+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for FcFontSort in -lfontconfig" >&5
+printf %s "checking for FcFontSort in -lfontconfig... " >&6; }
+if test ${ac_cv_lib_fontconfig_FcFontSort+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lfontconfig  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
 char FcFontSort ();
 int
-main ()
+main (void)
 {
 return FcFontSort ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_fontconfig_FcFontSort=yes
-else
+else $as_nop
   ac_cv_lib_fontconfig_FcFontSort=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_fontconfig_FcFontSort" >&5
-$as_echo "$ac_cv_lib_fontconfig_FcFontSort" >&6; }
-if test "x$ac_cv_lib_fontconfig_FcFontSort" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_fontconfig_FcFontSort" >&5
+printf "%s\n" "$ac_cv_lib_fontconfig_FcFontSort" >&6; }
+if test "x$ac_cv_lib_fontconfig_FcFontSort" = xyes
+then :
 
 		XFT_LIBS="$XFT_LIBS -lfontconfig"
 
 fi
 
@@ -7791,12 +8307,12 @@
 	    CFLAGS=$tk_oldCFlags
 	    LIBS=$tk_oldLibs
 	fi
 		if test "$found_xft" = "no" ; then
 	    if test "$enable_xft" = "yes" ; then
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Can't find xft configuration, or xft is unusable" >&5
-$as_echo "$as_me: WARNING: Can't find xft configuration, or xft is unusable" >&2;}
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Can't find xft configuration, or xft is unusable" >&5
+printf "%s\n" "$as_me: WARNING: Can't find xft configuration, or xft is unusable" >&2;}
 	    fi
 	    enable_xft=no
 	    XFT_CFLAGS=""
 	    XFT_LIBS=""
 	else
@@ -7804,11 +8320,11 @@
 	fi
     fi
     if test $enable_xft = "yes" ; then
 	UNIX_FONT_OBJS=tkUnixRFont.o
 
-$as_echo "#define HAVE_XFT 1" >>confdefs.h
+printf "%s\n" "#define HAVE_XFT 1" >>confdefs.h
 
     else
 	UNIX_FONT_OBJS=tkUnixFont.o
     fi
 
@@ -7830,119 +8346,121 @@
     CFLAGS="$CFLAGS $XINCLUDES"
     tk_oldLibs=$LIBS
     LIBS="$tk_oldLibs $XLIBSW"
     xss_header_found=no
     xss_lib_found=no
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to try to use XScreenSaver" >&5
-$as_echo_n "checking whether to try to use XScreenSaver... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to try to use XScreenSaver" >&5
+printf %s "checking whether to try to use XScreenSaver... " >&6; }
     # Check whether --enable-xss was given.
-if test "${enable_xss+set}" = set; then :
+if test ${enable_xss+y}
+then :
   enableval=$enable_xss; enable_xss=$enableval
-else
+else $as_nop
   enable_xss=yes
 fi
 
     if test "$enable_xss" = "no" ; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_xss" >&5
-$as_echo "$enable_xss" >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_xss" >&5
+printf "%s\n" "$enable_xss" >&6; }
     else
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_xss" >&5
-$as_echo "$enable_xss" >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_xss" >&5
+printf "%s\n" "$enable_xss" >&6; }
 	ac_fn_c_check_header_compile "$LINENO" "X11/extensions/scrnsaver.h" "ac_cv_header_X11_extensions_scrnsaver_h" "#include <X11/Xlib.h>
 "
-if test "x$ac_cv_header_X11_extensions_scrnsaver_h" = xyes; then :
+if test "x$ac_cv_header_X11_extensions_scrnsaver_h" = xyes
+then :
 
 	    xss_header_found=yes
 
 fi
 
-
 	ac_fn_c_check_func "$LINENO" "XScreenSaverQueryInfo" "ac_cv_func_XScreenSaverQueryInfo"
-if test "x$ac_cv_func_XScreenSaverQueryInfo" = xyes; then :
-
-else
-
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XScreenSaverQueryInfo in -lXext" >&5
-$as_echo_n "checking for XScreenSaverQueryInfo in -lXext... " >&6; }
-if ${ac_cv_lib_Xext_XScreenSaverQueryInfo+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+if test "x$ac_cv_func_XScreenSaverQueryInfo" = xyes
+then :
+
+else $as_nop
+
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for XScreenSaverQueryInfo in -lXext" >&5
+printf %s "checking for XScreenSaverQueryInfo in -lXext... " >&6; }
+if test ${ac_cv_lib_Xext_XScreenSaverQueryInfo+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lXext  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
 char XScreenSaverQueryInfo ();
 int
-main ()
+main (void)
 {
 return XScreenSaverQueryInfo ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_Xext_XScreenSaverQueryInfo=yes
-else
+else $as_nop
   ac_cv_lib_Xext_XScreenSaverQueryInfo=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xext_XScreenSaverQueryInfo" >&5
-$as_echo "$ac_cv_lib_Xext_XScreenSaverQueryInfo" >&6; }
-if test "x$ac_cv_lib_Xext_XScreenSaverQueryInfo" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xext_XScreenSaverQueryInfo" >&5
+printf "%s\n" "$ac_cv_lib_Xext_XScreenSaverQueryInfo" >&6; }
+if test "x$ac_cv_lib_Xext_XScreenSaverQueryInfo" = xyes
+then :
 
 		XLIBSW="$XLIBSW -lXext"
 		xss_lib_found=yes
 
-else
+else $as_nop
 
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for XScreenSaverQueryInfo in -lXss" >&5
-$as_echo_n "checking for XScreenSaverQueryInfo in -lXss... " >&6; }
-if ${ac_cv_lib_Xss_XScreenSaverQueryInfo+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for XScreenSaverQueryInfo in -lXss" >&5
+printf %s "checking for XScreenSaverQueryInfo in -lXss... " >&6; }
+if test ${ac_cv_lib_Xss_XScreenSaverQueryInfo+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lXss -lXext $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
 char XScreenSaverQueryInfo ();
 int
-main ()
+main (void)
 {
 return XScreenSaverQueryInfo ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_lib_Xss_XScreenSaverQueryInfo=yes
-else
+else $as_nop
   ac_cv_lib_Xss_XScreenSaverQueryInfo=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xss_XScreenSaverQueryInfo" >&5
-$as_echo "$ac_cv_lib_Xss_XScreenSaverQueryInfo" >&6; }
-if test "x$ac_cv_lib_Xss_XScreenSaverQueryInfo" = xyes; then :
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xss_XScreenSaverQueryInfo" >&5
+printf "%s\n" "$ac_cv_lib_Xss_XScreenSaverQueryInfo" >&6; }
+if test "x$ac_cv_lib_Xss_XScreenSaverQueryInfo" = xyes
+then :
 
 		    if test "$tcl_cv_ld_weak_l" = yes; then
 			# On Darwin, weak link libXss if possible,
 			# as it is only available on Tiger or later.
 			XLIBSW="$XLIBSW -Wl,-weak-lXss -lXext"
@@ -7960,11 +8478,11 @@
 fi
 
     fi
     if test $enable_xss = yes -a $xss_lib_found = yes -a $xss_header_found = yes; then
 
-$as_echo "#define HAVE_XSS 1" >>confdefs.h
+printf "%s\n" "#define HAVE_XSS 1" >>confdefs.h
 
     fi
     CFLAGS=$tk_oldCFlags
     LIBS=$tk_oldLibs
 fi
@@ -7972,40 +8490,42 @@
 #--------------------------------------------------------------------
 #	Figure out whether "char" is unsigned.  If so, set a
 #	#define for __CHAR_UNSIGNED__.
 #--------------------------------------------------------------------
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether char is unsigned" >&5
-$as_echo_n "checking whether char is unsigned... " >&6; }
-if ${ac_cv_c_char_unsigned+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether char is unsigned" >&5
+printf %s "checking whether char is unsigned... " >&6; }
+if test ${ac_cv_c_char_unsigned+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $ac_includes_default
 int
-main ()
+main (void)
 {
 static int test_array [1 - 2 * !(((char) -1) < 0)];
 test_array [0] = 0;
 return test_array [0];
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_c_char_unsigned=no
-else
+else $as_nop
   ac_cv_c_char_unsigned=yes
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_char_unsigned" >&5
-$as_echo "$ac_cv_c_char_unsigned" >&6; }
-if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
-  $as_echo "#define __CHAR_UNSIGNED__ 1" >>confdefs.h
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_char_unsigned" >&5
+printf "%s\n" "$ac_cv_c_char_unsigned" >&6; }
+if test $ac_cv_c_char_unsigned = yes; then
+  printf "%s\n" "#define __CHAR_UNSIGNED__ 1" >>confdefs.h
 
 fi
 
 
 #--------------------------------------------------------------------
@@ -8013,11 +8533,17 @@
 #	building libtk as a shared library instead of a static library.
 #--------------------------------------------------------------------
 
 eval eval "TK_UNSHARED_LIB_SUFFIX=${UNSHARED_LIB_SUFFIX}"
 eval eval "TK_SHARED_LIB_SUFFIX=${SHARED_LIB_SUFFIX}"
+eval "TK_LIB_FILE_TCL8=libtk${LIB_SUFFIX}"
+if test ${TCL_MAJOR_VERSION} = 8 ; then
 eval "TK_LIB_FILE=libtk${LIB_SUFFIX}"
+else
+eval "TK_LIB_FILE=libtcl9tk${LIB_SUFFIX}"
+fi
+eval "TK_LIB_FILE_TCL9=libtcl9tk${LIB_SUFFIX}"
 
 # tkConfig.sh needs a version of the _LIB_SUFFIX that has been eval'ed
 # since on some platforms TK_LIB_FILE contains shell escapes.
 
 eval "TK_LIB_FILE=${TK_LIB_FILE}"
@@ -8040,42 +8566,43 @@
 # up the Tcl library.
 
 if test "`uname -s`" = "Darwin" ; then
 
     if test "`uname -s`" = "Darwin" ; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to package libraries" >&5
-$as_echo_n "checking how to package libraries... " >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to package libraries" >&5
+printf %s "checking how to package libraries... " >&6; }
 	# Check whether --enable-framework was given.
-if test "${enable_framework+set}" = set; then :
+if test ${enable_framework+y}
+then :
   enableval=$enable_framework; enable_framework=$enableval
-else
+else $as_nop
   enable_framework=no
 fi
 
 	if test $enable_framework = yes; then
 	    if test $SHARED_BUILD = 0; then
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Frameworks can only be built if --enable-shared is yes" >&5
-$as_echo "$as_me: WARNING: Frameworks can only be built if --enable-shared is yes" >&2;}
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Frameworks can only be built if --enable-shared is yes" >&5
+printf "%s\n" "$as_me: WARNING: Frameworks can only be built if --enable-shared is yes" >&2;}
 		enable_framework=no
 	    fi
 	    if test $tcl_corefoundation = no; then
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Frameworks can only be used when CoreFoundation is available" >&5
-$as_echo "$as_me: WARNING: Frameworks can only be used when CoreFoundation is available" >&2;}
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Frameworks can only be used when CoreFoundation is available" >&5
+printf "%s\n" "$as_me: WARNING: Frameworks can only be used when CoreFoundation is available" >&2;}
 		enable_framework=no
 	    fi
 	fi
 	if test $enable_framework = yes; then
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: framework" >&5
-$as_echo "framework" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: framework" >&5
+printf "%s\n" "framework" >&6; }
 	    FRAMEWORK_BUILD=1
 	else
 	    if test $SHARED_BUILD = 1; then
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: shared library" >&5
-$as_echo "shared library" >&6; }
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: shared library" >&5
+printf "%s\n" "shared library" >&6; }
 	    else
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: static library" >&5
-$as_echo "static library" >&6; }
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: static library" >&5
+printf "%s\n" "static library" >&6; }
 	    fi
 	    FRAMEWORK_BUILD=0
 	fi
     fi
 
@@ -8082,20 +8609,23 @@
     TK_SHLIB_LD_EXTRAS="-compatibility_version ${TK_VERSION} -current_version ${TK_VERSION}`echo ${TK_PATCH_LEVEL} | awk '{match($0, "\\\.[0-9]+"); print substr($0,RSTART,RLENGTH)}'`"
     TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -install_name "${DYLIB_INSTALL_DIR}/${TK_LIB_FILE}" -unexported_symbols_list $$(f=$(TK_LIB_FILE).E && nm -gp tkMacOSX*.o 2>/dev/null | awk "/^[0-9a-f]+ . \.objc/ {print \$$3}" > $$f && nm -gjp "$(TCL_BIN_DIR)"/$(TCL_STUB_LIB_FILE) | grep ^_[^_] >> $$f && echo $$f)'
     echo "$LDFLAGS " | grep -q -- '-prebind ' && TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -seg1addr 0xb000000'
     TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tk-Info.plist'
     EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist'
-    EXTRA_APP_CC_SWITCHES="${EXTRA_APP_CC_SWITCHES}"' -mdynamic-no-pic'
-    ac_config_files="$ac_config_files Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in"
+    EXTRA_WISH_LIBS=${EXTRA_WISH_LIBS}' -sectcreate __TEXT __credits_html Credits.html'
+    if test "${SHARED_BUILD}" = "0"; then
+	EXTRA_WISH_LIBS=${EXTRA_WISH_LIBS}' -ObjC'
+    fi
+    ac_config_files="$ac_config_files Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in Credits.html:../macosx/Credits.html.in"
 
     for l in ${LOCALES}; do CFBUNDLELOCALIZATIONS="${CFBUNDLELOCALIZATIONS}<string>$l</string>"; done
     TK_YEAR="`date +%Y`"
 fi
 
 if test "$FRAMEWORK_BUILD" = "1" ; then
 
-$as_echo "#define TK_FRAMEWORK 1" >>confdefs.h
+printf "%s\n" "#define TK_FRAMEWORK 1" >>confdefs.h
 
     # Construct a fake local framework structure to make linking with
     # '-framework Tk' and running of tktest work
     ac_config_commands="$ac_config_commands Tk.framework"
 
@@ -8102,11 +8632,17 @@
     LD_LIBRARY_PATH_VAR="DYLD_FRAMEWORK_PATH"
     if test "${libdir}" = '${exec_prefix}/lib'; then
         # override libdir default
         libdir="/Library/Frameworks"
     fi
-    TK_LIB_FILE="Tk"
+    if test ${TCL_MAJOR_VERSION} = 8 ; then
+	TK_LIB_FILE="Tk"
+    else
+	TK_LIB_FILE="Tk"
+    fi
+    TK_LIB_FILE_TCL8="Tk"
+    TK_LIB_FILE_TCL9="Tk"
     TK_LIB_FLAG="-framework Tk"
     TK_BUILD_LIB_SPEC="-F`pwd | sed -e 's/ /\\\\ /g'` -framework Tk"
     TK_LIB_SPEC="-F${libdir} -framework Tk"
     libdir="${libdir}/Tk.framework/Versions/\${VERSION}"
     TK_LIBRARY="${libdir}/Resources/Scripts"
@@ -8117,19 +8653,21 @@
     PRIVATE_INCLUDE_DIR="${libdir}/PrivateHeaders"
     HTML_DIR="${libdir}/Resources/Documentation/Reference/Tk"
     EXTRA_INSTALL="install-private-headers html-tk"
     EXTRA_BUILD_HTML='@ln -fs contents.htm "$(HTML_INSTALL_DIR)"/TkTOC.html'
     EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"'
+    EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Credits.html "$(LIB_INSTALL_DIR)/Resources"'
     EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"'
     if test $tk_aqua = yes; then
 	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Images to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)/Resources"; done'
 	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing wish$(VERSION) script to $(INSTALL_ROOT)/'"${bindir}"'/" && $(INSTALL_DATA_DIR) "$(INSTALL_ROOT)/'"${bindir}"'" && printf > "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)" "#!/bin/sh\n\"\$$(dirname \$$0)'"`eval d="${bindir}"; echo "$d" | sed -e 's#/[^/][^/]*#/..#g'`"'$(bindir)/Wish\" \"\$$@\"" && chmod +x "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)"'
 	bindir="${libdir}/Resources/Wish.app/Contents/MacOS"
 	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Info.plist to $(BIN_INSTALL_DIR)/.." && $(INSTALL_DATA) Wish-Info.plist "$(BIN_INSTALL_DIR)/../Info.plist" && mv -f "$(BIN_INSTALL_DIR)/wish$(VERSION)" "$(BIN_INSTALL_DIR)/Wish"'
 	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA_DIR) "$(BIN_INSTALL_DIR)/../Resources"'
 	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Tk.icns" "$(BIN_INSTALL_DIR)/../Resources/Wish.icns"'
 	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.sdef to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.sdef" "$(BIN_INSTALL_DIR)/../Resources"'
+	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) Credits.html "$(BIN_INSTALL_DIR)/../Resources"'
     fi
     EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Finalizing Tk.framework" && rm -f "$(LIB_INSTALL_DIR)/../Current" && ln -s "$(VERSION)" "$(LIB_INSTALL_DIR)/../Current" && for f in "$(LIB_FILE)" tkConfig.sh Resources Headers PrivateHeaders; do rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/Current/$$f" "$(LIB_INSTALL_DIR)/../.."; done && f="$(STUB_LIB_FILE)" && rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/$(VERSION)/$$f" "$(LIB_INSTALL_DIR)/../.."'
     # Don't use AC_DEFINE for the following as the framework version define
     # needs to go into the Makefile even when using autoheader, so that we
     # can pick up a potential make override of VERSION. Also, don't put this
@@ -8139,23 +8677,227 @@
     if test $tk_aqua = yes; then
         EXTRA_INSTALL_BINARIES='@echo "Installing Images to $(LIB_INSTALL_DIR)/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)"; done'
     fi
     # libdir must be a fully qualified path and not ${exec_prefix}/lib
     eval libdir="$libdir"
+    TK_LIB_FLAG="-l"
+    if test "${TCL_MAJOR_VERSION}" -gt 8 ; then
+	TK_LIB_FLAG="${TK_LIB_FLAG}tcl9"
+    fi
     if test "${ac_cv_cygwin}" = "yes" -a "$SHARED_BUILD" = "1"; then
-	TK_LIB_FLAG="-ltk`echo ${TK_VERSION} | tr -d .`"
+	TK_LIB_FLAG="${TK_LIB_FLAG}tk`echo ${TK_VERSION} | tr -d .`"
 	TK_BUILD_LIB_SPEC="-L\$(TOP_DIR)/win ${TK_LIB_FLAG}"
     else
 	if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
-	    TK_LIB_FLAG="-ltk${TK_VERSION}"
+	    TK_LIB_FLAG="${TK_LIB_FLAG}tk${TK_VERSION}"
 	else
-	    TK_LIB_FLAG="-ltk`echo ${TK_VERSION} | tr -d .`"
+	    TK_LIB_FLAG="${TK_LIB_FLAG}tk`echo ${TK_VERSION} | tr -d .`"
 	fi
 	TK_BUILD_LIB_SPEC="-L`pwd | sed -e 's/ /\\\\ /g'` ${TK_LIB_FLAG}"
     fi
     TK_LIB_SPEC="-L${libdir} ${TK_LIB_FLAG}"
 fi
+
+#--------------------------------------------------------------------
+#	Zipfs support - Tip 430
+#--------------------------------------------------------------------
+# Check whether --enable-zipfs was given.
+if test ${enable_zipfs+y}
+then :
+  enableval=$enable_zipfs; tcl_ok=$enableval
+else $as_nop
+  tcl_ok=yes
+fi
+
+if test "$tcl_ok" = "yes" -a "x$enable_framework" != "xyes"; then
+    #
+    # Find a native compiler
+    #
+    # Put a plausible default for CC_FOR_BUILD in Makefile.
+    if test -z "$CC_FOR_BUILD"; then
+      if test "x$cross_compiling" = "xno"; then
+        CC_FOR_BUILD='$(CC)'
+      else
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gcc" >&5
+printf %s "checking for gcc... " >&6; }
+        if test ${ac_cv_path_cc+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+            search_path=`echo ${PATH} | sed -e 's/:/ /g'`
+            for dir in $search_path ; do
+                for j in `ls -r $dir/gcc 2> /dev/null` \
+                        `ls -r $dir/gcc 2> /dev/null` ; do
+                    if test x"$ac_cv_path_cc" = x ; then
+                        if test -f "$j" ; then
+                            ac_cv_path_cc=$j
+                            break
+                        fi
+                    fi
+                done
+            done
+
+fi
+
+      fi
+    fi
+
+    # Also set EXEEXT_FOR_BUILD.
+    if test "x$cross_compiling" = "xno"; then
+      EXEEXT_FOR_BUILD='$(EXEEXT)'
+      OBJEXT_FOR_BUILD='$(OBJEXT)'
+    else
+      OBJEXT_FOR_BUILD='.no'
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for build system executable suffix" >&5
+printf %s "checking for build system executable suffix... " >&6; }
+if test ${bfd_cv_build_exeext+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  rm -f conftest*
+         echo 'int main () { return 0; }' > conftest.c
+         bfd_cv_build_exeext=
+         ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5
+         for file in conftest.*; do
+           case $file in
+           *.c | *.o | *.obj | *.ilk | *.pdb) ;;
+           *) bfd_cv_build_exeext=`echo $file | sed -e s/conftest//` ;;
+           esac
+         done
+         rm -f conftest*
+         test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_build_exeext" >&5
+printf "%s\n" "$bfd_cv_build_exeext" >&6; }
+      EXEEXT_FOR_BUILD=""
+      test x"${bfd_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${bfd_cv_build_exeext}
+    fi
+
+    #
+    # Find a native zip implementation
+    #
+
+    MACHER_PROG=""
+    ZIP_PROG=""
+    ZIP_PROG_OPTIONS=""
+    ZIP_PROG_VFSSEARCH=""
+    ZIP_INSTALL_OBJS=""
+
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for macher" >&5
+printf %s "checking for macher... " >&6; }
+    if test ${ac_cv_path_macher+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+    search_path=`echo ${PATH} | sed -e 's/:/ /g'`
+    for dir in $search_path ; do
+        for j in `ls -r $dir/macher 2> /dev/null` \
+            `ls -r $dir/macher 2> /dev/null` ; do
+        if test x"$ac_cv_path_macher" = x ; then
+            if test -f "$j" ; then
+            ac_cv_path_macher=$j
+            break
+            fi
+        fi
+        done
+    done
+
+fi
+
+    if test -f "$ac_cv_path_macher" ; then
+        MACHER_PROG="$ac_cv_path_macher"
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MACHER_PROG" >&5
+printf "%s\n" "$MACHER_PROG" >&6; }
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Found macher in environment" >&5
+printf "%s\n" "Found macher in environment" >&6; }
+    fi
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zip" >&5
+printf %s "checking for zip... " >&6; }
+    if test ${ac_cv_path_zip+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+    search_path=`echo ${PATH} | sed -e 's/:/ /g'`
+    for dir in $search_path ; do
+        for j in `ls -r $dir/zip 2> /dev/null` \
+            `ls -r $dir/zip 2> /dev/null` ; do
+        if test x"$ac_cv_path_zip" = x ; then
+            if test -f "$j" ; then
+            ac_cv_path_zip=$j
+            break
+            fi
+        fi
+        done
+    done
+
+fi
+
+    if test -f "$ac_cv_path_zip" ; then
+        ZIP_PROG="$ac_cv_path_zip"
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ZIP_PROG" >&5
+printf "%s\n" "$ZIP_PROG" >&6; }
+        ZIP_PROG_OPTIONS="-rq"
+        ZIP_PROG_VFSSEARCH="*"
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Found INFO Zip in environment" >&5
+printf "%s\n" "Found INFO Zip in environment" >&6; }
+        # Use standard arguments for zip
+    else
+        # It is not an error if an installed version of Zip can't be located.
+        # We can use the locally distributed minizip instead
+        ZIP_PROG="./minizip${EXEEXT_FOR_BUILD}"
+        ZIP_PROG_OPTIONS="-o -r"
+        ZIP_PROG_VFSSEARCH="*"
+        ZIP_INSTALL_OBJS="minizip${EXEEXT_FOR_BUILD}"
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: No zip found on PATH. Building minizip" >&5
+printf "%s\n" "No zip found on PATH. Building minizip" >&6; }
+    fi
+
+
+
+
+
+
+	ZIPFS_BUILD=1
+	TK_ZIP_FILE=libtk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${TK_PATCH_LEVEL}.zip
+else
+	ZIPFS_BUILD=0
+	TK_ZIP_FILE=
+fi
+# Do checking message here to not mess up interleaved configure output
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for building with zipfs" >&5
+printf %s "checking for building with zipfs... " >&6; }
+if test "${ZIPFS_BUILD}" = 1; then
+    if test "${SHARED_BUILD}" = 0; then
+       ZIPFS_BUILD=2;
+
+printf "%s\n" "#define ZIPFS_BUILD 2" >>confdefs.h
+
+       INSTALL_LIBRARIES=install-demos
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+     else
+
+printf "%s\n" "#define ZIPFS_BUILD 1" >>confdefs.h
+\
+       INSTALL_LIBRARIES=install-demos
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+    fi
+else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+INSTALL_LIBRARIES=install-libraries
+INSTALL_MSGS=install-msgs
+fi
+
+
+
+
+
 
 #--------------------------------------------------------------------
 #       The statements below define various symbols relating to Tk
 #       stub support.
 #--------------------------------------------------------------------
@@ -8180,11 +8922,12 @@
 
 #------------------------------------------------------------------------
 # Demo dir
 #------------------------------------------------------------------------
 
-if test x"${DEMO_DIR}" = x; then :
+if test x"${DEMO_DIR}" = x
+then :
   DEMO_DIR='$(TK_LIBRARY)/demos'
 fi
 eval "TK_DEMO_DIR=\"`echo ${DEMO_DIR} | tr '()' '{}'`\""
 eval "TK_DEMO_DIR=\"`echo ${TK_DEMO_DIR} | tr '()' '{}'`\""
 
@@ -8193,10 +8936,12 @@
 #------------------------------------------------------------------------
 # tkConfig.sh refers to this by a different name
 #------------------------------------------------------------------------
 
 TK_SHARED_BUILD=${SHARED_BUILD}
+
+
 
 
 
 
 
@@ -8274,12 +9019,12 @@
   for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
     eval ac_val=\$$ac_var
     case $ac_val in #(
     *${as_nl}*)
       case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
       BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
       *) { eval $ac_var=; unset $ac_var;} ;;
@@ -8305,19 +9050,19 @@
 ) |
   sed '
      /^ac_cv_env_/b end
      t clear
      :clear
-     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/
      t end
      s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
      :end' >>confcache
 if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
   if test -w "$cache_file"; then
     if test "x$cache_file" != "x/dev/null"; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
-$as_echo "$as_me: updating cache $cache_file" >&6;}
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+printf "%s\n" "$as_me: updating cache $cache_file" >&6;}
       if test ! -f "$cache_file" || test -h "$cache_file"; then
 	cat confcache >"$cache_file"
       else
         case $cache_file in #(
         */* | ?:*)
@@ -8327,12 +9072,12 @@
 	  mv -f confcache "$cache_file" ;;
 	esac
       fi
     fi
   else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
-$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;}
   fi
 fi
 rm -f confcache
 
 test "x$prefix" = xNONE && prefix=$ac_default_prefix
@@ -8381,11 +9126,11 @@
 ac_ltlibobjs=
 U=
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
   # 1. Remove the extension, and $U if already installed.
   ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
-  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+  ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"`
   # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
   #    will be set to the directory where LIBOBJS objects are built.
   as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
   as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
 done
@@ -8399,12 +9144,12 @@
 
 : "${CONFIG_STATUS=./config.status}"
 ac_write_fail=0
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
-$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;}
 as_write_fail=0
 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
 #! $SHELL
 # Generated by $as_me.
 # Run this file to recreate the current configuration.
@@ -8423,92 +9168,91 @@
 ## M4sh Initialization. ##
 ## -------------------- ##
 
 # Be more Bourne compatible
 DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+as_nop=:
+if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1
+then :
   emulate sh
   NULLCMD=:
   # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
-else
+else $as_nop
   case `(set -o) 2>/dev/null` in #(
   *posix*) :
     set -o posix ;; #(
   *) :
      ;;
 esac
 fi
 
 
+
+# Reset variables that may have inherited troublesome values from
+# the environment.
+
+# IFS needs to be set, to space, tab, and newline, in precisely that order.
+# (If _AS_PATH_WALK were called with IFS unset, it would have the
+# side effect of setting IFS to empty, thus disabling word splitting.)
+# Quoting is to prevent editors from complaining about space-tab.
 as_nl='
 '
 export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='printf %s\n'
-  as_echo_n='printf %s'
-else
-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
-    as_echo_n='/usr/ucb/echo -n'
-  else
-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-    as_echo_n_body='eval
-      arg=$1;
-      case $arg in #(
-      *"$as_nl"*)
-	expr "X$arg" : "X\\(.*\\)$as_nl";
-	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-      esac;
-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-    '
-    export as_echo_n_body
-    as_echo_n='sh -c $as_echo_n_body as_echo'
-  fi
-  export as_echo_body
-  as_echo='sh -c $as_echo_body as_echo'
-fi
+IFS=" ""	$as_nl"
+
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# Ensure predictable behavior from utilities with locale-dependent output.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# We cannot yet rely on "unset" to work, but we need these variables
+# to be unset--not just set to an empty or harmless value--now, to
+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh).  This construct
+# also avoids known problems related to "unset" and subshell syntax
+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).
+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH
+do eval test \${$as_var+y} \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+
+# Ensure that fds 0, 1, and 2 are open.
+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi
+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi
+if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi
 
 # The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
+if ${PATH_SEPARATOR+false} :; then
   PATH_SEPARATOR=:
   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
       PATH_SEPARATOR=';'
   }
 fi
 
 
-# IFS
-# We need space, tab and new line, in precisely that order.  Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" ""	$as_nl"
-
 # Find who we are.  Look in the path if we contain no directory separator.
 as_myself=
 case $0 in #((
   *[\\/]* ) as_myself=$0 ;;
   *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    test -r "$as_dir$0" && as_myself=$as_dir$0 && break
   done
 IFS=$as_save_IFS
 
      ;;
 esac
@@ -8516,34 +9260,14 @@
 # in which case we are not to be found in the path.
 if test "x$as_myself" = x; then
   as_myself=$0
 fi
 if test ! -f "$as_myself"; then
-  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
   exit 1
 fi
 
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
 
 # as_fn_error STATUS ERROR [LINENO LOG_FD]
 # ----------------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
@@ -8552,15 +9276,16 @@
 as_fn_error ()
 {
   as_status=$1; test $as_status -eq 0 && as_status=1
   if test "$4"; then
     as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
   fi
-  $as_echo "$as_me: error: $2" >&2
+  printf "%s\n" "$as_me: error: $2" >&2
   as_fn_exit $as_status
 } # as_fn_error
+
 
 
 # as_fn_set_status STATUS
 # -----------------------
 # Set $? to STATUS, without forking.
@@ -8585,22 +9310,24 @@
 as_fn_unset ()
 {
   { eval $1=; unset $1;}
 }
 as_unset=as_fn_unset
+
 # as_fn_append VAR VALUE
 # ----------------------
 # Append the text in VALUE to the end of the definition contained in VAR. Take
 # advantage of any shell optimizations that allow amortized linear growth over
 # repeated appends, instead of the typical quadratic growth present in naive
 # implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null
+then :
   eval 'as_fn_append ()
   {
     eval $1+=\$2
   }'
-else
+else $as_nop
   as_fn_append ()
   {
     eval $1=\$$1\$2
   }
 fi # as_fn_append
@@ -8608,16 +9335,17 @@
 # as_fn_arith ARG...
 # ------------------
 # Perform arithmetic evaluation on the ARGs, and store the result in the
 # global $as_val. Take advantage of shells that can avoid forks. The arguments
 # must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null
+then :
   eval 'as_fn_arith ()
   {
     as_val=$(( $* ))
   }'
-else
+else $as_nop
   as_fn_arith ()
   {
     as_val=`expr "$@" || test $? -eq 1`
   }
 fi # as_fn_arith
@@ -8644,11 +9372,11 @@
 
 as_me=`$as_basename -- "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
 	 X"$0" : 'X\(//\)$' \| \
 	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
+printf "%s\n" X/"$0" |
     sed '/^.*\/\([^/][^/]*\)\/*$/{
 	    s//\1/
 	    q
 	  }
 	  /^X\/\(\/\/\)$/{
@@ -8666,10 +9394,14 @@
 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
 as_cr_digits='0123456789'
 as_cr_alnum=$as_cr_Letters$as_cr_digits
 
+
+# Determine whether it's possible to make 'echo' print without a newline.
+# These variables are no longer used directly by Autoconf, but are AC_SUBSTed
+# for compatibility with existing Makefiles.
 ECHO_C= ECHO_N= ECHO_T=
 case `echo -n x` in #(((((
 -n*)
   case `echo 'xy\c'` in
   *c*) ECHO_T='	';;	# ECHO_T is single tab character.
@@ -8678,10 +9410,16 @@
        ECHO_T='	';;
   esac;;
 *)
   ECHO_N='-n';;
 esac
+
+# For backward compatibility with old third-party macros, we provide
+# the shell variables $as_echo and $as_echo_n.  New code should use
+# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively.
+as_echo='printf %s\n'
+as_echo_n='printf %s'
 
 rm -f conf$$ conf$$.exe conf$$.file
 if test -d conf$$.dir; then
   rm -f conf$$.dir/conf$$.file
 else
@@ -8720,20 +9458,20 @@
   esac
   test -d "$as_dir" || eval $as_mkdir_p || {
     as_dirs=
     while :; do
       case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
       *) as_qdir=$as_dir;;
       esac
       as_dirs="'$as_qdir' $as_dirs"
       as_dir=`$as_dirname -- "$as_dir" ||
 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$as_dir" : 'X\(//\)[^/]' \| \
 	 X"$as_dir" : 'X\(//\)$' \| \
 	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
+printf "%s\n" X"$as_dir" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
 	    s//\1/
 	    q
 	  }
 	  /^X\(\/\/\)[^/].*/{
@@ -8792,11 +9530,11 @@
 # Save the log message, to keep $0 and so on meaningful, and to
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
 This file was extended by tk $as_me 8.7, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
   CONFIG_LINKS    = $CONFIG_LINKS
   CONFIG_COMMANDS = $CONFIG_COMMANDS
@@ -8845,18 +9583,20 @@
 $config_commands
 
 Report bugs to the package provider."
 
 _ACEOF
+ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"`
+ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"`
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
 tk config.status 8.7
-configured by $0, generated by GNU Autoconf 2.69,
+configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 2021 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
 ac_pwd='$ac_pwd'
 srcdir='$srcdir'
@@ -8889,25 +9629,25 @@
   case $ac_option in
   # Handling of the options.
   -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
     ac_cs_recheck=: ;;
   --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
-    $as_echo "$ac_cs_version"; exit ;;
+    printf "%s\n" "$ac_cs_version"; exit ;;
   --config | --confi | --conf | --con | --co | --c )
-    $as_echo "$ac_cs_config"; exit ;;
+    printf "%s\n" "$ac_cs_config"; exit ;;
   --debug | --debu | --deb | --de | --d | -d )
     debug=: ;;
   --file | --fil | --fi | --f )
     $ac_shift
     case $ac_optarg in
-    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
     '') as_fn_error $? "missing file argument" ;;
     esac
     as_fn_append CONFIG_FILES " '$ac_optarg'"
     ac_need_defaults=false;;
   --he | --h |  --help | --hel | -h )
-    $as_echo "$ac_cs_usage"; exit ;;
+    printf "%s\n" "$ac_cs_usage"; exit ;;
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
   | -silent | --silent | --silen | --sile | --sil | --si | --s)
     ac_cs_silent=: ;;
 
   # This is an error.
@@ -8931,11 +9671,11 @@
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 if \$ac_cs_recheck; then
   set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
   shift
-  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+  \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6
   CONFIG_SHELL='$SHELL'
   export CONFIG_SHELL
   exec "\$@"
 fi
 
@@ -8945,11 +9685,11 @@
 {
   echo
   sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
 ## Running $as_me. ##
 _ASBOX
-  $as_echo "$ac_log"
+  printf "%s\n" "$ac_log"
 } >&5
 
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 #
@@ -8965,10 +9705,11 @@
 for ac_config_target in $ac_config_targets
 do
   case $ac_config_target in
     "Tk-Info.plist") CONFIG_FILES="$CONFIG_FILES Tk-Info.plist:../macosx/Tk-Info.plist.in" ;;
     "Wish-Info.plist") CONFIG_FILES="$CONFIG_FILES Wish-Info.plist:../macosx/Wish-Info.plist.in" ;;
+    "Credits.html") CONFIG_FILES="$CONFIG_FILES Credits.html:../macosx/Credits.html.in" ;;
     "Tk.framework") CONFIG_COMMANDS="$CONFIG_COMMANDS Tk.framework" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile:../unix/Makefile.in" ;;
     "tkConfig.sh") CONFIG_FILES="$CONFIG_FILES tkConfig.sh:../unix/tkConfig.sh.in" ;;
     "tk.pc") CONFIG_FILES="$CONFIG_FILES tk.pc:../unix/tk.pc.in" ;;
 
@@ -8980,12 +9721,12 @@
 # If the user did not use the arguments to specify the items to instantiate,
 # then the envvar interface is used.  Set only those that are not.
 # We use the long form for the default assignment because of an extremely
 # bizarre bug on SunOS 4.1.3.
 if $ac_need_defaults; then
-  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
-  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+  test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files
+  test ${CONFIG_COMMANDS+y} || CONFIG_COMMANDS=$config_commands
 fi
 
 # Have a temporary directory for convenience.  Make it in the build tree
 # simply because there is no reason against having it here, and in addition,
 # creating and moving files from /tmp can sometimes cause problems.
@@ -9209,29 +9950,29 @@
 	   [\\/$]*) false;;
 	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
 	   esac ||
 	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
       esac
-      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
       as_fn_append ac_file_inputs " '$ac_f'"
     done
 
     # Let's still pretend it is `configure' which instantiates (i.e., don't
     # use $as_me), people would be surprised to read:
     #    /* config.h.  Generated by config.status.  */
     configure_input='Generated from '`
-	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+	  printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
 	`' by configure.'
     if test x"$ac_file" != x-; then
       configure_input="$ac_file.  $configure_input"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
-$as_echo "$as_me: creating $ac_file" >&6;}
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+printf "%s\n" "$as_me: creating $ac_file" >&6;}
     fi
     # Neutralize special characters interpreted by sed in replacement strings.
     case $configure_input in #(
     *\&* | *\|* | *\\* )
-       ac_sed_conf_input=`$as_echo "$configure_input" |
+       ac_sed_conf_input=`printf "%s\n" "$configure_input" |
        sed 's/[\\\\&|]/\\\\&/g'`;; #(
     *) ac_sed_conf_input=$configure_input;;
     esac
 
     case $ac_tag in
@@ -9244,11 +9985,11 @@
   ac_dir=`$as_dirname -- "$ac_file" ||
 $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$ac_file" : 'X\(//\)[^/]' \| \
 	 X"$ac_file" : 'X\(//\)$' \| \
 	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$ac_file" |
+printf "%s\n" X"$ac_file" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
 	    s//\1/
 	    q
 	  }
 	  /^X\(\/\/\)[^/].*/{
@@ -9268,13 +10009,13 @@
   ac_builddir=.
 
 case "$ac_dir" in
 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
 *)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'`
   # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
   case $ac_top_builddir_sub in
   "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
   *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
   esac ;;
 esac
@@ -9323,12 +10064,12 @@
 /@localedir@/p
 /@mandir@/p'
 case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
 *datarootdir*) ac_datarootdir_seen=yes;;
 *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
-$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
   ac_datarootdir_hack='
   s&@datadir@&$datadir&g
   s&@docdir@&$docdir&g
@@ -9366,13 +10107,13 @@
 
 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
   { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
   { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
       "$ac_tmp/out"`; test -z "$ac_out"; } &&
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
 which seems to be undefined.  Please make sure it is defined" >&5
-$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
 which seems to be undefined.  Please make sure it is defined" >&2;}
 
   rm -f "$ac_tmp/stdin"
   case $ac_file in
   -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
@@ -9380,12 +10121,12 @@
   esac \
   || as_fn_error $? "could not create $ac_file" "$LINENO" 5
  ;;
 
 
-  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
-$as_echo "$as_me: executing $ac_file commands" >&6;}
+  :C)  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+printf "%s\n" "$as_me: executing $ac_file commands" >&6;}
  ;;
   esac
 
 
   case $ac_file$ac_mode in
@@ -9429,10 +10170,11 @@
   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
   # would make configure fail if this is the last instruction.
   $ac_cs_success || as_fn_exit 1
 fi
 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
-$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
 fi
+
 
 

Index: unix/configure.ac
==================================================================
--- unix/configure.ac
+++ unix/configure.ac
@@ -1,12 +1,12 @@
-#! /bin/bash -norc
+! /bin/bash -norc
 dnl	This file is an input file used by the GNU "autoconf" program to
 dnl	generate the file "configure", which is run during Tk installation
 dnl	to configure the system for the local environment.
 
 AC_INIT([tk],[8.7])
-AC_PREREQ(2.69)
+AC_PREREQ([2.69])
 
 dnl This is only used when included from macosx/configure.ac
 m4_ifdef([SC_USE_CONFIG_HEADERS], [
     AC_CONFIG_HEADERS([tkConfig.h:../unix/tkConfig.h.in])
     AC_CONFIG_COMMANDS_PRE([DEFS="-DHAVE_TK_CONFIG_H  -imacros tkConfig.h"])
@@ -15,19 +15,20 @@
     #define _TKCONFIG])
     AH_BOTTOM([
     /* Undef unused package specific autoheader defines so that we can
      * include both tclConfig.h and tkConfig.h at the same time: */
     /* override */ #undef PACKAGE_NAME
-    /* override */ #undef PACKAGE_STRING
     /* override */ #undef PACKAGE_TARNAME
+    /* override */ #undef PACKAGE_VERSION
+    /* override */ #undef PACKAGE_STRING
     #endif /* _TKCONFIG */])
 ])
 
 TK_VERSION=8.7
 TK_MAJOR_VERSION=8
 TK_MINOR_VERSION=7
-TK_PATCH_LEVEL="a4"
+TK_PATCH_LEVEL="a6"
 VERSION=${TK_VERSION}
 LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv"
 
 #--------------------------------------------------------------------
 # Find and load the tclConfig.sh file
@@ -90,11 +91,11 @@
 
 if test -z "$no_pipe" && test -n "$GCC"; then
     AC_CACHE_CHECK([if the compiler understands -pipe],
 	tcl_cv_cc_pipe, [
 	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -pipe"
-	AC_TRY_COMPILE(,, tcl_cv_cc_pipe=yes, tcl_cv_cc_pipe=no)
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[tcl_cv_cc_pipe=yes],[tcl_cv_cc_pipe=no])
 	CFLAGS=$hold_cflags])
     if test $tcl_cv_cc_pipe = yes; then
 	CFLAGS="$CFLAGS -pipe"
     fi
 fi
@@ -143,11 +144,11 @@
 fi
 
 if test "$TCL_PREFIX" != "$prefix"; then
     AC_MSG_WARN([
         Different --prefix selected for Tk and Tcl!
-        [[package require Tk]] may not work correctly in tclsh.])
+        [[package require tk]] may not work correctly in tclsh.])
 fi
 
 #--------------------------------------------------------------------
 #	Include sys/select.h if it exists and if it supplies things
 #	that appear to be useful and aren't already in sys/types.h.
@@ -157,12 +158,11 @@
 #	pernicious.  If "fd_set" isn't defined anywhere then set a
 #	special flag.
 #--------------------------------------------------------------------
 
 AC_CACHE_CHECK([for fd_set in sys/types], tcl_cv_type_fd_set, [
-    AC_TRY_COMPILE([#include <sys/types.h>],[fd_set readMask, writeMask;],
-	tcl_cv_type_fd_set=yes, tcl_cv_type_fd_set=no)])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]], [[fd_set readMask, writeMask;]])],[tcl_cv_type_fd_set=yes],[tcl_cv_type_fd_set=no])])
 tk_ok=$tcl_cv_type_fd_set
 if test $tk_ok = no; then
     AC_CACHE_CHECK([for fd_mask in sys/select], tcl_cv_grep_fd_mask, [
 	AC_EGREP_HEADER(fd_mask, sys/select.h,
 	     tcl_cv_grep_fd_mask=present, tcl_cv_grep_fd_mask=missing)])
@@ -177,63 +177,31 @@
 
 #------------------------------------------------------------------------------
 #       Find out all about time handling differences.
 #------------------------------------------------------------------------------
 
-AC_CHECK_HEADERS(sys/time.h)
-AC_HEADER_TIME
+AC_CHECK_HEADERS_ONCE([sys/time.h])
 
 #--------------------------------------------------------------------
 #	Check for various typedefs and provide substitutes if
 #	they don't exist.
 #--------------------------------------------------------------------
 
 AC_TYPE_MODE_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
-AC_TYPE_UID_T
-
-AC_CHECK_TYPE([intptr_t], [
-    AC_DEFINE([HAVE_INTPTR_T], 1, [Do we have the intptr_t type?])], [
-    AC_CACHE_CHECK([for pointer-size signed integer type], tcl_cv_intptr_t, [
-    for tcl_cv_intptr_t in "int" "long" "long long" none; do
-	if test "$tcl_cv_intptr_t" != none; then
-	    AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT],
-		    [[sizeof (void *) <= sizeof ($tcl_cv_intptr_t)]])],
-		[tcl_ok=yes], [tcl_ok=no])
-	    test "$tcl_ok" = yes && break; fi
-    done])
-    if test "$tcl_cv_intptr_t" != none; then
-	AC_DEFINE_UNQUOTED([intptr_t], [$tcl_cv_intptr_t], [Signed integer
-	   type wide enough to hold a pointer.])
-    fi
-])
-AC_CHECK_TYPE([uintptr_t], [
-    AC_DEFINE([HAVE_UINTPTR_T], 1, [Do we have the uintptr_t type?])], [
-    AC_CACHE_CHECK([for pointer-size unsigned integer type], tcl_cv_uintptr_t, [
-    for tcl_cv_uintptr_t in "unsigned int" "unsigned long" "unsigned long long" \
-	    none; do
-	if test "$tcl_cv_uintptr_t" != none; then
-	    AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT],
-		    [[sizeof (void *) <= sizeof ($tcl_cv_uintptr_t)]])],
-		[tcl_ok=yes], [tcl_ok=no])
-	    test "$tcl_ok" = yes && break; fi
-    done])
-    if test "$tcl_cv_uintptr_t" != none; then
-	AC_DEFINE_UNQUOTED([uintptr_t], [$tcl_cv_uintptr_t], [Unsigned integer
-	   type wide enough to hold a pointer.])
-    fi
-])
+
+AC_CHECK_TYPES([intptr_t, uintptr_t],,,[[
+#include <stdint.h>
+]])
 
 #-------------------------------------------
 #     In OS/390 struct pwd has no pw_gecos field
 #-------------------------------------------
 
 AC_CACHE_CHECK([pw_gecos in struct pwd], tcl_cv_pwd_pw_gecos, [
-    AC_TRY_COMPILE([#include <pwd.h>],
-	    [struct passwd pwd; (void)pwd.pw_gecos;],
-	    tcl_cv_pwd_pw_gecos=yes, tcl_cv_pwd_pw_gecos=no)])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pwd.h>]], [[struct passwd pwd; (void)pwd.pw_gecos;]])],[tcl_cv_pwd_pw_gecos=yes],[tcl_cv_pwd_pw_gecos=no])])
 if test $tcl_cv_pwd_pw_gecos = yes; then
     AC_DEFINE(HAVE_PW_GECOS, 1, [Does struct password have a pw_gecos field?])
 fi
 
 #--------------------------------------------------------------------
@@ -241,11 +209,11 @@
 #--------------------------------------------------------------------
 
 if test "`uname -s`" = "Darwin" ; then
     AC_MSG_CHECKING([whether to use Aqua])
     AC_ARG_ENABLE(aqua,
-	AC_HELP_STRING([--enable-aqua=yes|no],
+	AS_HELP_STRING([--enable-aqua=yes|no],
 	    [use Aqua windowingsystem on Mac OS X (default: no)]),
 	[tk_aqua=$enableval], [tk_aqua=no])
     if test $tk_aqua = yes -o $tk_aqua = cocoa; then
 	tk_aqua=yes
 	if test $tcl_corefoundation = no; then
@@ -260,75 +228,52 @@
 	    AC_MSG_WARN([Aqua requires Mac OS X 10.5 or later])
 	    tk_aqua=no
 	fi
     fi
     AC_MSG_RESULT([$tk_aqua])
-    if test "$fat_32_64" = yes; then
-	if test $tk_aqua = no; then
-	    AC_CACHE_CHECK([for 64-bit X11], tcl_cv_lib_x11_64, [
-		for v in CFLAGS CPPFLAGS LDFLAGS; do
-		    eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"'
-		done
-		CPPFLAGS="$CPPFLAGS -I/usr/X11R6/include"
-		LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
-		AC_TRY_LINK([#include <X11/Xlib.h>], [XrmInitialize();],
-		    tcl_cv_lib_x11_64=yes, tcl_cv_lib_x11_64=no)
-		for v in CFLAGS CPPFLAGS LDFLAGS; do
-		    eval $v'="$hold_'$v'"'
-		done])
-	fi
-	# remove 64-bit arch flags from CFLAGS et al. for combined 32 & 64 bit
-	# fat builds if configuration does not support 64-bit.
-	if test "$tcl_cv_lib_x11_64" = no; then
-	    AC_MSG_NOTICE([Removing 64-bit architectures from compiler & linker flags])
-	    for v in CFLAGS CPPFLAGS LDFLAGS; do
-		eval $v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"'
-	    done
-	fi
-    fi
     if test $tk_aqua = no; then
 	# check if weak linking whole libraries is possible.
 	AC_CACHE_CHECK([if ld accepts -weak-l flag], tcl_cv_ld_weak_l, [
 	    hold_ldflags=$LDFLAGS
 	    LDFLAGS="$LDFLAGS -Wl,-weak-lm"
-	    AC_TRY_LINK([#include <math.h>], [double f = sin(1.0);],
-		tcl_cv_ld_weak_l=yes, tcl_cv_ld_weak_l=no)
+	    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[double f = sin(1.0);]])],
+	    [tcl_cv_ld_weak_l=yes],[tcl_cv_ld_weak_l=no])
 	    LDFLAGS=$hold_ldflags])
     fi
     AC_CHECK_HEADERS(AvailabilityMacros.h)
     if test "$ac_cv_header_AvailabilityMacros_h" = yes; then
 	AC_CACHE_CHECK([if weak import is available], tcl_cv_cc_weak_import, [
 	    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
-	    AC_TRY_LINK([
+	    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 		    #ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
 		    #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1020
 		    #error __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1020
 		    #endif
 		    #elif MAC_OS_X_VERSION_MIN_REQUIRED < 1020
 		    #error MAC_OS_X_VERSION_MIN_REQUIRED < 1020
 		    #endif
 		    int rand(void) __attribute__((weak_import));
-		], [rand();],
-		tcl_cv_cc_weak_import=yes, tcl_cv_cc_weak_import=no)
+		]], [[rand();]])],
+		[tcl_cv_cc_weak_import=yes],[tcl_cv_cc_weak_import=no])
 	    CFLAGS=$hold_cflags])
 	if test $tcl_cv_cc_weak_import = yes; then
 	    AC_DEFINE(HAVE_WEAK_IMPORT, 1, [Is weak import available?])
 	fi
 	AC_CACHE_CHECK([if Darwin SUSv3 extensions are available],
 	    tcl_cv_cc_darwin_c_source, [
 	    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
-	    AC_TRY_COMPILE([
+	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 		    #ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
 		    #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
 		    #error __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
 		    #endif
 		    #elif MAC_OS_X_VERSION_MIN_REQUIRED < 1050
 		    #error MAC_OS_X_VERSION_MIN_REQUIRED < 1050
 		    #endif
 		    #define _DARWIN_C_SOURCE 1
 		    #include <sys/cdefs.h>
-		],,tcl_cv_cc_darwin_c_source=yes, tcl_cv_cc_darwin_c_source=no)
+		]], [[]])],[tcl_cv_cc_darwin_c_source=yes],[tcl_cv_cc_darwin_c_source=no])
 	    CFLAGS=$hold_cflags])
 	if test $tcl_cv_cc_darwin_c_source = yes; then
 	    AC_DEFINE(_DARWIN_C_SOURCE, 1,
 		    [Are Darwin SUSv3 extensions available?])
 	fi
@@ -337,12 +282,18 @@
     tk_aqua=no
 fi
 
 if test $tk_aqua = yes; then
     AC_DEFINE(MAC_OSX_TK, 1, [Are we building TkAqua?])
-    LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit"
-    EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c'
+    LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit -framework QuartzCore -framework Security"
+    if test -d /System/Library/Frameworks/UserNotifications.framework; then
+        LIBS="$LIBS -framework UserNotifications"
+    fi
+    if test -d "/System/Library/Frameworks/UniformTypeIdentifiers.framework"; then
+        LIBS="$LIBS -framework UniformTypeIdentifiers"
+    fi
+    EXTRA_CC_SWITCHES='-x objective-c'
     TK_WINDOWINGSYSTEM=AQUA
     if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then
         AC_DEFINE(TK_MAC_DEBUG, 1, [Are TkAqua debug messages enabled?])
     fi
 else
@@ -419,19 +370,19 @@
     AC_MSG_CHECKING([MIT X libraries])
     tk_oldCFlags=$CFLAGS
     CFLAGS="$CFLAGS -I/usr/include/mit"
     tk_oldLibs=$LIBS
     LIBS="$LIBS -lX11-mit"
-    AC_TRY_LINK([
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 	#include <X11/Xlib.h>
-    ], [
+    ]], [[
 	XOpenDisplay(0);
-    ], [
+    ]])],[
 	AC_MSG_RESULT([yes])
 	XLIBSW="-lX11-mit"
 	XINCLUDES="-I/usr/include/mit"
-    ], AC_MSG_RESULT([no]))
+    ],[AC_MSG_RESULT(no)])
     CFLAGS=$tk_oldCFlags
     LIBS=$tk_oldLibs
 fi
 
 #--------------------------------------------------------------------
@@ -439,11 +390,11 @@
 #--------------------------------------------------------------------
 
 if test $tk_aqua = no; then
     AC_MSG_CHECKING([whether to use xft])
     AC_ARG_ENABLE(xft,
-	AC_HELP_STRING([--enable-xft],
+	AS_HELP_STRING([--enable-xft],
 	    [use freetype/fontconfig/xft (default: on)]),
 	[enable_xft=$enableval], [enable_xft="default"])
     XFT_CFLAGS=""
     XFT_LIBS=""
     if test "$enable_xft" = "no" ; then
@@ -535,11 +486,11 @@
     LIBS="$tk_oldLibs $XLIBSW"
     xss_header_found=no
     xss_lib_found=no
     AC_MSG_CHECKING([whether to try to use XScreenSaver])
     AC_ARG_ENABLE(xss,
-	AC_HELP_STRING([--enable-xss],
+	AS_HELP_STRING([--enable-xss],
 	    [use XScreenSaver for activity timer (default: on)]),
 	[enable_xss=$enableval], [enable_xss=yes])
     if test "$enable_xss" = "no" ; then
 	AC_MSG_RESULT([$enable_xss])
     else
@@ -584,11 +535,17 @@
 #	building libtk as a shared library instead of a static library.
 #--------------------------------------------------------------------
 
 eval eval "TK_UNSHARED_LIB_SUFFIX=${UNSHARED_LIB_SUFFIX}"
 eval eval "TK_SHARED_LIB_SUFFIX=${SHARED_LIB_SUFFIX}"
+eval "TK_LIB_FILE_TCL8=libtk${LIB_SUFFIX}"
+if test ${TCL_MAJOR_VERSION} = 8 ; then
 eval "TK_LIB_FILE=libtk${LIB_SUFFIX}"
+else
+eval "TK_LIB_FILE=libtcl9tk${LIB_SUFFIX}"
+fi
+eval "TK_LIB_FILE_TCL9=libtcl9tk${LIB_SUFFIX}"
 
 # tkConfig.sh needs a version of the _LIB_SUFFIX that has been eval'ed
 # since on some platforms TK_LIB_FILE contains shell escapes.
 
 eval "TK_LIB_FILE=${TK_LIB_FILE}"
@@ -615,12 +572,15 @@
     TK_SHLIB_LD_EXTRAS="-compatibility_version ${TK_VERSION} -current_version ${TK_VERSION}`echo ${TK_PATCH_LEVEL} | awk ['{match($0, "\\\.[0-9]+"); print substr($0,RSTART,RLENGTH)}']`"
     TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -install_name "${DYLIB_INSTALL_DIR}/${TK_LIB_FILE}" -unexported_symbols_list $$(f=$(TK_LIB_FILE).E && nm -gp tkMacOSX*.o 2>/dev/null | awk "/^[[0-9a-f]]+ . \.objc/ {print \$$3}" > $$f && nm -gjp "$(TCL_BIN_DIR)"/$(TCL_STUB_LIB_FILE) | grep ^_[[^_]] >> $$f && echo $$f)'
     echo "$LDFLAGS " | grep -q -- '-prebind ' && TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -seg1addr 0xb000000'
     TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tk-Info.plist'
     EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist'
-    EXTRA_APP_CC_SWITCHES="${EXTRA_APP_CC_SWITCHES}"' -mdynamic-no-pic'
-    AC_CONFIG_FILES([Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in])
+    EXTRA_WISH_LIBS=${EXTRA_WISH_LIBS}' -sectcreate __TEXT __credits_html Credits.html'
+    if test "${SHARED_BUILD}" = "0"; then
+	EXTRA_WISH_LIBS=${EXTRA_WISH_LIBS}' -ObjC'
+    fi
+    AC_CONFIG_FILES([Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in Credits.html:../macosx/Credits.html.in])
     for l in ${LOCALES}; do CFBUNDLELOCALIZATIONS="${CFBUNDLELOCALIZATIONS}<string>$l</string>"; done
     TK_YEAR="`date +%Y`"
 fi
 
 if test "$FRAMEWORK_BUILD" = "1" ; then
@@ -638,11 +598,17 @@
     LD_LIBRARY_PATH_VAR="DYLD_FRAMEWORK_PATH"
     if test "${libdir}" = '${exec_prefix}/lib'; then
         # override libdir default
         libdir="/Library/Frameworks"
     fi
-    TK_LIB_FILE="Tk"
+    if test ${TCL_MAJOR_VERSION} = 8 ; then
+	TK_LIB_FILE="Tk"
+    else
+	TK_LIB_FILE="Tk"
+    fi
+    TK_LIB_FILE_TCL8="Tk"
+    TK_LIB_FILE_TCL9="Tk"
     TK_LIB_FLAG="-framework Tk"
     TK_BUILD_LIB_SPEC="-F`pwd | sed -e 's/ /\\\\ /g'` -framework Tk"
     TK_LIB_SPEC="-F${libdir} -framework Tk"
     libdir="${libdir}/Tk.framework/Versions/\${VERSION}"
     TK_LIBRARY="${libdir}/Resources/Scripts"
@@ -653,19 +619,21 @@
     PRIVATE_INCLUDE_DIR="${libdir}/PrivateHeaders"
     HTML_DIR="${libdir}/Resources/Documentation/Reference/Tk"
     EXTRA_INSTALL="install-private-headers html-tk"
     EXTRA_BUILD_HTML='@ln -fs contents.htm "$(HTML_INSTALL_DIR)"/TkTOC.html'
     EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"'
+    EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Credits.html "$(LIB_INSTALL_DIR)/Resources"'
     EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"'
     if test $tk_aqua = yes; then
 	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Images to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)/Resources"; done'
 	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing wish$(VERSION) script to $(INSTALL_ROOT)/'"${bindir}"'/" && $(INSTALL_DATA_DIR) "$(INSTALL_ROOT)/'"${bindir}"'" && printf > "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)" "#!/bin/sh\n\"\$$(dirname \$$0)'"`eval d="${bindir}"; echo "$d" | sed -e 's#/[^/][^/]*#/..#g'`"'$(bindir)/Wish\" \"\$$@\"" && chmod +x "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)"'
 	bindir="${libdir}/Resources/Wish.app/Contents/MacOS"
 	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Info.plist to $(BIN_INSTALL_DIR)/.." && $(INSTALL_DATA) Wish-Info.plist "$(BIN_INSTALL_DIR)/../Info.plist" && mv -f "$(BIN_INSTALL_DIR)/wish$(VERSION)" "$(BIN_INSTALL_DIR)/Wish"'
 	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA_DIR) "$(BIN_INSTALL_DIR)/../Resources"'
 	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Tk.icns" "$(BIN_INSTALL_DIR)/../Resources/Wish.icns"'
 	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.sdef to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.sdef" "$(BIN_INSTALL_DIR)/../Resources"'
+	EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Credits.html to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) Credits.html "$(BIN_INSTALL_DIR)/../Resources"'
     fi
     EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Finalizing Tk.framework" && rm -f "$(LIB_INSTALL_DIR)/../Current" && ln -s "$(VERSION)" "$(LIB_INSTALL_DIR)/../Current" && for f in "$(LIB_FILE)" tkConfig.sh Resources Headers PrivateHeaders; do rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/Current/$$f" "$(LIB_INSTALL_DIR)/../.."; done && f="$(STUB_LIB_FILE)" && rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/$(VERSION)/$$f" "$(LIB_INSTALL_DIR)/../.."'
     # Don't use AC_DEFINE for the following as the framework version define
     # needs to go into the Makefile even when using autoheader, so that we
     # can pick up a potential make override of VERSION. Also, don't put this
@@ -675,23 +643,72 @@
     if test $tk_aqua = yes; then
         EXTRA_INSTALL_BINARIES='@echo "Installing Images to $(LIB_INSTALL_DIR)/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)"; done'
     fi
     # libdir must be a fully qualified path and not ${exec_prefix}/lib
     eval libdir="$libdir"
+    TK_LIB_FLAG="-l"
+    if test "${TCL_MAJOR_VERSION}" -gt 8 ; then
+	TK_LIB_FLAG="${TK_LIB_FLAG}tcl9"
+    fi
     if test "${ac_cv_cygwin}" = "yes" -a "$SHARED_BUILD" = "1"; then
-	TK_LIB_FLAG="-ltk`echo ${TK_VERSION} | tr -d .`"
+	TK_LIB_FLAG="${TK_LIB_FLAG}tk`echo ${TK_VERSION} | tr -d .`"
 	TK_BUILD_LIB_SPEC="-L\$(TOP_DIR)/win ${TK_LIB_FLAG}"
     else
 	if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
-	    TK_LIB_FLAG="-ltk${TK_VERSION}"
+	    TK_LIB_FLAG="${TK_LIB_FLAG}tk${TK_VERSION}"
 	else
-	    TK_LIB_FLAG="-ltk`echo ${TK_VERSION} | tr -d .`"
+	    TK_LIB_FLAG="${TK_LIB_FLAG}tk`echo ${TK_VERSION} | tr -d .`"
 	fi
 	TK_BUILD_LIB_SPEC="-L`pwd | sed -e 's/ /\\\\ /g'` ${TK_LIB_FLAG}"
     fi
     TK_LIB_SPEC="-L${libdir} ${TK_LIB_FLAG}"
 fi
+
+#--------------------------------------------------------------------
+#	Zipfs support - Tip 430
+#--------------------------------------------------------------------
+AC_ARG_ENABLE(zipfs,
+    AS_HELP_STRING([--enable-zipfs],[build with Zipfs support (default: on)]),
+    [tcl_ok=$enableval], [tcl_ok=yes])
+if test "$tcl_ok" = "yes" -a "x$enable_framework" != "xyes"; then
+    #
+    # Find a native compiler
+    #
+    AX_CC_FOR_BUILD
+    #
+    # Find a native zip implementation
+    #
+    SC_ZIPFS_SUPPORT
+	ZIPFS_BUILD=1
+	TK_ZIP_FILE=libtk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${TK_PATCH_LEVEL}.zip
+else
+	ZIPFS_BUILD=0
+	TK_ZIP_FILE=
+fi
+# Do checking message here to not mess up interleaved configure output
+AC_MSG_CHECKING([for building with zipfs])
+if test "${ZIPFS_BUILD}" = 1; then
+    if test "${SHARED_BUILD}" = 0; then
+       ZIPFS_BUILD=2;
+       AC_DEFINE(ZIPFS_BUILD, 2, [Are we building with zipfs enabled?])
+       INSTALL_LIBRARIES=install-demos
+       AC_MSG_RESULT([yes])
+     else
+       AC_DEFINE(ZIPFS_BUILD, 1, [Are we building with zipfs enabled?])\
+       INSTALL_LIBRARIES=install-demos
+       AC_MSG_RESULT([yes])
+    fi
+else
+AC_MSG_RESULT([no])
+INSTALL_LIBRARIES=install-libraries
+INSTALL_MSGS=install-msgs
+fi
+AC_SUBST(ZIPFS_BUILD)
+AC_SUBST(TK_ZIP_FILE)
+AC_SUBST(INSTALL_LIBRARIES)
+AC_SUBST(INSTALL_MSGS)
+
 
 #--------------------------------------------------------------------
 #       The statements below define various symbols relating to Tk
 #       stub support.
 #--------------------------------------------------------------------
@@ -735,10 +752,12 @@
 AC_SUBST(TK_MINOR_VERSION)
 AC_SUBST(TK_PATCH_LEVEL)
 AC_SUBST(TK_YEAR)
 
 AC_SUBST(TK_LIB_FILE)
+AC_SUBST(TK_LIB_FILE_TCL8)
+AC_SUBST(TK_LIB_FILE_TCL9)
 AC_SUBST(TK_LIB_FLAG)
 AC_SUBST(TK_LIB_SPEC)
 AC_SUBST(TK_STUB_LIB_FILE)
 AC_SUBST(TK_STUB_LIB_FLAG)
 AC_SUBST(TK_STUB_LIB_SPEC)

Index: unix/installManPage
==================================================================
--- unix/installManPage
+++ unix/installManPage
@@ -115,11 +115,11 @@
 	sed -e "/man\.macros/r $SrcDir/man.macros" -e "/man\.macros/d" \
 	    $ManPage > "$Dir/$First"
 	chmod 644 "$Dir/$First"
 	$Gzip "$Dir/$First"
     else
-	ln "$SymOrLoc$First$Gz" "$Dir/$Target$Gz"
+	ln $SymOrLoc"$First$Gz" "$Dir/$Target$Gz"
     fi
 done
 
 ########################################################################
 exit 0

Index: unix/tcl.m4
==================================================================
--- unix/tcl.m4
+++ unix/tcl.m4
@@ -26,13 +26,13 @@
 
     if test x"${no_tcl}" = x ; then
 	# we reset no_tcl in case something fails here
 	no_tcl=true
 	AC_ARG_WITH(tcl,
-	    AC_HELP_STRING([--with-tcl],
+	    AS_HELP_STRING([--with-tcl],
 		[directory containing tcl configuration (tclConfig.sh)]),
-	    with_tclconfig="${withval}")
+	    [with_tclconfig="${withval}"])
 	AC_MSG_CHECKING([for Tcl configuration])
 	AC_CACHE_VAL(ac_cv_c_tclconfig,[
 
 	    # First check to see if --with-tcl was specified.
 	    if test x"${with_tclconfig}" != x ; then
@@ -159,13 +159,13 @@
 
     if test x"${no_tk}" = x ; then
 	# we reset no_tk in case something fails here
 	no_tk=true
 	AC_ARG_WITH(tk,
-	    AC_HELP_STRING([--with-tk],
+	    AS_HELP_STRING([--with-tk],
 		[directory containing tk configuration (tkConfig.sh)]),
-	    with_tkconfig="${withval}")
+	    [with_tkconfig="${withval}"])
 	AC_MSG_CHECKING([for Tk configuration])
 	AC_CACHE_VAL(ac_cv_c_tkconfig,[
 
 	    # First check to see if --with-tkconfig was specified.
 	    if test x"${with_tkconfig}" != x ; then
@@ -506,21 +506,13 @@
 #------------------------------------------------------------------------
 
 AC_DEFUN([SC_ENABLE_SHARED], [
     AC_MSG_CHECKING([how to build libraries])
     AC_ARG_ENABLE(shared,
-	AC_HELP_STRING([--enable-shared],
+	AS_HELP_STRING([--enable-shared],
 	    [build and link with shared libraries (default: on)]),
 	[tcl_ok=$enableval], [tcl_ok=yes])
-
-    if test "${enable_shared+set}" = set; then
-	enableval="$enable_shared"
-	tcl_ok=$enableval
-    else
-	tcl_ok=yes
-    fi
-
     if test "$tcl_ok" = "yes" ; then
 	AC_MSG_RESULT([shared])
 	SHARED_BUILD=1
     else
 	AC_MSG_RESULT([static])
@@ -549,11 +541,11 @@
 
 AC_DEFUN([SC_ENABLE_FRAMEWORK], [
     if test "`uname -s`" = "Darwin" ; then
 	AC_MSG_CHECKING([how to package libraries])
 	AC_ARG_ENABLE(framework,
-	    AC_HELP_STRING([--enable-framework],
+	    AS_HELP_STRING([--enable-framework],
 		[package shared libraries in MacOSX frameworks (default: off)]),
 	    [enable_framework=$enableval], [enable_framework=no])
 	if test $enable_framework = yes; then
 	    if test $SHARED_BUILD = 0; then
 		AC_MSG_WARN([Frameworks can only be built if --enable-shared is yes])
@@ -607,11 +599,11 @@
 #------------------------------------------------------------------------
 
 AC_DEFUN([SC_ENABLE_SYMBOLS], [
     AC_MSG_CHECKING([for build with symbols])
     AC_ARG_ENABLE(symbols,
-	AC_HELP_STRING([--enable-symbols],
+	AS_HELP_STRING([--enable-symbols],
 	    [build with debugging symbols (default: off)]),
 	[tcl_ok=$enableval], [tcl_ok=no])
 # FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
     if test "$tcl_ok" = "no"; then
 	CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
@@ -666,11 +658,11 @@
 #		HAVE_LANGINFO	Triggers use of nl_langinfo if defined.
 #------------------------------------------------------------------------
 
 AC_DEFUN([SC_ENABLE_LANGINFO], [
     AC_ARG_ENABLE(langinfo,
-	AC_HELP_STRING([--enable-langinfo],
+	AS_HELP_STRING([--enable-langinfo],
 	    [use nl_langinfo if possible to determine encoding at startup, otherwise use old heuristic (default: on)]),
 	[langinfo_ok=$enableval], [langinfo_ok=yes])
 
     HAVE_LANGINFO=0
     if test "$langinfo_ok" = "yes"; then
@@ -677,12 +669,12 @@
 	AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
     fi
     AC_MSG_CHECKING([whether to use nl_langinfo])
     if test "$langinfo_ok" = "yes"; then
 	AC_CACHE_VAL(tcl_cv_langinfo_h, [
-	    AC_TRY_COMPILE([#include <langinfo.h>], [nl_langinfo(CODESET);],
-		    [tcl_cv_langinfo_h=yes],[tcl_cv_langinfo_h=no])])
+	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]], [[nl_langinfo(CODESET);]])],
+		    [tcl_cv_langinfo_h=yes], [tcl_cv_langinfo_h=no])])
 	AC_MSG_RESULT([$tcl_cv_langinfo_h])
 	if test $tcl_cv_langinfo_h = yes; then
 	    AC_DEFINE(HAVE_LANGINFO, 1, [Do we have nl_langinfo()?])
 	fi
     else
@@ -718,26 +710,26 @@
 #--------------------------------------------------------------------
 
 AC_DEFUN([SC_CONFIG_MANPAGES], [
     AC_MSG_CHECKING([whether to use symlinks for manpages])
     AC_ARG_ENABLE(man-symlinks,
-	AC_HELP_STRING([--enable-man-symlinks],
+	AS_HELP_STRING([--enable-man-symlinks],
 	    [use symlinks for the manpages (default: off)]),
-	test "$enableval" != "no" && MAN_FLAGS="$MAN_FLAGS --symlinks",
-	enableval="no")
+	[test "$enableval" != "no" && MAN_FLAGS="$MAN_FLAGS --symlinks"],
+	[enableval="no"])
     AC_MSG_RESULT([$enableval])
 
     AC_MSG_CHECKING([whether to compress the manpages])
     AC_ARG_ENABLE(man-compression,
-	AC_HELP_STRING([--enable-man-compression=PROG],
+	AS_HELP_STRING([--enable-man-compression=PROG],
 	    [compress the manpages with PROG (default: off)]),
 	[case $enableval in
 	    yes) AC_MSG_ERROR([missing argument to --enable-man-compression]);;
 	    no)  ;;
 	    *)   MAN_FLAGS="$MAN_FLAGS --compress $enableval";;
 	esac],
-	enableval="no")
+	[enableval="no"])
     AC_MSG_RESULT([$enableval])
     if test "$enableval" != "no"; then
 	AC_MSG_CHECKING([for compressed file suffix])
 	touch TeST
 	$enableval TeST
@@ -747,18 +739,18 @@
 	AC_MSG_RESULT([$Z])
     fi
 
     AC_MSG_CHECKING([whether to add a package name suffix for the manpages])
     AC_ARG_ENABLE(man-suffix,
-	AC_HELP_STRING([--enable-man-suffix=STRING],
+	AS_HELP_STRING([--enable-man-suffix=STRING],
 	    [use STRING as a suffix to manpage file names (default: no, AC_PACKAGE_NAME if enabled without specifying STRING)]),
 	[case $enableval in
 	    yes) enableval="AC_PACKAGE_NAME" MAN_FLAGS="$MAN_FLAGS --suffix $enableval";;
 	    no)  ;;
 	    *)   MAN_FLAGS="$MAN_FLAGS --suffix $enableval";;
 	esac],
-	enableval="no")
+	[enableval="no"])
     AC_MSG_RESULT([$enableval])
 
     AC_SUBST(MAN_FLAGS)
 ])
 
@@ -774,10 +766,11 @@
 #
 # Results:
 #	Defines the following var:
 #
 #	system -	System/platform/version identification code.
+#
 #--------------------------------------------------------------------
 
 AC_DEFUN([SC_CONFIG_SYSTEM], [
     AC_CACHE_CHECK([system version], tcl_cv_sys_version, [
 	if test "${TEA_PLATFORM}" = "windows" ; then
@@ -890,20 +883,20 @@
 
     # Step 0.a: Enable 64 bit support?
 
     AC_MSG_CHECKING([if 64bit support is requested])
     AC_ARG_ENABLE(64bit,
-	AC_HELP_STRING([--enable-64bit],
+	AS_HELP_STRING([--enable-64bit],
 	    [enable 64bit support (default: off)]),
 	[do64bit=$enableval], [do64bit=no])
     AC_MSG_RESULT([$do64bit])
 
     # Step 0.b: Enable Solaris 64 bit VIS support?
 
     AC_MSG_CHECKING([if 64bit Sparc VIS support is requested])
     AC_ARG_ENABLE(64bit-vis,
-	AC_HELP_STRING([--enable-64bit-vis],
+	AS_HELP_STRING([--enable-64bit-vis],
 	    [enable 64bit Sparc VIS support (default: off)]),
 	[do64bitVIS=$enableval], [do64bitVIS=no])
     AC_MSG_RESULT([$do64bitVIS])
     # Force 64bit on with VIS
     AS_IF([test "$do64bitVIS" = "yes"], [do64bit=yes])
@@ -912,14 +905,15 @@
     # that platform specific alternatives can be used below if this fails.
 
     AC_CACHE_CHECK([if compiler supports visibility "hidden"],
 	tcl_cv_cc_visibility_hidden, [
 	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
-	AC_TRY_LINK([
+	AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 	    extern __attribute__((__visibility__("hidden"))) void f(void);
-	    void f(void) {}], [f();], tcl_cv_cc_visibility_hidden=yes,
-	    tcl_cv_cc_visibility_hidden=no)
+	    void f(void) {}]], [[f();]])],
+	    [tcl_cv_cc_visibility_hidden=yes],
+	    [tcl_cv_cc_visibility_hidden=no])
 	CFLAGS=$hold_cflags])
     AS_IF([test $tcl_cv_cc_visibility_hidden = yes], [
 	AC_DEFINE(MODULE_SCOPE,
 	    [extern __attribute__((__visibility__("hidden")))],
 	    [Compiler support for module scope symbols])
@@ -928,11 +922,11 @@
 
     # Step 0.d: Disable -rpath support?
 
     AC_MSG_CHECKING([if rpath support is requested])
     AC_ARG_ENABLE(rpath,
-	AC_HELP_STRING([--disable-rpath],
+	AS_HELP_STRING([--disable-rpath],
 	    [disable rpath support (default: on)]),
 	[doRpath=$enableval], [doRpath=yes])
     AC_MSG_RESULT([$doRpath])
 
     # Step 1: set the variable "system" to hold the name and version number
@@ -969,11 +963,11 @@
 	CFLAGS_WARNING="-Wall -Wextra -Wshadow -Wundef -Wwrite-strings -Wpointer-arith"
 	case "${CC}" in
 	    *++|*++-*)
 		;;
 	    *)
-		CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -Wdeclaration-after-statement"
+		CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -fextended-identifiers"
 		;;
 	esac
 
     ], [
 	CFLAGS_OPTIMIZE=-O
@@ -1081,11 +1075,11 @@
 	    DL_LIBS="-ldl"
 	    LDFLAGS="$LDFLAGS -export-dynamic"
 	    CC_SEARCH_FLAGS=""
 	    LD_SEARCH_FLAGS=""
 	    ;;
-	CYGWIN_*)
+	CYGWIN_*|MINGW32_*|MSYS_*)
 	    SHLIB_CFLAGS="-fno-common"
 	    SHLIB_LD='${CC} -shared'
 	    SHLIB_SUFFIX=".dll"
 	    DL_OBJS="tclLoadDl.o"
 	    PLAT_OBJS='${CYGWIN_OBJS}'
@@ -1096,26 +1090,26 @@
 	    TCL_NEEDS_EXP_FILE=1
 	    TCL_EXPORT_FILE_SUFFIX='${VERSION}.dll.a'
 	    SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$[@].a"
 	    AC_CACHE_CHECK(for Cygwin version of gcc,
 		ac_cv_cygwin,
-		AC_TRY_COMPILE([
+		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 		#ifdef __CYGWIN__
 		    #error cygwin
 		#endif
-		], [],
-		ac_cv_cygwin=no,
-		ac_cv_cygwin=yes)
+		]], [[]])],
+		[ac_cv_cygwin=no],
+		[ac_cv_cygwin=yes])
 	    )
 	    if test "$ac_cv_cygwin" = "no"; then
 		AC_MSG_ERROR([${CC} is not a cygwin compiler.])
 	    fi
 	    do64bit_ok=yes
 	    if test "x${SHARED_BUILD}" = "x1"; then
-		echo "running cd ../win; ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args"
+		echo "running cd ../win; ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args --enable-64bit --host=x86_64-w64-mingw32"
 		# The eval makes quoting arguments work.
-		if cd ../win; eval ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args; cd ../unix
+		if cd ../win; eval ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args --enable-64bit --host=x86_64-w64-mingw32; cd ../unix
 		then :
 		else
 		    { echo "configure: error: configure failed for ../win" 1>&2; exit 1; }
 		fi
 	    fi
@@ -1266,11 +1260,11 @@
 	            CFLAGS="$CFLAGS -64"
 	            LDFLAGS_ARCH="-64"
 	        ])
 	    ])
 	    ;;
-	Linux*|GNU*|NetBSD-Debian)
+	Linux*|GNU*|NetBSD-Debian|DragonFly-*|FreeBSD-*)
 	    SHLIB_CFLAGS="-fPIC -fno-common"
 	    SHLIB_SUFFIX=".so"
 
 	    CFLAGS_OPTIMIZE="-O2"
 	    # egcs-2.91.66 on Redhat Linux 6.0 generates lots of warnings
@@ -1280,19 +1274,31 @@
 
 	    SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS} -shared'
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS="-ldl"
 	    LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
+
+	    case $system in
+	    DragonFly-*|FreeBSD-*)
+		AS_IF([test "${TCL_THREADS}" = "1"], [
+		    # The -pthread needs to go in the LDFLAGS, not LIBS
+		    LIBS=`echo $LIBS | sed s/-pthread//`
+		    CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+		    LDFLAGS="$LDFLAGS $PTHREAD_LIBS"])
+	    ;;
+            esac
+
 	    AS_IF([test $doRpath = yes], [
 		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
 	    LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
 	    AS_IF([test "`uname -m`" = "alpha"], [CFLAGS="$CFLAGS -mieee"])
 	    AS_IF([test $do64bit = yes], [
 		AC_CACHE_CHECK([if compiler accepts -m64 flag], tcl_cv_cc_m64, [
 		    hold_cflags=$CFLAGS
 		    CFLAGS="$CFLAGS -m64"
-		    AC_TRY_LINK(,, tcl_cv_cc_m64=yes, tcl_cv_cc_m64=no)
+		    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+			    [tcl_cv_cc_m64=yes],[tcl_cv_cc_m64=no])
 		    CFLAGS=$hold_cflags])
 		AS_IF([test $tcl_cv_cc_m64 = yes], [
 		    CFLAGS="$CFLAGS -m64"
 		    do64bit_ok=yes
 		])
@@ -1360,36 +1366,12 @@
 	    # The -pthread needs to go in the CFLAGS, not LIBS
 	    LIBS=`echo $LIBS | sed s/-pthread//`
 	    CFLAGS="$CFLAGS -pthread"
 	    LDFLAGS="$LDFLAGS -pthread"
 	    ;;
-	DragonFly-*|FreeBSD-*)
-	    # This configuration from FreeBSD Ports.
-	    SHLIB_LD="${CC} -shared"
-	    SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,-soname,\$[@]"
-	    SHLIB_SUFFIX=".so"
-	    DL_OBJS="tclLoadDl.o"
-	    DL_LIBS=""
-	    AS_IF([test $doRpath = yes], [
-		CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
-		LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
-	    # The -pthread needs to go in the LDFLAGS, not LIBS
-	    LIBS=`echo $LIBS | sed s/-pthread//`
-	    CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-	    LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
-	    case $system in
-	    FreeBSD-3.*)
-		# Version numbers are dot-stripped by system policy.
-		TCL_TRIM_DOTS=`echo ${VERSION} | tr -d .`
-		UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
-		SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so'
-		TCL_LIB_VERSIONS_OK=nodots
-		;;
-	    esac
-	    ;;
 	Darwin-*)
-	    CFLAGS_OPTIMIZE="-Os"
+	    CFLAGS_OPTIMIZE="-O2"
 	    SHLIB_CFLAGS="-fno-common"
 	    # To avoid discrepancies between what headers configure sees during
 	    # preprocessing tests and compiling tests, move any -isysroot and
 	    # -mmacosx-version-min flags from CFLAGS to CPPFLAGS:
 	    CPPFLAGS="${CPPFLAGS} `echo " ${CFLAGS}" | \
@@ -1403,43 +1385,56 @@
 		    ppc)
 			AC_CACHE_CHECK([if compiler accepts -arch ppc64 flag],
 				tcl_cv_cc_arch_ppc64, [
 			    hold_cflags=$CFLAGS
 			    CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
-			    AC_TRY_LINK(,, tcl_cv_cc_arch_ppc64=yes,
-				    tcl_cv_cc_arch_ppc64=no)
+			    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+				    [tcl_cv_cc_arch_ppc64=yes],[tcl_cv_cc_arch_ppc64=no])
 			    CFLAGS=$hold_cflags])
 			AS_IF([test $tcl_cv_cc_arch_ppc64 = yes], [
 			    CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
 			    do64bit_ok=yes
 			]);;
-		    i386)
+		    i386|x86_64)
 			AC_CACHE_CHECK([if compiler accepts -arch x86_64 flag],
 				tcl_cv_cc_arch_x86_64, [
 			    hold_cflags=$CFLAGS
 			    CFLAGS="$CFLAGS -arch x86_64"
-			    AC_TRY_LINK(,, tcl_cv_cc_arch_x86_64=yes,
-				    tcl_cv_cc_arch_x86_64=no)
+			    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+				    [tcl_cv_cc_arch_x86_64=yes],[tcl_cv_cc_arch_x86_64=no])
 			    CFLAGS=$hold_cflags])
 			AS_IF([test $tcl_cv_cc_arch_x86_64 = yes], [
 			    CFLAGS="$CFLAGS -arch x86_64"
 			    do64bit_ok=yes
 			]);;
+		    arm64|arm64e)
+			AC_CACHE_CHECK([if compiler accepts -arch arm64e flag],
+				tcl_cv_cc_arch_arm64e, [
+			    hold_cflags=$CFLAGS
+			    CFLAGS="$CFLAGS -arch arm64e"
+			    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+				    [tcl_cv_cc_arch_arm64e=yes],[tcl_cv_cc_arch_arm64e=no])
+			    CFLAGS=$hold_cflags])
+			AS_IF([test $tcl_cv_cc_arch_arm64e = yes], [
+			    CFLAGS="$CFLAGS -arch arm64e"
+			    do64bit_ok=yes
+			]);;
 		    *)
 			AC_MSG_WARN([Don't know how enable 64-bit on architecture `arch`]);;
 		esac
 	    ], [
 		# Check for combined 32-bit and 64-bit fat build
-		AS_IF([echo "$CFLAGS " |grep -E -q -- '-arch (ppc64|x86_64) ' \
+		AS_IF([echo "$CFLAGS " |grep -E -q -- '-arch (ppc64|x86_64|arm64e) ' \
 		    && echo "$CFLAGS " |grep -E -q -- '-arch (ppc|i386) '], [
 		    fat_32_64=yes])
 	    ])
 	    SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS}'
 	    AC_CACHE_CHECK([if ld accepts -single_module flag], tcl_cv_ld_single_module, [
 		hold_ldflags=$LDFLAGS
 		LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module"
-		AC_TRY_LINK(, [int i;], tcl_cv_ld_single_module=yes, tcl_cv_ld_single_module=no)
+		AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])],[tcl_cv_ld_single_module=yes],
+		    [tcl_cv_ld_single_module=no])
 		LDFLAGS=$hold_ldflags])
 	    AS_IF([test $tcl_cv_ld_single_module = yes], [
 		SHLIB_LD="${SHLIB_LD} -Wl,-single_module"
 	    ])
 	    SHLIB_SUFFIX=".dylib"
@@ -1448,12 +1443,13 @@
 	    LDFLAGS="$LDFLAGS -headerpad_max_install_names"
 	    AC_CACHE_CHECK([if ld accepts -search_paths_first flag],
 		    tcl_cv_ld_search_paths_first, [
 		hold_ldflags=$LDFLAGS
 		LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
-		AC_TRY_LINK(, [int i;], tcl_cv_ld_search_paths_first=yes,
-			tcl_cv_ld_search_paths_first=no)
+		AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])],
+			[tcl_cv_ld_search_paths_first=yes],
+		    [tcl_cv_ld_search_paths_first=no])
 		LDFLAGS=$hold_ldflags])
 	    AS_IF([test $tcl_cv_ld_search_paths_first = yes], [
 		LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
 	    ])
 	    AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [
@@ -1467,11 +1463,11 @@
 	    AC_DEFINE(MAC_OSX_TCL, 1, [Is this a Mac I see before me?])
 	    PLAT_OBJS='${MAC_OSX_OBJS}'
 	    PLAT_SRCS='${MAC_OSX_SRCS}'
 	    AC_MSG_CHECKING([whether to use CoreFoundation])
 	    AC_ARG_ENABLE(corefoundation,
-		AC_HELP_STRING([--enable-corefoundation],
+		AS_HELP_STRING([--enable-corefoundation],
 		    [use CoreFoundation API on MacOSX (default: on)]),
 		[tcl_corefoundation=$enableval], [tcl_corefoundation=yes])
 	    AC_MSG_RESULT([$tcl_corefoundation])
 	    AS_IF([test $tcl_corefoundation = yes], [
 		AC_CACHE_CHECK([for CoreFoundation.framework],
@@ -1484,14 +1480,14 @@
 			    # presence of CF. 64-bit CF is disabled in
 			    # tclUnixPort.h if necessary.
 			    eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"'
 			done])
 		    LIBS="$LIBS -framework CoreFoundation"
-		    AC_TRY_LINK([#include <CoreFoundation/CoreFoundation.h>],
-			[CFBundleRef b = CFBundleGetMainBundle();],
-			tcl_cv_lib_corefoundation=yes,
-			tcl_cv_lib_corefoundation=no)
+		    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <CoreFoundation/CoreFoundation.h>]],
+			[[CFBundleRef b = CFBundleGetMainBundle();]])],
+			[tcl_cv_lib_corefoundation=yes],
+			[tcl_cv_lib_corefoundation=no])
 		    AS_IF([test "$fat_32_64" = yes], [
 			for v in CFLAGS CPPFLAGS LDFLAGS; do
 			    eval $v'="$hold_'$v'"'
 		        done])
 		    LIBS=$hold_libs])
@@ -1504,14 +1500,14 @@
 		    AC_CACHE_CHECK([for 64-bit CoreFoundation],
 			    tcl_cv_lib_corefoundation_64, [
 			for v in CFLAGS CPPFLAGS LDFLAGS; do
 			    eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"'
 			done
-			AC_TRY_LINK([#include <CoreFoundation/CoreFoundation.h>],
-			    [CFBundleRef b = CFBundleGetMainBundle();],
-			    tcl_cv_lib_corefoundation_64=yes,
-			    tcl_cv_lib_corefoundation_64=no)
+			AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <CoreFoundation/CoreFoundation.h>]],
+			    [[CFBundleRef b = CFBundleGetMainBundle();]])],
+			    [tcl_cv_lib_corefoundation_64=yes],
+			    [tcl_cv_lib_corefoundation_64=no])
 			for v in CFLAGS CPPFLAGS LDFLAGS; do
 			    eval $v'="$hold_'$v'"'
 			done])
 		    AS_IF([test $tcl_cv_lib_corefoundation_64 = no], [
 			AC_DEFINE(NO_COREFOUNDATION_64, 1,
@@ -1529,13 +1525,13 @@
 	    ;;
 	OSF1-V*)
 	    # Digital OSF/1
 	    SHLIB_CFLAGS=""
 	    AS_IF([test "$SHARED_BUILD" = 1], [
-	        SHLIB_LD='ld -shared -expect_unresolved "*"'
+	        SHLIB_LD='${CC} -shared'
 	    ], [
-	        SHLIB_LD='ld -non_shared -expect_unresolved "*"'
+	        SHLIB_LD='${CC} -non_shared'
 	    ])
 	    SHLIB_SUFFIX=".so"
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS=""
 	    AS_IF([test $doRpath = yes], [
@@ -1727,11 +1723,11 @@
 	    # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
 	    # that don't grok the -Bexport option.  Test that it does.
 	    AC_CACHE_CHECK([for ld accepts -Bexport flag], tcl_cv_ld_Bexport, [
 		hold_ldflags=$LDFLAGS
 		LDFLAGS="$LDFLAGS -Wl,-Bexport"
-		AC_TRY_LINK(, [int i;], tcl_cv_ld_Bexport=yes, tcl_cv_ld_Bexport=no)
+		AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])],[tcl_cv_ld_Bexport=yes],[tcl_cv_ld_Bexport=no])
 	        LDFLAGS=$hold_ldflags])
 	    AS_IF([test $tcl_cv_ld_Bexport = yes], [
 		LDFLAGS="$LDFLAGS -Wl,-Bexport"
 	    ])
 	    CC_SEARCH_FLAGS=""
@@ -1754,11 +1750,11 @@
     AC_CONFIG_COMMANDS_PRE([CFLAGS="${CFLAGS} ${CPPFLAGS}"; CPPFLAGS=""])
 
     # Step 4: disable dynamic loading if requested via a command-line switch.
 
     AC_ARG_ENABLE(load,
-	AC_HELP_STRING([--enable-load],
+	AS_HELP_STRING([--enable-load],
 	    [allow dynamic loading and "load" command (default: on)]),
 	[tcl_ok=$enableval], [tcl_ok=yes])
     AS_IF([test "$tcl_ok" = no], [DL_OBJS=""])
 
     AS_IF([test "x$DL_OBJS" != x], [BUILD_DLTEST="\$(DLTEST_TARGETS)"], [
@@ -1781,17 +1777,17 @@
 
     AS_IF([test "$DL_OBJS" != "tclLoadNone.o" -a "$GCC" = yes], [
 	case $system in
 	    AIX-*) ;;
 	    BSD/OS*) ;;
-	    CYGWIN_*) ;;
-	    HP_UX*) ;;
+	    CYGWIN_*|MINGW32_*|MSYS_*) ;;
+	    HP-UX*) ;;
 	    Darwin-*) ;;
 	    IRIX*) ;;
 	    Linux*|GNU*) ;;
 	    NetBSD-*|OpenBSD-*) ;;
-	    OSF1-V*) ;;
+	    OSF1-*) ;;
 	    SCO_SV-3.2*) ;;
 	    *) SHLIB_CFLAGS="-fPIC" ;;
 	esac])
 
     AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [
@@ -1838,28 +1834,48 @@
     # it is already set when tclConfig.sh had been loaded by Tk.
     AS_IF([test "x${TCL_LIBS}" = x], [
         TCL_LIBS="${DL_LIBS} ${LIBS} ${MATH_LIBS}"])
     AC_SUBST(TCL_LIBS)
 
-	# See if the compiler supports casting to a union type.
-	# This is used to stop gcc from printing a compiler
-	# warning when initializing a union member.
-
-	AC_CACHE_CHECK(for cast to union support,
-	    tcl_cv_cast_to_union,
-	    AC_TRY_COMPILE([],
-	    [
-		  union foo { int i; double d; };
-		  union foo f = (union foo) (int) 0;
-	    ],
-	    tcl_cv_cast_to_union=yes,
-	    tcl_cv_cast_to_union=no)
-	)
-	if test "$tcl_cv_cast_to_union" = "yes"; then
-	    AC_DEFINE(HAVE_CAST_TO_UNION, 1,
-		    [Defined when compiler supports casting to union type.])
-	fi
+    # See if the compiler supports casting to a union type.
+    # This is used to stop gcc from printing a compiler
+    # warning when initializing a union member.
+
+    AC_CACHE_CHECK(for cast to union support,
+	tcl_cv_cast_to_union,
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+		union foo { int i; double d; };
+		union foo f = (union foo) (int) 0;
+	]])],
+	[tcl_cv_cast_to_union=yes],
+	[tcl_cv_cast_to_union=no])
+    )
+    if test "$tcl_cv_cast_to_union" = "yes"; then
+	AC_DEFINE(HAVE_CAST_TO_UNION, 1,
+		[Defined when compiler supports casting to union type.])
+    fi
+    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -fno-lto"
+    AC_CACHE_CHECK(for working -fno-lto,
+	ac_cv_nolto,
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+	[ac_cv_nolto=yes],
+	[ac_cv_nolto=no])
+    )
+    CFLAGS=$hold_cflags
+    if test "$ac_cv_nolto" = "yes" ; then
+	CFLAGS_NOLTO="-fno-lto"
+    else
+	CFLAGS_NOLTO=""
+    fi
+    AC_CACHE_CHECK([if the compiler understands -finput-charset],
+	tcl_cv_cc_input_charset, [
+	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -finput-charset=UTF-8"
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[tcl_cv_cc_input_charset=yes],[tcl_cv_cc_input_charset=no])
+	CFLAGS=$hold_cflags])
+    if test $tcl_cv_cc_input_charset = yes; then
+	CFLAGS="$CFLAGS -finput-charset=UTF-8"
+    fi
 
     AC_CHECK_HEADER(stdbool.h, [AC_DEFINE(HAVE_STDBOOL_H, 1, [Do we have <stdbool.h>?])],)
 
     # FIXME: This subst was left in only because the TCL_DL_LIBS
     # entry in tclConfig.sh uses it. It is not clear why someone
@@ -1872,10 +1888,11 @@
     AC_SUBST(LDAIX_SRC)
     AC_SUBST(CFLAGS)
     AC_SUBST(CFLAGS_DEBUG)
     AC_SUBST(CFLAGS_OPTIMIZE)
     AC_SUBST(CFLAGS_WARNING)
+    AC_SUBST(CFLAGS_NOLTO)
 
     AC_SUBST(LDFLAGS)
     AC_SUBST(LDFLAGS_DEBUG)
     AC_SUBST(LDFLAGS_OPTIMIZE)
     AC_SUBST(CC_SEARCH_FLAGS)
@@ -1925,12 +1942,12 @@
 #
 #--------------------------------------------------------------------
 
 AC_DEFUN([SC_MISSING_POSIX_HEADERS], [
     AC_CACHE_CHECK([dirent.h], tcl_cv_dirent_h, [
-    AC_TRY_LINK([#include <sys/types.h>
-#include <dirent.h>], [
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
+#include <dirent.h>]], [[
 #ifndef _POSIX_SOURCE
 #   ifdef __Lynx__
 	/*
 	 * Generate compilation error to make the test fail:  Lynx headers
 	 * are only valid if really in the POSIX environment.
@@ -1944,11 +1961,11 @@
 char *p;
 d = opendir("foobar");
 entryPtr = readdir(d);
 p = entryPtr->d_name;
 closedir(d);
-], tcl_cv_dirent_h=yes, tcl_cv_dirent_h=no)])
+]])],[tcl_cv_dirent_h=yes],[tcl_cv_dirent_h=no])])
 
     if test $tcl_cv_dirent_h = no; then
 	AC_DEFINE(NO_DIRENT_H, 1, [Do we have <dirent.h>?])
     fi
 
@@ -1971,11 +1988,11 @@
 
     AC_CHECK_HEADER(sys/wait.h, , [AC_DEFINE(NO_SYS_WAIT_H, 1, [Do we have <sys/wait.h>?])])
     AC_CHECK_HEADER(dlfcn.h, , [AC_DEFINE(NO_DLFCN_H, 1, [Do we have <dlfcn.h>?])])
 
     # OS/390 lacks sys/param.h (and doesn't need it, by chance).
-    AC_HAVE_HEADERS(sys/param.h)
+    AC_CHECK_HEADERS([sys/param.h])
 ])
 
 #--------------------------------------------------------------------
 # SC_PATH_X
 #
@@ -2000,21 +2017,21 @@
 AC_DEFUN([SC_PATH_X], [
     AC_PATH_X
     not_really_there=""
     if test "$no_x" = ""; then
 	if test "$x_includes" = ""; then
-	    AC_TRY_CPP([#include <X11/Xlib.h>], , not_really_there="yes")
+	    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <X11/Xlib.h>]])],[],[not_really_there="yes"])
 	else
 	    if test ! -r $x_includes/X11/Xlib.h; then
 		not_really_there="yes"
 	    fi
 	fi
     fi
     if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
 	AC_MSG_CHECKING([for X11 header files])
 	found_xincludes="no"
-	AC_TRY_CPP([#include <X11/Xlib.h>], found_xincludes="yes", found_xincludes="no")
+	AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <X11/Xlib.h>]])],[found_xincludes="yes"],[found_xincludes="no"])
 	if test "$found_xincludes" = "no"; then
 	    dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/X11R6/include /usr/X11R5/include /usr/include/X11R5 /usr/include/X11R4 /usr/openwin/include /usr/X11/include /usr/sww/include"
 	    for i in $dirs ; do
 		if test -r $i/X11/Xlib.h; then
 		    AC_MSG_RESULT([$i])
@@ -2118,50 +2135,54 @@
 #
 #--------------------------------------------------------------------
 
 AC_DEFUN([SC_TIME_HANDLER], [
     AC_CHECK_HEADERS(sys/time.h)
-    AC_HEADER_TIME
+    AC_CHECK_HEADERS_ONCE([sys/time.h])
 
     AC_CHECK_FUNCS(gmtime_r localtime_r mktime)
 
     AC_CACHE_CHECK([tm_tzadj in struct tm], tcl_cv_member_tm_tzadj, [
-	AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
-	    tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no)])
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm tm; (void)tm.tm_tzadj;]])],
+	    [tcl_cv_member_tm_tzadj=yes],
+	    [tcl_cv_member_tm_tzadj=no])])
     if test $tcl_cv_member_tm_tzadj = yes ; then
 	AC_DEFINE(HAVE_TM_TZADJ, 1, [Should we use the tm_tzadj field of struct tm?])
     fi
 
     AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff, [
-	AC_TRY_COMPILE([#include <time.h>], [struct tm tm; (void)tm.tm_gmtoff;],
-	    tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no)])
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm tm; (void)tm.tm_gmtoff;]])],
+	    [tcl_cv_member_tm_gmtoff=yes],
+	    [tcl_cv_member_tm_gmtoff=no])])
     if test $tcl_cv_member_tm_gmtoff = yes ; then
 	AC_DEFINE(HAVE_TM_GMTOFF, 1, [Should we use the tm_gmtoff field of struct tm?])
     fi
 
     #
     # Its important to include time.h in this check, as some systems
     # (like convex) have timezone functions, etc.
     #
     AC_CACHE_CHECK([long timezone variable], tcl_cv_timezone_long, [
-	AC_TRY_COMPILE([#include <time.h>],
-	    [extern long timezone;
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>
+#include <stdlib.h>]],
+	[[extern long timezone;
 	    timezone += 1;
-	    exit (0);],
-	    tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no)])
+	    exit (0);]])],
+	    [tcl_cv_timezone_long=yes], [tcl_cv_timezone_long=no])])
     if test $tcl_cv_timezone_long = yes ; then
 	AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
     else
 	#
 	# On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
 	#
 	AC_CACHE_CHECK([time_t timezone variable], tcl_cv_timezone_time, [
-	    AC_TRY_COMPILE([#include <time.h>],
-		[extern time_t timezone;
+	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>
+#include <stdlib.h>]],
+	    [[extern time_t timezone;
 		timezone += 1;
-		exit (0);],
-		tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no)])
+		exit (0);]])],
+		[tcl_cv_timezone_time=yes], [tcl_cv_timezone_time=no])])
 	if test $tcl_cv_timezone_time = yes ; then
 	    AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
 	fi
     fi
 ])
@@ -2168,12 +2189,13 @@
 
 #--------------------------------------------------------------------
 # SC_TCL_LINK_LIBS
 #
 #	Search for the libraries needed to link the Tcl shell.
-#	Things like the math library (-lm) and socket stuff (-lsocket vs.
-#	-lnsl) or thread library (-lpthread) are dealt with here.
+#	Things like the math library (-lm), socket stuff (-lsocket vs.
+#	-lnsl), zlib (-lz) and libtommath (-ltommath) or thread library
+#	(-lpthread) are dealt with here.
 #
 # Arguments:
 #	None.
 #
 # Results:
@@ -2311,15 +2333,15 @@
 #
 #--------------------------------------------------------------------
 
 AC_DEFUN([SC_TCL_EARLY_FLAG],[
     AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]),
-	AC_TRY_COMPILE([$2], $3, [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,
-	    AC_TRY_COMPILE([[#define ]$1[ 1
-]$2], $3,
-		[tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
-		[tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)))
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$2]], [[$3]])],
+	    [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no,[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[[#define ]$1[ 1
+]$2]], [[$3]])],
+	[tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
+	[tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)]))
     if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then
 	AC_DEFINE($1, 1, [Add the ]$1[ flag when building])
 	tcl_flags="$tcl_flags $1"
     fi
 ])
@@ -2350,11 +2372,10 @@
 #
 # Results:
 #
 #	Might define the following vars:
 #		TCL_WIDE_INT_IS_LONG
-#		TCL_WIDE_INT_TYPE
 #		HAVE_STRUCT_DIRENT64, HAVE_DIR64
 #		HAVE_STRUCT_STAT64
 #		HAVE_TYPE_OFF64_T
 #
 #--------------------------------------------------------------------
@@ -2361,59 +2382,52 @@
 
 AC_DEFUN([SC_TCL_64BIT_FLAGS], [
     AC_MSG_CHECKING([for 64-bit integer type])
     AC_CACHE_VAL(tcl_cv_type_64bit,[
 	tcl_cv_type_64bit=none
-	# See if the compiler knows natively about __int64
-	AC_TRY_COMPILE(,[__int64 value = (__int64) 0;],
-	    tcl_type_64bit=__int64, tcl_type_64bit="long long")
 	# See if we could use long anyway  Note that we substitute in the
 	# type that is our current guess for a 64-bit type inside this check
 	# program, so it should be modified only carefully...
-        AC_TRY_COMPILE(,[switch (0) {
-            case 1: case (sizeof(]${tcl_type_64bit}[)==sizeof(long)): ;
-        }],tcl_cv_type_64bit=${tcl_type_64bit})])
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[switch (0) {
+            case 1: case (sizeof(long long)==sizeof(long)): ;
+        }]])],[tcl_cv_type_64bit="long long"],[])])
     if test "${tcl_cv_type_64bit}" = none ; then
 	AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, [Do 'long' and 'long long' have the same size (64-bit)?])
 	AC_MSG_RESULT([yes])
     else
-	AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit},
-	    [What type should be used to define wide integers?])
-	AC_MSG_RESULT([${tcl_cv_type_64bit}])
-
 	# Now check for auxiliary declarations
 	AC_CACHE_CHECK([for struct dirent64], tcl_cv_struct_dirent64,[
-	    AC_TRY_COMPILE([#include <sys/types.h>
-#include <dirent.h>],[struct dirent64 p;],
-		tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)])
+	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
+#include <dirent.h>]], [[struct dirent64 p;]])],
+		[tcl_cv_struct_dirent64=yes],[tcl_cv_struct_dirent64=no])])
 	if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
 	    AC_DEFINE(HAVE_STRUCT_DIRENT64, 1, [Is 'struct dirent64' in <sys/types.h>?])
 	fi
 
 	AC_CACHE_CHECK([for DIR64], tcl_cv_DIR64,[
-	    AC_TRY_COMPILE([#include <sys/types.h>
-#include <dirent.h>],[struct dirent64 *p; DIR64 d = opendir64(".");
-            p = readdir64(d); rewinddir64(d); closedir64(d);],
-		tcl_cv_DIR64=yes,tcl_cv_DIR64=no)])
+	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
+#include <dirent.h>]], [[struct dirent64 *p; DIR64 d = opendir64(".");
+            p = readdir64(d); rewinddir64(d); closedir64(d);]])],
+		[tcl_cv_DIR64=yes], [tcl_cv_DIR64=no])])
 	if test "x${tcl_cv_DIR64}" = "xyes" ; then
 	    AC_DEFINE(HAVE_DIR64, 1, [Is 'DIR64' in <sys/types.h>?])
 	fi
 
 	AC_CACHE_CHECK([for struct stat64], tcl_cv_struct_stat64,[
-	    AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat64 p;
-],
-		tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)])
+	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[struct stat64 p;
+]])],
+		[tcl_cv_struct_stat64=yes], [tcl_cv_struct_stat64=no])])
 	if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
 	    AC_DEFINE(HAVE_STRUCT_STAT64, 1, [Is 'struct stat64' in <sys/stat.h>?])
 	fi
 
 	AC_CHECK_FUNCS(open64 lseek64)
 	AC_MSG_CHECKING([for off64_t])
 	AC_CACHE_VAL(tcl_cv_type_off64_t,[
-	    AC_TRY_COMPILE([#include <sys/types.h>],[off64_t offset;
-],
-		tcl_cv_type_off64_t=yes,tcl_cv_type_off64_t=no)])
+	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]], [[off64_t offset;
+]])],
+		[tcl_cv_type_off64_t=yes], [tcl_cv_type_off64_t=no])])
 	dnl Define HAVE_TYPE_OFF64_T only when the off64_t type and the
 	dnl functions lseek64 and open64 are defined.
 	if test "x${tcl_cv_type_off64_t}" = "xyes" && \
 	        test "x${ac_cv_func_lseek64}" = "xyes" && \
 	        test "x${ac_cv_func_open64}" = "xyes" ; then
@@ -2442,19 +2456,19 @@
 #
 #--------------------------------------------------------------------
 
 AC_DEFUN([SC_TCL_CFG_ENCODING], [
     AC_ARG_WITH(encoding,
-	AC_HELP_STRING([--with-encoding],
-	    [encoding for configuration values (default: iso8859-1)]),
-	with_tcencoding=${withval})
+	AS_HELP_STRING([--with-encoding],
+	    [encoding for configuration values (default: utf-8)]),
+	[with_tcencoding=${withval}])
 
     if test x"${with_tcencoding}" != x ; then
 	AC_DEFINE_UNQUOTED(TCL_CFGVAL_ENCODING,"${with_tcencoding}",
 	    [What encoding should be used for embedded configuration info?])
     else
-	AC_DEFINE(TCL_CFGVAL_ENCODING,"iso8859-1",
+	AC_DEFINE(TCL_CFGVAL_ENCODING,"utf-8",
 	    [What encoding should be used for embedded configuration info?])
     fi
 ])
 
 #--------------------------------------------------------------------
@@ -2475,15 +2489,15 @@
 
 AC_DEFUN([SC_TCL_CHECK_BROKEN_FUNC],[
     AC_CHECK_FUNC($1, tcl_ok=1, tcl_ok=0)
     if test ["$tcl_ok"] = 1; then
 	AC_CACHE_CHECK([proper ]$1[ implementation], [tcl_cv_]$1[_unbroken],
-	    AC_TRY_RUN([[
+	    AC_RUN_IFELSE([AC_LANG_SOURCE([[[
 #include <stdlib.h>
 #include <string.h>
-int main() {]$2[}]],[tcl_cv_]$1[_unbroken]=ok,
-		[tcl_cv_]$1[_unbroken]=broken,[tcl_cv_]$1[_unbroken]=unknown))
+int main() {]$2[}]]])],[tcl_cv_$1_unbroken=ok],
+		[tcl_cv_$1_unbroken=broken],[tcl_cv_$1_unbroken=unknown]))
 	if test ["$tcl_cv_]$1[_unbroken"] = "ok"; then
 	    tcl_ok=1
 	else
 	    tcl_ok=0
 	fi
@@ -2524,13 +2538,13 @@
     tcl_cv_api_gethostbyaddr_r=yes],[tcl_cv_api_gethostbyaddr_r=no],[#include <netdb.h>])
 ])
 
 AC_DEFUN([SC_TCL_GETHOSTBYADDR_R_TYPE], [AC_CHECK_FUNC(gethostbyaddr_r, [
     AC_CACHE_CHECK([for gethostbyaddr_r with 7 args], tcl_cv_api_gethostbyaddr_r_7, [
-    AC_TRY_COMPILE([
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	#include <netdb.h>
-    ], [
+    ]], [[
 	char *addr;
 	int length;
 	int type;
 	struct hostent *result;
 	char buffer[2048];
@@ -2537,20 +2551,20 @@
 	int buflen = 2048;
 	int h_errnop;
 
 	(void) gethostbyaddr_r(addr, length, type, result, buffer, buflen,
 			       &h_errnop);
-    ], tcl_cv_api_gethostbyaddr_r_7=yes, tcl_cv_api_gethostbyaddr_r_7=no)])
+    ]])],[tcl_cv_api_gethostbyaddr_r_7=yes],[tcl_cv_api_gethostbyaddr_r_7=no])])
     tcl_ok=$tcl_cv_api_gethostbyaddr_r_7
     if test "$tcl_ok" = yes; then
 	AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1,
 	    [Define to 1 if gethostbyaddr_r takes 7 args.])
     else
 	AC_CACHE_CHECK([for gethostbyaddr_r with 8 args], tcl_cv_api_gethostbyaddr_r_8, [
-	AC_TRY_COMPILE([
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	    #include <netdb.h>
-	], [
+	]], [[
 	    char *addr;
 	    int length;
 	    int type;
 	    struct hostent *result, *resultp;
 	    char buffer[2048];
@@ -2557,11 +2571,11 @@
 	    int buflen = 2048;
 	    int h_errnop;
 
 	    (void) gethostbyaddr_r(addr, length, type, result, buffer, buflen,
 				   &resultp, &h_errnop);
-	], tcl_cv_api_gethostbyaddr_r_8=yes, tcl_cv_api_gethostbyaddr_r_8=no)])
+	]])],[tcl_cv_api_gethostbyaddr_r_8=yes],[tcl_cv_api_gethostbyaddr_r_8=no])])
 	tcl_ok=$tcl_cv_api_gethostbyaddr_r_8
 	if test "$tcl_ok" = yes; then
 	    AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1,
 		[Define to 1 if gethostbyaddr_r takes 8 args.])
 	fi
@@ -2605,53 +2619,53 @@
     tcl_cv_api_gethostbyname_r=yes],[tcl_cv_api_gethostbyname_r=no],[#include <netdb.h>])
 ])
 
 AC_DEFUN([SC_TCL_GETHOSTBYNAME_R_TYPE], [AC_CHECK_FUNC(gethostbyname_r, [
     AC_CACHE_CHECK([for gethostbyname_r with 6 args], tcl_cv_api_gethostbyname_r_6, [
-    AC_TRY_COMPILE([
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	#include <netdb.h>
-    ], [
+    ]], [[
 	char *name;
 	struct hostent *he, *res;
 	char buffer[2048];
 	int buflen = 2048;
 	int h_errnop;
 
 	(void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop);
-    ], tcl_cv_api_gethostbyname_r_6=yes, tcl_cv_api_gethostbyname_r_6=no)])
+    ]])],[tcl_cv_api_gethostbyname_r_6=yes],[tcl_cv_api_gethostbyname_r_6=no])])
     tcl_ok=$tcl_cv_api_gethostbyname_r_6
     if test "$tcl_ok" = yes; then
 	AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1,
 	    [Define to 1 if gethostbyname_r takes 6 args.])
     else
 	AC_CACHE_CHECK([for gethostbyname_r with 5 args], tcl_cv_api_gethostbyname_r_5, [
-	AC_TRY_COMPILE([
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	    #include <netdb.h>
-	], [
+	]], [[
 	    char *name;
 	    struct hostent *he;
 	    char buffer[2048];
 	    int buflen = 2048;
 	    int h_errnop;
 
 	    (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop);
-	], tcl_cv_api_gethostbyname_r_5=yes, tcl_cv_api_gethostbyname_r_5=no)])
+	]])],[tcl_cv_api_gethostbyname_r_5=yes],[tcl_cv_api_gethostbyname_r_5=no])])
 	tcl_ok=$tcl_cv_api_gethostbyname_r_5
 	if test "$tcl_ok" = yes; then
 	    AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1,
 		[Define to 1 if gethostbyname_r takes 5 args.])
 	else
 	    AC_CACHE_CHECK([for gethostbyname_r with 3 args], tcl_cv_api_gethostbyname_r_3, [
-	    AC_TRY_COMPILE([
+	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 		#include <netdb.h>
-	    ], [
+	    ]], [[
 		char *name;
 		struct hostent *he;
 		struct hostent_data data;
 
 		(void) gethostbyname_r(name, he, &data);
-	    ], tcl_cv_api_gethostbyname_r_3=yes, tcl_cv_api_gethostbyname_r_3=no)])
+	    ]])],[tcl_cv_api_gethostbyname_r_3=yes],[tcl_cv_api_gethostbyname_r_3=no])])
 	    tcl_ok=$tcl_cv_api_gethostbyname_r_3
 	    if test "$tcl_ok" = yes; then
 		AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1,
 		    [Define to 1 if gethostbyname_r takes 3 args.])
 	    fi
@@ -2681,38 +2695,38 @@
 #
 #--------------------------------------------------------------------
 
 AC_DEFUN([SC_TCL_GETPWUID_R], [AC_CHECK_FUNC(getpwuid_r, [
     AC_CACHE_CHECK([for getpwuid_r with 5 args], tcl_cv_api_getpwuid_r_5, [
-    AC_TRY_COMPILE([
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	#include <sys/types.h>
 	#include <pwd.h>
-    ], [
+    ]], [[
 	uid_t uid;
 	struct passwd pw, *pwp;
 	char buf[512];
 	int buflen = 512;
 
 	(void) getpwuid_r(uid, &pw, buf, buflen, &pwp);
-    ], tcl_cv_api_getpwuid_r_5=yes, tcl_cv_api_getpwuid_r_5=no)])
+    ]])],[tcl_cv_api_getpwuid_r_5=yes],[tcl_cv_api_getpwuid_r_5=no])])
     tcl_ok=$tcl_cv_api_getpwuid_r_5
     if test "$tcl_ok" = yes; then
 	AC_DEFINE(HAVE_GETPWUID_R_5, 1,
 	    [Define to 1 if getpwuid_r takes 5 args.])
     else
 	AC_CACHE_CHECK([for getpwuid_r with 4 args], tcl_cv_api_getpwuid_r_4, [
-	AC_TRY_COMPILE([
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	    #include <sys/types.h>
 	    #include <pwd.h>
-	], [
+	]], [[
 	    uid_t uid;
 	    struct passwd pw;
 	    char buf[512];
 	    int buflen = 512;
 
 	    (void)getpwnam_r(uid, &pw, buf, buflen);
-	], tcl_cv_api_getpwuid_r_4=yes, tcl_cv_api_getpwuid_r_4=no)])
+	]])],[tcl_cv_api_getpwuid_r_4=yes],[tcl_cv_api_getpwuid_r_4=no])])
 	tcl_ok=$tcl_cv_api_getpwuid_r_4
 	if test "$tcl_ok" = yes; then
 	    AC_DEFINE(HAVE_GETPWUID_R_4, 1,
 		[Define to 1 if getpwuid_r takes 4 args.])
 	fi
@@ -2741,38 +2755,38 @@
 #
 #--------------------------------------------------------------------
 
 AC_DEFUN([SC_TCL_GETPWNAM_R], [AC_CHECK_FUNC(getpwnam_r, [
     AC_CACHE_CHECK([for getpwnam_r with 5 args], tcl_cv_api_getpwnam_r_5, [
-    AC_TRY_COMPILE([
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	#include <sys/types.h>
 	#include <pwd.h>
-    ], [
+    ]], [[
 	char *name;
 	struct passwd pw, *pwp;
 	char buf[512];
 	int buflen = 512;
 
 	(void) getpwnam_r(name, &pw, buf, buflen, &pwp);
-    ], tcl_cv_api_getpwnam_r_5=yes, tcl_cv_api_getpwnam_r_5=no)])
+    ]])],[tcl_cv_api_getpwnam_r_5=yes],[tcl_cv_api_getpwnam_r_5=no])])
     tcl_ok=$tcl_cv_api_getpwnam_r_5
     if test "$tcl_ok" = yes; then
 	AC_DEFINE(HAVE_GETPWNAM_R_5, 1,
 	    [Define to 1 if getpwnam_r takes 5 args.])
     else
 	AC_CACHE_CHECK([for getpwnam_r with 4 args], tcl_cv_api_getpwnam_r_4, [
-	AC_TRY_COMPILE([
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	    #include <sys/types.h>
 	    #include <pwd.h>
-	], [
+	]], [[
 	    char *name;
 	    struct passwd pw;
 	    char buf[512];
 	    int buflen = 512;
 
 	    (void)getpwnam_r(name, &pw, buf, buflen);
-	], tcl_cv_api_getpwnam_r_4=yes, tcl_cv_api_getpwnam_r_4=no)])
+	]])],[tcl_cv_api_getpwnam_r_4=yes],[tcl_cv_api_getpwnam_r_4=no])])
 	tcl_ok=$tcl_cv_api_getpwnam_r_4
 	if test "$tcl_ok" = yes; then
 	    AC_DEFINE(HAVE_GETPWNAM_R_4, 1,
 		[Define to 1 if getpwnam_r takes 4 args.])
 	fi
@@ -2801,38 +2815,38 @@
 #
 #--------------------------------------------------------------------
 
 AC_DEFUN([SC_TCL_GETGRGID_R], [AC_CHECK_FUNC(getgrgid_r, [
     AC_CACHE_CHECK([for getgrgid_r with 5 args], tcl_cv_api_getgrgid_r_5, [
-    AC_TRY_COMPILE([
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	#include <sys/types.h>
 	#include <grp.h>
-    ], [
+    ]], [[
 	gid_t gid;
 	struct group gr, *grp;
 	char buf[512];
 	int buflen = 512;
 
 	(void) getgrgid_r(gid, &gr, buf, buflen, &grp);
-    ], tcl_cv_api_getgrgid_r_5=yes, tcl_cv_api_getgrgid_r_5=no)])
+    ]])],[tcl_cv_api_getgrgid_r_5=yes],[tcl_cv_api_getgrgid_r_5=no])])
     tcl_ok=$tcl_cv_api_getgrgid_r_5
     if test "$tcl_ok" = yes; then
 	AC_DEFINE(HAVE_GETGRGID_R_5, 1,
 	    [Define to 1 if getgrgid_r takes 5 args.])
     else
 	AC_CACHE_CHECK([for getgrgid_r with 4 args], tcl_cv_api_getgrgid_r_4, [
-	AC_TRY_COMPILE([
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	    #include <sys/types.h>
 	    #include <grp.h>
-	], [
+	]], [[
 	    gid_t gid;
 	    struct group gr;
 	    char buf[512];
 	    int buflen = 512;
 
 	    (void)getgrgid_r(gid, &gr, buf, buflen);
-	], tcl_cv_api_getgrgid_r_4=yes, tcl_cv_api_getgrgid_r_4=no)])
+	]])],[tcl_cv_api_getgrgid_r_4=yes],[tcl_cv_api_getgrgid_r_4=no])])
 	tcl_ok=$tcl_cv_api_getgrgid_r_4
 	if test "$tcl_ok" = yes; then
 	    AC_DEFINE(HAVE_GETGRGID_R_4, 1,
 		[Define to 1 if getgrgid_r takes 4 args.])
 	fi
@@ -2861,38 +2875,38 @@
 #
 #--------------------------------------------------------------------
 
 AC_DEFUN([SC_TCL_GETGRNAM_R], [AC_CHECK_FUNC(getgrnam_r, [
     AC_CACHE_CHECK([for getgrnam_r with 5 args], tcl_cv_api_getgrnam_r_5, [
-    AC_TRY_COMPILE([
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	#include <sys/types.h>
 	#include <grp.h>
-    ], [
+    ]], [[
 	char *name;
 	struct group gr, *grp;
 	char buf[512];
 	int buflen = 512;
 
 	(void) getgrnam_r(name, &gr, buf, buflen, &grp);
-    ], tcl_cv_api_getgrnam_r_5=yes, tcl_cv_api_getgrnam_r_5=no)])
+    ]])],[tcl_cv_api_getgrnam_r_5=yes],[tcl_cv_api_getgrnam_r_5=no])])
     tcl_ok=$tcl_cv_api_getgrnam_r_5
     if test "$tcl_ok" = yes; then
 	AC_DEFINE(HAVE_GETGRNAM_R_5, 1,
 	    [Define to 1 if getgrnam_r takes 5 args.])
     else
 	AC_CACHE_CHECK([for getgrnam_r with 4 args], tcl_cv_api_getgrnam_r_4, [
-	AC_TRY_COMPILE([
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	    #include <sys/types.h>
 	    #include <grp.h>
-	], [
+	]], [[
 	    char *name;
 	    struct group gr;
 	    char buf[512];
 	    int buflen = 512;
 
 	    (void)getgrnam_r(name, &gr, buf, buflen);
-	], tcl_cv_api_getgrnam_r_4=yes, tcl_cv_api_getgrnam_r_4=no)])
+	]])],[tcl_cv_api_getgrnam_r_4=yes],[tcl_cv_api_getgrnam_r_4=no])])
 	tcl_ok=$tcl_cv_api_getgrnam_r_4
 	if test "$tcl_ok" = yes; then
 	    AC_DEFINE(HAVE_GETGRNAM_R_4, 1,
 		[Define to 1 if getgrnam_r takes 4 args.])
 	fi
@@ -2995,22 +3009,44 @@
 # Arguments:
 #	none
 #
 # Results:
 #	Substitutes the following vars:
-#		ZIP_PROG
+#       MACHER_PROG
+#       ZIP_PROG
 #       ZIP_PROG_OPTIONS
 #       ZIP_PROG_VFSSEARCH
 #       ZIP_INSTALL_OBJS
 #------------------------------------------------------------------------
 
 AC_DEFUN([SC_ZIPFS_SUPPORT], [
+    MACHER_PROG=""
     ZIP_PROG=""
     ZIP_PROG_OPTIONS=""
     ZIP_PROG_VFSSEARCH=""
     ZIP_INSTALL_OBJS=""
 
+    AC_MSG_CHECKING([for macher])
+    AC_CACHE_VAL(ac_cv_path_macher, [
+    search_path=`echo ${PATH} | sed -e 's/:/ /g'`
+    for dir in $search_path ; do
+        for j in `ls -r $dir/macher 2> /dev/null` \
+            `ls -r $dir/macher 2> /dev/null` ; do
+        if test x"$ac_cv_path_macher" = x ; then
+            if test -f "$j" ; then
+            ac_cv_path_macher=$j
+            break
+            fi
+        fi
+        done
+    done
+    ])
+    if test -f "$ac_cv_path_macher" ; then
+        MACHER_PROG="$ac_cv_path_macher"
+        AC_MSG_RESULT([$MACHER_PROG])
+        AC_MSG_RESULT([Found macher in environment])
+    fi
     AC_MSG_CHECKING([for zip])
     AC_CACHE_VAL(ac_cv_path_zip, [
     search_path=`echo ${PATH} | sed -e 's/:/ /g'`
     for dir in $search_path ; do
         for j in `ls -r $dir/zip 2> /dev/null` \
@@ -3038,14 +3074,15 @@
         ZIP_PROG_OPTIONS="-o -r"
         ZIP_PROG_VFSSEARCH="*"
         ZIP_INSTALL_OBJS="minizip${EXEEXT_FOR_BUILD}"
         AC_MSG_RESULT([No zip found on PATH. Building minizip])
     fi
+    AC_SUBST(MACHER_PROG)
     AC_SUBST(ZIP_PROG)
     AC_SUBST(ZIP_PROG_OPTIONS)
     AC_SUBST(ZIP_PROG_VFSSEARCH)
     AC_SUBST(ZIP_INSTALL_OBJS)
 ])
 
 # Local Variables:
 # mode: autoconf
 # End:

Index: unix/tk.spec
==================================================================
--- unix/tk.spec
+++ unix/tk.spec
@@ -2,11 +2,11 @@
 
 %{!?directory:%define directory /usr/local}
 
 Name:          tk
 Summary:       Tk graphical toolkit for the Tcl scripting language.
-Version:       8.7a4
+Version:       8.7a6
 Release:       2
 License:       BSD
 Group:         Development/Languages
 Source:        http://prdownloads.sourceforge.net/tcl/tk%{version}-src.tar.gz
 URL:           https://www.tcl-lang.org/

Index: unix/tkAppInit.c
==================================================================
--- unix/tkAppInit.c
+++ unix/tkAppInit.c
@@ -14,16 +14,20 @@
 
 #undef BUILD_tk
 #undef STATIC_BUILD
 #include "tk.h"
 #include "tkPort.h"
+#if TCL_MAJOR_VERSION < 9 && TCL_MINOR_VERSION < 7
+#   define Tcl_LibraryInitProc Tcl_PackageInitProc
+#   define Tcl_StaticLibrary Tcl_StaticPackage
+#endif
 
 #ifdef TK_TEST
 #ifdef __cplusplus
 extern "C" {
 #endif
-extern Tcl_PackageInitProc Tktest_Init;
+extern Tcl_LibraryInitProc Tktest_Init;
 #ifdef __cplusplus
 }
 #endif
 #endif /* TK_TEST */
 
@@ -35,11 +39,15 @@
 
 #ifndef TK_LOCAL_APPINIT
 #define TK_LOCAL_APPINIT Tcl_AppInit
 #endif
 #ifndef MODULE_SCOPE
-#   define MODULE_SCOPE extern
+#   ifdef __cplusplus
+#	define MODULE_SCOPE extern "C"
+#   else
+#	define MODULE_SCOPE extern
+#   endif
 #endif
 MODULE_SCOPE int TK_LOCAL_APPINIT(Tcl_Interp *);
 MODULE_SCOPE int main(int, char **);
 
 /*
@@ -117,24 +125,23 @@
     }
 
     if (Tk_Init(interp) == TCL_ERROR) {
 	return TCL_ERROR;
     }
-    Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);
+    Tcl_StaticLibrary(interp, "Tk", Tk_Init, Tk_SafeInit);
 
 #if defined(USE_CUSTOM_EXIT_PROC)
     if (TkpWantsExitProc()) {
-	/* The cast below avoids warnings from old gcc compilers. */
-	Tcl_SetExitProc((void *)TkpExitProc);
+	Tcl_SetExitProc(TkpExitProc);
     }
 #endif
 
 #ifdef TK_TEST
     if (Tktest_Init(interp) == TCL_ERROR) {
 	return TCL_ERROR;
     }
-    Tcl_StaticPackage(interp, "Tktest", Tktest_Init, 0);
+    Tcl_StaticLibrary(interp, "Tktest", Tktest_Init, 0);
 #endif /* TK_TEST */
 
     /*
      * Call the init procedures for included packages. Each call should look
      * like this:

Index: unix/tkConfig.h.in
==================================================================
--- unix/tkConfig.h.in
+++ unix/tkConfig.h.in
@@ -20,11 +20,11 @@
 #undef HAVE_DIR64
 
 /* Compiler support for module scope symbols */
 #undef HAVE_HIDDEN
 
-/* Do we have the intptr_t type? */
+/* Define to 1 if the system has the type `intptr_t'. */
 #undef HAVE_INTPTR_T
 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -32,13 +32,10 @@
 #undef HAVE_LIBXFT
 
 /* Define to 1 if you have the `lseek64' function. */
 #undef HAVE_LSEEK64
 
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
 /* Define to 1 if you have the `open64' function. */
 #undef HAVE_OPEN64
 
 /* Does struct password have a pw_gecos field? */
 #undef HAVE_PW_GECOS
@@ -46,10 +43,13 @@
 /* Do we have <stdbool.h>? */
 #undef HAVE_STDBOOL_H
 
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
 
 /* Define to 1 if you have the <stdlib.h> header file. */
 #undef HAVE_STDLIB_H
 
 /* Define to 1 if you have the <strings.h> header file. */
@@ -77,11 +77,11 @@
 #undef HAVE_SYS_TYPES_H
 
 /* Is off64_t in <sys/types.h>? */
 #undef HAVE_TYPE_OFF64_T
 
-/* Do we have the uintptr_t type? */
+/* Define to 1 if the system has the type `uintptr_t'. */
 #undef HAVE_UINTPTR_T
 
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
@@ -131,11 +131,13 @@
 #undef PACKAGE_VERSION
 
 /* Is this a static build? */
 #undef STATIC_BUILD
 
-/* Define to 1 if you have the ANSI C header files. */
+/* Define to 1 if all of the C90 standard headers exist (not just the ones
+   required in a freestanding environment). This macro is provided for
+   backward compatibility; new code need not use it. */
 #undef STDC_HEADERS
 
 /* What encoding should be used for embedded configuration info? */
 #undef TCL_CFGVAL_ENCODING
 
@@ -158,16 +160,10 @@
 #undef TCL_SHLIB_EXT
 
 /* Do 'long' and 'long long' have the same size (64-bit)? */
 #undef TCL_WIDE_INT_IS_LONG
 
-/* What type should be used to define wide integers? */
-#undef TCL_WIDE_INT_TYPE
-
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
-#undef TIME_WITH_SYS_TIME
-
 /* Is Tk built as a framework? */
 #undef TK_FRAMEWORK
 
 /* Are TkAqua debug messages enabled? */
 #undef TK_MAC_DEBUG
@@ -181,10 +177,13 @@
 #else
 # ifndef WORDS_BIGENDIAN
 #  undef WORDS_BIGENDIAN
 # endif
 #endif
+
+/* Are we building with zipfs enabled? */
+#undef ZIPFS_BUILD
 
 /* Are Darwin SUSv3 extensions available? */
 #undef _DARWIN_C_SOURCE
 
 /* Add the _ISOC99_SOURCE flag when building */
@@ -209,44 +208,34 @@
 #undef _XOPEN_SOURCE
 
 /* Do we want to use the XOPEN network library? */
 #undef _XOPEN_SOURCE_EXTENDED
 
-/* Define to 1 if type `char' is unsigned and you are not using gcc.  */
+/* Define to 1 if type `char' is unsigned and your compiler does not
+   predefine this macro.  */
 #ifndef __CHAR_UNSIGNED__
 # undef __CHAR_UNSIGNED__
 #endif
 
-/* Define to `int' if <sys/types.h> doesn't define. */
-#undef gid_t
-
 /* Define to `__inline__' or `__inline' if that's what the C compiler
    calls it, or to nothing if 'inline' is not supported under any name.  */
 #ifndef __cplusplus
 #undef inline
 #endif
 
-/* Signed integer type wide enough to hold a pointer. */
-#undef intptr_t
-
 /* Define to `int' if <sys/types.h> does not define. */
 #undef mode_t
 
-/* Define to `int' if <sys/types.h> does not define. */
+/* Define as a signed integer type capable of holding a process identifier. */
 #undef pid_t
 
 /* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t
 
-/* Define to `int' if <sys/types.h> doesn't define. */
-#undef uid_t
-
-/* Unsigned integer type wide enough to hold a pointer. */
-#undef uintptr_t
-
 
     /* Undef unused package specific autoheader defines so that we can
      * include both tclConfig.h and tkConfig.h at the same time: */
     /* override */ #undef PACKAGE_NAME
-    /* override */ #undef PACKAGE_STRING
     /* override */ #undef PACKAGE_TARNAME
+    /* override */ #undef PACKAGE_VERSION
+    /* override */ #undef PACKAGE_STRING
     #endif /* _TKCONFIG */

Index: unix/tkUnix.c
==================================================================
--- unix/tkUnix.c
+++ unix/tkUnix.c
@@ -3,11 +3,11 @@
  *
  *	This file contains procedures that are UNIX/X-specific, and will
  *	probably have to be written differently for Windows or Macintosh
  *	platforms.
  *
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright © 1995 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -202,12 +202,16 @@
  *----------------------------------------------------------------------
  */
 
 long
 Tk_GetUserInactiveTime(
-    Display *dpy)		/* The display for which to query the inactive
+ #ifdef HAVE_XSS
+   Display *dpy)		/* The display for which to query the inactive
 				 * time. */
+#else
+  TCL_UNUSED(Display *))
+#endif /* HAVE_XSS */
 {
     long inactiveTime = -1;
 #ifdef HAVE_XSS
     int eventBase, errorBase, major, minor;
 

Index: unix/tkUnix3d.c
==================================================================
--- unix/tkUnix3d.c
+++ unix/tkUnix3d.c
@@ -2,20 +2,22 @@
  * tkUnix3d.c --
  *
  *	This file contains the platform specific routines for drawing 3d
  *	borders in the Motif style.
  *
- * Copyright (c) 1996 by Sun Microsystems, Inc.
+ * Copyright © 1996 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
 #include "tkInt.h"
 #include "tk3d.h"
 
-#if !(defined(_WIN32) || defined(MAC_OSX_TK))
+#if defined(MAC_OSX_TK)
+#include "tkMacOSXInt.h"
+#else
 #include "tkUnixInt.h"
 #endif
 
 /*
  * This structure is used to keep track of the extra colors used by Unix 3D

Index: unix/tkUnixButton.c
==================================================================
--- unix/tkUnixButton.c
+++ unix/tkUnixButton.c
@@ -1,11 +1,11 @@
 /*
  * tkUnixButton.c --
  *
  *	This file implements the Unix specific portion of the button widgets.
  *
- * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: unix/tkUnixColor.c
==================================================================
--- unix/tkUnixColor.c
+++ unix/tkUnixColor.c
@@ -2,11 +2,11 @@
  * tkUnixColor.c --
  *
  *	This file contains the platform specific color routines needed for X
  *	support.
  *
- * Copyright (c) 1996 by Sun Microsystems, Inc.
+ * Copyright © 1996 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -421,10 +421,11 @@
  *	None.
  *
  *----------------------------------------------------------------------
  */
 
+#undef TkpCmapStressed
 int
 TkpCmapStressed(
     Tk_Window tkwin,		/* Window that identifies the display
 				 * containing the colormap. */
     Colormap colormap)		/* Colormap to check for stress. */

Index: unix/tkUnixConfig.c
==================================================================
--- unix/tkUnixConfig.c
+++ unix/tkUnixConfig.c
@@ -2,11 +2,11 @@
  * tkUnixConfig.c --
  *
  *	This module implements the Unix system defaults for the configuration
  *	package.
  *
- * Copyright (c) 1997 by Sun Microsystems, Inc.
+ * Copyright © 1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -14,11 +14,11 @@
 
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpGetSystemDefault --
+ * Tk_GetSystemDefault --
  *
  *	Given a dbName and className for a configuration option, return a
  *	string representation of the option.
  *
  * Results:
@@ -31,11 +31,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 Tcl_Obj *
-TkpGetSystemDefault(
+Tk_GetSystemDefault(
     Tk_Window tkwin,		/* A window to use. */
     const char *dbName,		/* The option database name. */
     const char *className)	/* The name of the option class. */
 {
     (void)tkwin;

Index: unix/tkUnixCursor.c
==================================================================
--- unix/tkUnixCursor.c
+++ unix/tkUnixCursor.c
@@ -1,11 +1,11 @@
 /*
  * tkUnixCursor.c --
  *
  *	This file contains X specific cursor manipulation routines.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -178,11 +178,11 @@
 #ifndef CURSORFONT
 #define CURSORFONT "cursor"
 #endif
 
 static Cursor		CreateCursorFromTableOrFile(Tcl_Interp *interp,
-			    Tk_Window tkwin, int argc, const char **argv,
+			    Tk_Window tkwin, TkSizeT argc, const char **argv,
 			    const struct TkCursorName *tkCursorPtr);
 
 /*
  *----------------------------------------------------------------------
  *
@@ -208,11 +208,11 @@
     Tk_Uid string)		/* Description of cursor. See manual entry for
 				 * details on legal syntax. */
 {
     TkUnixCursor *cursorPtr = NULL;
     Cursor cursor = None;
-    int argc;
+    TkSizeT argc;
     const char **argv = NULL;
     Display *display = Tk_Display(tkwin);
     int inTkTable = 0;
     const struct TkCursorName *tkCursorPtr = NULL;
 
@@ -379,11 +379,11 @@
 
 static Cursor
 CreateCursorFromTableOrFile(
     Tcl_Interp *interp,		/* Interpreter to use for error reporting. */
     Tk_Window tkwin,		/* Window in which cursor will be used. */
-    int argc,
+    TkSizeT argc,
     const char **argv,		/* Cursor spec parsed into elements. */
     const struct TkCursorName *tkCursorPtr)
 				/* Non-NULL when cursor is defined in Tk
 				 * table. */
 {

Index: unix/tkUnixDefault.h
==================================================================
--- unix/tkUnixDefault.h
+++ unix/tkUnixDefault.h
@@ -54,10 +54,11 @@
 #define DEF_BUTTON_COMPOUND		"none"
 #define DEF_BUTTON_COMMAND		""
 #define DEF_BUTTON_DEFAULT		"disabled"
 #define DEF_BUTTON_DISABLED_FG_COLOR	DISABLED
 #define DEF_BUTTON_DISABLED_FG_MONO	""
+#define DEF_LABEL_FG			BLACK
 #define DEF_BUTTON_FG			BLACK
 #define DEF_CHKRAD_FG			DEF_BUTTON_FG
 #define DEF_BUTTON_FONT			"TkDefaultFont"
 #define DEF_BUTTON_HEIGHT		"0"
 #define DEF_BUTTON_HIGHLIGHT_BG_COLOR	DEF_BUTTON_BG_COLOR
@@ -86,11 +87,10 @@
 #define DEF_BUTTON_STATE		"normal"
 #define DEF_LABEL_TAKE_FOCUS		"0"
 #define DEF_BUTTON_TAKE_FOCUS		NULL
 #define DEF_BUTTON_TEXT			""
 #define DEF_BUTTON_TEXT_VARIABLE	""
-#define DEF_BUTTON_UNDERLINE		"-1"
 #define DEF_BUTTON_VALUE		""
 #define DEF_BUTTON_WIDTH		"0"
 #define DEF_BUTTON_WRAP_LENGTH		"0"
 #define DEF_RADIOBUTTON_VARIABLE	"selectedButton"
 #define DEF_CHECKBUTTON_VARIABLE	""
@@ -266,11 +266,10 @@
 #define DEF_MENU_ENTRY_STATE		"normal"
 #define DEF_MENU_ENTRY_VALUE		NULL
 #define DEF_MENU_ENTRY_CHECK_VARIABLE	NULL
 #define DEF_MENU_ENTRY_RADIO_VARIABLE	"selectedButton"
 #define DEF_MENU_ENTRY_SELECT		NULL
-#define DEF_MENU_ENTRY_UNDERLINE	"-1"
 
 /*
  * Defaults for menus overall:
  */
 
@@ -331,11 +330,10 @@
 #define DEF_MENUBUTTON_RELIEF		"flat"
 #define DEF_MENUBUTTON_STATE		"normal"
 #define DEF_MENUBUTTON_TAKE_FOCUS	"0"
 #define DEF_MENUBUTTON_TEXT		""
 #define DEF_MENUBUTTON_TEXT_VARIABLE	""
-#define DEF_MENUBUTTON_UNDERLINE	"-1"
 #define DEF_MENUBUTTON_WIDTH		"0"
 #define DEF_MENUBUTTON_WRAP_LENGTH	"0"
 
 /*
  * Defaults for messages:

Index: unix/tkUnixDialog.c
==================================================================
--- unix/tkUnixDialog.c
+++ unix/tkUnixDialog.c
@@ -1,11 +1,11 @@
 /*
  * tkUnixDialog.c --
  *
  *	Contains the Unix implementation of the common dialog boxes:
  *
- * Copyright (c) 1996 Sun Microsystems, Inc.
+ * Copyright © 1996 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -164,11 +164,11 @@
  *
  * Results:
  *	See user documentation.
  *
  * Side effects:
- *	None. The MessageBox window will be destroy before this procedure
+ *	None. The MessageBox window will be destroyed before this procedure
  *	returns.
  *
  *----------------------------------------------------------------------
  */
 

Index: unix/tkUnixDraw.c
==================================================================
--- unix/tkUnixDraw.c
+++ unix/tkUnixDraw.c
@@ -1,11 +1,11 @@
 /*
  * tkUnixDraw.c --
  *
  *	This file contains X specific drawing routines.
  *
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright © 1995 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -173,11 +173,11 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpDrawHighlightBorder --
+ * Tk_DrawHighlightBorder --
  *
  *	This function draws a rectangular ring around the outside of a widget
  *	to indicate that it has received the input focus.
  *
  *      On Unix, we just draw the simple inset ring. On other sytems, e.g. the
@@ -193,11 +193,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 void
-TkpDrawHighlightBorder(
+Tk_DrawHighlightBorder(
     Tk_Window tkwin,
     GC fgGC,
     GC bgGC,
     int highlightWidth,
     Drawable drawable)

Index: unix/tkUnixEmbed.c
==================================================================
--- unix/tkUnixEmbed.c
+++ unix/tkUnixEmbed.c
@@ -4,11 +4,11 @@
  *	This file contains platform-specific functions for UNIX to provide
  *	basic operations needed for application embedding (where one
  *	application can use as its main window an internal window from some
  *	other application). Also includes code to support busy windows.
  *
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -69,11 +69,11 @@
 static void		EmbedWindowDeleted(TkWindow *winPtr);
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpUseWindow --
+ * Tk_UseWindow --
  *
  *	This function causes a Tk window to use a given X window as its parent
  *	window, rather than the root window for the screen. It is invoked by
  *	an embedded application to specify the window in which it is embedded.
  *
@@ -89,11 +89,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 int
-TkpUseWindow(
+Tk_UseWindow(
     Tcl_Interp *interp,		/* If not NULL, used for error reporting if
 				 * string is bogus. */
     Tk_Window tkwin,		/* Tk window that does not yet have an
 				 * associated X window. */
     const char *string)		/* String identifying an X window to use for
@@ -192,11 +192,11 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpMakeWindow --
+ * Tk_MakeWindow --
  *
  *	Create an actual window system window object based on the current
  *	attributes of the specified TkWindow.
  *
  * Results:
@@ -207,17 +207,18 @@
  *
  *----------------------------------------------------------------------
  */
 
 Window
-TkpMakeWindow(
-    TkWindow *winPtr,		/* Tk's information about the window that is
+Tk_MakeWindow(
+    Tk_Window tkwin,		/* Tk's information about the window that is
 				 * to be instantiated. */
     Window parent)		/* Window system token for the parent in which
 				 * the window is to be created. */
 {
     Container *containerPtr;
+    TkWindow *winPtr = (TkWindow *) tkwin;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
             Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
 
     if (winPtr->flags & TK_EMBEDDED) {
 	/*
@@ -248,11 +249,11 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpMakeContainer --
+ * Tk_MakeContainer --
  *
  *	This function is called to indicate that a particular window will be a
  *	container for an embedded application. This changes certain aspects of
  *	the window's behavior, such as whether it will receive events anymore.
  *
@@ -264,11 +265,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 void
-TkpMakeContainer(
+Tk_MakeContainer(
     Tk_Window tkwin)		/* Token for a window that is about to become
 				 * a container. */
 {
     TkWindow *winPtr = (TkWindow *) tkwin;
     Container *containerPtr;
@@ -689,42 +690,42 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpGetOtherWindow --
+ * Tk_GetOtherWindow --
  *
  *	If both the container and embedded window are in the same process,
  *	this function will return either one, given the other.
  *
  * Results:
- *	If winPtr is a container, the return value is the token for the
+ *	If tkwin is a container, the return value is the token for the
  *	embedded window, and vice versa. If the "other" window isn't in this
  *	process, NULL is returned.
  *
  * Side effects:
  *	None.
  *
  *----------------------------------------------------------------------
  */
 
-TkWindow *
-TkpGetOtherWindow(
-    TkWindow *winPtr)		/* Tk's structure for a container or embedded
+Tk_Window
+Tk_GetOtherWindow(
+    Tk_Window tkwin)		/* Tk's structure for a container or embedded
 				 * window. */
 {
     Container *containerPtr;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
             Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
 
     for (containerPtr = tsdPtr->firstContainerPtr;
             containerPtr != NULL;
 	    containerPtr = containerPtr->nextPtr) {
-	if (containerPtr->embeddedPtr == winPtr) {
-	    return containerPtr->parentPtr;
-	} else if (containerPtr->parentPtr == winPtr) {
-	    return containerPtr->embeddedPtr;
+	if ((Tk_Window)containerPtr->embeddedPtr == tkwin) {
+	    return (Tk_Window)containerPtr->parentPtr;
+	} else if ((Tk_Window)containerPtr->parentPtr == tkwin) {
+	    return (Tk_Window)containerPtr->embeddedPtr;
 	}
     }
     return NULL;
 }
 
@@ -979,10 +980,11 @@
      */
 
     prevPtr = NULL;
     containerPtr = tsdPtr->firstContainerPtr;
     while (1) {
+	if (containerPtr == NULL) return;
 	if (containerPtr->embeddedPtr == winPtr) {
 	    containerPtr->wrapper = None;
 	    containerPtr->embeddedPtr = NULL;
 	    break;
 	}

Index: unix/tkUnixEvent.c
==================================================================
--- unix/tkUnixEvent.c
+++ unix/tkUnixEvent.c
@@ -2,11 +2,11 @@
  * tkUnixEvent.c --
  *
  *	This file implements an event source for X displays for the UNIX
  *	version of Tk.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -661,10 +661,11 @@
  *	Places new events on the Tk event queue.
  *
  *----------------------------------------------------------------------
  */
 
+#undef TkpSync
 void
 TkpSync(
     Display *display)		/* Display to sync. */
 {
     XSync(display, False);

Index: unix/tkUnixFocus.c
==================================================================
--- unix/tkUnixFocus.c
+++ unix/tkUnixFocus.c
@@ -2,11 +2,11 @@
  * tkUnixFocus.c --
  *
  *	This file contains platform specific functions that manage focus for
  *	Tk.
  *
- * Copyright (c) 1997 Sun Microsystems, Inc.
+ * Copyright © 1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: unix/tkUnixFont.c
==================================================================
--- unix/tkUnixFont.c
+++ unix/tkUnixFont.c
@@ -2,11 +2,11 @@
  * tkUnixFont.c --
  *
  *	Contains the Unix implementation of the platform-independent font
  *	package interface.
  *
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -236,18 +236,20 @@
 static unsigned		RankAttributes(FontAttributes *wantPtr,
 			    FontAttributes *gotPtr);
 static void		ReleaseFont(UnixFont *fontPtr);
 static void		ReleaseSubFont(Display *display, SubFont *subFontPtr);
 static int		SeenName(const char *name, Tcl_DString *dsPtr);
+#if TCL_MAJOR_VERSION < 9
 static int		Ucs2beToUtfProc(void *clientData, const char*src,
 			    int srcLen, int flags, Tcl_EncodingState*statePtr,
 			    char *dst, int dstLen, int *srcReadPtr,
 			    int *dstWrotePtr, int *dstCharsPtr);
 static int		UtfToUcs2beProc(void *clientData, const char*src,
 			    int srcLen, int flags, Tcl_EncodingState*statePtr,
 			    char *dst, int dstLen, int *srcReadPtr,
 			    int *dstWrotePtr, int *dstCharsPtr);
+#endif
 
 /*
  *-------------------------------------------------------------------------
  *
  * FontPkgCleanup --
@@ -310,11 +312,13 @@
 {
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
     SubFont dummy;
     int i;
+#if TCL_MAJOR_VERSION < 9
     Tcl_Encoding ucs2;
+#endif
 
     if (tsdPtr->controlFamily.encoding == NULL) {
 
 	Tcl_EncodingType type = {"X11ControlChars", ControlUtfProc, ControlUtfProc, NULL, NULL, 0};
 	tsdPtr->controlFamily.refCount = 2;
@@ -331,17 +335,19 @@
 	/*
 	 * UCS-2BE is unicode (UCS-2) in big-endian format. Define this if
 	 * if it doesn't exist yet. It is used in iso10646 fonts.
 	 */
 
+#if TCL_MAJOR_VERSION < 9
 	ucs2 = Tcl_GetEncoding(NULL, "ucs-2be");
 	if (ucs2 == NULL) {
 	    Tcl_EncodingType ucs2type = {"ucs-2be", Ucs2beToUtfProc, UtfToUcs2beProc, NULL, NULL, 2};
 	    Tcl_CreateEncoding(&ucs2type);
 	} else {
 	    Tcl_FreeEncoding(ucs2);
 	}
+#endif
 	Tcl_CreateThreadExitHandler(FontPkgCleanup, NULL);
     }
 }
 
 /*
@@ -456,10 +462,11 @@
  *	None.
  *
  *-------------------------------------------------------------------------
  */
 
+#if TCL_MAJOR_VERSION < 9
 static int
 Ucs2beToUtfProc(
     TCL_UNUSED(void *),		/* Not used. */
     const char *src,		/* Source string in Unicode. */
     int srcLen,			/* Source string length in bytes. */
@@ -551,10 +558,18 @@
  * Side effects:
  *	None.
  *
  *-------------------------------------------------------------------------
  */
+
+#if defined(USE_TCL_STUBS)
+/* Since the UCS-2BE encoding is only used when Tk 8.7 is dynamically loaded in Tcl 8.6,
+ * make sure that Tcl_UtfCharComplete is ALWAYS the pre-TIP #575 version,
+ * even though Tk 8.7 is being compiled with -DTCL_NO_DEPRECATED! */
+#   undef Tcl_UtfCharComplete
+#   define Tcl_UtfCharComplete ((int (*)(const char *, int))(void *)((&tclStubsPtr->tcl_PkgProvideEx)[326]))
+#endif
 
 static int
 UtfToUcs2beProc(
     TCL_UNUSED(void *),	/* TableEncodingData that specifies
 				 * encoding. */
@@ -625,10 +640,11 @@
     *srcReadPtr = src - srcStart;
     *dstWrotePtr = dst - dstStart;
     *dstCharsPtr = numChars;
     return result;
 }
+#endif
 
 /*
  *---------------------------------------------------------------------------
  *
  * TkpGetNativeFont --
@@ -1046,12 +1062,12 @@
 	for (p = source; p < end; ) {
 	    next = p + TkUtfToUniChar(p, &ch);
 	    thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr);
 	    if (thisSubFontPtr != lastSubFontPtr) {
 		familyPtr = lastSubFontPtr->familyPtr;
-		Tcl_UtfToExternalDString(familyPtr->encoding, source,
-			p - source, &runString);
+		(void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, source,
+			p - source, TCL_ENCODING_NOCOMPLAIN, &runString);
 		if (familyPtr->isTwoByteFont) {
 		    curX += XTextWidth16(lastSubFontPtr->fontStructPtr,
 			    (XChar2b *) Tcl_DStringValue(&runString),
 			    Tcl_DStringLength(&runString) / 2);
 		} else {
@@ -1064,12 +1080,12 @@
 		source = p;
 	    }
 	    p = next;
 	}
 	familyPtr = lastSubFontPtr->familyPtr;
-	Tcl_UtfToExternalDString(familyPtr->encoding, source, p - source,
-		&runString);
+	(void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, source, p - source,
+		TCL_ENCODING_NOCOMPLAIN, &runString);
 	if (familyPtr->isTwoByteFont) {
 	    curX += XTextWidth16(lastSubFontPtr->fontStructPtr,
 		    (XChar2b *) Tcl_DStringValue(&runString),
 		    Tcl_DStringLength(&runString) >> 1);
 	} else {
@@ -1313,12 +1329,12 @@
 		|| (p == end) || (p-source > 200)) {
 	    if (p > source) {
 		do_width = (needWidth || (p != end)) ? 1 : 0;
 		familyPtr = lastSubFontPtr->familyPtr;
 
-		Tcl_UtfToExternalDString(familyPtr->encoding, source,
-			p - source, &runString);
+		(void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, source,
+			p - source, TCL_ENCODING_NOCOMPLAIN, &runString);
 		if (familyPtr->isTwoByteFont) {
 		    XDrawString16(display, drawable, gc, x, y,
 			    (XChar2b *) Tcl_DStringValue(&runString),
 			    Tcl_DStringLength(&runString) / 2);
 		    if (do_width) {
@@ -2761,13 +2777,13 @@
 GetScreenFont(
     Display *display,		/* Display for new XFontStruct. */
     FontAttributes *wantPtr,	/* Contains desired actual pixel-size if the
 				 * best font was scalable. */
     char **nameList,		/* Array of XLFDs. */
-    int bestIdx[2],		/* Indices into above array for XLFD of best
+    int bestIdx[],		/* Indices into above array for XLFD of best
 				 * bitmapped and best scalable font. */
-    unsigned bestScore[2])	/* Scores of best bitmapped and best scalable
+    unsigned bestScore[])	/* Scores of best bitmapped and best scalable
 				 * font. XLFD corresponding to lowest score
 				 * will be constructed. */
 {
     XFontStruct *fontStructPtr;
 

Index: unix/tkUnixInit.c
==================================================================
--- unix/tkUnixInit.c
+++ unix/tkUnixInit.c
@@ -1,11 +1,11 @@
 /*
  * tkUnixInit.c --
  *
  *	This file contains Unix-specific interpreter initialization functions.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -39,10 +39,13 @@
 TkpInit(
     Tcl_Interp *interp)
 {
     TkCreateXEventSource();
     GetLibraryPath(interp);
+    Tktray_Init(interp);
+    (void)SysNotify_Init (interp);
+    Icu_Init(interp);
     return TCL_OK;
 }
 
 /*
  *----------------------------------------------------------------------

Index: unix/tkUnixInt.h
==================================================================
--- unix/tkUnixInt.h
+++ unix/tkUnixInt.h
@@ -22,11 +22,15 @@
  * they're defined in.
  */
 
 #include "tkIntPlatDecls.h"
 
+MODULE_SCOPE  int       Tktray_Init (Tcl_Interp* interp);
+MODULE_SCOPE  int       SysNotify_Init (Tcl_Interp* interp);
+
 #endif /* _TKUNIXINT */
+
 
 /*
  * Local Variables:
  * mode: c
  * c-basic-offset: 4

Index: unix/tkUnixKey.c
==================================================================
--- unix/tkUnixKey.c
+++ unix/tkUnixKey.c
@@ -2,11 +2,11 @@
  * tkUnixKey.c --
  *
  *	This file contains routines for dealing with international keyboard
  *	input.
  *
- * Copyright (c) 1997 by Sun Microsystems, Inc.
+ * Copyright © 1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -173,11 +173,11 @@
 	}
 	if ((status != XLookupChars) && (status != XLookupBoth)) {
 	    len = 0;
 	}
 	Tcl_DStringSetLength(&buf, len);
-	Tcl_ExternalToUtfDString(NULL, Tcl_DStringValue(&buf), len, dsPtr);
+	(void)Tcl_ExternalToUtfDStringEx(NULL, Tcl_DStringValue(&buf), len, TCL_ENCODING_NOCOMPLAIN, dsPtr);
 	Tcl_DStringFree(&buf);
 #endif /* X_HAVE_UTF8_STRING */
     } else
 #endif /* TK_USE_INPUT_METHODS */
     {

Index: unix/tkUnixMenu.c
==================================================================
--- unix/tkUnixMenu.c
+++ unix/tkUnixMenu.c
@@ -1,11 +1,11 @@
 /*
  * tkUnixMenu.c --
  *
  *	This module implements the UNIX platform-specific features of menus.
  *
- * Copyright (c) 1996-1998 by Sun Microsystems, Inc.
+ * Copyright © 1996-1998 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -288,11 +288,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 void
-TkpSetMainMenubar(
+Tk_SetMainMenubar(
     TCL_UNUSED(Tcl_Interp *),
     TCL_UNUSED(Tk_Window),
     TCL_UNUSED(const char *))
 {
     /*
@@ -849,20 +849,20 @@
     Tk_Font tkfont,		/* The precalculated font */
     const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
     int x, int y,
     TCL_UNUSED(int), int height)
 {
-    if ((mePtr->underline >= 0) && (mePtr->labelPtr != NULL)) {
+    if (mePtr->labelPtr != NULL) {
 	int len;
 
 	len = Tcl_GetCharLength(mePtr->labelPtr);
-	if (mePtr->underline < len) {
+	if (mePtr->underline < len && mePtr->underline >= -len) {
 	    int activeBorderWidth, leftEdge, ch;
 	    const char *label, *start, *end;
 
 	    label = Tcl_GetString(mePtr->labelPtr);
-	    start = Tcl_UtfAtIndex(label, mePtr->underline);
+	    start = Tcl_UtfAtIndex(label, (mePtr->underline < 0) ? mePtr->underline + len : mePtr->underline);
 	    end = start + TkUtfToUniChar(start, &ch);
 
 	    Tk_GetPixelsFromObj(NULL, menuPtr->tkwin,
 		    menuPtr->activeBorderWidthPtr, &activeBorderWidth);
 	    leftEdge = x + mePtr->indicatorSpace + activeBorderWidth;
@@ -926,25 +926,18 @@
  *----------------------------------------------------------------------
  */
 
 int
 TkpPostTearoffMenu(
-    TCL_UNUSED(Tcl_Interp *),		/* The interpreter of the menu */
+    TCL_UNUSED(Tcl_Interp *),	/* The interpreter of the menu */
     TkMenu *menuPtr,		/* The menu we are posting */
     int x, int y, int index)	/* The root X,Y coordinates where the
 				 * specified entry will be posted */
 {
     int vRootX, vRootY, vRootWidth, vRootHeight;
     int result;
 
-    if (index >= (int)menuPtr->numEntries) {
-	index = menuPtr->numEntries - 1;
-    }
-    if (index >= 0) {
-	y -= menuPtr->entries[index]->y;
-    }
-
     TkActivateMenuEntry(menuPtr, -1);
     TkRecomputeMenu(menuPtr);
     result = TkPostCommand(menuPtr);
     if (result != TCL_OK) {
     	return result;
@@ -956,10 +949,22 @@
      */
 
     if (menuPtr->tkwin == NULL) {
     	return TCL_OK;
     }
+
+    /*
+     * Adjust the menu y position so that the specified entry will be located
+     * at the given coordinates.
+     */
+
+    if (index >= (int)menuPtr->numEntries) {
+	index = menuPtr->numEntries - 1;
+    }
+    if (index >= 0) {
+	y -= menuPtr->entries[index]->y;
+    }
 
     /*
      * Adjust the position of the menu if necessary to keep it visible on the
      * screen. There are two special tricks to make this work right:
      *

Index: unix/tkUnixMenubu.c
==================================================================
--- unix/tkUnixMenubu.c
+++ unix/tkUnixMenubu.c
@@ -2,11 +2,11 @@
  * tkUnixMenubu.c --
  *
  *	This file implements the Unix specific portion of the menubutton
  *	widget.
  *
- * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: unix/tkUnixPort.h
==================================================================
--- unix/tkUnixPort.h
+++ unix/tkUnixPort.h
@@ -34,21 +34,15 @@
 #endif
 #include <sys/stat.h>
 #ifndef _TCL
 #   include <tcl.h>
 #endif
-#if TIME_WITH_SYS_TIME
-#   include <sys/time.h>
-#   include <time.h>
-#else
-#   if HAVE_SYS_TIME_H
+#ifdef HAVE_SYS_TIME_H
 #	include <sys/time.h>
-#   else
-#	include <time.h>
-#   endif
 #endif
-#if HAVE_INTTYPES_H
+#include <time.h>
+#ifdef HAVE_INTTYPES_H
 #    include <inttypes.h>
 #endif
 #include <unistd.h>
 #if defined(__GNUC__) && !defined(__cplusplus)
 #   pragma GCC diagnostic ignored "-Wc++-compat"
@@ -168,15 +162,9 @@
  * This should perhaps use the real size of an XID.
  */
 
 #ifndef __CYGWIN__
 #define TkpPrintWindowId(buf,w) \
-	sprintf((buf), "%#08lx", (unsigned long) (w))
+	sprintf((buf), "0x%lx", (unsigned long) (w))
 #endif
 
-/*
- * Used by tkWindow.c
- */
-
-#define TkpHandleMapOrUnmap(tkwin, event)  Tk_HandleEvent(event)
-
 #endif /* _UNIXPORT */

Index: unix/tkUnixRFont.c
==================================================================
--- unix/tkUnixRFont.c
+++ unix/tkUnixRFont.c
@@ -1,20 +1,19 @@
 /*
  * tkUnixRFont.c --
  *
  *	Alternate implementation of tkUnixFont.c using Xft.
  *
- * Copyright (c) 2002-2003 Keith Packard
+ * Copyright © 2002-2003 Keith Packard
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
 #include "tkUnixInt.h"
 #include "tkFont.h"
 #include <X11/Xft/Xft.h>
-#include <ctype.h>
 
 #define MAX_CACHED_COLORS 16
 
 typedef struct {
     XftFont *ftFont;
@@ -52,10 +51,14 @@
 
 typedef struct {
     Region clipRegion;		/* The clipping region, or None. */
 } ThreadSpecificData;
 static Tcl_ThreadDataKey dataKey;
+
+TCL_DECLARE_MUTEX(xftMutex);
+#define LOCK Tcl_MutexLock(&xftMutex)
+#define UNLOCK Tcl_MutexUnlock(&xftMutex)
 
 /*
  *-------------------------------------------------------------------------
  *
  * TkpFontPkgInit --
@@ -130,24 +133,28 @@
 	mat.xy = -(mat.yx = s);
 
 	if (angle != 0.0) {
 	    FcPatternAddMatrix(pat, FC_MATRIX, &mat);
 	}
+	LOCK;
 	ftFont = XftFontOpenPattern(fontPtr->display, pat);
+	UNLOCK;
 	if (!ftFont) {
 	    /*
 	     * The previous call to XftFontOpenPattern() should not fail, but
 	     * sometimes does anyway. Usual cause appears to be a
 	     * misconfigured fontconfig installation; see [Bug 1090382]. Try a
 	     * fallback:
 	     */
 
+	    LOCK;
 	    ftFont = XftFontOpen(fontPtr->display, fontPtr->screen,
 		    FC_FAMILY, FcTypeString, "sans",
 		    FC_SIZE, FcTypeDouble, 12.0,
 		    FC_MATRIX, FcTypeMatrix, &mat,
 		    NULL);
+	    UNLOCK;
 	}
 	if (!ftFont) {
 	    /*
 	     * The previous call should definitely not fail. Impossible to
 	     * proceed at this point.
@@ -158,11 +165,13 @@
 
 	if (angle == 0.0) {
 	    fontPtr->faces[i].ft0Font = ftFont;
 	} else {
 	    if (fontPtr->faces[i].ftFont) {
+		LOCK;
 		XftFontClose(fontPtr->display, fontPtr->faces[i].ftFont);
+		UNLOCK;
 	    }
 	    fontPtr->faces[i].ftFont = ftFont;
 	    fontPtr->faces[i].angle = angle;
 	}
     }
@@ -417,14 +426,18 @@
     Tk_ErrorHandler handler =
 	    Tk_CreateErrorHandler(display, -1, -1, -1, NULL, NULL);
 
     for (i = 0; i < fontPtr->nfaces; i++) {
 	if (fontPtr->faces[i].ftFont) {
+	    LOCK;
 	    XftFontClose(fontPtr->display, fontPtr->faces[i].ftFont);
+	    UNLOCK;
 	}
 	if (fontPtr->faces[i].ft0Font) {
+	    LOCK;
 	    XftFontClose(fontPtr->display, fontPtr->faces[i].ft0Font);
+	    UNLOCK;
 	}
 	if (fontPtr->faces[i].charset) {
 	    FcCharSetDestroy(fontPtr->faces[i].charset);
 	}
     }
@@ -759,11 +772,13 @@
 	string[len++] = (char) c;
 #endif /* DEBUG_FONTSEL */
 	ftFont = GetFont(fontPtr, c, 0.0);
 
 	if (!errorFlag) {
+	    LOCK;
 	    XftTextExtents32(fontPtr->display, ftFont, &c, 1, &extents);
+	    UNLOCK;
 	} else {
 	    extents.xOff = 0;
 	    errorFlag = 0;
 	}
 
@@ -970,12 +985,14 @@
 	numBytes -= clen;
 
 	ftFont = GetFont(fontPtr, c, 0.0);
 	if (ftFont) {
 	    specs[nspec].glyph = XftCharIndex(fontPtr->display, ftFont, c);
+	    LOCK;
 	    XftGlyphExtents(fontPtr->display, ftFont, &specs[nspec].glyph, 1,
 		    &metrics);
+	    UNLOCK;
 
 	    /*
 	     * Draw glyph only when it fits entirely into 16 bit coords.
 	     */
 
@@ -984,21 +1001,25 @@
 		y <= maxCoord - metrics.height) {
 		specs[nspec].font = ftFont;
 		specs[nspec].x = x;
 		specs[nspec].y = y;
 		if (++nspec == NUM_SPEC) {
+		    LOCK;
 		    XftDrawGlyphFontSpec(fontPtr->ftDraw, xftcolor,
 			    specs, nspec);
+		    UNLOCK;
 		    nspec = 0;
 		}
 	    }
 	    x += metrics.xOff;
 	    y += metrics.yOff;
 	}
     }
     if (nspec) {
+	LOCK;
 	XftDrawGlyphFontSpec(fontPtr->ftDraw, xftcolor, specs, nspec);
+	UNLOCK;
     }
 
   doUnderlineStrikeout:
     if (tsdPtr->clipRegion != NULL) {
 	XftDrawSetClip(fontPtr->ftDraw, NULL);
@@ -1121,12 +1142,15 @@
 		 * perform better rendering of sub-pixel inter-glyph spacing.
 		 * If only the current Xft implementation could make use of
 		 * this information... but we'll be ready when it does!
 		 */
 
+		LOCK;
 		XftGlyphExtents(fontPtr->display, currentFtFont, glyphs,
 			nglyph, &metrics);
+		UNLOCK;
+
 		/*
 		 * Draw glyph only when it fits entirely into 16 bit coords.
 		 */
 
 		if (x >= minCoord && y >= minCoord &&
@@ -1145,33 +1169,39 @@
                      * not be a huge issue since NUM_SPEC is 1024 and thus able to
                      * cover about 6000 pixels for a 6 pixel wide font (which is
                      * a very small barely readable font)
 		     */
 
+		    LOCK;
 		    XftDrawGlyphs(fontPtr->ftDraw, xftcolor, currentFtFont,
 			    originX, originY, glyphs, nglyph);
+		    UNLOCK;
 		}
 	    }
 	    originX = ROUND16(x);
 	    originY = ROUND16(y);
 	    currentFtFont = ftFont;
 	}
 	glyphs[nglyph++] = XftCharIndex(fontPtr->display, ftFont, c);
     }
     if (nglyph) {
+	LOCK;
 	XftGlyphExtents(fontPtr->display, currentFtFont, glyphs,
 		nglyph, &metrics);
+	UNLOCK;
 
 	/*
 	 * Draw glyph only when it fits entirely into 16 bit coords.
 	 */
 
 	if (x >= minCoord && y >= minCoord &&
 	    x <= maxCoord - metrics.width &&
 	    y <= maxCoord - metrics.height) {
+	    LOCK;
 	    XftDrawGlyphs(fontPtr->ftDraw, xftcolor, currentFtFont,
 		    originX, originY, glyphs, nglyph);
+	    UNLOCK;
 	}
     }
 #else /* !XFT_HAS_FIXED_ROTATED_PLACEMENT */
     int clen, nspec;
     XftGlyphFontSpec specs[NUM_SPEC];
@@ -1215,12 +1245,14 @@
 
 	ftFont = GetFont(fontPtr, c, angle);
 	ft0Font = GetFont(fontPtr, c, 0.0);
 	if (ftFont && ft0Font) {
 	    specs[nspec].glyph = XftCharIndex(fontPtr->display, ftFont, c);
+	    LOCK;
 	    XftGlyphExtents(fontPtr->display, ft0Font, &specs[nspec].glyph, 1,
 		    &metrics);
+	    UNLOCK;
 
 	    /*
 	     * Draw glyph only when it fits entirely into 16 bit coords.
 	     */
 
@@ -1229,21 +1261,25 @@
 		y <= maxCoord - metrics.height) {
 		specs[nspec].font = ftFont;
 		specs[nspec].x = ROUND16(x);
 		specs[nspec].y = ROUND16(y);
 		if (++nspec == NUM_SPEC) {
+		    LOCK;
 		    XftDrawGlyphFontSpec(fontPtr->ftDraw, xftcolor,
 			    specs, nspec);
+		    UNLOCK;
 		    nspec = 0;
 		}
 	    }
 	    x += metrics.xOff*cosA + metrics.yOff*sinA;
 	    y += metrics.yOff*cosA - metrics.xOff*sinA;
 	}
     }
     if (nspec) {
+	LOCK;
 	XftDrawGlyphFontSpec(fontPtr->ftDraw, xftcolor, specs, nspec);
+	UNLOCK;
     }
 #endif /* XFT_HAS_FIXED_ROTATED_PLACEMENT */
 
   doUnderlineStrikeout:
     if (tsdPtr->clipRegion != NULL) {

Index: unix/tkUnixScale.c
==================================================================
--- unix/tkUnixScale.c
+++ unix/tkUnixScale.c
@@ -1,12 +1,12 @@
 /*
  * tkUnixScale.c --
  *
  *	This file implements the X specific portion of the scrollbar widget.
  *
- * Copyright (c) 1996 by Sun Microsystems, Inc.
- * Copyright (c) 1998-2000 by Scriptics Corporation.
+ * Copyright © 1996 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: unix/tkUnixScrlbr.c
==================================================================
--- unix/tkUnixScrlbr.c
+++ unix/tkUnixScrlbr.c
@@ -2,11 +2,11 @@
  * tkUnixScrollbar.c --
  *
  *	This file implements the Unix specific portion of the scrollbar
  *	widget.
  *
- * Copyright (c) 1996 by Sun Microsystems, Inc.
+ * Copyright © 1996 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: unix/tkUnixSelect.c
==================================================================
--- unix/tkUnixSelect.c
+++ unix/tkUnixSelect.c
@@ -1,11 +1,11 @@
 /*
  * tkUnixSelect.c --
  *
  *	This file contains X specific routines for manipulating selections.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -618,11 +618,11 @@
 	    if (type == dispPtr->compoundTextAtom) {
 		encoding = Tcl_GetEncoding(NULL, "iso2022");
 	    } else {
 		encoding = Tcl_GetEncoding(NULL, "iso8859-1");
 	    }
-	    Tcl_ExternalToUtfDString(encoding, propInfo, (int)numItems, &ds);
+	    (void)Tcl_ExternalToUtfDStringEx(encoding, propInfo, numItems, TCL_ENCODING_NOCOMPLAIN, &ds);
 	    if (encoding) {
 		Tcl_FreeEncoding(encoding);
 	    }
 
 	    retrPtr->result = retrPtr->proc(retrPtr->clientData, interp,
@@ -993,11 +993,11 @@
 	    if (type == XA_STRING) {
 		encoding = Tcl_GetEncoding(NULL, "iso8859-1");
 	    } else {
 		encoding = Tcl_GetEncoding(NULL, "iso2022");
 	    }
-	    Tcl_UtfToExternalDString(encoding, (char *) buffer, -1, &ds);
+	    (void)Tcl_UtfToExternalDStringEx(encoding, (char *) buffer, -1, TCL_ENCODING_NOCOMPLAIN, &ds);
 	    XChangeProperty(reply.xsel.display, reply.xsel.requestor,
 		    property, type, 8, PropModeReplace,
 		    (unsigned char *) Tcl_DStringValue(&ds),
 		    Tcl_DStringLength(&ds));
 	    if (encoding) {

Index: unix/tkUnixSend.c
==================================================================
--- unix/tkUnixSend.c
+++ unix/tkUnixSend.c
@@ -2,13 +2,13 @@
  * tkUnixSend.c --
  *
  *	This file provides functions that implement the "send" command,
  *	allowing commands to be passed from interpreter to interpreter.
  *
- * Copyright (c) 1989-1994 The Regents of the University of California.
- * Copyright (c) 1994-1996 Sun Microsystems, Inc.
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright © 1989-1994 The Regents of the University of California.
+ * Copyright © 1994-1996 Sun Microsystems, Inc.
+ * Copyright © 1998-1999 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

ADDED   unix/tkUnixSysNotify.c
Index: unix/tkUnixSysNotify.c
==================================================================
--- /dev/null
+++ unix/tkUnixSysNotify.c
@@ -0,0 +1,233 @@
+/*
+ * tkUnixSysNotify.c --
+ *
+ * 	tkUnixSysNotify.c implements a "sysnotify" Tcl command which
+ * 	permits one to post system notifications based on the libnotify API.
+ *
+ * Copyright © 2020 Kevin Walzer/WordTech Communications LLC.
+ * Copyright © 2020 Christian Werner for runtime linking
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+#include "tkInt.h"
+#include "tkUnixInt.h"
+
+/*
+ * Runtime linking of libnotify.
+ */
+
+typedef int	(*fn_ln_init)(const char *);
+typedef void	(*fn_ln_uninit)(void);
+typedef void *	(*fn_ln_notification_new)(const char *, const char *,
+			const char *, void *);
+typedef int	(*fn_ln_notification_show)(void *, int *);
+
+static struct {
+    int				nopen;
+    Tcl_LoadHandle		lib;
+    fn_ln_init			init;
+    fn_ln_uninit		uninit;
+    fn_ln_notification_new	notification_new;
+    fn_ln_notification_show	notification_show;
+} ln_fns = {
+    0, NULL, NULL, NULL, NULL, NULL
+};
+
+#define notify_init			ln_fns.init
+#define notify_uninit			ln_fns.uninit
+#define notify_notification_new		ln_fns.notification_new
+#define notify_notification_show	ln_fns.notification_show
+
+TCL_DECLARE_MUTEX(ln_mutex);
+
+/*
+ * Forward declarations for procedures defined in this file.
+ */
+
+static void	SysNotifyDeleteCmd(void *);
+static int	SysNotifyCmd(void *, Tcl_Interp *, int, Tcl_Obj * const*);
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SysNotifyDeleteCmd --
+ *
+ *      Delete notification and clean up.
+ *
+ * Results:
+ *	Window destroyed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+SysNotifyDeleteCmd (
+    TCL_UNUSED(void *))
+{
+    Tcl_MutexLock(&ln_mutex);
+    if (--ln_fns.nopen == 0) {
+	if (notify_uninit) {
+	    notify_uninit();
+	}
+	if (ln_fns.lib != NULL) {
+	    Tcl_FSUnloadFile(NULL, ln_fns.lib);
+	}
+	memset(&ln_fns, 0, sizeof(ln_fns));
+    }
+    Tcl_MutexUnlock(&ln_mutex);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SysNotifyCreateCmd --
+ *
+ *      Create tray command and (unreal) window.
+ *
+ * Results:
+ *	Icon tray and hidden window created.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+SysNotifyCmd(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    int objc,
+    Tcl_Obj *const *objv)
+{
+    const char *title;
+    const char *message;
+    const char *icon;
+    const char *appname = "Wish";
+    void *notif;
+
+    if (objc < 3) {
+	Tcl_WrongNumArgs(interp, 1, objv, "title message");
+	return TCL_ERROR;
+    }
+
+    /*
+     * Pass strings to notification, and use a sane platform-specific
+     * icon in the alert.
+     */
+
+    title = Tcl_GetString(objv[1]);
+    message = Tcl_GetString(objv[2]);
+    icon = "dialog-information";
+
+
+    /* Use the appname for libnotify initialization
+     * See bug f63c37be3a for a discussion whether this should be
+     * allowed at all on safe interpreters
+     */
+    if (!Tcl_IsSafe(interp)) {
+	appname = ((TkWindow *)Tk_MainWindow(interp))->nameUid;
+    }
+
+    /*
+     * Call to notify_init should go here to prevent test suite failure.
+     */
+
+    if (notify_init && notify_notification_new && notify_notification_show) {
+	Tcl_Encoding enc;
+	Tcl_DString dst, dsm;
+
+	Tcl_DStringInit(&dst);
+	Tcl_DStringInit(&dsm);
+	enc = Tcl_GetEncoding(NULL, "utf-8");
+	(void)Tcl_UtfToExternalDStringEx(enc, title, -1, TCL_ENCODING_NOCOMPLAIN, &dst);
+	(void)Tcl_UtfToExternalDStringEx(enc, message, -1, TCL_ENCODING_NOCOMPLAIN, &dsm);
+	notify_init(appname);
+	notif = notify_notification_new(Tcl_DStringValue(&dst),
+	    Tcl_DStringValue(&dsm), icon, NULL);
+	notify_notification_show(notif, NULL);
+	Tcl_DStringFree(&dsm);
+	Tcl_DStringFree(&dst);
+	Tcl_FreeEncoding(enc);
+    }
+
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SysNotify_Init --
+ *
+ *      Initialize the command.
+ *
+ * Results:
+ *	Command initialized.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+SysNotify_Init(
+    Tcl_Interp *interp)
+{
+    Tcl_MutexLock(&ln_mutex);
+    if (ln_fns.nopen == 0) {
+	int i = 0;
+	Tcl_Obj *nameobj;
+	static const char *lnlibs[] = {
+	    "libnotify.so.4",
+	    "libnotify.so.3",
+	    "libnotify.so.2",
+	    "libnotify.so.1",
+	    "libnotify.so",
+	    NULL
+	};
+
+	while (lnlibs[i] != NULL) {
+	    Tcl_ResetResult(interp);
+	    nameobj = Tcl_NewStringObj(lnlibs[i], -1);
+	    Tcl_IncrRefCount(nameobj);
+	    if (Tcl_LoadFile(interp, nameobj, NULL, 0, NULL, &ln_fns.lib)
+		    == TCL_OK) {
+		Tcl_DecrRefCount(nameobj);
+		break;
+	    }
+	    Tcl_DecrRefCount(nameobj);
+	    ++i;
+	}
+	if (ln_fns.lib != NULL) {
+#define LN_SYM(name)							\
+	    ln_fns.name = (fn_ln_ ## name)				\
+		Tcl_FindSymbol(NULL, ln_fns.lib, "notify_" #name)
+	    LN_SYM(init);
+	    LN_SYM(uninit);
+	    LN_SYM(notification_new);
+	    LN_SYM(notification_show);
+#undef LN_SYM
+	}
+    }
+    ln_fns.nopen++;
+    Tcl_MutexUnlock(&ln_mutex);
+
+    Tcl_CreateObjCommand(interp, "::tk::sysnotify::_sysnotify", SysNotifyCmd,
+	    interp, SysNotifyDeleteCmd);
+    return TCL_OK;
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * coding: utf-8
+ * End:
+ */

ADDED   unix/tkUnixSysTray.c
Index: unix/tkUnixSysTray.c
==================================================================
--- /dev/null
+++ unix/tkUnixSysTray.c
@@ -0,0 +1,1724 @@
+/*
+ * tkUnixSysTray.c --
+ *
+ * 	tkUnixSysTray.c implements a "systray" Tcl command which permits to
+ * 	change the system tray/taskbar icon of a Tk toplevel window and
+ * 	to post system notifications.
+ *
+ * Copyright © 2005 Anton Kovalenko.
+ * Copyright © 2020 Kevin Walzer/WordTech Communications LLC.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+#include "tkInt.h"
+#include "tkUnixInt.h"
+
+/*
+ * Based extensively on the tktray extension package. Here we are removing
+ * non-essential parts of tktray.
+ */
+
+#include <time.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <X11/X.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+
+/* XEmbed definitions
+ * See http://www.freedesktop.org/wiki/Standards_2fxembed_2dspec
+ * */
+#define XEMBED_MAPPED           (1<<0)
+/* System tray opcodes
+ * See http://www.freedesktop.org/wiki/Standards_2fsystemtray_2dspec
+ * */
+#define SYSTEM_TRAY_REQUEST_DOCK    0
+#define SYSTEM_TRAY_BEGIN_MESSAGE   1
+#define SYSTEM_TRAY_CANCEL_MESSAGE  2
+
+/* Flags of widget configuration options */
+#define ICON_CONF_IMAGE         (1<<0)  /* Image changed */
+#define ICON_CONF_REDISPLAY     (1<<1)  /* Redisplay required */
+#define ICON_CONF_XEMBED        (1<<2)  /* Remapping or unmapping required */
+#define ICON_CONF_CLASS         (1<<3)   /* TODO WM_CLASS update required */
+#define ICON_CONF_FIRST_TIME    (1<<4)  /* For IconConfigureMethod invoked by the constructor */
+
+/* Widget states */
+#define ICON_FLAG_REDRAW_PENDING    (1<<0)
+#define ICON_FLAG_ARGB32            (1<<1)
+#define ICON_FLAG_DIRTY_EDGES       (1<<2)
+
+#define TKU_NO_BAD_WINDOW_BEGIN(display) \
+    { Tk_ErrorHandler error__handler = \
+	    Tk_CreateErrorHandler(display, BadWindow, -1, -1, NULL, NULL);
+#define TKU_NO_BAD_WINDOW_END Tk_DeleteErrorHandler(error__handler); }
+
+/*Declaration for utility functions.*/
+static void TKU_WmWithdraw(Tk_Window winPtr, Tcl_Interp* interp);
+static Tk_Window TKU_GetWrapper(Tk_Window winPtr);
+void TKU_AddInput(Display* dpy, Window win, long add_to_mask);
+static Tk_Window TKU_Wrapper(Tk_Window w, Tcl_Interp* interp);
+static Window TKU_XID(Tk_Window w);
+
+/* Customized window withdraw */
+static void
+TKU_WmWithdraw(
+    Tk_Window winPtr,
+    TCL_UNUSED(Tcl_Interp *))
+{
+    TkpWmSetState((TkWindow*)winPtr, WithdrawnState);
+}
+
+/* The wrapper should exist */
+static Tk_Window
+TKU_GetWrapper(
+    Tk_Window winPtr)
+{
+    return (Tk_Window)
+	    TkpGetWrapperWindow((TkWindow*)winPtr);
+}
+
+/* Subscribe for extra X11 events (needed for MANAGER selection) */
+void
+TKU_AddInput(
+    Display* dpy,
+    Window win,
+    long add_to_mask)
+{
+    XWindowAttributes xswa;
+    TKU_NO_BAD_WINDOW_BEGIN(dpy)
+        XGetWindowAttributes(dpy,win,&xswa);
+        XSelectInput(dpy,win,xswa.your_event_mask|add_to_mask);
+    TKU_NO_BAD_WINDOW_END
+}
+
+/* Get Tk Window wrapper (make it exist if ny) */
+static Tk_Window
+TKU_Wrapper(
+    Tk_Window w,
+    Tcl_Interp* interp)
+{
+    Tk_Window wrapper = TKU_GetWrapper(w);
+    if (!wrapper) {
+	Tk_MakeWindowExist(w);
+	TKU_WmWithdraw(w, interp);
+	Tk_MapWindow(w);
+	wrapper = (Tk_Window) TKU_GetWrapper(w);
+    }
+    return wrapper;
+}
+
+/* Return X window id for Tk window (make it exist if ny) */
+static Window
+TKU_XID(
+    Tk_Window w)
+{
+    Window xid = Tk_WindowId(w);
+    if (xid == None) {
+	Tk_MakeWindowExist(w);
+	xid = Tk_WindowId(w);
+    }
+    return xid;
+}
+
+/* Data structure representing dock widget */
+typedef struct {
+    /* standard for widget */
+    Tk_Window tkwin, drawingWin;
+    Window wrapper;
+    Window myManager;
+    Window trayManager;
+
+    Tk_OptionTable options;
+    Tcl_Interp *interp;
+    Tcl_Command widgetCmd;
+
+    Tk_Image image; /* image to be drawn */
+
+    /* Only one of imageVisualInstance and photo is needed for argb32
+     * operations. Unless imageString changes, imageVisualInstance is
+     * always valid for the same drawingWin instance, but photo is
+     * invalidated by any "whole image" type change. */
+
+    Tk_Image imageVisualInstance; /* image instance for use with argb32 */
+    Tk_PhotoHandle photo;	  /* !null if it's really a photo */
+
+    /* Offscreen pixmap is created for a given imageWidth,
+     * imageHeight, drawingWin, and invalidated (and freed) on image
+     * resize or drawingWin destruction.
+
+     * Contents of this pixmap is synced on demand; when image changes
+     * but is not resized, pixmap is marked as out-of-sync. Next time
+     * when redisplay is needed, pixmap is updated before drawing
+     * operation.
+     */
+
+    Pixmap offscreenPixmap;
+    /* There is no need to recreate GC ever; it remains valid once
+     * created */
+
+    GC offscreenGC;
+
+    /* XImage for drawing ARGB32 photo on offscreenPixmap.  Should be
+     * freed and nullified each time when a pixmap is freed.  Needed
+     * (and created) when redrawing an image being a photo on ARGB32
+     * offscreen pixmap. */
+    XImage *offscreenImage;	/* for photo (argb32) drawing code */
+
+    Visual *bestVisual;		/* Visual, when it's specified by tray
+				 * manager AND is guessed to be
+				 * ARGB32 */
+    Colormap bestColormap;	/* Colormap for bestVisual */
+
+    Atom aMANAGER;
+    Atom a_NET_SYSTEM_TRAY_Sn;
+    Atom a_XEMBED_INFO;
+    Atom a_NET_SYSTEM_TRAY_MESSAGE_DATA;
+    Atom a_NET_SYSTEM_TRAY_OPCODE;
+    Atom a_NET_SYSTEM_TRAY_ORIENTATION;
+    Atom a_NET_SYSTEM_TRAY_VISUAL;
+
+    int flags; /* ICON_FLAG_ - see defines above */
+    int msgid; /* Last balloon message ID */
+    int useShapeExt;
+
+    int x,y,width,height;
+    int imageWidth, imageHeight;
+    int requestedWidth, requestedHeight;
+    int visible; /* whether XEMBED_MAPPED should be set */
+    int docked;	 /* whether an icon should be docked */
+    char *imageString, /* option: -image as string */
+	 *classString; /* option: -class as string */
+} DockIcon;
+
+/*
+ * Forward declarations for procedures defined in this file.
+ */
+
+static int TrayIconCreateCmd(ClientData cd, Tcl_Interp *interp,
+			     int objc,  Tcl_Obj *const objv[]);
+static int TrayIconObjectCmd(ClientData cd, Tcl_Interp *interp,
+			     int objc,  Tcl_Obj *const objv[]);
+static int TrayIconConfigureMethod(DockIcon *icon, Tcl_Interp* interp,
+				   int objc,  Tcl_Obj *const objv[],
+				   int addflags);
+static int PostBalloon(DockIcon* icon, const char * utf8msg,
+		       long timeout);
+static void CancelBalloon(DockIcon* icon, int msgid);
+static int QueryTrayOrientation(DockIcon* icon);
+
+static void TrayIconDeleteProc(ClientData cd );
+static Atom DockSelectionAtomFor(Tk_Window tkwin);
+static void DockToManager(DockIcon *icon);
+static void CreateTrayIconWindow(DockIcon *icon);
+
+static void TrayIconRequestSize(DockIcon* icon, int w, int h);
+static void TrayIconForceImageChange(DockIcon* icon);
+static void TrayIconUpdate(DockIcon* icon, int mask);
+
+static void EventuallyRedrawIcon(DockIcon* icon);
+static void DisplayIcon(ClientData cd);
+
+static void RetargetEvent(DockIcon *icon, XEvent *ev);
+
+static void TrayIconEvent(ClientData cd, XEvent* ev);
+static void UserIconEvent(ClientData cd, XEvent* ev);
+static void TrayIconWrapperEvent(ClientData cd, XEvent* ev);
+static int IconGenericHandler(ClientData cd, XEvent *ev);
+
+int Tktray_Init (Tcl_Interp* interp );
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TrayIconObjectCmd --
+ *
+ * 	Manage attributes of tray icon.
+ *
+ * Results:
+ *	Various values of the tray icon are set and retrieved.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TrayIconObjectCmd(
+    ClientData cd,
+    Tcl_Interp *interp,
+    int objc,
+    Tcl_Obj *const objv[])
+{
+    DockIcon *icon = (DockIcon*)cd;
+    int bbox[4] = {0,0,0,0};
+    Tcl_Obj * bboxObj;
+    int wcmd;
+    int i;
+    XWindowAttributes xwa;
+    Window bogus;
+    int msgid;
+
+    enum {XWC_CONFIGURE = 0, XWC_CGET, XWC_BALLOON, XWC_CANCEL,
+            XWC_BBOX, XWC_DOCKED, XWC_ORIENTATION};
+    const char *st_wcmd[] = {"configure", "cget", "balloon", "cancel",
+            "bbox", "docked", "orientation", NULL};
+
+    long timeout = 0;
+    Tcl_Obj* optionValue;
+
+    if (objc<2) {
+	Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?");
+	return TCL_ERROR;
+    }
+    if (Tcl_GetIndexFromObj(interp, objv[1], st_wcmd,
+            "subcommand", TCL_EXACT, &wcmd) != TCL_OK) {
+	return TCL_ERROR;
+    }
+
+    switch (wcmd) {
+    case XWC_CONFIGURE:
+	return TrayIconConfigureMethod(icon,interp,objc-2,objv+2,0);
+
+    case XWC_CGET:
+	if (objc != 3) {
+	    Tcl_WrongNumArgs(interp,2,objv,"option");
+	    return TCL_ERROR;
+	}
+	optionValue = Tk_GetOptionValue(interp,(char*)icon,
+                icon->options,objv[2],icon->tkwin);
+	if (optionValue) {
+	    Tcl_SetObjResult(interp,optionValue);
+	    return TCL_OK;
+	} else {
+	    return TCL_ERROR;
+	}
+
+    case XWC_BALLOON:
+	if ((objc != 3) && (objc != 4)) {
+	    Tcl_WrongNumArgs(interp, 2, objv, "message ?timeout?");
+	    return TCL_ERROR;
+	}
+	if (objc == 4) {
+	    if (Tcl_GetLongFromObj(interp,objv[3],&timeout) != TCL_OK)
+		return TCL_ERROR;
+	}
+	msgid = PostBalloon(icon,Tcl_GetString(objv[2]), timeout);
+	Tcl_SetObjResult(interp,Tcl_NewIntObj(msgid));
+	return TCL_OK;
+
+    case XWC_CANCEL:
+	if (objc != 3) {
+	    Tcl_WrongNumArgs(interp, 2, objv, "messageId");
+	    return TCL_ERROR;
+	}
+	if (Tcl_GetIntFromObj(interp,objv[2],&msgid) != TCL_OK) {
+	    return TCL_ERROR;
+	}
+	if (msgid)
+	    CancelBalloon(icon,msgid);
+	return TCL_OK;
+
+    case XWC_BBOX:
+	if (icon->drawingWin) {
+	    XGetWindowAttributes(Tk_Display(icon->drawingWin),
+                    TKU_XID(icon->drawingWin), &xwa);
+
+	    XTranslateCoordinates(Tk_Display(icon->drawingWin),
+                    TKU_XID(icon->drawingWin), xwa.root, 0,0,
+                    &icon->x, &icon->y, &bogus);
+	    bbox[0] = icon->x;
+	    bbox[1] = icon->y;
+	    bbox[2] = bbox[0] + icon->width - 1;
+	    bbox[3] = bbox[1] + icon->height - 1;
+	}
+	bboxObj = Tcl_NewObj();
+	for (i = 0; i < 4; ++i) {
+	    Tcl_ListObjAppendElement(interp, bboxObj, Tcl_NewIntObj(bbox[i]));
+	}
+	Tcl_SetObjResult(interp, bboxObj);
+	return TCL_OK;
+
+    case XWC_DOCKED:
+	Tcl_SetObjResult(interp, Tcl_NewBooleanObj(icon->myManager != None));
+	return TCL_OK;
+
+    case XWC_ORIENTATION:
+	if (icon->myManager == None || icon->wrapper == None) {
+	    Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1));
+	} else {
+	    switch(QueryTrayOrientation(icon)) {
+	    case 0:
+		Tcl_SetObjResult(interp, Tcl_NewStringObj("horizontal", -1));
+		break;
+	    case 1:
+		Tcl_SetObjResult(interp, Tcl_NewStringObj("vertical", -1));
+		break;
+	    default:
+		Tcl_SetObjResult(interp, Tcl_NewStringObj("unknown", -1));
+		break;
+	    }
+	}
+	return TCL_OK;
+    }
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * QueryTrayOrientation --
+ *
+ * 	Obtain the orientation of the tray icon.
+ *
+ * Results:
+ *	Orientation is returned.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+QueryTrayOrientation(
+    DockIcon* icon)
+{
+    Atom retType = None;
+    int retFormat = 32;
+    unsigned long retNitems, retBytesAfter;
+    unsigned char *retProp = NULL;
+    int result = -1;
+
+    if (icon->wrapper != None && icon->myManager != None) {
+	XGetWindowProperty(Tk_Display(icon->tkwin),
+			   icon->myManager,
+			   icon->a_NET_SYSTEM_TRAY_ORIENTATION,
+			   /* offset */ 0,
+			   /* length */ 1,
+			   /* delete */ False,
+			   /* type */ XA_CARDINAL,
+			   &retType, &retFormat, &retNitems,
+			   &retBytesAfter, &retProp);
+	if (retType == XA_CARDINAL && retFormat == 32 && retNitems == 1) {
+	    result = (int) *(long*)retProp;
+	}
+	if (retProp) {
+	    XFree(retProp);
+	}
+    }
+    return result;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * DockSelectionAtomFor --
+ *
+ * 	Obtain the dock selection atom.
+ *
+ * Results:
+ *	Selection returned.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static Atom
+DockSelectionAtomFor(
+    Tk_Window tkwin)
+{
+    char buf[256];
+    /* no snprintf in C89 */
+    sprintf(buf,"_NET_SYSTEM_TRAY_S%d",Tk_ScreenNumber(tkwin));
+    return Tk_InternAtom(tkwin,buf);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * XembedSetState --
+ *
+ * 	Set the xembed state.
+ *
+ * Results:
+ *	Updates the xembed state.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+XembedSetState(
+    DockIcon *icon,
+    long xembedState)
+{
+    long info[] = { 0, 0 };
+    info[1] = xembedState;
+    if (icon->drawingWin) {
+	XChangeProperty(Tk_Display(icon->drawingWin),
+			icon->wrapper,
+			icon->a_XEMBED_INFO,
+			icon->a_XEMBED_INFO, 32,
+			PropModeReplace, (unsigned char*)info, 2);
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * XembedRequestDock --
+ *
+ * 	Obtain the docking window.
+ *
+ * Results:
+ *	The dock window is requested.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+XembedRequestDock(
+    DockIcon *icon)
+{
+    Tk_Window tkwin = icon->drawingWin;
+    XEvent ev;
+    Display *dpy = Tk_Display(tkwin);
+
+    memset(&ev, 0, sizeof(ev));
+    ev.xclient.type = ClientMessage;
+    ev.xclient.window = icon->myManager;
+    ev.xclient.message_type = icon->a_NET_SYSTEM_TRAY_OPCODE;
+    ev.xclient.format = 32;
+    ev.xclient.data.l[0] = 0;
+    ev.xclient.data.l[1] = SYSTEM_TRAY_REQUEST_DOCK;
+    ev.xclient.data.l[2] = icon->wrapper;
+    ev.xclient.data.l[3] = 0;
+    ev.xclient.data.l[4] = 0;
+    XSendEvent(dpy, icon->myManager, True, StructureNotifyMask|SubstructureNotifyMask, &ev);
+ }
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CheckArgbVisual --
+ *
+ * 	Find out if a visual is recommended and if it looks like argb32.
+ *
+ * Results:
+ *	Render the visual as needed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+CheckArgbVisual(
+    DockIcon *icon)
+{
+    /* Find out if a visual is recommended and if it looks like argb32.
+     * For such visuals we should:
+     * Recreate a window if it's created but the depth is wrong;
+     * Don't use ParentRelative but blank background.
+     * For photo images, draw into a window by XPutImage.
+     */
+    Atom retType = None;
+    int retFormat = 32;
+    unsigned long retNitems, retBytesAfter;
+    unsigned char *retProp = NULL;
+    Visual *match = NULL;
+    int depth = 0;
+    Colormap cmap = None;
+
+    TKU_NO_BAD_WINDOW_BEGIN(Tk_Display(icon->tkwin))
+        XGetWindowProperty(Tk_Display(icon->tkwin),
+                icon->trayManager,
+                icon->a_NET_SYSTEM_TRAY_VISUAL,
+                /* offset */ 0,
+                /* length */ 1,
+                /* delete */ False,
+                /* type */ XA_VISUALID,
+                &retType, &retFormat, &retNitems,
+                &retBytesAfter, &retProp);
+    TKU_NO_BAD_WINDOW_END
+    if (retType == XA_VISUALID &&
+	    retNitems == 1 &&
+	    retFormat == 32) {
+	char numeric[256];
+	sprintf(numeric,"%ld",*(long*)retProp);
+	XFree(retProp);
+	match = Tk_GetVisual(icon->interp, icon->tkwin,
+                numeric, &depth, &cmap);
+    }
+    if (match&& depth == 32 &&
+	    match->red_mask == 0xFF0000UL &&
+	    match->green_mask == 0x00FF00UL &&
+	    match->blue_mask == 0x0000FFUL) {
+	icon->bestVisual = match;
+	icon->bestColormap = cmap;
+    } else {
+	icon->bestVisual = NULL;
+	icon->bestColormap = None;
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CreateTrayIconWindow --
+ *
+ * 	Create and configure the window for the icon tray.
+ *
+ * Results:
+ *	The window is created and displayed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+CreateTrayIconWindow(
+    DockIcon *icon)
+{
+    Tcl_InterpState saved;
+    Tk_Window tkwin;
+    Tk_Window wrapper;
+    XSetWindowAttributes attr;
+
+    saved = Tcl_SaveInterpState(icon->interp, TCL_OK);
+    /* Use the same name (tail) as the widget name, to enable
+     * name-based icon management for supporting trays, as promised by
+     * the docs.
+     */
+    tkwin = icon->drawingWin = Tk_CreateWindow(icon->interp, icon->tkwin,
+            Tk_Name(icon->tkwin), "");
+    if (tkwin) {
+	Tk_SetClass(icon->drawingWin,icon->classString);
+	Tk_CreateEventHandler(icon->drawingWin,ExposureMask|StructureNotifyMask|
+                ButtonPressMask|ButtonReleaseMask|
+                EnterWindowMask|LeaveWindowMask|PointerMotionMask,
+                TrayIconEvent,(ClientData)icon);
+	if(icon->bestVisual) {
+	    Tk_SetWindowVisual(icon->drawingWin,icon->bestVisual,
+                    32,icon->bestColormap);
+	    icon->flags |= ICON_FLAG_ARGB32;
+	    Tk_SetWindowBackground(tkwin, 0);
+	} else {
+	    Tk_SetWindowBackgroundPixmap(tkwin, ParentRelative);
+	    icon->flags &= ~ICON_FLAG_ARGB32;
+	}
+	Tk_MakeWindowExist(tkwin);
+	TKU_WmWithdraw(tkwin,icon->interp);
+	wrapper = TKU_Wrapper(tkwin,icon->interp);
+
+	attr.override_redirect = True;
+	Tk_ChangeWindowAttributes(wrapper,CWOverrideRedirect,&attr);
+	Tk_CreateEventHandler(wrapper,StructureNotifyMask,TrayIconWrapperEvent,(ClientData)icon);
+	if (!icon->bestVisual) {
+	    Tk_SetWindowBackgroundPixmap(wrapper, ParentRelative);
+	} else {
+	    Tk_SetWindowBackground(tkwin, 0);
+	}
+	icon->wrapper = TKU_XID(wrapper);
+	TrayIconForceImageChange(icon);
+    } else {
+	Tcl_BackgroundError(icon->interp);
+    }
+    Tcl_RestoreInterpState(icon->interp, saved);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * DockToManager --
+ *
+ * 	Helper function to manage icon in display.
+ *
+ * Results:
+ *	Icon is created and displayed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+DockToManager(
+    DockIcon *icon)
+{
+    icon->myManager = icon->trayManager;
+    Tk_SendVirtualEvent(icon->tkwin,Tk_GetUid("IconCreate"), NULL);
+    XembedSetState(icon, icon->visible ? XEMBED_MAPPED : 0);
+    XembedRequestDock(icon);
+}
+
+static const
+Tk_OptionSpec IconOptionSpec[] = {
+    {TK_OPTION_STRING,"-image","image","Image",
+	NULL, TCL_INDEX_NONE, offsetof(DockIcon, imageString),
+	TK_OPTION_NULL_OK, NULL,
+	ICON_CONF_IMAGE | ICON_CONF_REDISPLAY},
+    {TK_OPTION_STRING,"-class","class","Class",
+	"TrayIcon", TCL_INDEX_NONE, offsetof(DockIcon, classString),
+	0, NULL, ICON_CONF_CLASS},
+    {TK_OPTION_BOOLEAN,"-docked","docked","Docked",
+	"1", TCL_INDEX_NONE, offsetof(DockIcon, docked), 0, NULL,
+	ICON_CONF_XEMBED | ICON_CONF_REDISPLAY},
+    {TK_OPTION_BOOLEAN,"-shape","shape","Shape",
+	"0", TCL_INDEX_NONE, offsetof(DockIcon, useShapeExt), 0, NULL,
+	ICON_CONF_IMAGE | ICON_CONF_REDISPLAY},
+    {TK_OPTION_BOOLEAN,"-visible","visible","Visible",
+	"1", TCL_INDEX_NONE, offsetof(DockIcon, visible), 0, NULL,
+	ICON_CONF_XEMBED | ICON_CONF_REDISPLAY},
+    {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
+};
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TrayIconRequestSize --
+ *
+ * 	Set icon size.
+ *
+ * Results:
+ *	Icon size is obtained/set.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+TrayIconRequestSize(
+    DockIcon* icon,
+    int w,
+    int h)
+{
+    if (icon->drawingWin) {
+	if (icon->requestedWidth != w ||
+	        icon->requestedHeight != h) {
+	    Tk_SetMinimumRequestSize(icon->drawingWin,w,h);
+	    Tk_GeometryRequest(icon->drawingWin,w,h);
+	    Tk_SetGrid(icon->drawingWin,1,1,w,h);
+	    icon->requestedWidth = w;
+	    icon->requestedHeight = h;
+	}
+    } else {
+	/* Sign that no size is requested yet */
+	icon->requestedWidth = 0;
+	icon->requestedHeight = 0;
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TrayIconImageChanged --
+ *
+ * 	Fires when icon state changes.
+ *
+ * Results:
+ *	Icon changes are rendered.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+TrayIconImageChanged(
+    ClientData cd,
+    int x,
+    int y,
+    int w,
+    int h,
+    int imgw,
+    int imgh)
+{
+    DockIcon *icon = (DockIcon*) cd;
+    if (imgw != icon->imageWidth || imgh != icon->imageHeight) {
+	if (icon->offscreenImage) {
+	    XDestroyImage(icon->offscreenImage);
+	    icon->offscreenImage = NULL;
+	}
+	if (icon->offscreenPixmap) {
+	    /* its size is bad */
+	    Tk_FreePixmap(Tk_Display(icon->tkwin), icon->offscreenPixmap);
+	    icon->offscreenPixmap = None;
+	}
+	/* if some image dimension decreases,
+	 * empty areas around the image should be cleared */
+	if (imgw < icon->imageWidth || imgh < icon->imageHeight) {
+	    icon->flags |= ICON_FLAG_DIRTY_EDGES;
+	}
+    }
+    icon->imageWidth = imgw;
+    icon->imageHeight = imgh;
+    if (imgw == w && imgh == h && x == 0 && y == 0) {
+	icon->photo = NULL;	/* invalidate */
+    }
+    TrayIconRequestSize(icon,imgw,imgh);
+    EventuallyRedrawIcon(icon);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * IgnoreImageChange --
+ *
+ * 	Currently no-op.
+ *
+ * Results:
+ *	None.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+IgnoreImageChange(
+    TCL_UNUSED(void *),
+    TCL_UNUSED(int),
+    TCL_UNUSED(int),
+    TCL_UNUSED(int),
+    TCL_UNUSED(int),
+    TCL_UNUSED(int),
+    TCL_UNUSED(int))
+{
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ForceImageChange --
+ *
+ * 	Push icon changes through.
+ *
+ * Results:
+ *	Icon image is updated.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+TrayIconForceImageChange(
+    DockIcon* icon)
+{
+    if (icon->image) {
+	int w,h;
+	Tk_SizeOfImage(icon->image,&w,&h);
+	TrayIconImageChanged((ClientData)icon,0,0,w,h,w,h);
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ *  EventuallyRedrawIcon --
+ *
+ * 	Update image icon.
+ *
+ * Results:
+ *	Icon image is updated.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+EventuallyRedrawIcon(
+    DockIcon* icon)
+{
+    if (icon->drawingWin && icon->myManager) {	/* don't redraw invisible icon */
+	if (!(icon->flags & ICON_FLAG_REDRAW_PENDING)) { /* don't schedule multiple redraw ops */
+	    icon->flags |= ICON_FLAG_REDRAW_PENDING;
+	    Tcl_DoWhenIdle(DisplayIcon,(ClientData)icon);
+	}
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ *  DisplayIcon --
+ *
+ * 	Main function for displaying icon.
+ *
+ * Results:
+ *	Icon image is displayed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+DisplayIcon(
+    ClientData cd)
+{
+    DockIcon *icon = (DockIcon*)cd;
+    int w = icon->imageWidth, h = icon->imageHeight;
+    int imgx, imgy, outx, outy, outw, outh;
+    imgx = (icon->width >= w) ? 0 : -(icon->width - w)/2;
+    imgy = (icon->height >= h) ? 0 : -(icon->height - h)/2;
+    outx = (icon->width >= w) ? (icon->width - w)/2 : 0;
+    outy = (icon->height >= h) ? (icon->height - h)/2 : 0;
+    outw = (icon->width >= w) ? w : icon->width;
+    outh = (icon->height >= h) ? h : icon->height;
+
+    icon->flags &= (~ICON_FLAG_REDRAW_PENDING);
+
+    if (icon->drawingWin && icon->docked) {
+	if (icon->flags & ICON_FLAG_ARGB32) {
+	    /* ARGB32 redraw: never use a ParentRelative method, and
+	       no need to clear window except FIXME when its size changed.
+	       Draw on the offscreen pixmap instead, then copy to the window.
+	     */
+	    if (icon->offscreenPixmap == None) {
+		icon->offscreenPixmap = Tk_GetPixmap(Tk_Display(icon->drawingWin),
+                        Tk_WindowId(icon->drawingWin), w, h, 32);
+	    }
+	    if (!icon->photo) {
+		icon->photo = Tk_FindPhoto(icon->interp, icon->imageString);
+	    }
+	    if (!icon->photo && !icon->imageVisualInstance) {
+		Tcl_InterpState saved
+			= Tcl_SaveInterpState(icon->interp, TCL_OK);
+		icon->imageVisualInstance = Tk_GetImage(icon->interp,icon->drawingWin,
+                        icon->imageString, IgnoreImageChange,(ClientData)NULL);
+		Tcl_RestoreInterpState(icon->interp,saved);
+	    }
+	    if (icon->photo && !icon->offscreenImage) {
+		icon->offscreenImage = XGetImage(Tk_Display(icon->drawingWin),
+                        icon->offscreenPixmap, 0, 0, w, h, AllPlanes, ZPixmap);
+	    }
+	    if (icon->offscreenGC == None) {
+		XGCValues gcv;
+		gcv.function = GXcopy;
+		gcv.plane_mask = AllPlanes;
+		gcv.foreground = 0;
+		gcv.background = 0;
+		icon->offscreenGC = Tk_GetGC(icon->drawingWin,
+                        GCFunction|GCPlaneMask|GCForeground|GCBackground, &gcv);
+	    }
+	    if (icon->flags & ICON_FLAG_DIRTY_EDGES) {
+		XClearWindow(Tk_Display(icon->drawingWin), TKU_XID(icon->drawingWin));
+		icon->flags &= ~ICON_FLAG_DIRTY_EDGES;
+	    }
+	    if (icon->photo) {
+		Tk_PhotoImageBlock pib;
+		int cx,cy;
+		XImage *xim = icon->offscreenImage;
+		/* redraw photo using raw data */
+		Tk_PhotoGetImage(icon->photo,&pib);
+		for (cy = 0; cy < h; ++cy) {
+		    for (cx = 0; cx < w; ++cx) {
+			XPutPixel(xim,cx,cy,
+				  (*(pib.pixelPtr +
+				     pib.pixelSize*cx +
+				     pib.pitch*cy +
+				     pib.offset[0])<<16) |
+				  (*(pib.pixelPtr +
+				     pib.pixelSize*cx +
+				     pib.pitch*cy +
+				     pib.offset[1])<<8) |
+				  (*(pib.pixelPtr +
+				     pib.pixelSize*cx +
+				     pib.pitch*cy +
+				     pib.offset[2])) |
+				  (pib.offset[3] ?
+				   (*(pib.pixelPtr +
+				      pib.pixelSize*cx +
+				      pib.pitch*cy +
+				      pib.offset[3])<<24) : 0));
+		    }
+		}
+		XPutImage(Tk_Display(icon->drawingWin),
+			icon->offscreenPixmap,
+			icon->offscreenGC,
+			icon->offscreenImage,
+			0,0,0,0,w,h);
+	    } else {
+		XFillRectangle(Tk_Display(icon->drawingWin),
+			icon->offscreenPixmap,
+			icon->offscreenGC,
+			0,0,w,h);
+		if (icon->imageVisualInstance) {
+		    Tk_RedrawImage(icon->imageVisualInstance,
+                            0,0,w,h,
+                            icon->offscreenPixmap,
+                            0,0);
+		}
+	    }
+	    XCopyArea(Tk_Display(icon->drawingWin),
+                    icon->offscreenPixmap,
+                    TKU_XID(icon->drawingWin),
+                    icon->offscreenGC,
+                    imgx,imgy,outw,outh,outx,outy);
+	} else {
+	    /* Non-argb redraw: clear window and draw an image over it.
+	       For photos it gives a correct alpha blending with a parent
+	       window background, even if it's a fancy pixmap (proved to
+	       work with lxpanel fancy backgrounds).
+	    */
+	    XClearWindow(Tk_Display(icon->drawingWin),
+                    TKU_XID(icon->drawingWin));
+	    if (icon->image && icon->visible) {
+		Tk_RedrawImage(icon->image,imgx,imgy,outw,outh,
+                        TKU_XID(icon->drawingWin), outx, outy);
+	    }
+	}
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ *  RetargetEvent --
+ *
+ * 	Redirect X events to widgets.
+ *
+ * Results:
+ *	Icon image is displayed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+RetargetEvent(
+    DockIcon *icon,
+    XEvent *ev)
+{
+    int send = 0;
+    Window* saveWin1 = NULL, *saveWin2 = NULL;
+    if (!icon->visible)
+	return;
+    switch (ev->type) {
+    case MotionNotify:
+	send = 1;
+	saveWin1 = &ev->xmotion.subwindow;
+	saveWin2 = &ev->xmotion.window;
+	break;
+    case LeaveNotify:
+    case EnterNotify:
+	send = 1;
+	saveWin1 = &ev->xcrossing.subwindow;
+	saveWin2 = &ev->xcrossing.window;
+	break;
+    case ButtonPress:
+    case ButtonRelease:
+	send = 1;
+	saveWin1 = &ev->xbutton.subwindow;
+	saveWin2 = &ev->xbutton.window;
+	break;
+    case MappingNotify:
+	send = 1;
+	saveWin1 = &ev->xmapping.window;
+    }
+    if (saveWin1) {
+	Tk_MakeWindowExist(icon->tkwin);
+	*saveWin1 = Tk_WindowId(icon->tkwin);
+	if (saveWin2) *saveWin2 = *saveWin1;
+    }
+    if (send) {
+	ev->xany.send_event = 0x147321ac;
+	Tk_HandleEvent(ev);
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ *  TrayIconWrapperEvent --
+ *
+ * 	Ensure automapping in root window is done in withdrawn state.
+ *
+ * Results:
+ *	Icon image is displayed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+TrayIconWrapperEvent(
+    ClientData cd,
+    XEvent* ev)
+{
+  /* Some embedders, like Docker, add icon windows to save set
+   * (XAddToSaveSet), so when they crash the icon is reparented to root.
+   * We have to make sure that automatic mapping in root is done in
+   * withdrawn state (no way to prevent it entirely)
+   */
+    DockIcon *icon = (DockIcon*)cd;
+    XWindowAttributes attr;
+    if (icon->drawingWin) {
+	switch(ev->type) {
+	case ReparentNotify:
+	    /* With virtual roots and screen roots etc, the only way
+	       to check for reparent-to-root is to ask for this root
+	       first */
+	    XGetWindowAttributes(ev->xreparent.display,
+                    ev->xreparent.window, &attr);
+	    if (attr.root == ev->xreparent.parent) {
+		/* upon reparent to root, */
+		if (icon->drawingWin) {
+		    /* we were sent away to root */
+		    TKU_WmWithdraw(icon->drawingWin,icon->interp);
+		    if (icon->myManager)
+			Tk_SendVirtualEvent(icon->tkwin,Tk_GetUid("IconDestroy"), NULL);
+		    icon->myManager = None;
+		}
+	    } /* Reparenting into some other embedder is theoretically possible,
+	       * and everything would just work in this case.
+               */
+	    break;
+	}
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TrayIconEvent --
+ *
+ * 	Handle X events.
+ *
+ * Results:
+ *	Events are handled and processed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+TrayIconEvent(
+    ClientData cd,
+    XEvent* ev)
+{
+    DockIcon *icon = (DockIcon*)cd;
+
+    switch (ev->type) {
+    case Expose:
+	if (!ev->xexpose.count)
+	    EventuallyRedrawIcon(icon);
+	break;
+
+    case DestroyNotify:
+	/* If anonymous window is destroyed first, then either
+	 * something went wrong with a tray (if -visible) or we just
+	 * reconfigured to invisibility: nothing to be done in both
+	 * cases.
+	 * If unreal window is destroyed first, freeing the data structures
+	 * is the only thing to do.
+	 */
+	if (icon->myManager) {
+	    Tk_SendVirtualEvent(icon->tkwin,Tk_GetUid("IconDestroy"), NULL);
+	}
+	Tcl_CancelIdleCall(DisplayIcon,(ClientData)icon);
+	icon->flags &= ~ICON_FLAG_REDRAW_PENDING;
+	icon->drawingWin = NULL;
+	icon->requestedWidth = 0; /* trigger re-request on recreation */
+	icon->requestedHeight = 0;
+	icon->wrapper = None;
+	icon->myManager = None;
+	break;
+
+    case ConfigureNotify:
+	Tk_SendVirtualEvent(icon->tkwin,Tk_GetUid("IconConfigure"), NULL);
+	if (icon->width != ev->xconfigure.width ||
+	        icon->height != ev->xconfigure.height) {
+	    icon->width = ev->xconfigure.width;
+	    icon->height = ev->xconfigure.height;
+	    icon->flags |= ICON_FLAG_DIRTY_EDGES;
+	    EventuallyRedrawIcon(icon);
+	}
+	RetargetEvent(icon,ev);
+	break;
+
+    case MotionNotify:  /* fall through */
+    case ButtonPress:   /* fall through */
+    case ButtonRelease: /* fall through */
+    case EnterNotify:   /* fall through */
+    case LeaveNotify:
+	RetargetEvent(icon,ev);
+	break;
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * UserIconEvent --
+ *
+ * 	Handle user events.
+ *
+ * Results:
+ *	Events are handled and processed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+UserIconEvent(
+    ClientData cd,
+    XEvent* ev)
+{
+    DockIcon *icon = (DockIcon*)cd;
+
+    switch (ev->type) {
+
+    case DestroyNotify:
+	Tk_DeleteGenericHandler(IconGenericHandler, (ClientData)icon);
+	if(icon->drawingWin) {
+	    icon->visible = 0;
+	    Tcl_CancelIdleCall(DisplayIcon,(ClientData)icon);
+	    icon->flags &= ~ICON_FLAG_REDRAW_PENDING;
+	    Tk_DestroyWindow(icon->drawingWin);
+	}
+	if(icon->imageVisualInstance) {
+	    Tk_FreeImage(icon->imageVisualInstance);
+	    icon->image = NULL;
+	}
+	if(icon->offscreenImage) {
+	    XDestroyImage(icon->offscreenImage);
+	    icon->offscreenImage = NULL;
+	}
+	if(icon->offscreenGC) {
+	    Tk_FreeGC(Tk_Display(icon->tkwin),icon->offscreenGC);
+	    icon->offscreenGC = NULL;
+	}
+	if(icon->offscreenPixmap) {
+	    Tk_FreePixmap(Tk_Display(icon->tkwin),icon->offscreenPixmap);
+	}
+	if(icon->image) {
+	    Tk_FreeImage(icon->image);
+	    icon->image = NULL;
+	}
+	if(icon->widgetCmd)
+	    Tcl_DeleteCommandFromToken(icon->interp,icon->widgetCmd);
+	Tk_FreeConfigOptions((char*)icon, icon->options, icon->tkwin);
+	break;
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * PostBalloon --
+ *
+ * 	Display tooltip/balloon window over tray icon.
+ *
+ * Results:
+ *	Window is displayed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+PostBalloon(
+    DockIcon *icon,
+    const char *utf8msg,
+    long timeout)
+{
+    Tk_Window tkwin = icon -> tkwin;
+    Display* dpy = Tk_Display(tkwin);
+    int length = strlen(utf8msg);
+    XEvent ev;
+
+    if (!(icon->drawingWin) || (icon->myManager == None))
+	return 0;
+
+    /* overflow protection */
+    if (icon->msgid < 0)
+	icon->msgid = 0;
+
+    memset(&ev, 0, sizeof(ev));
+    ev.xclient.type = ClientMessage;
+    ev.xclient.window = icon->wrapper;
+    ev.xclient.message_type = icon->a_NET_SYSTEM_TRAY_OPCODE;
+    ev.xclient.format = 32;
+    ev.xclient.data.l[0] = CurrentTime;
+    ev.xclient.data.l[1] = SYSTEM_TRAY_BEGIN_MESSAGE;
+    ev.xclient.data.l[2] = timeout;
+    ev.xclient.data.l[3] = length;
+    ev.xclient.data.l[4] = ++icon->msgid;
+    TKU_NO_BAD_WINDOW_BEGIN(Tk_Display(icon->tkwin))
+	XSendEvent(dpy, icon->myManager , True, StructureNotifyMask|SubstructureNotifyMask, &ev);
+        XSync(dpy, False);
+
+        /* Sending message elements */
+        while (length>0) {
+	    ev.type = ClientMessage;
+	    ev.xclient.window = icon->wrapper;
+	    ev.xclient.message_type = icon->a_NET_SYSTEM_TRAY_MESSAGE_DATA;
+	    ev.xclient.format = 8;
+	    memset(ev.xclient.data.b,0,20);
+	    strncpy(ev.xclient.data.b,utf8msg,length<20?length:20);
+	    XSendEvent(dpy, icon->myManager, True, StructureNotifyMask|SubstructureNotifyMask, &ev);
+	    XSync(dpy,False);
+	    utf8msg += 20;
+	    length -= 20;
+        }
+    TKU_NO_BAD_WINDOW_END;
+    return icon->msgid;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CancelBalloon --
+ *
+ * 	Remove balloon from display over tray icon.
+ *
+ * Results:
+ *	Window is destroyed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+CancelBalloon(
+    DockIcon *icon,
+    int msgid)
+{
+    Tk_Window tkwin = icon -> tkwin;
+    Display* dpy = Tk_Display(tkwin);
+    XEvent ev;
+
+    if (!(icon->drawingWin) || (icon->myManager == None))
+	return;
+    /* overflow protection */
+    if (icon->msgid < 0)
+	icon->msgid = 0;
+
+    memset(&ev, 0, sizeof(ev));
+    ev.type = ClientMessage;
+    ev.xclient.window = icon->wrapper;
+    ev.xclient.message_type = icon->a_NET_SYSTEM_TRAY_OPCODE;
+    ev.xclient.format = 32;
+    ev.xclient.data.l[0] = CurrentTime;
+    ev.xclient.data.l[1] = SYSTEM_TRAY_CANCEL_MESSAGE;
+    ev.xclient.data.l[2]  =msgid;
+    TKU_NO_BAD_WINDOW_BEGIN(Tk_Display(icon->tkwin))
+	XSendEvent(dpy, icon->myManager , True,
+                StructureNotifyMask|SubstructureNotifyMask, &ev);
+    TKU_NO_BAD_WINDOW_END
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * IconGenericHandler --
+ *
+ * 	Process non-tk events.
+ *
+ * Results:
+ *	Events are processed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+IconGenericHandler(
+    ClientData cd,
+    XEvent *ev)
+{
+    DockIcon *icon = (DockIcon*)cd;
+
+    if ((ev->type == ClientMessage) &&
+	    (ev->xclient.message_type == icon->aMANAGER) &&
+	    ((Atom)ev->xclient.data.l[1] == icon->a_NET_SYSTEM_TRAY_Sn)) {
+	icon->trayManager = (Window)ev->xclient.data.l[2];
+	XSelectInput(ev->xclient.display,icon->trayManager,StructureNotifyMask);
+	if (icon->myManager == None)
+	    TrayIconUpdate(icon, ICON_CONF_XEMBED);
+	return 1;
+    }
+    if (ev->type == DestroyNotify) {
+	if (ev->xdestroywindow.window == icon->trayManager) {
+	    icon->trayManager = None;
+	}
+	if (ev->xdestroywindow.window == icon->myManager) {
+	    icon->myManager = None;
+	    icon->wrapper = None;
+	    if (icon->drawingWin) {
+		Tk_DestroyWindow(icon->drawingWin);
+		icon->drawingWin = NULL;
+	    }
+	}
+    }
+    return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TrayIconUpdate --
+ *
+ * 	Get in touch with new options that are certainly valid.
+ *
+ * Results:
+ *	Options updated.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+TrayIconUpdate(
+    DockIcon *icon,
+    int mask)
+{
+    /* why should someone need this option?
+     * anyway, let's handle it if we provide it.
+     */
+    if (mask & ICON_CONF_CLASS) {
+	if (icon->drawingWin)
+	    Tk_SetClass(icon->drawingWin,Tk_GetUid(icon->classString));
+    }
+    /*
+     * First, ensure right icon visibility.
+     * If should be visible and not yet managed,
+     * we have to get the tray or wait for it.
+     * If should be invisible and managed,
+     * real-window is simply destroyed.
+     * If should be invisible and not managed,
+     * generic handler should be abandoned.
+     */
+    if (mask & ICON_CONF_XEMBED) {
+	if (icon->myManager == None &&
+	        icon->trayManager != None &&
+	        icon->docked) {
+	    CheckArgbVisual(icon);
+	    if (icon->drawingWin &&
+		    ((icon->bestVisual && !(icon->flags & ICON_FLAG_ARGB32)) ||
+		     (!icon->bestVisual && (icon->flags & ICON_FLAG_ARGB32)))) {
+		icon->myManager = None;
+		icon->wrapper = None;
+		icon->requestedWidth = icon->requestedHeight = 0;
+		Tk_DestroyWindow(icon->drawingWin);
+		icon->drawingWin = NULL;
+	    }
+	    if (!icon->drawingWin) {
+		CreateTrayIconWindow(icon);
+	    }
+	    if (icon->drawingWin) {
+		DockToManager(icon);
+	    }
+	}
+	if (icon->myManager != None &&
+	        icon->drawingWin != NULL &&
+	        !icon->docked) {
+	    Tk_DestroyWindow(icon->drawingWin);
+	    icon->drawingWin = NULL;
+	    icon->myManager = None;
+	    icon->wrapper = None;
+	}
+	if (icon->drawingWin) {
+	    XembedSetState(icon, icon->visible ? XEMBED_MAPPED : 0);
+	}
+    }
+    if (mask & ICON_CONF_IMAGE) {
+	TrayIconForceImageChange(icon);
+    }
+    if (mask & ICON_CONF_REDISPLAY) {
+	EventuallyRedrawIcon(icon);
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TrayIconConfigureMethod --
+ *
+ *      Returns TCL_ERROR if some option is invalid,
+ *      or else retrieve resource references and free old resources.
+ *
+ * Results:
+ *	Widget configured.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TrayIconConfigureMethod(
+    DockIcon *icon,
+    Tcl_Interp* interp,
+    int objc,
+    Tcl_Obj *const objv[],
+    int addflags)
+{
+    Tk_SavedOptions saved;
+    Tk_Image newImage = NULL;
+    int mask = 0;
+
+    if (objc <= 1 && !(addflags & ICON_CONF_FIRST_TIME)) {
+	Tcl_Obj* info = Tk_GetOptionInfo(interp, (char*)icon, icon->options,
+                objc? objv[0] : NULL, icon->tkwin);
+	if (info) {
+	    Tcl_SetObjResult(interp,info);
+	    return TCL_OK;
+	} else {
+	    return TCL_ERROR; /* msg by Tk_GetOptionInfo */
+	}
+    }
+
+    if (Tk_SetOptions(interp,(char*)icon,icon->options,objc,objv,
+            icon->tkwin,&saved,&mask) != TCL_OK) {
+	return TCL_ERROR; /* msg by Tk_SetOptions */
+    }
+    mask |= addflags;
+    /* now check option validity */
+    if (mask & ICON_CONF_IMAGE) {
+	if (icon->imageString) {
+	    newImage = Tk_GetImage(interp, icon->tkwin, icon->imageString,
+                    TrayIconImageChanged, (ClientData)icon);
+	    if (!newImage) {
+		Tk_RestoreSavedOptions(&saved);
+		return TCL_ERROR; /* msg by Tk_GetImage */
+	    }
+	}
+	if (icon->image) {
+	    Tk_FreeImage(icon->image);
+	    icon->image = NULL;
+	}
+	if (icon->imageVisualInstance) {
+	    Tk_FreeImage(icon->imageVisualInstance);
+	    icon->imageVisualInstance = NULL;
+	}
+	icon->image = newImage; /* may be null, as intended */
+	icon->photo = NULL; /* invalidate photo reference */
+    }
+    Tk_FreeSavedOptions(&saved);
+    /* Now as we are reconfigured... */
+    TrayIconUpdate(icon,mask);
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TrayIconDeleteProc --
+ *
+ *      Delete tray window and clean up.
+ *
+ * Results:
+ *	Window destroyed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+TrayIconDeleteProc(
+    ClientData cd )
+{
+    DockIcon *icon = (DockIcon *)cd;
+    Tk_DestroyWindow(icon->tkwin);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TrayIconCreateCmd --
+ *
+ *      Create tray command and (unreal) window.
+ *
+ * Results:
+ *	Icon tray and hidden window created.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TrayIconCreateCmd(
+    ClientData cd,
+    Tcl_Interp *interp,
+    int objc,
+    Tcl_Obj *const objv[])
+{
+    Tk_Window mainWindow = (Tk_Window)cd;
+    DockIcon *icon;
+
+    icon = (DockIcon*)attemptckalloc(sizeof(DockIcon));
+    if (!icon) {
+	Tcl_SetObjResult(interp, Tcl_NewStringObj("running out of memory", -1));
+	goto handleErrors;
+    }
+    memset(icon,0,sizeof(*icon));
+
+    if (objc < 2||(objc%2)) {
+	Tcl_WrongNumArgs(interp, 1, objv, "pathName ?option value ...?");
+	goto handleErrors;
+    }
+
+    /* It's not a toplevel window by now. It really doesn't matter,
+     * because it's not really shown.
+     */
+    icon->tkwin = Tk_CreateWindowFromPath(interp, mainWindow,
+            Tcl_GetString(objv[1]),"");
+    if (icon->tkwin == NULL) {
+	goto handleErrors;
+    }
+
+    /* Subscribe to StructureNotify */
+    TKU_AddInput(Tk_Display(icon->tkwin),
+            RootWindowOfScreen(Tk_Screen(icon->tkwin)),StructureNotifyMask);
+    TKU_AddInput(Tk_Display(icon->tkwin),
+            RootWindow(Tk_Display(icon->tkwin),0),StructureNotifyMask);
+    /* Spec says "screen 0" not "default", but... */
+    TKU_AddInput(Tk_Display(icon->tkwin),
+            DefaultRootWindow(Tk_Display(icon->tkwin)),StructureNotifyMask);
+
+    /* Early tracking of DestroyNotify is essential */
+    Tk_CreateEventHandler(icon->tkwin,StructureNotifyMask,
+            UserIconEvent,(ClientData)icon);
+
+    /* Now try setting options */
+    icon->options = Tk_CreateOptionTable(interp,IconOptionSpec);
+    /* Class name is used for retrieving defaults, so... */
+    Tk_SetClass(icon->tkwin, Tk_GetUid("TrayIcon"));
+    if (Tk_InitOptions(interp,(char*)icon,icon->options,icon->tkwin) != TCL_OK) {
+	goto handleErrors;
+    }
+
+    icon->a_NET_SYSTEM_TRAY_Sn = DockSelectionAtomFor(icon->tkwin);
+    icon->a_NET_SYSTEM_TRAY_OPCODE = Tk_InternAtom(icon->tkwin,"_NET_SYSTEM_TRAY_OPCODE");
+    icon->a_NET_SYSTEM_TRAY_MESSAGE_DATA = Tk_InternAtom(icon->tkwin,"_NET_SYSTEM_TRAY_MESSAGE_DATA");
+    icon->a_NET_SYSTEM_TRAY_ORIENTATION = Tk_InternAtom(icon->tkwin,"_NET_SYSTEM_TRAY_ORIENTATION");
+    icon->a_NET_SYSTEM_TRAY_VISUAL = Tk_InternAtom(icon->tkwin,"_NET_SYSTEM_TRAY_VISUAL");
+    icon->a_XEMBED_INFO = Tk_InternAtom(icon->tkwin,"_XEMBED_INFO");
+    icon->aMANAGER = Tk_InternAtom(icon->tkwin,"MANAGER");
+
+    icon->interp = interp;
+
+    icon->trayManager = XGetSelectionOwner(Tk_Display(icon->tkwin), icon->a_NET_SYSTEM_TRAY_Sn);
+    if (icon->trayManager) {
+	XSelectInput(Tk_Display(icon->tkwin),icon->trayManager, StructureNotifyMask);
+    }
+
+    Tk_CreateGenericHandler(IconGenericHandler, (ClientData)icon);
+
+    if (objc>3) {
+	if (TrayIconConfigureMethod(icon, interp, objc-2, objv+2,
+                ICON_CONF_XEMBED|ICON_CONF_IMAGE|ICON_CONF_FIRST_TIME) != TCL_OK) {
+	    goto handleErrors;
+	}
+    }
+
+    icon->widgetCmd = Tcl_CreateObjCommand(interp, Tcl_GetString(objv[1]),
+            TrayIconObjectCmd, (ClientData)icon, TrayIconDeleteProc);
+
+    /* Sometimes a command just can't be created... */
+    if (!icon->widgetCmd) {
+	goto handleErrors;
+    }
+
+    Tcl_SetObjResult(interp,objv[1]);
+    return TCL_OK;
+
+handleErrors:
+    /* Rolling back */
+    if (icon) {
+	if (icon->options) {
+	    Tk_DeleteOptionTable(icon->options);
+	    icon->options = NULL;
+	}
+	if (icon->tkwin) {
+	    /* Resources will be freed by DestroyNotify handler */
+	    Tk_DestroyWindow(icon->tkwin);
+	}
+	ckfree((char*)icon);
+    }
+    return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tktray_Init --
+ *
+ *      Initialize the command.
+ *
+ * Results:
+ *	Command initialized.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+Tktray_Init(
+    Tcl_Interp *interp)
+{
+    Tcl_CreateObjCommand(interp, "::tk::systray::_systray",
+            TrayIconCreateCmd, Tk_MainWindow(interp), NULL);
+    return TCL_OK;
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */

Index: unix/tkUnixWm.c
==================================================================
--- unix/tkUnixWm.c
+++ unix/tkUnixWm.c
@@ -4,12 +4,12 @@
  *	This module takes care of the interactions between a Tk-based
  *	application and the window manager. Among other things, it implements
  *	the "wm" command and passes geometry information to the window
  *	manager.
  *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -48,17 +48,17 @@
     int zoomed;			/* Flag: true=>maximized */
     int fullscreen;		/* Flag: true=>fullscreen */
 } WmAttributes;
 
 typedef enum {
-    WMATT_ALPHA, WMATT_TOPMOST, WMATT_ZOOMED, WMATT_FULLSCREEN,
-    WMATT_TYPE, _WMATT_LAST_ATTRIBUTE
+    WMATT_ALPHA, WMATT_FULLSCREEN, WMATT_TOPMOST, WMATT_TYPE,
+    WMATT_ZOOMED, _WMATT_LAST_ATTRIBUTE
 } WmAttribute;
 
 static const char *const WmAttributeNames[] = {
-    "-alpha", "-topmost", "-zoomed", "-fullscreen",
-    "-type", NULL
+    "-alpha", "-fullscreen", "-topmost", "-type",
+    "-zoomed", NULL
 };
 
 /*
  * A data structure of the following type holds window-manager-related
  * information for each top-level window in an application.
@@ -411,10 +411,13 @@
 static int		WmGridCmd(Tk_Window tkwin, TkWindow *winPtr,
 			    Tcl_Interp *interp, int objc,
 			    Tcl_Obj *const objv[]);
 static int		WmGroupCmd(Tk_Window tkwin, TkWindow *winPtr,
 			    Tcl_Interp *interp, int objc,
+			    Tcl_Obj *const objv[]);
+static int		WmIconbadgeCmd(Tk_Window tkwin, TkWindow *winPtr,
+			    Tcl_Interp *interp, int objc,
 			    Tcl_Obj *const objv[]);
 static int		WmIconbitmapCmd(Tk_Window tkwin, TkWindow *winPtr,
 			    Tcl_Interp *interp, int objc,
 			    Tcl_Obj *const objv[]);
 static int		WmIconifyCmd(Tk_Window tkwin, TkWindow *winPtr,
@@ -708,11 +711,11 @@
 	UpdateWmProtocols(wmPtr);
 	if (wmPtr->cmdArgv != NULL) {
 	    UpdateCommand(winPtr);
 	}
 	if (wmPtr->clientMachine != NULL) {
-	    Tcl_UtfToExternalDString(NULL, wmPtr->clientMachine, -1, &ds);
+	    (void)Tcl_UtfToExternalDStringEx(NULL, wmPtr->clientMachine, -1, TCL_ENCODING_NOCOMPLAIN, &ds);
 	    if (XStringListToTextProperty(&(Tcl_DStringValue(&ds)), 1,
 		    &textProp) != 0) {
 		unsigned long pid = (unsigned long) getpid();
 
 		XSetWMClientMachine(winPtr->display,
@@ -980,12 +983,12 @@
 
     if (winPtr->classUid != NULL) {
 	XClassHint *classPtr;
 	Tcl_DString name, ds;
 
-	Tcl_UtfToExternalDString(NULL, winPtr->nameUid, -1, &name);
-	Tcl_UtfToExternalDString(NULL, winPtr->classUid, -1, &ds);
+	(void)Tcl_UtfToExternalDStringEx(NULL, winPtr->nameUid, -1, TCL_ENCODING_NOCOMPLAIN, &name);
+	(void)Tcl_UtfToExternalDStringEx(NULL, winPtr->classUid, -1, TCL_ENCODING_NOCOMPLAIN, &ds);
 	classPtr = XAllocClassHint();
 	classPtr->res_name = Tcl_DStringValue(&name);
 	classPtr->res_class = Tcl_DStringValue(&ds);
 	XSetClassHint(winPtr->display, winPtr->wmInfoPtr->wrapperPtr->window,
 		classPtr);
@@ -1014,21 +1017,21 @@
 {
     Tk_Window tkwin = (Tk_Window)clientData;
     static const char *const optionStrings[] = {
 	"aspect", "attributes", "client", "colormapwindows",
 	"command", "deiconify", "focusmodel", "forget",
-	"frame", "geometry", "grid", "group", "iconbitmap",
+	"frame", "geometry", "grid", "group", "iconbadge", "iconbitmap",
 	"iconify", "iconmask", "iconname", "iconphoto",
 	"iconposition", "iconwindow", "manage", "maxsize",
 	"minsize", "overrideredirect", "positionfrom",
 	"protocol", "resizable", "sizefrom", "stackorder",
 	"state", "title", "transient", "withdraw", NULL };
     enum options {
 	WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
 	WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FORGET,
 	WMOPT_FRAME, WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP,
-	WMOPT_ICONBITMAP,
+	WMOPT_ICONBADGE, WMOPT_ICONBITMAP,
 	WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME, WMOPT_ICONPHOTO,
 	WMOPT_ICONPOSITION, WMOPT_ICONWINDOW, WMOPT_MANAGE, WMOPT_MAXSIZE,
 	WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT, WMOPT_POSITIONFROM,
 	WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM, WMOPT_STACKORDER,
 	WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT, WMOPT_WITHDRAW };
@@ -1114,10 +1117,12 @@
 	return WmGeometryCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_GRID:
 	return WmGridCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_GROUP:
 	return WmGroupCmd(tkwin, winPtr, interp, objc, objv);
+    case WMOPT_ICONBADGE:
+	return WmIconbadgeCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_ICONBITMAP:
 	return WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_ICONIFY:
 	return WmIconifyCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_ICONMASK:
@@ -1487,11 +1492,11 @@
     strcpy(wmPtr->clientMachine, argv3);
     if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
 	XTextProperty textProp;
 	Tcl_DString ds;
 
-	Tcl_UtfToExternalDString(NULL, wmPtr->clientMachine, -1, &ds);
+	(void)Tcl_UtfToExternalDStringEx(NULL, wmPtr->clientMachine, -1, TCL_ENCODING_NOCOMPLAIN, &ds);
 	if (XStringListToTextProperty(&(Tcl_DStringValue(&ds)), 1,
 		&textProp) != 0) {
 	    unsigned long pid = (unsigned long) getpid();
 
 	    XSetWMClientMachine(winPtr->display, wmPtr->wrapperPtr->window,
@@ -2114,10 +2119,52 @@
 	strcpy(wmPtr->leaderName, argv3);
     }
     UpdateHints(winPtr);
     return TCL_OK;
 }
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * WmIconbadgeCmd --
+ *
+ *	This function is invoked to process the "wm iconbadge" Tcl command.
+ *	See the user documentation for details on what it does.
+ *
+ * Results:
+ *	A standard Tcl result.
+ *
+ * Side effects:
+ *	See the user documentation.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+WmIconbadgeCmd(
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
+    TkWindow *tkWin,		/* Toplevel to work with */
+    Tcl_Interp *interp,		/* Current interpreter. */
+    int objc,			/* Number of arguments. */
+    Tcl_Obj *const objv[])	/* Argument objects. */
+{
+    (void) tkWin;
+    char cmd[4096];
+
+    if (objc < 4) {
+	Tcl_WrongNumArgs(interp, 2, objv, "window badge");
+	return TCL_ERROR;
+    }
+
+    sprintf(cmd, "::tk::icons::IconBadge {%s} {%s}",
+	    Tcl_GetString(objv[2]),
+	    Tcl_GetString(objv[3]));
+    if (Tcl_EvalEx(interp, cmd, -1, TCL_EVAL_DIRECT) != TCL_OK) {
+	return TCL_ERROR;
+    }
+    return TCL_OK;
+}
 
 /*
  *----------------------------------------------------------------------
  *
  * WmIconbitmapCmd --
@@ -3073,11 +3120,11 @@
 	    }
 	    Tcl_EventuallyFree(protPtr, TCL_DYNAMIC);
 	    break;
 	}
     }
-    cmd = TkGetStringFromObj(objv[4], &cmdLength);
+    cmd = Tcl_GetStringFromObj(objv[4], &cmdLength);
     if (cmdLength > 0) {
 	protPtr = (ProtocolHandler *)ckalloc(HANDLER_SIZE(cmdLength));
 	protPtr->protocol = protocol;
 	protPtr->nextPtr = wmPtr->protPtr;
 	wmPtr->protPtr = protPtr;
@@ -3366,13 +3413,13 @@
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     static const char *const optionStrings[] = {
-	"normal", "iconic", "withdrawn", NULL };
+	"iconic", "normal", "withdrawn", NULL };
     enum options {
-	OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN };
+	OPT_ICONIC, OPT_NORMAL, OPT_WITHDRAWN };
     int index;
 
     if ((objc < 3) || (objc > 4)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?state?");
 	return TCL_ERROR;
@@ -3594,11 +3641,11 @@
 	    Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
 	    return TCL_ERROR;
 	}
 
 	for (w = containerPtr; w != NULL && w->wmInfoPtr != NULL;
-	     w = (TkWindow *)w->wmInfoPtr->containerPtr) {
+	    w = (TkWindow *)w->wmInfoPtr->containerPtr) {
 	    if (w == winPtr) {
 		Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 		    "can't set \"%s\" as container: would cause management loop",
 		    Tk_PathName(containerPtr)));
 		Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL);
@@ -4707,11 +4754,11 @@
      *	  position on the screen.
      */
 
     if ((winPtr->flags & (TK_EMBEDDED|TK_BOTH_HALVES))
 	    == (TK_EMBEDDED|TK_BOTH_HALVES)) {
-	TkWindow *childPtr = TkpGetOtherWindow(winPtr);
+	Tk_Window childPtr = Tk_GetOtherWindow((Tk_Window)winPtr);
 
 	/*
 	 * This window is embedded and the container is also in this process,
 	 * so we don't need to do anything special about the geometry, except
 	 * to make sure that the desired size is known by the container. Also,
@@ -4721,11 +4768,11 @@
 
 	wmPtr->x = wmPtr->y = 0;
 	wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y);
 	height += wmPtr->menuHeight;
 	if (childPtr != NULL) {
-	    Tk_GeometryRequest((Tk_Window) childPtr, width, height);
+	    Tk_GeometryRequest(childPtr, width, height);
 	}
 	return;
     }
     serial = NextRequest(winPtr->display);
     height += wmPtr->menuHeight;
@@ -4930,11 +4977,11 @@
     /*
      * Set window title:
      */
 
     string = (wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid;
-    Tcl_UtfToExternalDString(NULL, string, -1, &ds);
+    (void)Tcl_UtfToExternalDStringEx(NULL, string, -1, TCL_ENCODING_NOCOMPLAIN, &ds);
     XStoreName(winPtr->display, wmPtr->wrapperPtr->window,
 	    Tcl_DStringValue(&ds));
     Tcl_DStringFree(&ds);
 
     SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_NAME", XA_UTF8_STRING, 8,
@@ -4943,11 +4990,11 @@
     /*
      * Set icon name:
      */
 
     if (wmPtr->iconName != NULL) {
-	Tcl_UtfToExternalDString(NULL, wmPtr->iconName, -1, &ds);
+	(void)Tcl_UtfToExternalDStringEx(NULL, wmPtr->iconName, -1, TCL_ENCODING_NOCOMPLAIN, &ds);
 	XSetIconName(winPtr->display, wmPtr->wrapperPtr->window,
 		Tcl_DStringValue(&ds));
 	Tcl_DStringFree(&ds);
 
 	SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_ICON_NAME",
@@ -5460,14 +5507,14 @@
     }
 
     for (n = 0; n < objc; ++n) {
 	Tcl_DString ds, dsName;
 	TkSizeT len;
-	char *name = TkGetStringFromObj(objv[n], &len);
+	char *name = Tcl_GetStringFromObj(objv[n], &len);
 
 	Tcl_UtfToUpper(name);
-	Tcl_UtfToExternalDString(NULL, name, len, &dsName);
+	(void)Tcl_UtfToExternalDStringEx(NULL, name, len, TCL_ENCODING_NOCOMPLAIN, &dsName);
 	Tcl_DStringInit(&ds);
 	Tcl_DStringAppend(&ds, "_NET_WM_WINDOW_TYPE_", 20);
 	Tcl_DStringAppend(&ds, Tcl_DStringValue(&dsName),
 		Tcl_DStringLength(&dsName));
 	Tcl_DStringFree(&dsName);
@@ -5527,11 +5574,11 @@
 	atoms = (Atom *) propertyValue;
 	for (n = 0; n < count; ++n) {
 	    const char *name = Tk_GetAtomName(tkwin, atoms[n]);
 
 	    if (strncmp("_NET_WM_WINDOW_TYPE_", name, 20) == 0) {
-		Tcl_ExternalToUtfDString(NULL, name+20, -1, &ds);
+		(void)Tcl_ExternalToUtfDStringEx(NULL, name+20, -1, TCL_ENCODING_NOCOMPLAIN, &ds);
 		Tcl_UtfToLower(Tcl_DStringValue(&ds));
 		Tcl_ListObjAppendElement(interp, typePtr,
 			Tcl_NewStringObj(Tcl_DStringValue(&ds),
 				Tcl_DStringLength(&ds)));
 		Tcl_DStringFree(&ds);
@@ -5727,16 +5774,16 @@
 	    y -= winPtr->wmInfoPtr->menuHeight;
 	    winPtr = winPtr->wmInfoPtr->winPtr;
 	    continue;
 	}
 	if (winPtr->flags & TK_TOP_LEVEL) {
-	    TkWindow *otherPtr;
+	    Tk_Window otherPtr;
 
 	    if (!(winPtr->flags & TK_EMBEDDED)) {
 		break;
 	    }
-	    otherPtr = TkpGetOtherWindow(winPtr);
+	    otherPtr = Tk_GetOtherWindow((Tk_Window)winPtr);
 	    if (otherPtr == NULL) {
 		/*
 		 * The container window is not in the same application. Query
 		 * the X server.
 		 */
@@ -5757,11 +5804,11 @@
 		/*
 		 * The container window is in the same application. Let's
 		 * query its coordinates.
 		 */
 
-		winPtr = otherPtr;
+		winPtr = (TkWindow *)otherPtr;
 		continue;
 	    }
 	}
 	winPtr = winPtr->parentPtr;
 	if (winPtr == NULL) {
@@ -5891,11 +5938,11 @@
 	    }
 	    if (wmPtr->wrapperPtr != NULL) {
 		if (child == wmPtr->wrapperPtr->window) {
 		    goto gotToplevel;
 		} else if (wmPtr->winPtr->flags & TK_EMBEDDED &&
-                           TkpGetOtherWindow(wmPtr->winPtr) == NULL) {
+                           Tk_GetOtherWindow((Tk_Window)wmPtr->winPtr) == NULL) {
 
                     /*
                      * This toplevel is embedded in a window belonging to
                      * a different application.
                      */
@@ -5991,11 +6038,11 @@
 	     * The window containing the point is a container, and the
 	     * embedded application is in this same process. Switch over to
 	     * the toplevel for the embedded application and start processing
 	     * that toplevel from scratch.
 	     */
-	    winPtr = TkpGetOtherWindow(nextPtr);
+	    winPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)nextPtr);
 	    if (winPtr == NULL) {
 		return (Tk_Window) nextPtr;
 	    }
 	    wmPtr = winPtr->wmInfoPtr;
 	    childX = x;
@@ -6997,11 +7044,11 @@
 	Tk_MakeWindowExist((Tk_Window) winPtr);
     }
 
     /*
      * The code below is copied from CreateTopLevelWindow, Tk_MakeWindowExist,
-     * and TkpMakeWindow. The idea is to create an "official" Tk window (so
+     * and Tk_MakeWindow. The idea is to create an "official" Tk window (so
      * that we can get events on it), but to hide the window outside the
      * official Tk hierarchy so that it isn't visible to the application. See
      * the comments for the other functions if you have questions about this
      * code.
      */
@@ -7337,11 +7384,11 @@
 
     cmdArgv = (char **)ckalloc(sizeof(char *) * wmPtr->cmdArgc);
     offsets = (int *)ckalloc(sizeof(int) * wmPtr->cmdArgc);
     Tcl_DStringInit(&cmds);
     for (i = 0; i < wmPtr->cmdArgc; i++) {
-	Tcl_UtfToExternalDString(NULL, wmPtr->cmdArgv[i], -1, &ds);
+	(void)Tcl_UtfToExternalDStringEx(NULL, wmPtr->cmdArgv[i], -1, TCL_ENCODING_NOCOMPLAIN, &ds);
 	offsets[i] = Tcl_DStringLength(&cmds);
 	Tcl_DStringAppend(&cmds, Tcl_DStringValue(&ds),
 		Tcl_DStringLength(&ds)+1);
 	Tcl_DStringFree(&ds);
     }

Index: unix/tkUnixXId.c
==================================================================
--- unix/tkUnixXId.c
+++ unix/tkUnixXId.c
@@ -1,10 +1,10 @@
 /*
  * tkUnixXId.c --
  *
- * Copyright (c) 1993 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1993 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: win/Makefile.in
==================================================================
--- win/Makefile.in
+++ win/Makefile.in
@@ -124,24 +124,33 @@
 TCL_SRC_DIR_NATIVE		= $(shell $(CYGPATH) '$(TCL_SRC_DIR)')
 
 DLLSUFFIX		= @DLLSUFFIX@
 LIBSUFFIX		= @LIBSUFFIX@
 EXESUFFIX		= @EXESUFFIX@
+TCLVER			= @TCL_MAJOR_VERSION@@TCL_MINOR_VERSION@
+VER			= @TK_MAJOR_VERSION@@TK_MINOR_VERSION@
+DOTVER			= @TK_MAJOR_VERSION@.@TK_MINOR_VERSION@
+
+TK_ZIP_FILE		= @TK_ZIP_FILE@
+TK_VFS_PATH		= libtk.vfs/tk_library
+TK_VFS_ROOT		= libtk.vfs
 
 TK_STUB_LIB_FILE	= @TK_STUB_LIB_FILE@
 TK_LIB_FILE		= @TK_LIB_FILE@
 TK_DLL_FILE		= @TK_DLL_FILE@
+TK_DLL_FILE_TCL8	= @TK_DLL_FILE_TCL8@
+TK_DLL_FILE_TCL9	= @TK_DLL_FILE_TCL9@
 TEST_DLL_FILE		= tktest$(VER)${DLLSUFFIX}
-TEST_LIB_FILE		= @LIBPREFIX@tktest$(VER)${LIBSUFFIX}
+TEST_LIB_FILE		= @LIBPREFIX@tktest$(VER)${DLLSUFFIX}${LIBSUFFIX}
 
 SHARED_LIBRARIES 	= $(TK_DLL_FILE) $(TK_STUB_LIB_FILE)
 STATIC_LIBRARIES	= $(TK_LIB_FILE)
 
 WISH			= wish$(VER)${EXESUFFIX}
-TKTEST			= tktest.exe
-CAT32			= cat32.exe
-MAN2TCL			= man2tcl.exe
+TKTEST			= tktest${EXESUFFIX}
+CAT32			= cat32${EXESUFFIX}
+MAN2TCL			= man2tcl${EXESUFFIX}
 
 @SET_MAKE@
 
 # Setting the VPATH variable to a list of paths will cause the
 # makefile to look into these paths when resolving .c to .obj
@@ -163,11 +172,11 @@
 # To change the compiler switches, for example to change from optimization to
 # debugging symbols, change the following line:
 #CFLAGS		= $(CFLAGS_DEBUG)
 #CFLAGS		= $(CFLAGS_OPTIMIZE)
 #CFLAGS		= $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE)
-CFLAGS		= @CFLAGS@ @CFLAGS_DEFAULT@ -D_ATL_XP_TARGETING
+CFLAGS		= @CFLAGS@ @CFLAGS_DEFAULT@ -D_ATL_XP_TARGETING=1 -D__USE_MINGW_ANSI_STDIO=0
 
 # Special compiler flags to use when building man2tcl on Windows.
 MAN2TCLFLAGS	= @MAN2TCLFLAGS@
 
 AR		= @AR@
@@ -174,11 +183,11 @@
 RANLIB		= @RANLIB@
 CC		= @CC@
 RC		= @RC@
 RES		= @RES@
 TK_RES		= @TK_RES@
-AC_FLAGS	= @EXTRA_CFLAGS@ @DEFS@ @TCL_DEFS@
+AC_FLAGS	= @EXTRA_CFLAGS@ @DEFS@
 CPPFLAGS	= @CPPFLAGS@
 LDFLAGS		= @LDFLAGS@ @LDFLAGS_DEFAULT@
 LDFLAGS_CONSOLE	= @LDFLAGS_CONSOLE@
 LDFLAGS_WINDOW	= @LDFLAGS_WINDOW@
 OBJEXT		= @OBJEXT@
@@ -185,25 +194,22 @@
 STLIB_LD	= @STLIB_LD@
 SHLIB_LD	= @SHLIB_LD@
 SHLIB_LD_LIBS	= @SHLIB_LD_LIBS@
 SHLIB_CFLAGS	= @SHLIB_CFLAGS@
 SHLIB_SUFFIX	= @SHLIB_SUFFIX@
-VER		= @TK_MAJOR_VERSION@@TK_MINOR_VERSION@
-DOTVER		= @TK_MAJOR_VERSION@.@TK_MINOR_VERSION@
 LIBS		= $(TCL_STUB_LIB_FILE) @LIBS@ @LIBS_GUI@
 RMDIR		= rm -rf
 MKDIR		= mkdir -p
 SHELL		= @SHELL@
 RM		= rm -f
 COPY		= cp
-
-BUILD_TCLSH	= @BUILD_TCLSH@
+LN		= ln
 
 # Tk does not used deprecated Tcl constructs so it should
 # compile fine with -DTCL_NO_DEPRECATED. To remove its own
 # set of deprecated code uncomment the second line.
-NO_DEPRECATED_FLAGS	= -DTCL_NO_DEPRECATED
+NO_DEPRECATED_FLAGS	=
 #NO_DEPRECATED_FLAGS	= -DTCL_NO_DEPRECATED -DTK_NO_DEPRECATED
 
 # TCL_EXE is the name of a tclsh executable that is available *BEFORE*
 # running make for the first time. Certain build targets (make genstubs)
 # need it to be available on the PATH. This executable should *NOT* be
@@ -210,15 +216,54 @@
 # required just to do a normal build although it can be required to run
 # make dist.
 TCL_EXE			= @TCLSH_PROG@
 WINE    		= @WINE@
 
+###
+# Tip 430 - ZipFS Modifications
+###
+
+TK_ZIP_FILE		= @TK_ZIP_FILE@
+TK_VFS_PATH		= libtk.vfs/tk_library
+TK_VFS_ROOT		= libtk.vfs
+
+HOST_CC		        = @CC_FOR_BUILD@
+HOST_EXEEXT             = @EXEEXT_FOR_BUILD@
+HOST_OBJEXT             = @OBJEXT_FOR_BUILD@
+ZIPFS_BUILD	        = @ZIPFS_BUILD@
+NATIVE_ZIP		= @ZIP_PROG@
+ZIP_PROG_OPTIONS		= @ZIP_PROG_OPTIONS@
+ZIP_PROG_VFSSEARCH  = @ZIP_PROG_VFSSEARCH@
+SHARED_BUILD		= @SHARED_BUILD@
+INSTALL_MSGS            = @INSTALL_MSGS@
+INSTALL_LIBRARIES       = @INSTALL_LIBRARIES@
+
+# Minizip
+MINIZIP_OBJS = \
+        adler32.$(HOST_OBJEXT) \
+        compress.$(HOST_OBJEXT) \
+        crc32.$(HOST_OBJEXT) \
+        deflate.$(HOST_OBJEXT) \
+        infback.$(HOST_OBJEXT) \
+        inffast.$(HOST_OBJEXT) \
+        inflate.$(HOST_OBJEXT) \
+        inftrees.$(HOST_OBJEXT) \
+        ioapi.$(HOST_OBJEXT) \
+        iowin32.$(HOST_OBJEXT)  \
+        trees.$(HOST_OBJEXT) \
+        uncompr.$(HOST_OBJEXT) \
+        zip.$(HOST_OBJEXT) \
+        zutil.$(HOST_OBJEXT) \
+        minizip.$(HOST_OBJEXT)
+
+ZIP_INSTALL_OBJS =  @ZIP_INSTALL_OBJS@
+
 CC_SWITCHES = ${CFLAGS} ${CFLAGS_WARNING} ${SHLIB_CFLAGS} \
 -I"${GENERIC_DIR_NATIVE}" -I"${WIN_DIR_NATIVE}" \
 -I"${XLIB_DIR_NATIVE}" -I"${BITMAP_DIR_NATIVE}" \
 -I"${TCL_GENERIC_NATIVE}" -I"${TCL_PLATFORM_NATIVE}" \
-${AC_FLAGS} $(NO_DEPRECATED_FLAGS) -DUSE_TCL_STUBS
+${AC_FLAGS} $(NO_DEPRECATED_FLAGS) -DTCL_UTF_MAX=3 -DUSE_TCL_STUBS
 
 CC_OBJNAME = @CC_OBJNAME@
 CC_EXENAME = @CC_EXENAME@
 
 # Tk used to let the configure script choose which program to use
@@ -260,10 +305,12 @@
 	tkWinCursor.$(OBJEXT) \
 	tkWinDialog.$(OBJEXT) \
 	tkWinDraw.$(OBJEXT) \
 	tkWinEmbed.$(OBJEXT) \
 	tkWinFont.$(OBJEXT) \
+	tkWinGDI.$(OBJEXT) \
+	tkWinIco.$(OBJEXT) \
 	tkWinImage.$(OBJEXT) \
 	tkWinInit.$(OBJEXT) \
 	tkWinKey.$(OBJEXT) \
 	tkWinMenu.$(OBJEXT) \
 	tkWinPixmap.$(OBJEXT) \
@@ -270,10 +317,11 @@
 	tkWinPointer.$(OBJEXT) \
 	tkWinRegion.$(OBJEXT) \
 	tkWinScrlbr.$(OBJEXT) \
 	tkWinSend.$(OBJEXT) \
 	tkWinSendCom.$(OBJEXT) \
+	tkWinSysTray.$(OBJEXT) \
 	tkWinWindow.$(OBJEXT) \
 	tkWinWm.$(OBJEXT) \
 	tkWinX.$(OBJEXT) \
 	stubs.$(OBJEXT) \
 	tk3d.$(OBJEXT) \
@@ -308,10 +356,11 @@
 	tkGC.$(OBJEXT) \
 	tkGeometry.$(OBJEXT) \
 	tkGet.$(OBJEXT) \
 	tkGrab.$(OBJEXT) \
 	tkGrid.$(OBJEXT) \
+	tkIcu.$(OBJEXT) \
 	tkImage.$(OBJEXT) \
 	tkImgBmap.$(OBJEXT) \
 	tkImgListFormat.$(OBJEXT) \
 	tkImgGIF.$(OBJEXT) \
 	tkImgPNG.$(OBJEXT) \
@@ -483,17 +532,26 @@
 	    fi; \
 	    done
 	@echo "Creating package index $(PKG_INDEX)";
 	@$(RM) $(PKG_INDEX);
 	@(\
-	echo "if {[catch {package present Tcl 8.6-}]} return";\
+	echo "if {![package vsatisfies [package provide Tcl] 8.6-]} return";\
 	echo "if {(\$$::tcl_platform(platform) eq \"unix\") && ([info exists ::env(DISPLAY)]";\
 	echo "	|| ([info exists ::argv] && (\"-display\" in \$$::argv)))} {";\
-	echo "    package ifneeded Tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin libtk$(VERSION).dll]] Tk]";\
+	echo "    if {[package vsatisfies [package provide Tcl] 9.0]} {";\
+	echo "	package ifneeded tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin libtcl9tk$(VERSION).dll]]]";\
+	echo "    } else {";\
+	echo "	package ifneeded tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin libtk$(VERSION).dll]]]";\
+	echo "    }";\
 	echo "} else {";\
-	echo "    package ifneeded Tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin $(TK_DLL_FILE)]] Tk]";\
+	echo "    if {[package vsatisfies [package provide Tcl] 9.0]} {";\
+	echo "	package ifneeded tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin $(TK_DLL_FILE_TCL9)]]]";\
+	echo "    } else {";\
+	echo "	package ifneeded tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin $(TK_DLL_FILE_TCL8)]]]";\
+	echo "    }";\
 	echo "}";\
+	echo "package ifneeded Tk $(VERSION)$(PATCH_LEVEL) [list package require -exact tk $(VERSION)$(PATCH_LEVEL)]";\
 	) > $(PKG_INDEX);
 	@for i in tkConfig.sh $(TK_LIB_FILE) $(TK_STUB_LIB_FILE); \
 	    do \
 	    if [ -f $$i ]; then \
 		echo "Installing $$i to $(LIB_INSTALL_DIR)/"; \
@@ -607,15 +665,20 @@
 		"$(WIN_DIR)/tkWinPort.h" "$(WIN_DIR)/tkWinInt.h" "$(WIN_DIR)/tkWin.h"; \
 	    do \
 	    $(INSTALL_DATA) $$i $(PRIVATE_INCLUDE_INSTALL_DIR); \
 	    done;
 
-$(WISH): $(WISH_OBJS) @LIBRARIES@ $(TK_STUB_LIB_FILE) wish.$(RES)
+$(WISH): $(WISH_OBJS) @LIBRARIES@ $(TK_STUB_LIB_FILE) wish.$(RES) ${TK_ZIP_FILE}
 	$(CC) $(CFLAGS) $(WISH_OBJS) $(TK_LIB_FILE) \
 	$(TK_STUB_LIB_FILE) $(TCL_LIB_FILE) $(LIBS) \
 	wish.$(RES) $(CC_EXENAME) $(LDFLAGS_WINDOW)
 	@VC_MANIFEST_EMBED_EXE@
+	@if test "${ZIPFS_BUILD}" = "2" ; then \
+		cat ${TK_ZIP_FILE} >> ${WISH}; \
+		${NATIVE_ZIP} -A ${WISH} \
+		  || echo 'ignore zip-error by adjust sfx process (not executable?)'; \
+	fi
 
 tktest: $(TKTEST)
 
 $(TKTEST): testMain.$(OBJEXT) $(TEST_DLL_FILE) @LIBRARIES@ $(TK_STUB_LIB_FILE) wish.$(RES)
 	$(CC) $(CFLAGS) testMain.$(OBJEXT) $(TEST_LIB_FILE) $(TK_LIB_FILE) \
@@ -623,32 +686,70 @@
 	wish.$(RES) $(CC_EXENAME) $(LDFLAGS_WINDOW)
 	@VC_MANIFEST_EMBED_EXE@
 
 ${TEST_DLL_FILE}: ${TKTEST_OBJS} ${TK_STUB_LIB_FILE}
 	@MAKE_DLL@ ${TKTEST_OBJS} $(TK_STUB_LIB_FILE) $(SHLIB_LD_LIBS)
+
+$(TOP_DIR)/manifest.uuid:
+	printf "git-" >$(TOP_DIR)/manifest.uuid
+	(cd $(TOP_DIR); git rev-parse HEAD >>$(TOP_DIR)/manifest.uuid || printf "unknown" >$(TOP_DIR)/manifest.uuid)
+
+tkUuid.h:	$(TOP_DIR)/manifest.uuid
+	echo "#define TK_VERSION_UUID \\" >$@
+	cat $(TOP_DIR)/manifest.uuid >>$@
+	echo "" >>$@
 
 # Msys make requires this next rule for some reason.
 $(TCL_SRC_DIR)/win/cat.c:
 
 cat32.${OBJEXT}: $(TCL_SRC_DIR)/win/cat.c
 	$(CC) -c $(CC_SWITCHES) -DUNICODE -D_UNICODE "$(TCL_SRC_DIR)/win/cat.c" $(CC_OBJNAME)
 
 $(CAT32): cat32.${OBJEXT}
 	$(CC) $(CFLAGS) cat32.$(OBJEXT) $(CC_EXENAME) $(LIBS) $(LDFLAGS_CONSOLE)
+
+tkzipfile: ${TK_ZIP_FILE}
+
+${TK_ZIP_FILE}:  ${ZIP_INSTALL_OBJS}
+	@$(RMDIR) ${TK_VFS_ROOT}
+	@mkdir -p ${TK_VFS_PATH}
+	@echo "creating ${TK_VFS_PATH} (prepare compression)"
+	@( \
+	  $(COPY) -a $(TOP_DIR)/library/* ${TK_VFS_PATH}; \
+	)
+	@$(RMDIR) $(TK_VFS_PATH)/demos
+	-@if test "${ZIPFS_BUILD}" = "2" ; then \
+	    cp ${TCL_BIN_DIR}/tclsh${TCLVER}s.exe ${TK_VFS_ROOT}/../${TK_ZIP_FILE} || cp ${TCL_BIN_DIR}/../bin/tclsh${TCLVER}s.exe ${TK_VFS_ROOT}/../${TK_ZIP_FILE}; \
+	    (zip=`(realpath '${NATIVE_ZIP}' || readlink -m '${NATIVE_ZIP}') 2>/dev/null || \
+		(echo '${NATIVE_ZIP}' | sed "s?^\./?$$(pwd)/?")`; \
+		cd ${TK_VFS_ROOT} && $$zip -J ../${TK_ZIP_FILE}) \
+	fi
+	(zip=`(realpath '${NATIVE_ZIP}' || readlink -m '${NATIVE_ZIP}') 2>/dev/null || \
+	  (echo '${NATIVE_ZIP}' | sed "s?^\./?$$(pwd)/?")`; \
+	  cd ${TK_VFS_ROOT} && \
+	  $$zip ${ZIP_PROG_OPTIONS} ../${TK_ZIP_FILE} ${ZIP_PROG_VFSSEARCH} >/dev/null && \
+	  echo "${TK_ZIP_FILE} successful created with $$zip" && \
+	  cd ..)
+
 
 # The following targets are configured by autoconf to generate either
 # a shared library or static library
 
 ${TK_STUB_LIB_FILE}: ${STUB_OBJS}
 	@$(RM) ${TK_STUB_LIB_FILE}
 	@MAKE_STUB_LIB@ ${STUB_OBJS}
 	@POST_MAKE_LIB@
 
-${TK_DLL_FILE}: ${TK_OBJS} $(TK_RES)
+${TK_DLL_FILE}: ${TK_OBJS} $(TK_RES) ${TK_ZIP_FILE}
 	@$(RM) ${TK_DLL_FILE}
 	@MAKE_DLL@ ${TK_OBJS} $(TK_RES) $(SHLIB_LD_LIBS)
 	@VC_MANIFEST_EMBED_DLL@
+	@if test "${ZIPFS_BUILD}" = "1" ; then \
+		cat ${TK_ZIP_FILE} >> ${TK_DLL_FILE}; \
+		${NATIVE_ZIP} -A ${TK_DLL_FILE} \
+		  || echo 'ignore zip-error by adjust sfx process (not executable?)'; \
+	fi
 
 ${TK_LIB_FILE}: ${TK_OBJS}
 	@$(RM) ${TK_LIB_FILE}
 	@MAKE_LIB@ ${TK_OBJS}
 	@POST_MAKE_LIB@
@@ -671,24 +772,38 @@
 	$(CC) -c $(CC_SWITCHES) @DEPARG@ $(CC_OBJNAME)
 
 tkSquare.$(OBJEXT): tkSquare.c
 	$(CC) -c $(CC_SWITCHES) @DEPARG@ $(CC_OBJNAME)
 
+tkStubLib.$(OBJEXT): tkStubLib.c
+	$(CC) -c $(CC_SWITCHES) @CFLAGS_NOLTO@ @DEPARG@ $(CC_OBJNAME)
+
+ttkStubLib.$(OBJEXT): ${TTK_DIR}/ttkStubLib.c
+	$(CC) -c $(CC_SWITCHES) @CFLAGS_NOLTO@ @DEPARG@ $(CC_OBJNAME)
+
 tkMain2.$(OBJEXT): tkMain.c
 	$(CC) -c $(CC_SWITCHES) -DBUILD_tk -DUNICODE=1 -D_UNICODE=1 @DEPARG@ $(CC_OBJNAME)
 
 tkUnixMenubu.$(OBJEXT): ${UNIX_DIR}/tkUnixMenubu.c
 	$(CC) -c $(CC_SWITCHES) -DBUILD_tk -DBUILD_ttk @DEPARG@ $(CC_OBJNAME)
 
 tkUnixScale.$(OBJEXT): ${UNIX_DIR}/tkUnixScale.c
 	$(CC) -c $(CC_SWITCHES) -DBUILD_tk -DBUILD_ttk @DEPARG@ $(CC_OBJNAME)
 
+tkPkgConfig.$(OBJEXT): $(GENERIC_DIR)/tkPkgConfig.c
+	$(CC) -c $(CC_SWITCHES)	 -DBUILD_tk -DBUILD_ttk		\
+		-DCFG_RUNTIME_DLLFILE="\"$(TK_DLL_FILE)\"" \
+		@DEPARG@ $(CC_OBJNAME)
+
+
+tkWindow.$(OBJEXT): ${GENERIC_DIR}/tkWindow.c configure Makefile tkUuid.h
+	$(CC) -c $(CC_SWITCHES) -I. -DBUILD_tk @DEPARG@ $(CC_OBJNAME)
+
 # Extra dependency info
 tkConsole.$(OBJEXT): configure Makefile
 tkMain.$(OBJEXT): configure Makefile
 tkMain2.$(OBJEXT): configure Makefile
-tkWindow.$(OBJEXT): configure Makefile
 
 # Add the object extension to the implicit rules.  By default .obj is not
 # automatically added.
 
 .SUFFIXES: .${OBJEXT}
@@ -709,11 +824,12 @@
 	$(RM) *.hlp *.cnt *.hpj *.GID *.rtf man2tcl.exe
 
 clean: cleanhelp
 	$(RM) *.lib *.a *.exp *.dll *.res *.${OBJEXT} *~ \#* TAGS a.out
 	$(RM) $(WISH) $(TKTEST) $(CAT32)
-	$(RM) *.pch *.ilk *.pdb
+	$(RM) *.pch *.ilk *.pdb *.zip
+	$(RMDIR) *.vfs
 
 distclean: clean
 	$(RM) Makefile config.status config.cache config.log tkConfig.sh \
 		wish.exe.manifest
 

Index: win/configure
==================================================================
--- win/configure
+++ win/configure
@@ -1,11 +1,12 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69.
+# Generated by GNU Autoconf 2.71 for tk 8.7.
 #
 #
-# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation,
+# Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
 # gives unlimited permission to copy, distribute and modify it.
 ## -------------------- ##
@@ -12,92 +13,91 @@
 ## M4sh Initialization. ##
 ## -------------------- ##
 
 # Be more Bourne compatible
 DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+as_nop=:
+if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1
+then :
   emulate sh
   NULLCMD=:
   # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
-else
+else $as_nop
   case `(set -o) 2>/dev/null` in #(
   *posix*) :
     set -o posix ;; #(
   *) :
      ;;
 esac
 fi
 
 
+
+# Reset variables that may have inherited troublesome values from
+# the environment.
+
+# IFS needs to be set, to space, tab, and newline, in precisely that order.
+# (If _AS_PATH_WALK were called with IFS unset, it would have the
+# side effect of setting IFS to empty, thus disabling word splitting.)
+# Quoting is to prevent editors from complaining about space-tab.
 as_nl='
 '
 export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='printf %s\n'
-  as_echo_n='printf %s'
-else
-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
-    as_echo_n='/usr/ucb/echo -n'
-  else
-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-    as_echo_n_body='eval
-      arg=$1;
-      case $arg in #(
-      *"$as_nl"*)
-	expr "X$arg" : "X\\(.*\\)$as_nl";
-	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-      esac;
-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-    '
-    export as_echo_n_body
-    as_echo_n='sh -c $as_echo_n_body as_echo'
-  fi
-  export as_echo_body
-  as_echo='sh -c $as_echo_body as_echo'
-fi
+IFS=" ""	$as_nl"
+
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# Ensure predictable behavior from utilities with locale-dependent output.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# We cannot yet rely on "unset" to work, but we need these variables
+# to be unset--not just set to an empty or harmless value--now, to
+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh).  This construct
+# also avoids known problems related to "unset" and subshell syntax
+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).
+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH
+do eval test \${$as_var+y} \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+
+# Ensure that fds 0, 1, and 2 are open.
+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi
+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi
+if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi
 
 # The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
+if ${PATH_SEPARATOR+false} :; then
   PATH_SEPARATOR=:
   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
       PATH_SEPARATOR=';'
   }
 fi
 
 
-# IFS
-# We need space, tab and new line, in precisely that order.  Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" ""	$as_nl"
-
 # Find who we are.  Look in the path if we contain no directory separator.
 as_myself=
 case $0 in #((
   *[\\/]* ) as_myself=$0 ;;
   *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    test -r "$as_dir$0" && as_myself=$as_dir$0 && break
   done
 IFS=$as_save_IFS
 
      ;;
 esac
@@ -105,34 +105,14 @@
 # in which case we are not to be found in the path.
 if test "x$as_myself" = x; then
   as_myself=$0
 fi
 if test ! -f "$as_myself"; then
-  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
   exit 1
 fi
 
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
 # Use a proper internal environment variable to ensure we don't fall
   # into an infinite loop, continuously re-executing ourselves.
   if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
     _as_can_reexec=no; export _as_can_reexec;
@@ -150,24 +130,26 @@
   * ) as_opts= ;;
 esac
 exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
 # Admittedly, this is quite paranoid, since all the known shells bail
 # out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-as_fn_exit 255
+printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
   fi
   # We don't want this to propagate to other subprocesses.
           { _as_can_reexec=; unset _as_can_reexec;}
 if test "x$CONFIG_SHELL" = x; then
-  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  as_bourne_compatible="as_nop=:
+if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1
+then :
   emulate sh
   NULLCMD=:
   # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '\${1+\"\$@\"}'='\"\$@\"'
   setopt NO_GLOB_SUBST
-else
+else \$as_nop
   case \`(set -o) 2>/dev/null\` in #(
   *posix*) :
     set -o posix ;; #(
   *) :
      ;;
@@ -183,61 +165,79 @@
 exitcode=0
 as_fn_success || { exitcode=1; echo as_fn_success failed.; }
 as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
 as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
 as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
-if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+if ( set x; as_fn_ret_success y && test x = \"\$1\" )
+then :
 
-else
+else \$as_nop
   exitcode=1; echo positional parameters were not saved.
 fi
 test x\$exitcode = x0 || exit 1
+blah=\$(echo \$(echo blah))
+test x\"\$blah\" = xblah || exit 1
 test -x / || exit 1"
   as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
   eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
   test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
 test \$(( 1 + 1 )) = 2 || exit 1"
-  if (eval "$as_required") 2>/dev/null; then :
+  if (eval "$as_required") 2>/dev/null
+then :
   as_have_required=yes
-else
+else $as_nop
   as_have_required=no
 fi
-  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null
+then :
 
-else
+else $as_nop
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 as_found=false
 for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
   as_found=:
   case $as_dir in #(
 	 /*)
 	   for as_base in sh bash ksh sh5; do
 	     # Try only shells that exist, to save several forks.
-	     as_shell=$as_dir/$as_base
+	     as_shell=$as_dir$as_base
 	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
-		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+		    as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null
+then :
   CONFIG_SHELL=$as_shell as_have_required=yes
-		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+		   if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null
+then :
   break 2
 fi
 fi
 	   done;;
        esac
   as_found=false
 done
-$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
-	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+IFS=$as_save_IFS
+if $as_found
+then :
+
+else $as_nop
+  if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+	      as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null
+then :
   CONFIG_SHELL=$SHELL as_have_required=yes
-fi; }
-IFS=$as_save_IFS
+fi
+fi
 
 
-      if test "x$CONFIG_SHELL" != x; then :
+      if test "x$CONFIG_SHELL" != x
+then :
   export CONFIG_SHELL
              # We cannot yet assume a decent shell, so we have to provide a
 # neutralization value for shells without unset; and this also
 # works around shells that cannot unset nonexistent variables.
 # Preserve -v and -x to the replacement shell.
@@ -251,22 +251,23 @@
   * ) as_opts= ;;
 esac
 exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
 # Admittedly, this is quite paranoid, since all the known shells bail
 # out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2
 exit 255
 fi
 
-    if test x$as_have_required = xno; then :
-  $as_echo "$0: This script requires a shell more modern than all"
-  $as_echo "$0: the shells that I found on your system."
-  if test x${ZSH_VERSION+set} = xset ; then
-    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
-    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+    if test x$as_have_required = xno
+then :
+  printf "%s\n" "$0: This script requires a shell more modern than all"
+  printf "%s\n" "$0: the shells that I found on your system."
+  if test ${ZSH_VERSION+y} ; then
+    printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later."
   else
-    $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
+    printf "%s\n" "$0: Please tell bug-autoconf@gnu.org about your system,
 $0: including any error possibly output before this
 $0: message. Then install a modern shell, or manually run
 $0: the script under such a shell if you do have one."
   fi
   exit 1
@@ -288,10 +289,11 @@
 as_fn_unset ()
 {
   { eval $1=; unset $1;}
 }
 as_unset=as_fn_unset
+
 
 # as_fn_set_status STATUS
 # -----------------------
 # Set $? to STATUS, without forking.
 as_fn_set_status ()
@@ -306,10 +308,18 @@
 {
   set +e
   as_fn_set_status $1
   exit $1
 } # as_fn_exit
+# as_fn_nop
+# ---------
+# Do nothing but, unlike ":", preserve the value of $?.
+as_fn_nop ()
+{
+  return $?
+}
+as_nop=as_fn_nop
 
 # as_fn_mkdir_p
 # -------------
 # Create "$as_dir" as a directory, including parents if necessary.
 as_fn_mkdir_p ()
@@ -320,20 +330,20 @@
   esac
   test -d "$as_dir" || eval $as_mkdir_p || {
     as_dirs=
     while :; do
       case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
       *) as_qdir=$as_dir;;
       esac
       as_dirs="'$as_qdir' $as_dirs"
       as_dir=`$as_dirname -- "$as_dir" ||
 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$as_dir" : 'X\(//\)[^/]' \| \
 	 X"$as_dir" : 'X\(//\)$' \| \
 	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
+printf "%s\n" X"$as_dir" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
 	    s//\1/
 	    q
 	  }
 	  /^X\(\/\/\)[^/].*/{
@@ -368,16 +378,17 @@
 # ----------------------
 # Append the text in VALUE to the end of the definition contained in VAR. Take
 # advantage of any shell optimizations that allow amortized linear growth over
 # repeated appends, instead of the typical quadratic growth present in naive
 # implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null
+then :
   eval 'as_fn_append ()
   {
     eval $1+=\$2
   }'
-else
+else $as_nop
   as_fn_append ()
   {
     eval $1=\$$1\$2
   }
 fi # as_fn_append
@@ -385,22 +396,31 @@
 # as_fn_arith ARG...
 # ------------------
 # Perform arithmetic evaluation on the ARGs, and store the result in the
 # global $as_val. Take advantage of shells that can avoid forks. The arguments
 # must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null
+then :
   eval 'as_fn_arith ()
   {
     as_val=$(( $* ))
   }'
-else
+else $as_nop
   as_fn_arith ()
   {
     as_val=`expr "$@" || test $? -eq 1`
   }
 fi # as_fn_arith
 
+# as_fn_nop
+# ---------
+# Do nothing but, unlike ":", preserve the value of $?.
+as_fn_nop ()
+{
+  return $?
+}
+as_nop=as_fn_nop
 
 # as_fn_error STATUS ERROR [LINENO LOG_FD]
 # ----------------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
@@ -408,13 +428,13 @@
 as_fn_error ()
 {
   as_status=$1; test $as_status -eq 0 && as_status=1
   if test "$4"; then
     as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
   fi
-  $as_echo "$as_me: error: $2" >&2
+  printf "%s\n" "$as_me: error: $2" >&2
   as_fn_exit $as_status
 } # as_fn_error
 
 if expr a : '\(a\)' >/dev/null 2>&1 &&
    test "X`expr 00001 : '.*\(...\)'`" = X001; then
@@ -437,11 +457,11 @@
 
 as_me=`$as_basename -- "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
 	 X"$0" : 'X\(//\)$' \| \
 	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
+printf "%s\n" X/"$0" |
     sed '/^.*\/\([^/][^/]*\)\/*$/{
 	    s//\1/
 	    q
 	  }
 	  /^X\/\(\/\/\)$/{
@@ -481,11 +501,11 @@
       s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
       t loop
       s/-\n.*//
     ' >$as_me.lineno &&
   chmod +x "$as_me.lineno" ||
-    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+    { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
 
   # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
   # already done that, so ensure we don't try to do so again and fall
   # in an infinite loop.  This has already happened in practice.
   _as_can_reexec=no; export _as_can_reexec
@@ -495,10 +515,14 @@
   . "./$as_me.lineno"
   # Exit status is that of the last command.
   exit
 }
 
+
+# Determine whether it's possible to make 'echo' print without a newline.
+# These variables are no longer used directly by Autoconf, but are AC_SUBSTed
+# for compatibility with existing Makefiles.
 ECHO_C= ECHO_N= ECHO_T=
 case `echo -n x` in #(((((
 -n*)
   case `echo 'xy\c'` in
   *c*) ECHO_T='	';;	# ECHO_T is single tab character.
@@ -507,10 +531,17 @@
        ECHO_T='	';;
   esac;;
 *)
   ECHO_N='-n';;
 esac
+
+# For backward compatibility with old third-party macros, we provide
+# the shell variables $as_echo and $as_echo_n.  New code should use
+# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively.
+as_echo='printf %s\n'
+as_echo_n='printf %s'
+
 
 rm -f conf$$ conf$$.exe conf$$.file
 if test -d conf$$.dir; then
   rm -f conf$$.dir/conf$$.file
 else
@@ -573,54 +604,50 @@
 subdirs=
 MFLAGS=
 MAKEFLAGS=
 
 # Identity of this package.
-PACKAGE_NAME=
-PACKAGE_TARNAME=
-PACKAGE_VERSION=
-PACKAGE_STRING=
-PACKAGE_BUGREPORT=
-PACKAGE_URL=
+PACKAGE_NAME='tk'
+PACKAGE_TARNAME='tk'
+PACKAGE_VERSION='8.7'
+PACKAGE_STRING='tk 8.7'
+PACKAGE_BUGREPORT=''
+PACKAGE_URL=''
 
 ac_unique_file="../generic/tk.h"
 # Factoring default headers for most tests.
 ac_includes_default="\
-#include <stdio.h>
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
+#include <stddef.h>
+#ifdef HAVE_STDIO_H
+# include <stdio.h>
+#endif
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
 #endif
 #ifdef HAVE_STRING_H
-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
-#  include <memory.h>
-# endif
 # include <string.h>
 #endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
 #ifdef HAVE_INTTYPES_H
 # include <inttypes.h>
 #endif
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
 #endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif"
 
+ac_header_c_list=
 ac_subst_vars='LTLIBOBJS
 LIBOBJS
 RES
 RC_DEFINES
 RC_DEFINE
@@ -670,25 +697,41 @@
 TK_BIN_DIR
 TK_SRC_DIR
 TK_BUILD_STUB_LIB_SPEC
 TK_STUB_LIB_FLAG
 TK_STUB_LIB_FILE
+TK_DLL_FILE_TCL9
+TK_DLL_FILE_TCL8
 TK_DLL_FILE
 TK_LIB_FILE
 TK_PATCH_LEVEL
 TK_MINOR_VERSION
 TK_MAJOR_VERSION
 TK_VERSION
 MACHINE
 TK_WIN_VERSION
+INSTALL_MSGS
+INSTALL_LIBRARIES
+TK_ZIP_FILE
+ZIPFS_BUILD
+ZIP_INSTALL_OBJS
+ZIP_PROG_VFSSEARCH
+ZIP_PROG_OPTIONS
+ZIP_PROG
+EXEEXT_FOR_BUILD
+CC_FOR_BUILD
 TCLSH_PROG
 BUILD_TCLSH
 VC_MANIFEST_EMBED_EXE
 VC_MANIFEST_EMBED_DLL
+EGREP
+GREP
+CPP
 LDFLAGS_DEFAULT
 CFLAGS_DEFAULT
 MAN2TCLFLAGS
+CFLAGS_NOLTO
 CFLAGS_WARNING
 CFLAGS_OPTIMIZE
 CFLAGS_DEBUG
 DL_LIBS
 WINE
@@ -698,22 +741,18 @@
 TCL_STUB_LIB_FLAG
 TCL_STUB_LIB_FILE
 TCL_LIB_SPEC
 TCL_LIB_FLAG
 TCL_LIB_FILE
-TCL_ZIP_FILE
 TCL_SRC_DIR
 TCL_BIN_DIR
 TCL_VERSION
 SHARED_BUILD
 SET_MAKE
 RC
 RANLIB
 AR
-EGREP
-GREP
-CPP
 OBJEXT
 EXEEXT
 ac_ct_CC
 CPPFLAGS
 LDFLAGS
@@ -736,10 +775,11 @@
 htmldir
 infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
 datadir
 datarootdir
@@ -764,10 +804,11 @@
 enable_shared
 with_tcl
 enable_64bit
 enable_symbols
 enable_embedded_manifest
+enable_zipfs
 '
       ac_precious_vars='build_alias
 host_alias
 target_alias
 CC
@@ -812,13 +853,14 @@
 datarootdir='${prefix}/share'
 datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
-docdir='${datarootdir}/doc/${PACKAGE}'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
 infodir='${datarootdir}/info'
 htmldir='${docdir}'
 dvidir='${docdir}'
 pdfdir='${docdir}'
 psdir='${docdir}'
@@ -841,12 +883,10 @@
   *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
   *=)   ac_optarg= ;;
   *)    ac_optarg=yes ;;
   esac
 
-  # Accept the important Cygnus configure options, so we can diagnose typos.
-
   case $ac_dashdash$ac_option in
   --)
     ac_dashdash=yes ;;
 
   -bindir | --bindir | --bindi | --bind | --bin | --bi)
@@ -883,13 +923,13 @@
 
   -disable-* | --disable-*)
     ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
+      as_fn_error $? "invalid feature name: \`$ac_useropt'"
     ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
       *"
 "enable_$ac_useropt"
 "*) ;;
       *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
@@ -909,13 +949,13 @@
 
   -enable-* | --enable-*)
     ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
+      as_fn_error $? "invalid feature name: \`$ac_useropt'"
     ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
       *"
 "enable_$ac_useropt"
 "*) ;;
       *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
@@ -1063,10 +1103,19 @@
     psdir=$ac_optarg ;;
 
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
+
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
 
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
   | --sbi=* | --sb=*)
@@ -1113,13 +1162,13 @@
 
   -with-* | --with-*)
     ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
+      as_fn_error $? "invalid package name: \`$ac_useropt'"
     ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
       *"
 "with_$ac_useropt"
 "*) ;;
       *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
@@ -1129,13 +1178,13 @@
 
   -without-* | --without-*)
     ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
+      as_fn_error $? "invalid package name: \`$ac_useropt'"
     ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
       *"
 "with_$ac_useropt"
 "*) ;;
       *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
@@ -1175,13 +1224,13 @@
     eval $ac_envvar=\$ac_optarg
     export $ac_envvar ;;
 
   *)
     # FIXME: should be removed in autoconf 3.0.
-    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2
     expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+      printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2
     : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
     ;;
 
   esac
 done
@@ -1193,19 +1242,19 @@
 
 if test -n "$ac_unrecognized_opts"; then
   case $enable_option_checking in
     no) ;;
     fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
-    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+    *)     printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
   esac
 fi
 
 # Check all directory arguments for consistency.
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
   case $ac_val in
     */ )
@@ -1257,11 +1306,11 @@
   ac_confdir=`$as_dirname -- "$as_myself" ||
 $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$as_myself" : 'X\(//\)[^/]' \| \
 	 X"$as_myself" : 'X\(//\)$' \| \
 	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_myself" |
+printf "%s\n" X"$as_myself" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
 	    s//\1/
 	    q
 	  }
 	  /^X\(\/\/\)[^/].*/{
@@ -1314,11 +1363,11 @@
 #
 if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures this package to adapt to many kinds of systems.
+\`configure' configures tk 8.7 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
 To assign environment variables (e.g., CC, CFLAGS...), specify them as
 VAR=VALUE.  See below for descriptions of some of the useful variables.
@@ -1354,19 +1403,20 @@
   --sbindir=DIR           system admin executables [EPREFIX/sbin]
   --libexecdir=DIR        program executables [EPREFIX/libexec]
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
   --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
   --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
   --infodir=DIR           info documentation [DATAROOTDIR/info]
   --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
   --mandir=DIR            man documentation [DATAROOTDIR/man]
-  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/tk]
   --htmldir=DIR           html documentation [DOCDIR]
   --dvidir=DIR            dvi documentation [DOCDIR]
   --pdfdir=DIR            pdf documentation [DOCDIR]
   --psdir=DIR             ps documentation [DOCDIR]
 _ACEOF
@@ -1374,11 +1424,13 @@
   cat <<\_ACEOF
 _ACEOF
 fi
 
 if test -n "$ac_init_help"; then
-
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of tk 8.7:";;
+   esac
   cat <<\_ACEOF
 
 Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
@@ -1386,10 +1438,11 @@
   --enable-shared         build and link with shared libraries (default: on)
   --enable-64bit          enable 64bit support (where applicable)
   --enable-symbols        build with debugging symbols (default: off)
   --enable-embedded-manifest
                           embed manifest if possible (default: yes)
+  --enable-zipfs          build with Zipfs support (default: on)
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-tcl              directory containing tcl configuration
@@ -1422,13 +1475,13 @@
     ac_builddir=.
 
 case "$ac_dir" in
 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
 *)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'`
   # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
   case $ac_top_builddir_sub in
   "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
   *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
   esac ;;
 esac
@@ -1452,31 +1505,32 @@
     ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
 esac
 ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
 
     cd "$ac_dir" || { ac_status=$?; continue; }
-    # Check for guested configure.
+    # Check for configure.gnu first; this name is used for a wrapper for
+    # Metaconfig's "Configure" on case-insensitive file systems.
     if test -f "$ac_srcdir/configure.gnu"; then
       echo &&
       $SHELL "$ac_srcdir/configure.gnu" --help=recursive
     elif test -f "$ac_srcdir/configure"; then
       echo &&
       $SHELL "$ac_srcdir/configure" --help=recursive
     else
-      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+      printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2
     fi || ac_status=$?
     cd "$ac_pwd" || { ac_status=$?; break; }
   done
 fi
 
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-configure
-generated by GNU Autoconf 2.69
+tk configure 8.7
+generated by GNU Autoconf 2.71
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 2021 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
   exit
 fi
@@ -1489,41 +1543,132 @@
 # --------------------------
 # Try to compile conftest.$ac_ext, and return whether this succeeded.
 ac_fn_c_try_compile ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
+  rm -f conftest.$ac_objext conftest.beam
   if { { ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_compile") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
     grep -v '^ *+' conftest.err >conftest.er1
     cat conftest.er1 >&5
     mv -f conftest.er1 conftest.err
   fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; } && {
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then :
+       } && test -s conftest.$ac_objext
+then :
   ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 	ac_retval=1
 fi
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_compile
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+printf %s "checking for $2... " >&6; }
+if eval test \${$3+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  eval "$3=yes"
+else $as_nop
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+printf "%s\n" "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+printf %s "checking for $2... " >&6; }
+if eval test \${$3+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  eval "$3=no"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main (void)
+{
+if (sizeof ($2))
+	 return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main (void)
+{
+if (sizeof (($2)))
+	    return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+
+else $as_nop
+  eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+printf "%s\n" "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_type
 
 # ac_fn_c_try_cpp LINENO
 # ----------------------
 # Try to preprocess conftest.$ac_ext, and return whether this succeeded.
 ac_fn_c_try_cpp ()
@@ -1533,202 +1678,63 @@
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
     grep -v '^ *+' conftest.err >conftest.er1
     cat conftest.er1 >&5
     mv -f conftest.er1 conftest.err
   fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; } > conftest.i && {
 	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
 	 test ! -s conftest.err
-       }; then :
+       }
+then :
   ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
     ac_retval=1
 fi
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_cpp
-
-# ac_fn_c_try_run LINENO
-# ----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
-# that executables *can* be run.
-ac_fn_c_try_run ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-       $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_retval=$ac_status
-fi
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_run
-
-# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists, giving a warning if it cannot be compiled using
-# the include files in INCLUDES and setting the cache variable VAR
-# accordingly.
-ac_fn_c_check_header_mongrel ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if eval \${$3+:} false; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-else
-  # Is the header compilable?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
-$as_echo_n "checking $2 usability... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_header_compiler=yes
-else
-  ac_header_compiler=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
-$as_echo "$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
-$as_echo_n "checking $2 presence... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <$2>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  ac_header_preproc=yes
-else
-  ac_header_preproc=no
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
-$as_echo "$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
-  yes:no: )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
-$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-    ;;
-  no:yes:* )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
-$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
-$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
-$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
-$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-    ;;
-esac
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  eval "$3=\$ac_header_compiler"
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_mongrel
-
-# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists and can be compiled using the include files in
-# INCLUDES, setting the cache variable VAR accordingly.
-ac_fn_c_check_header_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_compile
+ac_configure_args_raw=
+for ac_arg
+do
+  case $ac_arg in
+  *\'*)
+    ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+  esac
+  as_fn_append ac_configure_args_raw " '$ac_arg'"
+done
+
+case $ac_configure_args_raw in
+  *$as_nl*)
+    ac_safe_unquote= ;;
+  *)
+    ac_unsafe_z='|&;<>()$`\\"*?[ ''	' # This string ends in space, tab.
+    ac_unsafe_a="$ac_unsafe_z#~"
+    ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g"
+    ac_configure_args_raw=`      printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;;
+esac
+
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by $as_me, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+It was created by tk $as_me 8.7, which was
+generated by GNU Autoconf 2.71.  Invocation command line was
 
-  $ $0 $@
+  $ $0$ac_configure_args_raw
 
 _ACEOF
 exec 5>>config.log
 {
 cat <<_ASUNAME
@@ -1757,12 +1763,16 @@
 
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    $as_echo "PATH: $as_dir"
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    printf "%s\n" "PATH: $as_dir"
   done
 IFS=$as_save_IFS
 
 } >&5
 
@@ -1793,11 +1803,11 @@
     -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
     -q | -quiet | --quiet | --quie | --qui | --qu | --q \
     | -silent | --silent | --silen | --sile | --sil)
       continue ;;
     *\'*)
-      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+      ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
     esac
     case $ac_pass in
     1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
     2)
       as_fn_append ac_configure_args1 " '$ac_arg'"
@@ -1828,15 +1838,17 @@
 # config.log.  We remove comments because anyway the quotes in there
 # would cause problems or look ugly.
 # WARNING: Use '\'' to represent an apostrophe within the trap.
 # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
 trap 'exit_status=$?
+  # Sanitize IFS.
+  IFS=" ""	$as_nl"
   # Save into config.log some information that might help in debugging.
   {
     echo
 
-    $as_echo "## ---------------- ##
+    printf "%s\n" "## ---------------- ##
 ## Cache variables. ##
 ## ---------------- ##"
     echo
     # The following way of writing the cache mishandles newlines in values,
 (
@@ -1843,12 +1855,12 @@
   for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
     eval ac_val=\$$ac_var
     case $ac_val in #(
     *${as_nl}*)
       case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
       BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
       *) { eval $ac_var=; unset $ac_var;} ;;
@@ -1868,51 +1880,51 @@
     esac |
     sort
 )
     echo
 
-    $as_echo "## ----------------- ##
+    printf "%s\n" "## ----------------- ##
 ## Output variables. ##
 ## ----------------- ##"
     echo
     for ac_var in $ac_subst_vars
     do
       eval ac_val=\$$ac_var
       case $ac_val in
-      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
       esac
-      $as_echo "$ac_var='\''$ac_val'\''"
+      printf "%s\n" "$ac_var='\''$ac_val'\''"
     done | sort
     echo
 
     if test -n "$ac_subst_files"; then
-      $as_echo "## ------------------- ##
+      printf "%s\n" "## ------------------- ##
 ## File substitutions. ##
 ## ------------------- ##"
       echo
       for ac_var in $ac_subst_files
       do
 	eval ac_val=\$$ac_var
 	case $ac_val in
-	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+	*\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
 	esac
-	$as_echo "$ac_var='\''$ac_val'\''"
+	printf "%s\n" "$ac_var='\''$ac_val'\''"
       done | sort
       echo
     fi
 
     if test -s confdefs.h; then
-      $as_echo "## ----------- ##
+      printf "%s\n" "## ----------- ##
 ## confdefs.h. ##
 ## ----------- ##"
       echo
       cat confdefs.h
       echo
     fi
     test "$ac_signal" != 0 &&
-      $as_echo "$as_me: caught signal $ac_signal"
-    $as_echo "$as_me: exit $exit_status"
+      printf "%s\n" "$as_me: caught signal $ac_signal"
+    printf "%s\n" "$as_me: exit $exit_status"
   } >&5
   rm -f core *.core core.conftest.* &&
     rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
     exit $exit_status
 ' 0
@@ -1922,89 +1934,391 @@
 ac_signal=0
 
 # confdefs.h avoids OS command line length limits that DEFS can exceed.
 rm -f -r conftest* confdefs.h
 
-$as_echo "/* confdefs.h */" > confdefs.h
+printf "%s\n" "/* confdefs.h */" > confdefs.h
 
 # Predefined preprocessor variables.
 
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_URL "$PACKAGE_URL"
-_ACEOF
+printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h
+
+printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h
+
+printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h
+
+printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h
+
+printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h
+
+printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h
 
 
 # Let the site file select an alternate cache file if it wants to.
 # Prefer an explicitly selected file to automatically selected ones.
-ac_site_file1=NONE
-ac_site_file2=NONE
 if test -n "$CONFIG_SITE"; then
-  # We do not want a PATH search for config.site.
-  case $CONFIG_SITE in #((
-    -*)  ac_site_file1=./$CONFIG_SITE;;
-    */*) ac_site_file1=$CONFIG_SITE;;
-    *)   ac_site_file1=./$CONFIG_SITE;;
-  esac
+  ac_site_files="$CONFIG_SITE"
 elif test "x$prefix" != xNONE; then
-  ac_site_file1=$prefix/share/config.site
-  ac_site_file2=$prefix/etc/config.site
+  ac_site_files="$prefix/share/config.site $prefix/etc/config.site"
 else
-  ac_site_file1=$ac_default_prefix/share/config.site
-  ac_site_file2=$ac_default_prefix/etc/config.site
+  ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
 fi
-for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+
+for ac_site_file in $ac_site_files
 do
-  test "x$ac_site_file" = xNONE && continue
-  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
-$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+  case $ac_site_file in #(
+  */*) :
+     ;; #(
+  *) :
+    ac_site_file=./$ac_site_file ;;
+esac
+  if test -f "$ac_site_file" && test -r "$ac_site_file"; then
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;}
     sed 's/^/| /' "$ac_site_file" >&5
     . "$ac_site_file" \
-      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+      || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "failed to load site script $ac_site_file
 See \`config.log' for more details" "$LINENO" 5; }
   fi
 done
 
 if test -r "$cache_file"; then
   # Some versions of bash will fail to source /dev/null (special files
   # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
   if test /dev/null != "$cache_file" && test -f "$cache_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
-$as_echo "$as_me: loading cache $cache_file" >&6;}
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+printf "%s\n" "$as_me: loading cache $cache_file" >&6;}
     case $cache_file in
       [\\/]* | ?:[\\/]* ) . "$cache_file";;
       *)                      . "./$cache_file";;
     esac
   fi
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
-$as_echo "$as_me: creating cache $cache_file" >&6;}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+printf "%s\n" "$as_me: creating cache $cache_file" >&6;}
   >$cache_file
 fi
 
+# Test code for whether the C compiler supports C89 (global declarations)
+ac_c_conftest_c89_globals='
+/* Does the compiler advertise C89 conformance?
+   Do not test the value of __STDC__, because some compilers set it to 0
+   while being otherwise adequately conformant. */
+#if !defined __STDC__
+# error "Compiler does not advertise C89 conformance"
+#endif
+
+#include <stddef.h>
+#include <stdarg.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7 src/conf.sh.  */
+struct buf { int x; };
+struct buf * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not \xHH hex character constants.
+   These do not provoke an error unfortunately, instead are silently treated
+   as an "x".  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously \x00 != x always comes out true, for an
+   array size at least.  It is necessary to write \x00 == 0 to get something
+   that is true only with -std.  */
+int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) '\''x'\''
+int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int),
+               int, int);'
+
+# Test code for whether the C compiler supports C89 (body of main).
+ac_c_conftest_c89_main='
+ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]);
+'
+
+# Test code for whether the C compiler supports C99 (global declarations)
+ac_c_conftest_c99_globals='
+// Does the compiler advertise C99 conformance?
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
+# error "Compiler does not advertise C99 conformance"
+#endif
+
+#include <stdbool.h>
+extern int puts (const char *);
+extern int printf (const char *, ...);
+extern int dprintf (int, const char *, ...);
+extern void *malloc (size_t);
+
+// Check varargs macros.  These examples are taken from C99 6.10.3.5.
+// dprintf is used instead of fprintf to avoid needing to declare
+// FILE and stderr.
+#define debug(...) dprintf (2, __VA_ARGS__)
+#define showlist(...) puts (#__VA_ARGS__)
+#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
+static void
+test_varargs_macros (void)
+{
+  int x = 1234;
+  int y = 5678;
+  debug ("Flag");
+  debug ("X = %d\n", x);
+  showlist (The first, second, and third items.);
+  report (x>y, "x is %d but y is %d", x, y);
+}
+
+// Check long long types.
+#define BIG64 18446744073709551615ull
+#define BIG32 4294967295ul
+#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
+#if !BIG_OK
+  #error "your preprocessor is broken"
+#endif
+#if BIG_OK
+#else
+  #error "your preprocessor is broken"
+#endif
+static long long int bignum = -9223372036854775807LL;
+static unsigned long long int ubignum = BIG64;
+
+struct incomplete_array
+{
+  int datasize;
+  double data[];
+};
+
+struct named_init {
+  int number;
+  const wchar_t *name;
+  double average;
+};
+
+typedef const char *ccp;
+
+static inline int
+test_restrict (ccp restrict text)
+{
+  // See if C++-style comments work.
+  // Iterate through items via the restricted pointer.
+  // Also check for declarations in for loops.
+  for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i)
+    continue;
+  return 0;
+}
+
+// Check varargs and va_copy.
+static bool
+test_varargs (const char *format, ...)
+{
+  va_list args;
+  va_start (args, format);
+  va_list args_copy;
+  va_copy (args_copy, args);
+
+  const char *str = "";
+  int number = 0;
+  float fnumber = 0;
+
+  while (*format)
+    {
+      switch (*format++)
+	{
+	case '\''s'\'': // string
+	  str = va_arg (args_copy, const char *);
+	  break;
+	case '\''d'\'': // int
+	  number = va_arg (args_copy, int);
+	  break;
+	case '\''f'\'': // float
+	  fnumber = va_arg (args_copy, double);
+	  break;
+	default:
+	  break;
+	}
+    }
+  va_end (args_copy);
+  va_end (args);
+
+  return *str && number && fnumber;
+}
+'
+
+# Test code for whether the C compiler supports C99 (body of main).
+ac_c_conftest_c99_main='
+  // Check bool.
+  _Bool success = false;
+  success |= (argc != 0);
+
+  // Check restrict.
+  if (test_restrict ("String literal") == 0)
+    success = true;
+  char *restrict newvar = "Another string";
+
+  // Check varargs.
+  success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234);
+  test_varargs_macros ();
+
+  // Check flexible array members.
+  struct incomplete_array *ia =
+    malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
+  ia->datasize = 10;
+  for (int i = 0; i < ia->datasize; ++i)
+    ia->data[i] = i * 1.234;
+
+  // Check named initializers.
+  struct named_init ni = {
+    .number = 34,
+    .name = L"Test wide string",
+    .average = 543.34343,
+  };
+
+  ni.number = 58;
+
+  int dynamic_array[ni.number];
+  dynamic_array[0] = argv[0][0];
+  dynamic_array[ni.number - 1] = 543;
+
+  // work around unused variable warnings
+  ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\''
+	 || dynamic_array[ni.number - 1] != 543);
+'
+
+# Test code for whether the C compiler supports C11 (global declarations)
+ac_c_conftest_c11_globals='
+// Does the compiler advertise C11 conformance?
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
+# error "Compiler does not advertise C11 conformance"
+#endif
+
+// Check _Alignas.
+char _Alignas (double) aligned_as_double;
+char _Alignas (0) no_special_alignment;
+extern char aligned_as_int;
+char _Alignas (0) _Alignas (int) aligned_as_int;
+
+// Check _Alignof.
+enum
+{
+  int_alignment = _Alignof (int),
+  int_array_alignment = _Alignof (int[100]),
+  char_alignment = _Alignof (char)
+};
+_Static_assert (0 < -_Alignof (int), "_Alignof is signed");
+
+// Check _Noreturn.
+int _Noreturn does_not_return (void) { for (;;) continue; }
+
+// Check _Static_assert.
+struct test_static_assert
+{
+  int x;
+  _Static_assert (sizeof (int) <= sizeof (long int),
+                  "_Static_assert does not work in struct");
+  long int y;
+};
+
+// Check UTF-8 literals.
+#define u8 syntax error!
+char const utf8_literal[] = u8"happens to be ASCII" "another string";
+
+// Check duplicate typedefs.
+typedef long *long_ptr;
+typedef long int *long_ptr;
+typedef long_ptr long_ptr;
+
+// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
+struct anonymous
+{
+  union {
+    struct { int i; int j; };
+    struct { int k; long int l; } w;
+  };
+  int m;
+} v1;
+'
+
+# Test code for whether the C compiler supports C11 (body of main).
+ac_c_conftest_c11_main='
+  _Static_assert ((offsetof (struct anonymous, i)
+		   == offsetof (struct anonymous, w.k)),
+		  "Anonymous union alignment botch");
+  v1.i = 2;
+  v1.w.k = 5;
+  ok |= v1.i != 5;
+'
+
+# Test code for whether the C compiler supports C11 (complete).
+ac_c_conftest_c11_program="${ac_c_conftest_c89_globals}
+${ac_c_conftest_c99_globals}
+${ac_c_conftest_c11_globals}
+
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_c_conftest_c89_main}
+  ${ac_c_conftest_c99_main}
+  ${ac_c_conftest_c11_main}
+  return ok;
+}
+"
+
+# Test code for whether the C compiler supports C99 (complete).
+ac_c_conftest_c99_program="${ac_c_conftest_c89_globals}
+${ac_c_conftest_c99_globals}
+
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_c_conftest_c89_main}
+  ${ac_c_conftest_c99_main}
+  return ok;
+}
+"
+
+# Test code for whether the C compiler supports C89 (complete).
+ac_c_conftest_c89_program="${ac_c_conftest_c89_globals}
+
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_c_conftest_c89_main}
+  return ok;
+}
+"
+
+as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H"
+as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H"
+as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H"
+as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H"
+as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H"
+as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H"
+as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H"
+as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H"
+as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H"
 # Check that the precious variables saved in the cache have kept the same
 # value.
 ac_cache_corrupted=false
 for ac_var in $ac_precious_vars; do
   eval ac_old_set=\$ac_cv_env_${ac_var}_set
@@ -2011,56 +2325,57 @@
   eval ac_new_set=\$ac_env_${ac_var}_set
   eval ac_old_val=\$ac_cv_env_${ac_var}_value
   eval ac_new_val=\$ac_env_${ac_var}_value
   case $ac_old_set,$ac_new_set in
     set,)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,set)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,);;
     *)
       if test "x$ac_old_val" != "x$ac_new_val"; then
 	# differences in whitespace do not lead to failure.
 	ac_old_val_w=`echo x $ac_old_val`
 	ac_new_val_w=`echo x $ac_new_val`
 	if test "$ac_old_val_w" != "$ac_new_val_w"; then
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
-$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+	  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
 	  ac_cache_corrupted=:
 	else
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
-$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+	  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
 	  eval $ac_var=\$ac_old_val
 	fi
-	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
-$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
-	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
-$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+printf "%s\n" "$as_me:   former value:  \`$ac_old_val'" >&2;}
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+printf "%s\n" "$as_me:   current value: \`$ac_new_val'" >&2;}
       fi;;
   esac
   # Pass precious variables to config.status.
   if test "$ac_new_set" = set; then
     case $ac_new_val in
-    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
     *) ac_arg=$ac_var=$ac_new_val ;;
     esac
     case " $ac_configure_args " in
       *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
       *) as_fn_append ac_configure_args " '$ac_arg'" ;;
     esac
   fi
 done
 if $ac_cache_corrupted; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
-$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file'
+	    and start over" "$LINENO" 5
 fi
 ## -------------------- ##
 ## Main body of script. ##
 ## -------------------- ##
 
@@ -2070,20 +2385,21 @@
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+
 
 # The following define is needed when building with Cygwin since newer
 # versions of autoconf incorrectly set SHELL to /bin/bash instead of
 # /bin/sh. The bash shell seems to suffer from some strange failures.
 SHELL=/bin/sh
 
 TK_VERSION=8.7
 TK_MAJOR_VERSION=8
 TK_MINOR_VERSION=7
-TK_PATCH_LEVEL="a4"
+TK_PATCH_LEVEL="a6"
 VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION
 
 #------------------------------------------------------------------------
 # Handle the --prefix=... option
 #------------------------------------------------------------------------
@@ -2104,36 +2420,50 @@
 # If the user did not set CFLAGS, set it now to keep
 # the AC_PROG_CC macro from adding "-g -O2".
 if test "${CFLAGS+set}" != "set" ; then
     CFLAGS=""
 fi
+
+
+
+
+
+
+
+
+
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -2140,40 +2470,45 @@
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
 fi
 if test -z "$ac_cv_prog_CC"; then
   ac_ct_CC=$CC
   # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_CC"; then
   ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -2180,24 +2515,24 @@
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+printf "%s\n" "$ac_ct_CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_CC" = x; then
     CC=""
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     CC=$ac_ct_CC
   fi
 else
@@ -2206,27 +2541,32 @@
 
 if test -z "$CC"; then
           if test -n "$ac_tool_prefix"; then
     # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -2233,45 +2573,50 @@
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
   fi
 fi
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   ac_prog_rejected=no
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
      fi
     ac_cv_prog_CC="cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -2283,22 +2628,22 @@
   if test $# != 0; then
     # We chose a different compiler from the bogus one.
     # However, it has the same basename, so the bogon will be chosen
     # first if we set CC to just the basename; use the full file name.
     shift
-    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+    ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@"
   fi
 fi
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
 fi
 if test -z "$CC"; then
@@ -2305,27 +2650,32 @@
   if test -n "$ac_tool_prefix"; then
   for ac_prog in cl.exe
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -2332,15 +2682,15 @@
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
     test -n "$CC" && break
   done
@@ -2349,27 +2699,32 @@
   ac_ct_CC=$CC
   for ac_prog in cl.exe
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_CC"; then
   ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -2376,15 +2731,15 @@
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+printf "%s\n" "$ac_ct_CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
   test -n "$ac_ct_CC" && break
 done
@@ -2392,56 +2747,160 @@
   if test "x$ac_ct_CC" = x; then
     CC=""
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args.
+set dummy ${ac_tool_prefix}clang; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}clang"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf "%s\n" "$CC" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "clang", so it can be a program name with args.
+set dummy clang; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_CC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="clang"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+printf "%s\n" "$ac_ct_CC" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     CC=$ac_ct_CC
   fi
+else
+  CC="$ac_cv_prog_CC"
 fi
 
 fi
 
 
-test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "no acceptable C compiler found in \$PATH
 See \`config.log' for more details" "$LINENO" 5; }
 
 # Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
 set X $ac_compile
 ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
+for ac_option in --version -v -V -qversion -version; do
   { { ac_try="$ac_compiler $ac_option >&5"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_compiler $ac_option >&5") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
     sed '10a\
 ... rest of stderr output deleted ...
          10q' conftest.err >conftest.er1
     cat conftest.er1 >&5
   fi
   rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
 done
 
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
@@ -2449,13 +2908,13 @@
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
 # Try to create an executable without -o first, disregard a.out.
 # It will help us diagnose broken compilers, and finding out an intuition
 # of exeext.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-$as_echo_n "checking whether the C compiler works... " >&6; }
-ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+printf %s "checking whether the C compiler works... " >&6; }
+ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
 
 # The possible output files:
 ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
 
 ac_rmfiles=
@@ -2472,15 +2931,16 @@
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_link_default") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+then :
   # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
 # So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
 # in a Makefile.  We should not override ac_cv_exeext if it was cached,
 # so that the user can short-circuit this test for compilers unknown to
 # Autoconf.
@@ -2493,11 +2953,11 @@
     [ab].out )
 	# We found the default executable, but exeext='' is most
 	# certainly right.
 	break;;
     *.* )
-	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+	if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no;
 	then :; else
 	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
 	fi
 	# We set ac_cv_exeext here because the later test for it is not
 	# safe: cross compilers may not add the suffix if given an `-o'
@@ -2509,48 +2969,50 @@
 	break;;
   esac
 done
 test "$ac_cv_exeext" = no && ac_cv_exeext=
 
-else
+else $as_nop
   ac_file=''
 fi
-if test -z "$ac_file"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-$as_echo "$as_me: failed program was:" >&5
+if test -z "$ac_file"
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error 77 "C compiler cannot create executables
 See \`config.log' for more details" "$LINENO" 5; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
-$as_echo_n "checking for C compiler default output file name... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-$as_echo "$ac_file" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+printf %s "checking for C compiler default output file name... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+printf "%s\n" "$ac_file" >&6; }
 ac_exeext=$ac_cv_exeext
 
 rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
 ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
-$as_echo_n "checking for suffix of executables... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+printf %s "checking for suffix of executables... " >&6; }
 if { { ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_link") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+then :
   # If both `conftest.exe' and `conftest' are `present' (well, observable)
 # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
 # work properly (i.e., refer to `conftest.exe'), while it won't with
 # `rm'.
 for ac_file in conftest.exe conftest conftest.*; do
@@ -2560,28 +3022,28 @@
     *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
 	  break;;
     * ) break;;
   esac
 done
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+else $as_nop
+  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "cannot compute suffix of executables: cannot compile and link
 See \`config.log' for more details" "$LINENO" 5; }
 fi
 rm -f conftest conftest$ac_cv_exeext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
-$as_echo "$ac_cv_exeext" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+printf "%s\n" "$ac_cv_exeext" >&6; }
 
 rm -f conftest.$ac_ext
 EXEEXT=$ac_cv_exeext
 ac_exeext=$EXEEXT
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 FILE *f = fopen ("conftest.out", "w");
  return ferror (f) || fclose (f) != 0;
 
   ;
@@ -2589,63 +3051,64 @@
 }
 _ACEOF
 ac_clean_files="$ac_clean_files conftest.out"
 # Check that the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-$as_echo_n "checking whether we are cross compiling... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+printf %s "checking whether we are cross compiling... " >&6; }
 if test "$cross_compiling" != yes; then
   { { ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_link") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
   if { ac_try='./conftest$ac_cv_exeext'
   { { case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_try") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; }; then
     cross_compiling=no
   else
     if test "$cross_compiling" = maybe; then
 	cross_compiling=yes
     else
-	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run C compiled programs.
+	{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot run C compiled programs.
 If you meant to cross compile, use \`--host'.
 See \`config.log' for more details" "$LINENO" 5; }
     fi
   fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-$as_echo "$cross_compiling" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+printf "%s\n" "$cross_compiling" >&6; }
 
 rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
 ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
-$as_echo_n "checking for suffix of object files... " >&6; }
-if ${ac_cv_objext+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+printf %s "checking for suffix of object files... " >&6; }
+if test ${ac_cv_objext+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
@@ -2655,139 +3118,148 @@
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_compile") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+then :
   for ac_file in conftest.o conftest.obj conftest.*; do
   test -f "$ac_file" || continue;
   case $ac_file in
     *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
     *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
        break;;
   esac
 done
-else
-  $as_echo "$as_me: failed program was:" >&5
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "cannot compute suffix of object files: cannot compile
 See \`config.log' for more details" "$LINENO" 5; }
 fi
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
-$as_echo "$ac_cv_objext" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+printf "%s\n" "$ac_cv_objext" >&6; }
 OBJEXT=$ac_cv_objext
 ac_objext=$OBJEXT
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
-$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if ${ac_cv_c_compiler_gnu+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5
+printf %s "checking whether the compiler supports GNU C... " >&6; }
+if test ${ac_cv_c_compiler_gnu+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 #ifndef __GNUC__
        choke me
 #endif
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_compiler_gnu=yes
-else
+else $as_nop
   ac_compiler_gnu=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 ac_cv_c_compiler_gnu=$ac_compiler_gnu
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
-$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; }
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
 if test $ac_compiler_gnu = yes; then
   GCC=yes
 else
   GCC=
 fi
-ac_test_CFLAGS=${CFLAGS+set}
+ac_test_CFLAGS=${CFLAGS+y}
 ac_save_CFLAGS=$CFLAGS
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
-$as_echo_n "checking whether $CC accepts -g... " >&6; }
-if ${ac_cv_prog_cc_g+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+printf %s "checking whether $CC accepts -g... " >&6; }
+if test ${ac_cv_prog_cc_g+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_save_c_werror_flag=$ac_c_werror_flag
    ac_c_werror_flag=yes
    ac_cv_prog_cc_g=no
    CFLAGS="-g"
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_prog_cc_g=yes
-else
+else $as_nop
   CFLAGS=""
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
 
-else
+else $as_nop
   ac_c_werror_flag=$ac_save_c_werror_flag
 	 CFLAGS="-g"
 	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_prog_cc_g=yes
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
    ac_c_werror_flag=$ac_save_c_werror_flag
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
-$as_echo "$ac_cv_prog_cc_g" >&6; }
-if test "$ac_test_CFLAGS" = set; then
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+printf "%s\n" "$ac_cv_prog_cc_g" >&6; }
+if test $ac_test_CFLAGS; then
   CFLAGS=$ac_save_CFLAGS
 elif test $ac_cv_prog_cc_g = yes; then
   if test "$GCC" = yes; then
     CFLAGS="-g -O2"
   else
@@ -2798,133 +3270,185 @@
     CFLAGS="-O2"
   else
     CFLAGS=
   fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
-$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if ${ac_cv_prog_cc_c89+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+ac_prog_cc_stdc=no
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5
+printf %s "checking for $CC option to enable C11 features... " >&6; }
+if test ${ac_cv_prog_cc_c11+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_cv_prog_cc_c11=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_c_conftest_c11_program
+_ACEOF
+for ac_arg in '' -std=gnu11
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_prog_cc_c11=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam
+  test "x$ac_cv_prog_cc_c11" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+fi
+
+if test "x$ac_cv_prog_cc_c11" = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
+else $as_nop
+  if test "x$ac_cv_prog_cc_c11" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5
+printf "%s\n" "$ac_cv_prog_cc_c11" >&6; }
+     CC="$CC $ac_cv_prog_cc_c11"
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11
+  ac_prog_cc_stdc=c11
+fi
+fi
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5
+printf %s "checking for $CC option to enable C99 features... " >&6; }
+if test ${ac_cv_prog_cc_c99+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_cv_prog_cc_c99=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_c_conftest_c99_program
+_ACEOF
+for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99=
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_prog_cc_c99=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam
+  test "x$ac_cv_prog_cc_c99" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+fi
+
+if test "x$ac_cv_prog_cc_c99" = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
+else $as_nop
+  if test "x$ac_cv_prog_cc_c99" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
+printf "%s\n" "$ac_cv_prog_cc_c99" >&6; }
+     CC="$CC $ac_cv_prog_cc_c99"
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
+  ac_prog_cc_stdc=c99
+fi
+fi
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5
+printf %s "checking for $CC option to enable C89 features... " >&6; }
+if test ${ac_cv_prog_cc_c89+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_cv_prog_cc_c89=no
 ac_save_CC=$CC
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdio.h>
-struct stat;
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
-{
-  return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
-  char *s;
-  va_list v;
-  va_start (v,p);
-  s = g (p, va_arg (v,int));
-  va_end (v);
-  return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
-   function prototypes and stuff, but not '\xHH' hex character constants.
-   These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std is added to get
-   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
-   array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std.  */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
-   inside strings and character constants.  */
-#define FOO(x) 'x'
-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
-  ;
-  return 0;
-}
+$ac_c_conftest_c89_program
 _ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 do
   CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
+  if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_prog_cc_c89=$ac_arg
 fi
-rm -f core conftest.err conftest.$ac_objext
+rm -f core conftest.err conftest.$ac_objext conftest.beam
   test "x$ac_cv_prog_cc_c89" != "xno" && break
 done
 rm -f conftest.$ac_ext
 CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c89" in
-  x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
-  xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_c89"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
-$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c89" != xno; then :
-
+fi
+
+if test "x$ac_cv_prog_cc_c89" = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
+else $as_nop
+  if test "x$ac_cv_prog_cc_c89" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+printf "%s\n" "$ac_cv_prog_cc_c89" >&6; }
+     CC="$CC $ac_cv_prog_cc_c89"
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
+  ac_prog_cc_stdc=c89
+fi
 fi
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
-$as_echo_n "checking for inline... " >&6; }
-if ${ac_cv_c_inline+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
+printf %s "checking for inline... " >&6; }
+if test ${ac_cv_c_inline+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #ifndef __cplusplus
 typedef int foo_t;
-static $ac_kw foo_t static_foo () {return 0; }
-$ac_kw foo_t foo () {return 0; }
+static $ac_kw foo_t static_foo (void) {return 0; }
+$ac_kw foo_t foo (void) {return 0; }
 #endif
 
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_c_inline=$ac_kw
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
   test "$ac_cv_c_inline" != no && break
 done
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
-$as_echo "$ac_cv_c_inline" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
+printf "%s\n" "$ac_cv_c_inline" >&6; }
 
 case $ac_cv_c_inline in
   inline | yes) ;;
   *)
     case $ac_cv_c_inline in
@@ -2937,411 +3461,65 @@
 #endif
 _ACEOF
     ;;
 esac
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
-$as_echo_n "checking how to run the C preprocessor... " >&6; }
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
-fi
-if test -z "$CPP"; then
-  if ${ac_cv_prog_CPP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-      # Double quotes because CPP needs to be expanded
-    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
-    do
-      ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
-else
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-  break
-fi
-
-    done
-    ac_cv_prog_CPP=$CPP
-
-fi
-  CPP=$ac_cv_prog_CPP
-else
-  ac_cv_prog_CPP=$CPP
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
-$as_echo "$CPP" >&6; }
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
-else
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
-$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if ${ac_cv_path_GREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$GREP"; then
-  ac_path_GREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in grep ggrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_GREP" || continue
-# Check for GNU ac_path_GREP and select it if it is found.
-  # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'GREP' >> "conftest.nl"
-    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_GREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_GREP="$ac_path_GREP"
-      ac_path_GREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_GREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_GREP"; then
-    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_GREP=$GREP
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
-$as_echo "$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-$as_echo_n "checking for egrep... " >&6; }
-if ${ac_cv_path_EGREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
-   then ac_cv_path_EGREP="$GREP -E"
-   else
-     if test -z "$EGREP"; then
-  ac_path_EGREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in egrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_EGREP" || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
-  # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'EGREP' >> "conftest.nl"
-    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_EGREP="$ac_path_EGREP"
-      ac_path_EGREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_EGREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_EGREP=$EGREP
-fi
-
-   fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-$as_echo "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if ${ac_cv_header_stdc+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_header_stdc=yes
-else
-  ac_cv_header_stdc=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then :
-  :
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
-		   (('a' <= (c) && (c) <= 'i') \
-		     || ('j' <= (c) && (c) <= 'r') \
-		     || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-	|| toupper (i) != TOUPPER (i))
-      return 2;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
-$as_echo "$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-$as_echo "#define STDC_HEADERS 1" >>confdefs.h
-
-fi
-
+ac_header= ac_cache=
+for ac_item in $ac_header_c_list
+do
+  if test $ac_cache; then
+    ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default"
+    if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then
+      printf "%s\n" "#define $ac_item 1" >> confdefs.h
+    fi
+    ac_header= ac_cache=
+  elif test $ac_header; then
+    ac_cache=$ac_item
+  else
+    ac_header=$ac_item
+  fi
+done
+
+
+
+
+
+
+
+
+if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes
+then :
+
+printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
 
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_AR+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$AR"; then
   ac_cv_prog_AR="$AR" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_AR="${ac_tool_prefix}ar"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -3348,40 +3526,45 @@
 
 fi
 fi
 AR=$ac_cv_prog_AR
 if test -n "$AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
-$as_echo "$AR" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+printf "%s\n" "$AR" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
 fi
 if test -z "$ac_cv_prog_AR"; then
   ac_ct_AR=$AR
   # Extract the first word of "ar", so it can be a program name with args.
 set dummy ar; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_AR+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_AR"; then
   ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_AR="ar"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -3388,24 +3571,24 @@
 
 fi
 fi
 ac_ct_AR=$ac_cv_prog_ac_ct_AR
 if test -n "$ac_ct_AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
-$as_echo "$ac_ct_AR" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+printf "%s\n" "$ac_ct_AR" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_AR" = x; then
     AR=""
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     AR=$ac_ct_AR
   fi
 else
@@ -3413,27 +3596,32 @@
 fi
 
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_RANLIB+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -3440,40 +3628,45 @@
 
 fi
 fi
 RANLIB=$ac_cv_prog_RANLIB
 if test -n "$RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
-$as_echo "$RANLIB" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+printf "%s\n" "$RANLIB" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
 fi
 if test -z "$ac_cv_prog_RANLIB"; then
   ac_ct_RANLIB=$RANLIB
   # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_RANLIB+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_RANLIB"; then
   ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_RANLIB="ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -3480,24 +3673,24 @@
 
 fi
 fi
 ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
 if test -n "$ac_ct_RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
-$as_echo "$ac_ct_RANLIB" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+printf "%s\n" "$ac_ct_RANLIB" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_RANLIB" = x; then
     RANLIB=""
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     RANLIB=$ac_ct_RANLIB
   fi
 else
@@ -3505,27 +3698,32 @@
 fi
 
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args.
 set dummy ${ac_tool_prefix}windres; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_RC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_RC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$RC"; then
   ac_cv_prog_RC="$RC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_RC="${ac_tool_prefix}windres"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -3532,40 +3730,45 @@
 
 fi
 fi
 RC=$ac_cv_prog_RC
 if test -n "$RC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RC" >&5
-$as_echo "$RC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RC" >&5
+printf "%s\n" "$RC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
 fi
 if test -z "$ac_cv_prog_RC"; then
   ac_ct_RC=$RC
   # Extract the first word of "windres", so it can be a program name with args.
 set dummy windres; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_RC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_RC+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$ac_ct_RC"; then
   ac_cv_prog_ac_ct_RC="$ac_ct_RC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_RC="windres"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -3572,24 +3775,24 @@
 
 fi
 fi
 ac_ct_RC=$ac_cv_prog_ac_ct_RC
 if test -n "$ac_ct_RC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RC" >&5
-$as_echo "$ac_ct_RC" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RC" >&5
+printf "%s\n" "$ac_ct_RC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
   if test "x$ac_ct_RC" = x; then
     RC=""
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     RC=$ac_ct_RC
   fi
 else
@@ -3599,17 +3802,18 @@
 
 #--------------------------------------------------------------------
 # Checks to see if the make program sets the $MAKE variable.
 #--------------------------------------------------------------------
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
-$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+printf %s "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
 set x ${MAKE-make}
-ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
-if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+ac_make=`printf "%s\n" "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if eval test \${ac_cv_prog_make_${ac_make}_set+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat >conftest.make <<\_ACEOF
 SHELL = /bin/sh
 all:
 	@echo '@@@%%%=$(MAKE)=@@@%%%'
 _ACEOF
@@ -3621,16 +3825,16 @@
     eval ac_cv_prog_make_${ac_make}_set=no;;
 esac
 rm -f conftest.make
 fi
 if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
   SET_MAKE=
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
   SET_MAKE="MAKE=${MAKE-make}"
 fi
 
 
 #--------------------------------------------------------------------
@@ -3644,37 +3848,30 @@
 # The statements below define a collection of symbols related to
 # building libtk as a shared library instead of a static library.
 #--------------------------------------------------------------------
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to build libraries" >&5
-$as_echo_n "checking how to build libraries... " >&6; }
-    # Check whether --enable-shared was given.
-if test "${enable_shared+set}" = set; then :
-  enableval=$enable_shared; tcl_ok=$enableval
-else
-  tcl_ok=yes
-fi
-
-
-    if test "${enable_shared+set}" = set; then
-	enableval="$enable_shared"
-	tcl_ok=$enableval
-    else
-	tcl_ok=yes
-    fi
-
-    if test "$tcl_ok" = "yes" ; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: shared" >&5
-$as_echo "shared" >&6; }
-	SHARED_BUILD=1
-    else
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: static" >&5
-$as_echo "static" >&6; }
-	SHARED_BUILD=0
-
-$as_echo "#define STATIC_BUILD 1" >>confdefs.h
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to build libraries" >&5
+printf %s "checking how to build libraries... " >&6; }
+    # Check whether --enable-shared was given.
+if test ${enable_shared+y}
+then :
+  enableval=$enable_shared; tcl_ok=$enableval
+else $as_nop
+  tcl_ok=yes
+fi
+
+    if test "$tcl_ok" = "yes" ; then
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: shared" >&5
+printf "%s\n" "shared" >&6; }
+	SHARED_BUILD=1
+    else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: static" >&5
+printf "%s\n" "static" >&6; }
+	SHARED_BUILD=0
+
+printf "%s\n" "#define STATIC_BUILD 1" >>confdefs.h
 
     fi
 
 
 
@@ -3692,28 +3889,30 @@
     if test x"${no_tcl}" = x ; then
 	# we reset no_tcl in case something fails here
 	no_tcl=true
 
 # Check whether --with-tcl was given.
-if test "${with_tcl+set}" = set; then :
+if test ${with_tcl+y}
+then :
   withval=$with_tcl; with_tclconfig="${withval}"
 fi
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl configuration" >&5
-$as_echo_n "checking for Tcl configuration... " >&6; }
-	if ${ac_cv_c_tclconfig+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Tcl configuration" >&5
+printf %s "checking for Tcl configuration... " >&6; }
+	if test ${ac_cv_c_tclconfig+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 
 	    # First check to see if --with-tcl was specified.
 	    if test x"${with_tclconfig}" != x ; then
 		case "${with_tclconfig}" in
 		    */tclConfig.sh )
 			if test -f "${with_tclconfig}"; then
-			    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&5
-$as_echo "$as_me: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&2;}
+			    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&5
+printf "%s\n" "$as_me: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&2;}
 			    with_tclconfig="`echo "${with_tclconfig}" | sed 's!/tclConfig\.sh$!!'`"
 			fi ;;
 		esac
 		if test -f "${with_tclconfig}/tclConfig.sh" ; then
 		    ac_cv_c_tclconfig="`(cd "${with_tclconfig}"; pwd)`"
@@ -3784,26 +3983,26 @@
 	    TCL_BIN_DIR="# no Tcl configs found"
 	    as_fn_error $? "Can't find Tcl configuration definitions. Use --with-tcl to specify a directory containing tclConfig.sh" "$LINENO" 5
 	else
 	    no_tcl=
 	    TCL_BIN_DIR="${ac_cv_c_tclconfig}"
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${TCL_BIN_DIR}/tclConfig.sh" >&5
-$as_echo "found ${TCL_BIN_DIR}/tclConfig.sh" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found ${TCL_BIN_DIR}/tclConfig.sh" >&5
+printf "%s\n" "found ${TCL_BIN_DIR}/tclConfig.sh" >&6; }
 	fi
     fi
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for existence of ${TCL_BIN_DIR}/tclConfig.sh" >&5
-$as_echo_n "checking for existence of ${TCL_BIN_DIR}/tclConfig.sh... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for existence of ${TCL_BIN_DIR}/tclConfig.sh" >&5
+printf %s "checking for existence of ${TCL_BIN_DIR}/tclConfig.sh... " >&6; }
 
     if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: loading" >&5
-$as_echo "loading" >&6; }
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: loading" >&5
+printf "%s\n" "loading" >&6; }
 	. "${TCL_BIN_DIR}/tclConfig.sh"
     else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not find ${TCL_BIN_DIR}/tclConfig.sh" >&5
-$as_echo "could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6; }
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: could not find ${TCL_BIN_DIR}/tclConfig.sh" >&5
+printf "%s\n" "could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6; }
     fi
 
     #
     # If the TCL_BIN_DIR is the build directory (not the install directory),
     # then set the common variable name to the value of the build variables.
@@ -3836,11 +4035,10 @@
 
 
 
 
 
-
 if test "${TCL_MAJOR_VERSION}" -lt 9 ; then
 if test "${TCL_MAJOR_VERSION}" != "${TK_MAJOR_VERSION}"; then
     as_fn_error $? "${TCL_BIN_DIR}/tclConfig.sh is for Tcl ${TCL_VERSION}.
 Tk ${TK_VERSION}${TK_PATCH_LEVEL} needs Tcl 8.6+.
 Use --with-tcl= option to indicate location of tclConfig.sh file for Tcl 8.6 or better." "$LINENO" 5
@@ -3855,69 +4053,58 @@
 #--------------------------------------------------------------------
 # The statements below define a collection of compile flags.  This
 # macro depends on the value of SHARED_BUILD, and should be called
 # after SC_ENABLE_SHARED checks the configure switches.
 #--------------------------------------------------------------------
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-		  inttypes.h stdint.h unistd.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
 
 
 
     # Step 0: Enable 64 bit support?
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if 64bit support is requested" >&5
-$as_echo_n "checking if 64bit support is requested... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if 64bit support is requested" >&5
+printf %s "checking if 64bit support is requested... " >&6; }
     # Check whether --enable-64bit was given.
-if test "${enable_64bit+set}" = set; then :
+if test ${enable_64bit+y}
+then :
   enableval=$enable_64bit; do64bit=$enableval
-else
+else $as_nop
   do64bit=no
 fi
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $do64bit" >&5
-$as_echo "$do64bit" >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $do64bit" >&5
+printf "%s\n" "$do64bit" >&6; }
 
     # Set some defaults (may get changed below)
     EXTRA_CFLAGS=""
 
-$as_echo "#define MODULE_SCOPE extern" >>confdefs.h
+printf "%s\n" "#define MODULE_SCOPE extern" >>confdefs.h
 
 
     # Extract the first word of "cygpath", so it can be a program name with args.
 set dummy cygpath; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CYGPATH+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CYGPATH+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$CYGPATH"; then
   ac_cv_prog_CYGPATH="$CYGPATH" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_CYGPATH="cygpath -m"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -3925,37 +4112,42 @@
   test -z "$ac_cv_prog_CYGPATH" && ac_cv_prog_CYGPATH="echo"
 fi
 fi
 CYGPATH=$ac_cv_prog_CYGPATH
 if test -n "$CYGPATH"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CYGPATH" >&5
-$as_echo "$CYGPATH" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CYGPATH" >&5
+printf "%s\n" "$CYGPATH" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
     # Extract the first word of "wine", so it can be a program name with args.
 set dummy wine; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_WINE+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_WINE+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   if test -n "$WINE"; then
   ac_cv_prog_WINE="$WINE" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
     ac_cv_prog_WINE="wine"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
   done
 IFS=$as_save_IFS
@@ -3962,57 +4154,59 @@
 
 fi
 fi
 WINE=$ac_cv_prog_WINE
 if test -n "$WINE"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WINE" >&5
-$as_echo "$WINE" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $WINE" >&5
+printf "%s\n" "$WINE" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
 
 
     SHLIB_SUFFIX=".dll"
 
     # MACHINE is IX86 for LINK, but this is used by the manifest,
-    # which requires x86|amd64|ia64.
+    # which requires x86|amd64|arm64|ia64.
     MACHINE="X86"
 
     if test "$GCC" = "yes"; then
 
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cross-compile version of gcc" >&5
-$as_echo_n "checking for cross-compile version of gcc... " >&6; }
-if ${ac_cv_cross+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for cross-compile version of gcc" >&5
+printf %s "checking for cross-compile version of gcc... " >&6; }
+if test ${ac_cv_cross+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 	    #ifndef _WIN32
 		#error cross-compiler
 	    #endif
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_cross=no
-else
+else $as_nop
   ac_cv_cross=yes
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cross" >&5
-$as_echo "$ac_cv_cross" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cross" >&5
+printf "%s\n" "$ac_cv_cross" >&6; }
 
       if test "$ac_cv_cross" = "yes"; then
 	case "$do64bit" in
 	    amd64|x64|yes)
 		CC="x86_64-w64-mingw32-${CC}"
@@ -4019,10 +4213,17 @@
 		LD="x86_64-w64-mingw32-ld"
 		AR="x86_64-w64-mingw32-ar"
 		RANLIB="x86_64-w64-mingw32-ranlib"
 		RC="x86_64-w64-mingw32-windres"
 	    ;;
+	    arm64|aarch64)
+		CC="aarch64-w64-mingw32-${CC}"
+		LD="aarch64-w64-mingw32-ld"
+		AR="aarch64-w64-mingw32-ar"
+		RANLIB="aarch64-w64-mingw32-ranlib"
+		RC="aarch64-w64-mingw32-windres"
+	    ;;
 	    *)
 		CC="i686-w64-mingw32-${CC}"
 		LD="i686-w64-mingw32-ld"
 		AR="i686-w64-mingw32-ar"
 		RANLIB="i686-w64-mingw32-ranlib"
@@ -4043,24 +4244,24 @@
 	conftest=/tmp/conftest.rc
 	echo "STRINGTABLE BEGIN" > $conftest
 	echo "101 \"name\"" >> $conftest
 	echo "END" >> $conftest
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Windows native path bug in windres" >&5
-$as_echo_n "checking for Windows native path bug in windres... " >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Windows native path bug in windres" >&5
+printf %s "checking for Windows native path bug in windres... " >&6; }
 	cyg_conftest=`$CYGPATH $conftest`
 	if { ac_try='$RC -o conftest.res.o $cyg_conftest'
   { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; } ; then
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 	else
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
 	    CYGPATH=echo
 	fi
 	conftest=
 	cyg_conftest=
     fi
@@ -4074,83 +4275,90 @@
     # set various compiler flags depending on whether we are using gcc or cl
 
     if test "${GCC}" = "yes" ; then
 	extra_cflags="-pipe"
 	extra_ldflags="-pipe -static-libgcc"
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mingw32 version of gcc" >&5
-$as_echo_n "checking for mingw32 version of gcc... " >&6; }
-if ${ac_cv_win32+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for mingw32 version of gcc" >&5
+printf %s "checking for mingw32 version of gcc... " >&6; }
+if test ${ac_cv_win32+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 		#ifdef _WIN32
 		    #error win32
 		#endif
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   ac_cv_win32=no
-else
+else $as_nop
   ac_cv_win32=yes
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_win32" >&5
-$as_echo "$ac_cv_win32" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_win32" >&5
+printf "%s\n" "$ac_cv_win32" >&6; }
 	if test "$ac_cv_win32" != "yes"; then
 	    as_fn_error $? "${CC} cannot produce win32 executables." "$LINENO" 5
 	fi
+	if test "$do64bit" != "arm64"; then
+	    extra_cflags="$extra_cflags -DHAVE_CPUID=1"
+	fi
 
 	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -mwindows -municode -Dmain=xxmain"
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working -municode linker flag" >&5
-$as_echo_n "checking for working -municode linker flag... " >&6; }
-if ${ac_cv_municode+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working -municode linker flag" >&5
+printf %s "checking for working -municode linker flag... " >&6; }
+if test ${ac_cv_municode+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 # ac_fn_c_try_link LINENO
 # -----------------------
 # Try to link conftest.$ac_ext, and return whether this succeeded.
 ac_fn_c_try_link ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext conftest$ac_exeext
+  rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext
   if { { ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+printf "%s\n" "$ac_try_echo"; } >&5
   (eval "$ac_link") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
     grep -v '^ *+' conftest.err >conftest.er1
     cat conftest.er1 >&5
     mv -f conftest.er1 conftest.err
   fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; } && {
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
 	 test -x conftest$ac_exeext
-       }; then :
+       }
+then :
   ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 	ac_retval=1
 fi
   # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
@@ -4167,44 +4375,147 @@
 
 	#include <windows.h>
 	int APIENTRY wWinMain(HINSTANCE a, HINSTANCE b, LPWSTR c, int d) {return 0;}
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   ac_cv_municode=yes
-else
+else $as_nop
   ac_cv_municode=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_municode" >&5
-$as_echo "$ac_cv_municode" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_municode" >&5
+printf "%s\n" "$ac_cv_municode" >&6; }
 	CFLAGS=$hold_cflags
 	if test "$ac_cv_municode" = "yes" ; then
 	    extra_ldflags="$extra_ldflags -municode"
 	else
 	    extra_cflags="$extra_cflags -DTCL_BROKEN_MAINARGS"
 	fi
+	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -fno-lto"
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working -fno-lto" >&5
+printf %s "checking for working -fno-lto... " >&6; }
+if test ${ac_cv_nolto+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_nolto=yes
+else $as_nop
+  ac_cv_nolto=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_nolto" >&5
+printf "%s\n" "$ac_cv_nolto" >&6; }
+	CFLAGS=$hold_cflags
+	if test "$ac_cv_nolto" = "yes" ; then
+	    CFLAGS_NOLTO="-fno-lto"
+	else
+	    CFLAGS_NOLTO=""
+	fi
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the compiler understands -finput-charset" >&5
+printf %s "checking if the compiler understands -finput-charset... " >&6; }
+if test ${tcl_cv_cc_input_charset+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+	    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -finput-charset=UTF-8"
+	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  tcl_cv_cc_input_charset=yes
+else $as_nop
+  tcl_cv_cc_input_charset=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+	    CFLAGS=$hold_cflags
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_input_charset" >&5
+printf "%s\n" "$tcl_cv_cc_input_charset" >&6; }
+	if test $tcl_cv_cc_input_charset = yes; then
+	    extra_cflags="$extra_cflags -finput-charset=UTF-8"
+	fi
+    fi
+
+    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Wl,--enable-auto-image-base"
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working --enable-auto-image-base" >&5
+printf %s "checking for working --enable-auto-image-base... " >&6; }
+if test ${ac_cv_enable_auto_image_base+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_enable_auto_image_base=yes
+else $as_nop
+  ac_cv_enable_auto_image_base=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_enable_auto_image_base" >&5
+printf "%s\n" "$ac_cv_enable_auto_image_base" >&6; }
+    CFLAGS=$hold_cflags
+    if test "$ac_cv_enable_auto_image_base" == "yes" ; then
+	extra_ldflags="$extra_ldflags -Wl,--enable-auto-image-base"
     fi
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking compiler flags" >&5
-$as_echo_n "checking compiler flags... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking compiler flags" >&5
+printf %s "checking compiler flags... " >&6; }
     if test "${GCC}" = "yes" ; then
 	SHLIB_LD=""
 	SHLIB_LD_LIBS='${LIBS}'
 	LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -luserenv -lws2_32"
 	# mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't
-	LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32"
+	LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32 -lwinspool"
 	STLIB_LD='${AR} cr'
 	RC_OUT=-o
 	RC_TYPE=
 	RC_INCLUDE=--include
 	RC_DEFINE=--define
@@ -4215,19 +4526,19 @@
 	MAKE_EXE="\${CC} -o \$@"
 	LIBPREFIX="lib"
 
 	if test "${SHARED_BUILD}" = "0" ; then
 	    # static
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: using static flags" >&5
-$as_echo "using static flags" >&6; }
+            { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: using static flags" >&5
+printf "%s\n" "using static flags" >&6; }
 	    runtime=
 	    LIBRARIES="\${STATIC_LIBRARIES}"
 	    EXESUFFIX="s.exe"
 	else
 	    # dynamic
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: using shared flags" >&5
-$as_echo "using shared flags" >&6; }
+            { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: using shared flags" >&5
+printf "%s\n" "using shared flags" >&6; }
 
 	    # ad-hoc check to see if CC supports -shared.
 	    if "${CC}" -shared 2>&1 | egrep ': -shared not supported' >/dev/null; then
 		as_fn_error $? "${CC} does not support the -shared option.
                 You will need to upgrade to a newer version of the toolchain." "$LINENO" 5
@@ -4242,11 +4553,11 @@
 	# Link with gcc since ld does not link to default libs like
 	# -luser32 and -lmsvcrt by default.
 	SHLIB_LD='${CC} -shared'
 	SHLIB_LD_LIBS='${LIBS}'
 	MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -o \$@ ${extra_ldflags} \
-	    -Wl,--out-implib,\$(patsubst %.dll,lib%.a,\$@)"
+	    -Wl,--out-implib,\$(patsubst %.dll,lib%.dll.a,\$@)"
 	# DLLSUFFIX is separate because it is the building block for
 	# users of tclConfig.sh that may build shared or static.
 	DLLSUFFIX=".dll"
 	LIBSUFFIX=".a"
 	LIBFLAGSUFFIX=""
@@ -4263,11 +4574,11 @@
 	case "${CC}" in
 	    *++)
 		CFLAGS_WARNING="${CFLAGS_WARNING} -Wno-format"
 		;;
 	    *)
-		CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -Wdeclaration-after-statement"
+		CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -fextended-identifiers"
 		;;
 	esac
 
 	# Specify the CC output file names based on the target name
 	CC_OBJNAME="-o \$@"
@@ -4291,17 +4602,22 @@
 	LDFLAGS_WINDOW="-mwindows ${extra_ldflags}"
 
 	case "$do64bit" in
 	    amd64|x64|yes)
 		MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result:    Using 64-bit $MACHINE mode" >&5
-$as_echo "   Using 64-bit $MACHINE mode" >&6; }
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result:    Using 64-bit $MACHINE mode" >&5
+printf "%s\n" "   Using 64-bit $MACHINE mode" >&6; }
+		;;
+	    arm64|aarch64)
+		MACHINE="ARM64"
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result:    Using ARM64 $MACHINE mode" >&5
+printf "%s\n" "   Using ARM64 $MACHINE mode" >&6; }
 		;;
 	    ia64)
 		MACHINE="IA64"
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result:    Using 64-bit $MACHINE mode" >&5
-$as_echo "   Using 64-bit $MACHINE mode" >&6; }
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result:    Using IA64 $MACHINE mode" >&5
+printf "%s\n" "   Using IA64 $MACHINE mode" >&6; }
 		;;
 	    *)
 		cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -4308,44 +4624,45 @@
 		    #ifndef _WIN64
 			#error 32-bit
 		    #endif
 
 int
-main ()
+main (void)
 {
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_win_64bit=yes
-else
+else $as_nop
   tcl_win_64bit=no
 
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 		if test "$tcl_win_64bit" = "yes" ; then
-			do64bit=amd64
-			MACHINE="AMD64"
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result:    Using 64-bit $MACHINE mode" >&5
-$as_echo "   Using 64-bit $MACHINE mode" >&6; }
+		    do64bit=amd64
+		    MACHINE="AMD64"
+		    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result:    Using 64-bit $MACHINE mode" >&5
+printf "%s\n" "   Using 64-bit $MACHINE mode" >&6; }
 		fi
 		;;
 	esac
     else
 	if test "${SHARED_BUILD}" = "0" ; then
 	    # static
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: using static flags" >&5
-$as_echo "using static flags" >&6; }
+            { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: using static flags" >&5
+printf "%s\n" "using static flags" >&6; }
 	    runtime=-MT
 	    LIBRARIES="\${STATIC_LIBRARIES}"
 	    EXESUFFIX="s.exe"
 	else
 	    # dynamic
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: using shared flags" >&5
-$as_echo "using shared flags" >&6; }
+            { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: using shared flags" >&5
+printf "%s\n" "using shared flags" >&6; }
 	    runtime=-MD
 	    # Add SHLIB_LD_LIBS to the Make rule, not here.
 	    LIBRARIES="\${SHARED_LIBRARIES}"
 	    EXESUFFIX=".exe"
 	    case "x`echo \${VisualStudioVersion}`" in
@@ -4366,16 +4683,19 @@
 	if test "$do64bit" != "no" ; then
 	    case "$do64bit" in
 		amd64|x64|yes)
 		    MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
 		    ;;
+		arm64|aarch64)
+		    MACHINE="ARM64"
+		    ;;
 		ia64)
 		    MACHINE="IA64"
 		    ;;
 	    esac
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result:    Using 64-bit $MACHINE mode" >&5
-$as_echo "   Using 64-bit $MACHINE mode" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result:    Using 64-bit $MACHINE mode" >&5
+printf "%s\n" "   Using 64-bit $MACHINE mode" >&6; }
 	fi
 
 	LIBS="netapi32.lib kernel32.lib user32.lib advapi32.lib userenv.lib ws2_32.lib"
 
 	case "x`echo \${VisualStudioVersion}`" in
@@ -4387,12 +4707,11 @@
 	esac
 
 	if test "$do64bit" != "no" ; then
 	    RC="rc"
 	    CFLAGS_DEBUG="-nologo -Zi -Od ${runtime}d"
-	    # Do not use -O2 for Win64 - this has proved buggy in code gen.
-	    CFLAGS_OPTIMIZE="-nologo -O1 ${runtime}"
+	    CFLAGS_OPTIMIZE="-nologo -O2 ${runtime}"
 	    lflags="${lflags} -nologo -MACHINE:${MACHINE}"
 	    LINKBIN="link"
 	    # Avoid 'unresolved external symbol __security_cookie' errors.
 	    # c.f. http://support.microsoft.com/?id=894573
 	    LIBS="$LIBS bufferoverflowU.lib"
@@ -4405,11 +4724,11 @@
 	    CFLAGS_OPTIMIZE="-nologo -O2 ${runtime}"
 	    lflags="${lflags} -nologo"
 	    LINKBIN="link"
 	fi
 
-	LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib"
+	LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib winspool.lib"
 
 	SHLIB_LD="${LINKBIN} -dll -incremental:no ${lflags}"
 	SHLIB_LD_LIBS='${LIBS}'
 	# link -lib only works when -lib is the first arg
 	STLIB_LD="${LINKBIN} -lib ${lflags}"
@@ -4446,24 +4765,69 @@
 	    LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}"
 	fi
     fi
 
     if test "$do64bit" != "no" ; then
-	$as_echo "#define TCL_CFG_DO64BIT 1" >>confdefs.h
+	printf "%s\n" "#define TCL_CFG_DO64BIT 1" >>confdefs.h
 
     fi
 
     if test "${GCC}" = "yes" ; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SEH support in compiler" >&5
-$as_echo_n "checking for SEH support in compiler... " >&6; }
-if ${tcl_cv_seh+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SEH support in compiler" >&5
+printf %s "checking for SEH support in compiler... " >&6; }
+if test ${tcl_cv_seh+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test "$cross_compiling" = yes
+then :
   tcl_cv_seh=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+else $as_nop
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that
+# executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf "%s\n" "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf "%s\n" "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+then :
+  ac_retval=0
+else $as_nop
+  printf "%s\n" "$as_me: program exited with status $ac_status" >&5
+       printf "%s\n" "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 	    #define WIN32_LEAN_AND_MEAN
 	    #include <windows.h>
 	    #undef WIN32_LEAN_AND_MEAN
@@ -4478,92 +4842,96 @@
 		}
 		return 1;
 	    }
 
 _ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
+if ac_fn_c_try_run "$LINENO"
+then :
   tcl_cv_seh=yes
-else
+else $as_nop
   tcl_cv_seh=no
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_seh" >&5
-$as_echo "$tcl_cv_seh" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_seh" >&5
+printf "%s\n" "$tcl_cv_seh" >&6; }
 	if test "$tcl_cv_seh" = "no" ; then
 
-$as_echo "#define HAVE_NO_SEH 1" >>confdefs.h
+printf "%s\n" "#define HAVE_NO_SEH 1" >>confdefs.h
 
 	fi
 
 	#
 	# Check to see if the excpt.h include file provided contains the
 	# definition for EXCEPTION_DISPOSITION; if not, which is the case
 	# with Cygwin's version as of 2002-04-10, define it to be int,
 	# sufficient for getting the current code to work.
 	#
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for EXCEPTION_DISPOSITION support in include files" >&5
-$as_echo_n "checking for EXCEPTION_DISPOSITION support in include files... " >&6; }
-if ${tcl_cv_eh_disposition+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for EXCEPTION_DISPOSITION support in include files" >&5
+printf %s "checking for EXCEPTION_DISPOSITION support in include files... " >&6; }
+if test ${tcl_cv_eh_disposition+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 #	    define WIN32_LEAN_AND_MEAN
 #	    include <windows.h>
 #	    undef WIN32_LEAN_AND_MEAN
 
 int
-main ()
+main (void)
 {
 
 		EXCEPTION_DISPOSITION x;
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_eh_disposition=yes
-else
+else $as_nop
   tcl_cv_eh_disposition=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_eh_disposition" >&5
-$as_echo "$tcl_cv_eh_disposition" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_eh_disposition" >&5
+printf "%s\n" "$tcl_cv_eh_disposition" >&6; }
 	if test "$tcl_cv_eh_disposition" = "no" ; then
 
-$as_echo "#define EXCEPTION_DISPOSITION int" >>confdefs.h
+printf "%s\n" "#define EXCEPTION_DISPOSITION int" >>confdefs.h
 
 	fi
 
 	# Check to see if winnt.h defines CHAR, SHORT, and LONG
 	# even if VOID has already been #defined. The win32api
 	# used by mingw and cygwin is known to do this.
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for winnt.h that ignores VOID define" >&5
-$as_echo_n "checking for winnt.h that ignores VOID define... " >&6; }
-if ${tcl_cv_winnt_ignore_void+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for winnt.h that ignores VOID define" >&5
+printf %s "checking for winnt.h that ignores VOID define... " >&6; }
+if test ${tcl_cv_winnt_ignore_void+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 		#define VOID void
 		#define WIN32_LEAN_AND_MEAN
 		#include <windows.h>
 		#undef WIN32_LEAN_AND_MEAN
 
 int
-main ()
+main (void)
 {
 
 		CHAR c;
 		SHORT s;
 		LONG l;
@@ -4570,71 +4938,74 @@
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  tcl_cv_winnt_ignore_void=yes
-else
-  tcl_cv_winnt_ignore_void=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_winnt_ignore_void" >&5
-$as_echo "$tcl_cv_winnt_ignore_void" >&6; }
-	if test "$tcl_cv_winnt_ignore_void" = "yes" ; then
-
-$as_echo "#define HAVE_WINNT_IGNORE_VOID 1" >>confdefs.h
-
-	fi
-
-	ac_fn_c_check_header_mongrel "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default"
-if test "x$ac_cv_header_stdbool_h" = xyes; then :
-
-$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
-
-fi
-
+if ac_fn_c_try_compile "$LINENO"
+then :
+  tcl_cv_winnt_ignore_void=yes
+else $as_nop
+  tcl_cv_winnt_ignore_void=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_winnt_ignore_void" >&5
+printf "%s\n" "$tcl_cv_winnt_ignore_void" >&6; }
+	if test "$tcl_cv_winnt_ignore_void" = "yes" ; then
+
+printf "%s\n" "#define HAVE_WINNT_IGNORE_VOID 1" >>confdefs.h
+
+	fi
+
+	ac_fn_c_check_header_compile "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default"
+if test "x$ac_cv_header_stdbool_h" = xyes
+then :
+
+printf "%s\n" "#define HAVE_STDBOOL_H 1" >>confdefs.h
+
+fi
 
 
 	# See if the compiler supports casting to a union type.
 	# This is used to stop gcc from printing a compiler
 	# warning when initializing a union member.
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cast to union support" >&5
-$as_echo_n "checking for cast to union support... " >&6; }
-if ${tcl_cv_cast_to_union+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for cast to union support" >&5
+printf %s "checking for cast to union support... " >&6; }
+if test ${tcl_cv_cast_to_union+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
 		  union foo { int i; double d; };
 		  union foo f = (union foo) (int) 0;
 
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"
+then :
   tcl_cv_cast_to_union=yes
-else
+else $as_nop
   tcl_cv_cast_to_union=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cast_to_union" >&5
-$as_echo "$tcl_cv_cast_to_union" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cast_to_union" >&5
+printf "%s\n" "$tcl_cv_cast_to_union" >&6; }
 	if test "$tcl_cv_cast_to_union" = "yes"; then
 
-$as_echo "#define HAVE_CAST_TO_UNION 1" >>confdefs.h
+printf "%s\n" "#define HAVE_CAST_TO_UNION 1" >>confdefs.h
 
 	fi
     fi
 
     # DL_LIBS is empty, but then we match the Unix version
@@ -4641,163 +5012,573 @@
 
 
 
 
 
+
+
+ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "
+#include <stdint.h>
+
+"
+if test "x$ac_cv_type_intptr_t" = xyes
+then :
+
+printf "%s\n" "#define HAVE_INTPTR_T 1" >>confdefs.h
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "
+#include <stdint.h>
+
+"
+if test "x$ac_cv_type_uintptr_t" = xyes
+then :
+
+printf "%s\n" "#define HAVE_UINTPTR_T 1" >>confdefs.h
+
+
+fi
+
 
 #--------------------------------------------------------------------
 # man2tcl needs this so that it can use errno.h
 #--------------------------------------------------------------------
 
-ac_fn_c_check_header_mongrel "$LINENO" "errno.h" "ac_cv_header_errno_h" "$ac_includes_default"
-if test "x$ac_cv_header_errno_h" = xyes; then :
+ac_fn_c_check_header_compile "$LINENO" "errno.h" "ac_cv_header_errno_h" "$ac_includes_default"
+if test "x$ac_cv_header_errno_h" = xyes
+then :
 
-else
+else $as_nop
   MAN2TCLFLAGS="-DNO_ERRNO_H"
 fi
-
 
 
 
 #-------------------------------------------
 #     Check for _strtoi64
 #-------------------------------------------
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking availability of _strtoi64" >&5
-$as_echo_n "checking availability of _strtoi64... " >&6; }
-if ${tcl_cv_strtoi64+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking availability of _strtoi64" >&5
+printf %s "checking availability of _strtoi64... " >&6; }
+if test ${tcl_cv_strtoi64+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdlib.h>
 int
-main ()
+main (void)
 {
 _strtoi64(0,0,0)
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"
+then :
   tcl_cv_strtoi64=yes
-else
+else $as_nop
   tcl_cv_strtoi64=no
 fi
-rm -f core conftest.err conftest.$ac_objext \
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_strtoi64" >&5
-$as_echo "$tcl_cv_strtoi64" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_strtoi64" >&5
+printf "%s\n" "$tcl_cv_strtoi64" >&6; }
 if test $tcl_cv_strtoi64 = no; then
 
-$as_echo "#define NO_STRTOI64 1" >>confdefs.h
+printf "%s\n" "#define NO_STRTOI64 1" >>confdefs.h
+
+fi
+
+ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_intptr_t" = xyes
+then :
+
+
+printf "%s\n" "#define HAVE_INTPTR_T 1" >>confdefs.h
+
+else $as_nop
+
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pointer-size signed integer type" >&5
+printf %s "checking for pointer-size signed integer type... " >&6; }
+if test ${tcl_cv_intptr_t+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+    for tcl_cv_intptr_t in "int" "long" "__int64" none; do
+	if test "$tcl_cv_intptr_t" != none; then
+	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main (void)
+{
+static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($tcl_cv_intptr_t))];
+test_array [0] = 0;
+return test_array [0];
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  tcl_ok=yes
+else $as_nop
+  tcl_ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+	    test "$tcl_ok" = yes && break; fi
+    done
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_intptr_t" >&5
+printf "%s\n" "$tcl_cv_intptr_t" >&6; }
+    if test "$tcl_cv_intptr_t" != none; then
+
+printf "%s\n" "#define intptr_t $tcl_cv_intptr_t" >>confdefs.h
+
+    fi
+
+fi
+
+ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_uintptr_t" = xyes
+then :
+
+
+printf "%s\n" "#define HAVE_UINTPTR_T 1" >>confdefs.h
+
+else $as_nop
+
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pointer-size unsigned integer type" >&5
+printf %s "checking for pointer-size unsigned integer type... " >&6; }
+if test ${tcl_cv_uintptr_t+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+    for tcl_cv_uintptr_t in "unsigned int" "unsigned long" "unsigned __int64" \
+	    none; do
+	if test "$tcl_cv_uintptr_t" != none; then
+	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main (void)
+{
+static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($tcl_cv_uintptr_t))];
+test_array [0] = 0;
+return test_array [0];
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  tcl_ok=yes
+else $as_nop
+  tcl_ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+	    test "$tcl_ok" = yes && break; fi
+    done
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_uintptr_t" >&5
+printf "%s\n" "$tcl_cv_uintptr_t" >&6; }
+    if test "$tcl_cv_uintptr_t" != none; then
+
+printf "%s\n" "#define uintptr_t $tcl_cv_uintptr_t" >>confdefs.h
+
+    fi
 
 fi
+
 
 #--------------------------------------------------------------------
 # Windows XP theme engine header for Ttk
 #--------------------------------------------------------------------
 
 ac_fn_c_check_header_compile "$LINENO" "uxtheme.h" "ac_cv_header_uxtheme_h" "#include <windows.h>
 "
-if test "x$ac_cv_header_uxtheme_h" = xyes; then :
-  $as_echo "#define HAVE_UXTHEME_H 1" >>confdefs.h
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: xpnative theme will be unavailable" >&5
-$as_echo "$as_me: xpnative theme will be unavailable" >&6;}
-fi
-
+if test "x$ac_cv_header_uxtheme_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_UXTHEME_H 1" >>confdefs.h
+
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: xpnative theme will be unavailable" >&5
+printf "%s\n" "$as_me: xpnative theme will be unavailable" >&6;}
+fi
 
 ac_fn_c_check_header_compile "$LINENO" "vssym32.h" "ac_cv_header_vssym32_h" "#include <windows.h>
 #include <uxtheme.h>
 "
-if test "x$ac_cv_header_vssym32_h" = xyes; then :
-  $as_echo "#define HAVE_VSSYM32_H 1" >>confdefs.h
+if test "x$ac_cv_header_vssym32_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_VSSYM32_H 1" >>confdefs.h
 
 fi
-
 
 
 #--------------------------------------------------------------------
 # Set the default compiler switches based on the --enable-symbols
 # option.  This macro depends on C flags, and should be called
 # after SC_CONFIG_CFLAGS macro is called.
 #--------------------------------------------------------------------
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for build with symbols" >&5
-$as_echo_n "checking for build with symbols... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for build with symbols" >&5
+printf %s "checking for build with symbols... " >&6; }
     # Check whether --enable-symbols was given.
-if test "${enable_symbols+set}" = set; then :
+if test ${enable_symbols+y}
+then :
   enableval=$enable_symbols; tcl_ok=$enableval
-else
+else $as_nop
   tcl_ok=no
 fi
 
 # FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
     if test "$tcl_ok" = "no"; then
 	CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
 	LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
 
-$as_echo "#define NDEBUG 1" >>confdefs.h
+printf "%s\n" "#define NDEBUG 1" >>confdefs.h
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 
-	$as_echo "#define TCL_CFG_OPTIMIZED 1" >>confdefs.h
+	printf "%s\n" "#define TCL_CFG_OPTIMIZED 1" >>confdefs.h
 
     else
 	CFLAGS_DEFAULT='$(CFLAGS_DEBUG)'
 	LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)'
 	if test "$tcl_ok" = "yes"; then
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (standard debugging)" >&5
-$as_echo "yes (standard debugging)" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes (standard debugging)" >&5
+printf "%s\n" "yes (standard debugging)" >&6; }
 	fi
     fi
 
 
 
     if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
 
-$as_echo "#define TCL_MEM_DEBUG 1" >>confdefs.h
+printf "%s\n" "#define TCL_MEM_DEBUG 1" >>confdefs.h
 
     fi
 
     if test "$tcl_ok" = "compile" -o "$tcl_ok" = "all"; then
 
-$as_echo "#define TCL_COMPILE_DEBUG 1" >>confdefs.h
+printf "%s\n" "#define TCL_COMPILE_DEBUG 1" >>confdefs.h
 
 
-$as_echo "#define TCL_COMPILE_STATS 1" >>confdefs.h
+printf "%s\n" "#define TCL_COMPILE_STATS 1" >>confdefs.h
 
     fi
 
     if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
 	if test "$tcl_ok" = "all"; then
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled symbols mem compile debugging" >&5
-$as_echo "enabled symbols mem compile debugging" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: enabled symbols mem compile debugging" >&5
+printf "%s\n" "enabled symbols mem compile debugging" >&6; }
 	else
-	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled $tcl_ok debugging" >&5
-$as_echo "enabled $tcl_ok debugging" >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: enabled $tcl_ok debugging" >&5
+printf "%s\n" "enabled $tcl_ok debugging" >&6; }
 	fi
     fi
 
 
 #--------------------------------------------------------------------
 # Embed the manifest if we can determine how
 #--------------------------------------------------------------------
 
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+printf %s "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test ${ac_cv_prog_CPP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+      # Double quotes because $CC needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <limits.h>
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"
+then :
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to embed manifest" >&5
-$as_echo_n "checking whether to embed manifest... " >&6; }
+else $as_nop
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"
+then :
+  # Broken: success on invalid input.
+continue
+else $as_nop
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok
+then :
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+printf "%s\n" "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <limits.h>
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"
+then :
+
+else $as_nop
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"
+then :
+  # Broken: success on invalid input.
+continue
+else $as_nop
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok
+then :
+
+else $as_nop
+  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+printf %s "checking for grep that handles long lines and -e... " >&6; }
+if test ${ac_cv_path_GREP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in grep ggrep
+   do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  printf %s 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    printf "%s\n" 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+printf "%s\n" "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+printf %s "checking for egrep... " >&6; }
+if test ${ac_cv_path_EGREP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in egrep
+   do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  printf %s 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    printf "%s\n" 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+printf "%s\n" "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to embed manifest" >&5
+printf %s "checking whether to embed manifest... " >&6; }
     # Check whether --enable-embedded-manifest was given.
-if test "${enable_embedded_manifest+set}" = set; then :
+if test ${enable_embedded_manifest+y}
+then :
   enableval=$enable_embedded_manifest; embed_ok=$enableval
-else
+else $as_nop
   embed_ok=yes
 fi
 
 
     VC_MANIFEST_EMBED_DLL=
@@ -4813,11 +5594,12 @@
 print("manifest needed")
 #endif
 
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "manifest needed" >/dev/null 2>&1; then :
+  $EGREP "manifest needed" >/dev/null 2>&1
+then :
 
 	# Could do a CHECK_PROG for mt, but should always be with MSVC8+
 	# Could add 'if test -f' check, but manifest should be created
 	# in this compiler case
 	# Add in a manifest argument that may be specified
@@ -4829,34 +5611,35 @@
 	if test "xwish.exe.manifest" != x ; then
 	    result="yes (wish.exe.manifest)"
 	fi
 
 fi
-rm -f conftest*
+rm -rf conftest*
 
     fi
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $result" >&5
-$as_echo "$result" >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $result" >&5
+printf "%s\n" "$result" >&6; }
 
 
 
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tclsh in Tcl build directory" >&5
-$as_echo_n "checking for tclsh in Tcl build directory... " >&6; }
-    BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BUILD_TCLSH" >&5
-$as_echo "$BUILD_TCLSH" >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tclsh in Tcl build directory" >&5
+printf %s "checking for tclsh in Tcl build directory... " >&6; }
+    BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}\${EXESUFFIX}
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $BUILD_TCLSH" >&5
+printf "%s\n" "$BUILD_TCLSH" >&6; }
 
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tclsh" >&5
-$as_echo_n "checking for tclsh... " >&6; }
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tclsh" >&5
+printf %s "checking for tclsh... " >&6; }
 
-    if ${ac_cv_path_tclsh+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+    if test ${ac_cv_path_tclsh+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
 	search_path=`echo ${PATH} | sed -e 's/:/ /g'`
 	for dir in $search_path ; do
 	    for j in `ls -r $dir/tclsh[8-9]*.exe 2> /dev/null` \
 		    `ls -r $dir/tclsh* 2> /dev/null` ; do
@@ -4872,18 +5655,187 @@
 fi
 
 
     if test -f "$ac_cv_path_tclsh" ; then
 	TCLSH_PROG="$ac_cv_path_tclsh"
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $TCLSH_PROG" >&5
-$as_echo "$TCLSH_PROG" >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $TCLSH_PROG" >&5
+printf "%s\n" "$TCLSH_PROG" >&6; }
     else
 	# It is not an error if an installed version of Tcl can't be located.
 	TCLSH_PROG=""
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: No tclsh found on PATH" >&5
-$as_echo "No tclsh found on PATH" >&6; }
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: No tclsh found on PATH" >&5
+printf "%s\n" "No tclsh found on PATH" >&6; }
+    fi
+
+
+
+#--------------------------------------------------------------------
+#	Zipfs support - Tip 430
+#--------------------------------------------------------------------
+# Check whether --enable-zipfs was given.
+if test ${enable_zipfs+y}
+then :
+  enableval=$enable_zipfs; tcl_ok=$enableval
+else $as_nop
+  tcl_ok=yes
+fi
+
+if test "$tcl_ok" = "yes" ; then
+    #
+    # Find a native compiler
+    #
+    # Put a plausible default for CC_FOR_BUILD in Makefile.
+if test -z "$CC_FOR_BUILD"; then
+  if test "x$cross_compiling" = "xno"; then
+    CC_FOR_BUILD='$(CC)'
+  else
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gcc" >&5
+printf %s "checking for gcc... " >&6; }
+    if test ${ac_cv_path_cc+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+	search_path=`echo ${PATH} | sed -e 's/:/ /g'`
+	for dir in $search_path ; do
+	    for j in `ls -r $dir/gcc 2> /dev/null` \
+		    `ls -r $dir/gcc 2> /dev/null` ; do
+		if test x"$ac_cv_path_cc" = x ; then
+		    if test -f "$j" ; then
+			ac_cv_path_cc=$j
+			break
+		    fi
+		fi
+	    done
+	done
+
+fi
+
+  fi
+fi
+
+# Also set EXEEXT_FOR_BUILD.
+if test "x$cross_compiling" = "xno"; then
+  EXEEXT_FOR_BUILD='$(EXEEXT)'
+  OBJEXT_FOR_BUILD='$(OBJEXT)'
+else
+  OBJEXT_FOR_BUILD='.no'
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for build system executable suffix" >&5
+printf %s "checking for build system executable suffix... " >&6; }
+if test ${bfd_cv_build_exeext+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  rm -f conftest*
+     echo 'int main () { return 0; }' > conftest.c
+     bfd_cv_build_exeext=
+     ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5
+     for file in conftest.*; do
+       case $file in
+       *.c | *.o | *.obj | *.ilk | *.pdb) ;;
+       *) bfd_cv_build_exeext=`echo $file | sed -e s/conftest//` ;;
+       esac
+     done
+     rm -f conftest*
+     test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_build_exeext" >&5
+printf "%s\n" "$bfd_cv_build_exeext" >&6; }
+  EXEEXT_FOR_BUILD=""
+  test x"${bfd_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${bfd_cv_build_exeext}
+fi
+
+    #
+    # Find a native zip implementation
+    #
+
+    ZIP_PROG=""
+    ZIP_PROG_OPTIONS=""
+    ZIP_PROG_VFSSEARCH=""
+    ZIP_INSTALL_OBJS=""
+
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zip" >&5
+printf %s "checking for zip... " >&6; }
+    if test ${ac_cv_path_zip+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+    search_path=`echo ${PATH} | sed -e 's/:/ /g'`
+    for dir in $search_path ; do
+        for j in `ls -r $dir/zip 2> /dev/null` \
+            `ls -r $dir/zip 2> /dev/null` ; do
+        if test x"$ac_cv_path_zip" = x ; then
+            if test -f "$j" ; then
+            ac_cv_path_zip=$j
+            break
+            fi
+        fi
+        done
+    done
+
+fi
+
+    if test -f "$ac_cv_path_zip" ; then
+        ZIP_PROG="$ac_cv_path_zip"
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ZIP_PROG" >&5
+printf "%s\n" "$ZIP_PROG" >&6; }
+        ZIP_PROG_OPTIONS="-rq"
+        ZIP_PROG_VFSSEARCH="*"
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Found INFO Zip in environment" >&5
+printf "%s\n" "Found INFO Zip in environment" >&6; }
+        # Use standard arguments for zip
+    else
+        # It is not an error if an installed version of Zip can't be located.
+        # We can use the locally distributed minizip instead
+        ZIP_PROG="./minizip${EXEEXT_FOR_BUILD}"
+        ZIP_PROG_OPTIONS="-o -r"
+        ZIP_PROG_VFSSEARCH="*"
+        ZIP_INSTALL_OBJS="minizip${EXEEXT_FOR_BUILD}"
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: No zip found on PATH building minizip" >&5
+printf "%s\n" "No zip found on PATH building minizip" >&6; }
+    fi
+
+
+
+
+
+	ZIPFS_BUILD=1
+	TK_ZIP_FILE=libtk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${TK_PATCH_LEVEL}.zip
+else
+	ZIPFS_BUILD=0
+	TCL_ZIP_FILE=
+fi
+# Do checking message here to not mess up interleaved configure output
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for building with zipfs" >&5
+printf %s "checking for building with zipfs... " >&6; }
+if test "${ZIPFS_BUILD}" = 1; then
+    if test "${SHARED_BUILD}" = 0; then
+       ZIPFS_BUILD=2;
+
+printf "%s\n" "#define ZIPFS_BUILD 2" >>confdefs.h
+
+       INSTALL_LIBRARIES=install-libraries-zipfs-static
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+     else
+
+printf "%s\n" "#define ZIPFS_BUILD 1" >>confdefs.h
+\
+       INSTALL_LIBRARIES=install-libraries-zipfs-shared
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
     fi
+else
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+INSTALL_LIBRARIES=install-libraries
+INSTALL_MSGS=install-msgs
+fi
+
+
+
 
 
 
 #------------------------------------------------------------------------
 # tkConfig.sh refers to this by a different name
@@ -4897,29 +5849,48 @@
 
 TK_SHARED_LIB_SUFFIX="\${NODOT_VERSION}${DLLSUFFIX}"
 TK_UNSHARED_LIB_SUFFIX="\${NODOT_VERSION}${LIBSUFFIX}"
 TK_EXPORT_FILE_SUFFIX="\${NODOT_VERSION}${LIBSUFFIX}"
 
-eval "TK_SRC_DIR=\"`cd $srcdir/..; pwd`\""
+eval "TK_SRC_DIR=\"`cd $srcdir/..; $CYGPATH $(pwd)`\""
 
+eval "TK_DLL_FILE_TCL8=tk$VER${DLLSUFFIX}"
+eval "TK_DLL_FILE_TCL9=tcl9tk$VER${DLLSUFFIX}"
+if test ${TCL_MAJOR_VERSION} = 8 ; then
 eval "TK_DLL_FILE=tk$VER${DLLSUFFIX}"
-eval "TK_LIB_FILE=${LIBPREFIX}tk$VER${LIBSUFFIX}"
+if test ${SHARED_BUILD} = 0 -o "$GCC" != "yes" ; then
+ eval "TK_LIB_FILE=${LIBPREFIX}tk${VER}${LIBSUFFIX}"
+else
+ eval "TK_LIB_FILE=${LIBPREFIX}tk${VER}${DLLSUFFIX}.a"
+fi
+else
+eval "TK_DLL_FILE=tcl9tk$VER${DLLSUFFIX}"
+if test ${SHARED_BUILD} = 0 -o "$GCC" != "yes" ; then
+ eval "TK_LIB_FILE=${LIBPREFIX}tcl9tk${VER}${LIBSUFFIX}"
+else
+ eval "TK_LIB_FILE=${LIBPREFIX}tcl9tk${VER}${DLLSUFFIX}.a"
+fi
+fi
 
 eval "TK_STUB_LIB_FILE=${LIBPREFIX}tkstub${VER}${LIBSUFFIX}"
 # FIXME: All of this var junk needs to be done in tcl.m4 !!!!
 # I left out the other vars that also need to get defined here.
 # we also need to double check about spaces in path names
-eval "TK_LIB_FLAG=\"-ltk${VER}${LIBFLAGSUFFIX}\""
+TK_LIB_FLAG="-l"
+if test "${TCL_MAJOR_VERSION}" -gt 8 ; then
+    TK_LIB_FLAG="${TK_LIB_FLAG}tcl9"
+fi
+eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}${VER}${LIBFLAGSUFFIX}\""
 TK_LIB_SPEC="-L${libdir} ${TK_LIB_FLAG}"
-TK_BUILD_LIB_SPEC="-L`pwd` ${TK_LIB_FLAG}"
+eval "TK_BUILD_LIB_SPEC=\"-L`$CYGPATH $(pwd)` ${TK_LIB_FLAG}\""
 
 eval "TK_STUB_LIB_FLAG=\"-ltkstub${VER}${LIBFLAGSUFFIX}\""
-TK_BUILD_STUB_LIB_SPEC="-L`pwd` ${TK_STUB_LIB_FLAG}"
+eval "TK_BUILD_STUB_LIB_SPEC=\"-L`$CYGPATH $(pwd)` ${TK_STUB_LIB_FLAG}\""
 
 TK_STUB_LIB_SPEC="-L${libdir} ${TK_STUB_LIB_FLAG}"
 TK_STUB_LIB_PATH="${libdir}/${TK_STUB_LIB_FILE}"
-TK_BUILD_STUB_LIB_PATH="`pwd`/${TK_STUB_LIB_FILE}"
+eval "TK_BUILD_STUB_LIB_PATH=\"`$CYGPATH $(pwd)`/${TK_STUB_LIB_FILE}\""
 
 eval "DLLSUFFIX=${DLLSUFFIX}"
 eval "LIBPREFIX=${LIBPREFIX}"
 eval "LIBSUFFIX=${LIBSUFFIX}"
 eval "EXESUFFIX=${EXESUFFIX}"
@@ -4950,10 +5921,12 @@
      *)   TK_RELEASE_LEVEL=2 ;;
 esac
 TK_WIN_VERSION="$TK_VERSION.$TK_RELEASE_LEVEL.`echo $TK_PATCH_LEVEL | tr -d ab.`"
 
 # X86|AMD64|IA64 for manifest
+
+
 
 
 
 
 
@@ -5060,12 +6033,12 @@
   for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
     eval ac_val=\$$ac_var
     case $ac_val in #(
     *${as_nl}*)
       case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
       BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
       *) { eval $ac_var=; unset $ac_var;} ;;
@@ -5091,19 +6064,19 @@
 ) |
   sed '
      /^ac_cv_env_/b end
      t clear
      :clear
-     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/
      t end
      s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
      :end' >>confcache
 if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
   if test -w "$cache_file"; then
     if test "x$cache_file" != "x/dev/null"; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
-$as_echo "$as_me: updating cache $cache_file" >&6;}
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+printf "%s\n" "$as_me: updating cache $cache_file" >&6;}
       if test ! -f "$cache_file" || test -h "$cache_file"; then
 	cat confcache >"$cache_file"
       else
         case $cache_file in #(
         */* | ?:*)
@@ -5113,12 +6086,12 @@
 	  mv -f confcache "$cache_file" ;;
 	esac
       fi
     fi
   else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
-$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;}
   fi
 fi
 rm -f confcache
 
 test "x$prefix" = xNONE && prefix=$ac_default_prefix
@@ -5167,11 +6140,11 @@
 ac_ltlibobjs=
 U=
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
   # 1. Remove the extension, and $U if already installed.
   ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
-  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+  ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"`
   # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
   #    will be set to the directory where LIBOBJS objects are built.
   as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
   as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
 done
@@ -5183,12 +6156,12 @@
 
 : "${CONFIG_STATUS=./config.status}"
 ac_write_fail=0
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
-$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;}
 as_write_fail=0
 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
 #! $SHELL
 # Generated by $as_me.
 # Run this file to recreate the current configuration.
@@ -5207,92 +6180,91 @@
 ## M4sh Initialization. ##
 ## -------------------- ##
 
 # Be more Bourne compatible
 DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+as_nop=:
+if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1
+then :
   emulate sh
   NULLCMD=:
   # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
-else
+else $as_nop
   case `(set -o) 2>/dev/null` in #(
   *posix*) :
     set -o posix ;; #(
   *) :
      ;;
 esac
 fi
 
 
+
+# Reset variables that may have inherited troublesome values from
+# the environment.
+
+# IFS needs to be set, to space, tab, and newline, in precisely that order.
+# (If _AS_PATH_WALK were called with IFS unset, it would have the
+# side effect of setting IFS to empty, thus disabling word splitting.)
+# Quoting is to prevent editors from complaining about space-tab.
 as_nl='
 '
 export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='printf %s\n'
-  as_echo_n='printf %s'
-else
-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
-    as_echo_n='/usr/ucb/echo -n'
-  else
-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-    as_echo_n_body='eval
-      arg=$1;
-      case $arg in #(
-      *"$as_nl"*)
-	expr "X$arg" : "X\\(.*\\)$as_nl";
-	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-      esac;
-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-    '
-    export as_echo_n_body
-    as_echo_n='sh -c $as_echo_n_body as_echo'
-  fi
-  export as_echo_body
-  as_echo='sh -c $as_echo_body as_echo'
-fi
+IFS=" ""	$as_nl"
+
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# Ensure predictable behavior from utilities with locale-dependent output.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# We cannot yet rely on "unset" to work, but we need these variables
+# to be unset--not just set to an empty or harmless value--now, to
+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh).  This construct
+# also avoids known problems related to "unset" and subshell syntax
+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).
+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH
+do eval test \${$as_var+y} \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+
+# Ensure that fds 0, 1, and 2 are open.
+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi
+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi
+if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi
 
 # The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
+if ${PATH_SEPARATOR+false} :; then
   PATH_SEPARATOR=:
   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
       PATH_SEPARATOR=';'
   }
 fi
 
 
-# IFS
-# We need space, tab and new line, in precisely that order.  Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" ""	$as_nl"
-
 # Find who we are.  Look in the path if we contain no directory separator.
 as_myself=
 case $0 in #((
   *[\\/]* ) as_myself=$0 ;;
   *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    test -r "$as_dir$0" && as_myself=$as_dir$0 && break
   done
 IFS=$as_save_IFS
 
      ;;
 esac
@@ -5300,34 +6272,14 @@
 # in which case we are not to be found in the path.
 if test "x$as_myself" = x; then
   as_myself=$0
 fi
 if test ! -f "$as_myself"; then
-  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
   exit 1
 fi
 
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
 
 # as_fn_error STATUS ERROR [LINENO LOG_FD]
 # ----------------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
@@ -5336,15 +6288,16 @@
 as_fn_error ()
 {
   as_status=$1; test $as_status -eq 0 && as_status=1
   if test "$4"; then
     as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
   fi
-  $as_echo "$as_me: error: $2" >&2
+  printf "%s\n" "$as_me: error: $2" >&2
   as_fn_exit $as_status
 } # as_fn_error
+
 
 
 # as_fn_set_status STATUS
 # -----------------------
 # Set $? to STATUS, without forking.
@@ -5369,22 +6322,24 @@
 as_fn_unset ()
 {
   { eval $1=; unset $1;}
 }
 as_unset=as_fn_unset
+
 # as_fn_append VAR VALUE
 # ----------------------
 # Append the text in VALUE to the end of the definition contained in VAR. Take
 # advantage of any shell optimizations that allow amortized linear growth over
 # repeated appends, instead of the typical quadratic growth present in naive
 # implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null
+then :
   eval 'as_fn_append ()
   {
     eval $1+=\$2
   }'
-else
+else $as_nop
   as_fn_append ()
   {
     eval $1=\$$1\$2
   }
 fi # as_fn_append
@@ -5392,16 +6347,17 @@
 # as_fn_arith ARG...
 # ------------------
 # Perform arithmetic evaluation on the ARGs, and store the result in the
 # global $as_val. Take advantage of shells that can avoid forks. The arguments
 # must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null
+then :
   eval 'as_fn_arith ()
   {
     as_val=$(( $* ))
   }'
-else
+else $as_nop
   as_fn_arith ()
   {
     as_val=`expr "$@" || test $? -eq 1`
   }
 fi # as_fn_arith
@@ -5428,11 +6384,11 @@
 
 as_me=`$as_basename -- "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
 	 X"$0" : 'X\(//\)$' \| \
 	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
+printf "%s\n" X/"$0" |
     sed '/^.*\/\([^/][^/]*\)\/*$/{
 	    s//\1/
 	    q
 	  }
 	  /^X\/\(\/\/\)$/{
@@ -5450,10 +6406,14 @@
 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
 as_cr_digits='0123456789'
 as_cr_alnum=$as_cr_Letters$as_cr_digits
 
+
+# Determine whether it's possible to make 'echo' print without a newline.
+# These variables are no longer used directly by Autoconf, but are AC_SUBSTed
+# for compatibility with existing Makefiles.
 ECHO_C= ECHO_N= ECHO_T=
 case `echo -n x` in #(((((
 -n*)
   case `echo 'xy\c'` in
   *c*) ECHO_T='	';;	# ECHO_T is single tab character.
@@ -5462,10 +6422,16 @@
        ECHO_T='	';;
   esac;;
 *)
   ECHO_N='-n';;
 esac
+
+# For backward compatibility with old third-party macros, we provide
+# the shell variables $as_echo and $as_echo_n.  New code should use
+# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively.
+as_echo='printf %s\n'
+as_echo_n='printf %s'
 
 rm -f conf$$ conf$$.exe conf$$.file
 if test -d conf$$.dir; then
   rm -f conf$$.dir/conf$$.file
 else
@@ -5504,20 +6470,20 @@
   esac
   test -d "$as_dir" || eval $as_mkdir_p || {
     as_dirs=
     while :; do
       case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
       *) as_qdir=$as_dir;;
       esac
       as_dirs="'$as_qdir' $as_dirs"
       as_dir=`$as_dirname -- "$as_dir" ||
 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$as_dir" : 'X\(//\)[^/]' \| \
 	 X"$as_dir" : 'X\(//\)$' \| \
 	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
+printf "%s\n" X"$as_dir" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
 	    s//\1/
 	    q
 	  }
 	  /^X\(\/\/\)[^/].*/{
@@ -5575,12 +6541,12 @@
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # Save the log message, to keep $0 and so on meaningful, and to
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by $as_me, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+This file was extended by tk $as_me 8.7, which was
+generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
   CONFIG_LINKS    = $CONFIG_LINKS
   CONFIG_COMMANDS = $CONFIG_COMMANDS
@@ -5625,18 +6591,20 @@
 $config_files
 
 Report bugs to the package provider."
 
 _ACEOF
+ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"`
+ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"`
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
-config.status
-configured by $0, generated by GNU Autoconf 2.69,
+tk config.status 8.7
+configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 2021 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
 ac_pwd='$ac_pwd'
 srcdir='$srcdir'
@@ -5669,25 +6637,25 @@
   case $ac_option in
   # Handling of the options.
   -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
     ac_cs_recheck=: ;;
   --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
-    $as_echo "$ac_cs_version"; exit ;;
+    printf "%s\n" "$ac_cs_version"; exit ;;
   --config | --confi | --conf | --con | --co | --c )
-    $as_echo "$ac_cs_config"; exit ;;
+    printf "%s\n" "$ac_cs_config"; exit ;;
   --debug | --debu | --deb | --de | --d | -d )
     debug=: ;;
   --file | --fil | --fi | --f )
     $ac_shift
     case $ac_optarg in
-    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
     '') as_fn_error $? "missing file argument" ;;
     esac
     as_fn_append CONFIG_FILES " '$ac_optarg'"
     ac_need_defaults=false;;
   --he | --h |  --help | --hel | -h )
-    $as_echo "$ac_cs_usage"; exit ;;
+    printf "%s\n" "$ac_cs_usage"; exit ;;
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
   | -silent | --silent | --silen | --sile | --sil | --si | --s)
     ac_cs_silent=: ;;
 
   # This is an error.
@@ -5711,11 +6679,11 @@
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 if \$ac_cs_recheck; then
   set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
   shift
-  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+  \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6
   CONFIG_SHELL='$SHELL'
   export CONFIG_SHELL
   exec "\$@"
 fi
 
@@ -5725,11 +6693,11 @@
 {
   echo
   sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
 ## Running $as_me. ##
 _ASBOX
-  $as_echo "$ac_log"
+  printf "%s\n" "$ac_log"
 } >&5
 
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 _ACEOF
@@ -5752,11 +6720,11 @@
 # If the user did not use the arguments to specify the items to instantiate,
 # then the envvar interface is used.  Set only those that are not.
 # We use the long form for the default assignment because of an extremely
 # bizarre bug on SunOS 4.1.3.
 if $ac_need_defaults; then
-  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files
 fi
 
 # Have a temporary directory for convenience.  Make it in the build tree
 # simply because there is no reason against having it here, and in addition,
 # creating and moving files from /tmp can sometimes cause problems.
@@ -5980,29 +6948,29 @@
 	   [\\/$]*) false;;
 	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
 	   esac ||
 	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
       esac
-      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
       as_fn_append ac_file_inputs " '$ac_f'"
     done
 
     # Let's still pretend it is `configure' which instantiates (i.e., don't
     # use $as_me), people would be surprised to read:
     #    /* config.h.  Generated by config.status.  */
     configure_input='Generated from '`
-	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+	  printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
 	`' by configure.'
     if test x"$ac_file" != x-; then
       configure_input="$ac_file.  $configure_input"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
-$as_echo "$as_me: creating $ac_file" >&6;}
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+printf "%s\n" "$as_me: creating $ac_file" >&6;}
     fi
     # Neutralize special characters interpreted by sed in replacement strings.
     case $configure_input in #(
     *\&* | *\|* | *\\* )
-       ac_sed_conf_input=`$as_echo "$configure_input" |
+       ac_sed_conf_input=`printf "%s\n" "$configure_input" |
        sed 's/[\\\\&|]/\\\\&/g'`;; #(
     *) ac_sed_conf_input=$configure_input;;
     esac
 
     case $ac_tag in
@@ -6015,11 +6983,11 @@
   ac_dir=`$as_dirname -- "$ac_file" ||
 $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$ac_file" : 'X\(//\)[^/]' \| \
 	 X"$ac_file" : 'X\(//\)$' \| \
 	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$ac_file" |
+printf "%s\n" X"$ac_file" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
 	    s//\1/
 	    q
 	  }
 	  /^X\(\/\/\)[^/].*/{
@@ -6039,13 +7007,13 @@
   ac_builddir=.
 
 case "$ac_dir" in
 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
 *)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'`
   # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
   case $ac_top_builddir_sub in
   "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
   *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
   esac ;;
 esac
@@ -6094,12 +7062,12 @@
 /@localedir@/p
 /@mandir@/p'
 case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
 *datarootdir*) ac_datarootdir_seen=yes;;
 *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
-$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
   ac_datarootdir_hack='
   s&@datadir@&$datadir&g
   s&@docdir@&$docdir&g
@@ -6137,13 +7105,13 @@
 
 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
   { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
   { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
       "$ac_tmp/out"`; test -z "$ac_out"; } &&
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
 which seems to be undefined.  Please make sure it is defined" >&5
-$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
 which seems to be undefined.  Please make sure it is defined" >&2;}
 
   rm -f "$ac_tmp/stdin"
   case $ac_file in
   -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
@@ -6186,10 +7154,11 @@
   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
   # would make configure fail if this is the last instruction.
   $ac_cs_success || as_fn_exit 1
 fi
 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
-$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
 fi
+
 
 

Index: win/configure.ac
==================================================================
--- win/configure.ac
+++ win/configure.ac
@@ -1,22 +1,23 @@
 #! /bin/bash -norc
 # This file is an input file used by the GNU "autoconf" program to
 # generate the file "configure", which is run during Tk installation
 # to configure the system for the local environment.
 
-AC_INIT(../generic/tk.h)
-AC_PREREQ(2.69)
+AC_INIT([tk],[8.7])
+AC_CONFIG_SRCDIR([../generic/tk.h])
+AC_PREREQ([2.69])
 
 # The following define is needed when building with Cygwin since newer
 # versions of autoconf incorrectly set SHELL to /bin/bash instead of
 # /bin/sh. The bash shell seems to suffer from some strange failures.
 SHELL=/bin/sh
 
 TK_VERSION=8.7
 TK_MAJOR_VERSION=8
 TK_MINOR_VERSION=7
-TK_PATCH_LEVEL="a4"
+TK_PATCH_LEVEL="a6"
 VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION
 
 #------------------------------------------------------------------------
 # Handle the --prefix=... option
 #------------------------------------------------------------------------
@@ -40,11 +41,11 @@
     CFLAGS=""
 fi
 
 AC_PROG_CC
 AC_C_INLINE
-AC_HEADER_STDC
+AC_CHECK_INCLUDES_DEFAULT
 
 AC_CHECK_TOOL(AR, ar)
 AC_CHECK_TOOL(RANLIB, ranlib)
 AC_CHECK_TOOL(RC, windres)
 
@@ -93,10 +94,14 @@
 # macro depends on the value of SHARED_BUILD, and should be called
 # after SC_ENABLE_SHARED checks the configure switches.
 #--------------------------------------------------------------------
 
 SC_CONFIG_CFLAGS
+
+AC_CHECK_TYPES([intptr_t, uintptr_t],,,[[
+#include <stdint.h>
+]])
 
 #--------------------------------------------------------------------
 # man2tcl needs this so that it can use errno.h
 #--------------------------------------------------------------------
 
@@ -106,16 +111,47 @@
 #-------------------------------------------
 #     Check for _strtoi64
 #-------------------------------------------
 
 AC_CACHE_CHECK([availability of _strtoi64], tcl_cv_strtoi64, [
-    AC_TRY_LINK([#include <stdlib.h>],
-	    [_strtoi64(0,0,0)],
-	    tcl_cv_strtoi64=yes, tcl_cv_strtoi64=no)])
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
+    [[_strtoi64(0,0,0)]])],[tcl_cv_strtoi64=yes],[tcl_cv_strtoi64=no])])
 if test $tcl_cv_strtoi64 = no; then
     AC_DEFINE(NO_STRTOI64, 1, [Is _strtoi64 function available?])
 fi
+
+AC_CHECK_TYPE([intptr_t], [
+    AC_DEFINE([HAVE_INTPTR_T], 1, [Do we have the intptr_t type?])], [
+    AC_CACHE_CHECK([for pointer-size signed integer type], tcl_cv_intptr_t, [
+    for tcl_cv_intptr_t in "int" "long" "__int64" none; do
+	if test "$tcl_cv_intptr_t" != none; then
+	    AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT],
+		    [[sizeof (void *) <= sizeof ($tcl_cv_intptr_t)]])],
+		[tcl_ok=yes], [tcl_ok=no])
+	    test "$tcl_ok" = yes && break; fi
+    done])
+    if test "$tcl_cv_intptr_t" != none; then
+	AC_DEFINE_UNQUOTED([intptr_t], [$tcl_cv_intptr_t], [Signed integer
+	   type wide enough to hold a pointer.])
+    fi
+])
+AC_CHECK_TYPE([uintptr_t], [
+    AC_DEFINE([HAVE_UINTPTR_T], 1, [Do we have the uintptr_t type?])], [
+    AC_CACHE_CHECK([for pointer-size unsigned integer type], tcl_cv_uintptr_t, [
+    for tcl_cv_uintptr_t in "unsigned int" "unsigned long" "unsigned __int64" \
+	    none; do
+	if test "$tcl_cv_uintptr_t" != none; then
+	    AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT],
+		    [[sizeof (void *) <= sizeof ($tcl_cv_uintptr_t)]])],
+		[tcl_ok=yes], [tcl_ok=no])
+	    test "$tcl_ok" = yes && break; fi
+    done])
+    if test "$tcl_cv_uintptr_t" != none; then
+	AC_DEFINE_UNQUOTED([uintptr_t], [$tcl_cv_uintptr_t], [Unsigned integer
+	   type wide enough to hold a pointer.])
+    fi
+])
 
 #--------------------------------------------------------------------
 # Windows XP theme engine header for Ttk
 #--------------------------------------------------------------------
 
@@ -140,10 +176,56 @@
 
 SC_EMBED_MANIFEST(wish.exe.manifest)
 
 SC_BUILD_TCLSH
 SC_PROG_TCLSH
+
+#--------------------------------------------------------------------
+#	Zipfs support - Tip 430
+#--------------------------------------------------------------------
+AC_ARG_ENABLE(zipfs,
+    AS_HELP_STRING([--enable-zipfs],
+	[build with Zipfs support (default: on)]),
+    [tcl_ok=$enableval], [tcl_ok=yes])
+if test "$tcl_ok" = "yes" ; then
+    #
+    # Find a native compiler
+    #
+    AX_CC_FOR_BUILD
+    #
+    # Find a native zip implementation
+    #
+    SC_ZIPFS_SUPPORT
+	ZIPFS_BUILD=1
+	TK_ZIP_FILE=libtk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${TK_PATCH_LEVEL}.zip
+else
+	ZIPFS_BUILD=0
+	TCL_ZIP_FILE=
+fi
+# Do checking message here to not mess up interleaved configure output
+AC_MSG_CHECKING([for building with zipfs])
+if test "${ZIPFS_BUILD}" = 1; then
+    if test "${SHARED_BUILD}" = 0; then
+       ZIPFS_BUILD=2;
+       AC_DEFINE(ZIPFS_BUILD, 2, [Are we building with zipfs enabled?])
+       INSTALL_LIBRARIES=install-libraries-zipfs-static
+       AC_MSG_RESULT([yes])
+     else
+       AC_DEFINE(ZIPFS_BUILD, 1, [Are we building with zipfs enabled?])\
+       INSTALL_LIBRARIES=install-libraries-zipfs-shared
+       AC_MSG_RESULT([yes])
+    fi
+else
+AC_MSG_RESULT([no])
+INSTALL_LIBRARIES=install-libraries
+INSTALL_MSGS=install-msgs
+fi
+AC_SUBST(ZIPFS_BUILD)
+AC_SUBST(TK_ZIP_FILE)
+AC_SUBST(INSTALL_LIBRARIES)
+AC_SUBST(INSTALL_MSGS)
+
 
 #------------------------------------------------------------------------
 # tkConfig.sh refers to this by a different name
 #------------------------------------------------------------------------
 
@@ -155,29 +237,48 @@
 
 TK_SHARED_LIB_SUFFIX="\${NODOT_VERSION}${DLLSUFFIX}"
 TK_UNSHARED_LIB_SUFFIX="\${NODOT_VERSION}${LIBSUFFIX}"
 TK_EXPORT_FILE_SUFFIX="\${NODOT_VERSION}${LIBSUFFIX}"
 
-eval "TK_SRC_DIR=\"`cd $srcdir/..; pwd`\""
+eval "TK_SRC_DIR=\"`cd $srcdir/..; $CYGPATH $(pwd)`\""
 
+eval "TK_DLL_FILE_TCL8=tk$VER${DLLSUFFIX}"
+eval "TK_DLL_FILE_TCL9=tcl9tk$VER${DLLSUFFIX}"
+if test ${TCL_MAJOR_VERSION} = 8 ; then
 eval "TK_DLL_FILE=tk$VER${DLLSUFFIX}"
-eval "TK_LIB_FILE=${LIBPREFIX}tk$VER${LIBSUFFIX}"
+if test ${SHARED_BUILD} = 0 -o "$GCC" != "yes" ; then
+ eval "TK_LIB_FILE=${LIBPREFIX}tk${VER}${LIBSUFFIX}"
+else
+ eval "TK_LIB_FILE=${LIBPREFIX}tk${VER}${DLLSUFFIX}.a"
+fi
+else
+eval "TK_DLL_FILE=tcl9tk$VER${DLLSUFFIX}"
+if test ${SHARED_BUILD} = 0 -o "$GCC" != "yes" ; then
+ eval "TK_LIB_FILE=${LIBPREFIX}tcl9tk${VER}${LIBSUFFIX}"
+else
+ eval "TK_LIB_FILE=${LIBPREFIX}tcl9tk${VER}${DLLSUFFIX}.a"
+fi
+fi
 
 eval "TK_STUB_LIB_FILE=${LIBPREFIX}tkstub${VER}${LIBSUFFIX}"
 # FIXME: All of this var junk needs to be done in tcl.m4 !!!!
 # I left out the other vars that also need to get defined here.
 # we also need to double check about spaces in path names
-eval "TK_LIB_FLAG=\"-ltk${VER}${LIBFLAGSUFFIX}\""
+TK_LIB_FLAG="-l"
+if test "${TCL_MAJOR_VERSION}" -gt 8 ; then
+    TK_LIB_FLAG="${TK_LIB_FLAG}tcl9"
+fi
+eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}${VER}${LIBFLAGSUFFIX}\""
 TK_LIB_SPEC="-L${libdir} ${TK_LIB_FLAG}"
-TK_BUILD_LIB_SPEC="-L`pwd` ${TK_LIB_FLAG}"
+eval "TK_BUILD_LIB_SPEC=\"-L`$CYGPATH $(pwd)` ${TK_LIB_FLAG}\""
 
 eval "TK_STUB_LIB_FLAG=\"-ltkstub${VER}${LIBFLAGSUFFIX}\""
-TK_BUILD_STUB_LIB_SPEC="-L`pwd` ${TK_STUB_LIB_FLAG}"
+eval "TK_BUILD_STUB_LIB_SPEC=\"-L`$CYGPATH $(pwd)` ${TK_STUB_LIB_FLAG}\""
 
 TK_STUB_LIB_SPEC="-L${libdir} ${TK_STUB_LIB_FLAG}"
 TK_STUB_LIB_PATH="${libdir}/${TK_STUB_LIB_FILE}"
-TK_BUILD_STUB_LIB_PATH="`pwd`/${TK_STUB_LIB_FILE}"
+eval "TK_BUILD_STUB_LIB_PATH=\"`$CYGPATH $(pwd)`/${TK_STUB_LIB_FILE}\""
 
 eval "DLLSUFFIX=${DLLSUFFIX}"
 eval "LIBPREFIX=${LIBPREFIX}"
 eval "LIBSUFFIX=${LIBSUFFIX}"
 eval "EXESUFFIX=${EXESUFFIX}"
@@ -216,10 +317,12 @@
 AC_SUBST(TK_MAJOR_VERSION)
 AC_SUBST(TK_MINOR_VERSION)
 AC_SUBST(TK_PATCH_LEVEL)
 AC_SUBST(TK_LIB_FILE)
 AC_SUBST(TK_DLL_FILE)
+AC_SUBST(TK_DLL_FILE_TCL8)
+AC_SUBST(TK_DLL_FILE_TCL9)
 AC_SUBST(TK_STUB_LIB_FILE)
 AC_SUBST(TK_STUB_LIB_FLAG)
 AC_SUBST(TK_BUILD_STUB_LIB_SPEC)
 AC_SUBST(TK_SRC_DIR)
 AC_SUBST(TK_BIN_DIR)
@@ -289,10 +392,11 @@
 AC_SUBST(RC_INCLUDE)
 AC_SUBST(RC_DEFINE)
 AC_SUBST(RC_DEFINES)
 AC_SUBST(RES)
 
-AC_OUTPUT(Makefile tkConfig.sh wish.exe.manifest)
+AC_CONFIG_FILES([Makefile tkConfig.sh wish.exe.manifest])
+AC_OUTPUT
 
 dnl Local Variables:
-dnl mode: autoconf;
+dnl mode: autoconf
 dnl End:

ADDED   win/gitmanifest.in
Index: win/gitmanifest.in
==================================================================
--- /dev/null
+++ win/gitmanifest.in
@@ -0,0 +1,1 @@
+git-

Index: win/makefile.vc
==================================================================
--- win/makefile.vc
+++ win/makefile.vc
@@ -18,10 +18,13 @@
 #   nmake [-nologo] -f makefile.vc [TARGET|MACRODEF [TARGET|MACRODEF] [...]]
 #
 # For MACRODEF, see TIP 477 (https://core.tcl-lang.org/tips/doc/trunk/tip/477.md)
 # or examine Sections 6-8 in rules.vc. This makefile has the following
 # values for the OPTS macro in addition to the ones described there.
+#       noembed  = Embeds Tcl scripts into the wish executable. Currently only
+#                  applicable for static builds. Non-static builds currently
+#                  never embed.
 #	noxp     = If you do not have the uxtheme.h header then you
 #                  cannot include support for XP themeing.
 #	square   = Include the demo square widget.
 #
 # Possible values for TARGET are:
@@ -87,10 +90,16 @@
 USE_WIDECHAR_API  = 0
 
 # The rules.vc file does much of the hard work in terms of defining
 # the build configuration, macros, output directories etc.
 !include "rules-ext.vc"
+
+!if ($(TCL_MAJOR_VERSION) > 8) || ($(TCL_MAJOR_VERSION) == 8 && $(TCL_MINOR_VERSION) > 6)
+USING_PRE87_TCL = 0
+!else
+USING_PRE87_TCL = 1
+!endif
 
 # TCLINSTALL is set to 1 by rules.vc to indicate we are building against
 # an installed Tcl and 0 if building against Tcl source. Tk needs the latter.
 !if $(TCLINSTALL)
 !message *** Warning: Tk requires the source distribution of Tcl to build from,
@@ -100,10 +109,11 @@
 
 # Extra makefile options processing for non-standard OPTS values ...
 !if "$(OPTS)" == "" || [nmakehlp -f "$(OPTS)" "none"]
 HAVE_UXTHEME_H    = 1
 TTK_SQUARE_WIDGET = 0
+TK_EMBED_SCRIPTS  = $(STATIC_BUILD)
 !else
 !if [nmakehlp -f $(OPTS) "noxp"]
 !message *** Exclude support for XP theme
 HAVE_UXTHEME_H  = 0
 !else
@@ -113,10 +123,21 @@
 !message *** Include ttk square demo widget
 TTK_SQUARE_WIDGET   = 1
 !else
 TTK_SQUARE_WIDGET   = 0
 !endif
+!if [nmakehlp -f $(OPTS) "noembed"]
+!message *** Option noembed specified. Tk script library will not be appended to the binary.
+TK_EMBED_SCRIPTS = 0
+!else
+!message *** Tk script library will be appended to the binary.
+TK_EMBED_SCRIPTS = $(STATIC_BUILD)
+!endif
+!endif
+
+!if $(USING_PRE87_TCL)
+TK_EMBED_SCRIPTS = 0
 !endif
 
 TK_NO_DEPRECATED = 0
 !if "$(CHECKS)" != "" && ![nmakehlp -f "$(CHECKS)" "none"]
 !if [nmakehlp -f $(CHECKS) "nodep"]
@@ -129,11 +150,11 @@
 TKTEST		= "$(OUT_DIR)\$(PROJECT)test.exe"
 CAT32		= "$(OUT_DIR)\cat32.exe"
 
 WISHOBJS = \
 	$(TMP_DIR)\winMain.obj \
-!if $(TCL_USE_STATIC_PACKAGES)
+!if $(STATIC_BUILD) && !$(STATIC_BUILD)
 	$(TCLDDELIB) \
 	$(TCLREGLIB) \
 !endif
 	$(TMP_DIR)\wish.res
 
@@ -165,10 +186,12 @@
 	$(TMP_DIR)\tkWinCursor.obj \
 	$(TMP_DIR)\tkWinDialog.obj \
 	$(TMP_DIR)\tkWinDraw.obj \
 	$(TMP_DIR)\tkWinEmbed.obj \
 	$(TMP_DIR)\tkWinFont.obj \
+	$(TMP_DIR)\tkWinGDI.obj \
+	$(TMP_DIR)\tkWinIco.obj \
 	$(TMP_DIR)\tkWinImage.obj \
 	$(TMP_DIR)\tkWinInit.obj \
 	$(TMP_DIR)\tkWinKey.obj \
 	$(TMP_DIR)\tkWinMenu.obj \
 	$(TMP_DIR)\tkWinPixmap.obj \
@@ -175,10 +198,11 @@
 	$(TMP_DIR)\tkWinPointer.obj \
 	$(TMP_DIR)\tkWinRegion.obj \
 	$(TMP_DIR)\tkWinScrlbr.obj \
 	$(TMP_DIR)\tkWinSend.obj \
 	$(TMP_DIR)\tkWinSendCom.obj \
+	$(TMP_DIR)\tkWinSysTray.obj \
 	$(TMP_DIR)\tkWinWindow.obj \
 	$(TMP_DIR)\tkWinWm.obj \
 	$(TMP_DIR)\tkWinX.obj \
 	$(TMP_DIR)\stubs.obj \
 	$(TMP_DIR)\tk3d.obj \
@@ -213,10 +237,11 @@
 	$(TMP_DIR)\tkGC.obj \
 	$(TMP_DIR)\tkGeometry.obj \
 	$(TMP_DIR)\tkGet.obj \
 	$(TMP_DIR)\tkGrab.obj \
 	$(TMP_DIR)\tkGrid.obj \
+	$(TMP_DIR)\tkIcu.obj \
 	$(TMP_DIR)\tkImage.obj \
 	$(TMP_DIR)\tkImgBmap.obj \
 	$(TMP_DIR)\tkImgListFormat.obj \
 	$(TMP_DIR)\tkImgGIF.obj \
 	$(TMP_DIR)\tkImgPNG.obj \
@@ -307,19 +332,24 @@
 ### The following paths CANNOT have spaces in them as they appear on
 ### the left side of implicit rules.
 XLIBDIR		= $(ROOT)\xlib
 TTKDIR		= $(ROOT)\generic\ttk
 BITMAPDIR	= $(ROOT)\bitmaps
+
+# Directories where to build TIP430 ZIP files
+# One for Tk - always built, contains Tk scripts
+# One for Wish - for static builds, contains Tcl+Tk scripts
+LIBTKVFS = $(OUT_DIR)\libtk.vfs
+WISHSCRIPTZIP = $(OUT_DIR)\wish.zip
 
 # Additional include and C macro definitions for the implicit rules
 # defined in rules.vc
 PRJ_INCLUDES	= -I"$(BITMAPDIR)" -I"$(XLIBDIR)"
 
-CONFIG_DEFS     =/DSTDC_HEADERS=1 /DHAVE_SYS_TYPES_H=1 /DHAVE_SYS_STAT_H=1 \
+CONFIG_DEFS     =/DHAVE_SYS_TYPES_H=1 /DHAVE_SYS_STAT_H=1 \
 		 /DHAVE_STRING_H=1 /DHAVE_MEMORY_H=1 \
-		 /DHAVE_STRINGS_H=1 \
-		 /DSUPPORT_CONFIG_EMBEDDED \
+		 /DHAVE_STRINGS_H=1 /DTCL_UTF_MAX=3 \
 !if $(HAVE_UXTHEME_H)
 		 /DHAVE_UXTHEME_H=1 \
 !endif
 !if $(TTK_SQUARE_WIDGET)
 		 /DTTK_SQUARE_WIDGET=1 \
@@ -329,12 +359,11 @@
 !endif
 
 PRJ_DEFINES	= /DBUILD_ttk $(CONFIG_DEFS) /Dinline=__inline /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE
 
 # Additional Link libraries needed beyond those in rules.vc
-PRJ_LIBS   = netapi32.lib gdi32.lib user32.lib userenv.lib
-
+PRJ_LIBS   = netapi32.lib gdi32.lib user32.lib userenv.lib winspool.lib shell32.lib ole32.lib uuid.lib
 
 #---------------------------------------------------------------------
 # TkTest flags
 #---------------------------------------------------------------------
 
@@ -345,13 +374,33 @@
 #---------------------------------------------------------------------
 # Project specific targets
 #---------------------------------------------------------------------
 
 release:  setup $(TKSTUBLIB) $(WISH)
+!if !$(USING_PRE87_TCL)
+release:  libtkzip embed
+!endif
 all:	  release $(CAT32)
 core:	  setup $(TKSTUBLIB) $(TKLIB)
 cwish:	  $(WISHC)
+libtkzip: setup $(TKSCRIPTZIP)
+!if $(TK_EMBED_SCRIPTS)
+!if $(STATIC_BUILD)
+embed:    setup $(WISH) $(WISHSCRIPTZIP)
+	@copy /y /b "$(WISH)"+"$(WISHSCRIPTZIP)" "$(WISH)"
+!else
+# Note this is currently dead code as TK_EMBED_SCRIPTS is always 0
+# for non-static builds as the C code does not currently setup up
+# a VFS for a non-static wish.
+embed:    setup $(TKLIB) $(TKSCRIPTZIP)
+	@copy /y /b "$(TKLIB)"+"$(TKSCRIPTZIP)" "$(TKLIB)"
+!endif
+!else
+# ! TK_EMBED_SCRIPTS - still need to build the zip even if not embedded
+embed: $(TKSCRIPTZIP)
+!endif
+
 install:  install-binaries install-libraries install-docs
 !if $(SYMBOLS)
 install:    install-pdbs
 !endif
 tktest:	  setup $(TKTEST) $(CAT32)
@@ -464,14 +513,38 @@
 
 $(TKTEST): $(TKTESTOBJS) $(TKSTUBLIB) $(TKIMPLIB)
 	$(GUIEXECMD) -stack:2300000 $**
 	$(_VC_MANIFEST_EMBED_EXE)
 
+TKSCRIPTZIPTOP = tk_library
+#TKSCRIPTZIPTOP = "tk$(DOTVERSION)"
+$(TKSCRIPTZIP): .PHONY
+	@echo Building Tk library zip file
+	@if not exist "$(LIBTKVFS)" $(MKDIR) "$(LIBTKVFS)"
+	@if exist "$(LIBTKVFS)\$(TKSCRIPTZIPTOP)" $(RMDIR) "$(LIBTKVFS)\$(TKSCRIPTZIPTOP)"
+	@$(CPYDIR) $(LIBDIR) "$(LIBTKVFS)\$(TKSCRIPTZIPTOP)"
+	@cd "$(OUT_DIR)" && $(TCLSH) <<
+file delete -force {$@}
+zipfs mkzip {$@} {$(LIBTKVFS)} {$(LIBTKVFS)}
+<<
+
+!if $(STATIC_BUILD)
+$(WISHSCRIPTZIP): $(TKSCRIPTZIP)
+	@echo Building Wish Tcl+Tk library zip file
+	@if exist "$(LIBTKVFS)\tcl_library" $(RMDIR) "$(LIBTKVFS)\tcl_library"
+	@cd "$(OUT_DIR)" && $(TCLSH) <<
+file delete -force {$@}
+zipfs mount mnt "$(TCLSCRIPTZIP:\=/)"
+file copy [file join [zipfs root] mnt tcl_library] "$(LIBTKVFS:\=/)"
+zipfs mkzip {$@} {$(LIBTKVFS)} {$(LIBTKVFS)}
+<<
+!endif
+
 
 $(CAT32): $(_TCLDIR)\win\cat.c
 	$(cc32) $(cflags) $(crt) /D_CRT_NONSTDC_NO_DEPRECATE /DCONSOLE /DUNICODE /D_UNICODE -Fo$(TMP_DIR)\ $?
-	$(CONEXECMD) /DCONSOLE -stack:16384 $(TMP_DIR)\cat.obj
+	$(CONEXECMD) -stack:16384 $(TMP_DIR)\cat.obj
 	$(_VC_MANIFEST_EMBED_EXE)
 
 #---------------------------------------------------------------------
 # Regenerate the stubs files.  [Development use only]
 #---------------------------------------------------------------------
@@ -481,10 +554,11 @@
 	@echo Build tclsh first!
 !else
 	set TCL_LIBRARY=$(TCL_LIBRARY)
 	$(TCLSH) $(_TCLDIR)\tools\genStubs.tcl $(GENERICDIR) \
 		$(GENERICDIR)\$(PROJECT).decls $(GENERICDIR)\$(PROJECT)Int.decls
+	$(TCLSH) $(_TCLDIR)\tools\genStubs.tcl $(GENERICDIR)\ttk $(GENERICDIR)\ttk\ttk.decls
 !endif
 
 
 #---------------------------------------------------------------------
 # Build the Windows HTML help file.
@@ -541,15 +615,23 @@
 
 #---------------------------------------------------------------------
 # Special case object file targets
 #---------------------------------------------------------------------
 
+# Note: Static builds now always mandate statically linking Tcl registry etc.
 $(TMP_DIR)\testMain.obj: $(WIN_DIR)\winMain.c
 	$(cc32) $(appcflags_nostubs) /DTK_TEST /DUNICODE /D_UNICODE \
-	    /DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
+	    /DTCL_USE_STATIC_PACKAGES=$(STATIC_BUILD) \
 	    -Fo$@ $?
 
+$(ROOT)\manifest.uuid:
+   copy $(WIN_DIR)\gitmanifest.in $(ROOT)\manifest.uuid
+   git rev-parse HEAD >>$(ROOT)\manifest.uuid
+
+$(TMP_DIR)\tkUuid.h:	$(ROOT)\manifest.uuid
+	copy $(WIN_DIR)\tkUuid.h.in+$(ROOT)\manifest.uuid $(TMP_DIR)\tkUuid.h
+
 $(TMP_DIR)\tkTest.obj: $(GENERICDIR)\tkTest.c
 	$(cc32) $(appcflags_nostubs) -Fo$@ $?
 
 $(TMP_DIR)\tkOldTest.obj: $(GENERICDIR)\tkOldTest.c
 	$(cc32) $(appcflags_nostubs) -Fo$@ $?
@@ -558,17 +640,26 @@
 	$(cc32) $(appcflags_nostubs) -Fo$@ $?
 
 $(TMP_DIR)\tkSquare.obj: $(GENERICDIR)\tkSquare.c
 	$(cc32) $(appcflags_nostubs) -Fo$@ $?
 
+# Note: Static builds now always mandate statically linking Tcl registry etc.
 $(TMP_DIR)\winMain.obj: $(WIN_DIR)\winMain.c
 	$(cc32) $(appcflags_nostubs) /DUNICODE /D_UNICODE \
-	    /DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
+	    /DTCL_USE_STATIC_PACKAGES=$(STATIC_BUILD) \
 	    -Fo$@ $?
 
 $(TMP_DIR)\tkMain2.obj: $(GENERICDIR)\tkMain.c
 	$(cc32) $(pkgcflags) /DUNICODE /D_UNICODE -Fo$@ $?
+
+$(TMP_DIR)\tkPkgConfig.obj: $(GENERICDIR)\tkPkgConfig.c
+	$(cc32) $(pkgcflags) 		\
+		-DCFG_RUNTIME_DLLFILE="\"$(TKLIBNAME)\"" \
+		-Fo$@ $?
+
+$(TMP_DIR)\tkWindow.obj: $(GENERICDIR)\tkWindow.c $(TMP_DIR)\tkUuid.h
+	$(cc32) $(pkgcflags) -I$(TMP_DIR) -Fo$@ $?
 
 # The following objects are part of the stub library and should not
 # be built as DLL objects but none of the symbols should be exported
 # and no reference made to a C runtime.
 
@@ -663,17 +754,26 @@
 	@$(CPY) "$(TKIMPLIB)" "$(LIB_INSTALL_DIR)\"
 	@$(CPY) "$(TKSTUBLIB)" "$(LIB_INSTALL_DIR)\"
 !if !$(STATIC_BUILD)
 	@echo creating package index
 	@type << > $(OUT_DIR)\pkgIndex.tcl
-if {[catch {package present Tcl 8.6-}]} { return }
+if {![package vsatisfies [package provide Tcl] 8.6-]} return
 if {($$::tcl_platform(platform) eq "unix") && ([info exists ::env(DISPLAY)]
 	|| ([info exists ::argv] && ("-display" in $$::argv)))} {
-    package ifneeded Tk $(TK_PATCH_LEVEL) [list load [file join $$dir .. .. bin libtk$(DOTVERSION).dll] Tk]
+    if {[package vsatisfies [package provide Tcl] 9.0]} {
+	package ifneeded tk $(TK_PATCH_LEVEL) [list load [file normalize [file join $$dir .. .. bin libtcl9tk$(DOTVERSION).dll]]]
+    } else {
+	package ifneeded tk $(TK_PATCH_LEVEL) [list load [file normalize [file join $$dir .. .. bin libtk$(DOTVERSION).dll]]]
+    }
 } else {
-    package ifneeded Tk $(TK_PATCH_LEVEL) [list load [file join $$dir .. .. bin $(TKLIBNAME)] Tk]
+    if {[package vsatisfies [package provide Tcl] 9.0]} {
+	package ifneeded tk $(TK_PATCH_LEVEL) [list load [file normalize [file join $$dir .. .. bin $(TKLIBNAME9)]]]
+    } else {
+	package ifneeded tk $(TK_PATCH_LEVEL) [list load [file normalize [file join $$dir .. .. bin $(TKLIBNAME8)]]]
+    }
 }
+package ifneeded Tk $(TK_PATCH_LEVEL) [list package require -exact tk $(TK_PATCH_LEVEL)]
 <<
 	@$(CPY) $(OUT_DIR)\pkgIndex.tcl "$(SCRIPT_INSTALL_DIR)\"
 !endif
 
 #"
@@ -683,18 +783,23 @@
 	@$(CPY) "$(GENERICDIR)\tk.h" "$(INCLUDE_INSTALL_DIR)\"
 	@$(CPY) "$(GENERICDIR)\tkDecls.h" "$(INCLUDE_INSTALL_DIR)\"
 	@$(CPY) "$(GENERICDIR)\tkPlatDecls.h" "$(INCLUDE_INSTALL_DIR)\"
 	@$(CPY) "$(GENERICDIR)\tkIntXlibDecls.h" "$(INCLUDE_INSTALL_DIR)\"
 	@$(CPY) "$(XLIBDIR)\X11\*.h" "$(INCLUDE_INSTALL_DIR)\X11\"
+!if !$(USING_PRE87_TCL)
+	@$(CPY) "$(TKSCRIPTZIP)" "$(LIB_INSTALL_DIR)"
+!endif
+!if !$(TK_EMBED_SCRIPTS)
 	@echo installing script library
 	@$(CPY) "$(LIBDIR)\*" "$(SCRIPT_INSTALL_DIR)\"
 	@echo installing theme library
 	@$(CPY) "$(LIBDIR)\ttk\*" "$(SCRIPT_INSTALL_DIR)\ttk\"
 	@echo installing images
 	@$(CPY) "$(LIBDIR)\images\*" "$(SCRIPT_INSTALL_DIR)\images\"
 	@echo installing language files
 	@$(CPY) "$(LIBDIR)\msgs\*" "$(SCRIPT_INSTALL_DIR)\msgs\"
+!endif
 	@echo installing demos
 	@$(CPY) "$(DEMODIR)\*" "$(DEMO_INSTALL_DIR)\"
 	@$(CPY) "$(DEMODIR)\images\*" "$(DEMO_INSTALL_DIR)\images\"
 
 #"
@@ -718,5 +823,10 @@
 	@echo Removing $(TKTEST) ...
 	@if exist $(TKTEST) del $(TKTEST)
 	@echo Removing $(TKSTUBLIB) ...
 	@if exist $(TKSTUBLIB) del $(TKSTUBLIB)
 
+.PHONY:
+
+# Local Variables:
+# mode: makefile
+# End:

Index: win/nmakehlp.c
==================================================================
--- win/nmakehlp.c
+++ win/nmakehlp.c
@@ -2,27 +2,24 @@
  * ----------------------------------------------------------------------------
  * nmakehlp.c --
  *
  *	This is used to fix limitations within nmake and the environment.
  *
- * Copyright (c) 2002 by David Gravereaux.
- * Copyright (c) 2006 by Pat Thoyts
+ * Copyright (c) 2002 David Gravereaux.
+ * Copyright (c) 2006 Pat Thoyts
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  * ----------------------------------------------------------------------------
  */
 
 #define _CRT_SECURE_NO_DEPRECATE
 #include <windows.h>
-#define NO_SHLWAPI_GDI
-#define NO_SHLWAPI_STREAM
-#define NO_SHLWAPI_REG
-#include <shlwapi.h>
+#ifdef _MSC_VER
 #pragma comment (lib, "user32.lib")
 #pragma comment (lib, "kernel32.lib")
-#pragma comment (lib, "shlwapi.lib")
+#endif
 #include <stdio.h>
 #include <math.h>
 
 /*
  * This library is required for x64 builds with _some_ versions of MSVC
@@ -40,11 +37,11 @@
 
 
 /* protos */
 
 static int CheckForCompilerFeature(const char *option);
-static int CheckForLinkerFeature(const char **options, int count);
+static int CheckForLinkerFeature(char **options, int count);
 static int IsIn(const char *string, const char *substring);
 static int SubstituteFile(const char *substs, const char *filename);
 static int QualifyPath(const char *path);
 static int LocateDependency(const char *keyfile);
 static const char *GetVersionFromFile(const char *filename, const char *match, int numdots);
@@ -57,12 +54,12 @@
 typedef struct {
     HANDLE pipe;
     char buffer[STATICBUFFERSIZE];
 } pipeinfo;
 
-pipeinfo Out = {INVALID_HANDLE_VALUE, '\0'};
-pipeinfo Err = {INVALID_HANDLE_VALUE, '\0'};
+pipeinfo Out = {INVALID_HANDLE_VALUE, ""};
+pipeinfo Err = {INVALID_HANDLE_VALUE, ""};
 
 /*
  * exitcodes: 0 == no, 1 == yes, 2 == error
  */
 
@@ -72,11 +69,11 @@
     char *argv[])
 {
     char msg[300];
     DWORD dwWritten;
     int chars;
-    char *s;
+    const char *s;
 
     /*
      * Make sure children (cl.exe and link.exe) are kept quiet.
      */
 
@@ -276,11 +273,11 @@
 	DWORD err = GetLastError();
 	int chars = snprintf(msg, sizeof(msg) - 1,
 		"Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
 
 	FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
-		FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID)&msg[chars],
+		FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPSTR)&msg[chars],
 		(300-chars), 0);
 	WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, lstrlen(msg), &err,NULL);
 	return 2;
     }
 
@@ -329,11 +326,11 @@
              || strstr(Err.buffer, "D2021") != NULL);
 }
 
 static int
 CheckForLinkerFeature(
-    const char **options,
+    char **options,
     int count)
 {
     STARTUPINFO si;
     PROCESS_INFORMATION pi;
     SECURITY_ATTRIBUTES sa;
@@ -410,11 +407,11 @@
 	DWORD err = GetLastError();
 	int chars = snprintf(msg, sizeof(msg) - 1,
 		"Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
 
 	FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
-		FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID)&msg[chars],
+		FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPSTR)&msg[chars],
 		(300-chars), 0);
 	WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, lstrlen(msg), &err,NULL);
 	return 2;
     }
 
@@ -506,47 +503,45 @@
 GetVersionFromFile(
     const char *filename,
     const char *match,
     int numdots)
 {
-    size_t cbBuffer = 100;
     static char szBuffer[100];
     char *szResult = NULL;
     FILE *fp = fopen(filename, "rt");
 
     if (fp != NULL) {
 	/*
 	 * Read data until we see our match string.
 	 */
 
-	while (fgets(szBuffer, cbBuffer, fp) != NULL) {
+	while (fgets(szBuffer, sizeof(szBuffer), fp) != NULL) {
 	    LPSTR p, q;
 
 	    p = strstr(szBuffer, match);
 	    if (p != NULL) {
 		/*
 		 * Skip to first digit after the match.
 		 */
 
 		p += strlen(match);
-		while (*p && !isdigit(*p)) {
+		while (*p && !isdigit((unsigned char)*p)) {
 		    ++p;
 		}
 
 		/*
 		 * Find ending whitespace.
 		 */
 
 		q = p;
-		while (*q && (strchr("0123456789.ab", *q)) && ((!strchr(".ab", *q)
-			    && (!strchr("ab", q[-1])) || --numdots))) {
+		while (*q && (strchr("0123456789.ab", *q)) && (((!strchr(".ab", *q)
+			    && !strchr("ab", q[-1])) || --numdots))) {
 		    ++q;
 		}
 
-		memcpy(szBuffer, p, q - p);
-		szBuffer[q-p] = 0;
-		szResult = szBuffer;
+		*q = 0;
+		szResult = p;
 		break;
 	    }
 	}
 	fclose(fp);
     }
@@ -565,11 +560,11 @@
 
 /* insert a list item into the list (list may be null) */
 static list_item_t *
 list_insert(list_item_t **listPtrPtr, const char *key, const char *value)
 {
-    list_item_t *itemPtr = malloc(sizeof(list_item_t));
+    list_item_t *itemPtr = (list_item_t *)malloc(sizeof(list_item_t));
     if (itemPtr) {
 	itemPtr->key = strdup(key);
 	itemPtr->value = strdup(value);
 	itemPtr->nextPtr = NULL;
 
@@ -614,13 +609,11 @@
 static int
 SubstituteFile(
     const char *substitutions,
     const char *filename)
 {
-    size_t cbBuffer = 1024;
     static char szBuffer[1024], szCopy[1024];
-    char *szResult = NULL;
     list_item_t *substPtr = NULL;
     FILE *fp, *sp;
 
     fp = fopen(filename, "rt");
     if (fp != NULL) {
@@ -629,11 +622,11 @@
 	 * Build a list of substutitions from the first filename
 	 */
 
 	sp = fopen(substitutions, "rt");
 	if (sp != NULL) {
-	    while (fgets(szBuffer, cbBuffer, sp) != NULL) {
+	    while (fgets(szBuffer, sizeof(szBuffer), sp) != NULL) {
 		unsigned char *ks, *ke, *vs, *ve;
 		ks = (unsigned char*)szBuffer;
 		while (ks && *ks && isspace(*ks)) ++ks;
 		ke = ks;
 		while (ke && *ke && !isspace(*ke)) ++ke;
@@ -646,11 +639,11 @@
 	    }
 	    fclose(sp);
 	}
 
 	/* debug: dump the list */
-#ifdef _DEBUG
+#ifndef NDEBUG
 	{
 	    int n = 0;
 	    list_item_t *p = NULL;
 	    for (p = substPtr; p != NULL; p = p->nextPtr, ++n) {
 		fprintf(stderr, "% 3d '%s' => '%s'\n", n, p->key, p->value);
@@ -660,11 +653,11 @@
 
 	/*
 	 * Run the substitutions over each line of the input
 	 */
 
-	while (fgets(szBuffer, cbBuffer, fp) != NULL) {
+	while (fgets(szBuffer, sizeof(szBuffer), fp) != NULL) {
 	    list_item_t *p = NULL;
 	    for (p = substPtr; p != NULL; p = p->nextPtr) {
 		char *m = strstr(szBuffer, p->key);
 		if (m) {
 		    char *cp, *op, *sp;
@@ -677,19 +670,30 @@
 		    while (*op) *cp++ = *op++;
 		    *cp = 0;
 		    memcpy(szBuffer, szCopy, sizeof(szCopy));
 		}
 	    }
-	    printf(szBuffer);
+	    printf("%s", szBuffer);
 	}
 
 	list_free(&substPtr);
     }
     fclose(fp);
     return 0;
 }
 
+BOOL FileExists(LPCTSTR szPath)
+{
+#ifndef INVALID_FILE_ATTRIBUTES
+    #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
+#endif
+    DWORD pathAttr = GetFileAttributes(szPath);
+    return (pathAttr != INVALID_FILE_ATTRIBUTES &&
+	    !(pathAttr & FILE_ATTRIBUTE_DIRECTORY));
+}
+
+
 /*
  * QualifyPath --
  *
  *	This composes the current working directory with a provided path
  *	and returns the fully qualified and normalized path.
@@ -699,17 +703,12 @@
 static int
 QualifyPath(
     const char *szPath)
 {
     char szCwd[MAX_PATH + 1];
-    char szTmp[MAX_PATH + 1];
-    char *p;
-    GetCurrentDirectory(MAX_PATH, szCwd);
-    while ((p = strchr(szPath, '/')) && *p)
-	*p = '\\';
-    PathCombine(szTmp, szCwd, szPath);
-    PathCanonicalize(szCwd, szTmp);
+
+    GetFullPathName(szPath, sizeof(szCwd)-1, szCwd, NULL);
     printf("%s\n", szCwd);
     return 0;
 }
 
 /*
@@ -722,11 +721,12 @@
  */
 static int LocateDependencyHelper(const char *dir, const char *keypath)
 {
     HANDLE hSearch;
     char path[MAX_PATH+1];
-    int dirlen, keylen, ret;
+    size_t dirlen;
+    int keylen, ret;
     WIN32_FIND_DATA finfo;
 
     if (dir == NULL || keypath == NULL)
 	return 2; /* Have no real error reporting mechanism into nmake */
     dirlen = strlen(dir);
@@ -763,11 +763,11 @@
 	if ((dirlen+1+sublen+1+keylen+1) > sizeof(path))
 	    continue;		/* Path does not fit, assume not matched */
 	strncpy(path+dirlen+1, finfo.cFileName, sublen);
 	path[dirlen+1+sublen] = '\\';
 	strncpy(path+dirlen+1+sublen+1, keypath, keylen+1);
-	if (PathFileExists(path)) {
+	if (FileExists(path)) {
 	    /* Found a match, print to stdout */
 	    path[dirlen+1+sublen] = '\0';
 	    QualifyPath(path);
 	    ret = 0;
 	    break;
@@ -789,12 +789,13 @@
  *         name_DIRPATH=<full path of located directory>
  *      and returns 0. If not found, does not print anything and returns 1.
  */
 static int LocateDependency(const char *keypath)
 {
-    int i, ret;
-    static char *paths[] = {"..", "..\\..", "..\\..\\.."};
+    size_t i;
+    int ret;
+    static const char *paths[] = {"..", "..\\..", "..\\..\\.."};
 
     for (i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i) {
 	ret = LocateDependencyHelper(paths[i], keypath);
 	if (ret == 0)
 	    return ret;

Index: win/rc/tk.rc
==================================================================
--- win/rc/tk.rc
+++ win/rc/tk.rc
@@ -36,11 +36,11 @@
         BEGIN
             VALUE "FileDescription", "Tk DLL\0"
             VALUE "OriginalFilename", "tk" STRINGIFY(TK_MAJOR_VERSION) STRINGIFY(TK_MINOR_VERSION) SUFFIX ".dll\0"
             VALUE "CompanyName", "ActiveState Corporation\0"
             VALUE "FileVersion", TK_PATCH_LEVEL
-            VALUE "LegalCopyright", "Copyright \251 2001 by ActiveState Corporation, et al\0"
+            VALUE "LegalCopyright", "Copyright \251 2001 ActiveState Corporation, et al\0"
             VALUE "ProductName", "Tk " TK_VERSION " for Windows\0"
             VALUE "ProductVersion", TK_PATCH_LEVEL
         END
     END
     BLOCK "VarFileInfo"

Index: win/rc/wish.rc
==================================================================
--- win/rc/wish.rc
+++ win/rc/wish.rc
@@ -42,11 +42,11 @@
         BEGIN
             VALUE "FileDescription", "Wish Application\0"
             VALUE "OriginalFilename", "wish" STRINGIFY(TK_MAJOR_VERSION) STRINGIFY(TK_MINOR_VERSION) SUFFIX ".exe\0"
             VALUE "CompanyName", "ActiveState Corporation\0"
             VALUE "FileVersion", TK_PATCH_LEVEL
-            VALUE "LegalCopyright", "Copyright \251 2000 by ActiveState Corporation, et al\0"
+            VALUE "LegalCopyright", "Copyright \251 2000 ActiveState Corporation, et al\0"
             VALUE "ProductName", "Tk " TK_VERSION " for Windows\0"
             VALUE "ProductVersion", TK_PATCH_LEVEL
         END
     END
     BLOCK "VarFileInfo"

Index: win/rules-ext.vc
==================================================================
--- win/rules-ext.vc
+++ win/rules-ext.vc
@@ -29,11 +29,16 @@
 !endif
 
 # We extract version numbers using the nmakehlp program. For now use
 # the local copy of nmakehlp. Once we locate Tcl, we will use that
 # one if it is newer.
-!if [$(CC) -nologo "nmakehlp.c" -link -subsystem:console > nul]
+!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
+!if [$(CC) -nologo -DNDEBUG "nmakehlp.c" -link -subsystem:console > nul]
+!endif
+!else
+!if [copy x86_64-w64-mingw32-nmakehlp.exe nmakehlp.exe >NUL]
+!endif
 !endif
 
 # First locate the Tcl directory that we are working with.
 !if "$(TCLDIR)" != ""
 

Index: win/rules.vc
==================================================================
--- win/rules.vc
+++ win/rules.vc
@@ -4,11 +4,11 @@
 # Part of the nmake based build system for Tcl and its extensions.
 # This file does all the hard work in terms of parsing build options,
 # compiler switches, defining common targets and macros. The Tcl makefile
 # directly includes this. Extensions include it via "rules-ext.vc".
 #
-# See TIP 477 (https://core.tcl-lang.org/tips/doc/trunk/tip/477.md) for
+# See TIP 477 (https://core.tcl-lang.org/tips/doc/main/tip/477.md) for
 # detailed documentation.
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 #
@@ -22,11 +22,11 @@
 
 # The following macros define the version of the rules.vc nmake build system
 # For modifications that are not backward-compatible, you *must* change
 # the major version.
 RULES_VERSION_MAJOR = 1
-RULES_VERSION_MINOR = 6
+RULES_VERSION_MINOR = 10
 
 # The PROJECT macro must be defined by parent makefile.
 !if "$(PROJECT)" == ""
 !error *** Error: Macro PROJECT not defined! Please define it before including rules.vc
 !endif
@@ -409,12 +409,12 @@
 #     This is also printed by the compiler in dotted form 19.10 etc.
 # VCVER - the "marketing version", for example Visual C++ 6 for internal
 #     compiler version 1200. This is kept only for legacy reasons as it
 #     does not make sense for recent Microsoft compilers. Only used for
 #     output directory names.
-# ARCH - set to IX86 or AMD64 depending on 32- or 64-bit target
-# NATIVE_ARCH - set to IX86 or AMD64 for the host machine
+# ARCH - set to IX86, ARM64 or AMD64 depending on 32- or 64-bit target
+# NATIVE_ARCH - set to IX86, ARM64 or AMD64 for the host machine
 # MACHINE - same as $(ARCH) - legacy
 # _VC_MANIFEST_EMBED_{DLL,EXE} - commands for embedding a manifest if needed
 
 cc32		= $(CC)   # built-in default.
 link32		= link
@@ -433,10 +433,12 @@
 !if ![echo VCVERSION=_MSC_VER > vercl.x] \
     && ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \
     && ![echo ARCH=IX86 >> vercl.x] \
     && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \
     && ![echo ARCH=AMD64 >> vercl.x] \
+    && ![echo $(_HASH)elif defined(_M_ARM64) >> vercl.x] \
+    && ![echo ARCH=ARM64 >> vercl.x] \
     && ![echo $(_HASH)endif >> vercl.x] \
     && ![$(cc32) -nologo -TC -P vercl.x 2>NUL]
 !include vercl.i
 !if $(VCVERSION) < 1900
 !if ![echo VCVER= ^\> vercl.vc] \
@@ -457,10 +459,13 @@
 # The MACHINE macro is used by legacy makefiles so set it as well
 !ifdef MACHINE
 !if "$(MACHINE)" == "x86"
 !undef MACHINE
 MACHINE = IX86
+!elseif "$(MACHINE)" == "arm64"
+!undef MACHINE
+MACHINE = ARM64
 !elseif "$(MACHINE)" == "x64"
 !undef MACHINE
 MACHINE = AMD64
 !endif
 !if "$(MACHINE)" != "$(ARCH)"
@@ -473,10 +478,12 @@
 #---------------------------------------------------------------
 # The PLATFORM_IDENTIFY macro matches the values returned by
 # the Tcl platform::identify command
 !if "$(MACHINE)" == "AMD64"
 PLATFORM_IDENTIFY = win32-x86_64
+!elseif "$(MACHINE)" == "ARM64"
+PLATFORM_IDENTIFY = win32-arm
 !else
 PLATFORM_IDENTIFY = win32-ix86
 !endif
 
 # The MULTIPLATFORM macro controls whether binary extensions are installed
@@ -488,10 +495,12 @@
 #------------------------------------------------------------
 # Figure out the *host* architecture by reading the registry
 
 !if ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i x86]
 NATIVE_ARCH=IX86
+!elseif ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i ARM | findstr /i 64-bit]
+NATIVE_ARCH=ARM64
 !else
 NATIVE_ARCH=AMD64
 !endif
 
 # Since MSVC8 we must deal with manifest resources.
@@ -539,12 +548,17 @@
 
 !endif # NMAKEHLPC
 
 # We always build nmakehlp even if it exists since we do not know
 # what source it was built from.
+!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
 !if [$(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console > nul]
 !endif
+!else
+!if [copy $(NMAKEHLPC:nmakehlp.c=x86_64-w64-mingw32-nmakehlp.exe) nmakehlp.exe >NUL]
+!endif
+!endif
 
 ################################################################
 # 5. Test for compiler features
 # Visual C++ compiler options have changed over the years. Check
 # which options are supported by the compiler in use.
@@ -650,12 +664,134 @@
 !if [nmakehlp -l -ltcg $(LINKER_TESTFLAGS)]
 LINKERFLAGS     = $(LINKERFLAGS) -ltcg
 !endif
 !endif
 
+
+################################################################
+# 6. Extract various version numbers from headers
+# For Tcl and Tk, version numbers are extracted from tcl.h and tk.h
+# respectively. For extensions, versions are extracted from the
+# configure.in or configure.ac from the TEA configuration if it
+# exists, and unset otherwise.
+# Sets the following macros:
+# TCL_MAJOR_VERSION
+# TCL_MINOR_VERSION
+# TCL_RELEASE_SERIAL
+# TCL_PATCH_LEVEL
+# TCL_PATCH_LETTER
+# TCL_VERSION
+# TK_MAJOR_VERSION
+# TK_MINOR_VERSION
+# TK_RELEASE_SERIAL
+# TK_PATCH_LEVEL
+# TK_PATCH_LETTER
+# TK_VERSION
+# DOTVERSION - set as (for example) 2.5
+# VERSION - set as (for example 25)
+#--------------------------------------------------------------
+
+!if [echo REM = This file is generated from rules.vc > versions.vc]
+!endif
+!if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
+   && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc]
+!endif
+!if [echo TCL_MINOR_VERSION = \>> versions.vc] \
+   && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc]
+!endif
+!if [echo TCL_RELEASE_SERIAL = \>> versions.vc] \
+   && [nmakehlp -V "$(_TCL_H)" TCL_RELEASE_SERIAL >> versions.vc]
+!endif
+!if [echo TCL_PATCH_LEVEL = \>> versions.vc] \
+   && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc]
+!endif
+
+!if defined(_TK_H)
+!if [echo TK_MAJOR_VERSION = \>> versions.vc] \
+   && [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc]
+!endif
+!if [echo TK_MINOR_VERSION = \>> versions.vc] \
+   && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc]
+!endif
+!if [echo TK_RELEASE_SERIAL = \>> versions.vc] \
+   && [nmakehlp -V "$(_TK_H)" TK_RELEASE_SERIAL >> versions.vc]
+!endif
+!if [echo TK_PATCH_LEVEL = \>> versions.vc] \
+   && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
+!endif
+!endif # _TK_H
+
+!include versions.vc
+
+TCL_VERSION	= $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
+TCL_DOTVERSION	= $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
+!if [nmakehlp -f $(TCL_PATCH_LEVEL) "a"]
+TCL_PATCH_LETTER = a
+!elseif [nmakehlp -f $(TCL_PATCH_LEVEL) "b"]
+TCL_PATCH_LETTER = b
+!else
+TCL_PATCH_LETTER = .
+!endif
+
+!if defined(_TK_H)
+
+TK_VERSION	= $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
+TK_DOTVERSION	= $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
+!if [nmakehlp -f $(TK_PATCH_LEVEL) "a"]
+TK_PATCH_LETTER = a
+!elseif [nmakehlp -f $(TK_PATCH_LEVEL) "b"]
+TK_PATCH_LETTER = b
+!else
+TK_PATCH_LETTER = .
+!endif
+
+!endif
+
+# Set DOTVERSION and VERSION
+!if $(DOING_TCL)
+
+DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
+VERSION = $(TCL_VERSION)
+
+!elseif $(DOING_TK)
+
+DOTVERSION = $(TK_DOTVERSION)
+VERSION = $(TK_VERSION)
+
+!else # Doing a non-Tk extension
+
+# If parent makefile has not defined DOTVERSION, try to get it from TEA
+# first from a configure.in file, and then from configure.ac
+!ifndef DOTVERSION
+!if [echo DOTVERSION = \> versions.vc] \
+   || [nmakehlp -V $(ROOT)\configure.in ^[$(PROJECT)^] >> versions.vc]
+!if [echo DOTVERSION = \> versions.vc] \
+   || [nmakehlp -V $(ROOT)\configure.ac ^[$(PROJECT)^] >> versions.vc]
+!error *** Could not figure out extension version. Please define DOTVERSION in parent makefile before including rules.vc.
+!endif
+!endif
+!include versions.vc
+!endif # DOTVERSION
+VERSION         = $(DOTVERSION:.=)
+
+!endif # $(DOING_TCL) ... etc.
+
+# Windows RC files have 3 version components. Ensure this irrespective
+# of how many components the package has specified. Basically, ensure
+# minimum 4 components by appending 4 0's and then pick out the first 4.
+# Also take care of the fact that DOTVERSION may have "a" or "b" instead
+# of "." separating the version components.
+DOTSEPARATED=$(DOTVERSION:a=.)
+DOTSEPARATED=$(DOTSEPARATED:b=.)
+!if [echo RCCOMMAVERSION = \> versions.vc] \
+  || [for /f "tokens=1,2,3,4,5* delims=." %a in ("$(DOTSEPARATED).0.0.0.0") do echo %a,%b,%c,%d >> versions.vc]
+!error *** Could not generate RCCOMMAVERSION ***
+!endif
+!include versions.vc
+
 ########################################################################
-# 6. Parse the OPTS macro to work out the requested build configuration.
+# 7. Parse the OPTS macro to work out the requested build configuration.
 # Based on this, we will construct the actual switches to be passed to the
 # compiler and linker using the macros defined in the previous section.
 # The following macros are defined by this section based on OPTS
 # STATIC_BUILD - 0 -> Tcl is to be built as a shared library
 #                1 -> build as a static library and shell
@@ -665,24 +801,24 @@
 # PROFILE - 1 -> generate profiling info, 0 -> no profiling
 # PGO     - 1 -> profile based optimization, 0 -> no
 # MSVCRT  - 1 -> link to dynamic C runtime even when building static Tcl build
 #           0 -> link to static C runtime for static Tcl build.
 #           Does not impact shared Tcl builds (STATIC_BUILD == 0)
+#           Default: 1 for Tcl 8.7 and up, 0 otherwise.
 # TCL_USE_STATIC_PACKAGES - 1 -> statically link the registry and dde extensions
-#           in the Tcl shell. 0 -> keep them as shared libraries
-#           Does not impact shared Tcl builds.
+#           in the Tcl and Wish shell. 0 -> keep them as shared libraries. Does
+#           not impact shared Tcl builds. Implied by STATIC_BUILD since Tcl 8.7.
 # USE_THREAD_ALLOC - 1 -> Use a shared global free pool for allocation.
 #           0 -> Use the non-thread allocator.
 # UNCHECKED - 1 -> when doing a debug build with symbols, use the release
 #           C runtime, 0 -> use the debug C runtime.
 # USE_STUBS - 1 -> compile to use stubs interfaces, 0 -> direct linking
 # CONFIG_CHECK - 1 -> check current build configuration against Tcl
 #           configuration (ignored for Tcl itself)
 # _USE_64BIT_TIME_T - forces a build using 64-bit time_t for 32-bit build
 #           (CRT library should support this, not needed for Tcl 9.x)
-# TCL_UTF_MAX=4 - forces a build allowing 4-byte UTF-8 sequences internally.
-#           (Not needed for Tcl 9.x)
+# TCL_UTF_MAX=3 - forces a build using UTF-16 internally (not recommended).
 # Further, LINKERFLAGS are modified based on above.
 
 # Default values for all the above
 STATIC_BUILD	= 0
 TCL_THREADS	= 1
@@ -722,11 +858,11 @@
 MSVCRT		= 0
 !else
 !if [nmakehlp -f $(OPTS) "msvcrt"]
 !message *** Doing msvcrt
 !else
-!if $(STATIC_BUILD)
+!if $(TCL_MAJOR_VERSION) == 8 && $(TCL_MINOR_VERSION) < 7 && $(STATIC_BUILD)
 MSVCRT		= 0
 !endif
 !endif
 !endif # [nmakehlp -f $(OPTS) "nomsvcrt"]
 
@@ -739,19 +875,19 @@
 !message *** Compile explicitly for non-threaded tcl
 TCL_THREADS = 0
 USE_THREAD_ALLOC= 0
 !endif
 
-!if "$(TCL_MAJOR_VERSION)" == "8"
+!if $(TCL_MAJOR_VERSION) == 8
 !if [nmakehlp -f $(OPTS) "time64bit"]
 !message *** Force 64-bit time_t
 _USE_64BIT_TIME_T = 1
 !endif
 
-!if [nmakehlp -f $(OPTS) "utfmax"]
-!message *** Force allowing 4-byte UTF-8 sequences internally
-TCL_UTF_MAX = 4
+!if [nmakehlp -f $(OPTS) "utf16"]
+!message *** Force UTF-16 internally
+TCL_UTF_MAX = 3
 !endif
 !endif
 
 # Yes, it's weird that the "symbols" option controls DEBUG and
 # the "pdbs" option controls SYMBOLS. That's historical.
@@ -834,11 +970,11 @@
 !error $(MSG)
 !endif
 !endif
 
 ################################################################
-# 7. Parse the STATS macro to configure code instrumentation
+# 8. Parse the STATS macro to configure code instrumentation
 # The following macros are set by this section:
 # TCL_MEM_DEBUG - 1 -> enables memory allocation instrumentation
 #                 0 -> disables
 # TCL_COMPILE_DEBUG - 1 -> enables byte compiler logging
 #                     0 -> disables
@@ -864,11 +1000,11 @@
 !endif
 
 !endif
 
 ####################################################################
-# 8. Parse the CHECKS macro to configure additional compiler checks
+# 9. Parse the CHECKS macro to configure additional compiler checks
 # The following macros are set by this section:
 # WARNINGS - compiler switches that control the warnings level
 # TCL_NO_DEPRECATED - 1 -> disable support for deprecated functions
 #                     0 -> enable deprecated functions
 
@@ -896,103 +1032,10 @@
 WARNINGS		    = $(WARNINGS) -Wp64
 !endif
 
 !endif
 
-################################################################
-# 9. Extract various version numbers
-# For Tcl and Tk, version numbers are extracted from tcl.h and tk.h
-# respectively. For extensions, versions are extracted from the
-# configure.in or configure.ac from the TEA configuration if it
-# exists, and unset otherwise.
-# Sets the following macros:
-# TCL_MAJOR_VERSION
-# TCL_MINOR_VERSION
-# TCL_PATCH_LEVEL
-# TCL_VERSION
-# TK_MAJOR_VERSION
-# TK_MINOR_VERSION
-# TK_PATCH_LEVEL
-# TK_VERSION
-# DOTVERSION - set as (for example) 2.5
-# VERSION - set as (for example 25)
-#--------------------------------------------------------------
-
-!if [echo REM = This file is generated from rules.vc > versions.vc]
-!endif
-!if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
-   && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc]
-!endif
-!if [echo TCL_MINOR_VERSION = \>> versions.vc] \
-   && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc]
-!endif
-!if [echo TCL_PATCH_LEVEL = \>> versions.vc] \
-   && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc]
-!endif
-
-!if defined(_TK_H)
-!if [echo TK_MAJOR_VERSION = \>> versions.vc] \
-   && [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc]
-!endif
-!if [echo TK_MINOR_VERSION = \>> versions.vc] \
-   && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc]
-!endif
-!if [echo TK_PATCH_LEVEL = \>> versions.vc] \
-   && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
-!endif
-!endif # _TK_H
-
-!include versions.vc
-
-TCL_VERSION	= $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
-TCL_DOTVERSION	= $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
-!if defined(_TK_H)
-TK_VERSION	= $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
-TK_DOTVERSION	= $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
-!endif
-
-# Set DOTVERSION and VERSION
-!if $(DOING_TCL)
-
-DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
-VERSION = $(TCL_VERSION)
-
-!elseif $(DOING_TK)
-
-DOTVERSION = $(TK_DOTVERSION)
-VERSION = $(TK_VERSION)
-
-!else # Doing a non-Tk extension
-
-# If parent makefile has not defined DOTVERSION, try to get it from TEA
-# first from a configure.in file, and then from configure.ac
-!ifndef DOTVERSION
-!if [echo DOTVERSION = \> versions.vc] \
-   || [nmakehlp -V $(ROOT)\configure.in ^[$(PROJECT)^] >> versions.vc]
-!if [echo DOTVERSION = \> versions.vc] \
-   || [nmakehlp -V $(ROOT)\configure.ac ^[$(PROJECT)^] >> versions.vc]
-!error *** Could not figure out extension version. Please define DOTVERSION in parent makefile before including rules.vc.
-!endif
-!endif
-!include versions.vc
-!endif # DOTVERSION
-VERSION         = $(DOTVERSION:.=)
-
-!endif # $(DOING_TCL) ... etc.
-
-# Windows RC files have 3 version components. Ensure this irrespective
-# of how many components the package has specified. Basically, ensure
-# minimum 4 components by appending 4 0's and then pick out the first 4.
-# Also take care of the fact that DOTVERSION may have "a" or "b" instead
-# of "." separating the version components.
-DOTSEPARATED=$(DOTVERSION:a=.)
-DOTSEPARATED=$(DOTSEPARATED:b=.)
-!if [echo RCCOMMAVERSION = \> versions.vc] \
-  || [for /f "tokens=1,2,3,4,5* delims=." %a in ("$(DOTSEPARATED).0.0.0.0") do echo %a,%b,%c,%d >> versions.vc]
-!error *** Could not generate RCCOMMAVERSION ***
-!endif
-!include versions.vc
 
 ################################################################
 # 10. Construct output directory and file paths
 # Figure-out how to name our intermediate and output directories.
 # In order to avoid inadvertent mixing of object files built using
@@ -1085,18 +1128,25 @@
 !include nmakehlp.out
 
 # The name of the stubs library for the project being built
 STUBPREFIX      = $(PROJECT)stub
 
+#
 # Set up paths to various Tcl executables and libraries needed by extensions
+#
+
+# TIP 430. Unused for 8.6 but no harm defining it to allow a common rules.vc
+TCLSCRIPTZIPNAME = libtcl$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)$(TCL_PATCH_LETTER)$(TCL_RELEASE_SERIAL).zip
+TKSCRIPTZIPNAME = libtk$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)$(TK_PATCH_LETTER)$(TK_RELEASE_SERIAL).zip
+
 !if $(DOING_TCL)
-
 TCLSHNAME       = $(PROJECT)sh$(VERSION)$(SUFX).exe
 TCLSH		= $(OUT_DIR)\$(TCLSHNAME)
 TCLIMPLIB	= $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
 TCLLIBNAME	= $(PROJECT)$(VERSION)$(SUFX).$(EXT)
 TCLLIB		= $(OUT_DIR)\$(TCLLIBNAME)
+TCLSCRIPTZIP    = $(OUT_DIR)\$(TCLSCRIPTZIPNAME)
 
 TCLSTUBLIBNAME	= $(STUBPREFIX)$(VERSION).lib
 TCLSTUBLIB	= $(OUT_DIR)\$(TCLSTUBLIBNAME)
 TCL_INCLUDES    = -I"$(WIN_DIR)" -I"$(GENERICDIR)"
 
@@ -1120,10 +1170,11 @@
 TCLIMPLIB	= $(_TCLDIR)\lib\tcl$(TCL_VERSION)t$(SUFX:t=).lib
 !endif
 TCL_LIBRARY	= $(_TCLDIR)\lib
 TCLREGLIB	= $(_TCLDIR)\lib\tclreg13$(SUFX:t=).lib
 TCLDDELIB	= $(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib
+TCLSCRIPTZIP	= $(_TCLDIR)\lib\$(TCLSCRIPTZIPNAME)
 TCLTOOLSDIR	= \must\have\tcl\sources\to\build\this\target
 TCL_INCLUDES    = -I"$(_TCLDIR)\include"
 
 !else # Building against Tcl sources
 
@@ -1139,10 +1190,11 @@
 TCLIMPLIB	= $(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)t$(SUFX:t=).lib
 !endif
 TCL_LIBRARY	= $(_TCLDIR)\library
 TCLREGLIB	= $(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg13$(SUFX:t=).lib
 TCLDDELIB	= $(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib
+TCLSCRIPTZIP	= $(_TCLDIR)\win\$(BUILDDIRTOP)\$(TCLSCRIPTZIPNAME)
 TCLTOOLSDIR	= $(_TCLDIR)\tools
 TCL_INCLUDES	= -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
 
 !endif # TCLINSTALL
 
@@ -1162,20 +1214,28 @@
 
 # Do the same for Tk and Tk extensions that require the Tk libraries
 !if $(DOING_TK) || $(NEED_TK)
 WISHNAMEPREFIX = wish
 WISHNAME = $(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe
-TKLIBNAME	= $(PROJECT)$(TK_VERSION)$(SUFX).$(EXT)
-TKSTUBLIBNAME	= tkstub$(TK_VERSION).lib
+TKLIBNAME8	= tk$(TK_VERSION)$(SUFX).$(EXT)
+TKLIBNAME9	= tcl9tk$(TK_VERSION)$(SUFX).$(EXT)
+!if $(TCL_MAJOR_VERSION) == 8
+TKLIBNAME	= tk$(TK_VERSION)$(SUFX).$(EXT)
 TKIMPLIBNAME	= tk$(TK_VERSION)$(SUFX).lib
+!else
+TKLIBNAME	= tcl9tk$(TK_VERSION)$(SUFX).$(EXT)
+TKIMPLIBNAME	= tcl9tk$(TK_VERSION)$(SUFX).lib
+!endif
+TKSTUBLIBNAME	= tkstub$(TK_VERSION).lib
 
 !if $(DOING_TK)
 WISH 		= $(OUT_DIR)\$(WISHNAME)
 TKSTUBLIB	= $(OUT_DIR)\$(TKSTUBLIBNAME)
 TKIMPLIB	= $(OUT_DIR)\$(TKIMPLIBNAME)
 TKLIB		= $(OUT_DIR)\$(TKLIBNAME)
-TK_INCLUDES    = -I"$(WIN_DIR)" -I"$(GENERICDIR)"
+TK_INCLUDES     = -I"$(WIN_DIR)" -I"$(GENERICDIR)"
+TKSCRIPTZIP     = $(OUT_DIR)\$(TKSCRIPTZIPNAME)
 
 !else # effectively NEED_TK
 
 !if $(TKINSTALL) # Building against installed Tk
 WISH		= $(_TKDIR)\bin\$(WISHNAME)
@@ -1186,11 +1246,14 @@
 !if !exist("$(TKIMPLIB)")
 TKIMPLIBNAME	= tk$(TK_VERSION)$(SUFX:t=).lib
 TKIMPLIB	= $(_TKDIR)\lib\$(TKIMPLIBNAME)
 !endif
 TK_INCLUDES     = -I"$(_TKDIR)\include"
+TKSCRIPTZIP     = $(_TKDIR)\lib\$(TKSCRIPTZIPNAME)
+
 !else # Building against Tk sources
+
 WISH		= $(_TKDIR)\win\$(BUILDDIRTOP)\$(WISHNAME)
 TKSTUBLIB	= $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSTUBLIBNAME)
 TKIMPLIB	= $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
 # When building extensions, may be linking against Tk that does not add
 # "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
@@ -1197,19 +1260,28 @@
 !if !exist("$(TKIMPLIB)")
 TKIMPLIBNAME	= tk$(TK_VERSION)$(SUFX:t=).lib
 TKIMPLIB	= $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
 !endif
 TK_INCLUDES     = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
+TKSCRIPTZIP     = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSCRIPTZIPNAME)
+
 !endif # TKINSTALL
+
 tklibs = "$(TKSTUBLIB)" "$(TKIMPLIB)"
 
 !endif # $(DOING_TK)
 !endif # $(DOING_TK) || $(NEED_TK)
 
 # Various output paths
 PRJIMPLIB	= $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
-PRJLIBNAME	= $(PROJECT)$(VERSION)$(SUFX).$(EXT)
+PRJLIBNAME8	= $(PROJECT)$(VERSION)$(SUFX).$(EXT)
+PRJLIBNAME9	= tcl9$(PROJECT)$(VERSION)$(SUFX).$(EXT)
+!if $(TCL_MAJOR_VERSION) == 8
+PRJLIBNAME	= $(PRJLIBNAME8)
+!else
+PRJLIBNAME	= $(PRJLIBNAME9)
+!endif
 PRJLIB		= $(OUT_DIR)\$(PRJLIBNAME)
 
 PRJSTUBLIBNAME	= $(STUBPREFIX)$(VERSION).lib
 PRJSTUBLIB	= $(OUT_DIR)\$(PRJSTUBLIBNAME)
 
@@ -1283,12 +1355,12 @@
 # conlflags - complete linker switches for console program (subsumes lflags)
 # guilflags - complete linker switches for GUI program (subsumes lflags)
 # baselibs - minimum Windows libraries required. Parent makefile can
 #    define PRJ_LIBS before including rules.rc if additional libs are needed
 
-OPTDEFINES	= /DSTDC_HEADERS
-!if $(VCVERSION) >= 1600
+OPTDEFINES	= /DSTDC_HEADERS /DUSE_NMAKE=1
+!if $(VCVERSION) > 1600
 OPTDEFINES	= $(OPTDEFINES) /DHAVE_STDINT_H=1
 !else
 OPTDEFINES	= $(OPTDEFINES) /DMP_NO_STDINT=1
 !endif
 !if $(VCVERSION) >= 1800
@@ -1309,11 +1381,11 @@
 !endif
 !if $(STATIC_BUILD)
 OPTDEFINES	= $(OPTDEFINES) /DSTATIC_BUILD
 !elseif $(TCL_VERSION) > 86
 OPTDEFINES	= $(OPTDEFINES) /DTCL_WITH_EXTERNAL_TOMMATH
-!if "$(MACHINE)" == "AMD64"
+!if "$(MACHINE)" == "AMD64" || "$(MACHINE)" == "ARM64"
 OPTDEFINES	= $(OPTDEFINES) /DMP_64BIT
 !endif
 !endif
 !if $(TCL_NO_DEPRECATED)
 OPTDEFINES	= $(OPTDEFINES) /DTCL_NO_DEPRECATED
@@ -1337,11 +1409,11 @@
 !endif
 !endif
 !if $(PROFILE)
 OPTDEFINES	= $(OPTDEFINES) /DTCL_CFG_PROFILED
 !endif
-!if "$(MACHINE)" == "AMD64"
+!if "$(MACHINE)" == "AMD64" || "$(MACHINE)" == "ARM64"
 OPTDEFINES	= $(OPTDEFINES) /DTCL_CFG_DO64BIT
 !endif
 !if $(VCVERSION) < 1300
 OPTDEFINES	= $(OPTDEFINES) /DNO_STRTOI64=1
 !endif
@@ -1348,17 +1420,17 @@
 
 !if "$(TCL_MAJOR_VERSION)" == "8"
 !if "$(_USE_64BIT_TIME_T)" == "1"
 OPTDEFINES	= $(OPTDEFINES) /D_USE_64BIT_TIME_T=1
 !endif
-!if "$(TCL_UTF_MAX)" == "4"
-OPTDEFINES	= $(OPTDEFINES) /DTCL_UTF_MAX=4
-!endif
 
 # _ATL_XP_TARGETING - Newer SDK's need this to build for XP
 COMPILERFLAGS  = /D_ATL_XP_TARGETING
 !endif
+!if "$(TCL_UTF_MAX)" == "3"
+OPTDEFINES	= $(OPTDEFINES) /DTCL_UTF_MAX=3
+!endif
 
 # Like the TEA system only set this non empty for non-Tk extensions
 # Note: some extensions use PACKAGE_NAME and others use PACKAGE_TCLNAME
 # so we pass both
 !if !$(DOING_TCL) && !$(DOING_TK)
@@ -1396,14 +1468,14 @@
 cdebug = $(cdebug) -Zi
 !endif
 
 !endif # $(DEBUG)
 
-# cwarn includes default warning levels.
-cwarn = $(WARNINGS)
+# cwarn includes default warning levels, also C4090 (buggy) and C4146 is useless.
+cwarn = $(WARNINGS) -wd4090 -wd4146
 
-!if "$(MACHINE)" == "AMD64"
+!if "$(MACHINE)" == "AMD64" || "$(MACHINE)" == "ARM64"
 # Disable pointer<->int warnings related to cast between different sizes
 # There are a gadzillion of these due to use of ClientData and
 # clutter up compiler
 # output increasing chance of a real warning getting lost. So disable them.
 # Eventually some day, Tcl will be 64-bit clean.
@@ -1414,10 +1486,15 @@
 !if "$(MACHINE)" == "ARM"
 carch = /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
 !else
 carch =
 !endif
+
+# cpuid is only available on intel machines
+!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "AMD64"
+carch = $(carch) /DHAVE_CPUID=1
+!endif
 
 !if $(DEBUG)
 # Turn warnings into errors
 cwarn = $(cwarn) -WX
 !endif
@@ -1454,11 +1531,11 @@
 # TBD - tclvfs has a comment that stubs libs should not be compiled with -GL
 # without stating why. Tcl itself compiled stubs libs with this flag.
 # so we do not remove it from cflags. -GL may prevent extensions
 # compiled with one VC version to fail to link against stubs library
 # compiled with another VC version. Check for this and fix accordingly.
-stubscflags = $(cflags) $(PKGNAMEFLAGS) $(PRJ_DEFINES) $(OPTDEFINES) -Zl /DSTATIC_BUILD $(INCLUDES) $(USE_STUBS_DEFS)
+stubscflags = $(cflags) $(PKGNAMEFLAGS) $(PRJ_DEFINES) $(OPTDEFINES) /Zl /GL- /DSTATIC_BUILD $(INCLUDES) $(USE_STUBS_DEFS)
 
 # Link flags
 
 !if $(DEBUG)
 ldebug	= -debug -debugtype:cv
@@ -1477,22 +1554,10 @@
 ### Declarations common to all linker versions
 lflags	= -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug)
 
 !if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900
 lflags	= $(lflags) -nodefaultlib:libucrt.lib
-!endif
-
-# Old linkers (Visual C++ 6 in particular) will link for fast loading
-# on Win98. Since we do not support Win98 any more, we specify nowin98
-# as recommended for NT and later. However, this is only required by
-# IX86 on older compilers and only needed if we are not doing a static build.
-
-!if "$(MACHINE)" == "IX86" && !$(STATIC_BUILD)
-!if [nmakehlp -l -opt:nowin98 $(LINKER_TESTFLAGS)]
-# Align sections for PE size savings.
-lflags	= $(lflags) -opt:nowin98
-!endif
 !endif
 
 dlllflags = $(lflags) -dll
 conlflags = $(lflags) -subsystem:console
 guilflags = $(lflags) -subsystem:windows
@@ -1547,24 +1612,36 @@
 
 default-target: $(DEFAULT_BUILD_TARGET)
 
 !if $(MULTIPLATFORM_INSTALL)
 default-pkgindex:
+	@echo if {[package vsatisfies [package provide Tcl] 9.0-]} { > $(OUT_DIR)\pkgIndex.tcl
+	@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
+	    [list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME9)]] >> $(OUT_DIR)\pkgIndex.tcl
+	@echo } else { >> $(OUT_DIR)\pkgIndex.tcl
 	@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
-	    [list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME)]] > $(OUT_DIR)\pkgIndex.tcl
+	    [list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME8)]] >> $(OUT_DIR)\pkgIndex.tcl
+	@echo } >> $(OUT_DIR)\pkgIndex.tcl
 !else
 default-pkgindex:
+	@echo if {[package vsatisfies [package provide Tcl] 9.0-]} { > $(OUT_DIR)\pkgIndex.tcl
+	@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
+	    [list load [file join $$dir $(PRJLIBNAME9)]] >> $(OUT_DIR)\pkgIndex.tcl
+	@echo } else { >> $(OUT_DIR)\pkgIndex.tcl
 	@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
-	    [list load [file join $$dir $(PRJLIBNAME)]] > $(OUT_DIR)\pkgIndex.tcl
+	    [list load [file join $$dir $(PRJLIBNAME8)]] >> $(OUT_DIR)\pkgIndex.tcl
+	@echo } >> $(OUT_DIR)\pkgIndex.tcl
 !endif
 
 default-pkgindex-tea:
 	@if exist $(ROOT)\pkgIndex.tcl.in nmakehlp -s << $(ROOT)\pkgIndex.tcl.in > $(OUT_DIR)\pkgIndex.tcl
 @PACKAGE_VERSION@    $(DOTVERSION)
 @PACKAGE_NAME@       $(PRJ_PACKAGE_TCLNAME)
 @PACKAGE_TCLNAME@    $(PRJ_PACKAGE_TCLNAME)
 @PKG_LIB_FILE@       $(PRJLIBNAME)
+@PKG_LIB_FILE8@      $(PRJLIBNAME8)
+@PKG_LIB_FILE9@      $(PRJLIBNAME9)
 <<
 
 default-install: default-install-binaries default-install-libraries
 !if $(SYMBOLS)
 default-install: default-install-pdbs
@@ -1597,10 +1674,12 @@
 
 default-install-pdbs:
 	@echo Installing PDBs to '$(LIB_INSTALL_DIR)'
 	@if not exist "$(LIB_INSTALL_DIR)" mkdir "$(LIB_INSTALL_DIR)"
 	@$(CPY) "$(OUT_DIR)\*.pdb" "$(LIB_INSTALL_DIR)\"
+
+# "emacs font-lock highlighting fix
 
 default-install-docs-html:
 	@echo Installing documentation files to '$(DOC_INSTALL_DIR)'
 	@if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)"
 	@if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.html" "$(DOCDIR)\*.css" "$(DOCDIR)\*.png") do @$(COPY) %f "$(DOC_INSTALL_DIR)"
@@ -1762,12 +1841,12 @@
 !if $(TCLINSTALL) # Building against an installed Tcl
 !if exist("$(_TCLDIR)\lib\nmake\tcl.nmake")
 TCLNMAKECONFIG = "$(_TCLDIR)\lib\nmake\tcl.nmake"
 !endif
 !else # !$(TCLINSTALL) - building against Tcl source
-!if exist("$(OUT_DIR)\tcl.nmake")
-TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake"
+!if exist("$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl.nmake")
+TCLNMAKECONFIG	= "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl.nmake"
 !endif
 !endif # TCLINSTALL
 
 !if $(CONFIG_CHECK)
 !ifdef TCLNMAKECONFIG

ADDED   win/svnmanifest.in
Index: win/svnmanifest.in
==================================================================
--- /dev/null
+++ win/svnmanifest.in
@@ -0,0 +1,1 @@
+svn-r

Index: win/targets.vc
==================================================================
--- win/targets.vc
+++ win/targets.vc
@@ -2,11 +2,11 @@
 # targets.vc --
 #
 # Part of the nmake based build system for Tcl and its extensions.
 # This file defines some standard targets for the convenience of extensions
 # and can be optionally included by the extension makefile.
-# See TIP 477 (https://core.tcl-lang.org/tips/doc/trunk/tip/477.md) for docs.
+# See TIP 477 (https://core.tcl-lang.org/tips/doc/main/tip/477.md) for docs.
 
 $(PROJECT): setup pkgindex $(PRJLIB)
 
 !ifdef PRJ_STUBOBJS
 $(PROJECT): $(PRJSTUBLIB)

Index: win/tcl.m4
==================================================================
--- win/tcl.m4
+++ win/tcl.m4
@@ -26,13 +26,13 @@
 
     if test x"${no_tcl}" = x ; then
 	# we reset no_tcl in case something fails here
 	no_tcl=true
 	AC_ARG_WITH(tcl,
-	    AC_HELP_STRING([--with-tcl],
+	    AS_HELP_STRING([--with-tcl],
 		[directory containing tcl configuration (tclConfig.sh)]),
-	    with_tclconfig="${withval}")
+	    [with_tclconfig="${withval}"])
 	AC_MSG_CHECKING([for Tcl configuration])
 	AC_CACHE_VAL(ac_cv_c_tclconfig,[
 
 	    # First check to see if --with-tcl was specified.
 	    if test x"${with_tclconfig}" != x ; then
@@ -144,13 +144,13 @@
 
     if test x"${no_tk}" = x ; then
 	# we reset no_tk in case something fails here
 	no_tk=true
 	AC_ARG_WITH(tk,
-	    AC_HELP_STRING([--with-tk],
+	    AS_HELP_STRING([--with-tk],
 		[directory containing tk configuration (tkConfig.sh)]),
-	    with_tkconfig="${withval}")
+	    [with_tkconfig="${withval}"])
 	AC_MSG_CHECKING([for Tk configuration])
 	AC_CACHE_VAL(ac_cv_c_tkconfig,[
 
 	    # First check to see if --with-tkconfig was specified.
 	    if test x"${with_tkconfig}" != x ; then
@@ -249,11 +249,10 @@
 #
 #	Substitutes the following vars:
 #		TCL_BIN_DIR
 #		TCL_SRC_DIR
 #		TCL_LIB_FILE
-#		TCL_ZIP_FILE
 #
 #------------------------------------------------------------------------
 
 AC_DEFUN([SC_LOAD_TCLCONFIG], [
     AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh])
@@ -286,11 +285,10 @@
 
     AC_SUBST(TCL_VERSION)
     AC_SUBST(TCL_BIN_DIR)
     AC_SUBST(TCL_SRC_DIR)
 
-    AC_SUBST(TCL_ZIP_FILE)
     AC_SUBST(TCL_LIB_FILE)
     AC_SUBST(TCL_LIB_FLAG)
     AC_SUBST(TCL_LIB_SPEC)
 
     AC_SUBST(TCL_STUB_LIB_FILE)
@@ -356,18 +354,10 @@
 AC_DEFUN([SC_ENABLE_SHARED], [
     AC_MSG_CHECKING([how to build libraries])
     AC_ARG_ENABLE(shared,
 	[  --enable-shared         build and link with shared libraries (default: on)],
 	[tcl_ok=$enableval], [tcl_ok=yes])
-
-    if test "${enable_shared+set}" = set; then
-	enableval="$enable_shared"
-	tcl_ok=$enableval
-    else
-	tcl_ok=yes
-    fi
-
     if test "$tcl_ok" = "yes" ; then
 	AC_MSG_RESULT([shared])
 	SHARED_BUILD=1
     else
 	AC_MSG_RESULT([static])
@@ -461,10 +451,11 @@
 #	Can the following vars:
 #		EXTRA_CFLAGS
 #		CFLAGS_DEBUG
 #		CFLAGS_OPTIMIZE
 #		CFLAGS_WARNING
+#		CFLAGS_NOLTO
 #		LDFLAGS_DEBUG
 #		LDFLAGS_OPTIMIZE
 #		LDFLAGS_CONSOLE
 #		LDFLAGS_WINDOW
 #		CC_OBJNAME
@@ -508,24 +499,24 @@
     AC_CHECK_PROG(WINE, wine, wine,)
 
     SHLIB_SUFFIX=".dll"
 
     # MACHINE is IX86 for LINK, but this is used by the manifest,
-    # which requires x86|amd64|ia64.
+    # which requires x86|amd64|arm64|ia64.
     MACHINE="X86"
 
     if test "$GCC" = "yes"; then
 
       AC_CACHE_CHECK(for cross-compile version of gcc,
 	ac_cv_cross,
-	AC_TRY_COMPILE([
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	    #ifndef _WIN32
 		#error cross-compiler
 	    #endif
-	], [],
-	ac_cv_cross=no,
-	ac_cv_cross=yes)
+	]], [[]])],
+	[ac_cv_cross=no],
+	[ac_cv_cross=yes])
       )
 
       if test "$ac_cv_cross" = "yes"; then
 	case "$do64bit" in
 	    amd64|x64|yes)
@@ -533,10 +524,17 @@
 		LD="x86_64-w64-mingw32-ld"
 		AR="x86_64-w64-mingw32-ar"
 		RANLIB="x86_64-w64-mingw32-ranlib"
 		RC="x86_64-w64-mingw32-windres"
 	    ;;
+	    arm64|aarch64)
+		CC="aarch64-w64-mingw32-${CC}"
+		LD="aarch64-w64-mingw32-ld"
+		AR="aarch64-w64-mingw32-ar"
+		RANLIB="aarch64-w64-mingw32-ranlib"
+		RC="aarch64-w64-mingw32-windres"
+	    ;;
 	    *)
 		CC="i686-w64-mingw32-${CC}"
 		LD="i686-w64-mingw32-ld"
 		AR="i686-w64-mingw32-ar"
 		RANLIB="i686-w64-mingw32-ranlib"
@@ -582,48 +580,83 @@
     if test "${GCC}" = "yes" ; then
 	extra_cflags="-pipe"
 	extra_ldflags="-pipe -static-libgcc"
 	AC_CACHE_CHECK(for mingw32 version of gcc,
 	    ac_cv_win32,
-	    AC_TRY_COMPILE([
+	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 		#ifdef _WIN32
 		    #error win32
 		#endif
-	    ], [],
-	    ac_cv_win32=no,
-	    ac_cv_win32=yes)
+	    ]], [[]])],
+	    [ac_cv_win32=no],
+	    [ac_cv_win32=yes])
 	)
 	if test "$ac_cv_win32" != "yes"; then
 	    AC_MSG_ERROR([${CC} cannot produce win32 executables.])
 	fi
+	if test "$do64bit" != "arm64"; then
+	    extra_cflags="$extra_cflags -DHAVE_CPUID=1"
+	fi
 
 	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -mwindows -municode -Dmain=xxmain"
 	AC_CACHE_CHECK(for working -municode linker flag,
 	    ac_cv_municode,
-	AC_TRY_LINK([
+	AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 	#include <windows.h>
 	int APIENTRY wWinMain(HINSTANCE a, HINSTANCE b, LPWSTR c, int d) {return 0;}
-	],
-	[],
-	    ac_cv_municode=yes,
-	    ac_cv_municode=no)
+	]], [[]])],
+	    [ac_cv_municode=yes],
+	    [ac_cv_municode=no])
 	)
 	CFLAGS=$hold_cflags
 	if test "$ac_cv_municode" = "yes" ; then
 	    extra_ldflags="$extra_ldflags -municode"
 	else
 	    extra_cflags="$extra_cflags -DTCL_BROKEN_MAINARGS"
 	fi
+	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -fno-lto"
+	AC_CACHE_CHECK(for working -fno-lto,
+	    ac_cv_nolto,
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+	    [ac_cv_nolto=yes],
+	    [ac_cv_nolto=no])
+	)
+	CFLAGS=$hold_cflags
+	if test "$ac_cv_nolto" = "yes" ; then
+	    CFLAGS_NOLTO="-fno-lto"
+	else
+	    CFLAGS_NOLTO=""
+	fi
+	AC_CACHE_CHECK([if the compiler understands -finput-charset],
+	    tcl_cv_cc_input_charset, [
+	    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -finput-charset=UTF-8"
+	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[tcl_cv_cc_input_charset=yes],[tcl_cv_cc_input_charset=no])
+	    CFLAGS=$hold_cflags])
+	if test $tcl_cv_cc_input_charset = yes; then
+	    extra_cflags="$extra_cflags -finput-charset=UTF-8"
+	fi
+    fi
+
+    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Wl,--enable-auto-image-base"
+    AC_CACHE_CHECK(for working --enable-auto-image-base,
+	ac_cv_enable_auto_image_base,
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+	[ac_cv_enable_auto_image_base=yes],
+	[ac_cv_enable_auto_image_base=no])
+    )
+    CFLAGS=$hold_cflags
+    if test "$ac_cv_enable_auto_image_base" == "yes" ; then
+	extra_ldflags="$extra_ldflags -Wl,--enable-auto-image-base"
     fi
 
     AC_MSG_CHECKING([compiler flags])
     if test "${GCC}" = "yes" ; then
 	SHLIB_LD=""
 	SHLIB_LD_LIBS='${LIBS}'
 	LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -luserenv -lws2_32"
 	# mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't
-	LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32"
+	LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32 -lwinspool"
 	STLIB_LD='${AR} cr'
 	RC_OUT=-o
 	RC_TYPE=
 	RC_INCLUDE=--include
 	RC_DEFINE=--define
@@ -659,11 +692,11 @@
 	# Link with gcc since ld does not link to default libs like
 	# -luser32 and -lmsvcrt by default.
 	SHLIB_LD='${CC} -shared'
 	SHLIB_LD_LIBS='${LIBS}'
 	MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -o \[$]@ ${extra_ldflags} \
-	    -Wl,--out-implib,\$(patsubst %.dll,lib%.a,\[$]@)"
+	    -Wl,--out-implib,\$(patsubst %.dll,lib%.dll.a,\[$]@)"
 	# DLLSUFFIX is separate because it is the building block for
 	# users of tclConfig.sh that may build shared or static.
 	DLLSUFFIX=".dll"
 	LIBSUFFIX=".a"
 	LIBFLAGSUFFIX=""
@@ -680,11 +713,11 @@
 	case "${CC}" in
 	    *++)
 		CFLAGS_WARNING="${CFLAGS_WARNING} -Wno-format"
 		;;
 	    *)
-		CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -Wdeclaration-after-statement"
+		CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -fextended-identifiers"
 		;;
 	esac
 
 	# Specify the CC output file names based on the target name
 	CC_OBJNAME="-o \[$]@"
@@ -710,27 +743,31 @@
 	case "$do64bit" in
 	    amd64|x64|yes)
 		MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
 		AC_MSG_RESULT([   Using 64-bit $MACHINE mode])
 		;;
+	    arm64|aarch64)
+		MACHINE="ARM64"
+		AC_MSG_RESULT([   Using ARM64 $MACHINE mode])
+		;;
 	    ia64)
 		MACHINE="IA64"
-		AC_MSG_RESULT([   Using 64-bit $MACHINE mode])
+		AC_MSG_RESULT([   Using IA64 $MACHINE mode])
 		;;
 	    *)
-		AC_TRY_COMPILE([
+		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 		    #ifndef _WIN64
 			#error 32-bit
 		    #endif
-		], [],
-			tcl_win_64bit=yes,
-			tcl_win_64bit=no
+		]], [[]])],
+			[tcl_win_64bit=yes],
+			[tcl_win_64bit=no]
 		)
 		if test "$tcl_win_64bit" = "yes" ; then
-			do64bit=amd64
-			MACHINE="AMD64"
-			AC_MSG_RESULT([   Using 64-bit $MACHINE mode])
+		    do64bit=amd64
+		    MACHINE="AMD64"
+		    AC_MSG_RESULT([   Using 64-bit $MACHINE mode])
 		fi
 		;;
 	esac
     else
 	if test "${SHARED_BUILD}" = "0" ; then
@@ -764,10 +801,13 @@
 	if test "$do64bit" != "no" ; then
 	    case "$do64bit" in
 		amd64|x64|yes)
 		    MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
 		    ;;
+		arm64|aarch64)
+		    MACHINE="ARM64"
+		    ;;
 		ia64)
 		    MACHINE="IA64"
 		    ;;
 	    esac
 	    AC_MSG_RESULT([   Using 64-bit $MACHINE mode])
@@ -784,12 +824,11 @@
 	esac
 
 	if test "$do64bit" != "no" ; then
 	    RC="rc"
 	    CFLAGS_DEBUG="-nologo -Zi -Od ${runtime}d"
-	    # Do not use -O2 for Win64 - this has proved buggy in code gen.
-	    CFLAGS_OPTIMIZE="-nologo -O1 ${runtime}"
+	    CFLAGS_OPTIMIZE="-nologo -O2 ${runtime}"
 	    lflags="${lflags} -nologo -MACHINE:${MACHINE}"
 	    LINKBIN="link"
 	    # Avoid 'unresolved external symbol __security_cookie' errors.
 	    # c.f. http://support.microsoft.com/?id=894573
 	    LIBS="$LIBS bufferoverflowU.lib"
@@ -802,11 +841,11 @@
 	    CFLAGS_OPTIMIZE="-nologo -O2 ${runtime}"
 	    lflags="${lflags} -nologo"
 	    LINKBIN="link"
 	fi
 
-	LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib"
+	LIBS_GUI="gdi32.lib comdlg32.lib imm32.lib comctl32.lib shell32.lib uuid.lib winspool.lib"
 
 	SHLIB_LD="${LINKBIN} -dll -incremental:no ${lflags}"
 	SHLIB_LD_LIBS='${LIBS}'
 	# link -lib only works when -lib is the first arg
 	STLIB_LD="${LINKBIN} -lib ${lflags}"
@@ -849,11 +888,11 @@
     fi
 
     if test "${GCC}" = "yes" ; then
 	AC_CACHE_CHECK(for SEH support in compiler,
 	    tcl_cv_seh,
-	AC_TRY_RUN([
+	AC_RUN_IFELSE([AC_LANG_SOURCE([[
 	    #define WIN32_LEAN_AND_MEAN
 	    #include <windows.h>
 	    #undef WIN32_LEAN_AND_MEAN
 
 	    int main(int argc, char** argv) {
@@ -864,14 +903,14 @@
 		__except (EXCEPTION_EXECUTE_HANDLER) {
 		    return 0;
 		}
 		return 1;
 	    }
-	],
-	    tcl_cv_seh=yes,
-	    tcl_cv_seh=no,
-	    tcl_cv_seh=no)
+	]])],
+	    [tcl_cv_seh=yes],
+	    [tcl_cv_seh=no],
+	    [tcl_cv_seh=no])
 	)
 	if test "$tcl_cv_seh" = "no" ; then
 	    AC_DEFINE(HAVE_NO_SEH, 1,
 		    [Defined when mingw does not support SEH])
 	fi
@@ -882,19 +921,19 @@
 	# with Cygwin's version as of 2002-04-10, define it to be int,
 	# sufficient for getting the current code to work.
 	#
 	AC_CACHE_CHECK(for EXCEPTION_DISPOSITION support in include files,
 	    tcl_cv_eh_disposition,
-	    AC_TRY_COMPILE([
+	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #	    define WIN32_LEAN_AND_MEAN
 #	    include <windows.h>
 #	    undef WIN32_LEAN_AND_MEAN
-	    ],[
+	    ]], [[
 		EXCEPTION_DISPOSITION x;
-	    ],
-		tcl_cv_eh_disposition=yes,
-		tcl_cv_eh_disposition=no)
+	    ]])],
+		[tcl_cv_eh_disposition=yes],
+		[tcl_cv_eh_disposition=no])
 	)
 	if test "$tcl_cv_eh_disposition" = "no" ; then
 	AC_DEFINE(EXCEPTION_DISPOSITION, int,
 		[Defined when cygwin/mingw does not support EXCEPTION DISPOSITION])
 	fi
@@ -903,22 +942,22 @@
 	# even if VOID has already been #defined. The win32api
 	# used by mingw and cygwin is known to do this.
 
 	AC_CACHE_CHECK(for winnt.h that ignores VOID define,
 	    tcl_cv_winnt_ignore_void,
-	    AC_TRY_COMPILE([
+	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 		#define VOID void
 		#define WIN32_LEAN_AND_MEAN
 		#include <windows.h>
 		#undef WIN32_LEAN_AND_MEAN
-	    ], [
+	    ]], [[
 		CHAR c;
 		SHORT s;
 		LONG l;
-	    ],
-        tcl_cv_winnt_ignore_void=yes,
-        tcl_cv_winnt_ignore_void=no)
+	    ]])],
+	    [tcl_cv_winnt_ignore_void=yes],
+	    [tcl_cv_winnt_ignore_void=no])
 	)
 	if test "$tcl_cv_winnt_ignore_void" = "yes" ; then
 	    AC_DEFINE(HAVE_WINNT_IGNORE_VOID, 1,
 		    [Defined when cygwin/mingw ignores VOID define in winnt.h])
 	fi
@@ -929,17 +968,16 @@
 	# This is used to stop gcc from printing a compiler
 	# warning when initializing a union member.
 
 	AC_CACHE_CHECK(for cast to union support,
 	    tcl_cv_cast_to_union,
-	    AC_TRY_COMPILE([],
-	    [
+	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
 		  union foo { int i; double d; };
 		  union foo f = (union foo) (int) 0;
-	    ],
-	    tcl_cv_cast_to_union=yes,
-	    tcl_cv_cast_to_union=no)
+	    ]])],
+	    [tcl_cv_cast_to_union=yes],
+	    [tcl_cv_cast_to_union=no])
 	)
 	if test "$tcl_cv_cast_to_union" = "yes"; then
 	    AC_DEFINE(HAVE_CAST_TO_UNION, 1,
 		    [Defined when compiler supports casting to union type.])
 	fi
@@ -948,10 +986,11 @@
     # DL_LIBS is empty, but then we match the Unix version
     AC_SUBST(DL_LIBS)
     AC_SUBST(CFLAGS_DEBUG)
     AC_SUBST(CFLAGS_OPTIMIZE)
     AC_SUBST(CFLAGS_WARNING)
+    AC_SUBST(CFLAGS_NOLTO)
 ])
 
 #------------------------------------------------------------------------
 # SC_WITH_TCL --
 #
@@ -1055,11 +1094,11 @@
 #		BUILD_TCLSH
 #------------------------------------------------------------------------
 
 AC_DEFUN([SC_BUILD_TCLSH], [
     AC_MSG_CHECKING([for tclsh in Tcl build directory])
-    BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}
+    BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}\${EXESUFFIX}
     AC_MSG_RESULT($BUILD_TCLSH)
     AC_SUBST(BUILD_TCLSH)
 ])
 
 #--------------------------------------------------------------------
@@ -1083,12 +1122,11 @@
     AC_ARG_WITH(encoding, [  --with-encoding         encoding for configuration values], with_tcencoding=${withval})
 
     if test x"${with_tcencoding}" != x ; then
 	AC_DEFINE_UNQUOTED(TCL_CFGVAL_ENCODING,"${with_tcencoding}")
     else
-	# Default encoding on windows is not "iso8859-1"
-	AC_DEFINE(TCL_CFGVAL_ENCODING,"cp1252")
+	AC_DEFINE(TCL_CFGVAL_ENCODING,"utf-8")
     fi
 ])
 
 #--------------------------------------------------------------------
 # SC_EMBED_MANIFEST
@@ -1106,11 +1144,11 @@
 #--------------------------------------------------------------------
 
 AC_DEFUN([SC_EMBED_MANIFEST], [
     AC_MSG_CHECKING(whether to embed manifest)
     AC_ARG_ENABLE(embedded-manifest,
-	AC_HELP_STRING([--enable-embedded-manifest],
+	AS_HELP_STRING([--enable-embedded-manifest],
 		[embed manifest if possible (default: yes)]),
 	[embed_ok=$enableval], [embed_ok=yes])
 
     VC_MANIFEST_EMBED_DLL=
     VC_MANIFEST_EMBED_EXE=

ADDED   win/tkUuid.h.in
Index: win/tkUuid.h.in
==================================================================
--- /dev/null
+++ win/tkUuid.h.in
@@ -0,0 +1,1 @@
+#define TK_VERSION_UUID \

Index: win/tkWin.h
==================================================================
--- win/tkWin.h
+++ win/tkWin.h
@@ -2,11 +2,11 @@
  * tkWin.h --
  *
  *	Declarations of public types and interfaces that are only
  *	available under Windows.
  *
- * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
+ * Copyright (c) 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -21,17 +21,17 @@
  * WINVER = 0x0600 means Windows Vista and above. Even though we still
  * support Windows XP, but the Vista-specifics are tested at runtime.
  */
 
 #ifndef WINVER
-#   define WINVER 0x0600
+#   define WINVER 0x0601
 #endif
 #ifndef _WIN32_WINNT
-#   define _WIN32_WINNT 0x0600
+#   define _WIN32_WINNT 0x0601
 #endif
 #ifndef _WIN32_IE
-#   define _WIN32_IE 0x0700
+#   define _WIN32_IE 0x0800
 #endif
 
 #ifndef _TK
 #include <tk.h>
 #endif

Index: win/tkWin32Dll.c
==================================================================
--- win/tkWin32Dll.c
+++ win/tkWin32Dll.c
@@ -1,11 +1,11 @@
 /*
  * tkWin32Dll.c --
  *
  *	This file contains a stub dll entry point.
  *
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright © 1995 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -99,11 +99,11 @@
 DllMain(
     HINSTANCE hInstance,
     DWORD reason,
     LPVOID reserved)
 {
-#ifdef HAVE_NO_SEH
+#if defined(HAVE_NO_SEH) && !defined(__aarch64__)
     TCLEXCEPTION_REGISTRATION registration;
 #endif
     (void)reserved;
 
     /*
@@ -118,15 +118,17 @@
 	break;
 
     case DLL_PROCESS_DETACH:
 	/*
 	 * Protect the call to TkFinalize in an SEH block. We can't be
-	 * guarenteed Tk is always being unloaded from a stable condition.
+	 * guaranteed Tk is always being unloaded from a stable condition.
 	 */
 
 #ifdef HAVE_NO_SEH
-#   ifdef __WIN64
+#   if defined(__aarch64__)
+	/* Don't run TkFinalize(NULL) on mingw-w64 for ARM64, since we don't have corresponding assembler-code. */
+#   elif defined(_WIN64)
 	__asm__ __volatile__ (
 
 	    /*
 	     * Construct an TCLEXCEPTION_REGISTRATION to protect the call to
 	     * TkFinalize
@@ -133,11 +135,11 @@
 	     */
 
 	    "leaq	%[registration], %%rdx"		"\n\t"
 	    "movq	%%gs:0,		%%rax"		"\n\t"
 	    "movq	%%rax,		0x0(%%rdx)"	"\n\t" /* link */
-	    "leaq	1f,		%%rax"		"\n\t"
+	    "leaq	1f(%%rip),	%%rax"		"\n\t"
 	    "movq	%%rax,		0x8(%%rdx)"	"\n\t" /* handler */
 	    "movq	%%rbp,		0x10(%%rdx)"	"\n\t" /* rbp */
 	    "movq	%%rsp,		0x18(%%rdx)"	"\n\t" /* rsp */
 	    "movl	%[error],	0x20(%%rdx)"	"\n\t" /* status */
 

Index: win/tkWin3d.c
==================================================================
--- win/tkWin3d.c
+++ win/tkWin3d.c
@@ -2,11 +2,11 @@
  * tkWin3d.c --
  *
  *	This file contains the platform specific routines for drawing 3D
  *	borders in the Windows 95 style.
  *
- * Copyright (c) 1996 by Sun Microsystems, Inc.
+ * Copyright © 1996 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: win/tkWinButton.c
==================================================================
--- win/tkWinButton.c
+++ win/tkWinButton.c
@@ -2,11 +2,11 @@
  * tkWinButton.c --
  *
  *	This file implements the Windows specific portion of the button
  *	widgets.
  *
- * Copyright (c) 1996-1998 by Sun Microsystems, Inc.
+ * Copyright © 1996-1998 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: win/tkWinClipboard.c
==================================================================
--- win/tkWinClipboard.c
+++ win/tkWinClipboard.c
@@ -1,12 +1,12 @@
 /*
  * tkWinClipboard.c --
  *
  *	This file contains functions for managing the clipboard.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-2000 by Scriptics Corporation.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -53,20 +53,20 @@
     Tcl_DString ds;
     HGLOBAL handle;
     Tcl_Encoding encoding;
     int result, locale, noBackslash = 0;
 
+    if ((selection != Tk_InternAtom(tkwin, "CLIPBOARD"))
+	    || (target != XA_STRING)) {
+	goto error;
+    }
     if (!OpenClipboard(NULL)) {
         Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 	        "clipboard cannot be opened, another application grabbed it"));
         Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "BUSY", NULL);
         return TCL_ERROR;
     }
-    if ((selection != Tk_InternAtom(tkwin, "CLIPBOARD"))
-	    || (target != XA_STRING)) {
-	goto error;
-    }
 
     /*
      * Attempt to get the data in Unicode form if available as this is less
      * work that CF_TEXT.
      */
@@ -130,11 +130,11 @@
 	    }
 	    CloseClipboard();
 	    goto error;
 	}
 	data = (char *)GlobalLock(handle);
-	Tcl_ExternalToUtfDString(encoding, data, -1, &ds);
+	(void)Tcl_ExternalToUtfDStringEx(encoding, data, -1, TCL_ENCODING_NOCOMPLAIN, &ds);
 	GlobalUnlock(handle);
 	if (encoding) {
 	    Tcl_FreeEncoding(encoding);
 	}
     } else if (IsClipboardFormatAvailable(CF_HDROP)) {

Index: win/tkWinColor.c
==================================================================
--- win/tkWinColor.c
+++ win/tkWinColor.c
@@ -1,12 +1,12 @@
 /*
  * tkWinColor.c --
  *
  *	Functions to map color names to system color values.
  *
- * Copyright (c) 1995 Sun Microsystems, Inc.
- * Copyright (c) 1994 Software Research Associates, Inc.
+ * Copyright © 1995 Sun Microsystems, Inc.
+ * Copyright © 1994 Software Research Associates, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -299,18 +299,17 @@
  *----------------------------------------------------------------------
  */
 
 int
 XAllocColor(
-    Display *display,
+    TCL_UNUSED(Display *),
     Colormap colormap,
     XColor *color)
 {
     TkWinColormap *cmap = (TkWinColormap *) colormap;
     PALETTEENTRY entry, closeEntry;
     HDC dc = GetDC(NULL);
-    (void)display;
 
     entry.peRed = (color->red) >> 8;
     entry.peGreen = (color->green) >> 8;
     entry.peBlue = (color->blue) >> 8;
     entry.peFlags = 0;
@@ -400,26 +399,24 @@
  *----------------------------------------------------------------------
  */
 
 int
 XFreeColors(
-    Display *display,
+    TCL_UNUSED(Display *),
     Colormap colormap,
     unsigned long *pixels,
     int npixels,
-    unsigned long planes)
+    TCL_UNUSED(unsigned long))
 {
     TkWinColormap *cmap = (TkWinColormap *) colormap;
     COLORREF cref;
     UINT count, index;
     size_t refCount;
     int i;
     PALETTEENTRY entry, *entries;
     Tcl_HashEntry *entryPtr;
     HDC dc = GetDC(NULL);
-    (void)display;
-    (void)planes;
 
     /*
      * We don't have to do anything for non-palette devices.
      */
 
@@ -474,27 +471,23 @@
  *----------------------------------------------------------------------
  */
 
 Colormap
 XCreateColormap(
-    Display *display,
-    Window w,
-    Visual *visual,
-    int alloc)
+    TCL_UNUSED(Display *),
+    TCL_UNUSED(Window),
+    TCL_UNUSED(Visual *),
+    TCL_UNUSED(int))
 {
     char logPalBuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)];
     LOGPALETTE *logPalettePtr;
     PALETTEENTRY *entryPtr;
     TkWinColormap *cmap;
     Tcl_HashEntry *hashPtr;
     int isNew;
     UINT i;
     HPALETTE sysPal;
-    (void)display;
-    (void)w;
-    (void)visual;
-    (void)alloc;
 
     /*
      * Allocate a starting palette with all of the reserved colors.
      */
 
@@ -541,15 +534,14 @@
  *----------------------------------------------------------------------
  */
 
 int
 XFreeColormap(
-    Display *display,
+    TCL_UNUSED(Display *),
     Colormap colormap)
 {
     TkWinColormap *cmap = (TkWinColormap *) colormap;
-    (void)display;
 
     if (!DeleteObject(cmap->palette)) {
 	Tcl_Panic("Unable to free colormap, palette is still selected");
     }
     Tcl_DeleteHashTable(&cmap->refCounts);

Index: win/tkWinConfig.c
==================================================================
--- win/tkWinConfig.c
+++ win/tkWinConfig.c
@@ -2,11 +2,11 @@
  * tkWinConfig.c --
  *
  *	This module implements the Windows system defaults for the
  *	configuration package.
  *
- * Copyright (c) 1997 by Sun Microsystems, Inc.
+ * Copyright © 1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -14,11 +14,11 @@
 
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpGetSystemDefault --
+ * Tk_GetSystemDefault --
  *
  *	Given a dbName and className for a configuration option, return a
  *	string representation of the option.
  *
  * Results:
@@ -31,11 +31,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 Tcl_Obj *
-TkpGetSystemDefault(
+Tk_GetSystemDefault(
     Tk_Window tkwin,		/* A window to use. */
     const char *dbName,		/* The option database name. */
     const char *className)	/* The name of the option class. */
 {
     Tcl_Obj *valueObjPtr;

Index: win/tkWinCursor.c
==================================================================
--- win/tkWinCursor.c
+++ win/tkWinCursor.c
@@ -1,11 +1,11 @@
 /*
  * tkWinCursor.c --
  *
  *	This file contains Win32 specific cursor related routines.
  *
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright © 1995 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -37,11 +37,11 @@
 /*
  * The table below is used to map from the name of a predefined cursor to its
  * resource identifier.
  */
 
-static struct CursorName {
+static const struct CursorName {
     const char *name;
     LPCTSTR id;
 } cursorNames[] = {
     {"starting",		IDC_APPSTARTING},
     {"arrow",			IDC_ARROW},
@@ -94,19 +94,19 @@
     Tcl_Interp *interp,		/* Interpreter to use for error reporting. */
     Tk_Window tkwin,		/* Window in which cursor will be used. */
     Tk_Uid string)		/* Description of cursor. See manual entry for
 				 * details on legal syntax. */
 {
-    struct CursorName *namePtr;
+    const struct CursorName *namePtr;
     TkWinCursor *cursorPtr;
-    int argc;
+    TkSizeT argc;
     const char **argv = NULL;
     (void)tkwin;
 
     /*
      * All cursor names are valid lists of one element (for
-     * Unix-compatability), even unadorned system cursor names.
+     * Unix-compatibility), even unadorned system cursor names.
      */
 
     if (Tcl_SplitList(interp, string, &argc, &argv) != TCL_OK) {
 	return NULL;
     }

Index: win/tkWinDefault.h
==================================================================
--- win/tkWinDefault.h
+++ win/tkWinDefault.h
@@ -57,10 +57,11 @@
 #define DEF_BUTTON_COMMAND		""
 #define DEF_BUTTON_COMPOUND		"none"
 #define DEF_BUTTON_DEFAULT		"disabled"
 #define DEF_BUTTON_DISABLED_FG_COLOR	DISABLED
 #define DEF_BUTTON_DISABLED_FG_MONO	""
+#define DEF_LABEL_FG			NORMAL_FG
 #define DEF_BUTTON_FG			NORMAL_FG
 #define DEF_CHKRAD_FG			TEXT_FG
 #define DEF_BUTTON_FONT			"TkDefaultFont"
 #define DEF_BUTTON_HEIGHT		"0"
 #define DEF_BUTTON_HIGHLIGHT_BG_COLOR	DEF_BUTTON_BG_COLOR
@@ -89,11 +90,10 @@
 #define DEF_LABEL_TAKE_FOCUS		"0"
 #define DEF_BUTTON_TAKE_FOCUS		NULL
 #define DEF_BUTTON_TEXT			""
 #define DEF_BUTTON_TEXT_VARIABLE	""
 #define DEF_BUTTON_TRISTATE_VALUE	""
-#define DEF_BUTTON_UNDERLINE		"-1"
 #define DEF_BUTTON_VALUE		""
 #define DEF_BUTTON_WIDTH		"0"
 #define DEF_BUTTON_WRAP_LENGTH		"0"
 #define DEF_RADIOBUTTON_VARIABLE	"selectedButton"
 #define DEF_CHECKBUTTON_VARIABLE	""
@@ -268,11 +268,10 @@
 #define DEF_MENU_ENTRY_STATE		"normal"
 #define DEF_MENU_ENTRY_VALUE		NULL
 #define DEF_MENU_ENTRY_CHECK_VARIABLE	NULL
 #define DEF_MENU_ENTRY_RADIO_VARIABLE	"selectedButton"
 #define DEF_MENU_ENTRY_SELECT		NULL
-#define DEF_MENU_ENTRY_UNDERLINE	"-1"
 
 /*
  * Defaults for menus overall:
  */
 
@@ -333,11 +332,10 @@
 #define DEF_MENUBUTTON_RELIEF		"flat"
 #define DEF_MENUBUTTON_STATE		"normal"
 #define DEF_MENUBUTTON_TAKE_FOCUS	"0"
 #define DEF_MENUBUTTON_TEXT		""
 #define DEF_MENUBUTTON_TEXT_VARIABLE	""
-#define DEF_MENUBUTTON_UNDERLINE	"-1"
 #define DEF_MENUBUTTON_WIDTH		"0"
 #define DEF_MENUBUTTON_WRAP_LENGTH	"0"
 
 /*
  * Defaults for messages:

Index: win/tkWinDialog.c
==================================================================
--- win/tkWinDialog.c
+++ win/tkWinDialog.c
@@ -1,11 +1,11 @@
 /*
  * tkWinDialog.c --
  *
  *	Contains the Windows implementation of the common dialog boxes.
  *
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -588,67 +588,11 @@
 static UINT APIENTRY	OFNHookProc(HWND hdlg, UINT uMsg, WPARAM wParam,
 			    LPARAM lParam);
 static LRESULT CALLBACK MsgBoxCBTProc(int nCode, WPARAM wParam, LPARAM lParam);
 static void		SetTkDialog(ClientData clientData);
 static const char *ConvertExternalFilename(LPCWSTR, Tcl_DString *);
-static void             LoadShellProcs(void);
-
-
-/* Definitions of dynamically loaded Win32 calls */
-typedef HRESULT (STDAPICALLTYPE SHCreateItemFromParsingNameProc)(
-    PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void **ppv);
-struct ShellProcPointers {
-    SHCreateItemFromParsingNameProc *SHCreateItemFromParsingName;
-} ShellProcs;
-
-
-/*
- *-------------------------------------------------------------------------
- *
- * LoadShellProcs --
- *
- *     Some shell functions are not available on older versions of
- *     Windows. This function dynamically loads them and stores pointers
- *     to them in ShellProcs. Any function that is not available has
- *     the corresponding pointer set to NULL.
- *
- *     Note this call never fails. Unavailability of a function is not
- *     a reason for failure. Caller should check whether a particular
- *     function pointer is NULL or not. Once loaded a function stays
- *     forever loaded.
- *
- *     XXX - we load the function pointers into global memory. This implies
- *     there is a potential (however small) for race conditions between
- *     threads. However, Tk is in any case meant to be loaded in exactly
- *     one thread so this should not be an issue and saves us from
- *     unnecessary bookkeeping.
- *
- * Return value:
- *     None.
- *
- * Side effects:
- *     ShellProcs is populated.
- *-------------------------------------------------------------------------
- */
-static void LoadShellProcs(void)
-{
-    static HMODULE shell32_handle = NULL;
-
-    if (shell32_handle != NULL) {
-	return; /* We have already been through here. */
-    }
-
-    shell32_handle = GetModuleHandleW(L"shell32.dll");
-    if (shell32_handle == NULL) { /* Should never happen but check anyways. */
-	return;
-    }
-
-    ShellProcs.SHCreateItemFromParsingName = (SHCreateItemFromParsingNameProc*)
-	    (void *)GetProcAddress(shell32_handle, "SHCreateItemFromParsingName");
-}
-
-
+
 /*
  *-------------------------------------------------------------------------
  *
  * EatSpuriousMessageBugFix --
  *
@@ -780,11 +724,11 @@
 	oldColor = RGB(0xa0, 0xa0, 0xa0);
 	inited = 1;
     }
 
     parent			= tkwin;
-    chooseColor.lStructSize	= sizeof(CHOOSECOLOR);
+    chooseColor.lStructSize	= sizeof(CHOOSECOLORW);
     chooseColor.hwndOwner	= NULL;
     chooseColor.hInstance	= NULL;
     chooseColor.rgbResult	= oldColor;
     chooseColor.lpCustColors	= dwCustColors;
     chooseColor.Flags		= CC_RGBINIT | CC_FULLOPEN | CC_ENABLEHOOK;
@@ -798,12 +742,12 @@
 	Tcl_Obj *optionPtr, *valuePtr;
 
 	optionPtr = objv[i];
 	valuePtr = objv[i + 1];
 
-	if (Tcl_GetIndexFromObjStruct(interp, optionPtr, optionStrings,
-		sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) {
+	if (Tcl_GetIndexFromObj(interp, optionPtr, optionStrings,
+		"option", TCL_EXACT, &index) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 	if (i + 1 == objc) {
 	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 		    "value for \"%s\" missing", Tcl_GetString(optionPtr)));
@@ -906,20 +850,20 @@
     LPARAM lParam)		/* Second message parameter. */
 {
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
     const char *title;
-    CHOOSECOLOR *ccPtr;
+    CHOOSECOLORW *ccPtr;
     (void)wParam;
 
     if (WM_INITDIALOG == uMsg) {
 
 	/*
 	 * Set the title string of the dialog.
 	 */
 
-	ccPtr = (CHOOSECOLOR *) lParam;
+	ccPtr = (CHOOSECOLORW *) lParam;
 	title = (const char *) ccPtr->lCustData;
 
 	if ((title != NULL) && (title[0] != '\0')) {
 	    Tcl_DString ds;
 
@@ -1069,11 +1013,11 @@
 	{"-typevariable",	FILE_TYPEVARIABLE},
 	{NULL,			FILE_DEFAULT/*ignored*/ }
     };
     static const struct Options dirOptions[] = {
 	{"-initialdir", FILE_INITDIR},
-        {"-mustexist",  FILE_MUSTEXIST},
+	{"-mustexist",  FILE_MUSTEXIST},
 	{"-parent",	FILE_PARENT},
 	{"-title",	FILE_TITLE},
 	{NULL,		FILE_DEFAULT/*ignored*/ }
     };
 
@@ -1084,11 +1028,11 @@
     case OFN_DIR_CHOOSE: options = dirOptions; break;
     case OFN_FILE_OPEN: options = openOptions; break;
     }
 
     ZeroMemory(optsPtr, sizeof(*optsPtr));
-    // optsPtr->forceXPStyle = 1;
+    /* optsPtr->forceXPStyle = 1; */
     optsPtr->tkwin = (Tk_Window)clientData;
     optsPtr->confirmOverwrite = 1; /* By default we ask for confirmation */
     Tcl_DStringInit(&optsPtr->utfDirString);
     optsPtr->file[0] = 0;
 
@@ -1209,34 +1153,30 @@
     IFileDialog *fdlgPtr = NULL;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
         Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
 
     if (tsdPtr->newFileDialogsState == FDLG_STATE_INIT) {
-        tsdPtr->newFileDialogsState = FDLG_STATE_USE_OLD;
-        LoadShellProcs();
-        if (ShellProcs.SHCreateItemFromParsingName != NULL) {
-            hr = CoInitialize(0);
-            /* XXX - need we schedule CoUninitialize at thread shutdown ? */
-
-            /* Ensure all COM interfaces we use are available */
-            if (SUCCEEDED(hr)) {
-                hr = CoCreateInstance(&ClsidFileOpenDialog, NULL,
-                                      CLSCTX_INPROC_SERVER, &IIDIFileOpenDialog, (void **) &fdlgPtr);
-                if (SUCCEEDED(hr)) {
-                    fdlgPtr->lpVtbl->Release(fdlgPtr);
-                    hr = CoCreateInstance(&ClsidFileSaveDialog, NULL,
-                             CLSCTX_INPROC_SERVER, &IIDIFileSaveDialog,
-                                          (void **) &fdlgPtr);
-                    if (SUCCEEDED(hr)) {
-                        fdlgPtr->lpVtbl->Release(fdlgPtr);
-
-                        /* Looks like we have all we need */
-                        tsdPtr->newFileDialogsState = FDLG_STATE_USE_NEW;
-                    }
-                }
-            }
-        }
+	tsdPtr->newFileDialogsState = FDLG_STATE_USE_OLD;
+	hr = CoInitialize(0);
+	/* XXX - need we schedule CoUninitialize at thread shutdown ? */
+
+	/* Ensure all COM interfaces we use are available */
+	if (SUCCEEDED(hr)) {
+	    hr = CoCreateInstance(&ClsidFileOpenDialog, NULL,
+		    CLSCTX_INPROC_SERVER, &IIDIFileOpenDialog, (void **) &fdlgPtr);
+	    if (SUCCEEDED(hr)) {
+		fdlgPtr->lpVtbl->Release(fdlgPtr);
+		hr = CoCreateInstance(&ClsidFileSaveDialog, NULL,
+			CLSCTX_INPROC_SERVER, &IIDIFileSaveDialog, (void **) &fdlgPtr);
+		if (SUCCEEDED(hr)) {
+		    fdlgPtr->lpVtbl->Release(fdlgPtr);
+
+		    /* Looks like we have all we need */
+		    tsdPtr->newFileDialogsState = FDLG_STATE_USE_NEW;
+		}
+	    }
+	}
     }
 
     return (tsdPtr->newFileDialogsState == FDLG_STATE_USE_NEW);
 }
 
@@ -1411,11 +1351,11 @@
         if (normPath) {
             LPCWSTR nativePath;
             Tcl_IncrRefCount(normPath);
             nativePath = (LPCWSTR)Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/
             if (nativePath) {
-                hr = ShellProcs.SHCreateItemFromParsingName(
+                hr = SHCreateItemFromParsingName(
                     nativePath, NULL,
                     &IIDIShellItem, (void **) &dirIf);
                 if (SUCCEEDED(hr)) {
                     /* Note we use SetFolder, not SetDefaultFolder - see MSDN */
                     fdlgIf->lpVtbl->SetFolder(fdlgIf, dirIf); /* Ignore errors */
@@ -1898,11 +1838,11 @@
 /*
  *-------------------------------------------------------------------------
  *
  * OFNHookProc --
  *
- *	Dialog box hook function. This is used to sets the "tk_dialog"
+ *	Dialog box hook function. This is used to set the "tk_dialog"
  *	variable for test/debugging when the dialog is ready to receive
  *	messages. When multiple file selection is enabled this function
  *	is used to process the list of names.
  *
  * Results:
@@ -2119,11 +2059,11 @@
 	TkSizeT len;
 
 	if (valuePtr == NULL) {
 	    len = 0;
 	} else {
-	    (void) TkGetStringFromObj(valuePtr, &len);
+	    (void) Tcl_GetStringFromObj(valuePtr, &len);
 	}
 
 	/*
 	 * We format the filetype into a string understood by Windows: {"Text
 	 * Documents" {.doc .txt} {TEXT}} becomes "Text Documents
@@ -2709,14 +2649,14 @@
 	 * Not called when user changes edit box directly.
 	 */
 
 	if (SHGetPathFromIDListW((LPITEMIDLIST) lParam, selDir)) {
 	    SendMessageW(hwnd, BFFM_SETSTATUSTEXTW, 0, (LPARAM) selDir);
-	    // enable the OK button
+	    /* enable the OK button */
 	    SendMessageW(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
 	} else {
-	    // disable the OK button
+	    /* disable the OK button */
 	    SendMessageW(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 0);
 	}
 	UpdateWindow(hwnd);
 	return 1;
 
@@ -2777,11 +2717,11 @@
  *
  * Results:
  *	See user documentation.
  *
  * Side effects:
- *	None. The MessageBox window will be destroy before this function
+ *	None. The MessageBox window will be destroyed before this function
  *	returns.
  *
  *----------------------------------------------------------------------
  */
 
@@ -2825,12 +2765,12 @@
 	Tcl_Obj *optionPtr, *valuePtr;
 
 	optionPtr = objv[i];
 	valuePtr = objv[i + 1];
 
-	if (Tcl_GetIndexFromObjStruct(interp, optionPtr, optionStrings,
-		sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) {
+	if (Tcl_GetIndexFromObj(interp, optionPtr, optionStrings,
+		"option", TCL_EXACT, &index) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 	if (i + 1 == objc) {
 	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 		    "value for \"%s\" missing", Tcl_GetString(optionPtr)));
@@ -3149,11 +3089,11 @@
     HWND hwndDlg,
     UINT msg,
     WPARAM wParam,
     LPARAM lParam)
 {
-    CHOOSEFONT *pcf = (CHOOSEFONT *) lParam;
+    CHOOSEFONTW *pcf = (CHOOSEFONTW *) lParam;
     HWND hwndCtrl;
     static HookData *phd = NULL;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
 
@@ -3222,11 +3162,11 @@
  * Helper for the FontchooserConfigure command to return the current value of
  * any of the options (which may be NULL in the structure)
  */
 
 enum FontchooserOption {
-    FontchooserParent, FontchooserTitle, FontchooserFont, FontchooserCmd,
+    FontchooserCmd, FontchooserFont, FontchooserParent, FontchooserTitle,
     FontchooserVisible
 };
 
 static Tcl_Obj *
 FontchooserCget(
@@ -3299,11 +3239,11 @@
 {
     Tk_Window tkwin = (Tk_Window)clientData;
     HookData *hdPtr = NULL;
     int i, r = TCL_OK;
     static const char *const optionStrings[] = {
-	"-parent", "-title", "-font", "-command", "-visible", NULL
+	"-command", "-font", "-parent", "-title", "-visible", NULL
     };
 
     hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
 
     /*
@@ -3326,12 +3266,12 @@
     }
 
     for (i = 1; i < objc; i += 2) {
 	int optionIndex;
 
-	if (Tcl_GetIndexFromObjStruct(interp, objv[i], optionStrings,
-		sizeof(char *),  "option", 0, &optionIndex) != TCL_OK) {
+	if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings,
+		"option", 0, &optionIndex) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 	if (objc == 2) {
 	    /*
 	     * If one option and no arg - return the current value.
@@ -3461,14 +3401,14 @@
 	}
     }
 
     Tk_MakeWindowExist(parent);
 
-    ZeroMemory(&cf, sizeof(CHOOSEFONT));
-    ZeroMemory(&lf, sizeof(LOGFONT));
+    ZeroMemory(&cf, sizeof(CHOOSEFONTW));
+    ZeroMemory(&lf, sizeof(LOGFONTW));
     lf.lfCharSet = DEFAULT_CHARSET;
-    cf.lStructSize = sizeof(CHOOSEFONT);
+    cf.lStructSize = sizeof(CHOOSEFONTW);
     cf.hwndOwner = Tk_GetHWND(Tk_WindowId(parent));
     cf.lpLogFont = &lf;
     cf.nFontType = SCREEN_FONTTYPE;
     cf.Flags = CF_SCREENFONTS | CF_EFFECTS | CF_ENABLEHOOK;
     cf.rgbColors = RGB(0,0,0);

Index: win/tkWinDraw.c
==================================================================
--- win/tkWinDraw.c
+++ win/tkWinDraw.c
@@ -2,12 +2,12 @@
  * tkWinDraw.c --
  *
  *	This file contains the Xlib emulation functions pertaining to actually
  *	drawing objects on a window.
  *
- * Copyright (c) 1995 Sun Microsystems, Inc.
- * Copyright (c) 1994 Software Research Associates, Inc.
+ * Copyright © 1995 Sun Microsystems, Inc.
+ * Copyright © 1994 Software Research Associates, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -584,13 +584,12 @@
 	bitmap = CreateDIBitmap(dc, &infoPtr->bmiHeader, CBM_INIT,
 		image->data, infoPtr, DIB_RGB_COLORS);
 	ckfree(infoPtr);
     }
     if (!bitmap) {
-	Tcl_Panic("Fail to allocate bitmap");
 	DeleteDC(dcMem);
-    	TkWinReleaseDrawableDC(d, dc, &state);
+	TkWinReleaseDrawableDC(d, dc, &state);
 	return BadValue;
     }
     bitmap = (HBITMAP)SelectObject(dcMem, bitmap);
     BitBlt(dc, dest_x, dest_y, (int) width, (int) height, dcMem, src_x, src_y,
 	    SRCCOPY);
@@ -1456,11 +1455,11 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpDrawHighlightBorder --
+ * Tk_DrawHighlightBorder --
  *
  *	This function draws a rectangular ring around the outside of a widget
  *	to indicate that it has received the input focus.
  *
  *      On Windows, we just draw the simple inset ring. On other sytems, e.g.
@@ -1476,11 +1475,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 void
-TkpDrawHighlightBorder(
+Tk_DrawHighlightBorder(
     Tk_Window tkwin,
     GC fgGC,
     GC bgGC,
     int highlightWidth,
     Drawable drawable)

Index: win/tkWinEmbed.c
==================================================================
--- win/tkWinEmbed.c
+++ win/tkWinEmbed.c
@@ -4,11 +4,11 @@
  *	This file contains platform specific procedures for Windows platforms
  *	to provide basic operations needed for application embedding (where
  *	one application can use as its main window an internal window from
  *	another application).
  *
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 1996-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -181,11 +181,11 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpUseWindow --
+ * Tk_UseWindow --
  *
  *	This procedure causes a Tk window to use a given Windows handle for a
  *	window as its underlying window, rather than a new Windows window
  *	being created automatically. It is invoked by an embedded application
  *	to specify the window in which the application is embedded.
@@ -227,11 +227,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 int
-TkpUseWindow(
+Tk_UseWindow(
     Tcl_Interp *interp,		/* If not NULL, used for error reporting if
 				 * string is bogus. */
     Tk_Window tkwin,		/* Tk window that does not yet have an
 				 * associated X window. */
     const char *string)		/* String identifying an X window to use for
@@ -342,11 +342,11 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpMakeContainer --
+ * Tk_MakeContainer --
  *
  *	This procedure is called to indicate that a particular window will be
  *	a container for an embedded application. This changes certain aspects
  *	of the window's behavior, such as whether it will receive events
  *	anymore.
@@ -359,11 +359,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 void
-TkpMakeContainer(
+Tk_MakeContainer(
     Tk_Window tkwin)
 {
     TkWindow *winPtr = (TkWindow *) tkwin;
     Container *containerPtr;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
@@ -887,41 +887,41 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpGetOtherWindow --
+ * Tk_GetOtherWindow --
  *
  *	If both the container and embedded window are in the same process,
  *	this procedure will return either one, given the other.
  *
  * Results:
- *	If winPtr is a container, the return value is the token for the
+ *	If tkwin is a container, the return value is the token for the
  *	embedded window, and vice versa. If the "other" window isn't in this
  *	process, NULL is returned.
  *
  * Side effects:
  *	None.
  *
  *----------------------------------------------------------------------
  */
 
-TkWindow *
-TkpGetOtherWindow(
-    TkWindow *winPtr)		/* Tk's structure for a container or embedded
+Tk_Window
+Tk_GetOtherWindow(
+    Tk_Window tkwin)		/* Tk's structure for a container or embedded
 				 * window. */
 {
     Container *containerPtr;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
 
     for (containerPtr = tsdPtr->firstContainerPtr; containerPtr != NULL;
 	    containerPtr = containerPtr->nextPtr) {
-	if (containerPtr->embeddedPtr == winPtr) {
-	    return containerPtr->parentPtr;
-	} else if (containerPtr->parentPtr == winPtr) {
-	    return containerPtr->embeddedPtr;
+	if ((Tk_Window)containerPtr->embeddedPtr == tkwin) {
+	    return (Tk_Window)containerPtr->parentPtr;
+	} else if ((Tk_Window)containerPtr->parentPtr == tkwin) {
+	    return (Tk_Window)containerPtr->embeddedPtr;
 	}
     }
     return NULL;
 }
 
@@ -1092,12 +1092,12 @@
      * record. The main container may be null. [Bug #476176]
      */
 
     prevPtr = NULL;
     containerPtr = tsdPtr->firstContainerPtr;
-    if (containerPtr == NULL) return;
     while (1) {
+	if (containerPtr == NULL) return;
 	if (containerPtr->embeddedPtr == winPtr) {
 	    containerPtr->embeddedHWnd = NULL;
 	    containerPtr->embeddedPtr = NULL;
 	    break;
 	}

Index: win/tkWinFont.c
==================================================================
--- win/tkWinFont.c
+++ win/tkWinFont.c
@@ -2,13 +2,13 @@
  * tkWinFont.c --
  *
  *	Contains the Windows implementation of the platform-independent font
  *	package interface.
  *
- * Copyright (c) 1994 Software Research Associates, Inc.
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright © 1994 Software Research Associates, Inc.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-1999 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -847,12 +847,12 @@
     for (p = start; p < end; ) {
 	next = p + TkUtfToUniChar(p, &ch);
 	thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr);
 	if (thisSubFontPtr != lastSubFontPtr) {
 	    familyPtr = lastSubFontPtr->familyPtr;
-	    Tcl_UtfToExternalDString(familyPtr->encoding, start,
-		    (int) (p - start), &runString);
+	    (void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, start,
+		    p - start, TCL_ENCODING_NOCOMPLAIN, &runString);
 	    size.cx = 0;
 	    familyPtr->getTextExtentPoint32Proc(hdc,
 		    (WCHAR *)Tcl_DStringValue(&runString),
 		    Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
 		    &size);
@@ -875,12 +875,12 @@
 	 * We get here if the previous loop was just finished normally,
 	 * without a break. Just measure the last run and that's it.
 	 */
 
 	familyPtr = lastSubFontPtr->familyPtr;
-	Tcl_UtfToExternalDString(familyPtr->encoding, start,
-		(int) (p - start), &runString);
+	(void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, start,
+		p - start, TCL_ENCODING_NOCOMPLAIN, &runString);
 	size.cx = 0;
 	familyPtr->getTextExtentPoint32Proc(hdc, (WCHAR *) Tcl_DStringValue(&runString),
 		Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
 		&size);
 	Tcl_DStringFree(&runString);
@@ -1491,13 +1491,13 @@
 	 */
 
 	if ((thisSubFontPtr != lastSubFontPtr) || (p-source > 200)) {
 	    if (p > source) {
 		familyPtr = lastSubFontPtr->familyPtr;
- 		Tcl_UtfToExternalDString(familyPtr->encoding, source,
-			(int) (p - source), &runString);
-		familyPtr->textOutProc(hdc, x-((double)tm.tmOverhang/2), y,
+		(void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, source,
+			p - source, TCL_ENCODING_NOCOMPLAIN, &runString);
+		familyPtr->textOutProc(hdc, (int)(x-(double)tm.tmOverhang/2.0), y,
 			(WCHAR *)Tcl_DStringValue(&runString),
 			Tcl_DStringLength(&runString) >> familyPtr->isWideFont);
 		familyPtr->getTextExtentPoint32Proc(hdc,
 			(WCHAR *)Tcl_DStringValue(&runString),
 			Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
@@ -1513,13 +1513,13 @@
 	}
 	p = next;
     }
     if (p > source) {
 	familyPtr = lastSubFontPtr->familyPtr;
- 	Tcl_UtfToExternalDString(familyPtr->encoding, source,
-		(int) (p - source), &runString);
-	familyPtr->textOutProc(hdc, x-((double)tm.tmOverhang/2), y,
+	(void)Tcl_UtfToExternalDStringEx(familyPtr->encoding, source,
+		p - source, TCL_ENCODING_NOCOMPLAIN, &runString);
+	familyPtr->textOutProc(hdc, (int)(x-(double)tm.tmOverhang/2.0), y,
 		(WCHAR *)Tcl_DStringValue(&runString),
 		Tcl_DStringLength(&runString) >> familyPtr->isWideFont);
 	Tcl_DStringFree(&runString);
     }
     SelectObject(hdc, oldFont);
@@ -2730,11 +2730,11 @@
 				 * range information. */
     USHORT **endCountPtr,	/* Filled with malloced pointer to character
 				 * range information. */
     int *symbolPtr)
  {
-    int n, i, swapped, offset, cbData, segCount;
+    int n, i, j, k, swapped, offset, cbData, segCount;
     DWORD cmapKey;
     USHORT *startCount, *endCount;
     CMAPTABLE cmapTable;
     ENCODINGTABLE encTable;
     SUBTABLE subTable;
@@ -2806,13 +2806,13 @@
 		offset = encTable.offset + sizeof(subTable.segment);
 		GetFontData(hdc, cmapKey, (DWORD) offset, endCount, cbData);
 		offset += cbData + sizeof(USHORT);
 		GetFontData(hdc, cmapKey, (DWORD) offset, startCount, cbData);
 		if (swapped) {
-		    for (i = 0; i < segCount; i++) {
-			SwapShort(&endCount[i]);
-			SwapShort(&startCount[i]);
+		    for (j = 0; j < segCount; j++) {
+			SwapShort(&endCount[j]);
+			SwapShort(&startCount[j]);
 		    }
 		}
 		if (*symbolPtr != 0) {
 		    /*
 		     * Empirically determined: When a symbol font is loaded,
@@ -2824,15 +2824,15 @@
 		     *
 		     * Symbol fonts should only use the symbol encoding for
 		     * 8-bit characters [note Bug: 2406]
 		     */
 
-		    for (i = 0; i < segCount; i++) {
-			if (((startCount[i] & 0xff00) == 0xf000)
-				&& ((endCount[i] & 0xff00) == 0xf000)) {
-			    startCount[i] &= 0xff;
-			    endCount[i] &= 0xff;
+		    for (k = 0; k < segCount; k++) {
+			if (((startCount[k] & 0xff00) == 0xf000)
+				&& ((endCount[k] & 0xff00) == 0xf000)) {
+			    startCount[k] &= 0xff;
+			    endCount[k] &= 0xff;
 			}
 		    }
 		}
 	    }
 	}

ADDED   win/tkWinGDI.c
Index: win/tkWinGDI.c
==================================================================
--- /dev/null
+++ win/tkWinGDI.c
@@ -0,0 +1,3893 @@
+/*
+ * tkWinGDI.c --
+ *
+ *      This module implements access to the Win32 GDI API.
+ *
+ * Copyright © 1991-2018 Microsoft Corp.
+ * Copyright © 2009, Michael I. Schwartz.
+ * Copyright © 1998-2019 Harald Oehlmann, Elmicron GmbH
+ * Copyright © 2021 Kevin Walzer/WordTech Communications LLC.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+
+#include <windows.h>
+#include <stdlib.h>
+#include <math.h>
+#include <wtypes.h>
+#include <winspool.h>
+#include <commdlg.h>
+#include <wingdi.h>
+
+#include <tcl.h>
+
+#include "tkWinInt.h"
+
+/*
+ * Create a standard "DrawFunc" to make this more workable....
+ */
+#ifdef _MSC_VER
+typedef BOOL (WINAPI *DrawFunc) (
+	HDC, int, int, int, int, int, int, int, int); /* Arc, Chord, Pie. */
+#else
+typedef BOOL WINAPI (*DrawFunc) (
+	HDC, int, int, int, int, int, int, int, int); /* Arc, Chord, Pie. */
+#endif
+
+/* Real functions. */
+static int		GdiArc(ClientData clientData, Tcl_Interp *interp,
+			    int argc, const char **argv);
+static int		GdiBitmap(ClientData clientData, Tcl_Interp *interp,
+			    int argc, const char **argv);
+static int		GdiCharWidths(ClientData clientData,
+			    Tcl_Interp *interp, int argc, const char **argv);
+static int		GdiImage(ClientData clientData, Tcl_Interp *interp,
+			    int argc, const char **argv);
+static int		GdiPhoto(ClientData clientData, Tcl_Interp *interp,
+			    int argc, const char **argv);
+static int		GdiLine(ClientData clientData, Tcl_Interp *interp,
+			    int argc, const char **argv);
+static int		GdiOval(ClientData clientData, Tcl_Interp *interp,
+			    int argc, const char **argv);
+static int		GdiPolygon(ClientData clientData, Tcl_Interp *interp,
+			    int argc, const char **argv);
+static int		GdiRectangle(ClientData clientData, Tcl_Interp *interp,
+			    int argc, const char **argv);
+static int		GdiText(ClientData clientData, Tcl_Interp *interp,
+			    int argc, const char **argv);
+static int		GdiMap(ClientData clientData, Tcl_Interp *interp,
+			    int argc, const char **argv);
+static int		GdiCopyBits(ClientData clientData, Tcl_Interp *interp,
+			    int argc, const char **argv);
+
+/* Local copies of similar routines elsewhere in Tcl/Tk. */
+static int		GdiGetColor(const char *name, COLORREF *color);
+
+/*
+ * Helper functions.
+ */
+static int		GdiMakeLogFont(Tcl_Interp *interp, const char *str,
+			    LOGFONTW *lf, HDC hDC);
+static int		GdiMakePen(Tcl_Interp *interp, int width,
+			    int dashstyle, const char *dashstyledata,
+			    int capstyle, int joinstyle,
+			    int stipplestyle, const char *stippledata,
+			    unsigned long color, HDC hDC, HGDIOBJ *oldPen);
+static int		GdiFreePen(Tcl_Interp *interp, HDC hDC, HGDIOBJ oldPen);
+static int		GdiMakeBrush(Tcl_Interp *interp, unsigned int style,
+			    unsigned long color, long hatch, LOGBRUSH *lb,
+			    HDC hDC, HGDIOBJ *oldBrush);
+static int		GdiFreeBrush(Tcl_Interp *interp, HDC hDC,
+			    HGDIOBJ oldBcrush);
+static int		GdiGetHdcInfo(HDC hdc,
+			    LPPOINT worigin, LPSIZE wextent,
+			    LPPOINT vorigin, LPSIZE vextent);
+
+/* Helper functions for printing the window client area. */
+enum PrintType { PTWindow = 0, PTClient = 1, PTScreen = 2 };
+
+static HANDLE		CopyToDIB(HWND wnd, enum PrintType type);
+static HBITMAP		CopyScreenToBitmap(LPRECT lpRect);
+static HANDLE		BitmapToDIB(HBITMAP hb, HPALETTE hp);
+static HANDLE		CopyScreenToDIB(LPRECT lpRect);
+static int		DIBNumColors(LPBITMAPINFOHEADER lpDIB);
+static int		PalEntriesOnDevice(HDC hDC);
+static HPALETTE		GetSystemPalette(void);
+static void		GetDisplaySize(LONG *width, LONG *height);
+static int		GdiWordToWeight(const char *str);
+static int		GdiParseFontWords(Tcl_Interp *interp, LOGFONTW *lf,
+			    const char *str[], int numargs);
+static int		PrintSelectPrinter(ClientData clientData,
+			    Tcl_Interp *interp, int objc,
+			    Tcl_Obj *const objv[]);
+static int		PrintOpenPrinter(ClientData clientData,
+			    Tcl_Interp *interp, int objc,
+			    Tcl_Obj *const objv[]);
+static int		PrintClosePrinter(ClientData clientData,
+			    Tcl_Interp *interp, int objc,
+			    Tcl_Obj *const objv[]);
+static int		PrintOpenDoc(ClientData clientData, Tcl_Interp *interp,
+			    int objc, Tcl_Obj *const objv[]);
+static int		PrintCloseDoc(ClientData clientData, Tcl_Interp *interp,
+			    int objc, Tcl_Obj *const objv[]);
+static int		PrintOpenPage(ClientData clientData, Tcl_Interp *interp,
+			    int objc, Tcl_Obj *const objv[]);
+static int		PrintClosePage(ClientData clientData,
+			    Tcl_Interp *interp, int objc,
+			    Tcl_Obj *const objv[]);
+
+/*
+ * Global state.
+ */
+
+static PRINTDLGW pd;
+static DOCINFOW di;
+static WCHAR *localPrinterName = NULL;
+static int copies, paper_width, paper_height, dpi_x, dpi_y;
+static LPDEVNAMES devnames;
+static HDC printDC;
+
+/*
+ * To make the "subcommands" follow a standard convention, add them to this
+ * array. The first element is the subcommand name, and the second a standard
+ * Tcl command handler.
+ */
+
+static const struct gdi_command {
+    const char *command_string;
+    Tcl_CmdProc *command;
+} gdi_commands[] = {
+    { "arc",        GdiArc },
+    { "bitmap",     GdiBitmap },
+    { "characters", GdiCharWidths },
+    { "image",      GdiImage },
+    { "line",       GdiLine },
+    { "map",        GdiMap },
+    { "oval",       GdiOval },
+    { "photo",      GdiPhoto },
+    { "polygon",    GdiPolygon },
+    { "rectangle",  GdiRectangle },
+    { "text",       GdiText },
+    { "copybits",   GdiCopyBits },
+};
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiArc --
+ *
+ * 	Map canvas arcs to GDI context.
+ *
+ * Results:
+ *	Renders arcs.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiArc(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    int argc,
+    const char **argv)
+{
+    static const char usage_message[] =
+	"::tk::print::_gdi arc hdc x1 y1 x2 y2 "
+	"-extent angle -start angle -style arcstyle "
+	"-fill color -outline color "
+	"-width dimension -dash dashrule "
+	"-outlinestipple ignored -stipple ignored\n" ;
+    int x1, y1, x2, y2;
+    int xr0, yr0, xr1, yr1;
+    HDC hDC;
+    double extent = 0.0, start = 0.0;
+    DrawFunc drawfunc;
+    int width = 0;
+    HPEN hPen;
+    COLORREF linecolor = 0, fillcolor = BS_NULL;
+    int dolinecolor = 0, dofillcolor = 0;
+    HBRUSH hBrush;
+    LOGBRUSH lbrush;
+    HGDIOBJ oldobj;
+    int dodash = 0;
+    const char *dashdata = 0;
+
+    drawfunc = Pie;
+
+    /* Verrrrrry simple for now.... */
+    if (argc < 6) {
+	Tcl_AppendResult(interp, usage_message, NULL);
+	return TCL_ERROR;
+    }
+
+    hDC = printDC;
+
+    x1 = atoi(argv[2]);
+    y1 = atoi(argv[3]);
+    x2 = atoi(argv[4]);
+    y2 = atoi(argv[5]);
+
+    argc -= 6;
+    argv += 6;
+    while (argc >= 2) {
+	if (strcmp(argv[0], "-extent") == 0) {
+	    extent = atof(argv[1]);
+	} else if (strcmp(argv[0], "-start") == 0) {
+	    start = atof(argv[1]);
+	} else if (strcmp(argv[0], "-style") == 0) {
+	    if (strcmp(argv[1], "pieslice") == 0) {
+		drawfunc = Pie;
+	    } else if (strcmp(argv[1], "arc") == 0) {
+		drawfunc = Arc;
+	    } else if (strcmp(argv[1], "chord") == 0) {
+		drawfunc = Chord;
+	    }
+	} else if (strcmp(argv[0], "-fill") == 0) {
+	    /* Handle all args, even if we don't use them yet. */
+	    if (GdiGetColor(argv[1], &fillcolor)) {
+		dofillcolor = 1;
+	    }
+	} else if (strcmp(argv[0], "-outline") == 0) {
+	    if (GdiGetColor(argv[1], &linecolor)) {
+		dolinecolor = 1;
+	    }
+	} else if (strcmp(argv[0], "-outlinestipple") == 0) {
+	    /* ignored */
+	} else if (strcmp(argv[0], "-stipple") == 0) {
+	    /* ignored */
+	} else if (strcmp(argv[0], "-width") == 0) {
+	    width = atoi(argv[1]);
+	} else if (strcmp(argv[0], "-dash") == 0) {
+	    if (argv[1]) {
+		dodash = 1;
+		dashdata = argv[1];
+	    }
+	} else {
+	    /* Don't know that option! */
+	    Tcl_AppendResult(interp, usage_message, NULL);
+	    return TCL_ERROR;
+	}
+	argc -= 2;
+	argv += 2;
+    }
+    xr0 = xr1 = (x1 + x2) / 2;
+    yr0 = yr1 = (y1 + y2) / 2;
+
+    /*
+     * The angle used by the arc must be "warped" by the eccentricity of the
+     * ellipse.  Thanks to Nigel Dodd <nigel.dodd@avellino.com> for bringing a
+     * nice example.
+     */
+
+    xr0 += (int)(100.0 * (x2 - x1) * cos((start * 2.0 * 3.14159265) / 360.0));
+    yr0 -= (int)(100.0 * (y2 - y1) * sin((start * 2.0 * 3.14159265) / 360.0));
+    xr1 += (int)(100.0 * (x2 - x1) * cos(((start+extent) * 2.0 * 3.14159265) / 360.0));
+    yr1 -= (int)(100.0 * (y2 - y1) * sin(((start+extent) * 2.0 * 3.14159265) / 360.0));
+
+    /*
+     * Under Win95, SetArcDirection isn't implemented--so we have to assume
+     * that arcs are drawn counterclockwise (e.g., positive extent) So if it's
+     * negative, switch the coordinates!
+     */
+
+    if (extent < 0) {
+	int xr2 = xr0;
+	int yr2 = yr0;
+
+	xr0 = xr1;
+	xr1 = xr2;
+	yr0 = yr1;
+	yr1 = yr2;
+    }
+
+    if (dofillcolor) {
+	GdiMakeBrush(interp, 0, fillcolor, 0, &lbrush, hDC, (HGDIOBJ *)&hBrush);
+    } else {
+	oldobj = SelectObject(hDC, GetStockObject(HOLLOW_BRUSH));
+    }
+
+    if (width || dolinecolor) {
+	GdiMakePen(interp, width, dodash, dashdata,
+		0, 0, 0, 0, linecolor, hDC, (HGDIOBJ *)&hPen);
+    }
+
+    (*drawfunc)(hDC, x1, y1, x2, y2, xr0, yr0, xr1, yr1);
+
+    if (width || dolinecolor) {
+	GdiFreePen(interp, hDC, hPen);
+    }
+    if (dofillcolor) {
+	GdiFreeBrush(interp, hDC, hBrush);
+    } else {
+	SelectObject(hDC, oldobj);
+    }
+
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiBitmap --
+ *
+ * 	Unimplemented for now. Should use the same techniques as
+ * 	CanvasPsBitmap (tkCanvPs.c).
+ *
+ * Results:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiBitmap(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    TCL_UNUSED(int),
+    TCL_UNUSED(const char **))
+{
+    static const char usage_message[] =
+	"::tk::print::_gdi bitmap hdc x y "
+	"-anchor [center|n|e|s|w] -background color "
+	"-bitmap bitmap -foreground color\n"
+	"Not implemented yet. Sorry!";
+
+    /*
+     * Skip this for now. Should be based on common code with the copybits
+     * command.
+     */
+
+    Tcl_AppendResult(interp, usage_message, NULL);
+    return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiImage --
+ *
+ *	Unimplemented for now. Unimplemented for now. Should switch on image
+ *	type and call either GdiPhoto or GdiBitmap. This code is similar to
+ *	that in tkWinImage.c.
+ *
+ * Results:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiImage(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    TCL_UNUSED(int),
+    TCL_UNUSED(const char **))
+{
+    static const char usage_message[] =
+	"::tk::print::_gdi image hdc x y -anchor [center|n|e|s|w] -image name\n"
+	"Not implemented yet. Sorry!";
+
+    /* Skip this for now..... */
+    /* Should be based on common code with the copybits command. */
+
+    Tcl_AppendResult(interp, usage_message, NULL);
+    /* Normally, usage results in TCL_ERROR--but wait til' it's implemented. */
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiPhoto --
+ *
+ *	Contributed by Lukas Rosenthaler <lukas.rosenthaler@balcab.ch>
+ *
+ *	Note: The canvas doesn't directly support photos (only as images), so
+ *	this is the first ::tk::print::_gdi command without an equivalent
+ *	canvas command.  This code may be modified to support photo images on
+ *	the canvas.
+ *
+ * Results:
+ *	Renders a photo.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiPhoto(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    int argc,
+    const char **argv)
+{
+    static const char usage_message[] =
+	"::tk::print::_gdi photo hdc [-destination x y [w [h]]] -photo name\n";
+    HDC dst;
+    int dst_x = 0, dst_y = 0, dst_w = 0, dst_h = 0;
+    int nx, ny, sll;
+    const char *photoname = 0;	/* For some reason Tk_FindPhoto takes a char *. */
+    Tk_PhotoHandle photo_handle;
+    Tk_PhotoImageBlock img_block;
+    BITMAPINFO bitmapinfo;	/* Since we don't need the bmiColors table,
+				 * there is no need for dynamic allocation. */
+    int oldmode;		/* For saving the old stretch mode. */
+    POINT pt;			/* For saving the brush org. */
+    char *pbuf = NULL;
+    int i, j, k;
+    int retval = TCL_OK;
+
+    /*
+     * Parse the arguments.
+     */
+
+    /* HDC is required. */
+    if (argc < 2) {
+	Tcl_AppendResult(interp, usage_message, NULL);
+	return TCL_ERROR;
+    }
+
+    dst = printDC;
+
+    /*
+     * Next, check to see if 'dst' can support BitBlt.
+     * If not, raise an error.
+     */
+
+    if ((GetDeviceCaps(dst, RASTERCAPS) & RC_STRETCHDIB) == 0) {
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"::tk::print::_gdi photo not supported on device context (0x%s)",
+		argv[1]));
+	return TCL_ERROR;
+    }
+
+    /* Parse the command line arguments. */
+    for (j = 2; j < argc; j++) {
+	if (strcmp(argv[j], "-destination") == 0) {
+	    double x, y, w, h;
+	    int count = 0;
+	    char dummy;
+
+	    if (j < argc) {
+		count = sscanf(argv[++j], "%lf%lf%lf%lf%c",
+			&x, &y, &w, &h, &dummy);
+	    }
+
+	    if (count < 2 || count > 4) {
+		/* Destination must provide at least 2 arguments. */
+		Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+			"-destination requires a list of 2 to 4 numbers\n%s",
+			usage_message));
+		return TCL_ERROR;
+	    }
+
+	    dst_x = (int) x;
+	    dst_y = (int) y;
+	    if (count == 3) {
+		dst_w = (int) w;
+		dst_h = -1;
+	    } else if (count == 4) {
+		dst_w = (int) w;
+		dst_h = (int) h;
+	    }
+	} else if (strcmp(argv[j], "-photo") == 0) {
+	    photoname = argv[++j];
+	}
+    }
+
+    if (photoname == 0) {	/* No photo provided. */
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"No photo name provided to ::tk::print::_gdi photo\n%s",
+		usage_message));
+	return TCL_ERROR;
+    }
+
+    photo_handle = Tk_FindPhoto(interp, photoname);
+    if (photo_handle == 0) {
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"::tk::print::_gdi photo: Photo name %s can't be located\n%s",
+		photoname, usage_message));
+	return TCL_ERROR;
+    }
+    Tk_PhotoGetImage(photo_handle, &img_block);
+
+    nx  = img_block.width;
+    ny  = img_block.height;
+    sll = ((3*nx + 3) / 4)*4; /* Must be multiple of 4. */
+
+    /*
+     * Buffer is potentially large enough that failure to allocate might be
+     * recoverable.
+     */
+
+    pbuf = (char *) Tcl_AttemptAlloc(sll * ny * sizeof(char));
+    if (pbuf == 0) { /* Memory allocation failure. */
+	Tcl_AppendResult(interp,
+		"::tk::print::_gdi photo failed--out of memory", NULL);
+	return TCL_ERROR;
+    }
+
+    /* After this, all returns must go through retval. */
+
+    /* BITMAP expects BGR; photo provides RGB. */
+    for (k = 0; k < ny; k++) {
+	for (i = 0; i < nx; i++) {
+	    pbuf[k*sll + 3*i] = img_block.pixelPtr[
+		    k*img_block.pitch + i*img_block.pixelSize + img_block.offset[2]];
+	    pbuf[k*sll + 3*i + 1] = img_block.pixelPtr[
+		    k*img_block.pitch + i*img_block.pixelSize + img_block.offset[1]];
+	    pbuf[k*sll + 3*i + 2] = img_block.pixelPtr[
+		    k*img_block.pitch + i*img_block.pixelSize + img_block.offset[0]];
+	}
+    }
+
+    memset(&bitmapinfo, 0L, sizeof(BITMAPINFO));
+
+    bitmapinfo.bmiHeader.biSize          = sizeof(BITMAPINFOHEADER);
+    bitmapinfo.bmiHeader.biWidth         = nx;
+    bitmapinfo.bmiHeader.biHeight        = -ny;
+    bitmapinfo.bmiHeader.biPlanes        = 1;
+    bitmapinfo.bmiHeader.biBitCount      = 24;
+    bitmapinfo.bmiHeader.biCompression   = BI_RGB;
+    bitmapinfo.bmiHeader.biSizeImage     = 0; /* sll*ny;. */
+    bitmapinfo.bmiHeader.biXPelsPerMeter = 0;
+    bitmapinfo.bmiHeader.biYPelsPerMeter = 0;
+    bitmapinfo.bmiHeader.biClrUsed       = 0;
+    bitmapinfo.bmiHeader.biClrImportant  = 0;
+
+    oldmode = SetStretchBltMode(dst, HALFTONE);
+    /*
+     * According to the Win32 Programmer's Manual, we have to set the brush
+     * org, now.
+     */
+    SetBrushOrgEx(dst, 0, 0, &pt);
+
+    if (dst_w <= 0) {
+	dst_w = nx;
+	dst_h = ny;
+    } else if (dst_h <= 0) {
+	dst_h = ny*dst_w / nx;
+    }
+
+    if (StretchDIBits(dst, dst_x, dst_y, dst_w, dst_h, 0, 0, nx, ny,
+	    pbuf, &bitmapinfo, DIB_RGB_COLORS, SRCCOPY) == (int)GDI_ERROR) {
+	int errcode = GetLastError();
+
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"::tk::print::_gdi photo internal failure: "
+		"StretchDIBits error code %d", errcode));
+	retval = TCL_ERROR;
+    }
+
+    /* Clean up the hDC. */
+    if (oldmode != 0) {
+	SetStretchBltMode(dst, oldmode);
+	SetBrushOrgEx(dst, pt.x, pt.y, &pt);
+    }
+
+    Tcl_Free(pbuf);
+
+    if (retval == TCL_OK) {
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"%d %d %d %d", dst_x, dst_y, dst_w, dst_h));
+    }
+
+    return retval;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Bezierize --
+ *
+ *	Interface to Tk's line smoother, used for lines and pollies.
+ *	Provided by Jasper Taylor <jasper.taylor@ed.ac.uk>.
+ *
+ * Results:
+ *	Smooths lines.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int Bezierize(
+    POINT* polypoints,
+    int npoly,
+    int nStep,
+    POINT* bpointptr)
+{
+    /* First, translate my points into a list of doubles. */
+    double *inPointList, *outPointList;
+    int n;
+    int nbpoints = 0;
+    POINT* bpoints;
+
+    inPointList = (double *) Tcl_AttemptAlloc(2 * sizeof(double) * npoly);
+    if (inPointList == 0) {
+	/* TODO: unreachable */
+        return nbpoints; /* 0. */
+    }
+
+    for (n=0; n<npoly; n++) {
+        inPointList[2*n] = polypoints[n].x;
+        inPointList[2*n + 1] = polypoints[n].y;
+    }
+
+    nbpoints = 1 + npoly * nStep; /* this is the upper limit. */
+    outPointList = (double *) Tcl_AttemptAlloc(2 * sizeof(double) * nbpoints);
+    if (outPointList == 0) {
+	/* TODO: unreachable */
+        Tcl_Free((void *) inPointList);
+        return 0;
+    }
+
+    nbpoints = TkMakeBezierCurve(NULL, inPointList, npoly, nStep,
+	    NULL, outPointList);
+
+    Tcl_Free((void *) inPointList);
+    bpoints = (POINT *) Tcl_AttemptAlloc(sizeof(POINT)*nbpoints);
+    if (bpoints == 0) {
+	/* TODO: unreachable */
+        Tcl_Free((void *) outPointList);
+        return 0;
+    }
+
+    for (n=0; n<nbpoints; n++) {
+        bpoints[n].x = (long) outPointList[2*n];
+        bpoints[n].y = (long) outPointList[2*n + 1];
+    }
+    Tcl_Free((void *) outPointList);
+    *bpointptr = *bpoints;
+    return nbpoints;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiLine --
+ *
+ *	Maps lines to GDI context.
+ *
+ * Results:
+ *	Renders lines.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiLine(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    int argc,
+    const char **argv)
+{
+    static const char usage_message[] =
+	"::tk::print::_gdi line hdc x1 y1 ... xn yn "
+	"-arrow [first|last|both|none] -arrowshape {d1 d2 d3} "
+	"-dash dashlist "
+	"-capstyle [butt|projecting|round] -fill color "
+	"-joinstyle [bevel|miter|round] -smooth [true|false|bezier] "
+	"-splinesteps number -stipple bitmap -width linewid";
+    char *strend;
+    POINT *polypoints;
+    int npoly;
+    int x, y;
+    HDC hDC;
+    HPEN hPen;
+
+    LOGBRUSH lbrush;
+    HBRUSH hBrush;
+
+    int width          = 0;
+    COLORREF linecolor = 0;
+    int dolinecolor    = 0;
+    int dosmooth       = 0;
+    int doarrow        = 0; /* 0=none; 1=end; 2=start; 3=both. */
+    int arrowshape[3];
+
+    int nStep = 12;
+
+    int dodash = 0;
+    const char *dashdata = 0;
+
+    arrowshape[0] = 8;
+    arrowshape[1] = 10;
+    arrowshape[2] = 3;
+
+    /* Verrrrrry simple for now.... */
+    if (argc < 6) {
+	Tcl_AppendResult(interp, usage_message, NULL);
+	return TCL_ERROR;
+    }
+
+    hDC = printDC;
+
+    polypoints = (POINT *) Tcl_AttemptAlloc((argc - 1) * sizeof(POINT));
+    if (polypoints == 0) {
+	Tcl_AppendResult(interp, "Out of memory in GdiLine", NULL);
+	return TCL_ERROR;
+    }
+    polypoints[0].x = atol(argv[2]);
+    polypoints[0].y = atol(argv[3]);
+    polypoints[1].x = atol(argv[4]);
+    polypoints[1].y = atol(argv[5]);
+    argc -= 6;
+    argv += 6;
+    npoly = 2;
+
+    while (argc >= 2) {
+	/* Check for a number. */
+	x = strtoul(argv[0], &strend, 0);
+	if (strend > argv[0]) {
+	    /* One number.... */
+	    y = strtoul(argv[1], &strend, 0);
+	    if (strend > argv[1]) {
+		/* TWO numbers!. */
+		polypoints[npoly].x = x;
+		polypoints[npoly].y = y;
+		npoly++;
+		argc -= 2;
+		argv += 2;
+	    } else {
+		/* Only one number... Assume a usage error. */
+		Tcl_Free((void *)polypoints);
+		Tcl_AppendResult(interp, usage_message, NULL);
+		return TCL_ERROR;
+	    }
+	} else {
+	    if (strcmp(*argv, "-arrow") == 0) {
+		if (strcmp(argv[1], "none") == 0) {
+		    doarrow = 0;
+		} else if (strcmp(argv[1], "both") == 0) {
+		    doarrow = 3;
+		} else if (strcmp(argv[1], "first") == 0) {
+		    doarrow = 2;
+		} else if (strcmp(argv[1], "last") == 0) {
+		    doarrow = 1;
+		}
+		argv += 2;
+		argc -= 2;
+	    } else if (strcmp(*argv, "-arrowshape") == 0) {
+		/* List of 3 numbers--set arrowshape array. */
+		int a1, a2, a3;
+		char dummy;
+
+		if (sscanf(argv[1], "%d%d%d%c", &a1, &a2, &a3, &dummy) == 3
+			&& a1 > 0 && a2 > 0 && a3 > 0) {
+		    arrowshape[0] = a1;
+		    arrowshape[1] = a2;
+		    arrowshape[2] = a3;
+		}
+		/* Else the argument was bad. */
+
+		argv += 2;
+		argc -= 2;
+	    } else if (strcmp(*argv, "-capstyle") == 0) {
+		argv += 2;
+		argc -= 2;
+	    } else if (strcmp(*argv, "-fill") == 0) {
+		if (GdiGetColor(argv[1], &linecolor)) {
+		    dolinecolor = 1;
+		}
+		argv += 2;
+		argc -= 2;
+	    } else if (strcmp(*argv, "-joinstyle") == 0) {
+		argv += 2;
+		argc -= 2;
+	    } else if (strcmp(*argv, "-smooth") == 0) {
+		/* Argument is true/false or 1/0 or bezier. */
+		if (argv[1]) {
+		    switch (argv[1][0]) {
+		    case 't': case 'T':
+		    case '1':
+		    case 'b': case 'B': /* bezier. */
+			dosmooth = 1;
+			break;
+		    default:
+			dosmooth = 0;
+			break;
+		    }
+		    argv += 2;
+		    argc -= 2;
+		}
+	    } else if (strcmp(*argv, "-splinesteps") == 0) {
+		nStep = atoi(argv[1]);
+		argv += 2;
+		argc -= 2;
+	    } else if (strcmp(*argv, "-dash") == 0) {
+		if (argv[1]) {
+		    dodash = 1;
+		    dashdata = argv[1];
+		}
+		argv += 2;
+		argc -= 2;
+	    } else if (strcmp(*argv, "-dashoffset") == 0) {
+		argv += 2;
+		argc -= 2;
+	    } else if (strcmp(*argv, "-stipple") == 0) {
+		argv += 2;
+		argc -= 2;
+	    } else if (strcmp(*argv, "-width") == 0) {
+		width = atoi(argv[1]);
+		argv += 2;
+		argc -= 2;
+	    } else { /* It's an unknown argument!. */
+		argc--;
+		argv++;
+	    }
+	    /* Check for arguments
+	     * Most of the arguments affect the "Pen"
+	     */
+	}
+    }
+
+    if (width || dolinecolor || dodash) {
+	GdiMakePen(interp, width, dodash, dashdata,
+		0, 0, 0, 0, linecolor, hDC, (HGDIOBJ *)&hPen);
+    }
+    if (doarrow != 0) {
+	GdiMakeBrush(interp, 0, linecolor, 0, &lbrush, hDC, (HGDIOBJ *)&hBrush);
+    }
+
+    if (dosmooth) { /* Use PolyBezier. */
+	int nbpoints;
+	POINT *bpoints = 0;
+
+	nbpoints = Bezierize(polypoints,npoly,nStep,bpoints);
+	if (nbpoints > 0) {
+	    Polyline(hDC, bpoints, nbpoints);
+	} else {
+	    Polyline(hDC, polypoints, npoly); /* Out of memory? Just draw a regular line. */
+	}
+	if (bpoints != 0) {
+	    Tcl_Free((void *)bpoints);
+	}
+    } else {
+	Polyline(hDC, polypoints, npoly);
+    }
+
+    if (dodash && doarrow) {  /* Don't use dashed or thick pen for the arrows! */
+	GdiFreePen(interp, hDC, hPen);
+	GdiMakePen(interp, width, 0, 0, 0, 0, 0, 0,
+		linecolor, hDC, (HGDIOBJ *)&hPen);
+    }
+
+    /* Now the arrowheads, if any. */
+    if (doarrow & 1) {
+	/* Arrowhead at end = polypoints[npoly-1].x, polypoints[npoly-1].y. */
+	POINT ahead[6];
+	double dx, dy, length;
+	double sinTheta, cosTheta;
+	double vertX, vertY, temp;
+	double fracHeight;
+
+	fracHeight = 2.0 / arrowshape[2];
+
+	ahead[0].x = ahead[5].x = polypoints[npoly-1].x;
+	ahead[0].y = ahead[5].y = polypoints[npoly-1].y;
+	dx = ahead[0].x - polypoints[npoly-2].x;
+	dy = ahead[0].y - polypoints[npoly-2].y;
+	if ((length = hypot(dx, dy)) == 0) {
+	    sinTheta = cosTheta = 0.0;
+	} else {
+	    sinTheta = dy / length;
+	    cosTheta = dx / length;
+	}
+	vertX = ahead[0].x - arrowshape[0]*cosTheta;
+	vertY = ahead[0].y - arrowshape[0]*sinTheta;
+	temp = arrowshape[2]*sinTheta;
+	ahead[1].x = (long)(ahead[0].x - arrowshape[1]*cosTheta + temp);
+	ahead[4].x = (long)(ahead[1].x - 2 * temp);
+	temp = arrowshape[2]*cosTheta;
+	ahead[1].y = (long)(ahead[0].y - arrowshape[1]*sinTheta - temp);
+	ahead[4].y = (long)(ahead[1].y + 2 * temp);
+	ahead[2].x = (long)(ahead[1].x*fracHeight + vertX*(1.0-fracHeight));
+	ahead[2].y = (long)(ahead[1].y*fracHeight + vertY*(1.0-fracHeight));
+	ahead[3].x = (long)(ahead[4].x*fracHeight + vertX*(1.0-fracHeight));
+	ahead[3].y = (long)(ahead[4].y*fracHeight + vertY*(1.0-fracHeight));
+
+	Polygon(hDC, ahead, 6);
+    }
+
+    if (doarrow & 2) {
+	/* Arrowhead at end = polypoints[0].x, polypoints[0].y. */
+	POINT ahead[6];
+	double dx, dy, length;
+	double sinTheta, cosTheta;
+	double vertX, vertY, temp;
+	double fracHeight;
+
+	fracHeight = 2.0 / arrowshape[2];
+
+	ahead[0].x = ahead[5].x = polypoints[0].x;
+	ahead[0].y = ahead[5].y = polypoints[0].y;
+	dx = ahead[0].x - polypoints[1].x;
+	dy = ahead[0].y - polypoints[1].y;
+	if ((length = hypot(dx, dy)) == 0) {
+	    sinTheta = cosTheta = 0.0;
+	} else {
+	    sinTheta = dy / length;
+	    cosTheta = dx / length;
+	}
+	vertX = ahead[0].x - arrowshape[0]*cosTheta;
+	vertY = ahead[0].y - arrowshape[0]*sinTheta;
+	temp = arrowshape[2]*sinTheta;
+	ahead[1].x = (long)(ahead[0].x - arrowshape[1]*cosTheta + temp);
+	ahead[4].x = (long)(ahead[1].x - 2 * temp);
+	temp = arrowshape[2]*cosTheta;
+	ahead[1].y = (long)(ahead[0].y - arrowshape[1]*sinTheta - temp);
+	ahead[4].y = (long)(ahead[1].y + 2 * temp);
+	ahead[2].x = (long)(ahead[1].x*fracHeight + vertX*(1.0-fracHeight));
+	ahead[2].y = (long)(ahead[1].y*fracHeight + vertY*(1.0-fracHeight));
+	ahead[3].x = (long)(ahead[4].x*fracHeight + vertX*(1.0-fracHeight));
+	ahead[3].y = (long)(ahead[4].y*fracHeight + vertY*(1.0-fracHeight));
+
+	Polygon(hDC, ahead, 6);
+    }
+
+    if (width || dolinecolor || dodash) {
+	GdiFreePen(interp, hDC, hPen);
+    }
+    if (doarrow) {
+	GdiFreeBrush(interp, hDC, hBrush);
+    }
+
+    Tcl_Free((void *)polypoints);
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiOval --
+ *
+ *	Maps ovals to GDI context.
+ *
+ * Results:
+ *	Renders ovals.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiOval(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    int argc,
+    const char **argv)
+{
+    static const char usage_message[] =
+	"::tk::print::_gdi oval hdc x1 y1 x2 y2 -fill color -outline color "
+	"-stipple bitmap -width linewid";
+    int x1, y1, x2, y2;
+    HDC hDC;
+    HPEN hPen;
+    int width = 0;
+    COLORREF linecolor = 0, fillcolor = 0;
+    int dolinecolor = 0, dofillcolor = 0;
+    HBRUSH hBrush;
+    LOGBRUSH lbrush;
+    HGDIOBJ oldobj;
+
+    int dodash = 0;
+    const char *dashdata = 0;
+
+    /* Verrrrrry simple for now.... */
+    if (argc < 6) {
+	Tcl_AppendResult(interp, usage_message, NULL);
+	return TCL_ERROR;
+    }
+
+    hDC = printDC;
+
+    x1 = atol(argv[2]);
+    y1 = atol(argv[3]);
+    x2 = atol(argv[4]);
+    y2 = atol(argv[5]);
+    if (x1 > x2) {
+	int x3 = x1;
+	x1 = x2;
+	x2 = x3;
+    }
+    if (y1 > y2) {
+	int y3 = y1;
+	y1 = y2;
+	y2 = y3;
+    }
+    argc -= 6;
+    argv += 6;
+
+    while (argc > 0) {
+	/* Now handle any other arguments that occur. */
+	if (strcmp(argv[0], "-fill") == 0) {
+	    if (argv[1] && GdiGetColor(argv[1], &fillcolor)) {
+		dofillcolor = 1;
+	    }
+	} else if (strcmp(argv[0], "-outline") == 0) {
+	    if (argv[1] && GdiGetColor(argv[1], &linecolor)) {
+		dolinecolor = 1;
+	    }
+	} else if (strcmp(argv[0], "-stipple") == 0) {
+	    /* Not actually implemented */
+	} else if (strcmp(argv[0], "-width") == 0) {
+	    if (argv[1]) {
+		width = atoi(argv[1]);
+	    }
+	} else if (strcmp(argv[0], "-dash") == 0) {
+	    if (argv[1]) {
+		dodash = 1;
+		dashdata = argv[1];
+	    }
+	}
+	argv += 2;
+	argc -= 2;
+    }
+
+    if (dofillcolor) {
+	GdiMakeBrush(interp, 0, fillcolor, 0, &lbrush, hDC, (HGDIOBJ *)&hBrush);
+    } else {
+	oldobj = SelectObject(hDC, GetStockObject(HOLLOW_BRUSH));
+    }
+
+    if (width || dolinecolor) {
+	GdiMakePen(interp, width, dodash, dashdata,
+		0, 0, 0, 0, linecolor, hDC, (HGDIOBJ *)&hPen);
+    }
+    /*
+     * Per Win32, Rectangle includes lower and right edges--per Tcl8.3.2 and
+     * earlier documentation, canvas rectangle does not. Thus, add 1 to right
+     * and lower bounds to get appropriate behavior.
+     */
+    Ellipse(hDC, x1, y1, x2+1, y2+1);
+
+    if (width || dolinecolor) {
+	GdiFreePen(interp, hDC, hPen);
+    }
+    if (dofillcolor) {
+	GdiFreeBrush(interp, hDC, hBrush);
+    } else {
+	SelectObject(hDC, oldobj);
+    }
+
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiPolygon --
+ *
+ *	Maps polygons to GDI context.
+ *
+ * Results:
+ *	Renders polygons.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiPolygon(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    int argc,
+    const char **argv)
+{
+    static const char usage_message[] =
+	"::tk::print::_gdi polygon hdc x1 y1 ... xn yn "
+	"-fill color -outline color -smooth [true|false|bezier] "
+	"-splinesteps number -stipple bitmap -width linewid";
+
+    char *strend;
+    POINT *polypoints;
+    int npoly;
+    int dosmooth = 0;
+    int nStep = 12;
+    int x, y;
+    HDC hDC;
+    HPEN hPen;
+    int width = 0;
+    COLORREF linecolor = 0, fillcolor = BS_NULL;
+    int dolinecolor = 0, dofillcolor = 0;
+    LOGBRUSH lbrush;
+    HBRUSH hBrush;
+    HGDIOBJ oldobj;
+
+    int dodash = 0;
+    const char *dashdata = 0;
+
+    /* Verrrrrry simple for now.... */
+    if (argc < 6) {
+	Tcl_AppendResult(interp, usage_message, NULL);
+	return TCL_ERROR;
+    }
+
+    hDC = printDC;
+
+    polypoints = (POINT *) Tcl_AttemptAlloc((argc - 1) * sizeof(POINT));
+    if (polypoints == 0) {
+	/* TODO: unreachable */
+	Tcl_AppendResult(interp, "Out of memory in GdiLine", NULL);
+	return TCL_ERROR;
+    }
+    polypoints[0].x = atol(argv[2]);
+    polypoints[0].y = atol(argv[3]);
+    polypoints[1].x = atol(argv[4]);
+    polypoints[1].y = atol(argv[5]);
+    argc -= 6;
+    argv += 6;
+    npoly = 2;
+
+    while (argc >= 2) {
+	/* Check for a number */
+	x = strtoul(argv[0], &strend, 0);
+	if (strend > argv[0]) {
+	    /* One number.... */
+	    y = strtoul(argv[1], &strend, 0);
+	    if (strend > argv[1]) {
+		/* TWO numbers!. */
+		polypoints[npoly].x = x;
+		polypoints[npoly].y = y;
+		npoly++;
+		argc -= 2;
+		argv += 2;
+	    } else {
+		/* Only one number... Assume a usage error. */
+		Tcl_Free((void *) polypoints);
+		Tcl_AppendResult(interp, usage_message, NULL);
+		return TCL_ERROR;
+	    }
+	} else {
+	    /*
+	     * Check for arguments.
+	     * Most of the arguments affect the "Pen" and "Brush".
+	     */
+	    if (strcmp(argv[0], "-fill") == 0) {
+		if (argv[1] && GdiGetColor(argv[1], &fillcolor)) {
+		    dofillcolor = 1;
+		}
+	    } else if (strcmp(argv[0], "-outline") == 0) {
+		if (GdiGetColor(argv[1], &linecolor)) {
+		    dolinecolor = 0;
+		}
+	    } else if (strcmp(argv[0], "-smooth") == 0) {
+		if (argv[1]) {
+		    switch (argv[1][0]) {
+		    case 't': case 'T':
+		    case '1':
+		    case 'b': case 'B': /* bezier. */
+			dosmooth = 1;
+			break;
+		    default:
+			dosmooth = 0;
+			break;
+		    }
+		}
+	    } else if (strcmp(argv[0], "-splinesteps") == 0) {
+		if (argv[1]) {
+		    nStep = atoi(argv[1]);
+		}
+	    } else if (strcmp(argv[0], "-stipple") == 0) {
+		/* Not supported */
+	    } else if (strcmp(argv[0], "-width") == 0) {
+		if (argv[1]) {
+		    width = atoi(argv[1]);
+		}
+	    } else if (strcmp(argv[0], "-dash") == 0) {
+		if (argv[1]) {
+		    dodash = 1;
+		    dashdata = argv[1];
+		}
+	    }
+	    argc -= 2;
+	    argv += 2;
+	}
+    }
+
+    if (dofillcolor) {
+	GdiMakeBrush(interp, 0, fillcolor, 0, &lbrush, hDC, (HGDIOBJ *)&hBrush);
+    } else {
+	oldobj = SelectObject(hDC, GetStockObject(HOLLOW_BRUSH));
+    }
+
+    if (width || dolinecolor) {
+	GdiMakePen(interp, width, dodash, dashdata, 0, 0, 0, 0,
+		linecolor, hDC, (HGDIOBJ *)&hPen);
+    }
+
+    if (dosmooth) {
+	int nbpoints;
+	POINT *bpoints = 0;
+	nbpoints = Bezierize(polypoints,npoly,nStep,bpoints);
+	if (nbpoints > 0) {
+	    Polygon(hDC, bpoints, nbpoints);
+	} else {
+	    Polygon(hDC, polypoints, npoly);
+	}
+	if (bpoints != 0) {
+	    Tcl_Free((void *)bpoints);
+	}
+    } else {
+	Polygon(hDC, polypoints, npoly);
+    }
+
+    if (width || dolinecolor) {
+	GdiFreePen(interp, hDC, hPen);
+    }
+    if (dofillcolor) {
+	GdiFreeBrush(interp, hDC, hBrush);
+    } else {
+	SelectObject(hDC, oldobj);
+    }
+
+    Tcl_Free((void *)polypoints);
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiRectangle --
+ *
+ *	Maps rectangles to GDI context.
+ *
+ * Results:
+ *	Renders rectangles.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiRectangle(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    int argc,
+    const char **argv)
+{
+    static const char usage_message[] =
+	"::tk::print::_gdi rectangle hdc x1 y1 x2 y2 "
+	"-fill color -outline color "
+	"-stipple bitmap -width linewid";
+
+    int x1, y1, x2, y2;
+    HDC hDC;
+    HPEN hPen;
+    int width = 0;
+    COLORREF linecolor = 0, fillcolor = BS_NULL;
+    int dolinecolor = 0, dofillcolor = 0;
+    LOGBRUSH lbrush;
+    HBRUSH hBrush;
+    HGDIOBJ oldobj;
+
+    int dodash = 0;
+    const char *dashdata = 0;
+
+    /* Verrrrrry simple for now.... */
+    if (argc < 6) {
+	Tcl_AppendResult(interp, usage_message, NULL);
+	return TCL_ERROR;
+    }
+
+    hDC = printDC;
+
+    x1 = atol(argv[2]);
+    y1 = atol(argv[3]);
+    x2 = atol(argv[4]);
+    y2 = atol(argv[5]);
+    if (x1 > x2) {
+	int x3 = x1;
+	x1 = x2;
+	x2 = x3;
+    }
+    if (y1 > y2) {
+	int y3 = y1;
+	y1 = y2;
+	y2 = y3;
+    }
+    argc -= 6;
+    argv += 6;
+
+    /* Now handle any other arguments that occur. */
+    while (argc > 1) {
+	if (strcmp(argv[0], "-fill") == 0) {
+	    if (argv[1] && GdiGetColor(argv[1], &fillcolor)) {
+		dofillcolor = 1;
+	    }
+	} else if (strcmp(argv[0], "-outline") == 0) {
+	    if (argv[1] && GdiGetColor(argv[1], &linecolor)) {
+		dolinecolor = 1;
+	    }
+	} else if (strcmp(argv[0], "-stipple") == 0) {
+	    /* Not supported; ignored */
+	} else if (strcmp(argv[0], "-width") == 0) {
+	    if (argv[1]) {
+		width = atoi(argv[1]);
+	    }
+	} else if (strcmp(argv[0], "-dash") == 0) {
+	    if (argv[1]) {
+		dodash = 1;
+		dashdata = argv[1];
+	    }
+	}
+
+	argc -= 2;
+	argv += 2;
+    }
+
+    /*
+     * Note: If any fill is specified, the function must create a brush and
+     * put the coordinates in a RECTANGLE structure, and call FillRect.
+     * FillRect requires a BRUSH / color.
+     * If not, the function Rectangle must be called.
+     */
+    if (dofillcolor) {
+	GdiMakeBrush(interp, 0, fillcolor, 0, &lbrush, hDC, (HGDIOBJ *)&hBrush);
+    } else {
+	oldobj = SelectObject(hDC, GetStockObject(HOLLOW_BRUSH));
+    }
+
+    if (width || dolinecolor) {
+	GdiMakePen(interp, width, dodash, dashdata,
+		0, 0, 0, 0, linecolor, hDC, (HGDIOBJ *)&hPen);
+    }
+    /*
+     * Per Win32, Rectangle includes lower and right edges--per Tcl8.3.2 and
+     * earlier documentation, canvas rectangle does not. Thus, add 1 to
+     * right and lower bounds to get appropriate behavior.
+     */
+    Rectangle(hDC, x1, y1, x2+1, y2+1);
+
+    if (width || dolinecolor) {
+	GdiFreePen(interp, hDC, hPen);
+    }
+    if (dofillcolor) {
+	GdiFreeBrush(interp, hDC, hBrush);
+    } else {
+	SelectObject(hDC, oldobj);
+    }
+
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiCharWidths --
+ *
+ *	Computes /character widths. This is completely inadequate for
+ *	typesetting, but should work for simple text manipulation.
+ *
+ * Results:
+ *	Returns character width.
+ *
+ *----------------------------------------------------------------------
+ */
+
+
+static int GdiCharWidths(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    int argc,
+    const char **argv)
+{
+    static const char usage_message[] =
+	"::tk::print::_gdi characters hdc [-font fontname] [-array ary]";
+    /*
+     * Returns widths of characters from font in an associative array.
+     * Font is currently selected font for HDC if not specified.
+     * Array name is GdiCharWidths if not specified.
+     * Widths should be in the same measures as all other values (1/1000 inch).
+     */
+
+    HDC hDC;
+    LOGFONTW lf;
+    HFONT hfont, oldfont;
+    int made_font = 0;
+    const char *aryvarname = "GdiCharWidths";
+    /* For now, assume 256 characters in the font.... */
+    int widths[256];
+    int retval;
+
+    if (argc < 2) {
+	Tcl_AppendResult(interp, usage_message, NULL);
+	return TCL_ERROR;
+    }
+
+    hDC = printDC;
+
+    argc -= 2;
+    argv += 2;
+
+    while (argc > 0) {
+	if (strcmp(argv[0], "-font") == 0) {
+	    argc--;
+	    argv++;
+	    if (GdiMakeLogFont(interp, argv[0], &lf, hDC)) {
+		if ((hfont = CreateFontIndirectW(&lf)) != NULL) {
+		    made_font = 1;
+		    oldfont = SelectObject(hDC, hfont);
+		}
+	    }
+	    /* Else leave the font alone!. */
+	} else if (strcmp(argv[0], "-array") == 0) {
+	    argv++;
+	    argc--;
+	    if (argc > 0) {
+		aryvarname = argv[0];
+	    }
+	}
+	argv++;
+	argc--;
+    }
+
+    /* Now, get the widths using the correct function for font type. */
+    if ((retval = GetCharWidth32W(hDC, 0, 255, widths)) == FALSE) {
+	retval = GetCharWidthW(hDC, 0, 255, widths);
+    }
+
+    /*
+     * Retval should be 1 (TRUE) if the function succeeded. If the function
+     * fails, get the "extended" error code and return. Be sure to deallocate
+     * the font if necessary.
+     */
+    if (retval == FALSE) {
+	DWORD val = GetLastError();
+
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+                "::tk::print::_gdi character failed with code %ld", val));
+	if (made_font) {
+	    SelectObject(hDC, oldfont);
+	    DeleteObject(hfont);
+	}
+	return TCL_ERROR;
+    }
+
+    {
+	int i;
+	char ind[2];
+	ind[1] = '\0';
+
+	for (i = 0; i < 255; i++) {
+	    /* TODO: use a bytearray for the index name so NUL works */
+	    ind[0] = i;
+	    Tcl_SetVar2Ex(interp, aryvarname, ind, Tcl_NewIntObj(widths[i]),
+		    TCL_GLOBAL_ONLY);
+	}
+    }
+    /* Now, remove the font if we created it only for this function. */
+    if (made_font) {
+	SelectObject(hDC, oldfont);
+	DeleteObject(hfont);
+    }
+
+    /* The return value should be the array name(?). */
+    Tcl_AppendResult(interp, (char *)aryvarname, NULL);
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiText --
+ *
+ *	Maps text to GDI context.
+ *
+ * Results:
+ *	Renders text.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int GdiText(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    int argc,
+    const char **argv)
+{
+    static const char usage_message[] =
+	"::tk::print::_gdi text hdc x y -anchor [center|n|e|s|w] "
+	"-fill color -font fontname "
+	"-justify [left|right|center] "
+	"-stipple bitmap -text string -width linelen "
+	"-single -backfill";
+
+    HDC hDC;
+    int x, y;
+    const char *string = 0;
+    RECT sizerect;
+    UINT format_flags = DT_EXPANDTABS|DT_NOPREFIX; /* Like the canvas. */
+    Tk_Anchor anchor = 0;
+    LOGFONTW lf;
+    HFONT hfont, oldfont;
+    int made_font = 0;
+    int retval;
+    int dotextcolor = 0;
+    int dobgmode = 0;
+    int bgmode;
+    COLORREF textcolor = 0;
+    int usesingle = 0;
+    WCHAR *wstring;
+    Tcl_DString tds;
+
+    if (argc < 4) {
+	Tcl_AppendResult(interp, usage_message, NULL);
+	return TCL_ERROR;
+    }
+
+    /* Parse the command. */
+
+    hDC = printDC;
+
+    x = atol(argv[2]);
+    y = atol(argv[3]);
+    argc -= 4;
+    argv += 4;
+
+    sizerect.left = sizerect.right = x;
+    sizerect.top = sizerect.bottom = y;
+
+    while (argc > 0) {
+	if (strcmp(argv[0], "-anchor") == 0) {
+	    argc--;
+	    argv++;
+	    if (argc > 0) {
+		Tk_GetAnchor(interp, argv[0], &anchor);
+	    }
+	} else if (strcmp(argv[0], "-justify") == 0) {
+	    argc--;
+	    argv++;
+	    if (argc > 0) {
+		if (strcmp(argv[0], "left") == 0) {
+		    format_flags |= DT_LEFT;
+		} else if (strcmp(argv[0], "center") == 0) {
+		    format_flags |= DT_CENTER;
+		} else if (strcmp(argv[0], "right") == 0) {
+		    format_flags |= DT_RIGHT;
+		}
+	    }
+	} else if (strcmp(argv[0], "-text") == 0) {
+	    argc--;
+	    argv++;
+	    if (argc > 0) {
+		string = argv[0];
+	    }
+	} else if (strcmp(argv[0], "-font") == 0) {
+	    argc--;
+	    argv++;
+	    if (GdiMakeLogFont(interp, argv[0], &lf, hDC)) {
+		if ((hfont = CreateFontIndirectW(&lf)) != NULL) {
+		    made_font = 1;
+		    oldfont = SelectObject(hDC, hfont);
+		}
+	    }
+	    /* Else leave the font alone! */
+	} else if (strcmp(argv[0], "-stipple") == 0) {
+	    argc--;
+	    argv++;
+	    /* Not implemented yet. */
+	} else if (strcmp(argv[0], "-fill") == 0) {
+	    argc--;
+	    argv++;
+	    /* Get text color. */
+	    if (GdiGetColor(argv[0], &textcolor)) {
+		dotextcolor = 1;
+	    }
+	} else if (strcmp(argv[0], "-width") == 0) {
+	    argc--;
+	    argv++;
+	    if (argc > 0) {
+		sizerect.right += atol(argv[0]);
+	    }
+	    /* If a width is specified, break at words. */
+	    format_flags |= DT_WORDBREAK;
+	} else if (strcmp(argv[0], "-single") == 0) {
+	    usesingle = 1;
+	} else if (strcmp(argv[0], "-backfill") == 0) {
+	    dobgmode = 1;
+	}
+
+	argc--;
+	argv++;
+    }
+
+    if (string == 0) {
+	Tcl_AppendResult(interp, usage_message, NULL);
+	return TCL_ERROR;
+    }
+
+    /* Set the format flags for -single: Overrides -width. */
+    if (usesingle == 1) {
+	format_flags |= DT_SINGLELINE;
+	format_flags |= DT_NOCLIP;
+	format_flags &= ~DT_WORDBREAK;
+    }
+
+    Tcl_DStringInit(&tds);
+    /* Just for fun, let's try translating string to Unicode. */
+    wstring = Tcl_UtfToWCharDString(string, -1, &tds);
+    DrawTextW(hDC, wstring, Tcl_DStringLength(&tds)/2, &sizerect,
+	    format_flags | DT_CALCRECT);
+
+    /* Adjust the rectangle according to the anchor. */
+    x = y = 0;
+    switch (anchor) {
+    case TK_ANCHOR_N:
+	x = (sizerect.right - sizerect.left) / 2;
+	break;
+    case TK_ANCHOR_S:
+	x = (sizerect.right - sizerect.left) / 2;
+	y = (sizerect.bottom - sizerect.top);
+	break;
+    case TK_ANCHOR_E:
+	x = (sizerect.right - sizerect.left);
+	y = (sizerect.bottom - sizerect.top) / 2;
+	break;
+    case TK_ANCHOR_W:
+	y = (sizerect.bottom - sizerect.top) / 2;
+	break;
+    case TK_ANCHOR_NE:
+	x = (sizerect.right - sizerect.left);
+	break;
+    case TK_ANCHOR_NW:
+	break;
+    case TK_ANCHOR_SE:
+	x = (sizerect.right - sizerect.left);
+	y = (sizerect.bottom - sizerect.top);
+	break;
+    case TK_ANCHOR_SW:
+	y = (sizerect.bottom - sizerect.top);
+	break;
+    default:
+	x = (sizerect.right - sizerect.left) / 2;
+	y = (sizerect.bottom - sizerect.top) / 2;
+	break;
+    }
+    sizerect.right  -= x;
+    sizerect.left   -= x;
+    sizerect.top    -= y;
+    sizerect.bottom -= y;
+
+    /* Get the color right. */
+    if (dotextcolor) {
+	textcolor = SetTextColor(hDC, textcolor);
+    }
+
+    if (dobgmode) {
+	bgmode = SetBkMode(hDC, OPAQUE);
+    } else {
+	bgmode = SetBkMode(hDC, TRANSPARENT);
+    }
+
+    /* Print the text. */
+    retval = DrawTextW(hDC, wstring,
+	    Tcl_DStringLength(&tds)/2, &sizerect, format_flags);
+    Tcl_DStringFree(&tds);
+
+    /* Get the color set back. */
+    if (dotextcolor) {
+	textcolor = SetTextColor(hDC, textcolor);
+    }
+    SetBkMode(hDC, bgmode);
+    if (made_font) {
+	SelectObject(hDC, oldfont);
+	DeleteObject(hfont);
+    }
+
+    /* In this case, the return value is the height of the text. */
+    Tcl_SetObjResult(interp, Tcl_NewIntObj(retval));
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiGetHdcInfo --
+ *
+ *	Gets salient characteristics of the CTM.
+ *
+ * Results:
+ *	The return value is 0 if any failure occurs--in which case none of the
+ *	other values are meaningful.  Otherwise the return value is the
+ *	current mapping mode.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiGetHdcInfo(
+    HDC hdc,
+    LPPOINT worigin,
+    LPSIZE wextent,
+    LPPOINT vorigin,
+    LPSIZE vextent)
+{
+    int mapmode;
+    int retval;
+
+    memset(worigin, 0, sizeof(POINT));
+    memset(vorigin, 0, sizeof(POINT));
+    memset(wextent, 0, sizeof(SIZE));
+    memset(vextent, 0, sizeof(SIZE));
+
+    if ((mapmode = GetMapMode(hdc)) == 0) {
+	/* Failed! */
+	retval = 0;
+    } else {
+	retval = mapmode;
+    }
+
+    if (GetWindowExtEx(hdc, wextent) == FALSE) {
+	/* Failed! */
+	retval = 0;
+    }
+    if (GetViewportExtEx(hdc, vextent) == FALSE) {
+	/* Failed! */
+	retval = 0;
+    }
+    if (GetWindowOrgEx(hdc, worigin) == FALSE) {
+	/* Failed! */
+	retval = 0;
+    }
+    if (GetViewportOrgEx(hdc, vorigin) == FALSE) {
+	/* Failed! */
+	retval = 0;
+    }
+
+    return retval;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiNameToMode --
+ *
+ *	Converts Windows mapping mode names.
+ *
+ * Results:
+ *	Mapping modes are delineated.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiNameToMode(
+    const char *name)
+{
+    static const struct gdimodes {
+	int mode;
+	const char *name;
+    } modes[] = {
+	{ MM_ANISOTROPIC, "MM_ANISOTROPIC" },
+	{ MM_HIENGLISH,   "MM_HIENGLISH" },
+	{ MM_HIMETRIC,    "MM_HIMETRIC" },
+	{ MM_ISOTROPIC,   "MM_ISOTROPIC" },
+	{ MM_LOENGLISH,   "MM_LOENGLISH" },
+	{ MM_LOMETRIC,    "MM_LOMETRIC" },
+	{ MM_TEXT,        "MM_TEXT" },
+	{ MM_TWIPS,       "MM_TWIPS" }
+    };
+
+    size_t i;
+    for (i=0; i < sizeof(modes) / sizeof(struct gdimodes); i++) {
+	if (strcmp(modes[i].name, name) == 0) {
+	    return modes[i].mode;
+	}
+    }
+    return atoi(name);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiModeToName --
+ *
+ *	Converts the mode number to a printable form.
+ *
+ * Results:
+ *	Mapping numbers are delineated.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static const char *GdiModeToName(
+    int mode)
+{
+    static const struct gdi_modes {
+	int mode;
+	const char *name;
+    } modes[] = {
+	{ MM_ANISOTROPIC, "Anisotropic" },
+	{ MM_HIENGLISH,   "1/1000 inch" },
+	{ MM_HIMETRIC,    "1/100 mm" },
+	{ MM_ISOTROPIC,   "Isotropic" },
+	{ MM_LOENGLISH,   "1/100 inch" },
+	{ MM_LOMETRIC,    "1/10 mm" },
+	{ MM_TEXT,        "1 to 1" },
+	{ MM_TWIPS,       "1/1440 inch" }
+    };
+
+    size_t i;
+    for (i=0; i < sizeof(modes) / sizeof(struct gdi_modes); i++) {
+	if (modes[i].mode == mode) {
+	    return modes[i].name;
+	}
+    }
+    return "Unknown";
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiMap --
+ *
+ *	Sets mapping mode between logical and physical device space.
+ *
+ * Results:
+ *	Bridges map modes.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiMap(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    int argc,
+    const char **argv)
+{
+    static const char usage_message[] =
+	"::tk::print::_gdi map hdc "
+	"[-logical x[y]] [-physical x[y]] "
+	"[-offset {x y} ] [-default] [-mode mode]";
+    HDC hdc;
+    int mapmode;	/* Mapping mode. */
+    SIZE wextent;	/* Device extent. */
+    SIZE vextent;	/* Viewport extent. */
+    POINT worigin;	/* Device origin. */
+    POINT vorigin;	/* Viewport origin. */
+    int argno;
+
+    /* Keep track of what parts of the function need to be executed. */
+    int need_usage   = 0;
+    int use_logical  = 0;
+    int use_physical = 0;
+    int use_offset   = 0;
+    int use_default  = 0;
+    int use_mode     = 0;
+
+    /* Required parameter: HDC for printer. */
+    if (argc < 2) {
+	Tcl_AppendResult(interp, usage_message, NULL);
+	return TCL_ERROR;
+    }
+
+    hdc = printDC;
+
+    if ((mapmode = GdiGetHdcInfo(hdc, &worigin, &wextent, &vorigin, &vextent)) == 0) {
+	/* Failed!. */
+	Tcl_AppendResult(interp, "Cannot get current HDC info", NULL);
+	return TCL_ERROR;
+    }
+
+    /* Parse remaining arguments. */
+    for (argno = 2; argno < argc; argno++) {
+	if (strcmp(argv[argno], "-default") == 0) {
+	    vextent.cx = vextent.cy = wextent.cx = wextent.cy = 1;
+	    vorigin.x = vorigin.y = worigin.x = worigin.y = 0;
+	    mapmode = MM_TEXT;
+	    use_default = 1;
+	} else if (strcmp(argv[argno], "-mode") == 0) {
+	    if (argno + 1 >= argc) {
+		need_usage = 1;
+	    } else {
+		mapmode = GdiNameToMode(argv[argno + 1]);
+		use_mode = 1;
+		argno++;
+	    }
+	} else if (strcmp(argv[argno], "-offset") == 0) {
+	    if (argno + 1 >= argc) {
+		need_usage = 1;
+	    } else {
+		/* It would be nice if this parsed units as well.... */
+		if (sscanf(argv[argno + 1], "%ld%ld",
+			&vorigin.x, &vorigin.y) == 2) {
+		    use_offset = 1;
+		} else {
+		    need_usage = 1;
+		}
+		argno++;
+	    }
+	} else if (strcmp(argv[argno], "-logical") == 0) {
+	    if (argno + 1 >= argc) {
+		need_usage = 1;
+	    } else {
+		int count;
+
+		argno++;
+		/* In "real-life", this should parse units as well.. */
+		if ((count = sscanf(argv[argno], "%ld%ld",
+			&wextent.cx, &wextent.cy)) != 2) {
+		    if (count == 1) {
+			mapmode = MM_ISOTROPIC;
+			use_logical = 1;
+			wextent.cy = wextent.cx;  /* Make them the same. */
+		    } else {
+			need_usage = 1;
+		    }
+		} else {
+		    mapmode = MM_ANISOTROPIC;
+		    use_logical = 2;
+		}
+	    }
+	} else if (strcmp(argv[argno], "-physical") == 0) {
+	    if (argno + 1 >= argc) {
+		need_usage = 1;
+	    } else {
+		int count;
+
+		argno++;
+		/* In "real-life", this should parse units as well.. */
+		if ((count = sscanf(argv[argno], "%ld%ld",
+			&vextent.cx, &vextent.cy)) != 2) {
+		    if (count == 1) {
+			mapmode = MM_ISOTROPIC;
+			use_physical = 1;
+			vextent.cy = vextent.cx;  /* Make them the same. */
+		    } else {
+			need_usage = 1;
+		    }
+		} else {
+		    mapmode = MM_ANISOTROPIC;
+		    use_physical = 2;
+		}
+	    }
+	}
+    }
+
+    /* Check for any impossible combinations. */
+    if (use_logical != use_physical) {
+	need_usage = 1;
+    }
+    if (use_default && (use_logical || use_offset || use_mode)) {
+	need_usage = 1;
+    }
+    if (use_mode && use_logical &&
+	    (mapmode != MM_ISOTROPIC && mapmode != MM_ANISOTROPIC)) {
+	need_usage = 1;
+    }
+
+    if (need_usage) {
+	Tcl_AppendResult(interp, usage_message, NULL);
+	return TCL_ERROR;
+    }
+
+    /* Call Windows CTM functions. */
+    if (use_logical || use_default || use_mode) { /* Don't call for offset only. */
+	SetMapMode(hdc, mapmode);
+    }
+
+    if (use_offset || use_default) {
+	POINT oldorg;
+	SetViewportOrgEx(hdc, vorigin.x, vorigin.y, &oldorg);
+	SetWindowOrgEx(hdc, worigin.x, worigin.y, &oldorg);
+    }
+
+    if (use_logical) {  /* Same as use_physical. */
+	SIZE oldsiz;
+	SetWindowExtEx(hdc, wextent.cx, wextent.cy, &oldsiz);
+	SetViewportExtEx(hdc, vextent.cx, vextent.cy, &oldsiz);
+    }
+
+    /*
+     * Since we may not have set up every parameter, get them again for the
+     * report.
+     */
+    mapmode = GdiGetHdcInfo(hdc, &worigin, &wextent, &vorigin, &vextent);
+
+    /*
+     * Output current CTM info.
+     * Note: This should really be in terms that can be used in a
+     * ::tk::print::_gdi map command!
+     */
+    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+	    "Transform: \"(%ld, %ld) -> (%ld, %ld)\" "
+	    "Origin: \"(%ld, %ld)\" "
+	    "MappingMode: \"%s\"",
+	    vextent.cx, vextent.cy, wextent.cx, wextent.cy,
+	    vorigin.x, vorigin.y,
+	    GdiModeToName(mapmode)));
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiCopyBits --
+ *
+ *	Copies window bits from source to destination.
+ *
+ * Results:
+ *	Copies window bits.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiCopyBits(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    int argc,
+    const char **argv)
+{
+    /* Goal: get the Tk_Window from the top-level
+     * convert it to an HWND
+     * get the HDC
+     * Do a bitblt to the given hdc
+     * Use an optional parameter to point to an arbitrary window instead of
+     * the main
+     * Use optional parameters to map to the width and height required for the
+     * dest.
+     */
+    static const char usage_message[] =
+	"::tk::print::_gdi copybits hdc [-window w|-screen] [-client] "
+	"[-source \"a b c d\"] "
+	"[-destination \"a b c d\"] [-scale number] [-calc]";
+
+    Tk_Window mainWin;
+    Tk_Window workwin;
+    Window wnd;
+    HDC src;
+    HDC dst;
+    HWND hwnd = 0;
+
+    HANDLE hDib;    /* Handle for device-independent bitmap. */
+    LPBITMAPINFOHEADER lpDIBHdr;
+    LPSTR lpBits;
+    enum PrintType wintype = PTWindow;
+
+    int hgt, wid;
+    char *strend;
+    long errcode;
+    int k;
+
+    /* Variables to remember what we saw in the arguments. */
+    int do_window = 0;
+    int do_screen = 0;
+    int do_scale = 0;
+    int do_print = 1;
+
+    /* Variables to remember the values in the arguments. */
+    const char *window_spec;
+    double scale = 1.0;
+    int src_x = 0, src_y = 0, src_w = 0, src_h = 0;
+    int dst_x = 0, dst_y = 0, dst_w = 0, dst_h = 0;
+    int is_toplevel = 0;
+
+    /*
+     * The following steps are peculiar to the top level window.
+     * There is likely a clever way to do the mapping of a widget pathname to
+     * the proper window, to support the idea of using a parameter for this
+     * purpose.
+     */
+    if ((workwin = mainWin = Tk_MainWindow(interp)) == 0) {
+	Tcl_AppendResult(interp, "Can't find main Tk window", NULL);
+	return TCL_ERROR;
+    }
+
+    /*
+     * Parse the arguments.
+     */
+    /* HDC is required. */
+    if (argc < 2) {
+	Tcl_AppendResult(interp, usage_message, NULL);
+	return TCL_ERROR;
+    }
+
+    dst = printDC;
+
+    /*
+     * Next, check to see if 'dst' can support BitBlt.  If not, raise an
+     * error.
+     */
+    if ((GetDeviceCaps(dst, RASTERCAPS) & RC_BITBLT) == 0) {
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"Can't do bitmap operations on device context\n"));
+	return TCL_ERROR;
+    }
+
+    /* Loop through the remaining arguments. */
+    for (k=2; k<argc; k++) {
+	if (strcmp(argv[k], "-window") == 0) {
+	    if (argv[k+1] && argv[k+1][0] == '.') {
+		do_window = 1;
+		workwin = Tk_NameToWindow(interp, window_spec = argv[++k], mainWin);
+		if (workwin == NULL) {
+		    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+			    "Can't find window %s in this application",
+			    window_spec));
+		    return TCL_ERROR;
+		}
+	    } else {
+		/* Use strtoul() so octal or hex representations will be
+		 * parsed. */
+		hwnd = (HWND) INT2PTR(strtoul(argv[++k], &strend, 0));
+		if (strend == 0 || strend == argv[k]) {
+		    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+			    "Can't understand window id %s", argv[k]));
+		    return TCL_ERROR;
+		}
+	    }
+	} else if (strcmp(argv[k], "-screen") == 0) {
+	    do_screen = 1;
+	    wintype = PTScreen;
+	} else if (strcmp(argv[k], "-client") == 0) {
+	    wintype = PTClient;
+	} else if (strcmp(argv[k], "-source") == 0) {
+	    float a, b, c, d;
+	    int count = sscanf(argv[++k], "%f%f%f%f", &a, &b, &c, &d);
+
+	    if (count < 2) { /* Can't make heads or tails of it.... */
+		Tcl_AppendResult(interp, usage_message, NULL);
+		return TCL_ERROR;
+	    }
+	    src_x = (int)a;
+	    src_y = (int)b;
+	    if (count == 4) {
+		src_w = (int)c;
+		src_h = (int)d;
+	    }
+	} else if (strcmp(argv[k], "-destination") == 0) {
+	    float a, b, c, d;
+	    int count;
+
+	    count = sscanf(argv[++k], "%f%f%f%f", &a, &b, &c, &d);
+	    if (count < 2) { /* Can't make heads or tails of it.... */
+		Tcl_AppendResult(interp, usage_message, NULL);
+		return TCL_ERROR;
+	    }
+	    dst_x = (int)a;
+	    dst_y = (int)b;
+	    if (count == 3) {
+		dst_w = (int)c;
+		dst_h = -1;
+	    } else if (count == 4) {
+		dst_w = (int)c;
+		dst_h = (int)d;
+	    }
+	} else if (strcmp(argv[k], "-scale") == 0) {
+	    if (argv[++k]) {
+		scale = strtod(argv[k], &strend);
+		if (strend == 0 || strend == argv[k]) {
+		    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+			    "Can't understand scale specification %s",
+			    argv[k]));
+		    return TCL_ERROR;
+		}
+		if (scale <= 0.01 || scale >= 100.0) {
+		    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+			    "Unreasonable scale specification %s", argv[k]));
+		    return TCL_ERROR;
+		}
+		do_scale = 1;
+	    }
+	} else if (strcmp(argv[k], "-noprint") == 0
+		|| strncmp(argv[k], "-calc", 5) == 0) {
+	    /* This option suggested by Pascal Bouvier to get sizes without
+	     * printing. */
+	    do_print = 0;
+	}
+    }
+
+    /*
+     * Check to ensure no incompatible arguments were used.
+     */
+    if (do_window && do_screen) {
+	Tcl_AppendResult(interp, usage_message, NULL);
+	return TCL_ERROR;
+    }
+
+    /*
+     * Get the MS Window we want to copy.  Given the HDC, we can get the
+     * "Window".
+     */
+    if (hwnd == 0) {
+	if (Tk_IsTopLevel(workwin)) {
+	    is_toplevel = 1;
+	}
+
+	if ((wnd = Tk_WindowId(workwin)) == 0) {
+	    Tcl_AppendResult(interp, "Can't get id for Tk window", NULL);
+	    return TCL_ERROR;
+	}
+
+	/* Given the "Window" we can get a Microsoft Windows HWND. */
+
+	if ((hwnd = Tk_GetHWND(wnd)) == 0) {
+	    Tcl_AppendResult(interp, "Can't get Windows handle for Tk window",
+		    NULL);
+	    return TCL_ERROR;
+	}
+
+	/*
+	 * If it's a toplevel, give it special treatment: Get the top-level
+	 * window instead.  If the user only wanted the client, the -client
+	 * flag will take care of it.  This uses "windows" tricks rather than
+	 * Tk since the obvious method of getting the wrapper window didn't
+	 * seem to work.
+	 */
+	if (is_toplevel) {
+	    HWND tmpWnd = hwnd;
+	    while ((tmpWnd = GetParent(tmpWnd)) != 0) {
+		hwnd = tmpWnd;
+	    }
+	}
+    }
+
+    /* Given the HWND, we can get the window's device context. */
+    if ((src = GetWindowDC(hwnd)) == 0) {
+	Tcl_AppendResult(interp, "Can't get device context for Tk window", NULL);
+	return TCL_ERROR;
+    }
+
+    if (do_screen) {
+	LONG w, h;
+	GetDisplaySize(&w, &h);
+	wid = w;
+	hgt = h;
+    } else if (is_toplevel) {
+	RECT tl;
+	GetWindowRect(hwnd, &tl);
+	wid = tl.right - tl.left;
+	hgt = tl.bottom - tl.top;
+    } else {
+	if ((hgt = Tk_Height(workwin)) <= 0) {
+	    Tcl_AppendResult(interp, "Can't get height of Tk window", NULL);
+	    ReleaseDC(hwnd,src);
+	    return TCL_ERROR;
+	}
+
+	if ((wid = Tk_Width(workwin)) <= 0) {
+	    Tcl_AppendResult(interp, "Can't get width of Tk window", NULL);
+	    ReleaseDC(hwnd,src);
+	    return TCL_ERROR;
+	}
+    }
+
+    /*
+     * Ensure all the widths and heights are set up right
+     * A: No dimensions are negative
+     * B: No dimensions exceed the maximums
+     * C: The dimensions don't lead to a 0 width or height image.
+     */
+    if (src_x < 0) {
+	src_x = 0;
+    }
+    if (src_y < 0) {
+	src_y = 0;
+    }
+    if (dst_x < 0) {
+	dst_x = 0;
+    }
+    if (dst_y < 0) {
+	dst_y = 0;
+    }
+
+    if (src_w > wid || src_w <= 0) {
+	src_w = wid;
+    }
+
+    if (src_h > hgt || src_h <= 0) {
+	src_h = hgt;
+    }
+
+    if (do_scale && dst_w == 0) {
+	/* Calculate destination width and height based on scale. */
+	dst_w = (int)(scale * src_w);
+	dst_h = (int)(scale * src_h);
+    }
+
+    if (dst_h == -1) {
+	dst_h = (int) (((long)src_h * dst_w) / (src_w + 1)) + 1;
+    }
+
+    if (dst_h == 0 || dst_w == 0) {
+	dst_h = src_h;
+	dst_w = src_w;
+    }
+
+    if (do_print) {
+	/*
+	 * Based on notes from Heiko Schock and Arndt Roger Schneider, create
+	 * this as a DIBitmap, to allow output to a greater range of devices.
+	 * This approach will also allow selection of
+	 *   a) Whole screen
+	 *   b) Whole window
+	 *   c) Client window only
+	 * for the "grab"
+	 */
+	hDib = CopyToDIB(hwnd, wintype);
+
+	/* GdiFlush();. */
+
+	if (!hDib) {
+	    Tcl_AppendResult(interp, "Can't create DIB", NULL);
+	    ReleaseDC(hwnd,src);
+	    return TCL_ERROR;
+	}
+
+	lpDIBHdr = (LPBITMAPINFOHEADER) GlobalLock(hDib);
+	if (!lpDIBHdr) {
+	    Tcl_AppendResult(interp, "Can't get DIB header", NULL);
+	    ReleaseDC(hwnd,src);
+	    return TCL_ERROR;
+	}
+
+	lpBits = (LPSTR) lpDIBHdr + lpDIBHdr->biSize + DIBNumColors(lpDIBHdr) * sizeof(RGBQUAD);
+
+	/* stretch the DIBbitmap directly in the target device. */
+
+	if (StretchDIBits(dst,
+		dst_x, dst_y, dst_w, dst_h,
+		src_x, src_y, src_w, src_h,
+		lpBits, (LPBITMAPINFO)lpDIBHdr, DIB_RGB_COLORS,
+		SRCCOPY) == (int)GDI_ERROR) {
+	    errcode = GetLastError();
+	    GlobalUnlock(hDib);
+	    GlobalFree(hDib);
+	    ReleaseDC(hwnd,src);
+	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		    "StretchDIBits failed with code %ld", errcode));
+	    return TCL_ERROR;
+	}
+
+	/* free allocated memory. */
+	GlobalUnlock(hDib);
+	GlobalFree(hDib);
+    }
+
+    ReleaseDC(hwnd,src);
+
+    /*
+     * The return value should relate to the size in the destination space.
+     * At least the height should be returned (for page layout purposes).
+     */
+    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+	    "%d %d %d %d", dst_x, dst_y, dst_w, dst_h));
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * DIBNumColors --
+ *
+ *	Computes the number of colors required for a DIB palette.
+ *
+ * Results:
+ *	Returns number of colors.
+
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int DIBNumColors(
+    LPBITMAPINFOHEADER lpDIB)
+{
+    WORD wBitCount;	/* DIB bit count. */
+    DWORD dwClrUsed;
+
+    /*
+     * If this is a Windows-style DIB, the number of colors in the color table
+     * can be less than the number of bits per pixel allows for (i.e.
+     * lpbi->biClrUsed can be set to some value).  If this is the case, return
+     * the appropriate value..
+     */
+
+    dwClrUsed = lpDIB->biClrUsed;
+    if (dwClrUsed) {
+	return (WORD) dwClrUsed;
+    }
+
+    /*
+     * Calculate the number of colors in the color table based on.
+     * The number of bits per pixel for the DIB.
+     */
+
+    wBitCount = lpDIB->biBitCount;
+
+    /* Return number of colors based on bits per pixel. */
+
+    switch (wBitCount) {
+    case 1:
+	return 2;
+    case 4:
+	return 16;
+    case 8:
+	return 256;
+    default:
+	return 0;
+    }
+}
+
+/*
+ * Helper functions
+ */
+
+/*
+ * ParseFontWords converts various keywords to modifyers of a
+ * font specification.
+ * For all words, later occurrences override earlier occurrences.
+ * Overstrike and underline cannot be "undone" by other words
+ */
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiParseFontWords --
+ *
+ *	Converts various keywords to modifiers of a font specification.  For
+ *	all words, later occurrences override earlier occurrences.  Overstrike
+ *	and underline cannot be "undone" by other words
+ *
+ * Results:
+ *	 Keywords converted to modifiers.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiParseFontWords(
+    TCL_UNUSED(Tcl_Interp *),
+    LOGFONTW *lf,
+    const char *str[],
+    int numargs)
+{
+    int i;
+    int retval = 0; /* Number of words that could not be parsed. */
+
+    for (i=0; i<numargs; i++) {
+	if (str[i]) {
+	    int wt;
+	    if ((wt = GdiWordToWeight(str[i])) != -1) {
+		lf->lfWeight = wt;
+	    } else if (strcmp(str[i], "roman") == 0) {
+		lf->lfItalic = FALSE;
+	    } else if (strcmp(str[i], "italic") == 0) {
+		lf->lfItalic = TRUE;
+	    } else if (strcmp(str[i], "underline") == 0) {
+		lf->lfUnderline = TRUE;
+	    } else if (strcmp(str[i], "overstrike") == 0) {
+		lf->lfStrikeOut = TRUE;
+	    } else {
+		retval++;
+	    }
+	}
+    }
+    return retval;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiWordToWeight --
+ *
+ *	Converts keywords to font weights.
+ *
+ * Results:
+ *	Helps set the proper font for GDI rendering.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiWordToWeight(
+    const char *str)
+{
+    int retval = -1;
+    size_t i;
+    static const struct font_weight {
+	const char *name;
+	int weight;
+    } font_weights[] = {
+	{ "thin", FW_THIN },
+	{ "extralight", FW_EXTRALIGHT },
+	{ "ultralight", FW_EXTRALIGHT },
+	{ "light", FW_LIGHT },
+	{ "normal", FW_NORMAL },
+	{ "regular", FW_NORMAL },
+	{ "medium", FW_MEDIUM },
+	{ "semibold", FW_SEMIBOLD },
+	{ "demibold", FW_SEMIBOLD },
+	{ "bold", FW_BOLD },
+	{ "extrabold", FW_EXTRABOLD },
+	{ "ultrabold", FW_EXTRABOLD },
+	{ "heavy", FW_HEAVY },
+	{ "black", FW_HEAVY },
+    };
+
+    if (str == 0) {
+	return -1;
+    }
+
+    for (i=0; i<sizeof(font_weights) / sizeof(struct font_weight); i++) {
+	if (strcmp(str, font_weights[i].name) == 0) {
+	    retval = font_weights[i].weight;
+	    break;
+	}
+    }
+
+    return retval;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * MakeLogFont --
+ *
+ *	Takes the font description string and converts this into a logical
+ *	font spec.
+ *
+ * Results:
+ *	 Sets font weight.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiMakeLogFont(
+    Tcl_Interp *interp,
+    const char *str,
+    LOGFONTW *lf,
+    HDC hDC)
+{
+    const char **list;
+    int count;
+
+    /* Set up defaults for logical font. */
+    memset(lf, 0, sizeof(*lf));
+    lf->lfWeight  = FW_NORMAL;
+    lf->lfCharSet = DEFAULT_CHARSET;
+    lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
+    lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
+    lf->lfQuality = DEFAULT_QUALITY;
+    lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
+
+    /* The cast to (char *) is silly, based on prototype of Tcl_SplitList. */
+    if (Tcl_SplitList(interp, str, &count, &list) != TCL_OK) {
+	return 0;
+    }
+
+    /* Now we have the font structure broken into name, size, weight. */
+    if (count >= 1) {
+	Tcl_DString ds;
+
+	Tcl_DStringInit(&ds);
+	wcsncpy(lf->lfFaceName, Tcl_UtfToWCharDString(list[0], -1, &ds),
+		LF_FACESIZE-1);
+	Tcl_DStringFree(&ds);
+	lf->lfFaceName[LF_FACESIZE-1] = 0;
+    } else {
+	return 0;
+    }
+
+    if (count >= 2) {
+	int siz;
+	char *strend;
+	siz = strtol(list[1], &strend, 0);
+
+	/*
+	 * Assumptions:
+	 * 1) Like canvas, if a positive number is specified, it's in points.
+	 * 2) Like canvas, if a negative number is specified, it's in pixels.
+	 */
+	if (strend > list[1]) { /* If it looks like a number, it is a number.... */
+	    if (siz > 0) {  /* Size is in points. */
+		SIZE wextent, vextent;
+		POINT worigin, vorigin;
+		double factor;
+
+		switch (GdiGetHdcInfo(hDC, &worigin, &wextent, &vorigin, &vextent)) {
+		case MM_ISOTROPIC:
+		    if (vextent.cy < -1 || vextent.cy > 1) {
+			factor = (double)wextent.cy / vextent.cy;
+			if (factor < 0.0) {
+			    factor = -factor;
+			}
+			lf->lfHeight = (int)(-siz * GetDeviceCaps(hDC, LOGPIXELSY) * factor / 72.0);
+		    } else if (vextent.cx < -1 || vextent.cx > 1) {
+			factor = (double)wextent.cx / vextent.cx;
+			if (factor < 0.0) {
+			    factor = -factor;
+			}
+			lf->lfHeight = (int)(-siz * GetDeviceCaps(hDC, LOGPIXELSY) * factor / 72.0);
+		    } else {
+			lf->lfHeight = -siz; /* This is bad news.... */
+		    }
+		    break;
+		case MM_ANISOTROPIC:
+		    if (vextent.cy != 0) {
+			factor = (double)wextent.cy / vextent.cy;
+			if (factor < 0.0) {
+			    factor = -factor;
+			}
+			lf->lfHeight = (int)(-siz * GetDeviceCaps(hDC, LOGPIXELSY) * factor / 72.0);
+		    } else {
+			lf->lfHeight = -siz; /* This is bad news.... */
+		    }
+		    break;
+		case MM_TEXT:
+		default:
+		    /* If mapping mode is MM_TEXT, use the documented
+		     * formula. */
+		    lf->lfHeight = -MulDiv(siz, GetDeviceCaps(hDC, LOGPIXELSY), 72);
+		    break;
+		case MM_HIENGLISH:
+		    lf->lfHeight = -MulDiv(siz, 1000, 72);
+		    break;
+		case MM_LOENGLISH:
+		    lf->lfHeight = -MulDiv(siz, 100, 72);
+		    break;
+		case MM_HIMETRIC:
+		    lf->lfHeight = -MulDiv(siz, (int)(1000*2.54), 72);
+		    break;
+		case MM_LOMETRIC:
+		    lf->lfHeight = -MulDiv(siz, (int)(100*2.54), 72);
+		    break;
+		case MM_TWIPS:
+		    lf->lfHeight = -MulDiv(siz, 1440, 72);
+		    break;
+		}
+	    } else if (siz == 0) {   /* Use default size of 12 points. */
+		lf->lfHeight = -MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72);
+	    } else {                 /* Use pixel size. */
+		lf->lfHeight = siz;  /* Leave this negative. */
+	    }
+	} else {
+	    GdiParseFontWords(interp, lf, list+1, count-1);
+	}
+    }
+
+    if (count >= 3) {
+	GdiParseFontWords(interp, lf, list+2, count-2);
+    }
+
+    Tcl_Free((char *)list);
+    return 1;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiMakePen --
+ *
+ *	Creates a logical pen based on input parameters and selects it into
+ *	the hDC.
+ *
+ * Results:
+ *	Sets rendering pen.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiMakePen(
+    Tcl_Interp *interp,
+    int width,
+    int dashstyle,
+    const char *dashstyledata,
+    TCL_UNUSED(int),		/* Ignored for now. */
+    TCL_UNUSED(int),		/* Ignored for now. */
+    TCL_UNUSED(int),
+    TCL_UNUSED(const char *),	/* Ignored for now. */
+    unsigned long color,
+    HDC hDC,
+    HGDIOBJ *oldPen)
+{
+    /*
+     * The LOGPEN structure takes the following dash options:
+     * PS_SOLID: a solid pen
+     * PS_DASH:  a dashed pen
+     * PS_DOT:   a dotted pen
+     * PS_DASHDOT: a pen with a dash followed by a dot
+     * PS_DASHDOTDOT: a pen with a dash followed by 2 dots
+     *
+     * It seems that converting to ExtCreatePen may be more advantageous, as
+     * it matches the Tk canvas pens much better--but not for Win95, which
+     * does not support PS_USERSTYLE. An explicit test (or storage in a static
+     * after first failure) may suffice for working around this. The
+     * ExtCreatePen is not supported at all under Win32.
+     */
+
+    HPEN hPen;
+    LOGBRUSH lBrush;
+    DWORD pStyle = PS_SOLID;           /* -dash should override*/
+    DWORD endStyle = PS_ENDCAP_ROUND;  /* -capstyle should override. */
+    DWORD joinStyle = PS_JOIN_ROUND;   /* -joinstyle should override. */
+    DWORD styleCount = 0;
+    DWORD *styleArray = 0;
+
+    /*
+     * To limit the propagation of allocated memory, the dashes will have a
+     * maximum here.  If one wishes to remove the static allocation, please be
+     * sure to update GdiFreePen and ensure that the array is NOT freed if the
+     * LOGPEN option is used.
+     */
+    static DWORD pStyleData[24];
+    if (dashstyle != 0 && dashstyledata != 0) {
+	const char *cp;
+	size_t i;
+	char *dup = (char *) Tcl_Alloc(strlen(dashstyledata) + 1);
+	strcpy(dup, dashstyledata);
+	/* DEBUG. */
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"DEBUG: Found a dash spec of |%s|\n",
+		dashstyledata));
+
+	/* Parse the dash spec. */
+	if (isdigit(dashstyledata[0])) {
+	    cp = strtok(dup, " \t,;");
+	    for (i = 0; cp && i < sizeof(pStyleData) / sizeof(DWORD); i++) {
+		pStyleData[styleCount++] = atoi(cp);
+		cp = strtok(NULL, " \t,;");
+	    }
+	} else {
+	    for (i=0; dashstyledata[i] != '\0' && i< sizeof(pStyleData) / sizeof(DWORD); i++) {
+		switch (dashstyledata[i]) {
+		case ' ':
+		    pStyleData[styleCount++] = 8;
+		    break;
+		case ',':
+		    pStyleData[styleCount++] = 4;
+		    break;
+		case '_':
+		    pStyleData[styleCount++] = 6;
+		    break;
+		case '-':
+		    pStyleData[styleCount++] = 4;
+		    break;
+		case '.':
+		    pStyleData[styleCount++] = 2;
+		    break;
+		default:
+		    break;
+		}
+	    }
+	}
+	if (styleCount > 0) {
+	    styleArray = pStyleData;
+	} else {
+	    dashstyle = 0;
+	}
+	if (dup) {
+	    Tcl_Free(dup);
+	}
+    }
+
+    if (dashstyle != 0) {
+	pStyle = PS_USERSTYLE;
+    }
+
+    /* -stipple could affect this.... */
+    lBrush.lbStyle = BS_SOLID;
+    lBrush.lbColor = color;
+    lBrush.lbHatch = 0;
+
+    /* We only use geometric pens, even for 1-pixel drawing. */
+    hPen = ExtCreatePen(PS_GEOMETRIC|pStyle|endStyle|joinStyle,
+	    width, &lBrush, styleCount, styleArray);
+
+    if (hPen == 0) { /* Failed for some reason...Fall back on CreatePenIndirect. */
+	LOGPEN lf;
+	lf.lopnWidth.x = width;
+	lf.lopnWidth.y = 0;		/* Unused in LOGPEN. */
+	if (dashstyle == 0) {
+	    lf.lopnStyle = PS_SOLID;	/* For now...convert 'style' in the future. */
+	} else {
+	    lf.lopnStyle = PS_DASH;	/* REALLLLY simple for now. */
+	}
+	lf.lopnColor = color;		/* Assume we're getting a COLORREF. */
+	/* Now we have a logical pen. Create the "real" pen and put it in the
+	 * hDC. */
+	hPen = CreatePenIndirect(&lf);
+    }
+
+    *oldPen = SelectObject(hDC, hPen);
+    return 1;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiFreePen --
+ *
+ *	Wraps the protocol to delete a created pen.
+ *
+ * Results:
+ *	Deletes pen.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiFreePen(
+    TCL_UNUSED(Tcl_Interp *),
+    HDC hDC,
+    HGDIOBJ oldPen)
+{
+    HGDIOBJ gonePen = SelectObject(hDC, oldPen);
+
+    DeleteObject(gonePen);
+    return 1;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiMakeBrush--
+ *
+ *	Creates a logical brush based on input parameters, and selects it into
+ *	the hdc.
+ *
+ * Results:
+ *	 Creates brush.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiMakeBrush(
+    TCL_UNUSED(Tcl_Interp *),
+    TCL_UNUSED(unsigned int),
+    unsigned long color,
+    long hatch,
+    LOGBRUSH *lb,
+    HDC hDC,
+    HGDIOBJ *oldBrush)
+{
+    HBRUSH hBrush;
+    lb->lbStyle = BS_SOLID; /* Support other styles later. */
+    lb->lbColor = color;    /* Assume this is a COLORREF. */
+    lb->lbHatch = hatch;    /* Ignored for now, given BS_SOLID in the Style. */
+
+    /* Now we have the logical brush. Create the "real" brush and put it in
+     * the hDC. */
+    hBrush = CreateBrushIndirect(lb);
+    *oldBrush = SelectObject(hDC, hBrush);
+    return 1;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiFreeBrush --
+ *
+ *	Wraps the protocol to delete a created brush.
+ *
+ * Results:
+ *	 Deletes brush.
+ *
+ *----------------------------------------------------------------------
+ */
+static int GdiFreeBrush(
+    TCL_UNUSED(Tcl_Interp *),
+    HDC hDC,
+    HGDIOBJ oldBrush)
+{
+    HGDIOBJ goneBrush;
+
+    goneBrush = SelectObject(hDC, oldBrush);
+    DeleteObject(goneBrush);
+    return 1;
+}
+
+/*
+ * Utility functions from elsewhere in Tcl.
+ * Functions have removed reliance on X and Tk libraries, as well as removing
+ * the need for TkWindows.
+ * GdiGetColor is a copy of a TkpGetColor from tkWinColor.c
+ */
+typedef struct {
+    const char *name;
+    int index;
+} SystemColorEntry;
+
+static const SystemColorEntry sysColors[] = {
+    {"3dDarkShadow",		COLOR_3DDKSHADOW},
+    {"3dLight",			COLOR_3DLIGHT},
+    {"ActiveBorder",		COLOR_ACTIVEBORDER},
+    {"ActiveCaption",		COLOR_ACTIVECAPTION},
+    {"AppWorkspace",		COLOR_APPWORKSPACE},
+    {"Background",		COLOR_BACKGROUND},
+    {"ButtonFace",		COLOR_BTNFACE},
+    {"ButtonHighlight",		COLOR_BTNHIGHLIGHT},
+    {"ButtonShadow",		COLOR_BTNSHADOW},
+    {"ButtonText",		COLOR_BTNTEXT},
+    {"CaptionText",		COLOR_CAPTIONTEXT},
+    {"DisabledText",		COLOR_GRAYTEXT},
+    {"GrayText",		COLOR_GRAYTEXT},
+    {"Highlight",		COLOR_HIGHLIGHT},
+    {"HighlightText",		COLOR_HIGHLIGHTTEXT},
+    {"InactiveBorder",		COLOR_INACTIVEBORDER},
+    {"InactiveCaption",		COLOR_INACTIVECAPTION},
+    {"InactiveCaptionText",	COLOR_INACTIVECAPTIONTEXT},
+    {"InfoBackground",		COLOR_INFOBK},
+    {"InfoText",		COLOR_INFOTEXT},
+    {"Menu",			COLOR_MENU},
+    {"MenuText",		COLOR_MENUTEXT},
+    {"Scrollbar",		COLOR_SCROLLBAR},
+    {"Window",			COLOR_WINDOW},
+    {"WindowFrame",		COLOR_WINDOWFRAME},
+    {"WindowText",		COLOR_WINDOWTEXT}
+};
+
+static int numsyscolors = 0;
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GdiGetColor --
+ *
+ *	Convert color name to color specification.
+ *
+ * Results:
+ *	 Color name converted.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int GdiGetColor(
+    const char *name,
+	COLORREF *color)
+{
+    if (numsyscolors == 0) {
+	numsyscolors = sizeof(sysColors) / sizeof(SystemColorEntry);
+    }
+    if (_strnicmp(name, "system", 6) == 0) {
+	int i, l, u, r;
+
+	l = 0;
+	u = numsyscolors;
+	while (l <= u) {
+	    i = (l + u) / 2;
+	    if ((r = _strcmpi(name+6, sysColors[i].name)) == 0) {
+		break;
+	    }
+	    if (r < 0) {
+		u = i - 1;
+	    } else {
+		l = i + 1;
+	    }
+	}
+	if (l > u) {
+	    return 0;
+	}
+	*color = GetSysColor(sysColors[i].index);
+	return 1;
+    } else {
+    int result;
+    XColor xcolor;
+	result = XParseColor(NULL, 0, name, &xcolor);
+	*color = ((xcolor.red & 0xFF00)>>8) | (xcolor.green & 0xFF00)
+		| ((xcolor.blue & 0xFF00)<<8);
+    return result;
+    }
+}
+
+/*
+ * Beginning of functions for screen-to-dib translations.
+ *
+ * Several of these functions are based on those in the WINCAP32 program
+ * provided as a sample by Microsoft on the VC++ 5.0 disk. The copyright on
+ * these functions is retained, even for those with significant changes.
+ */
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CopyToDIB --
+ *
+ *	Copy window bits to a DIB.
+ *
+ * Results:
+ *	 Color specification converted.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static HANDLE CopyToDIB(
+    HWND hWnd,
+    enum PrintType type)
+{
+    HANDLE hDIB;
+    HBITMAP hBitmap;
+    HPALETTE hPalette;
+
+    /* Check for a valid window handle. */
+
+    if (!hWnd) {
+        return NULL;
+    }
+
+    switch (type) {
+    case PTWindow: {	/* Copy entire window. */
+	RECT rectWnd;
+
+	/* Get the window rectangle. */
+
+	GetWindowRect(hWnd, &rectWnd);
+
+	/*
+	 * Get the DIB of the window by calling CopyScreenToDIB and passing it
+	 * the window rect.
+	 */
+
+	hDIB = CopyScreenToDIB(&rectWnd);
+	break;
+    }
+
+    case PTClient: {	/* Copy client area. */
+	RECT rectClient;
+	POINT pt1, pt2;
+
+	/* Get the client area dimensions. */
+
+	GetClientRect(hWnd, &rectClient);
+
+	/* Convert client coords to screen coords. */
+
+	pt1.x = rectClient.left;
+	pt1.y = rectClient.top;
+	pt2.x = rectClient.right;
+	pt2.y = rectClient.bottom;
+	ClientToScreen(hWnd, &pt1);
+	ClientToScreen(hWnd, &pt2);
+	rectClient.left = pt1.x;
+	rectClient.top = pt1.y;
+	rectClient.right = pt2.x;
+	rectClient.bottom = pt2.y;
+
+	/*
+	 * Get the DIB of the client area by calling CopyScreenToDIB and
+	 * passing it the client rect.
+	 */
+
+	hDIB = CopyScreenToDIB(&rectClient);
+	break;
+    }
+
+    case PTScreen: { /* Entire screen. */
+	RECT Rect;
+
+	/*
+	 * Get the device-dependent bitmap in lpRect by calling
+	 * CopyScreenToBitmap and passing it the rectangle to grab.
+	 */
+	Rect.top = Rect.left = 0;
+	GetDisplaySize(&Rect.right, &Rect.bottom);
+
+	hBitmap = CopyScreenToBitmap(&Rect);
+
+	/* Check for a valid bitmap handle. */
+
+	if (!hBitmap) {
+	    return NULL;
+	}
+
+	/* Get the current palette. */
+
+	hPalette = GetSystemPalette();
+
+	/* Convert the bitmap to a DIB. */
+
+	hDIB = BitmapToDIB(hBitmap, hPalette);
+
+	/* Clean up. */
+
+	DeleteObject(hPalette);
+	DeleteObject(hBitmap);
+
+	/* Return handle to the packed-DIB. */
+	break;
+    }
+    default:	/* Invalid print area. */
+	return NULL;
+    }
+
+    /* Return the handle to the DIB. */
+    return hDIB;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetDisplaySize--
+ *
+ *	GetDisplaySize does just that.  There may be an easier way, but it is
+ *	not apparent.
+ *
+ * Results:
+ *	Returns display size.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void GetDisplaySize(
+    LONG *width,
+    LONG *height)
+{
+    HDC hDC;
+
+    hDC = CreateDCW(L"DISPLAY", 0, 0, 0);
+    *width = GetDeviceCaps(hDC, HORZRES);
+    *height = GetDeviceCaps(hDC, VERTRES);
+    DeleteDC(hDC);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CopyScreenToBitmap--
+ *
+ *	Copies screen to bitmap.
+ *
+ * Results:
+ *	Screen is copied.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static HBITMAP CopyScreenToBitmap(
+    LPRECT lpRect)
+{
+    HDC     hScrDC, hMemDC;	/* Screen DC and memory DC. */
+    HBITMAP hBitmap, hOldBitmap; /* Handles to deice-dependent bitmaps. */
+    int     nX, nY, nX2, nY2;	/* Coordinates of rectangle to grab. */
+    int     nWidth, nHeight;	/* DIB width and height */
+    int     xScrn, yScrn;	/* Screen resolution. */
+
+    /* Check for an empty rectangle. */
+
+    if (IsRectEmpty(lpRect)) {
+	return NULL;
+    }
+
+    /*
+     * Create a DC for the screen and create a memory DC compatible to screen
+     * DC.
+     */
+
+    hScrDC = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
+    hMemDC = CreateCompatibleDC(hScrDC);
+
+    /* Get points of rectangle to grab. */
+
+    nX = lpRect->left;
+    nY = lpRect->top;
+    nX2 = lpRect->right;
+    nY2 = lpRect->bottom;
+
+    /* Get screen resolution. */
+
+    xScrn = GetDeviceCaps(hScrDC, HORZRES);
+    yScrn = GetDeviceCaps(hScrDC, VERTRES);
+
+    /* Make sure bitmap rectangle is visible. */
+
+    if (nX < 0) {
+        nX = 0;
+    }
+    if (nY < 0) {
+        nY = 0;
+    }
+    if (nX2 > xScrn) {
+        nX2 = xScrn;
+    }
+    if (nY2 > yScrn) {
+        nY2 = yScrn;
+    }
+
+    nWidth = nX2 - nX;
+    nHeight = nY2 - nY;
+
+    /* Create a bitmap compatible with the screen DC. */
+    hBitmap = CreateCompatibleBitmap(hScrDC, nWidth, nHeight);
+
+    /* Select new bitmap into memory DC. */
+    hOldBitmap = SelectObject(hMemDC, hBitmap);
+
+    /* Bitblt screen DC to memory DC. */
+    BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY);
+
+    /*
+     * Select old bitmap back into memory DC and get handle to bitmap of the
+     * screen.
+     */
+
+    hBitmap = SelectObject(hMemDC, hOldBitmap);
+
+    /* Clean up. */
+
+    DeleteDC(hScrDC);
+    DeleteDC(hMemDC);
+
+    /* Return handle to the bitmap. */
+
+    return hBitmap;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * BitmapToDIB--
+ *
+ *	Converts bitmap to DIB.
+ *
+ * Results:
+ *	Bitmap converted.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static HANDLE BitmapToDIB(
+    HBITMAP hBitmap,
+    HPALETTE hPal)
+{
+    BITMAP              bm;
+    BITMAPINFOHEADER    bi;
+    LPBITMAPINFOHEADER  lpbi;
+    DWORD               dwLen;
+    HANDLE              hDIB;
+    HANDLE              h;
+    HDC                 hDC;
+    WORD                biBits;
+
+    /* Check if bitmap handle is valid. */
+
+    if (!hBitmap) {
+        return NULL;
+    }
+
+    /* Fill in BITMAP structure, return NULL if it didn't work. */
+
+    if (!GetObjectW(hBitmap, sizeof(bm), (LPWSTR)&bm)) {
+        return NULL;
+    }
+
+    /* Ff no palette is specified, use default palette. */
+
+    if (hPal == NULL) {
+        hPal = GetStockObject(DEFAULT_PALETTE);
+    }
+
+    /* Calculate bits per pixel. */
+
+    biBits = bm.bmPlanes * bm.bmBitsPixel;
+
+    /* Make sure bits per pixel is valid. */
+
+    if (biBits <= 1) {
+        biBits = 1;
+    } else if (biBits <= 4) {
+        biBits = 4;
+    } else if (biBits <= 8) {
+        biBits = 8;
+    } else { /* If greater than 8-bit, force to 24-bit. */
+        biBits = 24;
+    }
+
+    /* Initialize BITMAPINFOHEADER. */
+
+    bi.biSize = sizeof(BITMAPINFOHEADER);
+    bi.biWidth = bm.bmWidth;
+    bi.biHeight = bm.bmHeight;
+    bi.biPlanes = 1;
+    bi.biBitCount = biBits;
+    bi.biCompression = BI_RGB;
+    bi.biSizeImage = 0;
+    bi.biXPelsPerMeter = 0;
+    bi.biYPelsPerMeter = 0;
+    bi.biClrUsed = 0;
+    bi.biClrImportant = 0;
+
+    /* Calculate size of memory block required to store BITMAPINFO. */
+
+    dwLen = bi.biSize + DIBNumColors(&bi) * sizeof(RGBQUAD);
+
+    /* Get a DC. */
+
+    hDC = GetDC(NULL);
+
+    /* Select and realize our palette. */
+
+    hPal = SelectPalette(hDC, hPal, FALSE);
+    RealizePalette(hDC);
+
+    /* Alloc memory block to store our bitmap. */
+
+    hDIB = GlobalAlloc(GHND, dwLen);
+
+    /* If we couldn't get memory block. */
+
+    if (!hDIB) {
+	/* clean up and return NULL. */
+
+	SelectPalette(hDC, hPal, TRUE);
+	RealizePalette(hDC);
+	ReleaseDC(NULL, hDC);
+	return NULL;
+    }
+
+    /* Lock memory and get pointer to it. */
+
+    lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
+
+    /* Use our bitmap info. to fill BITMAPINFOHEADER. */
+
+    *lpbi = bi;
+
+    /* Call GetDIBits with a NULL lpBits param, so it will calculate the
+     * biSizeImage field for us
+     */
+
+    GetDIBits(hDC, hBitmap, 0, (UINT)bi.biHeight, NULL, (LPBITMAPINFO)lpbi,
+	    DIB_RGB_COLORS);
+
+    /* get the info. returned by GetDIBits and unlock memory block. */
+
+    bi = *lpbi;
+    GlobalUnlock(hDIB);
+
+    /* If the driver did not fill in the biSizeImage field, make one up. */
+    if (bi.biSizeImage == 0) {
+        bi.biSizeImage = (((((DWORD)bm.bmWidth * biBits) + 31) / 32) * 4)
+		* bm.bmHeight;
+    }
+
+    /* Realloc the buffer big enough to hold all the bits. */
+
+    dwLen = bi.biSize + DIBNumColors(&bi) * sizeof(RGBQUAD) + bi.biSizeImage;
+
+    if ((h = GlobalReAlloc(hDIB, dwLen, 0)) != 0) {
+        hDIB = h;
+    } else {
+	/* Clean up and return NULL. */
+
+	GlobalFree(hDIB);
+	SelectPalette(hDC, hPal, TRUE);
+	RealizePalette(hDC);
+	ReleaseDC(NULL, hDC);
+	return NULL;
+    }
+
+    /* Lock memory block and get pointer to it. */
+
+    lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
+
+    /* Call GetDIBits with a NON-NULL lpBits param, and actualy get the
+     * bits this time.
+     */
+
+    if (GetDIBits(hDC, hBitmap, 0, (UINT)bi.biHeight, (LPSTR)lpbi +
+	    (WORD)lpbi->biSize + DIBNumColors(lpbi) * sizeof(RGBQUAD),
+	    (LPBITMAPINFO)lpbi, DIB_RGB_COLORS) == 0) {
+	/* Clean up and return NULL. */
+
+	GlobalUnlock(hDIB);
+	SelectPalette(hDC, hPal, TRUE);
+	RealizePalette(hDC);
+	ReleaseDC(NULL, hDC);
+	return NULL;
+    }
+
+    bi = *lpbi;
+
+    /* Clean up. */
+    GlobalUnlock(hDIB);
+    SelectPalette(hDC, hPal, TRUE);
+    RealizePalette(hDC);
+    ReleaseDC(NULL, hDC);
+
+    /* Return handle to the DIB. */
+    return hDIB;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CopyScreenToDIB--
+ *
+ *	Copies screen to DIB.
+ *
+ * Results:
+ *	Screen copied.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static HANDLE CopyScreenToDIB(
+    LPRECT lpRect)
+{
+    HBITMAP     hBitmap;
+    HPALETTE    hPalette;
+    HANDLE      hDIB;
+
+    /*
+     * Get the device-dependent bitmap in lpRect by calling CopyScreenToBitmap
+     * and passing it the rectangle to grab.
+     */
+
+    hBitmap = CopyScreenToBitmap(lpRect);
+
+    /* Check for a valid bitmap handle. */
+
+    if (!hBitmap) {
+	return NULL;
+    }
+
+    /* Get the current palette. */
+
+    hPalette = GetSystemPalette();
+
+    /* convert the bitmap to a DIB. */
+
+    hDIB = BitmapToDIB(hBitmap, hPalette);
+
+    /* Clean up. */
+
+    DeleteObject(hPalette);
+    DeleteObject(hBitmap);
+
+    /* Return handle to the packed-DIB. */
+    return hDIB;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetSystemPalette--
+ *
+ *	Obtains the system palette.
+ *
+ * Results:
+ *	Returns palette.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static HPALETTE GetSystemPalette(void)
+{
+    HDC hDC;                /* Handle to a DC. */
+    static HPALETTE hPal = NULL;   /* Handle to a palette. */
+    HANDLE hLogPal;         /* Handle to a logical palette. */
+    LPLOGPALETTE lpLogPal;  /* Pointer to a logical palette. */
+    int nColors;            /* Number of colors. */
+
+    /* Find out how many palette entries we want.. */
+
+    hDC = GetDC(NULL);
+    if (!hDC) {
+        return NULL;
+    }
+
+    nColors = PalEntriesOnDevice(hDC);   /* Number of palette entries. */
+
+    /* Allocate room for the palette and lock it.. */
+
+    hLogPal = GlobalAlloc(GHND, sizeof(LOGPALETTE) + nColors *
+	    sizeof(PALETTEENTRY));
+    if (!hLogPal) {
+	/* If we didn't get a logical palette, return NULL. */
+
+        return NULL;
+    }
+
+    /* get a pointer to the logical palette. */
+
+    lpLogPal = (LPLOGPALETTE)GlobalLock(hLogPal);
+
+    /* Set some important fields. */
+
+    lpLogPal->palVersion = 0x300;
+    lpLogPal->palNumEntries = nColors;
+
+    /* Copy the current system palette into our logical palette. */
+
+    GetSystemPaletteEntries(hDC, 0, nColors,
+	    (LPPALETTEENTRY) lpLogPal->palPalEntry);
+
+    /*
+     * Go ahead and create the palette.  Once it's created, we no longer need
+     * the LOGPALETTE, so free it.
+     */
+
+    hPal = CreatePalette(lpLogPal);
+
+    /* Clean up. */
+
+    GlobalUnlock(hLogPal);
+    GlobalFree(hLogPal);
+    ReleaseDC(NULL, hDC);
+
+    return hPal;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * PalEntriesOnDevice--
+ *
+ *	Returns the palettes on the device.
+ *
+ * Results:
+ *	Returns palettes.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int PalEntriesOnDevice(
+    HDC hDC)
+{
+    return (1 << (GetDeviceCaps(hDC, BITSPIXEL) * GetDeviceCaps(hDC, PLANES)));
+}
+
+/*
+ * --------------------------------------------------------------------------
+ *
+ * Winprint_Init--
+ *
+ *	Initializes printing module on Windows.
+ *
+ * Results:
+ *	Module initialized.
+ *
+ * -------------------------------------------------------------------------
+ */
+
+int Winprint_Init(
+    Tcl_Interp * interp)
+{
+    size_t i;
+    Tcl_Namespace *namespacePtr;
+    static const char *gdiName = "::tk::print::_gdi";
+    static const size_t numCommands =
+	    sizeof(gdi_commands) / sizeof(struct gdi_command);
+
+    /*
+     * Set up the low-level [_gdi] command.
+     */
+
+    namespacePtr = Tcl_CreateNamespace(interp, gdiName,
+	    NULL, (Tcl_NamespaceDeleteProc *) NULL);
+    for (i=0; i<numCommands; i++) {
+	char buffer[100];
+
+	sprintf(buffer, "%s::%s", gdiName, gdi_commands[i].command_string);
+	Tcl_CreateCommand(interp, buffer, gdi_commands[i].command,
+		NULL, (Tcl_CmdDeleteProc *) 0);
+	Tcl_Export(interp, namespacePtr, gdi_commands[i].command_string, 0);
+    }
+    Tcl_CreateEnsemble(interp, gdiName, namespacePtr, 0);
+
+    /*
+     * The other printing-related commands.
+     */
+
+    Tcl_CreateObjCommand(interp, "::tk::print::_selectprinter",
+	    PrintSelectPrinter, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "::tk::print::_openprinter",
+	    PrintOpenPrinter, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "::tk::print::_closeprinter",
+	    PrintClosePrinter, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "::tk::print::_opendoc",
+	    PrintOpenDoc, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "::tk::print::_closedoc",
+	    PrintCloseDoc, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "::tk::print::_openpage",
+	    PrintOpenPage, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "::tk::print::_closepage",
+	    PrintClosePage, NULL, NULL);
+    return TCL_OK;
+}
+
+/* Print API functions. */
+
+/*----------------------------------------------------------------------
+ *
+ * PrintSelectPrinter--
+ *
+ *	Main dialog for selecting printer and initializing data for print job.
+ *
+ * Results:
+ *	Printer selected.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int PrintSelectPrinter(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    TCL_UNUSED(int),
+    TCL_UNUSED(Tcl_Obj* const*))
+{
+    LPCWSTR printerName = NULL;
+    PDEVMODEW returnedDevmode = NULL;
+    PDEVMODEW localDevmode = NULL;
+
+    copies = 0;
+    paper_width = 0;
+    paper_height = 0;
+    dpi_x = 0;
+    dpi_y = 0;
+
+    /* Set up print dialog and initalize property structure. */
+
+    ZeroMemory(&pd, sizeof(pd));
+    pd.lStructSize = sizeof(pd);
+    pd.hwndOwner = GetDesktopWindow();
+    pd.Flags = PD_HIDEPRINTTOFILE | PD_DISABLEPRINTTOFILE | PD_NOSELECTION;
+
+    if (PrintDlgW(&pd) == TRUE) {
+
+	/*Get document info.*/
+	ZeroMemory(&di, sizeof(di));
+	di.cbSize = sizeof(di);
+	di.lpszDocName = L"Tk Print Output";
+
+	/* Copy print attributes to local structure. */
+	returnedDevmode = (PDEVMODEW) GlobalLock(pd.hDevMode);
+	devnames = (LPDEVNAMES) GlobalLock(pd.hDevNames);
+	printerName = (LPCWSTR) devnames + devnames->wDeviceOffset;
+	localDevmode = (LPDEVMODEW) HeapAlloc(GetProcessHeap(),
+		HEAP_ZERO_MEMORY | HEAP_GENERATE_EXCEPTIONS,
+		returnedDevmode->dmSize);
+
+	if (localDevmode != NULL) {
+	    memcpy((LPVOID)localDevmode, (LPVOID)returnedDevmode,
+		    returnedDevmode->dmSize);
+
+	    /* Get values from user-set and built-in properties. */
+	    localPrinterName = localDevmode->dmDeviceName;
+	    dpi_y = localDevmode->dmYResolution;
+	    dpi_x = localDevmode->dmPrintQuality;
+	    /* Convert height and width to logical points. */
+	    paper_height = (int) localDevmode->dmPaperLength / 0.254;
+	    paper_width = (int) localDevmode->dmPaperWidth / 0.254;
+	    copies = pd.nCopies;
+	    /* Set device context here for all GDI printing operations. */
+	    printDC = CreateDCW(L"WINSPOOL", printerName, NULL, localDevmode);
+	} else {
+	    localDevmode = NULL;
+	}
+    }
+
+    if (pd.hDevMode != NULL) {
+	GlobalFree(pd.hDevMode);
+    }
+
+    /*
+     * Store print properties and link variables so they can be accessed from
+     * script level.
+     */
+    if (localPrinterName != NULL) {
+        char* varlink1 = (char*)Tcl_Alloc(100 * sizeof(char));
+        char** varlink2 = (char**)Tcl_Alloc(sizeof(char*));
+        *varlink2 = varlink1;
+        WideCharToMultiByte(CP_UTF8, 0, localPrinterName, -1, varlink1, 0, NULL, NULL);
+
+        Tcl_LinkVar(interp, "::tk::print::printer_name", (char*)varlink2,
+            TCL_LINK_STRING | TCL_LINK_READ_ONLY);
+        Tcl_LinkVar(interp, "::tk::print::copies", (char*)&copies,
+            TCL_LINK_INT | TCL_LINK_READ_ONLY);
+        Tcl_LinkVar(interp, "::tk::print::dpi_x", (char*)&dpi_x,
+            TCL_LINK_INT | TCL_LINK_READ_ONLY);
+        Tcl_LinkVar(interp, "::tk::print::dpi_y", (char*)&dpi_y,
+            TCL_LINK_INT | TCL_LINK_READ_ONLY);
+        Tcl_LinkVar(interp, "::tk::print::paper_width", (char*)&paper_width,
+            TCL_LINK_INT | TCL_LINK_READ_ONLY);
+        Tcl_LinkVar(interp, "::tk::print::paper_height", (char*)&paper_height,
+            TCL_LINK_INT | TCL_LINK_READ_ONLY);
+    }
+
+    return TCL_OK;
+}
+
+/*
+ * --------------------------------------------------------------------------
+ *
+ * PrintOpenPrinter--
+ *
+ *	Open the given printer.
+ *
+ * Results:
+ *	Opens the selected printer.
+ *
+ * -------------------------------------------------------------------------
+ */
+
+int PrintOpenPrinter(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    int argc,
+    Tcl_Obj *const objv[])
+{
+    Tcl_DString ds;
+
+    if (argc < 2) {
+	Tcl_WrongNumArgs(interp, 1, objv, "printer");
+	return TCL_ERROR;
+    }
+
+    /*Start an individual page.*/
+    if (StartPage(printDC) <= 0) {
+	return TCL_ERROR;
+    }
+
+    const char *printer = Tcl_GetString(objv[1]);
+
+    if (printDC == NULL) {
+	Tcl_AppendResult(interp, "unable to establish device context", NULL);
+	return TCL_ERROR;
+    }
+
+    Tcl_DStringInit(&ds);
+    if ((OpenPrinterW(Tcl_UtfToWCharDString(printer, -1, &ds),
+	    (LPHANDLE)&printDC, NULL)) == FALSE) {
+	Tcl_AppendResult(interp, "unable to open printer", NULL);
+	Tcl_DStringFree(&ds);
+	return TCL_ERROR;
+    }
+
+    Tcl_DStringFree(&ds);
+    return TCL_OK;
+}
+
+/*
+ * --------------------------------------------------------------------------
+ *
+ * PrintClosePrinter--
+ *
+ *	Closes the given printer.
+ *
+ * Results:
+ *	Printer closed.
+ *
+ * -------------------------------------------------------------------------
+ */
+
+int PrintClosePrinter(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    TCL_UNUSED(int),
+    TCL_UNUSED(Tcl_Obj *const *))
+{
+    if (printDC == NULL) {
+	Tcl_AppendResult(interp, "unable to establish device context", NULL);
+	return TCL_ERROR;
+    }
+
+    ClosePrinter(printDC);
+    return TCL_OK;
+}
+
+/*
+ * --------------------------------------------------------------------------
+ *
+ * PrintOpenDoc--
+ *
+ *     Opens the document for printing.
+ *
+ * Results:
+ *      Opens the print document.
+ *
+ * -------------------------------------------------------------------------
+ */
+
+int PrintOpenDoc(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    TCL_UNUSED(int),
+    TCL_UNUSED(Tcl_Obj *const *))
+{
+    int output = 0;
+
+    if (printDC == NULL) {
+	Tcl_AppendResult(interp, "unable to establish device context", NULL);
+	return TCL_ERROR;
+    }
+
+    /*
+     * Start printing.
+     */
+    output = StartDocW(printDC, &di);
+    if (output <= 0) {
+	Tcl_AppendResult(interp, "unable to start document", NULL);
+	return TCL_ERROR;
+    }
+
+    return TCL_OK;
+}
+
+/*
+ * --------------------------------------------------------------------------
+ *
+ * PrintCloseDoc--
+ *
+ *	Closes the document for printing.
+ *
+ * Results:
+ *	Closes the print document.
+ *
+ * -------------------------------------------------------------------------
+ */
+
+int PrintCloseDoc(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    TCL_UNUSED(int),
+    TCL_UNUSED(Tcl_Obj *const *))
+{
+    if (printDC == NULL) {
+	Tcl_AppendResult(interp, "unable to establish device context", NULL);
+	return TCL_ERROR;
+    }
+
+    if (EndDoc(printDC) <= 0) {
+	Tcl_AppendResult(interp, "unable to establish close document", NULL);
+	return TCL_ERROR;
+    }
+    DeleteDC(printDC);
+    return TCL_OK;
+}
+
+/*
+ * --------------------------------------------------------------------------
+ *
+ * PrintOpenPage--
+ *
+ *    Opens a page for printing.
+ *
+ * Results:
+ *      Opens the print page.
+ *
+ * -------------------------------------------------------------------------
+ */
+
+int PrintOpenPage(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    TCL_UNUSED(int),
+    TCL_UNUSED(Tcl_Obj *const *))
+{
+    if (printDC == NULL) {
+	Tcl_AppendResult(interp, "unable to establish device context", NULL);
+	return TCL_ERROR;
+    }
+
+    /*Start an individual page.*/
+    if (StartPage(printDC) <= 0) {
+	Tcl_AppendResult(interp, "unable to start page", NULL);
+	return TCL_ERROR;
+    }
+
+    return TCL_OK;
+}
+
+/*
+ * --------------------------------------------------------------------------
+ *
+ * PrintClosePage--
+ *
+ *	Closes the printed page.
+ *
+ * Results:
+ *	Closes the page.
+ *
+ * -------------------------------------------------------------------------
+ */
+
+int PrintClosePage(
+    TCL_UNUSED(void *),
+    Tcl_Interp *interp,
+    TCL_UNUSED(int),
+    TCL_UNUSED(Tcl_Obj *const *))
+{
+    if (printDC == NULL) {
+	Tcl_AppendResult(interp, "unable to establish device context", NULL);
+	return TCL_ERROR;
+    }
+
+    if (EndPage(printDC) <= 0) {
+	Tcl_AppendResult(interp, "unable to close page", NULL);
+	return TCL_ERROR;
+    }
+    return TCL_OK;
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */

ADDED   win/tkWinIco.c
Index: win/tkWinIco.c
==================================================================
--- /dev/null
+++ win/tkWinIco.c
@@ -0,0 +1,227 @@
+/*
+ * tkWinIco.c --
+ *
+ *	This file contains functions for icon-manipulation routines
+ *      in Windows.
+ *
+ * Copyright © 1995-1996 Microsoft Corp.
+ * Copyright © 1998 Brueckner & Jarosch Ing.GmbH, Erfurt, Germany
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+#include "tkWinIco.h"
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * DIBNumColors --
+ *
+ *	Calculates the number of entries in the color table, given by LPSTR
+ *	lpbi - pointer to the CF_DIB memory block. Used by titlebar icon code.
+ *
+ * Results:
+ *	WORD - Number of entries in the color table.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static WORD
+DIBNumColors(
+    LPSTR lpbi)
+{
+    WORD wBitCount;
+    DWORD dwClrUsed;
+
+    dwClrUsed = ((LPBITMAPINFOHEADER) lpbi)->biClrUsed;
+
+    if (dwClrUsed) {
+	return (WORD) dwClrUsed;
+    }
+
+    wBitCount = ((LPBITMAPINFOHEADER) lpbi)->biBitCount;
+
+    switch (wBitCount) {
+    case 1:
+	return 2;
+    case 4:
+	return 16;
+    case 8:
+	return 256;
+    default:
+	return 0;
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * PaletteSize --
+ *
+ *	Calculates the number of bytes in the color table, as given by LPSTR
+ *	lpbi - pointer to the CF_DIB memory block. Used by titlebar icon code.
+ *
+ * Results:
+ *	Number of bytes in the color table
+ *
+ *----------------------------------------------------------------------
+ */
+static WORD
+PaletteSize(
+    LPSTR lpbi)
+{
+    return (WORD) (DIBNumColors(lpbi) * sizeof(RGBQUAD));
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FindDIBits --
+ *
+ *	Locate the image bits in a CF_DIB format DIB, as given by LPSTR lpbi -
+ *	pointer to the CF_DIB memory block. Used by titlebar icon code.
+ *
+ * Results:
+ *	pointer to the image bits
+ *
+ * Side effects: None
+ *
+ *
+ *----------------------------------------------------------------------
+ */
+
+LPSTR
+FindDIBBits(
+    LPSTR lpbi)
+{
+    return lpbi + *((LPDWORD) lpbi) + PaletteSize(lpbi);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * BytesPerLine --
+ *
+ *	Calculates the number of bytes in one scan line, as given by
+ *	LPBITMAPINFOHEADER lpBMIH - pointer to the BITMAPINFOHEADER that
+ *	begins the CF_DIB block. Used by titlebar icon code.
+ *
+ * Results:
+ *	number of bytes in one scan line (DWORD aligned)
+ *
+ *----------------------------------------------------------------------
+ */
+
+DWORD
+BytesPerLine(
+    LPBITMAPINFOHEADER lpBMIH)
+{
+    return WIDTHBYTES(lpBMIH->biWidth * lpBMIH->biPlanes * lpBMIH->biBitCount);
+}
+/*
+ *----------------------------------------------------------------------
+ *
+ * CreateIcoFromPhoto --
+ *
+ *	Create ico pointer from Tk photo block.
+ *
+ * Results:
+ *	Icon image is created from a valid Tk photo image.
+ *
+ * Side effects:
+ *	Icon is created.
+ *
+ *----------------------------------------------------------------------
+ */
+
+HICON
+CreateIcoFromPhoto(
+    int width,                  /* Width of image. */
+    int height,                 /* Height of image. */
+    Tk_PhotoImageBlock block)   /* Image block to convert. */
+{
+    int idx, bufferSize;
+    union {unsigned char *ptr; void *voidPtr;} bgraPixel;
+    union {unsigned char *ptr; void *voidPtr;} bgraMask;
+    HICON hIcon;
+    BITMAPINFO bmInfo;
+    ICONINFO iconInfo;
+
+    /*
+     * Don't use CreateIcon to create the icon, as it requires color
+     * bitmap data in device-dependent format. Instead we use
+     * CreateIconIndirect which takes device-independent bitmaps and
+     * converts them as required. Initialise icon info structure.
+     */
+
+    ZeroMemory(&iconInfo, sizeof(iconInfo));
+    iconInfo.fIcon = TRUE;
+
+    /*
+     * Create device-independent color bitmap.
+     */
+
+    ZeroMemory(&bmInfo, sizeof bmInfo);
+    bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+    bmInfo.bmiHeader.biWidth = width;
+    bmInfo.bmiHeader.biHeight = -height;
+    bmInfo.bmiHeader.biPlanes = 1;
+    bmInfo.bmiHeader.biBitCount = 32;
+    bmInfo.bmiHeader.biCompression = BI_RGB;
+
+    iconInfo.hbmColor = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS,
+            &bgraPixel.voidPtr, NULL, 0);
+    if (!iconInfo.hbmColor) {
+        return NULL;
+    }
+
+    /*
+     * Convert the photo image data into BGRA format (RGBQUAD).
+     */
+
+    bufferSize = height * width * 4;
+    for (idx = 0 ; idx < bufferSize ; idx += 4) {
+        bgraPixel.ptr[idx] = block.pixelPtr[idx+2];
+        bgraPixel.ptr[idx+1] = block.pixelPtr[idx+1];
+        bgraPixel.ptr[idx+2] = block.pixelPtr[idx+0];
+        bgraPixel.ptr[idx+3] = block.pixelPtr[idx+3];
+    }
+
+    /*
+     * Create a dummy mask bitmap. The contents of this don't appear to
+     * matter, as CreateIconIndirect will setup the icon mask based on the
+     * alpha channel in our color bitmap.
+     */
+
+    bmInfo.bmiHeader.biBitCount = 1;
+
+    iconInfo.hbmMask = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS,
+            &bgraMask.voidPtr, NULL, 0);
+    if (!iconInfo.hbmMask) {
+        DeleteObject(iconInfo.hbmColor);
+        return NULL;
+    }
+
+    ZeroMemory(bgraMask.ptr, width*height/8);
+
+    /*
+     * Create an icon from the bitmaps.
+     */
+
+    hIcon = CreateIconIndirect(&iconInfo);
+    DeleteObject(iconInfo.hbmColor);
+    DeleteObject(iconInfo.hbmMask);
+    if (hIcon == NULL) {
+        return NULL;
+    }
+
+    return hIcon;
+}
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */

ADDED   win/tkWinIco.h
Index: win/tkWinIco.h
==================================================================
--- /dev/null
+++ win/tkWinIco.h
@@ -0,0 +1,102 @@
+/*
+ * tkWinIco.h --
+ *
+ *	This file contains declarations for icon-manipulation routines
+ *      in Windows.
+ *
+ * Copyright © 1995-1996 Microsoft Corp.
+ * Copyright © 1998 Brueckner & Jarosch Ing.GmbH, Erfurt, Germany
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+#include "tkWin.h"
+#include <windows.h>
+#include <shellapi.h>
+
+/*
+ * These structures represent the contents of a icon, in terms of its image
+ * or resource.
+ */
+
+typedef struct {
+    UINT Width, Height, Colors;	/* Width, Height and bpp */
+    LPBYTE lpBits;		/* Ptr to DIB bits */
+    DWORD dwNumBytes;		/* How many bytes? */
+    LPBITMAPINFO lpbi;		/* Ptr to header */
+    LPBYTE lpXOR;		/* Ptr to XOR image bits */
+    LPBYTE lpAND;		/* Ptr to AND image bits */
+    HICON hIcon;		/* DAS ICON */
+} ICONIMAGE, *LPICONIMAGE;
+
+typedef struct {
+    BOOL         bHasChanged;                     // Has image changed?
+    TCHAR        szOriginalICOFileName[MAX_PATH]; // Original name
+    TCHAR        szOriginalDLLFileName[MAX_PATH]; // Original name
+    int          nNumImages;                      // How many images?
+    ICONIMAGE    IconImages[1];                   // Image entries
+} ICONRESOURCE, *LPICONRESOURCE;
+
+/*
+ * This structure is how we represent a block of the above items. We will
+ * reallocate these structures according to how many images they need to
+ * contain.
+ */
+
+typedef struct {
+    int nNumImages;		/* How many images? */
+    ICONIMAGE IconImages[1];	/* Image entries */
+} BlockOfIconImages, *BlockOfIconImagesPtr;
+
+/*
+ * These two structures are used to read in icons from an 'icon directory'
+ * (i.e. the contents of a .icr file, say). We only use these structures
+ * temporarily, since we copy the information we want into a
+ * BlockOfIconImages.
+ */
+
+typedef struct {
+    BYTE bWidth;		/* Width of the image */
+    BYTE bHeight;		/* Height of the image (times 2) */
+    BYTE bColorCount;		/* Number of colors in image (0 if >=8bpp) */
+    BYTE bReserved;		/* Reserved */
+    WORD wPlanes;		/* Color Planes */
+    WORD wBitCount;		/* Bits per pixel */
+    DWORD dwBytesInRes;		/* How many bytes in this resource? */
+    DWORD dwImageOffset;	/* Where in the file is this image */
+} ICONDIRENTRY, *LPICONDIRENTRY;
+
+typedef struct {
+    WORD idReserved;		/* Reserved */
+    WORD idType;		/* Resource type (1 for icons) */
+    WORD idCount;		/* How many images? */
+    ICONDIRENTRY idEntries[1];	/* The entries for each image */
+} ICONDIR, *LPICONDIR;
+
+/*
+ * Used in BytesPerLine
+ */
+
+#define WIDTHBYTES(bits)	((((bits) + 31)>>5)<<2)
+
+/*
+ * The following are implemented in tkWinIco.c and also used in tkWinWm.c and tkWinSysTray.c.
+ */
+
+DWORD BytesPerLine(LPBITMAPINFOHEADER lpBMIH);
+LPSTR FindDIBBits(LPSTR lpbi);
+HICON CreateIcoFromPhoto(int width, int height,
+                        Tk_PhotoImageBlock block);
+
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
+
+
+

Index: win/tkWinImage.c
==================================================================
--- win/tkWinImage.c
+++ win/tkWinImage.c
@@ -1,11 +1,11 @@
 /*
  * tkWinImage.c --
  *
  *	This file contains routines for manipulation full-color images.
  *
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright © 1995 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -275,11 +275,11 @@
  *
  * Side effects:
  *	None.
  *
  * This procedure is adapted from the XGetImage implementation in TkNT. That
- * code is Copyright (c) 1994 Software Research Associates, Inc.
+ * code is Copyright © 1994 Software Research Associates, Inc.
  *
  *----------------------------------------------------------------------
  */
 
 static XImage *

Index: win/tkWinInit.c
==================================================================
--- win/tkWinInit.c
+++ win/tkWinInit.c
@@ -2,11 +2,11 @@
  * tkWinInit.c --
  *
  *	This file contains Windows-specific interpreter initialization
  *	functions.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -33,17 +33,20 @@
 
 int
 TkpInit(
     Tcl_Interp *interp)
 {
-    (void)interp;
     /*
      * This is necessary for static initialization, and is ok otherwise
-     * because TkWinXInit flips a static bit to do its work just once.
+     * because TkWinXInit flips a static bit to do its work just once. Also,
+     * initialize printing and systray API's here.
      */
 
+    WinIcoInit(interp);
+    Winprint_Init(interp);
     TkWinXInit(Tk_GetHINSTANCE());
+    Icu_Init(interp);
     return TCL_OK;
 }
 
 /*
  *----------------------------------------------------------------------
@@ -66,11 +69,11 @@
 void
 TkpGetAppName(
     Tcl_Interp *interp,
     Tcl_DString *namePtr)	/* A previously initialized Tcl_DString. */
 {
-    int argc, namelength;
+    TkSizeT argc, namelength;
     const char **argv = NULL, *name, *p;
 
     name = Tcl_GetVar2(interp, "argv0", NULL, TCL_GLOBAL_ONLY);
     namelength = -1;
     if (name != NULL) {
@@ -122,11 +125,11 @@
     WCHAR *msgString; /* points to titleString, just after title, leaving space for ": " */
     int len; /* size of title, including terminating NULL */
 
     /* If running on Cygwin and we have a stderr channel, use it. */
 #if !defined(STATIC_BUILD)
-	if (tclStubsPtr->reserved9) {
+	if (tclStubsPtr->tcl_CreateFileHandler) {
 	Tcl_Channel errChannel = Tcl_GetStdChannel(TCL_STDERR);
 	if (errChannel) {
 	    Tcl_WriteChars(errChannel, title, -1);
 	    Tcl_WriteChars(errChannel, ": ", 2);
 	    Tcl_WriteChars(errChannel, msg, -1);

Index: win/tkWinInt.h
==================================================================
--- win/tkWinInt.h
+++ win/tkWinInt.h
@@ -3,11 +3,11 @@
  *
  *	This file contains declarations that are shared among the
  *	Windows-specific parts of Tk, but aren't used by the rest of Tk.
  *
  * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-2000 by Scriptics Corporation.
+ * Copyright (c) 1998-2000 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -212,10 +212,28 @@
  * The following is implemented in tkWinPointer.c and also used in tkWinWindow.c
  */
 
 MODULE_SCOPE void		TkSetCursorPos(int x, int y);
 
+/*
+ * The following is implemented in tkWinSysTray.c
+ */
+
+MODULE_SCOPE  int       WinIcoInit (Tcl_Interp* interp);
+
+/*
+ * The following is implemented in tkWinGDI.c
+ */
+
+MODULE_SCOPE  int       Winprint_Init(Tcl_Interp* interp);
+
+/*
+ * The following is implemented in tkWinSysTray.c
+ */
+
+MODULE_SCOPE  int       WinIcoInit (Tcl_Interp* interp);
+
 /*
  * Common routines used in Windows implementation
  */
 MODULE_SCOPE Tcl_Obj *	        TkWin32ErrorObj(HRESULT hrError);
 

Index: win/tkWinKey.c
==================================================================
--- win/tkWinKey.c
+++ win/tkWinKey.c
@@ -2,11 +2,11 @@
  * tkWinKey.c --
  *
  *	This file contains X emulation routines for keyboard related
  *	functions.
  *
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright © 1995 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -42,11 +42,11 @@
     NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*65 0x41*/
     NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*70 0x46*/
     NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*75 0x4B*/
     NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*80 0x50*/
     NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*85 0x55*/
-    NoSymbol, XK_Win_L, XK_Win_R, XK_App, NoSymbol, /*90 0x5A*/
+    NoSymbol, XK_Super_L, XK_Super_R, XK_Menu, NoSymbol, /*90 0x5A*/
     NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*95 0x5F*/
     NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*100 0x64*/
     NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*105 0x69*/
     NoSymbol, NoSymbol, XK_F1, XK_F2, XK_F3, /*110 0x6E*/
     XK_F4, XK_F5, XK_F6, XK_F7, XK_F8, /*115 0x73*/
@@ -88,27 +88,26 @@
  *----------------------------------------------------------------------
  */
 
 const char *
 TkpGetString(
-    TkWindow *winPtr,		/* Window where event occurred: needed to get
+    TCL_UNUSED(TkWindow *),		/* Window where event occurred: needed to get
 				 * input context. */
     XEvent *eventPtr,		/* X keyboard event. */
     Tcl_DString *dsPtr)		/* Uninitialized or empty string to hold
 				 * result. */
 {
     XKeyEvent *keyEv = &eventPtr->xkey;
     int len;
     char buf[6];
-    (void)winPtr;
 
     Tcl_DStringInit(dsPtr);
     if (keyEv->send_event == -1) {
 	TkKeyEvent *ev = (TkKeyEvent *)keyEv;
 	if (ev->nbytes > 0) {
-	    Tcl_ExternalToUtfDString(TkWinGetKeyInputEncoding(),
-		    ev->trans_chars, ev->nbytes, dsPtr);
+	    (void)Tcl_ExternalToUtfDStringEx(TkWinGetKeyInputEncoding(),
+		    ev->trans_chars, ev->nbytes, TCL_ENCODING_NOCOMPLAIN, dsPtr);
 	}
     } else if (keyEv->send_event == -3) {
 
 	/*
 	 * Special case for WM_UNICHAR and win2000 multilingual IME input
@@ -150,16 +149,15 @@
  *----------------------------------------------------------------------
  */
 
 KeySym
 XKeycodeToKeysym(
-    Display *display,
+    TCL_UNUSED(Display *),
     unsigned int keycode,
     int index)
 {
     int state = 0;
-    (void)display;
 
     if (index & 0x01) {
 	state |= ShiftMask;
     }
     return KeycodeToKeysym(keycode, state, 0);
@@ -566,18 +564,17 @@
  * taking into account the xkey.state, they will get back the original keysym.
  */
 
 void
 TkpSetKeycodeAndState(
-    Tk_Window tkwin,
+    TCL_UNUSED(Tk_Window),
     KeySym keySym,
     XEvent *eventPtr)
 {
     int i;
     SHORT result;
     int shift;
-    (void)tkwin;
 
     eventPtr->xkey.keycode = 0;
     if (keySym == NoSymbol) {
 	return;
     }
@@ -625,16 +622,15 @@
  *----------------------------------------------------------------------
  */
 
 KeyCode
 XKeysymToKeycode(
-    Display *display,
+    TCL_UNUSED(Display *),
     KeySym keysym)
 {
     int i;
     SHORT result;
-    (void)display;
 
     /*
      * We check our private map first for a virtual keycode, as VkKeyScan will
      * return values that don't map to X for the "extended" Syms. This may be
      * due to just casting problems below, but this works.
@@ -674,14 +670,13 @@
  *----------------------------------------------------------------------
  */
 
 XModifierKeymap	*
 XGetModifierMapping(
-    Display *display)
+    TCL_UNUSED(Display *))
 {
     XModifierKeymap *map = (XModifierKeymap *)ckalloc(sizeof(XModifierKeymap));
-    (void)display;
 
     map->max_keypermod = 1;
     map->modifiermap = (KeyCode *)ckalloc(sizeof(KeyCode) * 8);
     map->modifiermap[ShiftMapIndex] = VK_SHIFT;
     map->modifiermap[LockMapIndex] = VK_CAPITAL;
@@ -736,14 +731,12 @@
  *----------------------------------------------------------------------
  */
 
 KeySym
 XStringToKeysym(
-    _Xconst char *string)
+    TCL_UNUSED(_Xconst char *))
 {
-    (void)string;
-
     return NoSymbol;
 }
 
 /*
  *----------------------------------------------------------------------
@@ -761,14 +754,12 @@
  *----------------------------------------------------------------------
  */
 
 char *
 XKeysymToString(
-    KeySym keysym)
+    TCL_UNUSED(KeySym))
 {
-    (void)keysym;
-
     return NULL;
 }
 
 /*
  * Local Variables:

Index: win/tkWinMenu.c
==================================================================
--- win/tkWinMenu.c
+++ win/tkWinMenu.c
@@ -2,12 +2,12 @@
  * tkWinMenu.c --
  *
  *	This module implements the Windows platform-specific features of
  *	menus.
  *
- * Copyright (c) 1996-1998 by Sun Microsystems, Inc.
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright © 1996-1998 Sun Microsystems, Inc.
+ * Copyright © 1998-1999 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -509,11 +509,11 @@
 		: Tcl_GetString(mePtr->labelPtr);
 	const char *accel = ((menuPtr->menuType == MENUBAR) || (mePtr->accelPtr == NULL)) ? ""
 		: Tcl_GetString(mePtr->accelPtr);
 	const char *p, *next;
 	Tcl_DString itemString;
-	int ch;
+	Tcl_UniChar ch = 0;
 
 	/*
 	 * We have to construct the string with an ampersand preceeding the
 	 * underline character, and a tab seperating the text and the accel
 	 * text. We have to be careful with ampersands in the string.
@@ -526,20 +526,21 @@
 		Tcl_DStringAppend(&itemString, "&", 1);
 	    }
 	    if (*p == '&') {
 		Tcl_DStringAppend(&itemString, "&", 1);
 	    }
-	    next = p + TkUtfToUniChar(p, &ch);
+	    next = p + Tcl_UtfToUniChar(p, &ch);
 	    Tcl_DStringAppend(&itemString, p, (int) (next - p));
 	}
+	ch = 0;
 	if (mePtr->accelLength > 0) {
 	    Tcl_DStringAppend(&itemString, "\t", 1);
 	    for (p = accel, i = 0; *p != '\0'; i++, p = next) {
 		if (*p == '&') {
 		    Tcl_DStringAppend(&itemString, "&", 1);
 		}
-		next = p + TkUtfToUniChar(p, &ch);
+		next = p + Tcl_UtfToUniChar(p, &ch);
 		Tcl_DStringAppend(&itemString, p, (int) (next - p));
 	    }
 	}
 
 	itemText = (char *)ckalloc(Tcl_DStringLength(&itemString) + 1);
@@ -879,17 +880,10 @@
 {
     int vRootX, vRootY, vRootWidth, vRootHeight;
     int result;
     (void)dummy;
 
-    if (index >= (int)menuPtr->numEntries) {
-	index = menuPtr->numEntries - 1;
-    }
-    if (index >= 0) {
-	y -= menuPtr->entries[index]->y;
-    }
-
     TkActivateMenuEntry(menuPtr, -1);
     TkRecomputeMenu(menuPtr);
     result = TkPostCommand(menuPtr);
     if (result != TCL_OK) {
     	return result;
@@ -902,11 +896,23 @@
 
     if (menuPtr->tkwin == NULL) {
     	return TCL_OK;
     }
 
-    /*
+     /*
+     * Adjust the menu y position so that the specified entry will be located
+     * at the given coordinates.
+     */
+
+    if (index >= (int)menuPtr->numEntries) {
+	index = menuPtr->numEntries - 1;
+    }
+    if (index >= 0) {
+	y -= menuPtr->entries[index]->y;
+    }
+
+   /*
      * Adjust the position of the menu if necessary to keep it visible on the
      * screen. There are two special tricks to make this work right:
      *
      * 1. If a virtual root window manager is being used then the coordinates
      *    are in the virtual root window of menuPtr's parent; since the menu
@@ -1273,11 +1279,11 @@
 		labelPtr = menuPtr->entries[i]->labelPtr;
 		if ((underline >= 0) && (labelPtr != NULL)) {
 		    /*
 		     * Ensure we don't exceed the label length, then check
 		     */
-		    const char *src = TkGetStringFromObj(labelPtr, &len);
+		    const char *src = Tcl_GetStringFromObj(labelPtr, &len);
 
 		    Tcl_DStringFree(&ds);
 		    Tcl_DStringInit(&ds);
 		    wlabel = Tcl_UtfToWCharDString(src, len, &ds);
 		    if (((TkSizeT)underline + 1 < len + 1) && (menuChar ==
@@ -1537,11 +1543,11 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
- * TkpSetMainMenubar --
+ * Tk_SetMainMenubar --
  *
  *	Puts the menu associated with a window into the menubar. Should only
  *	be called when the window is in front.
  *
  * Results:
@@ -1552,11 +1558,11 @@
  *
  *----------------------------------------------------------------------
  */
 
 void
-TkpSetMainMenubar(
+Tk_SetMainMenubar(
     Tcl_Interp *interp,		/* The interpreter of the application */
     Tk_Window tkwin,		/* The frame we are setting up */
     const char *menuName)	/* The name of the menu to put in front. If
     				 * NULL, use the default menu bar. */
 {

Index: win/tkWinPixmap.c
==================================================================
--- win/tkWinPixmap.c
+++ win/tkWinPixmap.c
@@ -2,11 +2,11 @@
  * tkWinPixmap.c --
  *
  *	This file contains the Xlib emulation functions pertaining to creating
  *	and destroying pixmaps.
  *
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright © 1995 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: win/tkWinPointer.c
==================================================================
--- win/tkWinPointer.c
+++ win/tkWinPointer.c
@@ -1,12 +1,12 @@
 /*
  * tkWinPointer.c --
  *
  *	Windows specific mouse tracking code.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-1999 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -240,15 +240,10 @@
     POINT pos;
     (void)dummy;
 
     mouseTimerSet = 0;
 
-    /*
-     * Get the current mouse position and window. Don't do anything if the
-     * mouse hasn't moved since the last time we looked.
-     */
-
     GetCursorPos(&pos);
     TkWinPointerEvent(NULL, pos.x, pos.y);
 }
 
 /*
@@ -379,10 +374,21 @@
     int y)
 {
     INPUT input;
     int xscreen = (int)(GetSystemMetrics(SM_CXSCREEN) - 1);
     int yscreen = (int)(GetSystemMetrics(SM_CYSCREEN) - 1);
+
+    /*
+     * A multi-screen system may have different logical pixels/inch, with
+     * Windows applying behind-the-scenes scaling on secondary screens.
+     * Don't try and emulate that, instead fall back to SetCursor if the
+     * requested position is off the primary screen.
+     */
+    if ( x < 0 || x > xscreen || y < 0 || y > yscreen ) {
+        SetCursorPos(x, y);
+        return;
+    }
 
     input.type = INPUT_MOUSE;
     input.mi.dx = (x * 65535 + xscreen/2) / xscreen;
     input.mi.dy = (y * 65535 + yscreen/2) / yscreen;
 

Index: win/tkWinPort.h
==================================================================
--- win/tkWinPort.h
+++ win/tkWinPort.h
@@ -93,10 +93,11 @@
 
 /*
  * See ticket [916c1095438eae56]: GetVersionExW triggers warnings
  */
 #if defined(_MSC_VER)
+#   pragma warning(disable:4090) /* see: https://developercommunity.visualstudio.com/t/c-compiler-incorrect-propagation-of-const-qualifie/390711 */
 #   pragma warning(disable:4146)
 #   pragma warning(disable:4267)
 #   pragma warning(disable:4244)
 #   pragma warning(disable:4311)
 #   pragma warning(disable:4312)
@@ -122,16 +123,10 @@
  */
 
 #define TkpGetPixel(p) (((((p)->red >> 8) & 0xff) \
 	| ((p)->green & 0xff00) | (((p)->blue << 8) & 0xff0000)) | 0x20000000)
 
-/*
- * Used by tkWindow.c
- */
-
-#define TkpHandleMapOrUnmap(tkwin, event)  Tk_HandleEvent(event)
-
 /*
  * These calls implement native bitmaps which are not currently
  * supported under Windows.  The macros eliminate the calls.
  */
 

Index: win/tkWinRegion.c
==================================================================
--- win/tkWinRegion.c
+++ win/tkWinRegion.c
@@ -1,11 +1,11 @@
 /*
  * tkWinRegion.c --
  *
  *	Tk Region emulation code.
  *
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright © 1995 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: win/tkWinScrlbr.c
==================================================================
--- win/tkWinScrlbr.c
+++ win/tkWinScrlbr.c
@@ -2,11 +2,11 @@
  * tkWinScrollbar.c --
  *
  *	This file implements the Windows specific portion of the scrollbar
  *	widget.
  *
- * Copyright (c) 1996 by Sun Microsystems, Inc.
+ * Copyright © 1996 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: win/tkWinSend.c
==================================================================
--- win/tkWinSend.c
+++ win/tkWinSend.c
@@ -2,12 +2,12 @@
  * tkWinSend.c --
  *
  *	This file provides functions that implement the "send" command,
  *	allowing commands to be passed from interpreter to interpreter.
  *
- * Copyright (c) 1997 by Sun Microsystems, Inc.
- * Copyright (c) 2003 Pat Thoyts <patthoyts@users.sourceforge.net>
+ * Copyright © 1997 Sun Microsystems, Inc.
+ * Copyright © 2003 Pat Thoyts <patthoyts@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: win/tkWinSendCom.c
==================================================================
--- win/tkWinSendCom.c
+++ win/tkWinSendCom.c
@@ -11,11 +11,11 @@
  * with the following method:
  *	Send(String cmd) As String
  * In other words the Send methods takes a string and evaluates this in the
  * Tcl interpreter. The result is returned as another string.
  *
- * Copyright (C) 2002 Pat Thoyts <patthoyts@users.sourceforge.net>
+ * Copyright © 2002 Pat Thoyts <patthoyts@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: win/tkWinSendCom.h
==================================================================
--- win/tkWinSendCom.h
+++ win/tkWinSendCom.h
@@ -3,11 +3,11 @@
  *
  *	This file provides procedures that implement the Windows "send"
  *	command, allowing commands to be passed from interpreter to
  *	interpreter.
  *
- * Copyright (C) 2002 Pat Thoyts <patthoyts@users.sourceforge.net>
+ * Copyright © 2002 Pat Thoyts <patthoyts@users.sourceforge.net>
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

ADDED   win/tkWinSysTray.c
Index: win/tkWinSysTray.c
==================================================================
--- /dev/null
+++ win/tkWinSysTray.c
@@ -0,0 +1,1193 @@
+/*
+ * tkWinSysTray.c --
+ *
+ * 	tkWinSysTray.c implements a "systray" Tcl command which permits to
+ * 	change the system tray/taskbar icon of a Tk toplevel window and
+ * 	a "sysnotify" command to post system notifications.
+ *
+ * Copyright © 1995-1996 Microsoft Corp.
+ * Copyright © 1998 Brueckner & Jarosch Ing.GmbH, Erfurt, Germany
+ * Copyright © 2020 Kevin Walzer/WordTech Communications LLC.
+ * Copyright © 2020 Eric Boudaillier.
+ * Copyright © 2020 Francois Vogel.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+#include "tkInt.h"
+#include <windows.h>
+#include <shellapi.h>
+#include "tkWin.h"
+#include "tkWinInt.h"
+#include "tkWinIco.h"
+
+/*
+ * Based extensively on the winico extension and sample code from Microsoft.
+ * Some of the code was adapted into tkWinWM.c to implement the "wm iconphoto"
+ * command (TIP 159), and here we are borrowing that code to use Tk images
+ * to create system tray icons instead of ico files. Additionally, we are
+ * removing obsolete parts of the winico extension, and implementing
+ * more of the Shell_Notification API to add balloon/system notifications.
+ */
+
+#define GETHINSTANCE Tk_GetHINSTANCE()
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+#ifdef _MSC_VER
+/*
+ * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible.
+ * Note that sprintf is deprecated.
+ */
+# define snprintf _snprintf
+#endif
+
+typedef struct IcoInfo {
+    HICON hIcon;                /* icon handle returned by LoadIcon. */
+    unsigned id;                /* Identifier for command;  used to
+                                 * cancel it. */
+    Tcl_Obj *taskbar_txt;       /* text to display in the taskbar */
+    Tcl_Interp *interp;         /* interp which created the icon */
+    Tcl_Obj *taskbar_command;   /* command to eval if events in the taskbar
+                                 * arrive */
+    int taskbar_flags;          /* taskbar related flags*/
+    HWND hwndFocus;
+    struct IcoInfo *nextPtr;
+} IcoInfo;
+
+/* Per-interp struture */
+typedef struct IcoInterpInfo {
+    HWND hwnd;                  /* Handler window */
+    int counter;                /* Counter for IcoInfo id generation */
+    IcoInfo *firstIcoPtr;       /* List of created IcoInfo */
+    struct IcoInterpInfo *nextPtr;
+} IcoInterpInfo;
+
+#define TASKBAR_ICON 1
+#define ICON_MESSAGE WM_USER + 1234
+
+#define HANDLER_CLASS "Wtk_TaskbarHandler"
+static HWND CreateTaskbarHandlerWindow(void);
+
+static IcoInterpInfo *firstIcoInterpPtr = NULL;
+static Tk_EventProc WinIcoDestroy;
+
+/*
+ * If someone wants to see the several masks somewhere on the screen...
+ * set the ICO_DRAW define and feel free to make some Tcl commands
+ * for accessing it.  The normal drawing of an Icon to a DC is really easy:
+ * DrawIcon(hdc,x,y,hIcon) or , more complicated
+ * DrawIconEx32PlusMoreParameters ...
+ */
+
+/* #define ICO_DRAW */
+#ifdef ICO_DRAW
+#define RectWidth(r)((r).right - (r).left + 1)
+#define RectHeight(r)((r).bottom - (r).top + 1)
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * DrawXORMask --
+ *
+ * 	Using DIB functions, draw XOR mask on hDC in Rect.
+ *
+ * Results:
+ *	Icon is rendered.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static BOOL
+DrawXORMask(
+    HDC hDC,
+    RECT Rect,
+    LPLPICONIMAGE lpIcon)
+{
+    int x, y;
+
+    /* Sanity checks */
+    if (lpIcon == NULL)
+        return FALSE;
+    if (lpIcon->lpBits == NULL)
+        return FALSE;
+
+    /* Account for height*2 thing */
+    lpIcon->lpbi->bmiHeader.biHeight /= 2;
+
+    /* Locate it */
+    x = Rect.left + ((RectWidth(Rect) - lpIcon->lpbi->bmiHeader.biWidth) / 2);
+    y = Rect.top + ((RectHeight(Rect) - lpIcon->lpbi->bmiHeader.biHeight) / 2);
+
+    /* Blast it to the screen */
+    SetDIBitsToDevice(hDC, x, y,
+            lpIcon->lpbi->bmiHeader.biWidth,
+            lpIcon->lpbi->bmiHeader.biHeight,
+            0, 0, 0, lpIcon->lpbi->bmiHeader.biHeight,
+            lpIcon->lpXOR, lpIcon->lpbi, DIB_RGB_COLORS);
+
+    /* UnAccount for height*2 thing */
+    lpIcon->lpbi->bmiHeader.biHeight *= 2;
+
+    return TRUE;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * DrawANDMask --
+ *
+ * 	Using DIB functions, draw AND mask on hDC in Rect.
+ *
+ * Results:
+ *	Icon is rendered.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+BOOL
+DrawANDMask(
+    HDC hDC,
+    RECT Rect,
+    LPLPICONIMAGE lpIcon)
+{
+    LPBITMAPINFO lpbi;
+    int x, y;
+
+    /* Sanity checks */
+    if (lpIcon == NULL)
+        return FALSE;
+    if (lpIcon->lpBits == NULL)
+        return FALSE;
+
+    /* Need a bitmap header for the mono mask */
+    lpbi = ckalloc(sizeof(BITMAPINFO) + (2 * sizeof(RGBQUAD)));
+    lpbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+    lpbi->bmiHeader.biWidth = lpIcon->lpbi->bmiHeader.biWidth;
+    lpbi->bmiHeader.biHeight = lpIcon->lpbi->bmiHeader.biHeight / 2;
+    lpbi->bmiHeader.biPlanes = 1;
+    lpbi->bmiHeader.biBitCount = 1;
+    lpbi->bmiHeader.biCompression = BI_RGB;
+    lpbi->miHeader.biSizeImage = 0;
+    lpbi->bmiHeader.biXPelsPerMeter = 0;
+    lpbi->bmiHeader.biYPelsPerMeter = 0;
+    lpbi->bmiHeader.biClrUsed = 0;
+    lpbi->bmiHeader.biClrImportant = 0;
+    lpbi->bmiColors[0].rgbRed = 0;
+    lpbi->bmiColors[0].rgbGreen = 0;
+    lpbi->bmiColors[0].rgbBlue = 0;
+    lpbi->bmiColors[0].rgbReserved = 0;
+    lpbi->bmiColors[1].rgbRed = 255;
+    lpbi->bmiColors[1].rgbGreen = 255;
+    lpbi->bmiColors[1].rgbBlue = 255;
+    lpbi->bmiColors[1].rgbReserved = 0;
+
+    /* Locate it */
+    x = Rect.left + ((RectWidth(Rect) - lpbi->bmiHeader.biWidth) / 2);
+    y = Rect.top + ((RectHeight(Rect) - lpbi->bmiHeader.biHeight) / 2);
+
+    /* Blast it to the screen */
+    SetDIBitsToDevice(hDC, x, y,
+            lpbi->bmiHeader.biWidth,
+            lpbi->bmiHeader.biHeight,
+            0, 0, 0, lpbi->bmiHeader.biHeight,
+            lpIcon->lpAND, lpbi, DIB_RGB_COLORS);
+
+    /* clean up */
+    ckfree((char *) lpbi);
+
+    return TRUE;
+}
+#endif /* ICO_DRAW */
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TaskbarOperation --
+ *
+ * 	Management of icon display.
+ *
+ * Results:
+ *	Icon is displayed or deleted.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TaskbarOperation(
+    IcoInterpInfo *icoInterpPtr,
+    IcoInfo *icoPtr,
+    int oper)
+{
+    NOTIFYICONDATAW ni;
+    WCHAR *str;
+
+    ni.cbSize = sizeof(NOTIFYICONDATAW);
+    ni.hWnd = icoInterpPtr->hwnd;
+    ni.uID = icoPtr->id;
+    ni.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
+    ni.uCallbackMessage = ICON_MESSAGE;
+    ni.hIcon = icoPtr->hIcon;
+
+    if (icoPtr->taskbar_txt != NULL) {
+        Tcl_DString dst;
+        Tcl_DStringInit(&dst);
+        str = (WCHAR *)Tcl_UtfToWCharDString(Tcl_GetString(icoPtr->taskbar_txt), -1, &dst);
+        wcsncpy(ni.szTip, str, (Tcl_DStringLength(&dst) + 2) / 2);
+        Tcl_DStringFree(&dst);
+    } else {
+        ni.szTip[0] = 0;
+    }
+
+    if (Shell_NotifyIconW(oper, &ni) == 1) {
+        if (oper == NIM_ADD || oper == NIM_MODIFY) {
+            icoPtr->taskbar_flags |= TASKBAR_ICON;
+        }
+        if (oper == NIM_DELETE) {
+            icoPtr->taskbar_flags &= ~TASKBAR_ICON;
+        }
+    }
+    /* Silently ignore error? */
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * NewIcon --
+ *
+ * 	Create icon for display in system tray.
+ *
+ * Results:
+ *	Icon is created for display.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static IcoInfo *
+NewIcon(
+    Tcl_Interp *interp,
+    IcoInterpInfo *icoInterpPtr,
+    HICON hIcon)
+{
+    IcoInfo *icoPtr;
+
+    icoPtr = (IcoInfo *)ckalloc(sizeof(IcoInfo));
+    memset(icoPtr, 0, sizeof(IcoInfo));
+    icoPtr->id = ++icoInterpPtr->counter;
+    icoPtr->hIcon = hIcon;
+    icoPtr->taskbar_txt = NULL;
+    icoPtr->interp = interp;
+    icoPtr->taskbar_command = NULL;
+    icoPtr->taskbar_flags = 0;
+    icoPtr->hwndFocus = NULL;
+    icoPtr->nextPtr = icoInterpPtr->firstIcoPtr;
+    icoInterpPtr->firstIcoPtr = icoPtr;
+    return icoPtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FreeIcoPtr --
+ *
+ * 	Delete icon and free memory.
+ *
+ * Results:
+ *	Icon is removed from display.
+ *
+ * Side effects:
+ *	Memory/resources freed.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+FreeIcoPtr(
+    IcoInterpInfo *icoInterpPtr,
+    IcoInfo *icoPtr)
+{
+    IcoInfo *prevPtr;
+    if (icoInterpPtr->firstIcoPtr == icoPtr) {
+        icoInterpPtr->firstIcoPtr = icoPtr->nextPtr;
+    } else {
+        for (prevPtr = icoInterpPtr->firstIcoPtr; prevPtr->nextPtr != icoPtr;
+                prevPtr = prevPtr->nextPtr) {
+            /* Empty loop body. */
+        }
+        prevPtr->nextPtr = icoPtr->nextPtr;
+    }
+    if (icoPtr->taskbar_flags & TASKBAR_ICON) {
+        TaskbarOperation(icoInterpPtr, icoPtr, NIM_DELETE);
+    }
+    if (icoPtr->taskbar_txt != NULL) {
+        Tcl_DecrRefCount(icoPtr->taskbar_txt);
+    }
+    if (icoPtr->taskbar_command != NULL) {
+        Tcl_DecrRefCount(icoPtr->taskbar_command);
+    }
+    ckfree(icoPtr);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetIcoPtr --
+ *
+ * 	Get pointer to icon for display.
+ *
+ * Results:
+ *	Icon is obtained for display.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static IcoInfo *
+GetIcoPtr(
+    Tcl_Interp *interp,
+    IcoInterpInfo *icoInterpPtr,
+    const char *string)
+{
+    IcoInfo *icoPtr;
+    unsigned id;
+    const char *start;
+    char *end;
+
+    if (strncmp(string, "ico#", 4) != 0) {
+        goto notfound;
+    }
+    start = string + 4;
+    id = strtoul(start, &end, 10);
+    if ((end == start) || (*end != 0)) {
+        goto notfound;
+    }
+    for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) {
+        if (icoPtr->id == id) {
+            return icoPtr;
+        }
+    }
+
+notfound:
+    Tcl_AppendResult(interp, "icon \"", string,
+        "\" doesn't exist", NULL);
+    return NULL;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetInt --
+ *
+ * Utility function for calculating buffer length.
+ *
+ * Results:
+ *	Length.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+GetInt(
+    long theint,
+    char *buffer,
+    size_t len)
+{
+    snprintf(buffer, len, "0x%lx", theint);
+    buffer[len - 1] = 0;
+    return (int) strlen(buffer);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetIntDec --
+ *
+ * Utility function for calculating buffer length.
+ *
+ * Results:
+ *	Length.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+GetIntDec(
+    long theint,
+    char *buffer,
+    size_t len)
+{
+    snprintf(buffer, len - 1, "%ld", theint);
+    buffer[len - 1] = 0;
+    return (int) strlen(buffer);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TaskbarExpandPercents --
+ *
+ * Parse strings in taskbar display.
+ *
+ * Results:
+ *	Strings.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static char*
+TaskbarExpandPercents(
+    IcoInfo *icoPtr,
+    const char *msgstring,
+    WPARAM wParam,
+    LPARAM lParam,
+    char *before,
+    char *after,
+    int *aftersize)
+{
+#define SPACELEFT (*aftersize-(dst-after)-1)
+#define AFTERLEN ((*aftersize>0)?(*aftersize*2):1024)
+#define ALLOCLEN ((len>AFTERLEN)?(len*2):AFTERLEN)
+    char buffer[TCL_INTEGER_SPACE + 5];
+    char* dst;
+    dst = after;
+    while (*before) {
+        const char *ptr = before;
+        int len = 1;
+        if(*before == '%') {
+            switch(before[1]){
+                case 'M':
+                case 'm': {
+                    before++;
+                    len = strlen(msgstring);
+                    ptr = msgstring;
+                    break;
+                }
+                /* case 'W': {
+                   before++;
+                   len = (int)strlen(winstring);
+                   ptr = winstring;
+                   break;
+                   }
+                */
+                case 'i': {
+                    before++;
+                    snprintf(buffer, sizeof(buffer) - 1, "ico#%d", icoPtr->id);
+                    len = strlen(buffer);
+                    ptr = buffer;
+                    break;
+                }
+                case 'w': {
+                    before++;
+                    len = GetInt((long)wParam,buffer, sizeof(buffer));
+                    ptr = buffer;
+                    break;
+                }
+                case 'l': {
+                    before++;
+                    len = GetInt((long)lParam,buffer, sizeof(buffer));
+                    ptr = buffer;
+                    break;
+                }
+                case 't': {
+                    before++;
+                    len = GetInt((long)GetTickCount(), buffer, sizeof(buffer));
+                    ptr = buffer;
+                    break;
+                }
+                case 'x': {
+                    POINT pt;
+                    GetCursorPos(&pt);
+                    before++;
+                    len = GetIntDec((long)pt.x, buffer, sizeof(buffer));
+                    ptr = buffer;
+                    break;
+                }
+                case 'y': {
+                    POINT pt;
+                    GetCursorPos(&pt);
+                    before++;
+                    len = GetIntDec((long)pt.y,buffer, sizeof(buffer));
+                    ptr = buffer;
+                    break;
+                }
+                case 'X': {
+                    DWORD dw;
+                    dw = GetMessagePos();
+                    before++;
+                    len = GetIntDec((long)LOWORD(dw),buffer, sizeof(buffer));
+                    ptr = buffer;
+                    break;
+                }
+                case 'Y': {
+                    DWORD dw;
+                    dw = GetMessagePos();
+                    before++;
+                    len = GetIntDec((long)HIWORD(dw),buffer, sizeof(buffer));
+                    ptr = buffer;
+                    break;
+                }
+                case 'H': {
+                    before++;
+                    len = GetInt(PTR2INT(icoPtr->hwndFocus), buffer, sizeof(buffer));
+                    ptr = buffer;
+                    break;
+                }
+                case '%': {
+                    before++;
+                    len = 1;
+                    ptr = "%";
+                    break;
+                }
+            }
+        }
+        if (SPACELEFT < len) {
+            char *newspace;
+            ptrdiff_t dist = dst - after;
+            int alloclen = ALLOCLEN;
+            newspace = (char *)ckalloc(alloclen);
+            if (dist>0)
+                memcpy(newspace, after, dist);
+            if (after && *aftersize) {
+                ckfree(after);
+            }
+            *aftersize =alloclen;
+            after = newspace;
+            dst = after + dist;
+        }
+        if (len > 0) {
+            memcpy(dst, ptr, len);
+        }
+        dst += len;
+        if ((dst-after)>(*aftersize-1)) {
+            printf("oops\n");
+        }
+        before++;
+    }
+    *dst = 0;
+    return after;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TaskbarEval --
+ *
+ * Parse mouse and keyboard events over taskbar.
+ *
+ * Results:
+ *	Event processing.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+TaskbarEval(
+    IcoInfo *icoPtr,
+    WPARAM wParam,
+    LPARAM lParam)
+{
+    const char *msgstring = "none";
+    char evalspace[200];
+    int evalsize = 200;
+    char *expanded;
+    int fixup = 0;
+
+    switch (lParam) {
+    case WM_MOUSEMOVE:
+        msgstring = "WM_MOUSEMOVE";
+        icoPtr->hwndFocus = GetFocus();
+        break;
+    case WM_LBUTTONDOWN:
+        msgstring = "WM_LBUTTONDOWN";
+        fixup = 1;
+        break;
+    case WM_LBUTTONUP:
+        msgstring = "WM_LBUTTONUP";
+        fixup = 1;
+        break;
+    case WM_LBUTTONDBLCLK:
+        msgstring = "WM_LBUTTONDBLCLK";
+        fixup = 1;
+        break;
+    case WM_RBUTTONDOWN:
+        msgstring = "WM_RBUTTONDOWN";
+        fixup = 1;
+        break;
+    case WM_RBUTTONUP:
+        msgstring = "WM_RBUTTONUP";
+        fixup = 1;
+        break;
+    case WM_RBUTTONDBLCLK:
+        msgstring = "WM_RBUTTONDBLCLK";
+        fixup = 1;
+        break;
+    case WM_MBUTTONDOWN:
+        msgstring = "WM_MBUTTONDOWN";
+        fixup = 1;
+        break;
+    case WM_MBUTTONUP:
+        msgstring = "WM_MBUTTONUP";
+        fixup = 1;
+        break;
+    case WM_MBUTTONDBLCLK:
+        msgstring = "WM_MBUTTONDBLCLK";
+        fixup = 1;
+        break;
+    default:
+        msgstring = "WM_NULL";
+        fixup = 0;
+    }
+    expanded = TaskbarExpandPercents(icoPtr, msgstring, wParam, lParam,
+            Tcl_GetString(icoPtr->taskbar_command), evalspace, &evalsize);
+    if (icoPtr->interp != NULL) {
+        int result;
+        HWND hwnd = NULL;
+
+        /* See http://support.microsoft.com/kb/q135788/
+         * Seems to have moved to https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/135788 */
+        if (fixup) {
+            if (icoPtr->hwndFocus != NULL && IsWindow(icoPtr->hwndFocus)) {
+                hwnd = icoPtr->hwndFocus;
+            } else {
+                Tk_Window tkwin = Tk_MainWindow(icoPtr->interp);
+                if (tkwin != NULL) {
+                    hwnd = Tk_GetHWND(Tk_WindowId(tkwin));
+                }
+            }
+            if (hwnd != NULL) {
+                SetForegroundWindow(hwnd);
+            }
+        }
+
+        result = Tcl_GlobalEval(icoPtr->interp, expanded);
+
+        if (hwnd != NULL) {
+            /* See http://support.microsoft.com/kb/q135788/
+             * Seems to have moved to https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/135788 */
+            PostMessageW(hwnd, WM_NULL, 0, 0);
+        }
+        if (result != TCL_OK) {
+            char buffer[100];
+            sprintf(buffer, "\n  (command bound to taskbar-icon ico#%d)", icoPtr->id);
+            Tcl_AddErrorInfo(icoPtr->interp, buffer);
+            Tcl_BackgroundError(icoPtr->interp);
+        }
+    }
+    if (expanded != evalspace) {
+        ckfree(expanded);
+    }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TaskbarHandlerProc --
+ *
+ * 	Windows callback procedure, if ICON_MESSAGE arrives, try to execute
+ * 	the taskbar_command.
+ *
+ * Results:
+ *	Command execution.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static LRESULT CALLBACK
+TaskbarHandlerProc(
+    HWND hwnd,
+    UINT message,
+    WPARAM wParam,
+    LPARAM lParam)
+{
+    static UINT msgTaskbarCreated = 0;
+    IcoInterpInfo *icoInterpPtr;
+    IcoInfo *icoPtr;
+
+    switch (message) {
+    case WM_CREATE:
+        msgTaskbarCreated = RegisterWindowMessage(TEXT("TaskbarCreated"));
+        break;
+
+    case ICON_MESSAGE:
+        for (icoInterpPtr = firstIcoInterpPtr; icoInterpPtr != NULL; icoInterpPtr = icoInterpPtr->nextPtr) {
+            if (icoInterpPtr->hwnd == hwnd) {
+                for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) {
+                    if (icoPtr->id == wParam) {
+                        if (icoPtr->taskbar_command != NULL) {
+                            TaskbarEval(icoPtr, wParam, lParam);
+                        }
+                        break;
+                    }
+                }
+                break;
+            }
+        }
+        break;
+
+    default:
+        /*
+         * Check to see if explorer has been restarted and we need to
+         * re-add our icons.
+         */
+        if (message == msgTaskbarCreated) {
+            for (icoInterpPtr = firstIcoInterpPtr; icoInterpPtr != NULL; icoInterpPtr = icoInterpPtr->nextPtr) {
+                if (icoInterpPtr->hwnd == hwnd) {
+                    for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = icoPtr->nextPtr) {
+                        if (icoPtr->taskbar_flags & TASKBAR_ICON) {
+                            TaskbarOperation(icoInterpPtr, icoPtr, NIM_ADD);
+                        }
+                    }
+                    break;
+                }
+            }
+        }
+        return DefWindowProc(hwnd, message, wParam, lParam);
+    }
+    return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * RegisterHandlerClass --
+ *
+ * 	Registers the handler window class.
+ *
+ * Results:
+ *	Handler class registered.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+RegisterHandlerClass(
+    HINSTANCE hInstance)
+{
+    WNDCLASS wndclass;
+    memset(&wndclass, 0, sizeof(WNDCLASS));
+    wndclass.style = 0;
+    wndclass.lpfnWndProc = TaskbarHandlerProc;
+    wndclass.cbClsExtra = 0;
+    wndclass.cbWndExtra = 0;
+    wndclass.hInstance = hInstance;
+    wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+    wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
+    wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+    wndclass.lpszMenuName = NULL;
+    wndclass.lpszClassName = HANDLER_CLASS;
+    return RegisterClass(&wndclass);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CreateTaskbarHandlerWindow --
+ *
+ * 	Creates a hidden window to handle taskbar messages.
+ *
+ * Results:
+ *	Hidden window created.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static HWND
+CreateTaskbarHandlerWindow(void) {
+    static int registered = 0;
+    HINSTANCE hInstance = GETHINSTANCE;
+    if (!registered) {
+        if (!RegisterHandlerClass(hInstance))
+            return 0;
+        registered = 1;
+    }
+    return CreateWindow(HANDLER_CLASS, "", WS_OVERLAPPED, 0, 0,
+            CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * WinIcoDestroy --
+ *
+ *	Event handler to delete systray icons when interp main window
+ *	is deleted, either by destroy, interp deletion or application
+ *	exit.
+ *
+ * Results:
+ *	Icon/window removed and memory freed.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+WinIcoDestroy(
+    ClientData clientData,
+    XEvent *eventPtr)
+{
+    IcoInterpInfo *icoInterpPtr = (IcoInterpInfo*) clientData;
+    IcoInterpInfo *prevIcoInterpPtr;
+    IcoInfo *icoPtr;
+    IcoInfo *nextPtr;
+
+    if (eventPtr->type != DestroyNotify) {
+        return;
+    }
+
+    if (firstIcoInterpPtr == icoInterpPtr) {
+        firstIcoInterpPtr = icoInterpPtr->nextPtr;
+    } else {
+        for (prevIcoInterpPtr = firstIcoInterpPtr; prevIcoInterpPtr->nextPtr != icoInterpPtr;
+                prevIcoInterpPtr = prevIcoInterpPtr->nextPtr) {
+            /* Empty loop body. */
+        }
+        prevIcoInterpPtr->nextPtr = icoInterpPtr->nextPtr;
+    }
+
+    DestroyWindow(icoInterpPtr->hwnd);
+    for (icoPtr = icoInterpPtr->firstIcoPtr; icoPtr != NULL; icoPtr = nextPtr) {
+            nextPtr = icoPtr->nextPtr;
+        FreeIcoPtr(icoInterpPtr, icoPtr);
+    }
+    ckfree((char *) icoInterpPtr);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * WinSystrayCmd --
+ *
+ * 	Main command for creating, displaying, and removing icons from taskbar.
+ *
+ * Results:
+ *	Management of icon display in taskbar/system tray.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+WinSystrayCmd(
+    ClientData clientData,
+    Tcl_Interp *interp,
+    int objc,
+    Tcl_Obj *const objv[])
+{
+    static const char *const cmdStrings[] = {
+        "add", "delete", "modify", NULL
+    };
+    enum { CMD_ADD, CMD_DELETE, CMD_MODIFY };
+    static const char *const optStrings[] = {
+        "-callback", "-image", "-text", NULL
+    };
+    enum { OPT_CALLBACK, OPT_IMAGE, OPT_TEXT };
+    int cmd, opt;
+
+    HICON hIcon;
+    int i;
+    IcoInterpInfo *icoInterpPtr = (IcoInterpInfo*) clientData;
+    IcoInfo *icoPtr = NULL;
+
+    if (objc < 2) {
+        Tcl_WrongNumArgs(interp, 1, objv, "command ...");
+        return TCL_ERROR;
+    }
+    if (Tcl_GetIndexFromObj(interp, objv[1], cmdStrings, "command",
+            0, &cmd) == TCL_ERROR) {
+        return TCL_ERROR;
+    }
+    switch (cmd) {
+        case CMD_ADD:
+        case CMD_MODIFY: {
+            Tcl_Obj *imageObj = NULL, *textObj = NULL, *callbackObj = NULL;
+            int optStart;
+            int oper;
+            if (cmd == CMD_ADD) {
+                optStart = 2;
+                oper = NIM_ADD;
+            } else {
+                optStart = 3;
+                oper = NIM_MODIFY;
+                if (objc != 5) {
+                    Tcl_WrongNumArgs(interp, 2, objv, "id option value");
+                    return TCL_ERROR;
+                }
+                icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2]));
+                if (icoPtr == NULL) {
+                    return TCL_ERROR;
+                }
+            }
+            for (i = optStart; i < objc; i += 2) {
+                if (Tcl_GetIndexFromObj(interp, objv[i], optStrings, "option",
+                        0, &opt) == TCL_ERROR) {
+                    return TCL_ERROR;
+                }
+                if (i+1 >= objc) {
+                    Tcl_AppendResult(interp,
+                            "missing value for option \"", Tcl_GetString(objv[i]),
+                            "\"", NULL);
+                    return TCL_ERROR;
+                }
+                switch (opt) {
+                    case OPT_IMAGE:
+                        imageObj = objv[i+1];
+                        break;
+                    case OPT_TEXT:
+                        textObj = objv[i+1];
+                        break;
+                    case OPT_CALLBACK:
+                        callbackObj = objv[i+1];
+                        break;
+                }
+            }
+            if (cmd == CMD_ADD && imageObj == NULL) {
+                Tcl_SetObjResult(interp, Tcl_NewStringObj("missing required option \"-image\"", -1));
+                return TCL_ERROR;
+            }
+            if (imageObj != NULL) {
+                Tk_PhotoHandle photo;
+                int width, height;
+                Tk_PhotoImageBlock block;
+
+                photo = Tk_FindPhoto(interp, Tcl_GetString(imageObj));
+                if (photo == NULL) {
+                    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+                            "image \"%s\" doesn't exist", Tcl_GetString(imageObj)));
+                    return TCL_ERROR;
+                }
+                Tk_PhotoGetSize(photo, &width, &height);
+                Tk_PhotoGetImage(photo, &block);
+                hIcon = CreateIcoFromPhoto(width, height, block);
+                if (hIcon == NULL) {
+                    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+                            "failed to create an iconphoto with image \"%s\"", Tcl_GetString(imageObj)));
+                    return TCL_ERROR;
+                }
+            }
+            if (cmd == CMD_ADD) {
+                icoPtr = NewIcon(interp, icoInterpPtr, hIcon);
+            } else {
+                if (imageObj != NULL) {
+                    DestroyIcon(icoPtr->hIcon);
+                    icoPtr->hIcon = hIcon;
+                }
+            }
+            if (callbackObj != NULL) {
+                if (icoPtr->taskbar_command != NULL) {
+                    Tcl_DecrRefCount(icoPtr->taskbar_command);
+                }
+                icoPtr->taskbar_command = callbackObj;
+                Tcl_IncrRefCount(icoPtr->taskbar_command);
+            }
+            if (textObj != NULL) {
+                if (icoPtr->taskbar_txt != NULL) {
+                    Tcl_DecrRefCount(icoPtr->taskbar_txt);
+                }
+                icoPtr->taskbar_txt = textObj;
+                Tcl_IncrRefCount(icoPtr->taskbar_txt);
+            }
+            TaskbarOperation(icoInterpPtr, icoPtr, oper);
+            if (cmd == CMD_ADD) {
+                char buffer[5 + TCL_INTEGER_SPACE];
+                int n;
+                n = _snprintf(buffer, sizeof(buffer) - 1, "ico#%d", icoPtr->id);
+                buffer[n] = 0;
+                Tcl_SetObjResult(interp, Tcl_NewStringObj(buffer, n));
+            }
+            return TCL_OK;
+        }
+        case CMD_DELETE:
+            if (objc != 3) {
+                Tcl_WrongNumArgs(interp, 2, objv, "id");
+                return TCL_ERROR;
+            }
+            icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2]));
+            if (icoPtr == NULL) {
+                return TCL_ERROR;
+            }
+            FreeIcoPtr(icoInterpPtr, icoPtr);
+            return TCL_OK;
+    }
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * WinSysNotifyCmd --
+ *
+ * 	Main command for creating and displaying notifications/balloons from system tray.
+ *
+ * Results:
+ *	Display of notifications.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+WinSysNotifyCmd(
+    ClientData clientData,
+    Tcl_Interp *interp,
+    int objc,
+    Tcl_Obj *const objv[])
+{
+    IcoInterpInfo *icoInterpPtr = (IcoInterpInfo*) clientData;
+    IcoInfo *icoPtr;
+    Tcl_DString infodst;
+    Tcl_DString titledst;
+    NOTIFYICONDATAW ni;
+    char *msgtitle;
+    char *msginfo;
+
+    if (objc < 2) {
+        Tcl_WrongNumArgs(interp, 1, objv, "command ...");
+        return TCL_ERROR;
+    }
+    if (strcmp(Tcl_GetString(objv[1]), "notify") != 0) {
+        Tcl_AppendResult(interp, "unknown subcommand \"", Tcl_GetString(objv[1]),
+                "\": must be notify", NULL);
+        return TCL_ERROR;
+    }
+    if (objc != 5) {
+        Tcl_WrongNumArgs(interp, 2, objv, "id title detail");
+        return TCL_ERROR;
+    }
+
+    icoPtr = GetIcoPtr(interp, icoInterpPtr, Tcl_GetString(objv[2]));
+    if (icoPtr == NULL) {
+        return TCL_ERROR;
+    }
+
+    ni.cbSize = sizeof(NOTIFYICONDATAW);
+    ni.hWnd = icoInterpPtr->hwnd;
+    ni.uID = icoPtr->id;
+    ni.uFlags = NIF_INFO;
+    ni.uCallbackMessage = ICON_MESSAGE;
+    ni.hIcon = icoPtr->hIcon;
+    ni.dwInfoFlags = NIIF_INFO; /* Use a sane platform-specific icon here.*/
+
+    msgtitle = Tcl_GetString(objv[3]);
+    msginfo = Tcl_GetString(objv[4]);
+
+    /* Balloon notification for system tray icon. */
+    if (msgtitle != NULL) {
+        WCHAR *title;
+        Tcl_DStringInit(&titledst);
+        title = Tcl_UtfToWCharDString(msgtitle, -1, &titledst);
+        wcsncpy(ni.szInfoTitle, title, (Tcl_DStringLength(&titledst) + 2) / 2);
+        Tcl_DStringFree(&titledst);
+    }
+    if (msginfo != NULL) {
+        WCHAR *info;
+        Tcl_DStringInit(&infodst);
+        info = Tcl_UtfToWCharDString(msginfo, -1, &infodst);
+        wcsncpy(ni.szInfo, info, (Tcl_DStringLength(&infodst) + 2) / 2);
+        Tcl_DStringFree(&infodst);
+    }
+
+    Shell_NotifyIconW(NIM_MODIFY, &ni);
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * WinIcoInit --
+ *
+ * 	Initialize this package and create script-level commands.
+ *
+ * Results:
+ *	Initialization of code.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+WinIcoInit(
+    Tcl_Interp *interp)
+{
+    IcoInterpInfo *icoInterpPtr;
+    Tk_Window mainWindow;
+
+    mainWindow = Tk_MainWindow(interp);
+    if (mainWindow == NULL) {
+        Tcl_SetObjResult(interp, Tcl_NewStringObj("main window has been destroyed", -1));
+        return TCL_ERROR;
+    }
+
+    icoInterpPtr = (IcoInterpInfo*) ckalloc(sizeof(IcoInterpInfo));
+    icoInterpPtr->counter = 0;
+    icoInterpPtr->firstIcoPtr = NULL;
+    icoInterpPtr->hwnd = CreateTaskbarHandlerWindow();
+    icoInterpPtr->nextPtr = firstIcoInterpPtr;
+    firstIcoInterpPtr = icoInterpPtr;
+    Tcl_CreateObjCommand(interp, "::tk::systray::_systray", WinSystrayCmd,
+            (ClientData) icoInterpPtr, NULL);
+    Tcl_CreateObjCommand(interp, "::tk::sysnotify::_sysnotify", WinSysNotifyCmd,
+            (ClientData) icoInterpPtr, NULL);
+
+    Tk_CreateEventHandler(mainWindow, StructureNotifyMask,
+            WinIcoDestroy, (ClientData) icoInterpPtr);
+
+    return TCL_OK;
+}
+
+/*
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: nil
+ * End:
+ */

Index: win/tkWinTest.c
==================================================================
--- win/tkWinTest.c
+++ win/tkWinTest.c
@@ -2,13 +2,13 @@
  * tkWinTest.c --
  *
  *	Contains commands for platform specific tests for the Windows
  *	platform.
  *
- * Copyright (c) 1997 Sun Microsystems, Inc.
- * Copyright (c) 2000 by Scriptics Corporation.
- * Copyright (c) 2001 by ActiveState Corporation.
+ * Copyright © 1997 Sun Microsystems, Inc.
+ * Copyright © 2000 Scriptics Corporation.
+ * Copyright © 2001 ActiveState Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -309,11 +309,11 @@
     (void)dummy;
 
     if ((objc == 3) && (strcmp(Tcl_GetString(objv[1]), "debug") == 0)) {
 	int b;
 
-	if (Tcl_GetBoolean(interp, Tcl_GetString(objv[2]), &b) != TCL_OK) {
+	if (Tcl_GetBooleanFromObj(interp, objv[2], &b) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 	TkWinDialogDebug(b);
 	return TCL_OK;
     }
@@ -379,11 +379,11 @@
         }
         buf[0] = 0;
         SendMessageA(control, WM_GETTEXT, (WPARAM)sizeof(buf),
                      (LPARAM) buf);
 #endif
-	Tcl_ExternalToUtfDString(NULL, buf, -1, &ds);
+	(void)Tcl_ExternalToUtfDStringEx(NULL, buf, -1, TCL_ENCODING_NOCOMPLAIN, &ds);
 	Tcl_AppendResult(interp, Tcl_DStringValue(&ds), NULL);
 	Tcl_DStringFree(&ds);
 	break;
     }
     case WM_SETTEXT: {
@@ -394,11 +394,11 @@
 	    Tcl_SetObjResult(interp,
 		    Tcl_ObjPrintf("Could not find control with id %d", id));
 	    return TCL_ERROR;
 	}
 	Tcl_DStringInit(&ds);
-	Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[4]), -1, &ds);
+	(void)Tcl_UtfToExternalDStringEx(NULL, Tcl_GetString(objv[4]), -1, TCL_ENCODING_NOCOMPLAIN, &ds);
 	result = SendMessageA(control, WM_SETTEXT, 0,
 		(LPARAM) Tcl_DStringValue(&ds));
 	Tcl_DStringFree(&ds);
 	if (result == 0) {
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to send text to dialog: ", -1));

Index: win/tkWinWindow.c
==================================================================
--- win/tkWinWindow.c
+++ win/tkWinWindow.c
@@ -2,11 +2,11 @@
  * tkWinWindow.c --
  *
  *	Xlib emulation routines for Windows related to creating, displaying
  *	and destroying windows.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -245,17 +245,18 @@
  *
  *----------------------------------------------------------------------
  */
 
 Window
-TkpMakeWindow(
-    TkWindow *winPtr,
+Tk_MakeWindow(
+    Tk_Window tkwin,
     Window parent)
 {
     HWND parentWin;
     int style;
     HWND hwnd;
+    TkWindow *winPtr = (TkWindow *)tkwin;
 
     if (parent != None) {
 	parentWin = Tk_GetHWND(parent);
 	style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
     } else {

Index: win/tkWinWm.c
==================================================================
--- win/tkWinWm.c
+++ win/tkWinWm.c
@@ -4,20 +4,24 @@
  *	This module takes care of the interactions between a Tk-based
  *	application and the window manager. Among other things, it implements
  *	the "wm" command and passes geometry information to the window
  *	manager.
  *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-2000 by Scriptics Corporation.
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
 #include "tkWinInt.h"
+#include <windows.h>
+#include <wtypes.h>
+#include <shobjidl.h>
+#include <shlguid.h>
 #include <shellapi.h>
-
+#include "tkWinIco.h"
 /*
  * These next two defines are only valid on Win2K/XP+.
  */
 
 #ifndef WS_EX_LAYERED
@@ -75,65 +79,13 @@
 typedef struct TkWmStackorderToplevelPair {
     Tcl_HashTable *table;
     TkWindow **windowPtr;
 } TkWmStackorderToplevelPair;
 
-/*
- * This structure represents the contents of a icon, in terms of its image.
- * The HICON is an internal Windows format. Most of these icon-specific
- * structures originated with the Winico extension. We stripped out unused
- * parts of that code, and integrated the code more naturally with Tcl.
- */
-
-typedef struct {
-    UINT Width, Height, Colors;	/* Width, Height and bpp */
-    LPBYTE lpBits;		/* Ptr to DIB bits */
-    DWORD dwNumBytes;		/* How many bytes? */
-    LPBITMAPINFO lpbi;		/* Ptr to header */
-    LPBYTE lpXOR;		/* Ptr to XOR image bits */
-    LPBYTE lpAND;		/* Ptr to AND image bits */
-    HICON hIcon;		/* DAS ICON */
-} ICONIMAGE, *LPICONIMAGE;
-
-/*
- * This structure is how we represent a block of the above items. We will
- * reallocate these structures according to how many images they need to
- * contain.
- */
-
-typedef struct {
-    int nNumImages;		/* How many images? */
-    ICONIMAGE IconImages[1];	/* Image entries */
-} BlockOfIconImages, *BlockOfIconImagesPtr;
-
-/*
- * These two structures are used to read in icons from an 'icon directory'
- * (i.e. the contents of a .icr file, say). We only use these structures
- * temporarily, since we copy the information we want into a
- * BlockOfIconImages.
- */
-
-typedef struct {
-    BYTE bWidth;		/* Width of the image */
-    BYTE bHeight;		/* Height of the image (times 2) */
-    BYTE bColorCount;		/* Number of colors in image (0 if >=8bpp) */
-    BYTE bReserved;		/* Reserved */
-    WORD wPlanes;		/* Color Planes */
-    WORD wBitCount;		/* Bits per pixel */
-    DWORD dwBytesInRes;		/* How many bytes in this resource? */
-    DWORD dwImageOffset;	/* Where in the file is this image */
-} ICONDIRENTRY, *LPICONDIRENTRY;
-
-typedef struct {
-    WORD idReserved;		/* Reserved */
-    WORD idType;		/* Resource type (1 for icons) */
-    WORD idCount;		/* How many images? */
-    ICONDIRENTRY idEntries[1];	/* The entries for each image */
-} ICONDIR, *LPICONDIR;
-
-/*
- * A pointer to one of these strucutures is associated with each toplevel.
+
+/*
+ * A pointer to one of these structures is associated with each toplevel.
  * This allows us to free up all memory associated with icon resources when a
  * window is deleted or if the window's icon is changed. They are simply
  * reference counted according to:
  *
  * (1) How many WmInfo structures point to this object
@@ -356,11 +308,11 @@
 /*
  * The following structure is the official type record for geometry management
  * of top-level windows.
  */
 
-static void		TopLevelReqProc(ClientData dummy, Tk_Window tkwin);
+static void		TopLevelReqProc(void *dummy, Tk_Window tkwin);
 static void		RemapWindows(TkWindow *winPtr, HWND parentHWND);
 
 static const Tk_GeomMgr wmMgrType = {
     "wm",			/* name */
     TopLevelReqProc,		/* requestProc */
@@ -395,10 +347,20 @@
 static int initialized;		/* Flag indicating whether module has been
 				 * initialized. */
 
 TCL_DECLARE_MUTEX(winWmMutex)
 
+/*
+ * The following records the "TaskbarButtonCreated" message ID
+ * for overlay icons.
+ */
+
+static UINT TaskbarButtonCreatedMessageId = WM_NULL;
+
+/* Reference to taskbarlist API for overlay icons. */
+ITaskbarList3 *ptbl;
+
 /*
  * Forward declarations for functions defined in this file:
  */
 
 static int		ActivateWindow(Tcl_Event *evPtr, int flags);
@@ -421,26 +383,26 @@
 static void		SetLimits(HWND hwnd, MINMAXINFO *info);
 static void		TkWmStackorderToplevelWrapperMap(TkWindow *winPtr,
 			    Display *display, Tcl_HashTable *table);
 static LRESULT CALLBACK	TopLevelProc(HWND hwnd, UINT message,
 			    WPARAM wParam, LPARAM lParam);
-static void		TopLevelEventProc(ClientData clientData,
+static void		TopLevelEventProc(void *clientData,
 			    XEvent *eventPtr);
-static void		TopLevelReqProc(ClientData dummy, Tk_Window tkwin);
-static void		UpdateGeometryInfo(ClientData clientData);
+static void		TopLevelReqProc(void *dummy, Tk_Window tkwin);
+static void		UpdateGeometryInfo(void *clientData);
 static void		UpdateWrapper(TkWindow *winPtr);
 static LRESULT CALLBACK	WmProc(HWND hwnd, UINT message,
 			    WPARAM wParam, LPARAM lParam);
-static void		WmWaitVisibilityOrMapProc(ClientData clientData,
+static void		WmWaitVisibilityOrMapProc(void *clientData,
 			    XEvent *eventPtr);
 static BlockOfIconImagesPtr ReadIconOrCursorFromFile(Tcl_Interp *interp,
 			    Tcl_Obj* fileName, BOOL isIcon);
 static WinIconPtr	ReadIconFromFile(Tcl_Interp *interp,
 			    Tcl_Obj *fileName);
+static BOOL		AdjustIconImagePointers(LPICONIMAGE lpImage);
 static WinIconPtr	GetIconFromPixmap(Display *dsPtr, Pixmap pixmap);
 static int		ReadICOHeader(Tcl_Channel channel);
-static BOOL		AdjustIconImagePointers(LPICONIMAGE lpImage);
 static HICON		MakeIconOrCursorFromResource(LPICONIMAGE lpIcon,
 			    BOOL isIcon);
 static HICON		GetIcon(WinIconPtr titlebaricon, int icon_size);
 static int		WinSetIcon(Tcl_Interp *interp,
 			    WinIconPtr titlebaricon, Tk_Window tkw);
@@ -481,10 +443,13 @@
 			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
 			    Tcl_Obj *const objv[]);
 static int		WmGroupCmd(Tk_Window tkwin,
 			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
 			    Tcl_Obj *const objv[]);
+static int		WmIconbadgeCmd(Tk_Window tkwin,
+			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
+			    Tcl_Obj *const objv[]);
 static int		WmIconbitmapCmd(Tk_Window tkwin,
 			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
 			    Tcl_Obj *const objv[]);
 static int		WmIconifyCmd(Tk_Window tkwin,
 			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
@@ -542,191 +507,10 @@
 			    Tcl_Obj *const objv[]);
 static int		WmWithdrawCmd(Tk_Window tkwin,
 			    TkWindow *winPtr, Tcl_Interp *interp, int objc,
 			    Tcl_Obj *const objv[]);
 static void		WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr);
-
-/*
- * Used in BytesPerLine
- */
-
-#define WIDTHBYTES(bits)	((((bits) + 31)>>5)<<2)
-
-/*
- *----------------------------------------------------------------------
- *
- * DIBNumColors --
- *
- *	Calculates the number of entries in the color table, given by LPSTR
- *	lpbi - pointer to the CF_DIB memory block. Used by titlebar icon code.
- *
- * Results:
- *	WORD - Number of entries in the color table.
- *
- *----------------------------------------------------------------------
- */
-
-static WORD
-DIBNumColors(
-    LPSTR lpbi)
-{
-    WORD wBitCount;
-    DWORD dwClrUsed;
-
-    dwClrUsed = ((LPBITMAPINFOHEADER) lpbi)->biClrUsed;
-
-    if (dwClrUsed) {
-	return (WORD) dwClrUsed;
-    }
-
-    wBitCount = ((LPBITMAPINFOHEADER) lpbi)->biBitCount;
-
-    switch (wBitCount) {
-    case 1:
-	return 2;
-    case 4:
-	return 16;
-    case 8:
-	return 256;
-    default:
-	return 0;
-    }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * PaletteSize --
- *
- *	Calculates the number of bytes in the color table, as given by LPSTR
- *	lpbi - pointer to the CF_DIB memory block. Used by titlebar icon code.
- *
- * Results:
- *	Number of bytes in the color table
- *
- *----------------------------------------------------------------------
- */
-static WORD
-PaletteSize(
-    LPSTR lpbi)
-{
-    return (WORD) (DIBNumColors(lpbi) * sizeof(RGBQUAD));
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FindDIBits --
- *
- *	Locate the image bits in a CF_DIB format DIB, as given by LPSTR lpbi -
- *	pointer to the CF_DIB memory block. Used by titlebar icon code.
- *
- * Results:
- *	pointer to the image bits
- *
- * Side effects: None
- *
- *
- *----------------------------------------------------------------------
- */
-
-static LPSTR
-FindDIBBits(
-    LPSTR lpbi)
-{
-    return lpbi + *((LPDWORD) lpbi) + PaletteSize(lpbi);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * BytesPerLine --
- *
- *	Calculates the number of bytes in one scan line, as given by
- *	LPBITMAPINFOHEADER lpBMIH - pointer to the BITMAPINFOHEADER that
- *	begins the CF_DIB block. Used by titlebar icon code.
- *
- * Results:
- *	number of bytes in one scan line (DWORD aligned)
- *
- *----------------------------------------------------------------------
- */
-
-static DWORD
-BytesPerLine(
-    LPBITMAPINFOHEADER lpBMIH)
-{
-    return WIDTHBYTES(lpBMIH->biWidth * lpBMIH->biPlanes * lpBMIH->biBitCount);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * AdjustIconImagePointers --
- *
- *	Adjusts internal pointers in icon resource struct, as given by
- *	LPICONIMAGE lpImage - the resource to handle. Used by titlebar icon
- *	code.
- *
- * Results:
- *	BOOL - TRUE for success, FALSE for failure
- *
- *----------------------------------------------------------------------
- */
-
-static BOOL
-AdjustIconImagePointers(
-    LPICONIMAGE lpImage)
-{
-    /*
-     * Sanity check.
-     */
-
-    if (lpImage == NULL) {
-	return FALSE;
-    }
-
-    /*
-     * BITMAPINFO is at beginning of bits.
-     */
-
-    lpImage->lpbi = (LPBITMAPINFO) lpImage->lpBits;
-
-    /*
-     * Width - simple enough.
-     */
-
-    lpImage->Width = lpImage->lpbi->bmiHeader.biWidth;
-
-    /*
-     * Icons are stored in funky format where height is doubled so account for
-     * that.
-     */
-
-    lpImage->Height = (lpImage->lpbi->bmiHeader.biHeight)/2;
-
-    /*
-     * How many colors?
-     */
-
-    lpImage->Colors = lpImage->lpbi->bmiHeader.biPlanes
-	    * lpImage->lpbi->bmiHeader.biBitCount;
-
-    /*
-     * XOR bits follow the header and color table.
-     */
-
-    lpImage->lpXOR = (LPBYTE) FindDIBBits((LPSTR) lpImage->lpbi);
-
-    /*
-     * AND bits follow the XOR bits.
-     */
-
-    lpImage->lpAND = lpImage->lpXOR +
-	    lpImage->Height*BytesPerLine((LPBITMAPINFOHEADER) lpImage->lpbi);
-    return TRUE;
-}
 
 /*
  *----------------------------------------------------------------------
  *
  * MakeIconOrCursorFromResource --
@@ -1296,10 +1080,79 @@
 	titlebaricon->refCount = 1;
     }
     return titlebaricon;
 }
 
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * AdjustIconImagePointers --
+ *
+ *	Adjusts internal pointers in icon resource struct, as given by
+ *	LPICONIMAGE lpImage - the resource to handle. Used by titlebar icon
+ *	code.
+ *
+ * Results:
+ *	BOOL - TRUE for success, FALSE for failure
+ *
+ *----------------------------------------------------------------------
+ */
+
+static BOOL
+AdjustIconImagePointers(
+    LPICONIMAGE lpImage)
+{
+    /*
+     * Sanity check.
+     */
+
+    if (lpImage == NULL) {
+	return FALSE;
+    }
+
+    /*
+     * BITMAPINFO is at beginning of bits.
+     */
+
+    lpImage->lpbi = (LPBITMAPINFO) lpImage->lpBits;
+
+    /*
+     * Width - simple enough.
+     */
+
+    lpImage->Width = lpImage->lpbi->bmiHeader.biWidth;
+
+    /*
+     * Icons are stored in funky format where height is doubled so account for
+     * that.
+     */
+
+    lpImage->Height = (lpImage->lpbi->bmiHeader.biHeight)/2;
+
+    /*
+     * How many colors?
+     */
+
+    lpImage->Colors = lpImage->lpbi->bmiHeader.biPlanes
+	    * lpImage->lpbi->bmiHeader.biBitCount;
+
+    /*
+     * XOR bits follow the header and color table.
+     */
+
+    lpImage->lpXOR = (LPBYTE) FindDIBBits((LPSTR) lpImage->lpbi);
+
+    /*
+     * AND bits follow the XOR bits.
+     */
+
+    lpImage->lpAND = lpImage->lpXOR +
+	    lpImage->Height*BytesPerLine((LPBITMAPINFOHEADER) lpImage->lpbi);
+    return TRUE;
+}
+
 /*
  *----------------------------------------------------------------------
  *
  * GetIconFromPixmap --
  *
@@ -1879,10 +1732,16 @@
     if (!tsdPtr->initialized) {
 	return;
     }
     tsdPtr->initialized = 0;
 
+    /*
+     * COM library cleanup.
+     */
+
+    CoUninitialize();
+
     UnregisterClassW(TK_WIN_TOPLEVEL_CLASS_NAME, hInstance);
 }
 
 /*
  *--------------------------------------------------------------
@@ -1995,10 +1854,11 @@
     HWND child, nextHWND, focusHWND;
     int x, y, width, height, state;
     WINDOWPLACEMENT place;
     HICON hSmallIcon = NULL;
     HICON hBigIcon = NULL;
+    HRESULT hr;
     Tcl_DString titleString;
     int *childStateInfo = NULL;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
 
@@ -2323,10 +2183,39 @@
 	tsdPtr->firstWindow = 0;
 	SetActiveWindow(wmPtr->wrapper);
     } else if (focusHWND) {
 	SetFocus(focusHWND);
     }
+
+    /*
+     * Initialize hooks for overlay icon.
+     * Start with TaskbarButtonCreated message.
+     */
+
+    TaskbarButtonCreatedMessageId = RegisterWindowMessage(TEXT("TaskbarButtonCreated"));
+
+    /*
+     * In case the application is run elevated, allow the
+     * TaskbarButtonCreated message through.
+     */
+
+    ChangeWindowMessageFilter(TaskbarButtonCreatedMessageId, MSGFLT_ADD);
+
+    /*
+     * Load COM library for icon overlay.
+     */
+
+    hr = CoInitialize(0);
+    if (SUCCEEDED(hr)) {
+	hr = CoCreateInstance(&CLSID_TaskbarList, NULL,
+		CLSCTX_INPROC_SERVER, &IID_ITaskbarList3, (void **) &ptbl);
+	if (FAILED(hr)) {
+	    printf("Unable to initialize ITaskbarList3 API");
+	    ptbl->lpVtbl->Release(NULL);
+	    ptbl = NULL;
+	}
+    }
 }
 
 /*
  *--------------------------------------------------------------
  *
@@ -2738,14 +2627,12 @@
  *--------------------------------------------------------------
  */
 
 void
 TkWmSetClass(
-    TkWindow *winPtr)		/* Newly-created top-level window. */
+    TCL_UNUSED(TkWindow *))	/* Newly-created top-level window. */
 {
-    (void)winPtr;
-
     /* Do nothing */
     return;
 }
 
 /*
@@ -2765,20 +2652,20 @@
  *----------------------------------------------------------------------
  */
 
 int
 Tk_WmObjCmd(
-    ClientData clientData,	/* Main window associated with interpreter. */
+    void *clientData,	/* Main window associated with interpreter. */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     Tk_Window tkwin = (Tk_Window)clientData;
     static const char *const optionStrings[] = {
 	"aspect", "attributes", "client", "colormapwindows",
 	"command", "deiconify", "focusmodel", "forget", "frame",
-	"geometry", "grid", "group", "iconbitmap",
+	"geometry", "grid", "group", "iconbadge", "iconbitmap",
 	"iconify", "iconmask", "iconname",
 	"iconphoto", "iconposition",
 	"iconwindow", "manage", "maxsize", "minsize", "overrideredirect",
 	"positionfrom", "protocol", "resizable", "sizefrom",
 	"stackorder", "state", "title", "transient",
@@ -2786,11 +2673,11 @@
     };
     enum options {
 	WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
 	WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FORGET,
 	WMOPT_FRAME,
-	WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP,
+	WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBADGE, WMOPT_ICONBITMAP,
 	WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME,
 	WMOPT_ICONPHOTO, WMOPT_ICONPOSITION,
 	WMOPT_ICONWINDOW, WMOPT_MANAGE, WMOPT_MAXSIZE, WMOPT_MINSIZE,
 	WMOPT_OVERRIDEREDIRECT,
 	WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM,
@@ -2807,11 +2694,11 @@
     wrongNumArgs:
 	Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?");
 	return TCL_ERROR;
     }
 
-    argv1 = TkGetStringFromObj(objv[1], &length);
+    argv1 = Tcl_GetStringFromObj(objv[1], &length);
     if ((argv1[0] == 't') && !strncmp(argv1, "tracing", length)
 	    && (length >= 3)) {
 	int wmTracing;
 
 	if ((objc != 2) && (objc != 3)) {
@@ -2832,12 +2719,12 @@
 	    dispPtr->flags &= ~TK_DISPLAY_WM_TRACING;
 	}
 	return TCL_OK;
     }
 
-    if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings,
-	    sizeof(char *), "option", 0, &index) != TCL_OK) {
+    if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings,
+	    "option", 0, &index) != TCL_OK) {
 	return TCL_ERROR;
     }
 
     if (objc < 3) {
 	goto wrongNumArgs;
@@ -2879,10 +2766,12 @@
 	return WmGeometryCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_GRID:
 	return WmGridCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_GROUP:
 	return WmGroupCmd(tkwin, winPtr, interp, objc, objv);
+    case WMOPT_ICONBADGE:
+	return WmIconbadgeCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_ICONBITMAP:
 	return WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_ICONIFY:
 	return WmIconifyCmd(tkwin, winPtr, interp, objc, objv);
     case WMOPT_ICONMASK:
@@ -2944,19 +2833,18 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmAspectCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     int numer1, denom1, numer2, denom2;
-    (void)tkwin;
 
     if ((objc != 3) && (objc != 7)) {
 	Tcl_WrongNumArgs(interp, 2, objv,
 		"window ?minNumer minDenom maxNumer maxDenom?");
 	return TCL_ERROR;
@@ -3072,14 +2960,11 @@
 		Tcl_NewWideIntObj((exStyle & WS_EX_TOPMOST) != 0));
 	Tcl_SetObjResult(interp, objPtr);
 	return TCL_OK;
     }
     for (i = 3; i < objc; i += 2) {
-	string = TkGetStringFromObj(objv[i], &length);
-	if ((length < 2) || (string[0] != '-')) {
-	    goto configArgs;
-	}
+	string = Tcl_GetStringFromObj(objv[i], &length);
 	if (strncmp(string, "-disabled", length) == 0) {
 	    stylePtr = &style;
 	    styleBit = WS_DISABLED;
 	} else if ((strncmp(string, "-alpha", length) == 0)
 		|| ((length > 2) && (strncmp(string, "-transparentcolor",
@@ -3108,10 +2993,16 @@
 			"can't set topmost flag on %s: it is an embedded window",
 			winPtr->pathName));
 		Tcl_SetErrorCode(interp, "TK", "WM", "ATTR", "TOPMOST", NULL);
 		return TCL_ERROR;
 	    }
+	} else if (i == 3) {
+	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		    "bad attribute \"%s\": must be -alpha, -disabled, -fullscreen, -toolwindow, -topmost, or -transparentcolor",
+		    string));
+	    Tcl_SetErrorCode(interp, "TK", "WM", "ATTR", "UNRECOGNIZED", NULL);
+	    return TCL_ERROR;
 	} else {
 	    goto configArgs;
 	}
 	if (styleBit == WS_EX_LAYERED) {
 	    if (objc == 4) {
@@ -3140,11 +3031,11 @@
 		    } else if (dval > 1.0) {
 			dval = 1;
 		    }
 		    wmPtr->alpha = dval;
 		} else {			/* -transparentcolor */
-		    const char *crefstr = TkGetStringFromObj(objv[i+1], &length);
+		    const char *crefstr = Tcl_GetStringFromObj(objv[i+1], &length);
 
 		    if (length == 0) {
 			/* reset to no transparent color */
 			if (wmPtr->crefObj) {
 			    Tcl_DecrRefCount(wmPtr->crefObj);
@@ -3311,20 +3202,19 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmClientCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     const char *argv3;
     TkSizeT length;
-    (void)tkwin;
 
     if ((objc != 3) && (objc != 4)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?name?");
 	return TCL_ERROR;
     }
@@ -3333,11 +3223,11 @@
 	    Tcl_SetObjResult(interp,
 		    Tcl_NewStringObj(wmPtr->clientMachine, -1));
 	}
 	return TCL_OK;
     }
-    argv3 = TkGetStringFromObj(objv[3], &length);
+    argv3 = Tcl_GetStringFromObj(objv[3], &length);
     if (argv3[0] == 0) {
 	if (wmPtr->clientMachine != NULL) {
 	    ckfree(wmPtr->clientMachine);
 	    wmPtr->clientMachine = NULL;
 	    if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
@@ -3476,21 +3366,20 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmCommandCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     const char *argv3;
     int cmdArgc;
     const char **cmdArgv;
-    (void)tkwin;
 
     if ((objc != 3) && (objc != 4)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?value?");
 	return TCL_ERROR;
     }
@@ -3546,18 +3435,17 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmDeiconifyCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
-    (void)tkwin;
 
     if (objc != 3) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window");
 	return TCL_ERROR;
     }
@@ -3599,11 +3487,11 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmFocusmodelCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
@@ -3613,11 +3501,10 @@
     };
     enum options {
 	OPT_ACTIVE, OPT_PASSIVE
     };
     int index;
-    (void)tkwin;
 
     if ((objc != 3) && (objc != 4)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?");
 	return TCL_ERROR;
     }
@@ -3625,12 +3512,12 @@
 	Tcl_SetObjResult(interp, Tcl_NewStringObj(
 		wmPtr->hints.input ? "passive" : "active", -1));
 	return TCL_OK;
     }
 
-    if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings,
-	    sizeof(char *), "argument", 0,&index) != TCL_OK) {
+    if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings,
+	    "argument", 0,&index) != TCL_OK) {
 	return TCL_ERROR;
     }
     if (index == OPT_ACTIVE) {
 	wmPtr->hints.input = False;
     } else { /* OPT_PASSIVE */
@@ -3656,32 +3543,28 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmForgetCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel or Frame to work with */
-    Tcl_Interp *dummy,		/* Current interpreter. */
-    int objc,			/* Number of arguments. */
-    Tcl_Obj *const objv[])	/* Argument objects. */
+    TCL_UNUSED(Tcl_Interp *),		/* Current interpreter. */
+    TCL_UNUSED(int),		/* Number of arguments. */
+    TCL_UNUSED(Tcl_Obj *const *))	/* Argument objects. */
 {
     Tk_Window frameWin = (Tk_Window) winPtr;
-    (void)tkwin;
-    (void)dummy;
-    (void)objc;
-    (void)objv;
 
     if (Tk_IsTopLevel(frameWin)) {
 	Tk_UnmapWindow(frameWin);
 	winPtr->flags &= ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
 	Tk_MakeWindowExist((Tk_Window)winPtr->parentPtr);
 	RemapWindows(winPtr, Tk_GetHWND(winPtr->parentPtr->window));
 
-        /*
-         * Make sure wm no longer manages this window
-         */
-        Tk_ManageGeometry(frameWin, NULL, NULL);
+	/*
+	 * Make sure wm no longer manages this window
+	 */
+	Tk_ManageGeometry(frameWin, NULL, NULL);
 
 	TkWmDeadWindow(winPtr);
 	/* flags (above) must be cleared before calling */
 	/* TkMapTopFrame (below) */
 	TkMapTopFrame(frameWin);
@@ -3708,20 +3591,19 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmFrameCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     HWND hwnd;
     char buf[TCL_INTEGER_SPACE];
-    (void)tkwin;
 
     if (objc != 3) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window");
 	return TCL_ERROR;
     }
@@ -3754,21 +3636,20 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmGeometryCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     char xSign, ySign;
     int width, height;
     const char *argv3;
-    (void)tkwin;
 
     if ((objc != 3) && (objc != 4)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?");
 	return TCL_ERROR;
     }
@@ -3823,19 +3704,18 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmGridCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     int reqWidth, reqHeight, widthInc, heightInc;
-    (void)tkwin;
 
     if ((objc != 3) && (objc != 7)) {
 	Tcl_WrongNumArgs(interp, 2, objv,
 		"window ?baseWidth baseHeight widthInc heightInc?");
 	return TCL_ERROR;
@@ -3943,11 +3823,11 @@
 	if (wmPtr->hints.flags & WindowGroupHint) {
 	    Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->leaderName, -1));
 	}
 	return TCL_OK;
     }
-    argv3 = TkGetStringFromObj(objv[3], &length);
+    argv3 = Tcl_GetStringFromObj(objv[3], &length);
     if (*argv3 == '\0') {
 	wmPtr->hints.flags &= ~WindowGroupHint;
 	if (wmPtr->leaderName != NULL) {
 	    ckfree(wmPtr->leaderName);
 	}
@@ -3969,10 +3849,121 @@
 }
 
 /*
  *----------------------------------------------------------------------
  *
+ * WmIconbadgeCmd --
+ *
+ *	This function is invoked to process the "wm iconbadge" Tcl command.
+ *	See the user documentation for details on what it does.
+ *
+ * Results:
+ *	A standard Tcl result.
+ *
+ * Side effects:
+ *	See the user documentation.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+WmIconbadgeCmd(
+    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(TkWindow *),	/* Toplevel to work with */
+    Tcl_Interp *interp,		/* Current interpreter. */
+    int objc,			/* Number of arguments. */
+    Tcl_Obj *const objv[])	/* Argument objects. */
+{
+    HWND hwnd;
+    Tk_PhotoHandle photo;
+    Tk_PhotoImageBlock block;
+    int width, height;
+    HICON overlayicon;
+    int badgenumber;
+    char *badgestring = NULL;
+    char photoname[4096];
+    LPCWSTR string;
+    HRESULT hr;
+    Tk_Window badgewindow;
+    WmInfo *wmPtr;
+
+    if (objc < 4) {
+	Tcl_WrongNumArgs(interp, 2, objv, "window badge");
+	return TCL_ERROR;
+    }
+
+    /*
+     * Parse args, get native wrapper window, and determine image.
+     */
+
+    badgewindow = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin);
+    wmPtr = ((TkWindow *) badgewindow)->wmInfoPtr;
+    hwnd = wmPtr->wrapper;
+    badgestring = Tcl_GetString(objv[3]);
+
+    badgenumber = atoi(badgestring);
+    if (badgenumber > 9) {
+	strcpy(photoname, "::tk::icons::9plus-badge");
+    } else {
+	strcpy(photoname, "::tk::icons::");
+	strcat(photoname, badgestring);
+	strcat(photoname, "-badge");
+    }
+
+    /*
+     * If badgestring is empty string, remove icon.
+     */
+
+    if (strcmp("", badgestring) == 0) {
+	ptbl->lpVtbl->SetOverlayIcon(ptbl, hwnd, NULL, NULL);
+	return TCL_OK;
+    }
+
+    /*
+     * If photo does not exist, return error. This means we do not have
+     * to test for decimal or negative values; no photo for such values
+     * is present.
+     */
+
+    photo = Tk_FindPhoto(interp, photoname);
+    if (photo == NULL) {
+	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+		"can't use \"%s\" as icon badge", badgestring));
+	return TCL_ERROR;
+    }
+
+    /*
+     * We have found the image. Convert to icon.
+     */
+
+    Tk_PhotoGetSize(photo, &width, &height);
+    Tk_PhotoGetImage(photo, &block);
+
+    overlayicon = CreateIcoFromPhoto(width, height, block);
+    if (overlayicon == NULL) {
+	Tcl_SetObjResult(interp, Tcl_NewStringObj("Failed to create badge icon", -1));
+	return TCL_ERROR;
+    }
+
+    /*
+     * Place overlay icon on taskbar icon.
+     */
+
+    string = L"Alert";
+    hr = ptbl->lpVtbl->SetOverlayIcon(ptbl, hwnd, overlayicon, string);
+    if (hr != S_OK) {
+	Tcl_SetObjResult(interp, Tcl_NewStringObj("Failed to create badge icon", -1));
+	return TCL_ERROR;
+    }
+    DestroyIcon(overlayicon);
+
+    return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
  * WmIconbitmapCmd --
  *
  *	This function is invoked to process the "wm iconbitmap" Tcl command.
  *	See the user documentation for details on what it does.
  *
@@ -3985,20 +3976,19 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmIconbitmapCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     TkWindow *useWinPtr = winPtr; /* window to apply to (NULL if -default) */
     const char *string;
-    (void)tkwin;
 
     if ((objc < 3) || (objc > 5)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?-default? ?image?");
 	return TCL_ERROR;
     } else if (objc == 5) {
@@ -4122,18 +4112,17 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmIconifyCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
-    (void)tkwin;
 
     if (objc != 3) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window");
 	return TCL_ERROR;
     }
@@ -4247,20 +4236,19 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmIconnameCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     const char *argv3;
     TkSizeT length;
-    (void)tkwin;
 
     if (objc > 4) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?");
 	return TCL_ERROR;
     }
@@ -4270,11 +4258,11 @@
 	return TCL_OK;
     } else {
 	if (wmPtr->iconName != NULL) {
 	    ckfree(wmPtr->iconName);
 	}
-	argv3 = TkGetStringFromObj(objv[3], &length);
+	argv3 = Tcl_GetStringFromObj(objv[3], &length);
 	wmPtr->iconName = (char *)ckalloc(length + 1);
 	memcpy(wmPtr->iconName, argv3, length + 1);
 	if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
 	    XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName);
 	}
@@ -4299,29 +4287,24 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmIconphotoCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     TkWindow *useWinPtr = winPtr; /* window to apply to (NULL if -default) */
     Tk_PhotoHandle photo;
     Tk_PhotoImageBlock block;
-    int i, width, height, idx, bufferSize, startObj = 3;
-    union {unsigned char *ptr; void *voidPtr;} bgraPixel;
-    union {unsigned char *ptr; void *voidPtr;} bgraMask;
+    int i, width, height, startObj = 3;
     BlockOfIconImagesPtr lpIR;
     WinIconPtr titlebaricon = NULL;
     HICON hIcon;
     unsigned size;
-    BITMAPINFO bmInfo;
-    ICONINFO iconInfo;
-    (void)tkwin;
 
     if (objc < 4) {
 	Tcl_WrongNumArgs(interp, 2, objv,
 		"window ?-default? image1 ?image2 ...?");
 	return TCL_ERROR;
@@ -4361,107 +4344,29 @@
     if (lpIR == NULL) {
 	return TCL_ERROR;
     }
     ZeroMemory(lpIR, size);
 
-    lpIR->nNumImages = objc - startObj;
-
     for (i = startObj; i < objc; i++) {
 	photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i]));
 	Tk_PhotoGetSize(photo, &width, &height);
 	Tk_PhotoGetImage(photo, &block);
 
-	/*
-	 * Don't use CreateIcon to create the icon, as it requires color
-	 * bitmap data in device-dependent format. Instead we use
-	 * CreateIconIndirect which takes device-independent bitmaps and
-	 * converts them as required. Initialise icon info structure.
-	 */
-
-	ZeroMemory(&iconInfo, sizeof(iconInfo));
-	iconInfo.fIcon = TRUE;
-
-	/*
-	 * Create device-independent color bitmap.
-	 */
-
-	ZeroMemory(&bmInfo, sizeof bmInfo);
-	bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-	bmInfo.bmiHeader.biWidth = width;
-	bmInfo.bmiHeader.biHeight = -height;
-	bmInfo.bmiHeader.biPlanes = 1;
-	bmInfo.bmiHeader.biBitCount = 32;
-	bmInfo.bmiHeader.biCompression = BI_RGB;
-
-	iconInfo.hbmColor = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS,
-		&bgraPixel.voidPtr, NULL, 0);
-	if (!iconInfo.hbmColor) {
-	    ckfree(lpIR);
-	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
-		    "failed to create an iconphoto with image \"%s\"",
-		    Tcl_GetString(objv[i])));
-	    Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "IMAGE", NULL);
-	    return TCL_ERROR;
-	}
-
-	/*
-	 * Convert the photo image data into BGRA format (RGBQUAD).
-	 */
-
-	bufferSize = height * width * 4;
-	for (idx = 0 ; idx < bufferSize ; idx += 4) {
-	    bgraPixel.ptr[idx] = block.pixelPtr[idx+2];
-	    bgraPixel.ptr[idx+1] = block.pixelPtr[idx+1];
-	    bgraPixel.ptr[idx+2] = block.pixelPtr[idx+0];
-	    bgraPixel.ptr[idx+3] = block.pixelPtr[idx+3];
-	}
-
-	/*
-	 * Create a dummy mask bitmap. The contents of this don't appear to
-	 * matter, as CreateIconIndirect will setup the icon mask based on the
-	 * alpha channel in our color bitmap.
-	 */
-
-	bmInfo.bmiHeader.biBitCount = 1;
-
-	iconInfo.hbmMask = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS,
-		&bgraMask.voidPtr, NULL, 0);
-	if (!iconInfo.hbmMask) {
-	    DeleteObject(iconInfo.hbmColor);
-	    ckfree(lpIR);
-	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
-		    "failed to create mask bitmap for \"%s\"",
-		    Tcl_GetString(objv[i])));
-	    Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "MASK", NULL);
-	    return TCL_ERROR;
-	}
-
-	ZeroMemory(bgraMask.ptr, width*height/8);
-
-	/*
-	 * Create an icon from the bitmaps.
-	 */
-
-	hIcon = CreateIconIndirect(&iconInfo);
-	DeleteObject(iconInfo.hbmColor);
-	DeleteObject(iconInfo.hbmMask);
+	hIcon = CreateIcoFromPhoto(width, height, block);
 	if (hIcon == NULL) {
-	    /*
-	     * XXX should free up created icons.
-	     */
-
-	    ckfree(lpIR);
+	    FreeIconBlock(lpIR);
 	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
-		    "failed to create icon for \"%s\"",
+		    "failed to create an iconphoto with image \"%s\"",
 		    Tcl_GetString(objv[i])));
 	    Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "ICON", NULL);
 	    return TCL_ERROR;
 	}
 	lpIR->IconImages[i-startObj].Width = width;
 	lpIR->IconImages[i-startObj].Height = height;
 	lpIR->IconImages[i-startObj].Colors = 4;
 	lpIR->IconImages[i-startObj].hIcon = hIcon;
+	lpIR->nNumImages++;
     }
 
     titlebaricon = (WinIconPtr)ckalloc(sizeof(WinIconInstance));
     titlebaricon->iconBlock = lpIR;
     titlebaricon->refCount = 1;
@@ -4474,10 +4379,12 @@
 	return TCL_ERROR;
     }
     return TCL_OK;
 }
 
+
+
 /*
  *----------------------------------------------------------------------
  *
  * WmIconpositionCmd --
  *
@@ -4493,19 +4400,18 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmIconpositionCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),		/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     int x, y;
-    (void)tkwin;
 
     if ((objc != 3) && (objc != 5)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?");
 	return TCL_ERROR;
     }
@@ -4660,21 +4566,18 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmManageCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel or Frame to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
-    int objc,			/* Number of arguments. */
-    Tcl_Obj *const objv[])	/* Argument objects. */
+    TCL_UNUSED(int),		/* Number of arguments. */
+    TCL_UNUSED(Tcl_Obj *const *)) /* Argument objects. */
 {
     Tk_Window frameWin = (Tk_Window) winPtr;
     WmInfo *wmPtr = winPtr->wmInfoPtr;
-    (void)tkwin;
-    (void)objc;
-    (void)objv;
 
     if (!Tk_IsTopLevel(frameWin)) {
 	if (!Tk_IsManageable(frameWin)) {
 	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 		    "window \"%s\" is not manageable: must be a frame,"
@@ -4717,19 +4620,18 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmMaxsizeCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     int width, height;
-    (void)tkwin;
 
     if ((objc != 3) && (objc != 5)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
 	return TCL_ERROR;
     }
@@ -4769,19 +4671,18 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmMinsizeCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     int width, height;
-    (void)tkwin;
 
     if ((objc != 3) && (objc != 5)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
 	return TCL_ERROR;
     }
@@ -4821,20 +4722,19 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmOverrideredirectCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     int boolean, curValue;
     XSetWindowAttributes atts;
-    (void)tkwin;
 
     if ((objc != 3) && (objc != 4)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?");
 	return TCL_ERROR;
     }
@@ -4894,11 +4794,11 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmPositionfromCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
@@ -4908,11 +4808,10 @@
     };
     enum options {
 	OPT_PROGRAM, OPT_USER
     };
     int index;
-    (void)tkwin;
 
     if ((objc != 3) && (objc != 4)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?");
 	return TCL_ERROR;
     }
@@ -4928,12 +4827,12 @@
 	return TCL_OK;
     }
     if (*Tcl_GetString(objv[3]) == '\0') {
 	wmPtr->sizeHintsFlags &= ~(USPosition|PPosition);
     } else {
-	if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings,
-		sizeof(char *), "argument", 0, &index) != TCL_OK) {
+	if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings,
+		"argument", 0, &index) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 	if (index == OPT_USER) {
 	    wmPtr->sizeHintsFlags &= ~PPosition;
 	    wmPtr->sizeHintsFlags |= USPosition;
@@ -4963,11 +4862,11 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmProtocolCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
@@ -4975,11 +4874,10 @@
     ProtocolHandler *protPtr, *prevPtr;
     Atom protocol;
     const char *cmd;
     TkSizeT cmdLength;
     Tcl_Obj *resultObj;
-    (void)tkwin;
 
     if ((objc < 3) || (objc > 5)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?");
 	return TCL_ERROR;
     }
@@ -5029,11 +4927,11 @@
 	    }
 	    Tcl_EventuallyFree(protPtr, TCL_DYNAMIC);
 	    break;
 	}
     }
-    cmd = TkGetStringFromObj(objv[4], &cmdLength);
+    cmd = Tcl_GetStringFromObj(objv[4], &cmdLength);
     if (cmdLength > 0) {
 	protPtr = (ProtocolHandler *)ckalloc(HANDLER_SIZE(cmdLength));
 	protPtr->protocol = protocol;
 	protPtr->nextPtr = wmPtr->protPtr;
 	wmPtr->protPtr = protPtr;
@@ -5060,19 +4958,18 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmResizableCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     int width, height;
-    (void)tkwin;
 
     if ((objc != 3) && (objc != 5)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
 	return TCL_ERROR;
     }
@@ -5123,11 +5020,11 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmSizefromCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
@@ -5137,11 +5034,10 @@
     };
     enum options {
 	OPT_PROGRAM, OPT_USER
     };
     int index;
-    (void)tkwin;
 
     if ((objc != 3) && (objc != 4)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?");
 	return TCL_ERROR;
     }
@@ -5158,12 +5054,12 @@
     }
 
     if (*Tcl_GetString(objv[3]) == '\0') {
 	wmPtr->sizeHintsFlags &= ~(USSize|PSize);
     } else {
-	if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings,
-		sizeof(char *), "argument", 0, &index) != TCL_OK) {
+	if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings,
+		"argument", 0, &index) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 	if (index == OPT_USER) {
 	    wmPtr->sizeHintsFlags &= ~PSize;
 	    wmPtr->sizeHintsFlags |= USSize;
@@ -5288,12 +5184,12 @@
 	    Tcl_Panic("winPtr2 window not found");
 	}
 
 	ckfree(windows);
 
-	if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings,
-		sizeof(char *), "argument", 0, &index) != TCL_OK) {
+	if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings,
+		"argument", 0, &index) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 	if (index == OPT_ISABOVE) {
 	    result = index1 > index2;
 	} else { /* OPT_ISBELOW */
@@ -5321,25 +5217,24 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmStateCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),		/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     static const char *const optionStrings[] = {
-	"normal", "iconic", "withdrawn", "zoomed", NULL
+	"iconic", "normal", "withdrawn", "zoomed", NULL
     };
     enum options {
-	OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN, OPT_ZOOMED
+	OPT_ICONIC, OPT_NORMAL, OPT_WITHDRAWN, OPT_ZOOMED
     };
     int index;
-    (void)tkwin;
 
     if ((objc < 3) || (objc > 4)) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?state?");
 	return TCL_ERROR;
     }
@@ -5349,12 +5244,12 @@
 		    "can't change state of %s: it is an icon for %s",
 		    Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
 	    Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "ICON", NULL);
 	    return TCL_ERROR;
 	}
-	if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings,
-		sizeof(char *), "argument", 0, &index) != TCL_OK) {
+	if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings,
+		"argument", 0, &index) != TCL_OK) {
 	    return TCL_ERROR;
 	}
 
 	if (winPtr->flags & TK_EMBEDDED) {
 	    int state = 0;
@@ -5462,21 +5357,20 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmTitleCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
     const char *argv3;
     TkSizeT length;
     HWND wrapper;
-    (void)tkwin;
 
     if (objc > 4) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?");
 	return TCL_ERROR;
     }
@@ -5505,11 +5399,11 @@
 	}
     } else {
 	if (wmPtr->title != NULL) {
 	    ckfree(wmPtr->title);
 	}
-	argv3 = TkGetStringFromObj(objv[3], &length);
+	argv3 = Tcl_GetStringFromObj(objv[3], &length);
 	wmPtr->title = (char *)ckalloc(length + 1);
 	memcpy(wmPtr->title, argv3, length + 1);
 
 	if (!(wmPtr->flags & WM_NEVER_MAPPED) && wmPtr->wrapper != NULL) {
 	    Tcl_DString titleString;
@@ -5606,11 +5500,11 @@
 		    Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor)));
 	    Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
 	    return TCL_ERROR;
 	}
 	for (w = containerPtr; w != NULL && w->wmInfoPtr != NULL;
-	     w = (TkWindow *)w->wmInfoPtr->containerPtr) {
+	    w = (TkWindow *)w->wmInfoPtr->containerPtr) {
 	    if (w == winPtr) {
 		Tcl_SetObjResult(interp, Tcl_ObjPrintf(
 		    "can't set \"%s\" as container: would cause management loop",
 		    Tk_PathName(containerPtr)));
 		Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL);
@@ -5668,18 +5562,17 @@
  *----------------------------------------------------------------------
  */
 
 static int
 WmWithdrawCmd(
-    Tk_Window tkwin,		/* Main window of the application. */
+    TCL_UNUSED(Tk_Window),	/* Main window of the application. */
     TkWindow *winPtr,		/* Toplevel to work with */
     Tcl_Interp *interp,		/* Current interpreter. */
     int objc,			/* Number of arguments. */
     Tcl_Obj *const objv[])	/* Argument objects. */
 {
     WmInfo *wmPtr = winPtr->wmInfoPtr;
-    (void)tkwin;
 
     if (objc != 3) {
 	Tcl_WrongNumArgs(interp, 2, objv, "window");
 	return TCL_ERROR;
     }
@@ -5722,11 +5615,11 @@
     }
 }
 
 static void
 WmWaitVisibilityOrMapProc(
-    ClientData clientData,	/* Pointer to window. */
+    void *clientData,	/* Pointer to window. */
     XEvent *eventPtr)		/* Information about event. */
 {
     TkWindow *winPtr = (TkWindow *)clientData;
     TkWindow *containerPtr = winPtr->wmInfoPtr->containerPtr;
 
@@ -5939,11 +5832,11 @@
  *----------------------------------------------------------------------
  */
 
 static void
 TopLevelEventProc(
-    ClientData clientData,	/* Window for which event occurred. */
+    void *clientData,	/* Window for which event occurred. */
     XEvent *eventPtr)		/* Event that just happened. */
 {
     TkWindow *winPtr = (TkWindow *)clientData;
 
     if (eventPtr->type == DestroyNotify) {
@@ -5984,16 +5877,15 @@
  *----------------------------------------------------------------------
  */
 
 static void
 TopLevelReqProc(
-    ClientData dummy,		/* Not used. */
+    TCL_UNUSED(void *),		/* Not used. */
     Tk_Window tkwin)		/* Information about window. */
 {
     TkWindow *winPtr = (TkWindow *) tkwin;
     WmInfo *wmPtr;
-    (void)dummy;
 
     wmPtr = winPtr->wmInfoPtr;
     if (wmPtr) {
 	if ((winPtr->flags & TK_EMBEDDED) && (wmPtr->wrapper != NULL)) {
 	    SendMessageW(wmPtr->wrapper, TK_GEOMETRYREQ, Tk_ReqWidth(tkwin),
@@ -6027,11 +5919,11 @@
  *----------------------------------------------------------------------
  */
 
 static void
 UpdateGeometryInfo(
-    ClientData clientData)	/* Pointer to the window's record. */
+    void *clientData)	/* Pointer to the window's record. */
 {
     int x, y;			/* Position of border on desktop. */
     int width, height;		/* Size of client area. */
     int min, max;
     RECT rect;
@@ -6536,19 +6428,17 @@
  *----------------------------------------------------------------------
  */
 
 void
 Tk_GetVRootGeometry(
-    Tk_Window tkwin,		/* Window whose virtual root is to be
+    TCL_UNUSED(Tk_Window),/* Window whose virtual root is to be
 				 * queried. */
     int *xPtr, int *yPtr,	/* Store x and y offsets of virtual root
 				 * here. */
     int *widthPtr, int *heightPtr)
 				/* Store dimensions of virtual root here. */
 {
-    (void)tkwin;
-
     *xPtr = GetSystemMetrics(SM_XVIRTUALSCREEN);
     *yPtr = GetSystemMetrics(SM_YVIRTUALSCREEN);
     *widthPtr = GetSystemMetrics(SM_CXVIRTUALSCREEN);
     *heightPtr = GetSystemMetrics(SM_CYVIRTUALSCREEN);
 }
@@ -8327,11 +8217,11 @@
     }
 
     /*
      * If the toplevel is in the middle of a move or size operation then
      * we must delay handling of this event to avoid stealing the focus
-     * while the window manage is in control.
+     * while the window manager is in control.
      */
 
     if (eventPtr->flagPtr && *eventPtr->flagPtr) {
 	return 0;
     }
@@ -8395,11 +8285,11 @@
 /*
  *----------------------------------------------------------------------
  *
  * TkpWinToplevelWithdraw --
  *
- *	This function is to be used by a window manage to withdraw a toplevel
+ *	This function is to be used by a window manager to withdraw a toplevel
  *	window.
  *
  * Results:
  *	none
  *
@@ -8422,11 +8312,11 @@
 /*
  *----------------------------------------------------------------------
  *
  * TkpWinToplevelIconify --
  *
- *	This function is to be used by a window manage to iconify a toplevel
+ *	This function is to be used by a window manager to iconify a toplevel
  *	window.
  *
  * Results:
  *	none
  *
@@ -8446,11 +8336,11 @@
 /*
  *----------------------------------------------------------------------
  *
  * TkpWinToplevelDeiconify --
  *
- *	This function is to be used by a window manage to deiconify a toplevel
+ *	This function is to be used by a window manager to deiconify a toplevel
  *	window.
  *
  * Results:
  *	none
  *
@@ -8513,11 +8403,11 @@
 /*
  *----------------------------------------------------------------------
  *
  * TkpWinGeometryIsControlledByWm --
  *
- *	This function is to be used by a window manage to see if wm has
+ *	This function is to be used by a window manager to see if wm has
  *	canceled geometry control.
  *
  * Results:
  *	0 - if the window manager has canceled its control
  *	1 - if the window manager controls the geometry

Index: win/tkWinX.c
==================================================================
--- win/tkWinX.c
+++ win/tkWinX.c
@@ -1,13 +1,13 @@
 /*
  * tkWinX.c --
  *
  *	This file contains Windows emulation procedures for X routines.
  *
- * Copyright (c) 1995-1996 Sun Microsystems, Inc.
- * Copyright (c) 1994 Software Research Associates, Inc.
- * Copyright (c) 1998-2000 by Scriptics Corporation.
+ * Copyright © 1995-1996 Sun Microsystems, Inc.
+ * Copyright © 1994 Software Research Associates, Inc.
+ * Copyright © 1998-2000 Scriptics Corporation.
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
@@ -78,14 +78,13 @@
 typedef struct {
     TkDisplay *winDisplay;	/* TkDisplay structure that represents Windows
 				 * screen. */
     int updatingClipboard;	/* If 1, we are updating the clipboard. */
     int surrogateBuffer;	/* Buffer for first of surrogate pair. */
-    DWORD vWheelTickPrev;	/* For high resolution wheels (vertical). */
-    DWORD hWheelTickPrev;	/* For high resolution wheels (horizontal). */
-    short vWheelAcc;		/* For high resolution wheels (vertical). */
-    short hWheelAcc;		/* For high resolution wheels (horizontal). */
+    DWORD wheelTickPrev;	/* For high resolution wheels. */
+    int vWheelAcc;		/* For high resolution wheels (vertical). */
+    int hWheelAcc;		/* For high resolution wheels (horizontal). */
 } ThreadSpecificData;
 static Tcl_ThreadDataKey dataKey;
 
 /*
  * Forward declarations of functions used in this file.
@@ -126,17 +125,11 @@
     static char buffer[32]; /* Empty string means not initialized yet. */
     OSVERSIONINFOW os;
     (void)tkwin;
 
     if (!buffer[0]) {
-	HMODULE handle = GetModuleHandleW(L"NTDLL");
-	int(__stdcall *getversion)(void *) = (int(__stdcall *)(void *))
-		(void *)GetProcAddress(handle, "RtlGetVersion");
-	os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
-	if (!getversion || getversion(&os)) {
-	    GetVersionExW(&os);
-	}
+	GetVersionExW(&os);
 	/* Write the first character last, preventing multi-thread issues. */
 	sprintf(buffer+1, "indows %d.%d %d %s", (int)os.dwMajorVersion,
 		(int)os.dwMinorVersion, (int)os.dwBuildNumber,
 #ifdef _WIN64
 		"Win64"
@@ -525,11 +518,10 @@
     const char *display_name)
 {
     Display *display;
     ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
-    DWORD initialWheelTick;
 
     if (tsdPtr->winDisplay != NULL) {
 	if (!strcmp(tsdPtr->winDisplay->display->display_name, display_name)) {
 	    return tsdPtr->winDisplay;
 	} else {
@@ -542,13 +534,11 @@
 
     tsdPtr->winDisplay =(TkDisplay *) ckalloc(sizeof(TkDisplay));
     ZeroMemory(tsdPtr->winDisplay, sizeof(TkDisplay));
     tsdPtr->winDisplay->display = display;
     tsdPtr->updatingClipboard = FALSE;
-    initialWheelTick = GetTickCount();
-    tsdPtr->vWheelTickPrev = initialWheelTick;
-    tsdPtr->hWheelTickPrev = initialWheelTick;
+    tsdPtr->wheelTickPrev = GetTickCount();
     tsdPtr->vWheelAcc = 0;
     tsdPtr->hWheelAcc = 0;
 
     /*
      * Key map info must be available immediately, because of "send event".
@@ -1145,18 +1135,19 @@
 	    /*
 	     * Support for high resolution wheels (vertical).
 	     */
 
 	    DWORD wheelTick = GetTickCount();
-
-	    if (wheelTick - tsdPtr->vWheelTickPrev < 1500) {
-		tsdPtr->vWheelAcc += (short) HIWORD(wParam);
-	    } else {
-		tsdPtr->vWheelAcc = (short) HIWORD(wParam);
-	    }
-	    tsdPtr->vWheelTickPrev = wheelTick;
-	    if (abs(tsdPtr->vWheelAcc) < WHEEL_DELTA) {
+	    BOOL timeout = wheelTick - tsdPtr->wheelTickPrev >= 300;
+	    int intDelta;
+
+	    tsdPtr->wheelTickPrev = wheelTick;
+	    if (timeout) {
+		tsdPtr->vWheelAcc = tsdPtr->hWheelAcc = 0;
+	    }
+	    tsdPtr->vWheelAcc += (short) HIWORD(wParam);
+	    if (!tsdPtr->vWheelAcc || (!timeout && abs(tsdPtr->vWheelAcc) < WHEEL_DELTA * 6 / 10)) {
 		return;
 	    }
 
 	    /*
 	     * We have invented a new X event type to handle this event. It
@@ -1164,31 +1155,38 @@
 	     * been overloaded to hold the zDelta of the wheel. Set nbytes to
 	     * 0 to prevent conversion of the keycode to a keysym in
 	     * TkpGetString. [Bug 1118340].
 	     */
 
+	    intDelta = (abs(tsdPtr->vWheelAcc) + WHEEL_DELTA/2) / WHEEL_DELTA * WHEEL_DELTA;
+	    if (intDelta == 0) {
+		intDelta = (tsdPtr->vWheelAcc < 0) ? -WHEEL_DELTA : WHEEL_DELTA;
+	    } else if (tsdPtr->vWheelAcc < 0) {
+		intDelta = -intDelta;
+	    }
 	    event.x.type = MouseWheelEvent;
 	    event.x.xany.send_event = -1;
 	    event.key.nbytes = 0;
-	    event.x.xkey.keycode = tsdPtr->vWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
-	    tsdPtr->vWheelAcc = tsdPtr->vWheelAcc % WHEEL_DELTA;
+	    event.x.xkey.keycode = intDelta;
+	    tsdPtr->vWheelAcc -= intDelta;
 	    break;
 	}
 	case WM_MOUSEHWHEEL: {
 	    /*
 	     * Support for high resolution wheels (horizontal).
 	     */
 
 	    DWORD wheelTick = GetTickCount();
-
-	    if (wheelTick - tsdPtr->hWheelTickPrev < 1500) {
-		tsdPtr->hWheelAcc -= (short) HIWORD(wParam);
-	    } else {
-		tsdPtr->hWheelAcc = -((short) HIWORD(wParam));
-	    }
-	    tsdPtr->hWheelTickPrev = wheelTick;
-	    if (abs(tsdPtr->hWheelAcc) < WHEEL_DELTA) {
+	    BOOL timeout = wheelTick - tsdPtr->wheelTickPrev >= 300;
+	    int intDelta;
+
+	    tsdPtr->wheelTickPrev = wheelTick;
+	    if (timeout) {
+		tsdPtr->vWheelAcc = tsdPtr->hWheelAcc = 0;
+	    }
+	    tsdPtr->hWheelAcc -= (short) HIWORD(wParam);
+	    if (!tsdPtr->hWheelAcc || (!timeout && abs(tsdPtr->hWheelAcc) < WHEEL_DELTA * 6 / 10)) {
 		return;
 	    }
 
 	    /*
 	     * We have invented a new X event type to handle this event. It
@@ -1196,16 +1194,22 @@
 	     * been overloaded to hold the zDelta of the wheel. Set nbytes to
 	     * 0 to prevent conversion of the keycode to a keysym in
 	     * TkpGetString. [Bug 1118340].
 	     */
 
+	    intDelta =  (abs(tsdPtr->hWheelAcc) + WHEEL_DELTA/2) / WHEEL_DELTA * WHEEL_DELTA;
+	    if (intDelta == 0) {
+		intDelta = (tsdPtr->hWheelAcc < 0) ? -WHEEL_DELTA : WHEEL_DELTA;
+	    } else if (tsdPtr->hWheelAcc < 0) {
+		intDelta = -intDelta;
+	    }
 	    event.x.type = MouseWheelEvent;
 	    event.x.xany.send_event = -1;
 	    event.key.nbytes = 0;
 	    event.x.xkey.state |= ShiftMask;
-	    event.x.xkey.keycode = tsdPtr->hWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
-	    tsdPtr->hWheelAcc = tsdPtr->hWheelAcc % WHEEL_DELTA;
+	    event.x.xkey.keycode = intDelta;
+	    tsdPtr->hWheelAcc -= intDelta;
 	    break;
 	}
 	case WM_SYSKEYDOWN:
 	case WM_KEYDOWN:
 	    /*
@@ -1439,11 +1443,11 @@
 {
     MSG msg;
 
     xkey->nbytes = 0;
 
-    while ((xkey->nbytes < XMaxTransChars)
+    while ((xkey->nbytes < sizeof(xkey->trans_chars))
 	    && (PeekMessageA(&msg, NULL, type, type, PM_NOREMOVE) != 0)) {
 	if (msg.message != type) {
 	    break;
 	}
 

Index: win/ttkWinMonitor.c
==================================================================
--- win/ttkWinMonitor.c
+++ win/ttkWinMonitor.c
@@ -1,10 +1,10 @@
 #ifdef _MSC_VER
 #define WIN32_LEAN_AND_MEAN
 #endif
 
-#include <tkWinInt.h>
+#include "tkWinInt.h"
 #include "ttk/ttkTheme.h"
 
 #if !defined(WM_THEMECHANGED)
 #define WM_THEMECHANGED 0x031A
 #endif

Index: win/ttkWinTheme.c
==================================================================
--- win/ttkWinTheme.c
+++ win/ttkWinTheme.c
@@ -1,13 +1,13 @@
-/* winTheme.c - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sf.net>
+/* winTheme.c - Copyright © 2004 Pat Thoyts <patthoyts@users.sf.net>
  */
 
 #ifdef _MSC_VER
 #define WIN32_LEAN_AND_MEAN
 #endif
 
-#include <tkWinInt.h>
+#include "tkWinInt.h"
 
 #ifndef DFCS_HOT	/* Windows 98/Me, Windows 2000/XP only */
 #define DFCS_HOT 0
 #endif
 

Index: win/ttkWinXPTheme.c
==================================================================
--- win/ttkWinXPTheme.c
+++ win/ttkWinXPTheme.c
@@ -1,12 +1,12 @@
 /*
  * Tk theme engine which uses the Windows XP "Visual Styles" API
  * Adapted from Georgios Petasis' XP theme patch.
  *
- * Copyright (c) 2003 by Georgios Petasis, petasis@iit.demokritos.gr.
- * Copyright (c) 2003 by Joe English
- * Copyright (c) 2003 by Pat Thoyts
+ * Copyright © 2003 Georgios Petasis, petasis@iit.demokritos.gr.
+ * Copyright © 2003 Joe English
+ * Copyright © 2003 Pat Thoyts
  *
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
  * See also:
@@ -13,11 +13,11 @@
  *
  * <URL: http://msdn.microsoft.com/library/en-us/
  *  	shellcc/platform/commctls/userex/refentry.asp >
  */
 
-#include <tkWinInt.h>
+#include "tkWinInt.h"
 #ifndef HAVE_UXTHEME_H
 /* Stub for platforms that lack the XP theme API headers: */
 int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd) { return TCL_OK; }
 #else
 
@@ -836,20 +836,20 @@
     Tcl_DString ds;
 
     if (!InitElementData(elementData, tkwin, 0))
 	return;
 
-    src = TkGetStringFromObj(element->textObj, &len);
+    src = Tcl_GetStringFromObj(element->textObj, &len);
     Tcl_DStringInit(&ds);
     hr = elementData->procs->GetThemeTextExtent(
 	    elementData->hTheme,
 	    elementData->hDC,
 	    elementData->info->partId,
 	    Ttk_StateTableLookup(elementData->info->statemap, 0),
 	    Tcl_UtfToWCharDString(src, len, &ds),
 	    -1,
-	    DT_LEFT,// | DT_BOTTOM | DT_NOPREFIX,
+	    DT_LEFT /* | DT_BOTTOM | DT_NOPREFIX */,
 	    NULL,
 	    &rc);
 
     if (SUCCEEDED(hr)) {
 	*widthPtr = rc.right - rc.left;
@@ -875,20 +875,20 @@
     Tcl_DString ds;
 
     if (!InitElementData(elementData, tkwin, d))
 	return;
 
-    src = TkGetStringFromObj(element->textObj, &len);
+    src = Tcl_GetStringFromObj(element->textObj, &len);
     Tcl_DStringInit(&ds);
     hr = elementData->procs->DrawThemeText(
 	    elementData->hTheme,
 	    elementData->hDC,
 	    elementData->info->partId,
 	    Ttk_StateTableLookup(elementData->info->statemap, state),
 	    Tcl_UtfToWCharDString(src, len, &ds),
 	    -1,
-	    DT_LEFT,// | DT_BOTTOM | DT_NOPREFIX,
+	    DT_LEFT /* | DT_BOTTOM | DT_NOPREFIX */,
 	    (state & TTK_STATE_DISABLED) ? DTT_GRAYED : 0,
 	    &rc);
 
     Tcl_DStringFree(&ds);
     FreeElementData(elementData);
@@ -1125,14 +1125,14 @@
     LPWSTR wname;
     const Ttk_ElementSpec *elementSpec = &GenericElementSpec;
     Tcl_DString classBuf;
 
     static const char *const optionStrings[] =
-	{ "-padding","-width","-height","-margins", "-syssize",
-	  "-halfheight", "-halfwidth", NULL };
-    enum { O_PADDING, O_WIDTH, O_HEIGHT, O_MARGINS, O_SYSSIZE,
-	   O_HALFHEIGHT, O_HALFWIDTH };
+	{ "-halfheight", "-halfwidth", "-height", "-margins", "-padding",
+	  "-syssize", "-width", NULL };
+    enum { O_HALFHEIGHT, O_HALFWIDTH, O_HEIGHT, O_MARGINS, O_PADDING,
+	   O_SYSSIZE, O_WIDTH };
 
     if (objc < 2) {
 	Tcl_SetObjResult(interp, Tcl_NewStringObj(
 	    "missing required arguments 'class' and/or 'partId'", -1));
 	Tcl_SetErrorCode(interp, "TTK", "VSAPI", "REQUIRED", NULL);
@@ -1140,11 +1140,11 @@
     }
 
     if (Tcl_GetIntFromObj(interp, objv[1], &partId) != TCL_OK) {
 	return TCL_ERROR;
     }
-    name = TkGetStringFromObj(objv[0], &length);
+    name = Tcl_GetStringFromObj(objv[0], &length);
     Tcl_DStringInit(&classBuf);
     className = Tcl_UtfToWCharDString(name, length, &classBuf);
 
     /* flags or padding */
     if (objc > 3) {
@@ -1156,12 +1156,12 @@
 			"Missing value for \"%s\".",
 			Tcl_GetString(objv[i])));
 		Tcl_SetErrorCode(interp, "TTK", "VSAPI", "MISSING", NULL);
 		goto retErr;
 	    }
-	    if (Tcl_GetIndexFromObjStruct(interp, objv[i], optionStrings,
-		    sizeof(char *), "option", 0, &option) != TCL_OK)
+	    if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings,
+		    "option", 0, &option) != TCL_OK)
 		goto retErr;
 	    switch (option) {
 	    case O_PADDING:
 		if (Ttk_GetBorderFromObj(interp, objv[i+1], &pad) != TCL_OK) {
 		    goto retErr;

Index: win/winMain.c
==================================================================
--- win/winMain.c
+++ win/winMain.c
@@ -17,31 +17,44 @@
 #include <windows.h>
 #undef WIN32_LEAN_AND_MEAN
 #include <locale.h>
 #include <stdlib.h>
 #include <tchar.h>
+#if TCL_MAJOR_VERSION < 9 && TCL_MINOR_VERSION < 7
+#   define Tcl_LibraryInitProc Tcl_PackageInitProc
+#   define Tcl_StaticLibrary Tcl_StaticPackage
+#endif
 
 #if defined(__GNUC__)
 int _CRT_glob = 0;
 #endif /* __GNUC__ */
 
-#ifdef TK_TEST
 #ifdef __cplusplus
 extern "C" {
 #endif
-extern Tcl_PackageInitProc Tktest_Init;
+
+#ifdef TK_TEST
+extern Tcl_LibraryInitProc Tktest_Init;
+#endif /* TK_TEST */
+
+#if !defined(TCL_USE_STATIC_PACKAGES)
+#   if TCL_MAJOR_VERSION > 8 || TCL_MINOR_VERSION > 6
+#	define TCL_USE_STATIC_PACKAGES 1
+#   else
+#	define TCL_USE_STATIC_PACKAGES 0
+#   endif
+#endif
+
+#if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES
+extern Tcl_LibraryInitProc Registry_Init;
+extern Tcl_LibraryInitProc Dde_Init;
+extern Tcl_LibraryInitProc Dde_SafeInit;
+#endif
+
 #ifdef __cplusplus
 }
 #endif
-#endif /* TK_TEST */
-
-#if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES
-extern Tcl_PackageInitProc Registry_Init;
-extern Tcl_PackageInitProc Dde_Init;
-extern Tcl_PackageInitProc Dde_SafeInit;
-#endif
-
 #ifdef TCL_BROKEN_MAINARGS
 static void setargv(int *argcPtr, TCHAR ***argvPtr);
 #endif
 
 /*
@@ -58,11 +71,15 @@
 
 #ifndef TK_LOCAL_APPINIT
 #define TK_LOCAL_APPINIT Tcl_AppInit
 #endif
 #ifndef MODULE_SCOPE
-#   define MODULE_SCOPE extern
+#   ifdef __cplusplus
+#	define MODULE_SCOPE extern "C"
+#   else
+#	define MODULE_SCOPE extern
+#   endif
 #endif
 MODULE_SCOPE int TK_LOCAL_APPINIT(Tcl_Interp *interp);
 
 /*
  * The following #if block allows you to change how Tcl finds the startup
@@ -188,14 +205,25 @@
     Tcl_Interp *interp)		/* Interpreter for application. */
 {
     if ((Tcl_Init)(interp) == TCL_ERROR) {
 	return TCL_ERROR;
     }
+#if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES
+    if (Registry_Init(interp) == TCL_ERROR) {
+	return TCL_ERROR;
+    }
+    Tcl_StaticLibrary(interp, "Registry", Registry_Init, 0);
+
+    if (Dde_Init(interp) == TCL_ERROR) {
+	return TCL_ERROR;
+    }
+    Tcl_StaticLibrary(interp, "Dde", Dde_Init, Dde_SafeInit);
+#endif
     if (Tk_Init(interp) == TCL_ERROR) {
 	return TCL_ERROR;
     }
-    Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);
+    Tcl_StaticLibrary(interp, "Tk", Tk_Init, Tk_SafeInit);
 
     /*
      * Initialize the console only if we are running as an interactive
      * application.
      */
@@ -203,27 +231,15 @@
     if (consoleRequired) {
 	if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) {
 	    return TCL_ERROR;
 	}
     }
-#if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES
-    if (Registry_Init(interp) == TCL_ERROR) {
-	return TCL_ERROR;
-    }
-    Tcl_StaticPackage(interp, "registry", Registry_Init, 0);
-
-    if (Dde_Init(interp) == TCL_ERROR) {
-	return TCL_ERROR;
-    }
-    Tcl_StaticPackage(interp, "dde", Dde_Init, Dde_SafeInit);
-#endif
-
 #ifdef TK_TEST
     if (Tktest_Init(interp) == TCL_ERROR) {
 	return TCL_ERROR;
     }
-    Tcl_StaticPackage(interp, "Tktest", Tktest_Init, 0);
+    Tcl_StaticLibrary(interp, "Tktest", Tktest_Init, 0);
 #endif /* TK_TEST */
 
     /*
      * Call the init procedures for included packages. Each call should look
      * like this:

Index: win/wish.exe.manifest.in
==================================================================
--- win/wish.exe.manifest.in
+++ win/wish.exe.manifest.in
@@ -26,19 +26,21 @@
 	    <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
 	    <!-- Windows 8 -->
 	    <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
 	    <!-- Windows 7 -->
 	    <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
-	    <!-- Windows Vista -->
-	    <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
 	</application>
     </compatibility>
     <asmv3:application>
 	<asmv3:windowsSettings
 		xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
 	    <dpiAware>true</dpiAware>
 	</asmv3:windowsSettings>
+	<asmv3:windowsSettings
+		xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">
+	    <activeCodePage>UTF-8</activeCodePage>
+	</asmv3:windowsSettings>
     </asmv3:application>
     <dependency>
 	<dependentAssembly>
 	    <assemblyIdentity
 		    type="win32"

ADDED   win/x86_64-w64-mingw32-nmakehlp.exe
Index: win/x86_64-w64-mingw32-nmakehlp.exe
==================================================================
--- /dev/null
+++ win/x86_64-w64-mingw32-nmakehlp.exe
cannot compute difference between binary files

Index: xlib/X11/HPkeysym.h
==================================================================
--- xlib/X11/HPkeysym.h
+++ xlib/X11/HPkeysym.h
@@ -44,11 +44,11 @@
 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 SOFTWARE.
 
 HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD
-TO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+TO THIS SOFTWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 PURPOSE.  Hewlett-Packard shall not be liable for errors
 contained herein or direct, indirect, special, incidental or
 consequential damages in connection with the furnishing,
 performance, or use of this material.

Index: xlib/X11/XF86keysym.h
==================================================================
--- xlib/X11/XF86keysym.h
+++ xlib/X11/XF86keysym.h
@@ -1,12 +1,14 @@
 /*
  * XFree86 vendor specific keysyms.
  *
  * The XFree86 keysym range is 0x10080001 - 0x1008FFFF.
  *
- * X.Org will not be adding to the XF86 set of keysyms, though they have
- * been adopted and are considered a "standard" part of X keysym definitions.
+ * The XF86 set of keysyms is a catch-all set of defines for keysyms found
+ * on various multimedia keyboards. Originally specific to XFree86 they have
+ * been been adopted over time and are considered a "standard" part of X
+ * keysym definitions.
  * XFree86 never properly commented these keysyms, so we have done our
  * best to explain the semantic meaning of these keys.
  *
  * XFree86 has removed their mail archives of the period, that might have
  * shed more light on some of these definitions. Until/unless we resurrect
@@ -205,10 +207,12 @@
 
 #define XF86XK_AudioPreset	0x1008FFB6   /* Select equalizer preset, e.g. theatre-mode */
 
 #define XF86XK_RotationLockToggle 0x1008FFB7 /* Toggle screen rotation lock on/off */
 
+#define XF86XK_FullScreen	0x1008FFB8   /* Toggle fullscreen */
+
 /* Keys for special action keys (hot keys) */
 /* Virtual terminals on some operating systems */
 #define XF86XK_Switch_VT_1	0x1008FE01
 #define XF86XK_Switch_VT_2	0x1008FE02
 #define XF86XK_Switch_VT_3	0x1008FE03
@@ -226,5 +230,240 @@
 #define XF86XK_ClearGrab	0x1008FE21   /* kill application with grab */
 #define XF86XK_Next_VMode	0x1008FE22   /* next video mode available  */
 #define XF86XK_Prev_VMode	0x1008FE23   /* prev. video mode available */
 #define XF86XK_LogWindowTree	0x1008FE24   /* print window tree to log   */
 #define XF86XK_LogGrabInfo	0x1008FE25   /* print all active grabs to log */
+
+
+/*
+ * Reserved range for evdev symbols: 0x10081000-0x10081FFF
+ *
+ * Key syms within this range must match the Linux kernel
+ * input-event-codes.h file in the format:
+ *     XF86XK_CamelCaseKernelName	_EVDEVK(kernel value)
+ * For example, the kernel
+ *   #define KEY_MACRO_RECORD_START	0x2b0
+ * effectively ends up as:
+ *   #define XF86XK_MacroRecordStart	0x100812b0
+ *
+ * For historical reasons, some keysyms within the reserved range will be
+ * missing, most notably all "normal" keys that are mapped through default
+ * XKB layouts (e.g. KEY_Q).
+ *
+ * CamelCasing is done with a human control as last authority, e.g. see VOD
+ * instead of Vod for the Video on Demand key.
+ *
+ * The format for #defines is strict:
+ *
+ * #define XF86XK_FOO<tab...>_EVDEVK(0xABC)<tab><tab> |* kver KEY_FOO *|
+ *
+ * Where
+ * - alignment by tabs
+ * - the _EVDEVK macro must be used
+ * - the hex code must be in uppercase hex
+ * - the kernel version (kver) is in the form v5.10
+ * - kver and key name are within a slash-star comment (a pipe is used in
+ *   this example for technical reasons)
+ * These #defines are parsed by scripts. Do not stray from the given format.
+ *
+ * Where the evdev keycode is mapped to a different symbol, please add a
+ * comment line starting with Use: but otherwise the same format, e.g.
+ *  Use: XF86XK_RotationLockToggle	_EVDEVK(0x231)		   v4.16 KEY_ROTATE_LOCK_TOGGLE
+ *
+ */
+#define _EVDEVK(_v) (0x10081000 + _v)
+/* Use: XF86XK_Eject			_EVDEVK(0x0A2)		         KEY_EJECTCLOSECD */
+/* Use: XF86XK_New			_EVDEVK(0x0B5)		   v2.6.14 KEY_NEW */
+/* Use: XK_Redo				_EVDEVK(0x0B6)		   v2.6.14 KEY_REDO */
+/* KEY_DASHBOARD has been mapped to LaunchB in xkeyboard-config since 2011 */
+/* Use: XF86XK_LaunchB			_EVDEVK(0x0CC)		   v2.6.28 KEY_DASHBOARD */
+/* Use: XF86XK_Display			_EVDEVK(0x0E3)		   v2.6.12 KEY_SWITCHVIDEOMODE */
+/* Use: XF86XK_KbdLightOnOff		_EVDEVK(0x0E4)		   v2.6.12 KEY_KBDILLUMTOGGLE */
+/* Use: XF86XK_KbdBrightnessDown	_EVDEVK(0x0E5)		   v2.6.12 KEY_KBDILLUMDOWN */
+/* Use: XF86XK_KbdBrightnessUp		_EVDEVK(0x0E6)		   v2.6.12 KEY_KBDILLUMUP */
+/* Use: XF86XK_Send			_EVDEVK(0x0E7)		   v2.6.14 KEY_SEND */
+/* Use: XF86XK_Reply			_EVDEVK(0x0E8)		   v2.6.14 KEY_REPLY */
+/* Use: XF86XK_MailForward		_EVDEVK(0x0E9)		   v2.6.14 KEY_FORWARDMAIL */
+/* Use: XF86XK_Save			_EVDEVK(0x0EA)		   v2.6.14 KEY_SAVE */
+/* Use: XF86XK_Documents		_EVDEVK(0x0EB)		   v2.6.14 KEY_DOCUMENTS */
+/* Use: XF86XK_Battery			_EVDEVK(0x0EC)		   v2.6.17 KEY_BATTERY */
+/* Use: XF86XK_Bluetooth		_EVDEVK(0x0ED)		   v2.6.19 KEY_BLUETOOTH */
+/* Use: XF86XK_WLAN			_EVDEVK(0x0EE)		   v2.6.19 KEY_WLAN */
+/* Use: XF86XK_UWB			_EVDEVK(0x0EF)		   v2.6.24 KEY_UWB */
+/* Use: XF86XK_Next_VMode		_EVDEVK(0x0F1)		   v2.6.23 KEY_VIDEO_NEXT */
+/* Use: XF86XK_Prev_VMode		_EVDEVK(0x0F2)		   v2.6.23 KEY_VIDEO_PREV */
+/* Use: XF86XK_MonBrightnessCycle	_EVDEVK(0x0F3)		   v2.6.23 KEY_BRIGHTNESS_CYCLE */
+#define XF86XK_BrightnessAuto		_EVDEVK(0x0F4)		/* v3.16 KEY_BRIGHTNESS_AUTO */
+#define XF86XK_DisplayOff		_EVDEVK(0x0F5)		/* v2.6.23 KEY_DISPLAY_OFF */
+/* Use: XF86XK_WWAN			_EVDEVK(0x0F6)		   v3.13 KEY_WWAN */
+/* Use: XF86XK_RFKill			_EVDEVK(0x0F7)		   v2.6.33 KEY_RFKILL */
+/* Use: XF86XK_AudioMicMute		_EVDEVK(0x0F8)		   v3.1  KEY_MICMUTE */
+#define XF86XK_Info			_EVDEVK(0x166)		/*       KEY_INFO */
+/* Use: XF86XK_CycleAngle		_EVDEVK(0x173)		         KEY_ANGLE */
+/* Use: XF86XK_FullScreen		_EVDEVK(0x174)		   v5.1  KEY_FULL_SCREEN */
+#define XF86XK_AspectRatio		_EVDEVK(0x177)		/* v5.1  KEY_ASPECT_RATIO */
+#define XF86XK_DVD			_EVDEVK(0x185)		/*       KEY_DVD */
+#define XF86XK_Audio			_EVDEVK(0x188)		/*       KEY_AUDIO */
+/* Use: XF86XK_Video			_EVDEVK(0x189)		         KEY_VIDEO */
+/* Use: XF86XK_Calendar			_EVDEVK(0x18D)		         KEY_CALENDAR */
+#define XF86XK_ChannelUp		_EVDEVK(0x192)		/*       KEY_CHANNELUP */
+#define XF86XK_ChannelDown		_EVDEVK(0x193)		/*       KEY_CHANNELDOWN */
+/* Use: XF86XK_AudioRandomPlay		_EVDEVK(0x19A)		         KEY_SHUFFLE */
+#define XF86XK_Break			_EVDEVK(0x19B)		/*       KEY_BREAK */
+#define XF86XK_VideoPhone		_EVDEVK(0x1A0)		/* v2.6.20 KEY_VIDEOPHONE */
+/* Use: XF86XK_Game			_EVDEVK(0x1A1)		   v2.6.20 KEY_GAMES */
+/* Use: XF86XK_ZoomIn			_EVDEVK(0x1A2)		   v2.6.20 KEY_ZOOMIN */
+/* Use: XF86XK_ZoomOut			_EVDEVK(0x1A3)		   v2.6.20 KEY_ZOOMOUT */
+#define XF86XK_ZoomReset		_EVDEVK(0x1A4)		/* v2.6.20 KEY_ZOOMRESET */
+/* Use: XF86XK_Word			_EVDEVK(0x1A5)		   v2.6.20 KEY_WORDPROCESSOR */
+#define XF86XK_Editor			_EVDEVK(0x1A6)		/* v2.6.20 KEY_EDITOR */
+/* Use: XF86XK_Excel			_EVDEVK(0x1A7)		   v2.6.20 KEY_SPREADSHEET */
+#define XF86XK_GraphicsEditor		_EVDEVK(0x1A8)		/* v2.6.20 KEY_GRAPHICSEDITOR */
+#define XF86XK_Presentation		_EVDEVK(0x1A9)		/* v2.6.20 KEY_PRESENTATION */
+#define XF86XK_Database			_EVDEVK(0x1AA)		/* v2.6.20 KEY_DATABASE */
+/* Use: XF86XK_News			_EVDEVK(0x1AB)		   v2.6.20 KEY_NEWS */
+#define XF86XK_Voicemail		_EVDEVK(0x1AC)		/* v2.6.20 KEY_VOICEMAIL */
+#define XF86XK_Addressbook		_EVDEVK(0x1AD)		/* v2.6.20 KEY_ADDRESSBOOK */
+/* Use: XF86XK_Messenger		_EVDEVK(0x1AE)		   v2.6.20 KEY_MESSENGER */
+#define XF86XK_DisplayToggle		_EVDEVK(0x1AF)		/* v2.6.20 KEY_DISPLAYTOGGLE */
+#define XF86XK_SpellCheck		_EVDEVK(0x1B0)		/* v2.6.24 KEY_SPELLCHECK */
+/* Use: XF86XK_LogOff			_EVDEVK(0x1B1)		   v2.6.24 KEY_LOGOFF */
+/* Use: XK_dollar			_EVDEVK(0x1B2)		   v2.6.24 KEY_DOLLAR */
+/* Use: XK_EuroSign			_EVDEVK(0x1B3)		   v2.6.24 KEY_EURO */
+/* Use: XF86XK_FrameBack		_EVDEVK(0x1B4)		   v2.6.24 KEY_FRAMEBACK */
+/* Use: XF86XK_FrameForward		_EVDEVK(0x1B5)		   v2.6.24 KEY_FRAMEFORWARD */
+#define XF86XK_ContextMenu		_EVDEVK(0x1B6)		/* v2.6.24 KEY_CONTEXT_MENU */
+#define XF86XK_MediaRepeat		_EVDEVK(0x1B7)		/* v2.6.26 KEY_MEDIA_REPEAT */
+#define XF86XK_10ChannelsUp		_EVDEVK(0x1B8)		/* v2.6.38 KEY_10CHANNELSUP */
+#define XF86XK_10ChannelsDown		_EVDEVK(0x1B9)		/* v2.6.38 KEY_10CHANNELSDOWN */
+#define XF86XK_Images			_EVDEVK(0x1BA)		/* v2.6.39 KEY_IMAGES */
+#define XF86XK_NotificationCenter	_EVDEVK(0x1BC)		/* v5.10 KEY_NOTIFICATION_CENTER */
+#define XF86XK_PickupPhone		_EVDEVK(0x1BD)		/* v5.10 KEY_PICKUP_PHONE */
+#define XF86XK_HangupPhone		_EVDEVK(0x1BE)		/* v5.10 KEY_HANGUP_PHONE */
+#define XF86XK_Fn			_EVDEVK(0x1D0)		/*       KEY_FN */
+#define XF86XK_Fn_Esc			_EVDEVK(0x1D1)		/*       KEY_FN_ESC */
+#define XF86XK_FnRightShift		_EVDEVK(0x1E5)		/* v5.10 KEY_FN_RIGHT_SHIFT */
+/* Use: XK_braille_dot_1		_EVDEVK(0x1F1)		   v2.6.17 KEY_BRL_DOT1 */
+/* Use: XK_braille_dot_2		_EVDEVK(0x1F2)		   v2.6.17 KEY_BRL_DOT2 */
+/* Use: XK_braille_dot_3		_EVDEVK(0x1F3)		   v2.6.17 KEY_BRL_DOT3 */
+/* Use: XK_braille_dot_4		_EVDEVK(0x1F4)		   v2.6.17 KEY_BRL_DOT4 */
+/* Use: XK_braille_dot_5		_EVDEVK(0x1F5)		   v2.6.17 KEY_BRL_DOT5 */
+/* Use: XK_braille_dot_6		_EVDEVK(0x1F6)		   v2.6.17 KEY_BRL_DOT6 */
+/* Use: XK_braille_dot_7		_EVDEVK(0x1F7)		   v2.6.17 KEY_BRL_DOT7 */
+/* Use: XK_braille_dot_8		_EVDEVK(0x1F8)		   v2.6.17 KEY_BRL_DOT8 */
+/* Use: XK_braille_dot_9		_EVDEVK(0x1F9)		   v2.6.23 KEY_BRL_DOT9 */
+/* Use: XK_braille_dot_1		_EVDEVK(0x1FA)		   v2.6.23 KEY_BRL_DOT10 */
+#define XF86XK_Numeric0			_EVDEVK(0x200)		/* v2.6.28 KEY_NUMERIC_0 */
+#define XF86XK_Numeric1			_EVDEVK(0x201)		/* v2.6.28 KEY_NUMERIC_1 */
+#define XF86XK_Numeric2			_EVDEVK(0x202)		/* v2.6.28 KEY_NUMERIC_2 */
+#define XF86XK_Numeric3			_EVDEVK(0x203)		/* v2.6.28 KEY_NUMERIC_3 */
+#define XF86XK_Numeric4			_EVDEVK(0x204)		/* v2.6.28 KEY_NUMERIC_4 */
+#define XF86XK_Numeric5			_EVDEVK(0x205)		/* v2.6.28 KEY_NUMERIC_5 */
+#define XF86XK_Numeric6			_EVDEVK(0x206)		/* v2.6.28 KEY_NUMERIC_6 */
+#define XF86XK_Numeric7			_EVDEVK(0x207)		/* v2.6.28 KEY_NUMERIC_7 */
+#define XF86XK_Numeric8			_EVDEVK(0x208)		/* v2.6.28 KEY_NUMERIC_8 */
+#define XF86XK_Numeric9			_EVDEVK(0x209)		/* v2.6.28 KEY_NUMERIC_9 */
+#define XF86XK_NumericStar		_EVDEVK(0x20A)		/* v2.6.28 KEY_NUMERIC_STAR */
+#define XF86XK_NumericPound		_EVDEVK(0x20B)		/* v2.6.28 KEY_NUMERIC_POUND */
+#define XF86XK_NumericA			_EVDEVK(0x20C)		/* v4.1  KEY_NUMERIC_A */
+#define XF86XK_NumericB			_EVDEVK(0x20D)		/* v4.1  KEY_NUMERIC_B */
+#define XF86XK_NumericC			_EVDEVK(0x20E)		/* v4.1  KEY_NUMERIC_C */
+#define XF86XK_NumericD			_EVDEVK(0x20F)		/* v4.1  KEY_NUMERIC_D */
+#define XF86XK_CameraFocus		_EVDEVK(0x210)		/* v2.6.33 KEY_CAMERA_FOCUS */
+#define XF86XK_WPSButton		_EVDEVK(0x211)		/* v2.6.34 KEY_WPS_BUTTON */
+/* Use: XF86XK_TouchpadToggle		_EVDEVK(0x212)		   v2.6.37 KEY_TOUCHPAD_TOGGLE */
+/* Use: XF86XK_TouchpadOn		_EVDEVK(0x213)		   v2.6.37 KEY_TOUCHPAD_ON */
+/* Use: XF86XK_TouchpadOff		_EVDEVK(0x214)		   v2.6.37 KEY_TOUCHPAD_OFF */
+#define XF86XK_CameraZoomIn		_EVDEVK(0x215)		/* v2.6.39 KEY_CAMERA_ZOOMIN */
+#define XF86XK_CameraZoomOut		_EVDEVK(0x216)		/* v2.6.39 KEY_CAMERA_ZOOMOUT */
+#define XF86XK_CameraUp			_EVDEVK(0x217)		/* v2.6.39 KEY_CAMERA_UP */
+#define XF86XK_CameraDown		_EVDEVK(0x218)		/* v2.6.39 KEY_CAMERA_DOWN */
+#define XF86XK_CameraLeft		_EVDEVK(0x219)		/* v2.6.39 KEY_CAMERA_LEFT */
+#define XF86XK_CameraRight		_EVDEVK(0x21A)		/* v2.6.39 KEY_CAMERA_RIGHT */
+#define XF86XK_AttendantOn		_EVDEVK(0x21B)		/* v3.10 KEY_ATTENDANT_ON */
+#define XF86XK_AttendantOff		_EVDEVK(0x21C)		/* v3.10 KEY_ATTENDANT_OFF */
+#define XF86XK_AttendantToggle		_EVDEVK(0x21D)		/* v3.10 KEY_ATTENDANT_TOGGLE */
+#define XF86XK_LightsToggle		_EVDEVK(0x21E)		/* v3.10 KEY_LIGHTS_TOGGLE */
+#define XF86XK_ALSToggle		_EVDEVK(0x230)		/* v3.13 KEY_ALS_TOGGLE */
+/* Use: XF86XK_RotationLockToggle	_EVDEVK(0x231)		   v4.16 KEY_ROTATE_LOCK_TOGGLE */
+#define XF86XK_Buttonconfig		_EVDEVK(0x240)		/* v3.16 KEY_BUTTONCONFIG */
+#define XF86XK_Taskmanager		_EVDEVK(0x241)		/* v3.16 KEY_TASKMANAGER */
+#define XF86XK_Journal			_EVDEVK(0x242)		/* v3.16 KEY_JOURNAL */
+#define XF86XK_ControlPanel		_EVDEVK(0x243)		/* v3.16 KEY_CONTROLPANEL */
+#define XF86XK_AppSelect		_EVDEVK(0x244)		/* v3.16 KEY_APPSELECT */
+#define XF86XK_Screensaver		_EVDEVK(0x245)		/* v3.16 KEY_SCREENSAVER */
+#define XF86XK_VoiceCommand		_EVDEVK(0x246)		/* v3.16 KEY_VOICECOMMAND */
+#define XF86XK_Assistant		_EVDEVK(0x247)		/* v4.13 KEY_ASSISTANT */
+/* Use: XK_ISO_Next_Group		_EVDEVK(0x248)		   v5.2  KEY_KBD_LAYOUT_NEXT */
+#define XF86XK_EmojiPicker		_EVDEVK(0x249)		/* v5.13 KEY_EMOJI_PICKER */
+#define XF86XK_Dictate			_EVDEVK(0x24A)		/* v5.17 KEY_DICTATE */
+#define XF86XK_BrightnessMin		_EVDEVK(0x250)		/* v3.16 KEY_BRIGHTNESS_MIN */
+#define XF86XK_BrightnessMax		_EVDEVK(0x251)		/* v3.16 KEY_BRIGHTNESS_MAX */
+#define XF86XK_KbdInputAssistPrev	_EVDEVK(0x260)		/* v3.18 KEY_KBDINPUTASSIST_PREV */
+#define XF86XK_KbdInputAssistNext	_EVDEVK(0x261)		/* v3.18 KEY_KBDINPUTASSIST_NEXT */
+#define XF86XK_KbdInputAssistPrevgroup	_EVDEVK(0x262)		/* v3.18 KEY_KBDINPUTASSIST_PREVGROUP */
+#define XF86XK_KbdInputAssistNextgroup	_EVDEVK(0x263)		/* v3.18 KEY_KBDINPUTASSIST_NEXTGROUP */
+#define XF86XK_KbdInputAssistAccept	_EVDEVK(0x264)		/* v3.18 KEY_KBDINPUTASSIST_ACCEPT */
+#define XF86XK_KbdInputAssistCancel	_EVDEVK(0x265)		/* v3.18 KEY_KBDINPUTASSIST_CANCEL */
+#define XF86XK_RightUp			_EVDEVK(0x266)		/* v4.7  KEY_RIGHT_UP */
+#define XF86XK_RightDown		_EVDEVK(0x267)		/* v4.7  KEY_RIGHT_DOWN */
+#define XF86XK_LeftUp			_EVDEVK(0x268)		/* v4.7  KEY_LEFT_UP */
+#define XF86XK_LeftDown			_EVDEVK(0x269)		/* v4.7  KEY_LEFT_DOWN */
+#define XF86XK_RootMenu			_EVDEVK(0x26A)		/* v4.7  KEY_ROOT_MENU */
+#define XF86XK_MediaTopMenu		_EVDEVK(0x26B)		/* v4.7  KEY_MEDIA_TOP_MENU */
+#define XF86XK_Numeric11		_EVDEVK(0x26C)		/* v4.7  KEY_NUMERIC_11 */
+#define XF86XK_Numeric12		_EVDEVK(0x26D)		/* v4.7  KEY_NUMERIC_12 */
+#define XF86XK_AudioDesc		_EVDEVK(0x26E)		/* v4.7  KEY_AUDIO_DESC */
+#define XF86XK_3DMode			_EVDEVK(0x26F)		/* v4.7  KEY_3D_MODE */
+#define XF86XK_NextFavorite		_EVDEVK(0x270)		/* v4.7  KEY_NEXT_FAVORITE */
+#define XF86XK_StopRecord		_EVDEVK(0x271)		/* v4.7  KEY_STOP_RECORD */
+#define XF86XK_PauseRecord		_EVDEVK(0x272)		/* v4.7  KEY_PAUSE_RECORD */
+#define XF86XK_VOD			_EVDEVK(0x273)		/* v4.7  KEY_VOD */
+#define XF86XK_Unmute			_EVDEVK(0x274)		/* v4.7  KEY_UNMUTE */
+#define XF86XK_FastReverse		_EVDEVK(0x275)		/* v4.7  KEY_FASTREVERSE */
+#define XF86XK_SlowReverse		_EVDEVK(0x276)		/* v4.7  KEY_SLOWREVERSE */
+#define XF86XK_Data			_EVDEVK(0x277)		/* v4.7  KEY_DATA */
+#define XF86XK_OnScreenKeyboard		_EVDEVK(0x278)		/* v4.12 KEY_ONSCREEN_KEYBOARD */
+#define XF86XK_PrivacyScreenToggle	_EVDEVK(0x279)		/* v5.5  KEY_PRIVACY_SCREEN_TOGGLE */
+#define XF86XK_SelectiveScreenshot	_EVDEVK(0x27A)		/* v5.6  KEY_SELECTIVE_SCREENSHOT */
+#define XF86XK_Macro1			_EVDEVK(0x290)		/* v5.5  KEY_MACRO1 */
+#define XF86XK_Macro2			_EVDEVK(0x291)		/* v5.5  KEY_MACRO2 */
+#define XF86XK_Macro3			_EVDEVK(0x292)		/* v5.5  KEY_MACRO3 */
+#define XF86XK_Macro4			_EVDEVK(0x293)		/* v5.5  KEY_MACRO4 */
+#define XF86XK_Macro5			_EVDEVK(0x294)		/* v5.5  KEY_MACRO5 */
+#define XF86XK_Macro6			_EVDEVK(0x295)		/* v5.5  KEY_MACRO6 */
+#define XF86XK_Macro7			_EVDEVK(0x296)		/* v5.5  KEY_MACRO7 */
+#define XF86XK_Macro8			_EVDEVK(0x297)		/* v5.5  KEY_MACRO8 */
+#define XF86XK_Macro9			_EVDEVK(0x298)		/* v5.5  KEY_MACRO9 */
+#define XF86XK_Macro10			_EVDEVK(0x299)		/* v5.5  KEY_MACRO10 */
+#define XF86XK_Macro11			_EVDEVK(0x29A)		/* v5.5  KEY_MACRO11 */
+#define XF86XK_Macro12			_EVDEVK(0x29B)		/* v5.5  KEY_MACRO12 */
+#define XF86XK_Macro13			_EVDEVK(0x29C)		/* v5.5  KEY_MACRO13 */
+#define XF86XK_Macro14			_EVDEVK(0x29D)		/* v5.5  KEY_MACRO14 */
+#define XF86XK_Macro15			_EVDEVK(0x29E)		/* v5.5  KEY_MACRO15 */
+#define XF86XK_Macro16			_EVDEVK(0x29F)		/* v5.5  KEY_MACRO16 */
+#define XF86XK_Macro17			_EVDEVK(0x2A0)		/* v5.5  KEY_MACRO17 */
+#define XF86XK_Macro18			_EVDEVK(0x2A1)		/* v5.5  KEY_MACRO18 */
+#define XF86XK_Macro19			_EVDEVK(0x2A2)		/* v5.5  KEY_MACRO19 */
+#define XF86XK_Macro20			_EVDEVK(0x2A3)		/* v5.5  KEY_MACRO20 */
+#define XF86XK_Macro21			_EVDEVK(0x2A4)		/* v5.5  KEY_MACRO21 */
+#define XF86XK_Macro22			_EVDEVK(0x2A5)		/* v5.5  KEY_MACRO22 */
+#define XF86XK_Macro23			_EVDEVK(0x2A6)		/* v5.5  KEY_MACRO23 */
+#define XF86XK_Macro24			_EVDEVK(0x2A7)		/* v5.5  KEY_MACRO24 */
+#define XF86XK_Macro25			_EVDEVK(0x2A8)		/* v5.5  KEY_MACRO25 */
+#define XF86XK_Macro26			_EVDEVK(0x2A9)		/* v5.5  KEY_MACRO26 */
+#define XF86XK_Macro27			_EVDEVK(0x2AA)		/* v5.5  KEY_MACRO27 */
+#define XF86XK_Macro28			_EVDEVK(0x2AB)		/* v5.5  KEY_MACRO28 */
+#define XF86XK_Macro29			_EVDEVK(0x2AC)		/* v5.5  KEY_MACRO29 */
+#define XF86XK_Macro30			_EVDEVK(0x2AD)		/* v5.5  KEY_MACRO30 */
+#define XF86XK_MacroRecordStart		_EVDEVK(0x2B0)		/* v5.5  KEY_MACRO_RECORD_START */
+#define XF86XK_MacroRecordStop		_EVDEVK(0x2B1)		/* v5.5  KEY_MACRO_RECORD_STOP */
+#define XF86XK_MacroPresetCycle		_EVDEVK(0x2B2)		/* v5.5  KEY_MACRO_PRESET_CYCLE */
+#define XF86XK_MacroPreset1		_EVDEVK(0x2B3)		/* v5.5  KEY_MACRO_PRESET1 */
+#define XF86XK_MacroPreset2		_EVDEVK(0x2B4)		/* v5.5  KEY_MACRO_PRESET2 */
+#define XF86XK_MacroPreset3		_EVDEVK(0x2B5)		/* v5.5  KEY_MACRO_PRESET3 */
+#define XF86XK_KbdLcdMenu1		_EVDEVK(0x2B8)		/* v5.5  KEY_KBD_LCD_MENU1 */
+#define XF86XK_KbdLcdMenu2		_EVDEVK(0x2B9)		/* v5.5  KEY_KBD_LCD_MENU2 */
+#define XF86XK_KbdLcdMenu3		_EVDEVK(0x2BA)		/* v5.5  KEY_KBD_LCD_MENU3 */
+#define XF86XK_KbdLcdMenu4		_EVDEVK(0x2BB)		/* v5.5  KEY_KBD_LCD_MENU4 */
+#define XF86XK_KbdLcdMenu5		_EVDEVK(0x2BC)		/* v5.5  KEY_KBD_LCD_MENU5 */
+#undef _EVDEVK

Index: xlib/X11/Xfuncproto.h
==================================================================
--- xlib/X11/Xfuncproto.h
+++ xlib/X11/Xfuncproto.h
@@ -215,7 +215,15 @@
 #if __has_attribute(no_sanitize_thread)
 # define _X_NOTSAN __attribute__((no_sanitize_thread))
 #else
 # define _X_NOTSAN
 #endif
+
+/* Mark a char array/pointer as not containing a NUL-terminated string */
+/* requires xproto >= 7.0.33 */
+#if __has_attribute(nonstring)
+# define _X_NONSTRING __attribute__((nonstring))
+#else
+# define _X_NONSTRING
+#endif
 
 #endif /* _XFUNCPROTO_H_ */

Index: xlib/X11/Xlib.h
==================================================================
--- xlib/X11/Xlib.h
+++ xlib/X11/Xlib.h
@@ -204,15 +204,15 @@
 	int line_style;	 	/* LineSolid, LineOnOffDash, LineDoubleDash */
 	int cap_style;	  	/* CapNotLast, CapButt,
 				   CapRound, CapProjecting */
 	int join_style;	 	/* JoinMiter, JoinRound, JoinBevel */
 	int fill_style;	 	/* FillSolid, FillTiled,
-				   FillStippled, FillOpaeueStippled */
+				   FillStippled, FillOpaqueStippled */
 	int fill_rule;	  	/* EvenOddRule, WindingRule */
 	int arc_mode;		/* ArcChord, ArcPieSlice */
 	Pixmap tile;		/* tile pixmap for tiling operations */
-	Pixmap stipple;		/* stipple 1 plane pixmap for stipping */
+	Pixmap stipple;		/* stipple 1 plane pixmap for stippling */
 	int ts_x_origin;	/* offset for tile or stipple operations */
 	int ts_y_origin;
         Font font;	        /* default text font for text operations */
 	int subwindow_mode;     /* ClipByChildren, IncludeInferiors */
 	Bool graphics_exposures;/* boolean, should exposures be generated */
@@ -302,11 +302,11 @@
     Pixmap border_pixmap;	/* border of the window */
     unsigned long border_pixel;	/* border pixel value */
     int bit_gravity;		/* one of bit gravity values */
     int win_gravity;		/* one of the window gravity values */
     int backing_store;		/* NotUseful, WhenMapped, Always */
-    unsigned long backing_planes;/* planes to be preseved if possible */
+    unsigned long backing_planes;/* planes to be preserved if possible */
     unsigned long backing_pixel;/* value to use in restoring planes */
     Bool save_under;		/* should bits under be saved? (popups) */
     long event_mask;		/* set of events that should be saved */
     long do_not_propagate_mask;	/* set of events that should not propagate */
     Bool override_redirect;	/* boolean value for override-redirect */
@@ -374,13 +374,13 @@
     int byte_order;		/* data byte order, LSBFirst, MSBFirst */
     int bitmap_unit;		/* quant. of scanline 8, 16, 32 */
     int bitmap_bit_order;	/* LSBFirst, MSBFirst */
     int bitmap_pad;		/* 8, 16, 32 either XY or ZPixmap */
     int depth;			/* depth of image */
-    int bytes_per_line;		/* accelarator to next line */
+    int bytes_per_line;		/* accelerator to next line */
     int bits_per_pixel;		/* bits per pixel (ZPixmap) */
-    unsigned long red_mask;	/* bits in z arrangment */
+    unsigned long red_mask;	/* bits in z arrangement */
     unsigned long green_mask;
     unsigned long blue_mask;
     XPointer obdata;		/* hook for the object routines to hang on */
     struct funcs {		/* image manipulation routines */
 	struct _XImage *(*create_image)(
@@ -584,12 +584,10 @@
 #if NeedFunctionPrototypes	/* prototypes require event type definitions */
 #undef _XEVENT_
 #endif
 #ifndef _XEVENT_
 
-#define XMaxTransChars 7
-
 /*
  * Definitions of specific events.
  */
 typedef struct {
 	int type;		/* of event */
@@ -1718,11 +1716,12 @@
 EXTERN XHostAddress *XListHosts(
     Display*		/* display */,
     int*		/* nhosts_return */,
     Bool*		/* state_return */
 );
-EXTERN _X_DEPRECATED KeySym XKeycodeToKeysym(
+_X_DEPRECATED
+EXTERN KeySym XKeycodeToKeysym(
     Display*		/* display */,
 #if NeedWidePrototypes
     unsigned int	/* keycode */,
 #else
     KeyCode		/* keycode */,

Index: xlib/X11/ap_keysym.h
==================================================================
--- xlib/X11/ap_keysym.h
+++ xlib/X11/ap_keysym.h
@@ -11,11 +11,11 @@
 names of Apollo Computer Inc., the Hewlett-Packard Company, or the X
 Consortium not be used in advertising or publicity pertaining to
 distribution of the software without written prior permission.
 
 HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD
-TO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+TO THIS SOFTWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 PURPOSE.  Hewlett-Packard shall not be liable for errors
 contained herein or direct, indirect, special, incidental or
 consequential damages in connection with the furnishing,
 performance, or use of this material.

Index: xlib/X11/keysymdef.h
==================================================================
--- xlib/X11/keysymdef.h
+++ xlib/X11/keysymdef.h
@@ -84,12 +84,12 @@
  * file, all but the first one listed should be considered deprecated.
  *
  * Mnemonic names for keysyms are defined in this file with lines
  * that match one of these Perl regular expressions:
  *
- *    /^\#define XK_([a-zA-Z_0-9]+)\s+0x([0-9a-f]+)\s*\/\* U+([0-9A-F]{4,6}) (.*) \*\/\s*$/
- *    /^\#define XK_([a-zA-Z_0-9]+)\s+0x([0-9a-f]+)\s*\/\*\(U+([0-9A-F]{4,6}) (.*)\)\*\/\s*$/
+ *    /^\#define XK_([a-zA-Z_0-9]+)\s+0x([0-9a-f]+)\s*\/\* U\+([0-9A-F]{4,6}) (.*) \*\/\s*$/
+ *    /^\#define XK_([a-zA-Z_0-9]+)\s+0x([0-9a-f]+)\s*\/\*\(U\+([0-9A-F]{4,6}) (.*)\)\*\/\s*$/
  *    /^\#define XK_([a-zA-Z_0-9]+)\s+0x([0-9a-f]+)\s*(\/\*\s*(.*)\s*\*\/)?\s*$/
  *
  * Before adding new keysyms, please do consider the following: In
  * addition to the keysym names defined in this file, the
  * XStringToKeysym() and XKeysymToString() functions will also handle
@@ -179,15 +179,19 @@
 #define XK_Next                          0xff56  /* Next */
 #define XK_Page_Down                     0xff56
 #define XK_End                           0xff57  /* EOL */
 #define XK_Begin                         0xff58  /* BOL */
 
+
+#ifndef TK_NO_DEPRECATED
 /* Special Windows keyboard keys */
 
 #define XK_Win_L		0xFF5B	/* Left-hand Windows */
 #define XK_Win_R		0xFF5C	/* Right-hand Windows */
 #define XK_App			0xFF5D	/* Menu key */
+#endif
+
 
 /* Misc functions */
 
 #define XK_Select                        0xff60  /* Select, mark */
 #define XK_Print                         0xff61
@@ -884,42 +888,10 @@
 #define XK_uogonek                       0x03f9  /* U+0173 LATIN SMALL LETTER U WITH OGONEK */
 #define XK_utilde                        0x03fd  /* U+0169 LATIN SMALL LETTER U WITH TILDE */
 #define XK_umacron                       0x03fe  /* U+016B LATIN SMALL LETTER U WITH MACRON */
 #endif /* XK_LATIN4 */
 
-/*
- * Latin 8
- */
-#ifdef XK_LATIN8
-#define XK_Wcircumflex                0x1000174  /* U+0174 LATIN CAPITAL LETTER W WITH CIRCUMFLEX */
-#define XK_wcircumflex                0x1000175  /* U+0175 LATIN SMALL LETTER W WITH CIRCUMFLEX */
-#define XK_Ycircumflex                0x1000176  /* U+0176 LATIN CAPITAL LETTER Y WITH CIRCUMFLEX */
-#define XK_ycircumflex                0x1000177  /* U+0177 LATIN SMALL LETTER Y WITH CIRCUMFLEX */
-#define XK_Babovedot                  0x1001e02  /* U+1E02 LATIN CAPITAL LETTER B WITH DOT ABOVE */
-#define XK_babovedot                  0x1001e03  /* U+1E03 LATIN SMALL LETTER B WITH DOT ABOVE */
-#define XK_Dabovedot                  0x1001e0a  /* U+1E0A LATIN CAPITAL LETTER D WITH DOT ABOVE */
-#define XK_dabovedot                  0x1001e0b  /* U+1E0B LATIN SMALL LETTER D WITH DOT ABOVE */
-#define XK_Fabovedot                  0x1001e1e  /* U+1E1E LATIN CAPITAL LETTER F WITH DOT ABOVE */
-#define XK_fabovedot                  0x1001e1f  /* U+1E1F LATIN SMALL LETTER F WITH DOT ABOVE */
-#define XK_Mabovedot                  0x1001e40  /* U+1E40 LATIN CAPITAL LETTER M WITH DOT ABOVE */
-#define XK_mabovedot                  0x1001e41  /* U+1E41 LATIN SMALL LETTER M WITH DOT ABOVE */
-#define XK_Pabovedot                  0x1001e56  /* U+1E56 LATIN CAPITAL LETTER P WITH DOT ABOVE */
-#define XK_pabovedot                  0x1001e57  /* U+1E57 LATIN SMALL LETTER P WITH DOT ABOVE */
-#define XK_Sabovedot                  0x1001e60  /* U+1E60 LATIN CAPITAL LETTER S WITH DOT ABOVE */
-#define XK_sabovedot                  0x1001e61  /* U+1E61 LATIN SMALL LETTER S WITH DOT ABOVE */
-#define XK_Tabovedot                  0x1001e6a  /* U+1E6A LATIN CAPITAL LETTER T WITH DOT ABOVE */
-#define XK_tabovedot                  0x1001e6b  /* U+1E6B LATIN SMALL LETTER T WITH DOT ABOVE */
-#define XK_Wgrave                     0x1001e80  /* U+1E80 LATIN CAPITAL LETTER W WITH GRAVE */
-#define XK_wgrave                     0x1001e81  /* U+1E81 LATIN SMALL LETTER W WITH GRAVE */
-#define XK_Wacute                     0x1001e82  /* U+1E82 LATIN CAPITAL LETTER W WITH ACUTE */
-#define XK_wacute                     0x1001e83  /* U+1E83 LATIN SMALL LETTER W WITH ACUTE */
-#define XK_Wdiaeresis                 0x1001e84  /* U+1E84 LATIN CAPITAL LETTER W WITH DIAERESIS */
-#define XK_wdiaeresis                 0x1001e85  /* U+1E85 LATIN SMALL LETTER W WITH DIAERESIS */
-#define XK_Ygrave                     0x1001ef2  /* U+1EF2 LATIN CAPITAL LETTER Y WITH GRAVE */
-#define XK_ygrave                     0x1001ef3  /* U+1EF3 LATIN SMALL LETTER Y WITH GRAVE */
-#endif /* XK_LATIN8 */
-
 /*
  * Latin 9
  * Byte 3 = 0x13
  */
 
@@ -1011,39 +983,11 @@
  * Arabic
  * Byte 3 = 5
  */
 
 #ifdef XK_ARABIC
-#define XK_Farsi_0                    0x10006f0  /* U+06F0 EXTENDED ARABIC-INDIC DIGIT ZERO */
-#define XK_Farsi_1                    0x10006f1  /* U+06F1 EXTENDED ARABIC-INDIC DIGIT ONE */
-#define XK_Farsi_2                    0x10006f2  /* U+06F2 EXTENDED ARABIC-INDIC DIGIT TWO */
-#define XK_Farsi_3                    0x10006f3  /* U+06F3 EXTENDED ARABIC-INDIC DIGIT THREE */
-#define XK_Farsi_4                    0x10006f4  /* U+06F4 EXTENDED ARABIC-INDIC DIGIT FOUR */
-#define XK_Farsi_5                    0x10006f5  /* U+06F5 EXTENDED ARABIC-INDIC DIGIT FIVE */
-#define XK_Farsi_6                    0x10006f6  /* U+06F6 EXTENDED ARABIC-INDIC DIGIT SIX */
-#define XK_Farsi_7                    0x10006f7  /* U+06F7 EXTENDED ARABIC-INDIC DIGIT SEVEN */
-#define XK_Farsi_8                    0x10006f8  /* U+06F8 EXTENDED ARABIC-INDIC DIGIT EIGHT */
-#define XK_Farsi_9                    0x10006f9  /* U+06F9 EXTENDED ARABIC-INDIC DIGIT NINE */
-#define XK_Arabic_percent             0x100066a  /* U+066A ARABIC PERCENT SIGN */
-#define XK_Arabic_superscript_alef    0x1000670  /* U+0670 ARABIC LETTER SUPERSCRIPT ALEF */
-#define XK_Arabic_tteh                0x1000679  /* U+0679 ARABIC LETTER TTEH */
-#define XK_Arabic_peh                 0x100067e  /* U+067E ARABIC LETTER PEH */
-#define XK_Arabic_tcheh               0x1000686  /* U+0686 ARABIC LETTER TCHEH */
-#define XK_Arabic_ddal                0x1000688  /* U+0688 ARABIC LETTER DDAL */
-#define XK_Arabic_rreh                0x1000691  /* U+0691 ARABIC LETTER RREH */
 #define XK_Arabic_comma                  0x05ac  /* U+060C ARABIC COMMA */
-#define XK_Arabic_fullstop            0x10006d4  /* U+06D4 ARABIC FULL STOP */
-#define XK_Arabic_0                   0x1000660  /* U+0660 ARABIC-INDIC DIGIT ZERO */
-#define XK_Arabic_1                   0x1000661  /* U+0661 ARABIC-INDIC DIGIT ONE */
-#define XK_Arabic_2                   0x1000662  /* U+0662 ARABIC-INDIC DIGIT TWO */
-#define XK_Arabic_3                   0x1000663  /* U+0663 ARABIC-INDIC DIGIT THREE */
-#define XK_Arabic_4                   0x1000664  /* U+0664 ARABIC-INDIC DIGIT FOUR */
-#define XK_Arabic_5                   0x1000665  /* U+0665 ARABIC-INDIC DIGIT FIVE */
-#define XK_Arabic_6                   0x1000666  /* U+0666 ARABIC-INDIC DIGIT SIX */
-#define XK_Arabic_7                   0x1000667  /* U+0667 ARABIC-INDIC DIGIT SEVEN */
-#define XK_Arabic_8                   0x1000668  /* U+0668 ARABIC-INDIC DIGIT EIGHT */
-#define XK_Arabic_9                   0x1000669  /* U+0669 ARABIC-INDIC DIGIT NINE */
 #define XK_Arabic_semicolon              0x05bb  /* U+061B ARABIC SEMICOLON */
 #define XK_Arabic_question_mark          0x05bf  /* U+061F ARABIC QUESTION MARK */
 #define XK_Arabic_hamza                  0x05c1  /* U+0621 ARABIC LETTER HAMZA */
 #define XK_Arabic_maddaonalef            0x05c2  /* U+0622 ARABIC LETTER ALEF WITH MADDA ABOVE */
 #define XK_Arabic_hamzaonalef            0x05c3  /* U+0623 ARABIC LETTER ALEF WITH HAMZA ABOVE */
@@ -1088,63 +1032,18 @@
 #define XK_Arabic_fatha                  0x05ee  /* U+064E ARABIC FATHA */
 #define XK_Arabic_damma                  0x05ef  /* U+064F ARABIC DAMMA */
 #define XK_Arabic_kasra                  0x05f0  /* U+0650 ARABIC KASRA */
 #define XK_Arabic_shadda                 0x05f1  /* U+0651 ARABIC SHADDA */
 #define XK_Arabic_sukun                  0x05f2  /* U+0652 ARABIC SUKUN */
-#define XK_Arabic_madda_above         0x1000653  /* U+0653 ARABIC MADDAH ABOVE */
-#define XK_Arabic_hamza_above         0x1000654  /* U+0654 ARABIC HAMZA ABOVE */
-#define XK_Arabic_hamza_below         0x1000655  /* U+0655 ARABIC HAMZA BELOW */
-#define XK_Arabic_jeh                 0x1000698  /* U+0698 ARABIC LETTER JEH */
-#define XK_Arabic_veh                 0x10006a4  /* U+06A4 ARABIC LETTER VEH */
-#define XK_Arabic_keheh               0x10006a9  /* U+06A9 ARABIC LETTER KEHEH */
-#define XK_Arabic_gaf                 0x10006af  /* U+06AF ARABIC LETTER GAF */
-#define XK_Arabic_noon_ghunna         0x10006ba  /* U+06BA ARABIC LETTER NOON GHUNNA */
-#define XK_Arabic_heh_doachashmee     0x10006be  /* U+06BE ARABIC LETTER HEH DOACHASHMEE */
-#define XK_Farsi_yeh                  0x10006cc  /* U+06CC ARABIC LETTER FARSI YEH */
-#define XK_Arabic_farsi_yeh           0x10006cc  /* U+06CC ARABIC LETTER FARSI YEH */
-#define XK_Arabic_yeh_baree           0x10006d2  /* U+06D2 ARABIC LETTER YEH BARREE */
-#define XK_Arabic_heh_goal            0x10006c1  /* U+06C1 ARABIC LETTER HEH GOAL */
 #define XK_Arabic_switch                 0xff7e  /* Alias for mode_switch */
 #endif /* XK_ARABIC */
 
 /*
  * Cyrillic
  * Byte 3 = 6
  */
 #ifdef XK_CYRILLIC
-#define XK_Cyrillic_GHE_bar           0x1000492  /* U+0492 CYRILLIC CAPITAL LETTER GHE WITH STROKE */
-#define XK_Cyrillic_ghe_bar           0x1000493  /* U+0493 CYRILLIC SMALL LETTER GHE WITH STROKE */
-#define XK_Cyrillic_ZHE_descender     0x1000496  /* U+0496 CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER */
-#define XK_Cyrillic_zhe_descender     0x1000497  /* U+0497 CYRILLIC SMALL LETTER ZHE WITH DESCENDER */
-#define XK_Cyrillic_KA_descender      0x100049a  /* U+049A CYRILLIC CAPITAL LETTER KA WITH DESCENDER */
-#define XK_Cyrillic_ka_descender      0x100049b  /* U+049B CYRILLIC SMALL LETTER KA WITH DESCENDER */
-#define XK_Cyrillic_KA_vertstroke     0x100049c  /* U+049C CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE */
-#define XK_Cyrillic_ka_vertstroke     0x100049d  /* U+049D CYRILLIC SMALL LETTER KA WITH VERTICAL STROKE */
-#define XK_Cyrillic_EN_descender      0x10004a2  /* U+04A2 CYRILLIC CAPITAL LETTER EN WITH DESCENDER */
-#define XK_Cyrillic_en_descender      0x10004a3  /* U+04A3 CYRILLIC SMALL LETTER EN WITH DESCENDER */
-#define XK_Cyrillic_U_straight        0x10004ae  /* U+04AE CYRILLIC CAPITAL LETTER STRAIGHT U */
-#define XK_Cyrillic_u_straight        0x10004af  /* U+04AF CYRILLIC SMALL LETTER STRAIGHT U */
-#define XK_Cyrillic_U_straight_bar    0x10004b0  /* U+04B0 CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE */
-#define XK_Cyrillic_u_straight_bar    0x10004b1  /* U+04B1 CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE */
-#define XK_Cyrillic_HA_descender      0x10004b2  /* U+04B2 CYRILLIC CAPITAL LETTER HA WITH DESCENDER */
-#define XK_Cyrillic_ha_descender      0x10004b3  /* U+04B3 CYRILLIC SMALL LETTER HA WITH DESCENDER */
-#define XK_Cyrillic_CHE_descender     0x10004b6  /* U+04B6 CYRILLIC CAPITAL LETTER CHE WITH DESCENDER */
-#define XK_Cyrillic_che_descender     0x10004b7  /* U+04B7 CYRILLIC SMALL LETTER CHE WITH DESCENDER */
-#define XK_Cyrillic_CHE_vertstroke    0x10004b8  /* U+04B8 CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE */
-#define XK_Cyrillic_che_vertstroke    0x10004b9  /* U+04B9 CYRILLIC SMALL LETTER CHE WITH VERTICAL STROKE */
-#define XK_Cyrillic_SHHA              0x10004ba  /* U+04BA CYRILLIC CAPITAL LETTER SHHA */
-#define XK_Cyrillic_shha              0x10004bb  /* U+04BB CYRILLIC SMALL LETTER SHHA */
-
-#define XK_Cyrillic_SCHWA             0x10004d8  /* U+04D8 CYRILLIC CAPITAL LETTER SCHWA */
-#define XK_Cyrillic_schwa             0x10004d9  /* U+04D9 CYRILLIC SMALL LETTER SCHWA */
-#define XK_Cyrillic_I_macron          0x10004e2  /* U+04E2 CYRILLIC CAPITAL LETTER I WITH MACRON */
-#define XK_Cyrillic_i_macron          0x10004e3  /* U+04E3 CYRILLIC SMALL LETTER I WITH MACRON */
-#define XK_Cyrillic_O_bar             0x10004e8  /* U+04E8 CYRILLIC CAPITAL LETTER BARRED O */
-#define XK_Cyrillic_o_bar             0x10004e9  /* U+04E9 CYRILLIC SMALL LETTER BARRED O */
-#define XK_Cyrillic_U_macron          0x10004ee  /* U+04EE CYRILLIC CAPITAL LETTER U WITH MACRON */
-#define XK_Cyrillic_u_macron          0x10004ef  /* U+04EF CYRILLIC SMALL LETTER U WITH MACRON */
-
 #define XK_Serbian_dje                   0x06a1  /* U+0452 CYRILLIC SMALL LETTER DJE */
 #define XK_Macedonia_gje                 0x06a2  /* U+0453 CYRILLIC SMALL LETTER GJE */
 #define XK_Cyrillic_io                   0x06a3  /* U+0451 CYRILLIC SMALL LETTER IO */
 #define XK_Ukrainian_ie                  0x06a4  /* U+0454 CYRILLIC SMALL LETTER UKRAINIAN IE */
 #define XK_Ukranian_je                   0x06a4  /* deprecated */
@@ -1458,13 +1357,13 @@
 #define XK_fourfifths                    0x0ab5  /* U+2158 VULGAR FRACTION FOUR FIFTHS */
 #define XK_onesixth                      0x0ab6  /* U+2159 VULGAR FRACTION ONE SIXTH */
 #define XK_fivesixths                    0x0ab7  /* U+215A VULGAR FRACTION FIVE SIXTHS */
 #define XK_careof                        0x0ab8  /* U+2105 CARE OF */
 #define XK_figdash                       0x0abb  /* U+2012 FIGURE DASH */
-#define XK_leftanglebracket              0x0abc  /*(U+27E8 MATHEMATICAL LEFT ANGLE BRACKET)*/
+#define XK_leftanglebracket              0x0abc  /*(U+2329 LEFT-POINTING ANGLE BRACKET)*/
 #define XK_decimalpoint                  0x0abd  /*(U+002E FULL STOP)*/
-#define XK_rightanglebracket             0x0abe  /*(U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET)*/
+#define XK_rightanglebracket             0x0abe  /*(U+232A RIGHT-POINTING ANGLE BRACKET)*/
 #define XK_marker                        0x0abf
 #define XK_oneeighth                     0x0ac3  /* U+215B VULGAR FRACTION ONE EIGHTH */
 #define XK_threeeighths                  0x0ac4  /* U+215C VULGAR FRACTION THREE EIGHTHS */
 #define XK_fiveeighths                   0x0ac5  /* U+215D VULGAR FRACTION FIVE EIGHTHS */
 #define XK_seveneighths                  0x0ac6  /* U+215E VULGAR FRACTION SEVEN EIGHTHS */
@@ -1713,439 +1612,120 @@
 #define XK_Hangul_PreviousCandidate      0xff3e  /* Previous candidate */
 #define XK_Hangul_Special                0xff3f  /* Special symbols */
 #define XK_Hangul_switch                 0xff7e  /* Alias for mode_switch */
 
 /* Hangul Consonant Characters */
-#define XK_Hangul_Kiyeog                 0x0ea1
-#define XK_Hangul_SsangKiyeog            0x0ea2
-#define XK_Hangul_KiyeogSios             0x0ea3
-#define XK_Hangul_Nieun                  0x0ea4
-#define XK_Hangul_NieunJieuj             0x0ea5
-#define XK_Hangul_NieunHieuh             0x0ea6
-#define XK_Hangul_Dikeud                 0x0ea7
-#define XK_Hangul_SsangDikeud            0x0ea8
-#define XK_Hangul_Rieul                  0x0ea9
-#define XK_Hangul_RieulKiyeog            0x0eaa
-#define XK_Hangul_RieulMieum             0x0eab
-#define XK_Hangul_RieulPieub             0x0eac
-#define XK_Hangul_RieulSios              0x0ead
-#define XK_Hangul_RieulTieut             0x0eae
-#define XK_Hangul_RieulPhieuf            0x0eaf
-#define XK_Hangul_RieulHieuh             0x0eb0
-#define XK_Hangul_Mieum                  0x0eb1
-#define XK_Hangul_Pieub                  0x0eb2
-#define XK_Hangul_SsangPieub             0x0eb3
-#define XK_Hangul_PieubSios              0x0eb4
-#define XK_Hangul_Sios                   0x0eb5
-#define XK_Hangul_SsangSios              0x0eb6
-#define XK_Hangul_Ieung                  0x0eb7
-#define XK_Hangul_Jieuj                  0x0eb8
-#define XK_Hangul_SsangJieuj             0x0eb9
-#define XK_Hangul_Cieuc                  0x0eba
-#define XK_Hangul_Khieuq                 0x0ebb
-#define XK_Hangul_Tieut                  0x0ebc
-#define XK_Hangul_Phieuf                 0x0ebd
-#define XK_Hangul_Hieuh                  0x0ebe
+#define XK_Hangul_Kiyeog                 0x0ea1  /* U+3131 HANGUL LETTER KIYEOK */
+#define XK_Hangul_SsangKiyeog            0x0ea2  /* U+3132 HANGUL LETTER SSANGKIYEOK */
+#define XK_Hangul_KiyeogSios             0x0ea3  /* U+3133 HANGUL LETTER KIYEOK-SIOS */
+#define XK_Hangul_Nieun                  0x0ea4  /* U+3134 HANGUL LETTER NIEUN */
+#define XK_Hangul_NieunJieuj             0x0ea5  /* U+3135 HANGUL LETTER NIEUN-CIEUC */
+#define XK_Hangul_NieunHieuh             0x0ea6  /* U+3136 HANGUL LETTER NIEUN-HIEUH */
+#define XK_Hangul_Dikeud                 0x0ea7  /* U+3137 HANGUL LETTER TIKEUT */
+#define XK_Hangul_SsangDikeud            0x0ea8  /* U+3138 HANGUL LETTER SSANGTIKEUT */
+#define XK_Hangul_Rieul                  0x0ea9  /* U+3139 HANGUL LETTER RIEUL */
+#define XK_Hangul_RieulKiyeog            0x0eaa  /* U+313A HANGUL LETTER RIEUL-KIYEOK */
+#define XK_Hangul_RieulMieum             0x0eab  /* U+313B HANGUL LETTER RIEUL-MIEUM */
+#define XK_Hangul_RieulPieub             0x0eac  /* U+313C HANGUL LETTER RIEUL-PIEUP */
+#define XK_Hangul_RieulSios              0x0ead  /* U+313D HANGUL LETTER RIEUL-SIOS */
+#define XK_Hangul_RieulTieut             0x0eae  /* U+313E HANGUL LETTER RIEUL-THIEUTH */
+#define XK_Hangul_RieulPhieuf            0x0eaf  /* U+313F HANGUL LETTER RIEUL-PHIEUPH */
+#define XK_Hangul_RieulHieuh             0x0eb0  /* U+3140 HANGUL LETTER RIEUL-HIEUH */
+#define XK_Hangul_Mieum                  0x0eb1  /* U+3141 HANGUL LETTER MIEUM */
+#define XK_Hangul_Pieub                  0x0eb2  /* U+3142 HANGUL LETTER PIEUP */
+#define XK_Hangul_SsangPieub             0x0eb3  /* U+3143 HANGUL LETTER SSANGPIEUP */
+#define XK_Hangul_PieubSios              0x0eb4  /* U+3144 HANGUL LETTER PIEUP-SIOS */
+#define XK_Hangul_Sios                   0x0eb5  /* U+3145 HANGUL LETTER SIOS */
+#define XK_Hangul_SsangSios              0x0eb6  /* U+3146 HANGUL LETTER SSANGSIOS */
+#define XK_Hangul_Ieung                  0x0eb7  /* U+3147 HANGUL LETTER IEUNG */
+#define XK_Hangul_Jieuj                  0x0eb8  /* U+3148 HANGUL LETTER CIEUC */
+#define XK_Hangul_SsangJieuj             0x0eb9  /* U+3149 HANGUL LETTER SSANGCIEUC */
+#define XK_Hangul_Cieuc                  0x0eba  /* U+314A HANGUL LETTER CHIEUCH */
+#define XK_Hangul_Khieuq                 0x0ebb  /* U+314B HANGUL LETTER KHIEUKH */
+#define XK_Hangul_Tieut                  0x0ebc  /* U+314C HANGUL LETTER THIEUTH */
+#define XK_Hangul_Phieuf                 0x0ebd  /* U+314D HANGUL LETTER PHIEUPH */
+#define XK_Hangul_Hieuh                  0x0ebe  /* U+314E HANGUL LETTER HIEUH */
 
 /* Hangul Vowel Characters */
-#define XK_Hangul_A                      0x0ebf
-#define XK_Hangul_AE                     0x0ec0
-#define XK_Hangul_YA                     0x0ec1
-#define XK_Hangul_YAE                    0x0ec2
-#define XK_Hangul_EO                     0x0ec3
-#define XK_Hangul_E                      0x0ec4
-#define XK_Hangul_YEO                    0x0ec5
-#define XK_Hangul_YE                     0x0ec6
-#define XK_Hangul_O                      0x0ec7
-#define XK_Hangul_WA                     0x0ec8
-#define XK_Hangul_WAE                    0x0ec9
-#define XK_Hangul_OE                     0x0eca
-#define XK_Hangul_YO                     0x0ecb
-#define XK_Hangul_U                      0x0ecc
-#define XK_Hangul_WEO                    0x0ecd
-#define XK_Hangul_WE                     0x0ece
-#define XK_Hangul_WI                     0x0ecf
-#define XK_Hangul_YU                     0x0ed0
-#define XK_Hangul_EU                     0x0ed1
-#define XK_Hangul_YI                     0x0ed2
-#define XK_Hangul_I                      0x0ed3
+#define XK_Hangul_A                      0x0ebf  /* U+314F HANGUL LETTER A */
+#define XK_Hangul_AE                     0x0ec0  /* U+3150 HANGUL LETTER AE */
+#define XK_Hangul_YA                     0x0ec1  /* U+3151 HANGUL LETTER YA */
+#define XK_Hangul_YAE                    0x0ec2  /* U+3152 HANGUL LETTER YAE */
+#define XK_Hangul_EO                     0x0ec3  /* U+3153 HANGUL LETTER EO */
+#define XK_Hangul_E                      0x0ec4  /* U+3154 HANGUL LETTER E */
+#define XK_Hangul_YEO                    0x0ec5  /* U+3155 HANGUL LETTER YEO */
+#define XK_Hangul_YE                     0x0ec6  /* U+3156 HANGUL LETTER YE */
+#define XK_Hangul_O                      0x0ec7  /* U+3157 HANGUL LETTER O */
+#define XK_Hangul_WA                     0x0ec8  /* U+3158 HANGUL LETTER WA */
+#define XK_Hangul_WAE                    0x0ec9  /* U+3159 HANGUL LETTER WAE */
+#define XK_Hangul_OE                     0x0eca  /* U+315A HANGUL LETTER OE */
+#define XK_Hangul_YO                     0x0ecb  /* U+315B HANGUL LETTER YO */
+#define XK_Hangul_U                      0x0ecc  /* U+315C HANGUL LETTER U */
+#define XK_Hangul_WEO                    0x0ecd  /* U+315D HANGUL LETTER WEO */
+#define XK_Hangul_WE                     0x0ece  /* U+315E HANGUL LETTER WE */
+#define XK_Hangul_WI                     0x0ecf  /* U+315F HANGUL LETTER WI */
+#define XK_Hangul_YU                     0x0ed0  /* U+3160 HANGUL LETTER YU */
+#define XK_Hangul_EU                     0x0ed1  /* U+3161 HANGUL LETTER EU */
+#define XK_Hangul_YI                     0x0ed2  /* U+3162 HANGUL LETTER YI */
+#define XK_Hangul_I                      0x0ed3  /* U+3163 HANGUL LETTER I */
 
 /* Hangul syllable-final (JongSeong) Characters */
-#define XK_Hangul_J_Kiyeog               0x0ed4
-#define XK_Hangul_J_SsangKiyeog          0x0ed5
-#define XK_Hangul_J_KiyeogSios           0x0ed6
-#define XK_Hangul_J_Nieun                0x0ed7
-#define XK_Hangul_J_NieunJieuj           0x0ed8
-#define XK_Hangul_J_NieunHieuh           0x0ed9
-#define XK_Hangul_J_Dikeud               0x0eda
-#define XK_Hangul_J_Rieul                0x0edb
-#define XK_Hangul_J_RieulKiyeog          0x0edc
-#define XK_Hangul_J_RieulMieum           0x0edd
-#define XK_Hangul_J_RieulPieub           0x0ede
-#define XK_Hangul_J_RieulSios            0x0edf
-#define XK_Hangul_J_RieulTieut           0x0ee0
-#define XK_Hangul_J_RieulPhieuf          0x0ee1
-#define XK_Hangul_J_RieulHieuh           0x0ee2
-#define XK_Hangul_J_Mieum                0x0ee3
-#define XK_Hangul_J_Pieub                0x0ee4
-#define XK_Hangul_J_PieubSios            0x0ee5
-#define XK_Hangul_J_Sios                 0x0ee6
-#define XK_Hangul_J_SsangSios            0x0ee7
-#define XK_Hangul_J_Ieung                0x0ee8
-#define XK_Hangul_J_Jieuj                0x0ee9
-#define XK_Hangul_J_Cieuc                0x0eea
-#define XK_Hangul_J_Khieuq               0x0eeb
-#define XK_Hangul_J_Tieut                0x0eec
-#define XK_Hangul_J_Phieuf               0x0eed
-#define XK_Hangul_J_Hieuh                0x0eee
+#define XK_Hangul_J_Kiyeog               0x0ed4  /* U+11A8 HANGUL JONGSEONG KIYEOK */
+#define XK_Hangul_J_SsangKiyeog          0x0ed5  /* U+11A9 HANGUL JONGSEONG SSANGKIYEOK */
+#define XK_Hangul_J_KiyeogSios           0x0ed6  /* U+11AA HANGUL JONGSEONG KIYEOK-SIOS */
+#define XK_Hangul_J_Nieun                0x0ed7  /* U+11AB HANGUL JONGSEONG NIEUN */
+#define XK_Hangul_J_NieunJieuj           0x0ed8  /* U+11AC HANGUL JONGSEONG NIEUN-CIEUC */
+#define XK_Hangul_J_NieunHieuh           0x0ed9  /* U+11AD HANGUL JONGSEONG NIEUN-HIEUH */
+#define XK_Hangul_J_Dikeud               0x0eda  /* U+11AE HANGUL JONGSEONG TIKEUT */
+#define XK_Hangul_J_Rieul                0x0edb  /* U+11AF HANGUL JONGSEONG RIEUL */
+#define XK_Hangul_J_RieulKiyeog          0x0edc  /* U+11B0 HANGUL JONGSEONG RIEUL-KIYEOK */
+#define XK_Hangul_J_RieulMieum           0x0edd  /* U+11B1 HANGUL JONGSEONG RIEUL-MIEUM */
+#define XK_Hangul_J_RieulPieub           0x0ede  /* U+11B2 HANGUL JONGSEONG RIEUL-PIEUP */
+#define XK_Hangul_J_RieulSios            0x0edf  /* U+11B3 HANGUL JONGSEONG RIEUL-SIOS */
+#define XK_Hangul_J_RieulTieut           0x0ee0  /* U+11B4 HANGUL JONGSEONG RIEUL-THIEUTH */
+#define XK_Hangul_J_RieulPhieuf          0x0ee1  /* U+11B5 HANGUL JONGSEONG RIEUL-PHIEUPH */
+#define XK_Hangul_J_RieulHieuh           0x0ee2  /* U+11B6 HANGUL JONGSEONG RIEUL-HIEUH */
+#define XK_Hangul_J_Mieum                0x0ee3  /* U+11B7 HANGUL JONGSEONG MIEUM */
+#define XK_Hangul_J_Pieub                0x0ee4  /* U+11B8 HANGUL JONGSEONG PIEUP */
+#define XK_Hangul_J_PieubSios            0x0ee5  /* U+11B9 HANGUL JONGSEONG PIEUP-SIOS */
+#define XK_Hangul_J_Sios                 0x0ee6  /* U+11BA HANGUL JONGSEONG SIOS */
+#define XK_Hangul_J_SsangSios            0x0ee7  /* U+11BB HANGUL JONGSEONG SSANGSIOS */
+#define XK_Hangul_J_Ieung                0x0ee8  /* U+11BC HANGUL JONGSEONG IEUNG */
+#define XK_Hangul_J_Jieuj                0x0ee9  /* U+11BD HANGUL JONGSEONG CIEUC */
+#define XK_Hangul_J_Cieuc                0x0eea  /* U+11BE HANGUL JONGSEONG CHIEUCH */
+#define XK_Hangul_J_Khieuq               0x0eeb  /* U+11BF HANGUL JONGSEONG KHIEUKH */
+#define XK_Hangul_J_Tieut                0x0eec  /* U+11C0 HANGUL JONGSEONG THIEUTH */
+#define XK_Hangul_J_Phieuf               0x0eed  /* U+11C1 HANGUL JONGSEONG PHIEUPH */
+#define XK_Hangul_J_Hieuh                0x0eee  /* U+11C2 HANGUL JONGSEONG HIEUH */
 
 /* Ancient Hangul Consonant Characters */
-#define XK_Hangul_RieulYeorinHieuh       0x0eef
-#define XK_Hangul_SunkyeongeumMieum      0x0ef0
-#define XK_Hangul_SunkyeongeumPieub      0x0ef1
-#define XK_Hangul_PanSios                0x0ef2
-#define XK_Hangul_KkogjiDalrinIeung      0x0ef3
-#define XK_Hangul_SunkyeongeumPhieuf     0x0ef4
-#define XK_Hangul_YeorinHieuh            0x0ef5
+#define XK_Hangul_RieulYeorinHieuh       0x0eef  /* U+316D HANGUL LETTER RIEUL-YEORINHIEUH */
+#define XK_Hangul_SunkyeongeumMieum      0x0ef0  /* U+3171 HANGUL LETTER KAPYEOUNMIEUM */
+#define XK_Hangul_SunkyeongeumPieub      0x0ef1  /* U+3178 HANGUL LETTER KAPYEOUNPIEUP */
+#define XK_Hangul_PanSios                0x0ef2  /* U+317F HANGUL LETTER PANSIOS */
+#define XK_Hangul_KkogjiDalrinIeung      0x0ef3  /* U+3181 HANGUL LETTER YESIEUNG */
+#define XK_Hangul_SunkyeongeumPhieuf     0x0ef4  /* U+3184 HANGUL LETTER KAPYEOUNPHIEUPH */
+#define XK_Hangul_YeorinHieuh            0x0ef5  /* U+3186 HANGUL LETTER YEORINHIEUH */
 
 /* Ancient Hangul Vowel Characters */
-#define XK_Hangul_AraeA                  0x0ef6
-#define XK_Hangul_AraeAE                 0x0ef7
+#define XK_Hangul_AraeA                  0x0ef6  /* U+318D HANGUL LETTER ARAEA */
+#define XK_Hangul_AraeAE                 0x0ef7  /* U+318E HANGUL LETTER ARAEAE */
 
 /* Ancient Hangul syllable-final (JongSeong) Characters */
-#define XK_Hangul_J_PanSios              0x0ef8
-#define XK_Hangul_J_KkogjiDalrinIeung    0x0ef9
-#define XK_Hangul_J_YeorinHieuh          0x0efa
+#define XK_Hangul_J_PanSios              0x0ef8  /* U+11EB HANGUL JONGSEONG PANSIOS */
+#define XK_Hangul_J_KkogjiDalrinIeung    0x0ef9  /* U+11F0 HANGUL JONGSEONG YESIEUNG */
+#define XK_Hangul_J_YeorinHieuh          0x0efa  /* U+11F9 HANGUL JONGSEONG YEORINHIEUH */
 
 /* Korean currency symbol */
 #define XK_Korean_Won                    0x0eff  /*(U+20A9 WON SIGN)*/
 
 #endif /* XK_KOREAN */
 
-/*
- * Armenian
- */
-
-#ifdef XK_ARMENIAN
-#define XK_Armenian_ligature_ew       0x1000587  /* U+0587 ARMENIAN SMALL LIGATURE ECH YIWN */
-#define XK_Armenian_full_stop         0x1000589  /* U+0589 ARMENIAN FULL STOP */
-#define XK_Armenian_verjaket          0x1000589  /* U+0589 ARMENIAN FULL STOP */
-#define XK_Armenian_separation_mark   0x100055d  /* U+055D ARMENIAN COMMA */
-#define XK_Armenian_but               0x100055d  /* U+055D ARMENIAN COMMA */
-#define XK_Armenian_hyphen            0x100058a  /* U+058A ARMENIAN HYPHEN */
-#define XK_Armenian_yentamna          0x100058a  /* U+058A ARMENIAN HYPHEN */
-#define XK_Armenian_exclam            0x100055c  /* U+055C ARMENIAN EXCLAMATION MARK */
-#define XK_Armenian_amanak            0x100055c  /* U+055C ARMENIAN EXCLAMATION MARK */
-#define XK_Armenian_accent            0x100055b  /* U+055B ARMENIAN EMPHASIS MARK */
-#define XK_Armenian_shesht            0x100055b  /* U+055B ARMENIAN EMPHASIS MARK */
-#define XK_Armenian_question          0x100055e  /* U+055E ARMENIAN QUESTION MARK */
-#define XK_Armenian_paruyk            0x100055e  /* U+055E ARMENIAN QUESTION MARK */
-#define XK_Armenian_AYB               0x1000531  /* U+0531 ARMENIAN CAPITAL LETTER AYB */
-#define XK_Armenian_ayb               0x1000561  /* U+0561 ARMENIAN SMALL LETTER AYB */
-#define XK_Armenian_BEN               0x1000532  /* U+0532 ARMENIAN CAPITAL LETTER BEN */
-#define XK_Armenian_ben               0x1000562  /* U+0562 ARMENIAN SMALL LETTER BEN */
-#define XK_Armenian_GIM               0x1000533  /* U+0533 ARMENIAN CAPITAL LETTER GIM */
-#define XK_Armenian_gim               0x1000563  /* U+0563 ARMENIAN SMALL LETTER GIM */
-#define XK_Armenian_DA                0x1000534  /* U+0534 ARMENIAN CAPITAL LETTER DA */
-#define XK_Armenian_da                0x1000564  /* U+0564 ARMENIAN SMALL LETTER DA */
-#define XK_Armenian_YECH              0x1000535  /* U+0535 ARMENIAN CAPITAL LETTER ECH */
-#define XK_Armenian_yech              0x1000565  /* U+0565 ARMENIAN SMALL LETTER ECH */
-#define XK_Armenian_ZA                0x1000536  /* U+0536 ARMENIAN CAPITAL LETTER ZA */
-#define XK_Armenian_za                0x1000566  /* U+0566 ARMENIAN SMALL LETTER ZA */
-#define XK_Armenian_E                 0x1000537  /* U+0537 ARMENIAN CAPITAL LETTER EH */
-#define XK_Armenian_e                 0x1000567  /* U+0567 ARMENIAN SMALL LETTER EH */
-#define XK_Armenian_AT                0x1000538  /* U+0538 ARMENIAN CAPITAL LETTER ET */
-#define XK_Armenian_at                0x1000568  /* U+0568 ARMENIAN SMALL LETTER ET */
-#define XK_Armenian_TO                0x1000539  /* U+0539 ARMENIAN CAPITAL LETTER TO */
-#define XK_Armenian_to                0x1000569  /* U+0569 ARMENIAN SMALL LETTER TO */
-#define XK_Armenian_ZHE               0x100053a  /* U+053A ARMENIAN CAPITAL LETTER ZHE */
-#define XK_Armenian_zhe               0x100056a  /* U+056A ARMENIAN SMALL LETTER ZHE */
-#define XK_Armenian_INI               0x100053b  /* U+053B ARMENIAN CAPITAL LETTER INI */
-#define XK_Armenian_ini               0x100056b  /* U+056B ARMENIAN SMALL LETTER INI */
-#define XK_Armenian_LYUN              0x100053c  /* U+053C ARMENIAN CAPITAL LETTER LIWN */
-#define XK_Armenian_lyun              0x100056c  /* U+056C ARMENIAN SMALL LETTER LIWN */
-#define XK_Armenian_KHE               0x100053d  /* U+053D ARMENIAN CAPITAL LETTER XEH */
-#define XK_Armenian_khe               0x100056d  /* U+056D ARMENIAN SMALL LETTER XEH */
-#define XK_Armenian_TSA               0x100053e  /* U+053E ARMENIAN CAPITAL LETTER CA */
-#define XK_Armenian_tsa               0x100056e  /* U+056E ARMENIAN SMALL LETTER CA */
-#define XK_Armenian_KEN               0x100053f  /* U+053F ARMENIAN CAPITAL LETTER KEN */
-#define XK_Armenian_ken               0x100056f  /* U+056F ARMENIAN SMALL LETTER KEN */
-#define XK_Armenian_HO                0x1000540  /* U+0540 ARMENIAN CAPITAL LETTER HO */
-#define XK_Armenian_ho                0x1000570  /* U+0570 ARMENIAN SMALL LETTER HO */
-#define XK_Armenian_DZA               0x1000541  /* U+0541 ARMENIAN CAPITAL LETTER JA */
-#define XK_Armenian_dza               0x1000571  /* U+0571 ARMENIAN SMALL LETTER JA */
-#define XK_Armenian_GHAT              0x1000542  /* U+0542 ARMENIAN CAPITAL LETTER GHAD */
-#define XK_Armenian_ghat              0x1000572  /* U+0572 ARMENIAN SMALL LETTER GHAD */
-#define XK_Armenian_TCHE              0x1000543  /* U+0543 ARMENIAN CAPITAL LETTER CHEH */
-#define XK_Armenian_tche              0x1000573  /* U+0573 ARMENIAN SMALL LETTER CHEH */
-#define XK_Armenian_MEN               0x1000544  /* U+0544 ARMENIAN CAPITAL LETTER MEN */
-#define XK_Armenian_men               0x1000574  /* U+0574 ARMENIAN SMALL LETTER MEN */
-#define XK_Armenian_HI                0x1000545  /* U+0545 ARMENIAN CAPITAL LETTER YI */
-#define XK_Armenian_hi                0x1000575  /* U+0575 ARMENIAN SMALL LETTER YI */
-#define XK_Armenian_NU                0x1000546  /* U+0546 ARMENIAN CAPITAL LETTER NOW */
-#define XK_Armenian_nu                0x1000576  /* U+0576 ARMENIAN SMALL LETTER NOW */
-#define XK_Armenian_SHA               0x1000547  /* U+0547 ARMENIAN CAPITAL LETTER SHA */
-#define XK_Armenian_sha               0x1000577  /* U+0577 ARMENIAN SMALL LETTER SHA */
-#define XK_Armenian_VO                0x1000548  /* U+0548 ARMENIAN CAPITAL LETTER VO */
-#define XK_Armenian_vo                0x1000578  /* U+0578 ARMENIAN SMALL LETTER VO */
-#define XK_Armenian_CHA               0x1000549  /* U+0549 ARMENIAN CAPITAL LETTER CHA */
-#define XK_Armenian_cha               0x1000579  /* U+0579 ARMENIAN SMALL LETTER CHA */
-#define XK_Armenian_PE                0x100054a  /* U+054A ARMENIAN CAPITAL LETTER PEH */
-#define XK_Armenian_pe                0x100057a  /* U+057A ARMENIAN SMALL LETTER PEH */
-#define XK_Armenian_JE                0x100054b  /* U+054B ARMENIAN CAPITAL LETTER JHEH */
-#define XK_Armenian_je                0x100057b  /* U+057B ARMENIAN SMALL LETTER JHEH */
-#define XK_Armenian_RA                0x100054c  /* U+054C ARMENIAN CAPITAL LETTER RA */
-#define XK_Armenian_ra                0x100057c  /* U+057C ARMENIAN SMALL LETTER RA */
-#define XK_Armenian_SE                0x100054d  /* U+054D ARMENIAN CAPITAL LETTER SEH */
-#define XK_Armenian_se                0x100057d  /* U+057D ARMENIAN SMALL LETTER SEH */
-#define XK_Armenian_VEV               0x100054e  /* U+054E ARMENIAN CAPITAL LETTER VEW */
-#define XK_Armenian_vev               0x100057e  /* U+057E ARMENIAN SMALL LETTER VEW */
-#define XK_Armenian_TYUN              0x100054f  /* U+054F ARMENIAN CAPITAL LETTER TIWN */
-#define XK_Armenian_tyun              0x100057f  /* U+057F ARMENIAN SMALL LETTER TIWN */
-#define XK_Armenian_RE                0x1000550  /* U+0550 ARMENIAN CAPITAL LETTER REH */
-#define XK_Armenian_re                0x1000580  /* U+0580 ARMENIAN SMALL LETTER REH */
-#define XK_Armenian_TSO               0x1000551  /* U+0551 ARMENIAN CAPITAL LETTER CO */
-#define XK_Armenian_tso               0x1000581  /* U+0581 ARMENIAN SMALL LETTER CO */
-#define XK_Armenian_VYUN              0x1000552  /* U+0552 ARMENIAN CAPITAL LETTER YIWN */
-#define XK_Armenian_vyun              0x1000582  /* U+0582 ARMENIAN SMALL LETTER YIWN */
-#define XK_Armenian_PYUR              0x1000553  /* U+0553 ARMENIAN CAPITAL LETTER PIWR */
-#define XK_Armenian_pyur              0x1000583  /* U+0583 ARMENIAN SMALL LETTER PIWR */
-#define XK_Armenian_KE                0x1000554  /* U+0554 ARMENIAN CAPITAL LETTER KEH */
-#define XK_Armenian_ke                0x1000584  /* U+0584 ARMENIAN SMALL LETTER KEH */
-#define XK_Armenian_O                 0x1000555  /* U+0555 ARMENIAN CAPITAL LETTER OH */
-#define XK_Armenian_o                 0x1000585  /* U+0585 ARMENIAN SMALL LETTER OH */
-#define XK_Armenian_FE                0x1000556  /* U+0556 ARMENIAN CAPITAL LETTER FEH */
-#define XK_Armenian_fe                0x1000586  /* U+0586 ARMENIAN SMALL LETTER FEH */
-#define XK_Armenian_apostrophe        0x100055a  /* U+055A ARMENIAN APOSTROPHE */
-#endif /* XK_ARMENIAN */
-
-/*
- * Georgian
- */
-
-#ifdef XK_GEORGIAN
-#define XK_Georgian_an                0x10010d0  /* U+10D0 GEORGIAN LETTER AN */
-#define XK_Georgian_ban               0x10010d1  /* U+10D1 GEORGIAN LETTER BAN */
-#define XK_Georgian_gan               0x10010d2  /* U+10D2 GEORGIAN LETTER GAN */
-#define XK_Georgian_don               0x10010d3  /* U+10D3 GEORGIAN LETTER DON */
-#define XK_Georgian_en                0x10010d4  /* U+10D4 GEORGIAN LETTER EN */
-#define XK_Georgian_vin               0x10010d5  /* U+10D5 GEORGIAN LETTER VIN */
-#define XK_Georgian_zen               0x10010d6  /* U+10D6 GEORGIAN LETTER ZEN */
-#define XK_Georgian_tan               0x10010d7  /* U+10D7 GEORGIAN LETTER TAN */
-#define XK_Georgian_in                0x10010d8  /* U+10D8 GEORGIAN LETTER IN */
-#define XK_Georgian_kan               0x10010d9  /* U+10D9 GEORGIAN LETTER KAN */
-#define XK_Georgian_las               0x10010da  /* U+10DA GEORGIAN LETTER LAS */
-#define XK_Georgian_man               0x10010db  /* U+10DB GEORGIAN LETTER MAN */
-#define XK_Georgian_nar               0x10010dc  /* U+10DC GEORGIAN LETTER NAR */
-#define XK_Georgian_on                0x10010dd  /* U+10DD GEORGIAN LETTER ON */
-#define XK_Georgian_par               0x10010de  /* U+10DE GEORGIAN LETTER PAR */
-#define XK_Georgian_zhar              0x10010df  /* U+10DF GEORGIAN LETTER ZHAR */
-#define XK_Georgian_rae               0x10010e0  /* U+10E0 GEORGIAN LETTER RAE */
-#define XK_Georgian_san               0x10010e1  /* U+10E1 GEORGIAN LETTER SAN */
-#define XK_Georgian_tar               0x10010e2  /* U+10E2 GEORGIAN LETTER TAR */
-#define XK_Georgian_un                0x10010e3  /* U+10E3 GEORGIAN LETTER UN */
-#define XK_Georgian_phar              0x10010e4  /* U+10E4 GEORGIAN LETTER PHAR */
-#define XK_Georgian_khar              0x10010e5  /* U+10E5 GEORGIAN LETTER KHAR */
-#define XK_Georgian_ghan              0x10010e6  /* U+10E6 GEORGIAN LETTER GHAN */
-#define XK_Georgian_qar               0x10010e7  /* U+10E7 GEORGIAN LETTER QAR */
-#define XK_Georgian_shin              0x10010e8  /* U+10E8 GEORGIAN LETTER SHIN */
-#define XK_Georgian_chin              0x10010e9  /* U+10E9 GEORGIAN LETTER CHIN */
-#define XK_Georgian_can               0x10010ea  /* U+10EA GEORGIAN LETTER CAN */
-#define XK_Georgian_jil               0x10010eb  /* U+10EB GEORGIAN LETTER JIL */
-#define XK_Georgian_cil               0x10010ec  /* U+10EC GEORGIAN LETTER CIL */
-#define XK_Georgian_char              0x10010ed  /* U+10ED GEORGIAN LETTER CHAR */
-#define XK_Georgian_xan               0x10010ee  /* U+10EE GEORGIAN LETTER XAN */
-#define XK_Georgian_jhan              0x10010ef  /* U+10EF GEORGIAN LETTER JHAN */
-#define XK_Georgian_hae               0x10010f0  /* U+10F0 GEORGIAN LETTER HAE */
-#define XK_Georgian_he                0x10010f1  /* U+10F1 GEORGIAN LETTER HE */
-#define XK_Georgian_hie               0x10010f2  /* U+10F2 GEORGIAN LETTER HIE */
-#define XK_Georgian_we                0x10010f3  /* U+10F3 GEORGIAN LETTER WE */
-#define XK_Georgian_har               0x10010f4  /* U+10F4 GEORGIAN LETTER HAR */
-#define XK_Georgian_hoe               0x10010f5  /* U+10F5 GEORGIAN LETTER HOE */
-#define XK_Georgian_fi                0x10010f6  /* U+10F6 GEORGIAN LETTER FI */
-#endif /* XK_GEORGIAN */
-
-/*
- * Azeri (and other Turkic or Caucasian languages)
- */
-
-#ifdef XK_CAUCASUS
-/* latin */
-#define XK_Xabovedot                  0x1001e8a  /* U+1E8A LATIN CAPITAL LETTER X WITH DOT ABOVE */
-#define XK_Ibreve                     0x100012c  /* U+012C LATIN CAPITAL LETTER I WITH BREVE */
-#define XK_Zstroke                    0x10001b5  /* U+01B5 LATIN CAPITAL LETTER Z WITH STROKE */
-#define XK_Gcaron                     0x10001e6  /* U+01E6 LATIN CAPITAL LETTER G WITH CARON */
-#define XK_Ocaron                     0x10001d1  /* U+01D1 LATIN CAPITAL LETTER O WITH CARON */
-#define XK_Obarred                    0x100019f  /* U+019F LATIN CAPITAL LETTER O WITH MIDDLE TILDE */
-#define XK_xabovedot                  0x1001e8b  /* U+1E8B LATIN SMALL LETTER X WITH DOT ABOVE */
-#define XK_ibreve                     0x100012d  /* U+012D LATIN SMALL LETTER I WITH BREVE */
-#define XK_zstroke                    0x10001b6  /* U+01B6 LATIN SMALL LETTER Z WITH STROKE */
-#define XK_gcaron                     0x10001e7  /* U+01E7 LATIN SMALL LETTER G WITH CARON */
-#define XK_ocaron                     0x10001d2  /* U+01D2 LATIN SMALL LETTER O WITH CARON */
-#define XK_obarred                    0x1000275  /* U+0275 LATIN SMALL LETTER BARRED O */
-#define XK_SCHWA                      0x100018f  /* U+018F LATIN CAPITAL LETTER SCHWA */
-#define XK_schwa                      0x1000259  /* U+0259 LATIN SMALL LETTER SCHWA */
-#define XK_EZH                        0x10001b7  /* U+01B7 LATIN CAPITAL LETTER EZH */
-#define XK_ezh                        0x1000292  /* U+0292 LATIN SMALL LETTER EZH */
-/* those are not really Caucasus */
-/* For Inupiak */
-#define XK_Lbelowdot                  0x1001e36  /* U+1E36 LATIN CAPITAL LETTER L WITH DOT BELOW */
-#define XK_lbelowdot                  0x1001e37  /* U+1E37 LATIN SMALL LETTER L WITH DOT BELOW */
-#endif /* XK_CAUCASUS */
-
-/*
- * Vietnamese
- */
-
-#ifdef XK_VIETNAMESE
-#define XK_Abelowdot                  0x1001ea0  /* U+1EA0 LATIN CAPITAL LETTER A WITH DOT BELOW */
-#define XK_abelowdot                  0x1001ea1  /* U+1EA1 LATIN SMALL LETTER A WITH DOT BELOW */
-#define XK_Ahook                      0x1001ea2  /* U+1EA2 LATIN CAPITAL LETTER A WITH HOOK ABOVE */
-#define XK_ahook                      0x1001ea3  /* U+1EA3 LATIN SMALL LETTER A WITH HOOK ABOVE */
-#define XK_Acircumflexacute           0x1001ea4  /* U+1EA4 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE */
-#define XK_acircumflexacute           0x1001ea5  /* U+1EA5 LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE */
-#define XK_Acircumflexgrave           0x1001ea6  /* U+1EA6 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE */
-#define XK_acircumflexgrave           0x1001ea7  /* U+1EA7 LATIN SMALL LETTER A WITH CIRCUMFLEX AND GRAVE */
-#define XK_Acircumflexhook            0x1001ea8  /* U+1EA8 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE */
-#define XK_acircumflexhook            0x1001ea9  /* U+1EA9 LATIN SMALL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE */
-#define XK_Acircumflextilde           0x1001eaa  /* U+1EAA LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE */
-#define XK_acircumflextilde           0x1001eab  /* U+1EAB LATIN SMALL LETTER A WITH CIRCUMFLEX AND TILDE */
-#define XK_Acircumflexbelowdot        0x1001eac  /* U+1EAC LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND DOT BELOW */
-#define XK_acircumflexbelowdot        0x1001ead  /* U+1EAD LATIN SMALL LETTER A WITH CIRCUMFLEX AND DOT BELOW */
-#define XK_Abreveacute                0x1001eae  /* U+1EAE LATIN CAPITAL LETTER A WITH BREVE AND ACUTE */
-#define XK_abreveacute                0x1001eaf  /* U+1EAF LATIN SMALL LETTER A WITH BREVE AND ACUTE */
-#define XK_Abrevegrave                0x1001eb0  /* U+1EB0 LATIN CAPITAL LETTER A WITH BREVE AND GRAVE */
-#define XK_abrevegrave                0x1001eb1  /* U+1EB1 LATIN SMALL LETTER A WITH BREVE AND GRAVE */
-#define XK_Abrevehook                 0x1001eb2  /* U+1EB2 LATIN CAPITAL LETTER A WITH BREVE AND HOOK ABOVE */
-#define XK_abrevehook                 0x1001eb3  /* U+1EB3 LATIN SMALL LETTER A WITH BREVE AND HOOK ABOVE */
-#define XK_Abrevetilde                0x1001eb4  /* U+1EB4 LATIN CAPITAL LETTER A WITH BREVE AND TILDE */
-#define XK_abrevetilde                0x1001eb5  /* U+1EB5 LATIN SMALL LETTER A WITH BREVE AND TILDE */
-#define XK_Abrevebelowdot             0x1001eb6  /* U+1EB6 LATIN CAPITAL LETTER A WITH BREVE AND DOT BELOW */
-#define XK_abrevebelowdot             0x1001eb7  /* U+1EB7 LATIN SMALL LETTER A WITH BREVE AND DOT BELOW */
-#define XK_Ebelowdot                  0x1001eb8  /* U+1EB8 LATIN CAPITAL LETTER E WITH DOT BELOW */
-#define XK_ebelowdot                  0x1001eb9  /* U+1EB9 LATIN SMALL LETTER E WITH DOT BELOW */
-#define XK_Ehook                      0x1001eba  /* U+1EBA LATIN CAPITAL LETTER E WITH HOOK ABOVE */
-#define XK_ehook                      0x1001ebb  /* U+1EBB LATIN SMALL LETTER E WITH HOOK ABOVE */
-#define XK_Etilde                     0x1001ebc  /* U+1EBC LATIN CAPITAL LETTER E WITH TILDE */
-#define XK_etilde                     0x1001ebd  /* U+1EBD LATIN SMALL LETTER E WITH TILDE */
-#define XK_Ecircumflexacute           0x1001ebe  /* U+1EBE LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE */
-#define XK_ecircumflexacute           0x1001ebf  /* U+1EBF LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE */
-#define XK_Ecircumflexgrave           0x1001ec0  /* U+1EC0 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE */
-#define XK_ecircumflexgrave           0x1001ec1  /* U+1EC1 LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE */
-#define XK_Ecircumflexhook            0x1001ec2  /* U+1EC2 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE */
-#define XK_ecircumflexhook            0x1001ec3  /* U+1EC3 LATIN SMALL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE */
-#define XK_Ecircumflextilde           0x1001ec4  /* U+1EC4 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE */
-#define XK_ecircumflextilde           0x1001ec5  /* U+1EC5 LATIN SMALL LETTER E WITH CIRCUMFLEX AND TILDE */
-#define XK_Ecircumflexbelowdot        0x1001ec6  /* U+1EC6 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW */
-#define XK_ecircumflexbelowdot        0x1001ec7  /* U+1EC7 LATIN SMALL LETTER E WITH CIRCUMFLEX AND DOT BELOW */
-#define XK_Ihook                      0x1001ec8  /* U+1EC8 LATIN CAPITAL LETTER I WITH HOOK ABOVE */
-#define XK_ihook                      0x1001ec9  /* U+1EC9 LATIN SMALL LETTER I WITH HOOK ABOVE */
-#define XK_Ibelowdot                  0x1001eca  /* U+1ECA LATIN CAPITAL LETTER I WITH DOT BELOW */
-#define XK_ibelowdot                  0x1001ecb  /* U+1ECB LATIN SMALL LETTER I WITH DOT BELOW */
-#define XK_Obelowdot                  0x1001ecc  /* U+1ECC LATIN CAPITAL LETTER O WITH DOT BELOW */
-#define XK_obelowdot                  0x1001ecd  /* U+1ECD LATIN SMALL LETTER O WITH DOT BELOW */
-#define XK_Ohook                      0x1001ece  /* U+1ECE LATIN CAPITAL LETTER O WITH HOOK ABOVE */
-#define XK_ohook                      0x1001ecf  /* U+1ECF LATIN SMALL LETTER O WITH HOOK ABOVE */
-#define XK_Ocircumflexacute           0x1001ed0  /* U+1ED0 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE */
-#define XK_ocircumflexacute           0x1001ed1  /* U+1ED1 LATIN SMALL LETTER O WITH CIRCUMFLEX AND ACUTE */
-#define XK_Ocircumflexgrave           0x1001ed2  /* U+1ED2 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE */
-#define XK_ocircumflexgrave           0x1001ed3  /* U+1ED3 LATIN SMALL LETTER O WITH CIRCUMFLEX AND GRAVE */
-#define XK_Ocircumflexhook            0x1001ed4  /* U+1ED4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE */
-#define XK_ocircumflexhook            0x1001ed5  /* U+1ED5 LATIN SMALL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE */
-#define XK_Ocircumflextilde           0x1001ed6  /* U+1ED6 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE */
-#define XK_ocircumflextilde           0x1001ed7  /* U+1ED7 LATIN SMALL LETTER O WITH CIRCUMFLEX AND TILDE */
-#define XK_Ocircumflexbelowdot        0x1001ed8  /* U+1ED8 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND DOT BELOW */
-#define XK_ocircumflexbelowdot        0x1001ed9  /* U+1ED9 LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT BELOW */
-#define XK_Ohornacute                 0x1001eda  /* U+1EDA LATIN CAPITAL LETTER O WITH HORN AND ACUTE */
-#define XK_ohornacute                 0x1001edb  /* U+1EDB LATIN SMALL LETTER O WITH HORN AND ACUTE */
-#define XK_Ohorngrave                 0x1001edc  /* U+1EDC LATIN CAPITAL LETTER O WITH HORN AND GRAVE */
-#define XK_ohorngrave                 0x1001edd  /* U+1EDD LATIN SMALL LETTER O WITH HORN AND GRAVE */
-#define XK_Ohornhook                  0x1001ede  /* U+1EDE LATIN CAPITAL LETTER O WITH HORN AND HOOK ABOVE */
-#define XK_ohornhook                  0x1001edf  /* U+1EDF LATIN SMALL LETTER O WITH HORN AND HOOK ABOVE */
-#define XK_Ohorntilde                 0x1001ee0  /* U+1EE0 LATIN CAPITAL LETTER O WITH HORN AND TILDE */
-#define XK_ohorntilde                 0x1001ee1  /* U+1EE1 LATIN SMALL LETTER O WITH HORN AND TILDE */
-#define XK_Ohornbelowdot              0x1001ee2  /* U+1EE2 LATIN CAPITAL LETTER O WITH HORN AND DOT BELOW */
-#define XK_ohornbelowdot              0x1001ee3  /* U+1EE3 LATIN SMALL LETTER O WITH HORN AND DOT BELOW */
-#define XK_Ubelowdot                  0x1001ee4  /* U+1EE4 LATIN CAPITAL LETTER U WITH DOT BELOW */
-#define XK_ubelowdot                  0x1001ee5  /* U+1EE5 LATIN SMALL LETTER U WITH DOT BELOW */
-#define XK_Uhook                      0x1001ee6  /* U+1EE6 LATIN CAPITAL LETTER U WITH HOOK ABOVE */
-#define XK_uhook                      0x1001ee7  /* U+1EE7 LATIN SMALL LETTER U WITH HOOK ABOVE */
-#define XK_Uhornacute                 0x1001ee8  /* U+1EE8 LATIN CAPITAL LETTER U WITH HORN AND ACUTE */
-#define XK_uhornacute                 0x1001ee9  /* U+1EE9 LATIN SMALL LETTER U WITH HORN AND ACUTE */
-#define XK_Uhorngrave                 0x1001eea  /* U+1EEA LATIN CAPITAL LETTER U WITH HORN AND GRAVE */
-#define XK_uhorngrave                 0x1001eeb  /* U+1EEB LATIN SMALL LETTER U WITH HORN AND GRAVE */
-#define XK_Uhornhook                  0x1001eec  /* U+1EEC LATIN CAPITAL LETTER U WITH HORN AND HOOK ABOVE */
-#define XK_uhornhook                  0x1001eed  /* U+1EED LATIN SMALL LETTER U WITH HORN AND HOOK ABOVE */
-#define XK_Uhorntilde                 0x1001eee  /* U+1EEE LATIN CAPITAL LETTER U WITH HORN AND TILDE */
-#define XK_uhorntilde                 0x1001eef  /* U+1EEF LATIN SMALL LETTER U WITH HORN AND TILDE */
-#define XK_Uhornbelowdot              0x1001ef0  /* U+1EF0 LATIN CAPITAL LETTER U WITH HORN AND DOT BELOW */
-#define XK_uhornbelowdot              0x1001ef1  /* U+1EF1 LATIN SMALL LETTER U WITH HORN AND DOT BELOW */
-#define XK_Ybelowdot                  0x1001ef4  /* U+1EF4 LATIN CAPITAL LETTER Y WITH DOT BELOW */
-#define XK_ybelowdot                  0x1001ef5  /* U+1EF5 LATIN SMALL LETTER Y WITH DOT BELOW */
-#define XK_Yhook                      0x1001ef6  /* U+1EF6 LATIN CAPITAL LETTER Y WITH HOOK ABOVE */
-#define XK_yhook                      0x1001ef7  /* U+1EF7 LATIN SMALL LETTER Y WITH HOOK ABOVE */
-#define XK_Ytilde                     0x1001ef8  /* U+1EF8 LATIN CAPITAL LETTER Y WITH TILDE */
-#define XK_ytilde                     0x1001ef9  /* U+1EF9 LATIN SMALL LETTER Y WITH TILDE */
-#define XK_Ohorn                      0x10001a0  /* U+01A0 LATIN CAPITAL LETTER O WITH HORN */
-#define XK_ohorn                      0x10001a1  /* U+01A1 LATIN SMALL LETTER O WITH HORN */
-#define XK_Uhorn                      0x10001af  /* U+01AF LATIN CAPITAL LETTER U WITH HORN */
-#define XK_uhorn                      0x10001b0  /* U+01B0 LATIN SMALL LETTER U WITH HORN */
-
-#endif /* XK_VIETNAMESE */
-
 #ifdef XK_CURRENCY
-#define XK_EcuSign                    0x10020a0  /* U+20A0 EURO-CURRENCY SIGN */
-#define XK_ColonSign                  0x10020a1  /* U+20A1 COLON SIGN */
-#define XK_CruzeiroSign               0x10020a2  /* U+20A2 CRUZEIRO SIGN */
-#define XK_FFrancSign                 0x10020a3  /* U+20A3 FRENCH FRANC SIGN */
-#define XK_LiraSign                   0x10020a4  /* U+20A4 LIRA SIGN */
-#define XK_MillSign                   0x10020a5  /* U+20A5 MILL SIGN */
-#define XK_NairaSign                  0x10020a6  /* U+20A6 NAIRA SIGN */
-#define XK_PesetaSign                 0x10020a7  /* U+20A7 PESETA SIGN */
-#define XK_RupeeSign                  0x10020a8  /* U+20A8 RUPEE SIGN */
-#define XK_WonSign                    0x10020a9  /* U+20A9 WON SIGN */
-#define XK_NewSheqelSign              0x10020aa  /* U+20AA NEW SHEQEL SIGN */
-#define XK_DongSign                   0x10020ab  /* U+20AB DONG SIGN */
 #define XK_EuroSign                      0x20ac  /* U+20AC EURO SIGN */
 #endif /* XK_CURRENCY */
 
-#ifdef XK_MATHEMATICAL
-/* one, two and three are defined above. */
-#define XK_zerosuperior               0x1002070  /* U+2070 SUPERSCRIPT ZERO */
-#define XK_foursuperior               0x1002074  /* U+2074 SUPERSCRIPT FOUR */
-#define XK_fivesuperior               0x1002075  /* U+2075 SUPERSCRIPT FIVE */
-#define XK_sixsuperior                0x1002076  /* U+2076 SUPERSCRIPT SIX */
-#define XK_sevensuperior              0x1002077  /* U+2077 SUPERSCRIPT SEVEN */
-#define XK_eightsuperior              0x1002078  /* U+2078 SUPERSCRIPT EIGHT */
-#define XK_ninesuperior               0x1002079  /* U+2079 SUPERSCRIPT NINE */
-#define XK_zerosubscript              0x1002080  /* U+2080 SUBSCRIPT ZERO */
-#define XK_onesubscript               0x1002081  /* U+2081 SUBSCRIPT ONE */
-#define XK_twosubscript               0x1002082  /* U+2082 SUBSCRIPT TWO */
-#define XK_threesubscript             0x1002083  /* U+2083 SUBSCRIPT THREE */
-#define XK_foursubscript              0x1002084  /* U+2084 SUBSCRIPT FOUR */
-#define XK_fivesubscript              0x1002085  /* U+2085 SUBSCRIPT FIVE */
-#define XK_sixsubscript               0x1002086  /* U+2086 SUBSCRIPT SIX */
-#define XK_sevensubscript             0x1002087  /* U+2087 SUBSCRIPT SEVEN */
-#define XK_eightsubscript             0x1002088  /* U+2088 SUBSCRIPT EIGHT */
-#define XK_ninesubscript              0x1002089  /* U+2089 SUBSCRIPT NINE */
-#define XK_partdifferential           0x1002202  /* U+2202 PARTIAL DIFFERENTIAL */
-#define XK_emptyset                   0x1002205  /* U+2205 NULL SET */
-#define XK_elementof                  0x1002208  /* U+2208 ELEMENT OF */
-#define XK_notelementof               0x1002209  /* U+2209 NOT AN ELEMENT OF */
-#define XK_containsas                 0x100220B  /* U+220B CONTAINS AS MEMBER */
-#define XK_squareroot                 0x100221A  /* U+221A SQUARE ROOT */
-#define XK_cuberoot                   0x100221B  /* U+221B CUBE ROOT */
-#define XK_fourthroot                 0x100221C  /* U+221C FOURTH ROOT */
-#define XK_dintegral                  0x100222C  /* U+222C DOUBLE INTEGRAL */
-#define XK_tintegral                  0x100222D  /* U+222D TRIPLE INTEGRAL */
-#define XK_because                    0x1002235  /* U+2235 BECAUSE */
-#define XK_approxeq                   0x1002248  /* U+2245 ALMOST EQUAL TO */
-#define XK_notapproxeq                0x1002247  /* U+2247 NOT ALMOST EQUAL TO */
-#define XK_notidentical               0x1002262  /* U+2262 NOT IDENTICAL TO */
-#define XK_stricteq                   0x1002263  /* U+2263 STRICTLY EQUIVALENT TO */
-#endif /* XK_MATHEMATICAL */
-
 #ifdef XK_BRAILLE
 #define XK_braille_dot_1                 0xfff1
 #define XK_braille_dot_2                 0xfff2
 #define XK_braille_dot_3                 0xfff3
 #define XK_braille_dot_4                 0xfff4
@@ -2153,356 +1733,12 @@
 #define XK_braille_dot_6                 0xfff6
 #define XK_braille_dot_7                 0xfff7
 #define XK_braille_dot_8                 0xfff8
 #define XK_braille_dot_9                 0xfff9
 #define XK_braille_dot_10                0xfffa
-#define XK_braille_blank              0x1002800  /* U+2800 BRAILLE PATTERN BLANK */
-#define XK_braille_dots_1             0x1002801  /* U+2801 BRAILLE PATTERN DOTS-1 */
-#define XK_braille_dots_2             0x1002802  /* U+2802 BRAILLE PATTERN DOTS-2 */
-#define XK_braille_dots_12            0x1002803  /* U+2803 BRAILLE PATTERN DOTS-12 */
-#define XK_braille_dots_3             0x1002804  /* U+2804 BRAILLE PATTERN DOTS-3 */
-#define XK_braille_dots_13            0x1002805  /* U+2805 BRAILLE PATTERN DOTS-13 */
-#define XK_braille_dots_23            0x1002806  /* U+2806 BRAILLE PATTERN DOTS-23 */
-#define XK_braille_dots_123           0x1002807  /* U+2807 BRAILLE PATTERN DOTS-123 */
-#define XK_braille_dots_4             0x1002808  /* U+2808 BRAILLE PATTERN DOTS-4 */
-#define XK_braille_dots_14            0x1002809  /* U+2809 BRAILLE PATTERN DOTS-14 */
-#define XK_braille_dots_24            0x100280a  /* U+280a BRAILLE PATTERN DOTS-24 */
-#define XK_braille_dots_124           0x100280b  /* U+280b BRAILLE PATTERN DOTS-124 */
-#define XK_braille_dots_34            0x100280c  /* U+280c BRAILLE PATTERN DOTS-34 */
-#define XK_braille_dots_134           0x100280d  /* U+280d BRAILLE PATTERN DOTS-134 */
-#define XK_braille_dots_234           0x100280e  /* U+280e BRAILLE PATTERN DOTS-234 */
-#define XK_braille_dots_1234          0x100280f  /* U+280f BRAILLE PATTERN DOTS-1234 */
-#define XK_braille_dots_5             0x1002810  /* U+2810 BRAILLE PATTERN DOTS-5 */
-#define XK_braille_dots_15            0x1002811  /* U+2811 BRAILLE PATTERN DOTS-15 */
-#define XK_braille_dots_25            0x1002812  /* U+2812 BRAILLE PATTERN DOTS-25 */
-#define XK_braille_dots_125           0x1002813  /* U+2813 BRAILLE PATTERN DOTS-125 */
-#define XK_braille_dots_35            0x1002814  /* U+2814 BRAILLE PATTERN DOTS-35 */
-#define XK_braille_dots_135           0x1002815  /* U+2815 BRAILLE PATTERN DOTS-135 */
-#define XK_braille_dots_235           0x1002816  /* U+2816 BRAILLE PATTERN DOTS-235 */
-#define XK_braille_dots_1235          0x1002817  /* U+2817 BRAILLE PATTERN DOTS-1235 */
-#define XK_braille_dots_45            0x1002818  /* U+2818 BRAILLE PATTERN DOTS-45 */
-#define XK_braille_dots_145           0x1002819  /* U+2819 BRAILLE PATTERN DOTS-145 */
-#define XK_braille_dots_245           0x100281a  /* U+281a BRAILLE PATTERN DOTS-245 */
-#define XK_braille_dots_1245          0x100281b  /* U+281b BRAILLE PATTERN DOTS-1245 */
-#define XK_braille_dots_345           0x100281c  /* U+281c BRAILLE PATTERN DOTS-345 */
-#define XK_braille_dots_1345          0x100281d  /* U+281d BRAILLE PATTERN DOTS-1345 */
-#define XK_braille_dots_2345          0x100281e  /* U+281e BRAILLE PATTERN DOTS-2345 */
-#define XK_braille_dots_12345         0x100281f  /* U+281f BRAILLE PATTERN DOTS-12345 */
-#define XK_braille_dots_6             0x1002820  /* U+2820 BRAILLE PATTERN DOTS-6 */
-#define XK_braille_dots_16            0x1002821  /* U+2821 BRAILLE PATTERN DOTS-16 */
-#define XK_braille_dots_26            0x1002822  /* U+2822 BRAILLE PATTERN DOTS-26 */
-#define XK_braille_dots_126           0x1002823  /* U+2823 BRAILLE PATTERN DOTS-126 */
-#define XK_braille_dots_36            0x1002824  /* U+2824 BRAILLE PATTERN DOTS-36 */
-#define XK_braille_dots_136           0x1002825  /* U+2825 BRAILLE PATTERN DOTS-136 */
-#define XK_braille_dots_236           0x1002826  /* U+2826 BRAILLE PATTERN DOTS-236 */
-#define XK_braille_dots_1236          0x1002827  /* U+2827 BRAILLE PATTERN DOTS-1236 */
-#define XK_braille_dots_46            0x1002828  /* U+2828 BRAILLE PATTERN DOTS-46 */
-#define XK_braille_dots_146           0x1002829  /* U+2829 BRAILLE PATTERN DOTS-146 */
-#define XK_braille_dots_246           0x100282a  /* U+282a BRAILLE PATTERN DOTS-246 */
-#define XK_braille_dots_1246          0x100282b  /* U+282b BRAILLE PATTERN DOTS-1246 */
-#define XK_braille_dots_346           0x100282c  /* U+282c BRAILLE PATTERN DOTS-346 */
-#define XK_braille_dots_1346          0x100282d  /* U+282d BRAILLE PATTERN DOTS-1346 */
-#define XK_braille_dots_2346          0x100282e  /* U+282e BRAILLE PATTERN DOTS-2346 */
-#define XK_braille_dots_12346         0x100282f  /* U+282f BRAILLE PATTERN DOTS-12346 */
-#define XK_braille_dots_56            0x1002830  /* U+2830 BRAILLE PATTERN DOTS-56 */
-#define XK_braille_dots_156           0x1002831  /* U+2831 BRAILLE PATTERN DOTS-156 */
-#define XK_braille_dots_256           0x1002832  /* U+2832 BRAILLE PATTERN DOTS-256 */
-#define XK_braille_dots_1256          0x1002833  /* U+2833 BRAILLE PATTERN DOTS-1256 */
-#define XK_braille_dots_356           0x1002834  /* U+2834 BRAILLE PATTERN DOTS-356 */
-#define XK_braille_dots_1356          0x1002835  /* U+2835 BRAILLE PATTERN DOTS-1356 */
-#define XK_braille_dots_2356          0x1002836  /* U+2836 BRAILLE PATTERN DOTS-2356 */
-#define XK_braille_dots_12356         0x1002837  /* U+2837 BRAILLE PATTERN DOTS-12356 */
-#define XK_braille_dots_456           0x1002838  /* U+2838 BRAILLE PATTERN DOTS-456 */
-#define XK_braille_dots_1456          0x1002839  /* U+2839 BRAILLE PATTERN DOTS-1456 */
-#define XK_braille_dots_2456          0x100283a  /* U+283a BRAILLE PATTERN DOTS-2456 */
-#define XK_braille_dots_12456         0x100283b  /* U+283b BRAILLE PATTERN DOTS-12456 */
-#define XK_braille_dots_3456          0x100283c  /* U+283c BRAILLE PATTERN DOTS-3456 */
-#define XK_braille_dots_13456         0x100283d  /* U+283d BRAILLE PATTERN DOTS-13456 */
-#define XK_braille_dots_23456         0x100283e  /* U+283e BRAILLE PATTERN DOTS-23456 */
-#define XK_braille_dots_123456        0x100283f  /* U+283f BRAILLE PATTERN DOTS-123456 */
-#define XK_braille_dots_7             0x1002840  /* U+2840 BRAILLE PATTERN DOTS-7 */
-#define XK_braille_dots_17            0x1002841  /* U+2841 BRAILLE PATTERN DOTS-17 */
-#define XK_braille_dots_27            0x1002842  /* U+2842 BRAILLE PATTERN DOTS-27 */
-#define XK_braille_dots_127           0x1002843  /* U+2843 BRAILLE PATTERN DOTS-127 */
-#define XK_braille_dots_37            0x1002844  /* U+2844 BRAILLE PATTERN DOTS-37 */
-#define XK_braille_dots_137           0x1002845  /* U+2845 BRAILLE PATTERN DOTS-137 */
-#define XK_braille_dots_237           0x1002846  /* U+2846 BRAILLE PATTERN DOTS-237 */
-#define XK_braille_dots_1237          0x1002847  /* U+2847 BRAILLE PATTERN DOTS-1237 */
-#define XK_braille_dots_47            0x1002848  /* U+2848 BRAILLE PATTERN DOTS-47 */
-#define XK_braille_dots_147           0x1002849  /* U+2849 BRAILLE PATTERN DOTS-147 */
-#define XK_braille_dots_247           0x100284a  /* U+284a BRAILLE PATTERN DOTS-247 */
-#define XK_braille_dots_1247          0x100284b  /* U+284b BRAILLE PATTERN DOTS-1247 */
-#define XK_braille_dots_347           0x100284c  /* U+284c BRAILLE PATTERN DOTS-347 */
-#define XK_braille_dots_1347          0x100284d  /* U+284d BRAILLE PATTERN DOTS-1347 */
-#define XK_braille_dots_2347          0x100284e  /* U+284e BRAILLE PATTERN DOTS-2347 */
-#define XK_braille_dots_12347         0x100284f  /* U+284f BRAILLE PATTERN DOTS-12347 */
-#define XK_braille_dots_57            0x1002850  /* U+2850 BRAILLE PATTERN DOTS-57 */
-#define XK_braille_dots_157           0x1002851  /* U+2851 BRAILLE PATTERN DOTS-157 */
-#define XK_braille_dots_257           0x1002852  /* U+2852 BRAILLE PATTERN DOTS-257 */
-#define XK_braille_dots_1257          0x1002853  /* U+2853 BRAILLE PATTERN DOTS-1257 */
-#define XK_braille_dots_357           0x1002854  /* U+2854 BRAILLE PATTERN DOTS-357 */
-#define XK_braille_dots_1357          0x1002855  /* U+2855 BRAILLE PATTERN DOTS-1357 */
-#define XK_braille_dots_2357          0x1002856  /* U+2856 BRAILLE PATTERN DOTS-2357 */
-#define XK_braille_dots_12357         0x1002857  /* U+2857 BRAILLE PATTERN DOTS-12357 */
-#define XK_braille_dots_457           0x1002858  /* U+2858 BRAILLE PATTERN DOTS-457 */
-#define XK_braille_dots_1457          0x1002859  /* U+2859 BRAILLE PATTERN DOTS-1457 */
-#define XK_braille_dots_2457          0x100285a  /* U+285a BRAILLE PATTERN DOTS-2457 */
-#define XK_braille_dots_12457         0x100285b  /* U+285b BRAILLE PATTERN DOTS-12457 */
-#define XK_braille_dots_3457          0x100285c  /* U+285c BRAILLE PATTERN DOTS-3457 */
-#define XK_braille_dots_13457         0x100285d  /* U+285d BRAILLE PATTERN DOTS-13457 */
-#define XK_braille_dots_23457         0x100285e  /* U+285e BRAILLE PATTERN DOTS-23457 */
-#define XK_braille_dots_123457        0x100285f  /* U+285f BRAILLE PATTERN DOTS-123457 */
-#define XK_braille_dots_67            0x1002860  /* U+2860 BRAILLE PATTERN DOTS-67 */
-#define XK_braille_dots_167           0x1002861  /* U+2861 BRAILLE PATTERN DOTS-167 */
-#define XK_braille_dots_267           0x1002862  /* U+2862 BRAILLE PATTERN DOTS-267 */
-#define XK_braille_dots_1267          0x1002863  /* U+2863 BRAILLE PATTERN DOTS-1267 */
-#define XK_braille_dots_367           0x1002864  /* U+2864 BRAILLE PATTERN DOTS-367 */
-#define XK_braille_dots_1367          0x1002865  /* U+2865 BRAILLE PATTERN DOTS-1367 */
-#define XK_braille_dots_2367          0x1002866  /* U+2866 BRAILLE PATTERN DOTS-2367 */
-#define XK_braille_dots_12367         0x1002867  /* U+2867 BRAILLE PATTERN DOTS-12367 */
-#define XK_braille_dots_467           0x1002868  /* U+2868 BRAILLE PATTERN DOTS-467 */
-#define XK_braille_dots_1467          0x1002869  /* U+2869 BRAILLE PATTERN DOTS-1467 */
-#define XK_braille_dots_2467          0x100286a  /* U+286a BRAILLE PATTERN DOTS-2467 */
-#define XK_braille_dots_12467         0x100286b  /* U+286b BRAILLE PATTERN DOTS-12467 */
-#define XK_braille_dots_3467          0x100286c  /* U+286c BRAILLE PATTERN DOTS-3467 */
-#define XK_braille_dots_13467         0x100286d  /* U+286d BRAILLE PATTERN DOTS-13467 */
-#define XK_braille_dots_23467         0x100286e  /* U+286e BRAILLE PATTERN DOTS-23467 */
-#define XK_braille_dots_123467        0x100286f  /* U+286f BRAILLE PATTERN DOTS-123467 */
-#define XK_braille_dots_567           0x1002870  /* U+2870 BRAILLE PATTERN DOTS-567 */
-#define XK_braille_dots_1567          0x1002871  /* U+2871 BRAILLE PATTERN DOTS-1567 */
-#define XK_braille_dots_2567          0x1002872  /* U+2872 BRAILLE PATTERN DOTS-2567 */
-#define XK_braille_dots_12567         0x1002873  /* U+2873 BRAILLE PATTERN DOTS-12567 */
-#define XK_braille_dots_3567          0x1002874  /* U+2874 BRAILLE PATTERN DOTS-3567 */
-#define XK_braille_dots_13567         0x1002875  /* U+2875 BRAILLE PATTERN DOTS-13567 */
-#define XK_braille_dots_23567         0x1002876  /* U+2876 BRAILLE PATTERN DOTS-23567 */
-#define XK_braille_dots_123567        0x1002877  /* U+2877 BRAILLE PATTERN DOTS-123567 */
-#define XK_braille_dots_4567          0x1002878  /* U+2878 BRAILLE PATTERN DOTS-4567 */
-#define XK_braille_dots_14567         0x1002879  /* U+2879 BRAILLE PATTERN DOTS-14567 */
-#define XK_braille_dots_24567         0x100287a  /* U+287a BRAILLE PATTERN DOTS-24567 */
-#define XK_braille_dots_124567        0x100287b  /* U+287b BRAILLE PATTERN DOTS-124567 */
-#define XK_braille_dots_34567         0x100287c  /* U+287c BRAILLE PATTERN DOTS-34567 */
-#define XK_braille_dots_134567        0x100287d  /* U+287d BRAILLE PATTERN DOTS-134567 */
-#define XK_braille_dots_234567        0x100287e  /* U+287e BRAILLE PATTERN DOTS-234567 */
-#define XK_braille_dots_1234567       0x100287f  /* U+287f BRAILLE PATTERN DOTS-1234567 */
-#define XK_braille_dots_8             0x1002880  /* U+2880 BRAILLE PATTERN DOTS-8 */
-#define XK_braille_dots_18            0x1002881  /* U+2881 BRAILLE PATTERN DOTS-18 */
-#define XK_braille_dots_28            0x1002882  /* U+2882 BRAILLE PATTERN DOTS-28 */
-#define XK_braille_dots_128           0x1002883  /* U+2883 BRAILLE PATTERN DOTS-128 */
-#define XK_braille_dots_38            0x1002884  /* U+2884 BRAILLE PATTERN DOTS-38 */
-#define XK_braille_dots_138           0x1002885  /* U+2885 BRAILLE PATTERN DOTS-138 */
-#define XK_braille_dots_238           0x1002886  /* U+2886 BRAILLE PATTERN DOTS-238 */
-#define XK_braille_dots_1238          0x1002887  /* U+2887 BRAILLE PATTERN DOTS-1238 */
-#define XK_braille_dots_48            0x1002888  /* U+2888 BRAILLE PATTERN DOTS-48 */
-#define XK_braille_dots_148           0x1002889  /* U+2889 BRAILLE PATTERN DOTS-148 */
-#define XK_braille_dots_248           0x100288a  /* U+288a BRAILLE PATTERN DOTS-248 */
-#define XK_braille_dots_1248          0x100288b  /* U+288b BRAILLE PATTERN DOTS-1248 */
-#define XK_braille_dots_348           0x100288c  /* U+288c BRAILLE PATTERN DOTS-348 */
-#define XK_braille_dots_1348          0x100288d  /* U+288d BRAILLE PATTERN DOTS-1348 */
-#define XK_braille_dots_2348          0x100288e  /* U+288e BRAILLE PATTERN DOTS-2348 */
-#define XK_braille_dots_12348         0x100288f  /* U+288f BRAILLE PATTERN DOTS-12348 */
-#define XK_braille_dots_58            0x1002890  /* U+2890 BRAILLE PATTERN DOTS-58 */
-#define XK_braille_dots_158           0x1002891  /* U+2891 BRAILLE PATTERN DOTS-158 */
-#define XK_braille_dots_258           0x1002892  /* U+2892 BRAILLE PATTERN DOTS-258 */
-#define XK_braille_dots_1258          0x1002893  /* U+2893 BRAILLE PATTERN DOTS-1258 */
-#define XK_braille_dots_358           0x1002894  /* U+2894 BRAILLE PATTERN DOTS-358 */
-#define XK_braille_dots_1358          0x1002895  /* U+2895 BRAILLE PATTERN DOTS-1358 */
-#define XK_braille_dots_2358          0x1002896  /* U+2896 BRAILLE PATTERN DOTS-2358 */
-#define XK_braille_dots_12358         0x1002897  /* U+2897 BRAILLE PATTERN DOTS-12358 */
-#define XK_braille_dots_458           0x1002898  /* U+2898 BRAILLE PATTERN DOTS-458 */
-#define XK_braille_dots_1458          0x1002899  /* U+2899 BRAILLE PATTERN DOTS-1458 */
-#define XK_braille_dots_2458          0x100289a  /* U+289a BRAILLE PATTERN DOTS-2458 */
-#define XK_braille_dots_12458         0x100289b  /* U+289b BRAILLE PATTERN DOTS-12458 */
-#define XK_braille_dots_3458          0x100289c  /* U+289c BRAILLE PATTERN DOTS-3458 */
-#define XK_braille_dots_13458         0x100289d  /* U+289d BRAILLE PATTERN DOTS-13458 */
-#define XK_braille_dots_23458         0x100289e  /* U+289e BRAILLE PATTERN DOTS-23458 */
-#define XK_braille_dots_123458        0x100289f  /* U+289f BRAILLE PATTERN DOTS-123458 */
-#define XK_braille_dots_68            0x10028a0  /* U+28a0 BRAILLE PATTERN DOTS-68 */
-#define XK_braille_dots_168           0x10028a1  /* U+28a1 BRAILLE PATTERN DOTS-168 */
-#define XK_braille_dots_268           0x10028a2  /* U+28a2 BRAILLE PATTERN DOTS-268 */
-#define XK_braille_dots_1268          0x10028a3  /* U+28a3 BRAILLE PATTERN DOTS-1268 */
-#define XK_braille_dots_368           0x10028a4  /* U+28a4 BRAILLE PATTERN DOTS-368 */
-#define XK_braille_dots_1368          0x10028a5  /* U+28a5 BRAILLE PATTERN DOTS-1368 */
-#define XK_braille_dots_2368          0x10028a6  /* U+28a6 BRAILLE PATTERN DOTS-2368 */
-#define XK_braille_dots_12368         0x10028a7  /* U+28a7 BRAILLE PATTERN DOTS-12368 */
-#define XK_braille_dots_468           0x10028a8  /* U+28a8 BRAILLE PATTERN DOTS-468 */
-#define XK_braille_dots_1468          0x10028a9  /* U+28a9 BRAILLE PATTERN DOTS-1468 */
-#define XK_braille_dots_2468          0x10028aa  /* U+28aa BRAILLE PATTERN DOTS-2468 */
-#define XK_braille_dots_12468         0x10028ab  /* U+28ab BRAILLE PATTERN DOTS-12468 */
-#define XK_braille_dots_3468          0x10028ac  /* U+28ac BRAILLE PATTERN DOTS-3468 */
-#define XK_braille_dots_13468         0x10028ad  /* U+28ad BRAILLE PATTERN DOTS-13468 */
-#define XK_braille_dots_23468         0x10028ae  /* U+28ae BRAILLE PATTERN DOTS-23468 */
-#define XK_braille_dots_123468        0x10028af  /* U+28af BRAILLE PATTERN DOTS-123468 */
-#define XK_braille_dots_568           0x10028b0  /* U+28b0 BRAILLE PATTERN DOTS-568 */
-#define XK_braille_dots_1568          0x10028b1  /* U+28b1 BRAILLE PATTERN DOTS-1568 */
-#define XK_braille_dots_2568          0x10028b2  /* U+28b2 BRAILLE PATTERN DOTS-2568 */
-#define XK_braille_dots_12568         0x10028b3  /* U+28b3 BRAILLE PATTERN DOTS-12568 */
-#define XK_braille_dots_3568          0x10028b4  /* U+28b4 BRAILLE PATTERN DOTS-3568 */
-#define XK_braille_dots_13568         0x10028b5  /* U+28b5 BRAILLE PATTERN DOTS-13568 */
-#define XK_braille_dots_23568         0x10028b6  /* U+28b6 BRAILLE PATTERN DOTS-23568 */
-#define XK_braille_dots_123568        0x10028b7  /* U+28b7 BRAILLE PATTERN DOTS-123568 */
-#define XK_braille_dots_4568          0x10028b8  /* U+28b8 BRAILLE PATTERN DOTS-4568 */
-#define XK_braille_dots_14568         0x10028b9  /* U+28b9 BRAILLE PATTERN DOTS-14568 */
-#define XK_braille_dots_24568         0x10028ba  /* U+28ba BRAILLE PATTERN DOTS-24568 */
-#define XK_braille_dots_124568        0x10028bb  /* U+28bb BRAILLE PATTERN DOTS-124568 */
-#define XK_braille_dots_34568         0x10028bc  /* U+28bc BRAILLE PATTERN DOTS-34568 */
-#define XK_braille_dots_134568        0x10028bd  /* U+28bd BRAILLE PATTERN DOTS-134568 */
-#define XK_braille_dots_234568        0x10028be  /* U+28be BRAILLE PATTERN DOTS-234568 */
-#define XK_braille_dots_1234568       0x10028bf  /* U+28bf BRAILLE PATTERN DOTS-1234568 */
-#define XK_braille_dots_78            0x10028c0  /* U+28c0 BRAILLE PATTERN DOTS-78 */
-#define XK_braille_dots_178           0x10028c1  /* U+28c1 BRAILLE PATTERN DOTS-178 */
-#define XK_braille_dots_278           0x10028c2  /* U+28c2 BRAILLE PATTERN DOTS-278 */
-#define XK_braille_dots_1278          0x10028c3  /* U+28c3 BRAILLE PATTERN DOTS-1278 */
-#define XK_braille_dots_378           0x10028c4  /* U+28c4 BRAILLE PATTERN DOTS-378 */
-#define XK_braille_dots_1378          0x10028c5  /* U+28c5 BRAILLE PATTERN DOTS-1378 */
-#define XK_braille_dots_2378          0x10028c6  /* U+28c6 BRAILLE PATTERN DOTS-2378 */
-#define XK_braille_dots_12378         0x10028c7  /* U+28c7 BRAILLE PATTERN DOTS-12378 */
-#define XK_braille_dots_478           0x10028c8  /* U+28c8 BRAILLE PATTERN DOTS-478 */
-#define XK_braille_dots_1478          0x10028c9  /* U+28c9 BRAILLE PATTERN DOTS-1478 */
-#define XK_braille_dots_2478          0x10028ca  /* U+28ca BRAILLE PATTERN DOTS-2478 */
-#define XK_braille_dots_12478         0x10028cb  /* U+28cb BRAILLE PATTERN DOTS-12478 */
-#define XK_braille_dots_3478          0x10028cc  /* U+28cc BRAILLE PATTERN DOTS-3478 */
-#define XK_braille_dots_13478         0x10028cd  /* U+28cd BRAILLE PATTERN DOTS-13478 */
-#define XK_braille_dots_23478         0x10028ce  /* U+28ce BRAILLE PATTERN DOTS-23478 */
-#define XK_braille_dots_123478        0x10028cf  /* U+28cf BRAILLE PATTERN DOTS-123478 */
-#define XK_braille_dots_578           0x10028d0  /* U+28d0 BRAILLE PATTERN DOTS-578 */
-#define XK_braille_dots_1578          0x10028d1  /* U+28d1 BRAILLE PATTERN DOTS-1578 */
-#define XK_braille_dots_2578          0x10028d2  /* U+28d2 BRAILLE PATTERN DOTS-2578 */
-#define XK_braille_dots_12578         0x10028d3  /* U+28d3 BRAILLE PATTERN DOTS-12578 */
-#define XK_braille_dots_3578          0x10028d4  /* U+28d4 BRAILLE PATTERN DOTS-3578 */
-#define XK_braille_dots_13578         0x10028d5  /* U+28d5 BRAILLE PATTERN DOTS-13578 */
-#define XK_braille_dots_23578         0x10028d6  /* U+28d6 BRAILLE PATTERN DOTS-23578 */
-#define XK_braille_dots_123578        0x10028d7  /* U+28d7 BRAILLE PATTERN DOTS-123578 */
-#define XK_braille_dots_4578          0x10028d8  /* U+28d8 BRAILLE PATTERN DOTS-4578 */
-#define XK_braille_dots_14578         0x10028d9  /* U+28d9 BRAILLE PATTERN DOTS-14578 */
-#define XK_braille_dots_24578         0x10028da  /* U+28da BRAILLE PATTERN DOTS-24578 */
-#define XK_braille_dots_124578        0x10028db  /* U+28db BRAILLE PATTERN DOTS-124578 */
-#define XK_braille_dots_34578         0x10028dc  /* U+28dc BRAILLE PATTERN DOTS-34578 */
-#define XK_braille_dots_134578        0x10028dd  /* U+28dd BRAILLE PATTERN DOTS-134578 */
-#define XK_braille_dots_234578        0x10028de  /* U+28de BRAILLE PATTERN DOTS-234578 */
-#define XK_braille_dots_1234578       0x10028df  /* U+28df BRAILLE PATTERN DOTS-1234578 */
-#define XK_braille_dots_678           0x10028e0  /* U+28e0 BRAILLE PATTERN DOTS-678 */
-#define XK_braille_dots_1678          0x10028e1  /* U+28e1 BRAILLE PATTERN DOTS-1678 */
-#define XK_braille_dots_2678          0x10028e2  /* U+28e2 BRAILLE PATTERN DOTS-2678 */
-#define XK_braille_dots_12678         0x10028e3  /* U+28e3 BRAILLE PATTERN DOTS-12678 */
-#define XK_braille_dots_3678          0x10028e4  /* U+28e4 BRAILLE PATTERN DOTS-3678 */
-#define XK_braille_dots_13678         0x10028e5  /* U+28e5 BRAILLE PATTERN DOTS-13678 */
-#define XK_braille_dots_23678         0x10028e6  /* U+28e6 BRAILLE PATTERN DOTS-23678 */
-#define XK_braille_dots_123678        0x10028e7  /* U+28e7 BRAILLE PATTERN DOTS-123678 */
-#define XK_braille_dots_4678          0x10028e8  /* U+28e8 BRAILLE PATTERN DOTS-4678 */
-#define XK_braille_dots_14678         0x10028e9  /* U+28e9 BRAILLE PATTERN DOTS-14678 */
-#define XK_braille_dots_24678         0x10028ea  /* U+28ea BRAILLE PATTERN DOTS-24678 */
-#define XK_braille_dots_124678        0x10028eb  /* U+28eb BRAILLE PATTERN DOTS-124678 */
-#define XK_braille_dots_34678         0x10028ec  /* U+28ec BRAILLE PATTERN DOTS-34678 */
-#define XK_braille_dots_134678        0x10028ed  /* U+28ed BRAILLE PATTERN DOTS-134678 */
-#define XK_braille_dots_234678        0x10028ee  /* U+28ee BRAILLE PATTERN DOTS-234678 */
-#define XK_braille_dots_1234678       0x10028ef  /* U+28ef BRAILLE PATTERN DOTS-1234678 */
-#define XK_braille_dots_5678          0x10028f0  /* U+28f0 BRAILLE PATTERN DOTS-5678 */
-#define XK_braille_dots_15678         0x10028f1  /* U+28f1 BRAILLE PATTERN DOTS-15678 */
-#define XK_braille_dots_25678         0x10028f2  /* U+28f2 BRAILLE PATTERN DOTS-25678 */
-#define XK_braille_dots_125678        0x10028f3  /* U+28f3 BRAILLE PATTERN DOTS-125678 */
-#define XK_braille_dots_35678         0x10028f4  /* U+28f4 BRAILLE PATTERN DOTS-35678 */
-#define XK_braille_dots_135678        0x10028f5  /* U+28f5 BRAILLE PATTERN DOTS-135678 */
-#define XK_braille_dots_235678        0x10028f6  /* U+28f6 BRAILLE PATTERN DOTS-235678 */
-#define XK_braille_dots_1235678       0x10028f7  /* U+28f7 BRAILLE PATTERN DOTS-1235678 */
-#define XK_braille_dots_45678         0x10028f8  /* U+28f8 BRAILLE PATTERN DOTS-45678 */
-#define XK_braille_dots_145678        0x10028f9  /* U+28f9 BRAILLE PATTERN DOTS-145678 */
-#define XK_braille_dots_245678        0x10028fa  /* U+28fa BRAILLE PATTERN DOTS-245678 */
-#define XK_braille_dots_1245678       0x10028fb  /* U+28fb BRAILLE PATTERN DOTS-1245678 */
-#define XK_braille_dots_345678        0x10028fc  /* U+28fc BRAILLE PATTERN DOTS-345678 */
-#define XK_braille_dots_1345678       0x10028fd  /* U+28fd BRAILLE PATTERN DOTS-1345678 */
-#define XK_braille_dots_2345678       0x10028fe  /* U+28fe BRAILLE PATTERN DOTS-2345678 */
-#define XK_braille_dots_12345678      0x10028ff  /* U+28ff BRAILLE PATTERN DOTS-12345678 */
 #endif /* XK_BRAILLE */
 
-/*
- * Sinhala (http://unicode.org/charts/PDF/U0D80.pdf)
- * http://www.nongnu.org/sinhala/doc/transliteration/sinhala-transliteration_6.html
- */
-
-#ifdef XK_SINHALA
-#define XK_Sinh_ng            0x1000d82  /* U+0D82 SINHALA ANUSVARAYA */
-#define XK_Sinh_h2            0x1000d83  /* U+0D83 SINHALA VISARGAYA */
-#define XK_Sinh_a             0x1000d85  /* U+0D85 SINHALA AYANNA */
-#define XK_Sinh_aa            0x1000d86  /* U+0D86 SINHALA AAYANNA */
-#define XK_Sinh_ae            0x1000d87  /* U+0D87 SINHALA AEYANNA */
-#define XK_Sinh_aee           0x1000d88  /* U+0D88 SINHALA AEEYANNA */
-#define XK_Sinh_i             0x1000d89  /* U+0D89 SINHALA IYANNA */
-#define XK_Sinh_ii            0x1000d8a  /* U+0D8A SINHALA IIYANNA */
-#define XK_Sinh_u             0x1000d8b  /* U+0D8B SINHALA UYANNA */
-#define XK_Sinh_uu            0x1000d8c  /* U+0D8C SINHALA UUYANNA */
-#define XK_Sinh_ri            0x1000d8d  /* U+0D8D SINHALA IRUYANNA */
-#define XK_Sinh_rii           0x1000d8e  /* U+0D8E SINHALA IRUUYANNA */
-#define XK_Sinh_lu            0x1000d8f  /* U+0D8F SINHALA ILUYANNA */
-#define XK_Sinh_luu           0x1000d90  /* U+0D90 SINHALA ILUUYANNA */
-#define XK_Sinh_e             0x1000d91  /* U+0D91 SINHALA EYANNA */
-#define XK_Sinh_ee            0x1000d92  /* U+0D92 SINHALA EEYANNA */
-#define XK_Sinh_ai            0x1000d93  /* U+0D93 SINHALA AIYANNA */
-#define XK_Sinh_o             0x1000d94  /* U+0D94 SINHALA OYANNA */
-#define XK_Sinh_oo            0x1000d95  /* U+0D95 SINHALA OOYANNA */
-#define XK_Sinh_au            0x1000d96  /* U+0D96 SINHALA AUYANNA */
-#define XK_Sinh_ka            0x1000d9a  /* U+0D9A SINHALA KAYANNA */
-#define XK_Sinh_kha           0x1000d9b  /* U+0D9B SINHALA MAHA. KAYANNA */
-#define XK_Sinh_ga            0x1000d9c  /* U+0D9C SINHALA GAYANNA */
-#define XK_Sinh_gha           0x1000d9d  /* U+0D9D SINHALA MAHA. GAYANNA */
-#define XK_Sinh_ng2           0x1000d9e  /* U+0D9E SINHALA KANTAJA NAASIKYAYA */
-#define XK_Sinh_nga           0x1000d9f  /* U+0D9F SINHALA SANYAKA GAYANNA */
-#define XK_Sinh_ca            0x1000da0  /* U+0DA0 SINHALA CAYANNA */
-#define XK_Sinh_cha           0x1000da1  /* U+0DA1 SINHALA MAHA. CAYANNA */
-#define XK_Sinh_ja            0x1000da2  /* U+0DA2 SINHALA JAYANNA */
-#define XK_Sinh_jha           0x1000da3  /* U+0DA3 SINHALA MAHA. JAYANNA */
-#define XK_Sinh_nya           0x1000da4  /* U+0DA4 SINHALA TAALUJA NAASIKYAYA */
-#define XK_Sinh_jnya          0x1000da5  /* U+0DA5 SINHALA TAALUJA SANYOOGA NAASIKYAYA */
-#define XK_Sinh_nja           0x1000da6  /* U+0DA6 SINHALA SANYAKA JAYANNA */
-#define XK_Sinh_tta           0x1000da7  /* U+0DA7 SINHALA TTAYANNA */
-#define XK_Sinh_ttha          0x1000da8  /* U+0DA8 SINHALA MAHA. TTAYANNA */
-#define XK_Sinh_dda           0x1000da9  /* U+0DA9 SINHALA DDAYANNA */
-#define XK_Sinh_ddha          0x1000daa  /* U+0DAA SINHALA MAHA. DDAYANNA */
-#define XK_Sinh_nna           0x1000dab  /* U+0DAB SINHALA MUURDHAJA NAYANNA */
-#define XK_Sinh_ndda          0x1000dac  /* U+0DAC SINHALA SANYAKA DDAYANNA */
-#define XK_Sinh_tha           0x1000dad  /* U+0DAD SINHALA TAYANNA */
-#define XK_Sinh_thha          0x1000dae  /* U+0DAE SINHALA MAHA. TAYANNA */
-#define XK_Sinh_dha           0x1000daf  /* U+0DAF SINHALA DAYANNA */
-#define XK_Sinh_dhha          0x1000db0  /* U+0DB0 SINHALA MAHA. DAYANNA */
-#define XK_Sinh_na            0x1000db1  /* U+0DB1 SINHALA DANTAJA NAYANNA */
-#define XK_Sinh_ndha          0x1000db3  /* U+0DB3 SINHALA SANYAKA DAYANNA */
-#define XK_Sinh_pa            0x1000db4  /* U+0DB4 SINHALA PAYANNA */
-#define XK_Sinh_pha           0x1000db5  /* U+0DB5 SINHALA MAHA. PAYANNA */
-#define XK_Sinh_ba            0x1000db6  /* U+0DB6 SINHALA BAYANNA */
-#define XK_Sinh_bha           0x1000db7  /* U+0DB7 SINHALA MAHA. BAYANNA */
-#define XK_Sinh_ma            0x1000db8  /* U+0DB8 SINHALA MAYANNA */
-#define XK_Sinh_mba           0x1000db9  /* U+0DB9 SINHALA AMBA BAYANNA */
-#define XK_Sinh_ya            0x1000dba  /* U+0DBA SINHALA YAYANNA */
-#define XK_Sinh_ra            0x1000dbb  /* U+0DBB SINHALA RAYANNA */
-#define XK_Sinh_la            0x1000dbd  /* U+0DBD SINHALA DANTAJA LAYANNA */
-#define XK_Sinh_va            0x1000dc0  /* U+0DC0 SINHALA VAYANNA */
-#define XK_Sinh_sha           0x1000dc1  /* U+0DC1 SINHALA TAALUJA SAYANNA */
-#define XK_Sinh_ssha          0x1000dc2  /* U+0DC2 SINHALA MUURDHAJA SAYANNA */
-#define XK_Sinh_sa            0x1000dc3  /* U+0DC3 SINHALA DANTAJA SAYANNA */
-#define XK_Sinh_ha            0x1000dc4  /* U+0DC4 SINHALA HAYANNA */
-#define XK_Sinh_lla           0x1000dc5  /* U+0DC5 SINHALA MUURDHAJA LAYANNA */
-#define XK_Sinh_fa            0x1000dc6  /* U+0DC6 SINHALA FAYANNA */
-#define XK_Sinh_al            0x1000dca  /* U+0DCA SINHALA AL-LAKUNA */
-#define XK_Sinh_aa2           0x1000dcf  /* U+0DCF SINHALA AELA-PILLA */
-#define XK_Sinh_ae2           0x1000dd0  /* U+0DD0 SINHALA AEDA-PILLA */
-#define XK_Sinh_aee2          0x1000dd1  /* U+0DD1 SINHALA DIGA AEDA-PILLA */
-#define XK_Sinh_i2            0x1000dd2  /* U+0DD2 SINHALA IS-PILLA */
-#define XK_Sinh_ii2           0x1000dd3  /* U+0DD3 SINHALA DIGA IS-PILLA */
-#define XK_Sinh_u2            0x1000dd4  /* U+0DD4 SINHALA PAA-PILLA */
-#define XK_Sinh_uu2           0x1000dd6  /* U+0DD6 SINHALA DIGA PAA-PILLA */
-#define XK_Sinh_ru2           0x1000dd8  /* U+0DD8 SINHALA GAETTA-PILLA */
-#define XK_Sinh_e2            0x1000dd9  /* U+0DD9 SINHALA KOMBUVA */
-#define XK_Sinh_ee2           0x1000dda  /* U+0DDA SINHALA DIGA KOMBUVA */
-#define XK_Sinh_ai2           0x1000ddb  /* U+0DDB SINHALA KOMBU DEKA */
-#define XK_Sinh_o2            0x1000ddc  /* U+0DDC SINHALA KOMBUVA HAA AELA-PILLA*/
-#define XK_Sinh_oo2           0x1000ddd  /* U+0DDD SINHALA KOMBUVA HAA DIGA AELA-PILLA*/
-#define XK_Sinh_au2           0x1000dde  /* U+0DDE SINHALA KOMBUVA HAA GAYANUKITTA */
-#define XK_Sinh_lu2           0x1000ddf  /* U+0DDF SINHALA GAYANUKITTA */
-#define XK_Sinh_ruu2          0x1000df2  /* U+0DF2 SINHALA DIGA GAETTA-PILLA */
-#define XK_Sinh_luu2          0x1000df3  /* U+0DF3 SINHALA DIGA GAYANUKITTA */
-#define XK_Sinh_kunddaliya    0x1000df4  /* U+0DF4 SINHALA KUNDDALIYA */
-#endif /* XK_SINHALA */
-
 /* Multimedia keys, defined same as on Linux
  * /usr/include/pkg/libxkbcommon/xkbcommon/xkbcommon-keysyms.h
  */
 
 #ifndef TK_NO_DEPRECATED

Index: xlib/xcolors.c
==================================================================
--- xlib/xcolors.c
+++ xlib/xcolors.c
@@ -2,12 +2,12 @@
  * xcolors.c --
  *
  *	This file contains the routines used to map from X color names to RGB
  *	and pixel values.
  *
- * Copyright (c) 1996 by Sun Microsystems, Inc.
- * Copyright (c) 2012 by Jan Nijtmans
+ * Copyright (c) 1996 Sun Microsystems, Inc.
+ * Copyright (c) 2012 Jan Nijtmans
  *
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 

Index: xlib/xgc.c
==================================================================
--- xlib/xgc.c
+++ xlib/xgc.c
@@ -11,31 +11,20 @@
  * See the file "license.terms" for information on usage and redistribution of
  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  */
 
 #include "tkInt.h"
-
-#if !defined(MAC_OSX_TK)
-#   include <X11/Xlib.h>
-#   define TkpInitGCCache(gc)
-#   define TkpFreeGCCache(gc)
-#   define TkpGetGCCache(gc)
-#else
-#   include <tkMacOSXInt.h>
-#   include <X11/Xlib.h>
-#   include <X11/X.h>
+#include <X11/Xlib.h>
+#if defined(MAC_OSX_TK)
 #endif
 
 
 #define MAX_DASH_LIST_SIZE 10
 typedef struct {
     XGCValues gc;
     char dash[MAX_DASH_LIST_SIZE];
-#ifdef MAC_OSX_TK
-    TkpGCCache cache;
-#endif
-} XGCValuesWithCache;
+} XGCValuesWithDash;
 
 /*
  *----------------------------------------------------------------------
  *
  * AllocClipMask --
@@ -115,14 +104,11 @@
      * are defined, which is invisible from the outside. The list is assumed
      * to end with a 0-char, so this must be set explicitly during
      * initialization.
      */
 
-    gp = (GC)ckalloc(sizeof(XGCValuesWithCache));
-    if (!gp) {
-	return NULL;
-    }
+    gp = (GC)ckalloc(sizeof(XGCValuesWithDash));
 
 #define InitField(name,maskbit,default) \
 	(gp->name = (mask & (maskbit)) ? values->name : (default))
 
     InitField(function,		  GCFunction,		GXcopy);
@@ -134,11 +120,11 @@
     InitField(line_width,	  GCLineWidth,		1);
     InitField(line_style,	  GCLineStyle,		LineSolid);
     InitField(cap_style,	  GCCapStyle,		0);
     InitField(join_style,	  GCJoinStyle,		0);
     InitField(fill_style,	  GCFillStyle,		FillSolid);
-    InitField(fill_rule,	  GCFillRule,		WindingRule);
+    InitField(fill_rule,	  GCFillRule,		EvenOddRule);
     InitField(arc_mode,		  GCArcMode,		ArcPieSlice);
     InitField(tile,		  GCTile,		0);
     InitField(stipple,		  GCStipple,		0);
     InitField(ts_x_origin,	  GCTileStipXOrigin,	0);
     InitField(ts_y_origin,	  GCTileStipYOrigin,	0);
@@ -156,36 +142,13 @@
 	TkpClipMask *clip_mask = AllocClipMask(gp);
 
 	clip_mask->type = TKP_CLIP_PIXMAP;
 	clip_mask->value.pixmap = values->clip_mask;
     }
-    TkpInitGCCache(gp);
-
     return gp;
 }
 
-#ifdef MAC_OSX_TK
-/*
- *----------------------------------------------------------------------
- *
- * TkpGetGCCache --
- *
- * Results:
- *	Pointer to the TkpGCCache at the end of the GC.
- *
- * Side effects:
- *	None.
- *
- *----------------------------------------------------------------------
- */
-
-TkpGCCache*
-TkpGetGCCache(GC gc) {
-    return (gc ? &((XGCValuesWithCache *)gc)->cache : NULL);
-}
-#endif
-
 /*
  *----------------------------------------------------------------------
  *
  * XChangeGC --
  *
@@ -263,11 +226,10 @@
 {
     (void)d;
 
     if (gc != NULL) {
 	FreeClipMask(gc);
-	TkpFreeGCCache(gc);
 	ckfree(gc);
     }
     return Success;
 }
 

Index: xlib/ximage.c
==================================================================
--- xlib/ximage.c
+++ xlib/ximage.c
@@ -49,15 +49,17 @@
     if (gc == NULL) {
 	return None;
     }
     ximage = XCreateImage(display, NULL, 1, XYBitmap, 0, (char*) data, width,
 	    height, 8, (width + 7) / 8);
-    ximage->bitmap_bit_order = LSBFirst;
-    _XInitImageFuncPtrs(ximage);
-    TkPutImage(NULL, 0, display, pix, gc, ximage, 0, 0, 0, 0, width, height);
-    ximage->data = NULL;
-    XDestroyImage(ximage);
+    if (ximage) {
+	ximage->bitmap_bit_order = LSBFirst;
+	_XInitImageFuncPtrs(ximage);
+	TkPutImage(NULL, 0, display, pix, gc, ximage, 0, 0, 0, 0, width, height);
+	ximage->data = NULL;
+	XDestroyImage(ximage);
+    }
     XFreeGC(display, gc);
     return pix;
 }
 
 /*