Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package jasper for openSUSE:Factory checked 
in at 2023-11-06 21:13:42
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/jasper (Old)
 and      /work/SRC/openSUSE:Factory/.jasper.new.17445 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "jasper"

Mon Nov  6 21:13:42 2023 rev:24 rq:1123411 version:4.1.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/jasper/jasper.changes    2023-10-31 
20:25:13.800904812 +0100
+++ /work/SRC/openSUSE:Factory/.jasper.new.17445/jasper.changes 2023-11-06 
21:13:48.546228308 +0100
@@ -1,0 +2,14 @@
+Sun Nov  5 13:14:59 UTC 2023 - Michael Vetter <mvet...@suse.com>
+
+- Update to 4.1.0:
+  * Add support for building several JasPer application programs for
+    WebAssembly target with WASI support.
+
+-------------------------------------------------------------------
+Sun Nov  5 13:14:39 UTC 2023 - Michael Vetter <mvet...@suse.com>
+
+- Update to 4.0.1:
+  * Fix integer overflow bug in PNM decoder (#353).
+  * Fix a few minor build issues.
+
+-------------------------------------------------------------------

Old:
----
  version-4.0.0.tar.gz

New:
----
  version-4.1.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ jasper.spec ++++++
--- /var/tmp/diff_new_pack.PpOmap/_old  2023-11-06 21:13:49.294255843 +0100
+++ /var/tmp/diff_new_pack.PpOmap/_new  2023-11-06 21:13:49.294255843 +0100
@@ -20,7 +20,7 @@
 %global __builddir obs_build
 
 Name:           jasper
-Version:        4.0.0
+Version:        4.1.0
 Release:        0
 Summary:        An Implementation of the JPEG-2000 Standard, Part 1
 License:        JasPer-2.0

++++++ version-4.0.0.tar.gz -> version-4.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/.github/workflows/ci.yml 
new/jasper-version-4.1.0/.github/workflows/ci.yml
--- old/jasper-version-4.0.0/.github/workflows/ci.yml   2022-11-05 
18:06:53.000000000 +0100
+++ new/jasper-version-4.1.0/.github/workflows/ci.yml   2023-11-05 
05:39:06.000000000 +0100
@@ -6,14 +6,22 @@
   build:
     strategy:
       matrix:
-        os: [ubuntu-latest, macos-latest]
+        os: [ubuntu-22.04, ubuntu-20.04, macos-12, macos-11]
         compiler: [ {cc: gcc, cxx: g++}, {cc: clang, cxx: clang++} ]
         include:
           - os: [windows-2022]
+        exclude:
+          # Temporarily disable Ubuntu 20.04 with GCC since linking with
+          # TSan fails due the linker being unable to find libtsan_preinit.o.
+          # This used to work previously.
+          # Perhaps, the cause is related to the following Ubuntu issue:
+          # https://bugs.launchpad.net/ubuntu/+source/gcc-9/+bug/2029910
+          - os: ubuntu-20.04
+            compiler: {cc: gcc, cxx: g++}
       fail-fast: false
     runs-on: ${{ matrix.os }}
     steps:
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
     ############################################################
     - name: prebuild
       shell: bash
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/jasper-version-4.0.0/.github/workflows/deploy_manual.yml 
new/jasper-version-4.1.0/.github/workflows/deploy_manual.yml
--- old/jasper-version-4.0.0/.github/workflows/deploy_manual.yml        
2022-11-05 18:06:53.000000000 +0100
+++ new/jasper-version-4.1.0/.github/workflows/deploy_manual.yml        
2023-11-05 05:39:06.000000000 +0100
@@ -12,7 +12,7 @@
     steps:
       ############################################################
       - name: Checkout
-        uses: actions/checkout@v2
+        uses: actions/checkout@v3
         with:
           fetch-depth: 0
       ############################################################
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/.github/workflows/release.yml 
new/jasper-version-4.1.0/.github/workflows/release.yml
--- old/jasper-version-4.0.0/.github/workflows/release.yml      2022-11-05 
18:06:53.000000000 +0100
+++ new/jasper-version-4.1.0/.github/workflows/release.yml      2023-11-05 
05:39:06.000000000 +0100
@@ -7,14 +7,17 @@
       - version-[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
       - version-[0-9]+.[0-9]+.[0-9]+-alpha[0-9]+
       - version-[0-9]+.[0-9]+.[0-9]+-beta[0-9]+
+      - experimental-version-*
+      - mdadams-experimental-version-*
 
 jobs:
   build:
-    runs-on: ubuntu-latest
+    #runs-on: ubuntu-latest
+    runs-on: ubuntu-22.04
     steps:
       ############################################################
       - name: Checkout
-        uses: actions/checkout@v2
+        uses: actions/checkout@v3
         with:
           fetch-depth: 0
       ############################################################
@@ -24,7 +27,7 @@
       ############################################################
       - name: Build
         shell: bash
-        run: build/make_release -r ${{github.ref}} -w ${{github.workspace}} -t 
${{runner.temp}}/tmp -o ${{runner.temp}}/out
+        run: build/make_release -W 1 -r ${{github.ref}} -w 
${{github.workspace}} -t ${{runner.temp}}/tmp -o ${{runner.temp}}/out
       ############################################################
       - name: Deploy Release
         uses: softprops/action-gh-release@v1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/.github/workflows/win_ci.yml 
new/jasper-version-4.1.0/.github/workflows/win_ci.yml
--- old/jasper-version-4.0.0/.github/workflows/win_ci.yml       2022-11-05 
18:06:53.000000000 +0100
+++ new/jasper-version-4.1.0/.github/workflows/win_ci.yml       2023-11-05 
05:39:06.000000000 +0100
@@ -11,7 +11,7 @@
       fail-fast: false
     runs-on: ${{ matrix.os }}
     steps:
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
     - name: testing
       shell: bash
       run: build/build --debug-level 10 --shared --test --verbose
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/CMakeLists.txt 
new/jasper-version-4.1.0/CMakeLists.txt
--- old/jasper-version-4.0.0/CMakeLists.txt     2022-11-05 18:06:53.000000000 
+0100
+++ new/jasper-version-4.1.0/CMakeLists.txt     2023-11-05 05:39:06.000000000 
+0100
@@ -9,7 +9,7 @@
 
 # The major, minor, and micro version numbers of the project.
 set(JAS_VERSION_MAJOR 4)
-set(JAS_VERSION_MINOR 0)
+set(JAS_VERSION_MINOR 1)
 set(JAS_VERSION_PATCH 0)
 
 # The shared library versioning information.
@@ -130,7 +130,7 @@
 option(JAS_INCLUDE_JPG_CODEC
   "Include JPG codec support (via IJG JPEG Library)" ON)
 option(JAS_INCLUDE_HEIC_CODEC
-       "Include experimental HEIC codec support (via Libheif Library)" ON)
+  "Include experimental HEIC codec support (via Libheif Library)" ON)
 option(JAS_INCLUDE_MIF_CODEC "Include (native) MIF codec support" ON)
 option(JAS_INCLUDE_PGX_CODEC "Include (native) PGX codec support" ON)
 option(JAS_INCLUDE_PNM_CODEC "Include (native) PNM codec support" ON)
@@ -144,7 +144,7 @@
 option(JAS_ENABLE_JPG_CODEC
   "Enable JPG codec support (via IJG JPEG Library)" ON)
 option(JAS_ENABLE_HEIC_CODEC
-       "Enable experimental HEIC codec support (via Libheif Library)" OFF)
+  "Enable experimental HEIC codec support (via Libheif Library)" OFF)
 option(JAS_ENABLE_MIF_CODEC "Enable (native) MIF codec support" OFF)
 option(JAS_ENABLE_PGX_CODEC "Enable (native) PGX codec support" ON)
 option(JAS_ENABLE_PNM_CODEC "Enable (native) PNM codec support" ON)
