SDL_image: Fixed test-versioning.sh on macOS

From 0c9bfe844ba7f48cbfa03f6395c9c4698bf4ba3b Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 25 May 2022 12:01:45 -0700
Subject: [PATCH] Fixed test-versioning.sh on macOS

---
 test-versioning.sh | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/test-versioning.sh b/test-versioning.sh
index d3f2f9d..e29d5ee 100755
--- a/test-versioning.sh
+++ b/test-versioning.sh
@@ -4,6 +4,9 @@
 
 set -eu
 
+# Needed so sed doesn't report illegal byte sequences on macOS
+export LC_CTYPE=C
+
 ref_major=$(sed -ne 's/^#define SDL_IMAGE_MAJOR_VERSION  *//p' SDL_image.h)
 ref_minor=$(sed -ne 's/^#define SDL_IMAGE_MINOR_VERSION  *//p' SDL_image.h)
 ref_micro=$(sed -ne 's/^#define SDL_IMAGE_PATCHLEVEL  *//p' SDL_image.h)
@@ -24,10 +27,11 @@ not_ok () {
     failed=1
 }
 
-major=$(sed -Ene 's/^m4_define\(\[MAJOR_VERSION_MACRO\], \[([0-9]+)\]\)$/\1/p' configure.ac)
-minor=$(sed -Ene 's/^m4_define\(\[MINOR_VERSION_MACRO\], \[([0-9]+)\]\)$/\1/p' configure.ac)
-micro=$(sed -Ene 's/^m4_define\(\[MICRO_VERSION_MACRO\], \[([0-9]+)\]\)$/\1/p' configure.ac)
+major=$(sed -Ene 's/^m4_define\(\[MAJOR_VERSION_MACRO\], \[([0-9]*)\]\)$/\1/p' configure.ac)
+minor=$(sed -Ene 's/^m4_define\(\[MINOR_VERSION_MACRO\], \[([0-9]*)\]\)$/\1/p' configure.ac)
+micro=$(sed -Ene 's/^m4_define\(\[MICRO_VERSION_MACRO\], \[([0-9]*)\]\)$/\1/p' configure.ac)
 version="${major}.${minor}.${micro}"
+ref_sdl_req=$(sed -ne 's/^SDL_VERSION=//p' configure.ac)
 
 if [ "$ref_version" = "$version" ]; then
     ok "configure.ac $version"
@@ -35,10 +39,11 @@ else
     not_ok "configure.ac $version disagrees with SDL_image.h $ref_version"
 fi
 
-major=$(sed -ne 's/^set(MAJOR_VERSION \([0-9]\+\))$/\1/p' CMakeLists.txt)
-minor=$(sed -ne 's/^set(MINOR_VERSION \([0-9]\+\))$/\1/p' CMakeLists.txt)
-micro=$(sed -ne 's/^set(MICRO_VERSION \([0-9]\+\))$/\1/p' CMakeLists.txt)
-sdl_req=$(sed -ne 's/^set(SDL_REQUIRED_VERSION \([0-9.]\+\))$/\1/p' CMakeLists.txt)
+major=$(sed -ne 's/^set(MAJOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
+minor=$(sed -ne 's/^set(MINOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
+micro=$(sed -ne 's/^set(MICRO_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
+sdl_req=$(sed -ne 's/^set(SDL_REQUIRED_VERSION \([0-9.]*\))$/\1/p' CMakeLists.txt)
+version="${major}.${minor}.${micro}"
 
 if [ "$ref_version" = "$version" ]; then
     ok "CMakeLists.txt $version"
@@ -81,7 +86,7 @@ for rcfile in version.rc VisualC/Version.rc; do
         not_ok "$rcfile PRODUCTVERSION $tuple disagrees with SDL_image.h $ref_tuple"
     fi
 
-    tuple=$(sed -Ene 's/^ *VALUE "FileVersion", "([0-9, ]+)\\0"\r?$/\1/p' "$rcfile" | tr -d '\r')
+    tuple=$(sed -Ene 's/^ *VALUE "FileVersion", "([0-9, ]*)\\0"\r?$/\1/p' "$rcfile" | tr -d '\r')
     ref_tuple="${ref_major}, ${ref_minor}, ${ref_micro}, 0"
 
     if [ "$ref_tuple" = "$tuple" ]; then
@@ -90,7 +95,7 @@ for rcfile in version.rc VisualC/Version.rc; do
         not_ok "$rcfile FileVersion $tuple disagrees with SDL_image.h $ref_tuple"
     fi
 
-    tuple=$(sed -Ene 's/^ *VALUE "ProductVersion", "([0-9, ]+)\\0"\r?$/\1/p' "$rcfile" | tr -d '\r')
+    tuple=$(sed -Ene 's/^ *VALUE "ProductVersion", "([0-9, ]*)\\0"\r?$/\1/p' "$rcfile" | tr -d '\r')
 
     if [ "$ref_tuple" = "$tuple" ]; then
         ok "$rcfile ProductVersion $tuple"
@@ -126,7 +131,7 @@ else
     not_ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is inconsistent"
 fi
 
-dylib_compat=$(sed -ne 's/^set(DYLIB_COMPATIBILITY_VERSION "\([0-9.]\+\)")$/\1/p' CMakeLists.txt)
+dylib_compat=$(sed -ne 's/^set(DYLIB_COMPATIBILITY_VERSION "\([0-9.]*\)")$/\1/p' CMakeLists.txt)
 ref='3.0.0'
 
 if [ "$ref" = "$dylib_compat" ]; then
@@ -157,7 +162,7 @@ else
     not_ok "project.pbxproj DYLIB_CURRENT_VERSION is inconsistent"
 fi
 
-sdl_req=$(sed -ne 's/\$sdl2_version = "\([0-9.]\+\)"$/\1/p' .github/fetch_sdl_vc.ps1)
+sdl_req=$(sed -ne 's/\$sdl2_version = "\([0-9.]*\)"$/\1/p' .github/fetch_sdl_vc.ps1)
 
 if [ "$ref_sdl_req" = "$sdl_req" ]; then
     ok ".github/fetch_sdl_vc.ps1 $sdl_req"