@@ -191,6 +191,16 @@
 option(JAS_ENABLE_CXX "Enable C++ code (for testing)." OFF)
 option(JAS_ENABLE_CONFORMANCE_TESTS "Enable conformance tests." OFF)
 
+option(JAS_WASM "Enable WebAssembly mode" OFF)
+if(JAS_WASM)
+       set(JAS_CROSSCOMPILING 1)
+       set(JAS_STDC_VERSION "201112L")
+       set(JAS_ENABLE_MULTITHREADING_SUPPORT 0)
+       set(JAS_ENABLE_SHARED 0)
+       set(JAS_USE_JAS_INIT 0)
+       add_compile_definitions(JAS_WASI_LIBC)
+endif()
+
 
################################################################################
 #
 
################################################################################
@@ -225,8 +235,10 @@
 # This policy was added in CMake 3.8.
 cmake_policy(SET CMP0067 NEW)
 
-set(CMAKE_CXX_STANDARD 11)
-set(CMAKE_CXX_EXTENSIONS ON)
+if(JAS_ENABLE_CXX)
+       set(CMAKE_CXX_STANDARD 11)
+       set(CMAKE_CXX_EXTENSIONS ON)
+endif()
 
 # Eliminate a CMake warning.
 # Note: This policy was added in CMake 3.20.  Do not add this for now,
@@ -263,9 +275,6 @@
 # files are not placed in subdirectories (such as Debug and Release)
 # as this will cause the CTest test suite to fail.
 if(JAS_MULTICONFIGURATION_GENERATOR)
-       if(CMAKE_CONFIGURATION_TYPES)
-               set(CMAKE_DEBUG_POSTFIX d)
-       endif()
        set(CMAKE_RUNTIME_OUTPUT_DIRECTORY .)
        set(CMAKE_LIBRARY_OUTPUT_DIRECTORY .)
        set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY .)
@@ -413,6 +422,7 @@
        # cross-compiling.  If cross-compiling, the value of JAS_STDC_VERSION
        # will need to be set manually from the command line
        # (e.g., using -DJAS_STDC_VERSION=YYYYMML) or by changing the line 
below.
+if(NOT JAS_WASM)
        set(JAS_STDC_VERSION "0L" CACHE INTERNAL "The value of 
__STDC_VERSION__.")
        if (JAS_STDC_VERSION STREQUAL "0L")
                message(FATAL_ERROR
@@ -422,6 +432,7 @@
                  "option -DJAS_STDC_VERSION=...) or modify the CMakeLists.txt "
                  "appropriately.")
        endif()
+endif()
 else()
        jas_get_stdc_version(status JAS_STDC_VERSION)
        if(NOT status)
@@ -824,6 +835,17 @@
 # The package configuation (pc) file should be installed in
 # ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig.
 string(JOIN " " JAS_PKGCONFIG_REQUIRES ${JAS_PKGCONFIG_REQUIRES})
+# Handle both relative and absolute paths (e.g. NixOS) for a relocatable 
package
+if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
+    set(JAS_PC_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
+else()
+    set(JAS_PC_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
+endif()
+if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
+    set(JAS_PC_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
+else()
+    set(JAS_PC_LIBDIR "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
+endif()
 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/build/jasper.pc.in"
   "${CMAKE_CURRENT_BINARY_DIR}/build/jasper.pc" @ONLY)
 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/build/jasper.pc"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/NEWS.txt 
new/jasper-version-4.1.0/NEWS.txt
--- old/jasper-version-4.0.0/NEWS.txt   2022-11-05 18:06:53.000000000 +0100
+++ new/jasper-version-4.1.0/NEWS.txt   2023-11-05 05:39:06.000000000 +0100
@@ -1,7 +1,19 @@
+4.1.0 (2023-11-04)
+==================
+
+* Add support for building several JasPer application programs for
+  WebAssembly target with WASI support.
+
+4.0.1 (2023-11-04)
+==================
+
+* Fix integer overflow bug in PNM decoder (#353).
+* Fix a few minor build issues.
+
 4.0.0 (2022-11-05)
 ==================
 
-* Improve static linking (##336).
+* Improve static linking (#336).
 * Fix path relocation in mingw environment (#335).
 * Improve logging and build scripts.
 * Improve JPEG-2000 conformance test results.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/build/build_wasi_jasper 
new/jasper-version-4.1.0/build/build_wasi_jasper
--- old/jasper-version-4.0.0/build/build_wasi_jasper    1970-01-01 
01:00:00.000000000 +0100
+++ new/jasper-version-4.1.0/build/build_wasi_jasper    2023-11-05 
05:39:06.000000000 +0100
@@ -0,0 +1,165 @@
+#! /usr/bin/env bash
+
+panic()
+{
+       echo "ERROR: $*" 1>& 2
+       exit 1
+}
+
+perform_cleanup()
+{
+       if [ -n "$tmp_dir" -a -d "$tmp_dir" ]; then
+               rm -rf "$tmp_dir" || \
+                 echo "warning: cannot remove temporary directory $tmp_dir"
+       fi
+}
+
+usage()
+{
+       cat <<- EOF
+       usage:
+       $0 [options] -p \$out_dir
+
+       Examples
+       ========
+
+       $0 -C -t /tmp/mdadams/wasi_jasper-XXXXXX -o /tmp/mdadams/wasi_jasper
+       EOF
+       if [ $# -ne 0 ]; then
+               echo "BAD USAGE: $*"
+       fi
+       exit 2
+}
+
+self_dir="$(dirname "$0")" || panic
+install_wasi_sdk="$self_dir/install_wasi_sdk"
+install_wasmtime="$self_dir/install_wasmtime"
+wasm_cc="$self_dir/wasm_cc"
+wasm_cxx="$self_dir/wasm_cxx"
+
+wasi_sdk_version=20.0
+wasmtime_version=12.0.1
+
+tmp_dir_template="${JAS_TMP_DIR:-/tmp}/wasi_jasper-XXXXXX"
+cleanup=1
+source_dir="$self_dir/.."
+out_dir=
+version=unknown-version
+
+while getopts ":hCt:s:o:V:" option; do
+       case "$option" in
+       C)
+               cleanup=0;;
+       t)
+               tmp_dir_template="$OPTARG";;
+       s)
+               source_dir="$OPTARG";;
+       o)
+               out_dir="$OPTARG";;
+       V)
+               version="$OPTARG";;
+       h)
+               usage;;
+       *)
+               usage "invalid option $option";;
+       esac
+done
+shift $((OPTIND - 1))
+
+if [ -z "$tmp_dir_template" ]; then
+       usage "no temporary directory pathname template specified"
+fi
+
+if [ -z "$source_dir" ]; then
+       usage "no source directory specified"
+fi
+
+if [ -z "$out_dir" ]; then
+       usage "no output directory specified"
+fi
+
+tmp_dir="$(mktemp -d "$tmp_dir_template")" || \
+  panic "cannot create temporary directory"
+if [ "$cleanup" -ne 0 ]; then
+       trap perform_cleanup EXIT
+fi
+
+sde_dir="$tmp_dir/wasm"
+wasi_sdk_dir="$sde_dir/wasi_sdk"
+wasmtime_dir="$sde_dir/wasmtime"
+
+"$install_wasi_sdk" -d "$wasi_sdk_dir" -v "$wasi_sdk_version" || \
+  panic "cannot install WASI SDK"
+"$install_wasmtime" -d "$wasmtime_dir" -v "$wasmtime_version" || \
+  panic "cannot install wasmtime"
+wasmtime="$wasmtime_dir/bin/wasmtime"
+
+export WASI_SDK_ROOT_DIR="$wasi_sdk_dir"
+export CC="$wasm_cc"
+export CXX="$wasm_cxx"
+export PATH="$wasi_sdk_dir/bin:$PATH"
+
+lld="$(type -P lld)" || lld=
+echo "lld program: $lld"
+
+#source_dir="$tmp_dir/git"
+build_dir="$tmp_dir/build"
+install_dir="$tmp_dir/install"
+readme_file="$install_dir/README.txt"
+
+configure_options=(
+       -DCMAKE_INSTALL_PREFIX="$install_dir"
+       -DCMAKE_BUILD_TYPE=Release
+       -DCMAKE_VERBOSE_MAKEFILE=1
+       -DJAS_WASM=1
+       -DJAS_ENABLE_CXX=0
+       -DJAS_STRICT=0
+       -DJAS_ENABLE_DOC=0
+       #-DJAS_CROSSCOMPILING=1
+       #-DJAS_STDC_VERSION=201112L
+       #-DJAS_ENABLE_MULTITHREADING_SUPPORT=0
+       #-DJAS_ENABLE_SHARED=0
+       #-DJAS_USE_JAS_INIT=0
+)
+
+cmake -H"$source_dir" -B"$build_dir" "${configure_options[@]}" || \
+  panic "configure failed"
+
+cmake --build "$build_dir" || \
+  panic "build failed"
+
+cmake --build "$build_dir" --target install || \
+  panic "install failed"
+
+"$wasmtime" "$install_dir/bin/imginfo" < 
"$source_dir/data/images/goldenears.jp2" || panic "jasper failed"
+
+cat > "$readme_file" <<- EOF
+JasPer WebAssembly Edition ($version)
+
+This directory contains several JasPer programs built for a WebAssembly
+target that uses WASI for interfacing to the host environment.
+
+The command-line interface (CLI) for these programs is identical to
+their non-WebAssembly counterparts.  For detailed information on the
+CLI for these programs, refer to the online manual at:
+
+    https://jasper-software.github.io/jasper-manual/latest/html/index.html
+
+In order to run these WebAssembly programs, you will need a WebAssembly
+runtime with WASI support, such as:
+
+    Wasmtime (https://wasmtime.dev)
+    Wasmer (https://wasmer.io)
+    WAMR (https://bytecodealliance.github.io/wamr.dev)
+    WasmEdge (https://wasmedge.org)
+EOF
+[ $? -eq 0 ] || panic "cannot make readme file"
+
+if [ ! -d "$out_dir" ]; then
+       mkdir -p "$out_dir" || panic
+fi
+
+for file in jasper imginfo imgcmp; do
+       cp -a "$install_dir/bin/$file" "$out_dir" || panic
+done
+cp -a "$readme_file" "$out_dir" || panic
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/build/github/prebuild-v2 
new/jasper-version-4.1.0/build/github/prebuild-v2
--- old/jasper-version-4.0.0/build/github/prebuild-v2   2022-11-05 
18:06:53.000000000 +0100
+++ new/jasper-version-4.1.0/build/github/prebuild-v2   2023-11-05 
05:39:06.000000000 +0100
@@ -68,18 +68,49 @@
        sudo apt-get install "${packages[@]}" || panic "apt-get install failed"
        ;;
 macos)
+
        packages=()
-       packages+=(findutils)
-       packages+=(netpbm)
-       packages+=(wget)
-       packages+=(unzip)
+       if [ 0 -ne 0 ]; then
+               for program_name in find ppmtoppm wget unzip; do
+                       program_pathname="$(type -P "$program_name")" || 
program_pathname=
+                       if [ -z "$program_pathname" ]; then
+                               echo "$program_name program not found"
+                               case "$program_name" in
+                               find)
+                                       packages+=(findutils);;
+                               ppmtoppm)
+                                       packages+=(netpbm);;
+                               wget)
+                                       packages+=(wget);;
+                               unzip)
+                                       packages+=(unzip);;
+                               *)
+                                       panic "invalid program name 
$program_name";;
+                               esac
+                       else
+                               echo "$program_name program: $program_pathname"
+                       fi
+               done
+       else
+               packages+=(findutils)
+               packages+=(netpbm)
+               packages+=(wget)
+               packages+=(unzip)
+       fi
+
+       export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
+       export HOMEBREW_NO_INSTALL_CLEANUP=1
        brew update || panic "brew update failed"
-       brew install "${packages[@]}" || panic "brew install failed"
+       if [ "${#packages[@]}" -ne 0 ]; then
+               echo "Installing packages ${packages[@]}"
+               brew install "${packages[@]}" || panic "brew install failed"
+       fi
        cat >> "$out_file" <<- EOF
        export PATH=\$(brew --prefix)/opt/findutils/libexec/gnubin:\$PATH
        EOF
        [ $? -eq 0 ] || panic "cat failed"
        ;;
+
 windows)
        ;;
 *)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/build/install_wasi_sdk 
new/jasper-version-4.1.0/build/install_wasi_sdk
--- old/jasper-version-4.0.0/build/install_wasi_sdk     1970-01-01 
01:00:00.000000000 +0100
+++ new/jasper-version-4.1.0/build/install_wasi_sdk     2023-11-05 
05:39:06.000000000 +0100
@@ -0,0 +1,53 @@
+#! /usr/bin/env bash
+
+panic()
+{
+       echo "ERROR: $*"
+       exit 1
+}
+
+wasi_sdk_version=
+install_dir=
+
+while getopts :d:v: option; do
+       case "$option" in
+       d)
+               install_dir="$OPTARG";;
+       v)
+               wasi_sdk_version="$OPTARG";;
+       esac
+done
+
+if [ -z "$install_dir" ]; then
+       panic "no install directory specified"
+fi
+if [ -z "$wasi_sdk_version" ]; then
+       panic "no version specified"
+fi
+
+if [ ! -d "$install_dir" ]; then
+       mkdir -p "$install_dir" || \
+         panic "cannot make directory $install_dir"
+fi
+
+#source_dir="$install_dir/.source"
+#build_dir="$install_dir/.build"
+#build_dir_2="$install_dir/.build2"
+
+wasi_sdk_archive_url="https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-$wasi_sdk_version-linux.tar.gz";
+
+wasi_sdk_archive="$install_dir/.wasi-sdk.tar.xz"
+
+if [ ! -d "$install_dir" ]; then
+       mkdir -p "$install_dir" || \
+         panic "cannot make directory $install_dir"
+fi
+
+wget -O "$wasi_sdk_archive" "$wasi_sdk_archive_url" || \
+  panic "wget failed"
+tar -x -z -f "$wasi_sdk_archive" --strip-components=1 -C "$install_dir" || \
+  panic "tar failed"
+
+#rm -rf "$source_dir" || panic
+#rm -rf "$build_dir" || panic
+#rm -rf "$build_dir_2" || panic
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/build/install_wasmtime 
new/jasper-version-4.1.0/build/install_wasmtime
--- old/jasper-version-4.0.0/build/install_wasmtime     1970-01-01 
01:00:00.000000000 +0100
+++ new/jasper-version-4.1.0/build/install_wasmtime     2023-11-05 
05:39:06.000000000 +0100
@@ -0,0 +1,74 @@
+#! /usr/bin/env bash
+
+# Wasmtime release artifacts for download:
+# - library and headers for C API:
+#   wasmtime-$version-x86_64-linux-c-api.tar.xz
+# - program to run WASM applications:
+#   wasmtime-$version-x86_64-linux.tar.xz
+
+panic()
+{
+       echo "ERROR: $*"
+       exit 1
+}
+
+usage()
+{
+       cat <<- EOF
+       usage: $0 [options]
+       -d \$install_dir
+       -v \$version
+       EOF
+       exit 2
+}
+
+wasmtime_version=
+install_dir=
+
+while getopts :d:v: option; do
+       case "$option" in
+       d)
+               install_dir="$OPTARG";;
+       v)
+               wasmtime_version="$OPTARG";;
+       *)
+               usage "invalid option $OPTARG";;
+       esac
+done
+
+if [ -z "$install_dir" ]; then
+       panic "no install directory specified"
+fi
+if [ -z "$wasmtime_version" ]; then
+       panic "no version specified"
+fi
+
+if [ ! -d "$install_dir" ]; then
+       mkdir -p "$install_dir" || \
+         panic "cannot make directory $install_dir"
+fi
+
+#source_dir="$install_dir/.source"
+#build_dir="$install_dir/.build"
+#build_dir_2="$install_dir/.build2"
+
+wasmtime_archive="$install_dir/.wasmtime.tar.xz"
+wasmtime_capi_archive="$install_dir/.wasmtime-capi.tar.xz"
+wasmtime_archive_url="https://github.com/bytecodealliance/wasmtime/releases/download/v$wasmtime_version/wasmtime-v$wasmtime_version-x86_64-linux.tar.xz";
+wasmtime_capi_archive_url="https://github.com/bytecodealliance/wasmtime/releases/download/v$wasmtime_version/wasmtime-v$wasmtime_version-x86_64-linux-c-api.tar.xz";
+
+wget -O "$wasmtime_archive" "$wasmtime_archive_url" || \
+  panic "wget failed"
+wget -O "$wasmtime_capi_archive" "$wasmtime_capi_archive_url" || \
+  panic "wget failed"
+if [ ! -d "$install_dir/bin" ]; then
+       mkdir -p "$install_dir/bin"
+fi
+tar -x -J -f "$wasmtime_archive" --strip-components=1 -C "$install_dir/bin" || 
\
+  panic "tar failed"
+tar -x -J -f "$wasmtime_capi_archive" --strip-components=1 -C "$install_dir" 
|| \
+  panic "tar failed"
+
+#rm -rf "$source_dir" || panic
+#rm -rf "$build_dir" || panic
+#rm -rf "$build_dir_2" || panic
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/build/jasper.pc.in 
new/jasper-version-4.1.0/build/jasper.pc.in
--- old/jasper-version-4.0.0/build/jasper.pc.in 2022-11-05 18:06:53.000000000 
+0100
+++ new/jasper-version-4.1.0/build/jasper.pc.in 2023-11-05 05:39:06.000000000 
+0100
@@ -1,6 +1,7 @@
 prefix=@CMAKE_INSTALL_PREFIX@
-libdir=@CMAKE_INSTALL_FULL_LIBDIR@
-includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
+exec_prefix=${prefix}
+libdir=@JAS_PC_LIBDIR@
+includedir=@JAS_PC_INCLUDEDIR@
 
 Name: JasPer
 Description: Image Processing/Coding Tool Kit with JPEG-2000 Support
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/build/make_release 
new/jasper-version-4.1.0/build/make_release
--- old/jasper-version-4.0.0/build/make_release 2022-11-05 18:06:53.000000000 
+0100
+++ new/jasper-version-4.1.0/build/make_release 2023-11-05 05:39:06.000000000 
+0100
@@ -1,30 +1,55 @@
 #! /usr/bin/env bash
 
-cmd_dir="$(dirname "$0")" || panic
+################################################################################
 
 panic()
 {
-       echo "ERROR: $@"
+       echo "ERROR: $*" 1>& 2
        exit 1
 }
 
 warn()
 {
-       echo "WARNING: $@"
+       echo "WARNING: $*" 1>& 2
 }
 
 usage()
 {
-       echo "bad usage: $@"
+       cat <<- EOF
+       usage:
+       $0 [options]
+
+       Example
+       =======
+
+       $0 -w $self_dir/.. \\
+         -W 1 \\
+         -t /tmp/jasper/tmp \\
+         -o /tmp/jasper/output \\
+         -r refs/tags/mdadams-experimental-version-wasm1
+       EOF
+       if [ $# -ne 0 ]; then
+               echo "BAD USAGE: $*"
+       fi
        exit 2
 }
 
+################################################################################
+
+self_dir="$(dirname "$0")" || panic
+build_wasi_jasper="$self_dir/build_wasi_jasper"
+
+################################################################################
+# Command-Line Processing
+################################################################################
+
 tmp_dir=
 workspace_dir=
 out_dir=
 github_ref=
+enable_wasm=0
 
-while getopts t:w:o:r: opt; do
+while getopts :t:w:o:r:W:h opt; do
        case "$opt" in
        w)
                workspace_dir="$OPTARG";;
@@ -34,14 +59,16 @@
                out_dir="$OPTARG";;
        r)
                github_ref="$OPTARG";;
-       \?)
-               usage "invalid option $opt"
-               break;;
+       W)
+               enable_wasm="$OPTARG";;
+       h)
+               usage;;
+       *)
+               usage "invalid option $OPTARG";;
        esac
 done
 shift $((OPTIND - 1))
 
-
 if [ -z "$github_ref" ]; then
        usage "no GitHub ref specified"
 fi
@@ -67,14 +94,54 @@
 echo "workspace directory: $workspace_dir"
 echo "GitHub ref: $github_ref"
 
+################################################################################
+#
+################################################################################
+
 commit="$(git -C "$workspace_dir" rev-parse HEAD)" || \
   panic "cannot get commit"
 #tag="$(git -C "$workspace_dir" describe "$commit")" || \
 #  panic "cannot get tag"
 tag="$(awk -v FS="/" '{print $3;}' <<< "$github_ref")" || \
   panic "cannot get tag"
-version="$(awk -v FS="-" '{print $2;}' <<< "$tag")" || \
-  panic "cannot get version"
+
+release_type=
+grep -q -E '^version-.*$' <<< "$tag" && release_type=normal
+if [ -z "$release_type" ]; then
+       grep -q -E '^experimental-version-.*$' <<< "$tag" && \
+         release_type=experimental
+fi
+if [ -z "$release_type" ]; then
+       grep -q -E '^mdadams-experimental-version-.*$' <<< "$tag" && \
+         release_type=mdadams
+fi
+case "$release_type" in
+normal)
+       version="$(awk -v FS="-" '{print $2;}' <<< "$tag")" || \
+         panic "cannot get version"
+       ;;
+experimental)
+       version="$(awk -v FS="-" '{print $3;}' <<< "$tag")" || \
+         panic "cannot get version"
+       ;;
+mdadams)
+       version="$(awk -v FS="-" '{print $4;}' <<< "$tag")" || \
+         panic "cannot get version"
+       ;;
+*)
+       #version="$tag"
+       panic "unknown release type"
+       ;;
+esac
+
+cat <<- EOF
+release type: $release_type
+EOF
+
+################################################################################
+#
+################################################################################
+
 name="jasper-$version"
 
 source_dir="$tmp_dir/$name"
@@ -108,8 +175,26 @@
   fmt --split-only > "$changelog_file" || \
   panic "cannot generate changelog"
 
-"$cmd_dir"/extract_release_notes < "$news_file" > "$release_notes_file" || \
-  panic
+case "$release_type" in
+normal)
+       "$self_dir"/extract_release_notes \
+         < "$news_file" \
+         > "$release_notes_file" \
+         || \
+         panic
+       ;;
+experimental|mdadams)
+       cat > "$release_notes_file" <<- EOF
+       WARNING: DO NOT USE THIS RELEASE!
+
+       This is an experimental release whose sole purpose is to test some of
+       the software build/deployment infrastructure employed in this project.
+       EOF
+       ;;
+*)
+       panic "unknown release type"
+       ;;
+esac
 
 cmake \
   -G "Unix Makefiles" \
@@ -159,3 +244,30 @@
 
 tar -C "$tmp_dir" -czf - "$name" > "$archive_file" || \
   panic "cannot make archive"
+
+################################################################################
+
+if [ "$enable_wasm" -ne 0 ]; then
+
+       name="jasper-WebAssembly-$version"
+
+       stage_dir="$tmp_dir/wasm"
+       archive_file="$out_dir/$name.tar.gz"
+
+       echo "stage directory: $stage_dir"
+       echo "archive file: $archive_file"
+
+       JAS_TMP_DIR="$tmp_dir" \
+         "$build_wasi_jasper" -V "$version" -o "$stage_dir/$name" || \
+         panic "cannot build WASI jasper"
+
+       ls -al "$stage_dir"
+       (cd "$stage_dir" && ls -al)
+
+       tar -C "$stage_dir" -c -z -f - "$name" > "$archive_file" || \
+         panic "cannot make archive"
+
+fi
+
+################################################################################
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/build/wasm_cc 
new/jasper-version-4.1.0/build/wasm_cc
--- old/jasper-version-4.0.0/build/wasm_cc      1970-01-01 01:00:00.000000000 
+0100
+++ new/jasper-version-4.1.0/build/wasm_cc      2023-11-05 05:39:06.000000000 
+0100
@@ -0,0 +1,46 @@
+#! /usr/bin/env bash
+
+eecho()
+{
+       echo "$*" 1>&2
+}
+
+panic()
+{
+       eecho "$*"
+       exit 1
+}
+
+#mode=zig
+mode=wasi_sdk
+
+#eecho "wasm_cc mode: $mode"
+
+case "$mode" in
+
+wasi_sdk)
+       if [ -z "$WASI_SDK_ROOT_DIR" ]; then
+               panic "WASI_SDK_ROOT_DIR not set"
+       fi
+       wasi_sdk_path="$WASI_SDK_ROOT_DIR"
+       clang=$wasi_sdk_path/bin/clang
+       if [ ! -x "$clang" ]; then
+               panic "clang not found ($clang)"
+       fi
+       exec "$clang" --sysroot=$wasi_sdk_path/share/wasi-sysroot "$@"
+       ;;
+
+zig)
+       if [ -z "$WASM_ROOT_DIR" ]; then
+               panic "WASM_ROOT_DIR not set"
+       fi
+       wasm_root_dir="$WASM_ROOT_DIR"
+       #zig="$(type -P zig)" || zig=false
+       zig="$wasm_root_dir/zig/zig"
+       if [ ! -x "$zig" ]; then
+               panic "zig not found ($zig)"
+       fi
+       exec "$zig" cc --target=wasm32-wasi "$@"
+       ;;
+
+esac
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/data/test/bad/353.pnm 
new/jasper-version-4.1.0/data/test/bad/353.pnm
--- old/jasper-version-4.0.0/data/test/bad/353.pnm      1970-01-01 
01:00:00.000000000 +0100
+++ new/jasper-version-4.1.0/data/test/bad/353.pnm      2023-11-05 
05:39:06.000000000 +0100
@@ -0,0 +1,4 @@
+P28 8
+400
+300000000000000000000000000 0
+0 0 0 0 0 0 
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/data/test/good/signed_pnm.pnm 
new/jasper-version-4.1.0/data/test/good/signed_pnm.pnm
--- old/jasper-version-4.0.0/data/test/good/signed_pnm.pnm      1970-01-01 
01:00:00.000000000 +0100
+++ new/jasper-version-4.1.0/data/test/good/signed_pnm.pnm      2023-11-05 
05:39:06.000000000 +0100
@@ -0,0 +1,10 @@
+P2 8 8
+-255
++000 +001 +002 +003 +004 +005 +006 +007
+-010 +011 +012 +013 +014 +015 +016 +017
+-020 -021 +022 +023 +024 +025 +026 +027
+-030 -031 -032 +033 +034 +035 +036 +037
+-040 -041 -042 -043 +044 +045 +046 +047
+-050 -051 -052 -053 -054 +055 +056 +057
+-060 -061 -062 -063 -064 -065 +066 +067
+-070 -071 -072 -073 -074 -075 -076 +077
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/doc/CMakeLists.txt 
new/jasper-version-4.1.0/doc/CMakeLists.txt
--- old/jasper-version-4.0.0/doc/CMakeLists.txt 2022-11-05 18:06:53.000000000 
+0100
+++ new/jasper-version-4.1.0/doc/CMakeLists.txt 2023-11-05 05:39:06.000000000 
+0100
@@ -44,7 +44,7 @@
                add_custom_command(OUTPUT "latex/refman.pdf"
                  COMMAND "${PDFLATEX_COMPILER}" refman.tex
                  WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/latex"
-                 DEPENDS "latex/index.tex"
+                 DEPENDS "doc"
                )
 
                add_custom_target(manual_pdf ALL
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/src/libjasper/base/jas_malloc.c 
new/jasper-version-4.1.0/src/libjasper/base/jas_malloc.c
--- old/jasper-version-4.0.0/src/libjasper/base/jas_malloc.c    2022-11-05 
18:06:53.000000000 +0100
+++ new/jasper-version-4.1.0/src/libjasper/base/jas_malloc.c    2023-11-05 
05:39:06.000000000 +0100
@@ -626,7 +626,15 @@
 
 size_t jas_get_total_mem_size()
 {
-#if defined(__linux__)
+#if defined(JAS_WASI_LIBC)
+       /*
+       NOTE: On the 32-bit WebAssembly platform, the unsigned integral type
+       size_t is likely to have a size of 32 bits.  So, choose the maximum
+       memory to be less than 2 ^ 32 in order to avoid overflow.
+       */
+       return JAS_CAST(size_t, 4096) * JAS_CAST(size_t, 1024) *
+         JAS_CAST(size_t, 1024) - 1;
+#elif defined(__linux__)
        struct sysinfo buf;
        if (sysinfo(&buf)) {
                return 0;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/src/libjasper/base/jas_stream.c 
new/jasper-version-4.1.0/src/libjasper/base/jas_stream.c
--- old/jasper-version-4.0.0/src/libjasper/base/jas_stream.c    2022-11-05 
18:06:53.000000000 +0100
+++ new/jasper-version-4.1.0/src/libjasper/base/jas_stream.c    2023-11-05 
05:39:06.000000000 +0100
@@ -459,6 +459,8 @@
        return open(buffer,
          O_CREAT | O_EXCL | O_RDWR | O_TRUNC | O_BINARY | O_CLOEXEC,
          JAS_STREAM_PERMS);
+#elif defined(JAS_WASI_LIBC)
+       return -1;
 #else
 #ifdef JAS_HAVE_MKOSTEMP
        return mkostemp(buffer, O_CLOEXEC);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/jasper-version-4.0.0/src/libjasper/include/jasper/jas_math.h 
new/jasper-version-4.1.0/src/libjasper/include/jasper/jas_math.h
--- old/jasper-version-4.0.0/src/libjasper/include/jasper/jas_math.h    
2022-11-05 18:06:53.000000000 +0100
+++ new/jasper-version-4.1.0/src/libjasper/include/jasper/jas_math.h    
2023-11-05 05:39:06.000000000 +0100
@@ -487,6 +487,123 @@
 }
 
 
/******************************************************************************\
+* Safe 64-bit signed integer arithmetic (i.e., with overflow checking).
+\******************************************************************************/
+
+typedef struct {
+       bool valid;
+       int_least64_t value;
+} jas_safei64_t;
+
+JAS_ATTRIBUTE_CONST
+static inline
+jas_safei64_t jas_safei64_from_intmax(intmax_t x)
+{
+       jas_safei64_t result;
+       if (x >= INT_LEAST64_MIN && x <= INT_LEAST64_MAX) {
+               result.valid = true;
+               result.value = JAS_CAST(int_least64_t, x);
+       } else {
+               result.valid = false;
+               result.value = 0;
+       }
+       return result;
+}
+
+JAS_ATTRIBUTE_CONST
+static inline
+jas_safei64_t jas_safei64_add(jas_safei64_t x, jas_safei64_t y)
+{
+       jas_safei64_t result;
+       if (((y.value > 0) && (x.value > (INT_LEAST64_MAX - y.value))) ||
+         ((y.value < 0) && (x.value < (INT_LEAST64_MIN - y.value)))) {
+               result.value = false;
+               result.value = 0;
+       } else {
+               result.valid = true;
+               result.value = x.value + y.value;
+       }
+       return result;
+}
+
+JAS_ATTRIBUTE_CONST
+static inline
+jas_safei64_t jas_safei64_sub(jas_safei64_t x, jas_safei64_t y)
+{
+       jas_safei64_t result;
+       if ((y.value > 0 && x.value < INT_LEAST64_MIN + y.value) ||
+       (y.value < 0 && x.value > INT_LEAST64_MAX + y.value)) {
+               result.valid = false;
+               result.value = 0;
+       } else {
+               result.valid = true;
+               result.value = x.value - y.value;
+       }
+       return result;
+}
+
+JAS_ATTRIBUTE_CONST
+static inline
+jas_safei64_t jas_safei64_mul(jas_safei64_t x, jas_safei64_t y)
+{
+       jas_safei64_t result;
+       if (x.value > 0) {  /* x.value is positive */
+               if (y.value > 0) {  /* x.value and y.value are positive */
+                       if (x.value > (INT_LEAST64_MAX / y.value)) {
+                               goto error;
+                       }
+               } else { /* x.value positive, y.value nonpositive */
+                       if (y.value < (INT_LEAST64_MIN / x.value)) {
+                               goto error;
+                       }
+               } /* x.value positive, y.value nonpositive */
+       } else { /* x.value is nonpositive */
+               if (y.value > 0) { /* x.value is nonpositive, y.value is 
positive */
+                       if (x.value < (INT_LEAST64_MIN / y.value)) {
+                               goto error;
+                       }
+               } else { /* x.value and y.value are nonpositive */
+                       if ( (x.value != 0) && (y.value < (INT_LEAST64_MAX / 
x.value))) {
+                               goto error;
+                       }
+               } /* End if x.value and y.value are nonpositive */
+       } /* End if x.value is nonpositive */
+       result.valid = true;
+       result.value = x.value * y.value;
+       return result;
+error:
+       result.valid = false;
+       result.value = 0;
+       return result;
+}
+
+#if 0
+JAS_ATTRIBUTE_CONST
+static inline
+jas_safei64_t jas_safei64_div(jas_safei64_t x, jas_safei64_t y)
+{
+       // TODO/FIXME: Not yet implemented.
+       jas_safei64_t result;
+       result.valid = false;
+       result.value = 0;
+       return result;
+}
+#endif
+
+JAS_ATTRIBUTE_CONST
+static inline
+jas_i32_t jas_safei64_to_i32(jas_safei64_t x, jas_i32_t invalid_value)
+{
+       jas_i32_t result;
+       if (x.valid && x.value >= JAS_I32_MIN && x.value <= JAS_I32_MAX) {
+               result = JAS_CAST(jas_i32_t, x.value);
+       } else {
+               result = invalid_value;
+       }
+       return result;
+}
+
+/******************************************************************************\
 * Safe 64-bit unsigned integer arithmetic (i.e., with overflow checking).
 
\******************************************************************************/
 
@@ -596,6 +713,32 @@
        } else {
                result = invalid_value;
        }
+       return result;
+}
+
+JAS_ATTRIBUTE_CONST
+static inline
+jas_ui32_t jas_safeui64_to_ui32(jas_safeui64_t x, jas_ui32_t invalid_value)
+{
+       jas_ui32_t result;
+       if (x.valid && x.value <= JAS_UI32_MAX) {
+               result = JAS_CAST(jas_ui32_t, x.value);
+       } else {
+               result = invalid_value;
+       }
+       return result;
+}
+
+JAS_ATTRIBUTE_CONST
+static inline
+jas_i32_t jas_safeui64_to_i32(jas_safeui64_t x, jas_i32_t invalid_value)
+{
+       jas_i32_t result;
+       if (x.valid && x.value >= JAS_I32_MIN && x.value <= JAS_I32_MAX) {
+               result = JAS_CAST(jas_i32_t, x.value);
+       } else {
+               result = invalid_value;
+       }
        return result;
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/jasper-version-4.0.0/src/libjasper/include/jasper/jas_stream.h 
new/jasper-version-4.1.0/src/libjasper/include/jasper/jas_stream.h
--- old/jasper-version-4.0.0/src/libjasper/include/jasper/jas_stream.h  
2022-11-05 18:06:53.000000000 +0100
+++ new/jasper-version-4.1.0/src/libjasper/include/jasper/jas_stream.h  
2023-11-05 05:39:06.000000000 +0100
@@ -258,6 +258,9 @@
 typedef struct {
        int fd;
        int flags;
+#if defined(JAS_WASI_LIBC)
+#define L_tmpnam 4096
+#endif
        char pathname[L_tmpnam + 1];
 } jas_stream_fileobj_t;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/jasper-version-4.0.0/src/libjasper/include/jasper/jas_types.h 
new/jasper-version-4.1.0/src/libjasper/include/jasper/jas_types.h
--- old/jasper-version-4.0.0/src/libjasper/include/jasper/jas_types.h   
2022-11-05 18:06:53.000000000 +0100
+++ new/jasper-version-4.1.0/src/libjasper/include/jasper/jas_types.h   
2023-11-05 05:39:06.000000000 +0100
@@ -201,6 +201,15 @@
 #endif
 #endif
 
+/* 32-bit unsigned integer type */
+typedef uint_least32_t jas_ui32_t;
+#define JAS_UI32_MAX UINT_LEAST32_MAX
+
+/* 32-bit signed integer type */
+typedef int_least32_t jas_i32_t;
+#define JAS_I32_MIN INT_LEAST32_MIN
+#define JAS_I32_MAX INT_LEAST32_MAX
+
 #ifdef __cplusplus
 }
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jasper-version-4.0.0/src/libjasper/pnm/pnm_dec.c 
new/jasper-version-4.1.0/src/libjasper/pnm/pnm_dec.c
--- old/jasper-version-4.0.0/src/libjasper/pnm/pnm_dec.c        2022-11-05 
18:06:53.000000000 +0100
+++ new/jasper-version-4.1.0/src/libjasper/pnm/pnm_dec.c        2023-11-05 
05:39:06.000000000 +0100
@@ -549,7 +549,6 @@
 
 static int pnm_getuintstr(jas_stream_t *in, uint_fast32_t *val)
 {
-       uint_fast32_t v;
        int c;
 
        /* Discard any leading whitespace. */
@@ -560,14 +559,21 @@
        } while (isspace(JAS_CAST(unsigned char, c)));
 
        /* Parse the number. */
-       v = 0;
+       jas_safeui64_t value = jas_safeui64_from_intmax(0);
        while (isdigit(JAS_CAST(unsigned char, c))) {
-               v = 10 * v + c - '0';
+               int d = c - '0';
+               value = jas_safeui64_mul(value, jas_safeui64_from_intmax(10));
+               value = jas_safeui64_add(value, jas_safeui64_from_intmax(d));
                if ((c = pnm_getc(in)) < 0) {
                        return -1;
                }
        }
 
+       uint_fast32_t v = jas_safeui64_to_ui32(value, JAS_UI32_MAX);
+       if (v == JAS_UI32_MAX) {
+               return -1;
+       }
+
        /* The number must be followed by whitespace. */
        if (!isspace(JAS_CAST(unsigned char, c))) {
                return -1;
@@ -604,19 +610,18 @@
                }
        }
 
-       jas_safeui32_t sv = jas_safeui32_from_ulong(0);
+       jas_safei64_t sv = jas_safei64_from_intmax(0);
        while (isdigit(JAS_CAST(unsigned char, c))) {
                // sv = 10 * sv + c - '0';
-               sv = jas_safeui32_add(
-                 jas_safeui32_mul(sv, jas_safeui32_from_ulong(10)),
-                 jas_safeui32_sub(jas_safeui32_from_ulong(c),
-                 jas_safeui32_from_ulong('0')));
+               int d = c - '0';
+               sv = jas_safei64_mul(sv, jas_safei64_from_intmax(10));
+               sv = jas_safei64_add(sv, jas_safei64_from_intmax(d));
                if ((c = pnm_getc(in)) < 0) {
                        return -1;
                }
        }
-       int_fast32_t v;
-       if (!jas_safeui32_to_intfast32(sv, &v)) {
+       int_fast32_t v = jas_safei64_to_i32(sv, JAS_I32_MAX);
+       if (v == JAS_I32_MAX) {
                return -1;
        }
 

Reply via email to