From 96cca4557d34227d9e18a9c30019d13533830094 Mon Sep 17 00:00:00 2001
From: Sander Jansen <s.jansen@gmail.com>
Date: Wed, 14 Jun 2023 21:08:05 -0500
Subject: [PATCH] fox 1.7.83 compatibility fixes

---
 gap/ap_utils.cpp         |  5 +++++
 src/GMCover.cpp          |  4 ++++
 src/GMDatabaseSource.cpp |  4 ++++
 src/GMFilename.cpp       |  8 ++++++++
 src/GMScanner.cpp        |  9 ++++++++-
 src/gmutils.cpp          | 19 +++++++++++++++++++
 6 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/gap/ap_utils.cpp b/gap/ap_utils.cpp
index 76aeb906..96986ba5 100644
--- a/gap/ap_utils.cpp
+++ b/gap/ap_utils.cpp
@@ -510,8 +510,13 @@ FXbool ap_md5_digest(FXString & io) {
 
   io.length(32);
   for (FXint i=0,d=0;i<32;i+=2,d++) {
+#if FOXVERSION < FXVERSION(1, 7, 83)
     io[i]=Ascii::toLower(FXString::value2Digit[(digest[d]/16)%16]);
     io[i+1]=Ascii::toLower(FXString::value2Digit[digest[d]%16]);
+#else
+    io[i]=Ascii::toLower(Ascii::valueDigit((digest[d]/16)%16));
+    io[i+1]=Ascii::toLower(Ascii::valueDigit(digest[d]%16));
+#endif
     }
 
   return true;
diff --git a/src/GMCover.cpp b/src/GMCover.cpp
index ea2b2de7..317e01f4 100644
--- a/src/GMCover.cpp
+++ b/src/GMCover.cpp
@@ -495,7 +495,11 @@ GMCover * GMCover::fromPath(const FXString & path) {
   if (nfiles) {
     names = new FXString[nfiles];
     for (FXint i=0;i<nfiles;i++)
+#if FOXVERSION < FXVERSION(1, 7, 83)
       names[i]=FXPath::title(files[i]);
+#else
+      names[i]=FXPath::stem(files[i]);
+#endif
 
     for (FXint c=0;covernames[c]!=nullptr;c++) {
       for (FXint i=0;i<nfiles;i++){
diff --git a/src/GMDatabaseSource.cpp b/src/GMDatabaseSource.cpp
index a9c66908..2c4df1b4 100644
--- a/src/GMDatabaseSource.cpp
+++ b/src/GMDatabaseSource.cpp
@@ -1606,7 +1606,11 @@ long GMDatabaseSource::onCmdImportPlayList(FXObject*,FXSelector,void*){
         gm_make_absolute_path(FXPath::directory(dialog.getFilename()),urls);
 
         title.trim();
+#if FOXVERSION < FXVERSION(1, 7, 83)
         if (title.empty()) title = FXPath::title(dialog.getFilename());
+#else
+        if (title.empty()) title = FXPath::stem(dialog.getFilename());
+#endif
 
         FXint pl = GMPlayerManager::instance()->createPlaylist(title);
 
diff --git a/src/GMFilename.cpp b/src/GMFilename.cpp
index 93acfbd5..c171a440 100644
--- a/src/GMFilename.cpp
+++ b/src/GMFilename.cpp
@@ -473,7 +473,11 @@ void parse(GMTrack & track,const FXString & mask,FXuint options) {
   /// Remove path components from the front that are not part of the mask
   /// Or if the mask doesn't specifiy path components, we just take the title of the filename.
   if (nsep) {
+#if FOXVERSION < FXVERSION(1, 7, 83)
     input=FXPath::title(track.url);
+#else
+    input=FXPath::stem(track.url);
+#endif
     FXString dir=FXPath::directory(track.url);
     for (i=0;i<nsep;i++) {
       input = FXPath::name(dir) + PATHSEPSTRING + input;
@@ -481,7 +485,11 @@ void parse(GMTrack & track,const FXString & mask,FXuint options) {
       }
     }
   else {
+#if FOXVERSION < FXVERSION(1, 7, 83)
     input=FXPath::title(track.url);
+#else
+    input=FXPath::stem(track.url);
+#endif
     }
 
   // Start from fresh
diff --git a/src/GMScanner.cpp b/src/GMScanner.cpp
index e664a3e3..879cba23 100644
--- a/src/GMScanner.cpp
+++ b/src/GMScanner.cpp
@@ -246,7 +246,11 @@ void GMDBTracks::insert(GMTrack & track,FXint & path_index) {
     /// Insert Track
     insert_track.set(0,path_index);
     insert_track.set(1,path_index ? FXPath::name(track.url) : track.url);
+#if FOXVERSION < FXVERSION(1, 7, 83)
     insert_track.set(2,track.title.empty() ? FXPath::title(track.url) : track.title);
+#else
+    insert_track.set(2,track.title.empty() ? FXPath::stem(track.url) : track.title);
+#endif
     insert_track.set(3,track.time);
     insert_track.set(4,track.no);
     insert_track.set(5,track.year);
@@ -287,7 +291,11 @@ void GMDBTracks::update(GMTrack & track) {
   FXint album_id        = insertAlbum(track,album_artist_id);
 
   /// Update Tracks
+#if FOXVERSION < FXVERSION(1, 7, 83)
   update_track.set(0,track.title.empty() ? FXPath::title(track.url) : track.title);
+#else
+  update_track.set(0,track.title.empty() ? FXPath::stem(track.url) : track.title);
+#endif
   update_track.set(1,track.time);
   update_track.set(2,track.no);
   update_track.set(3,track.year);
@@ -1058,4 +1066,3 @@ void GMRemoveTask::remove(GMTaskTransaction & transaction) {
     }
   if (changed) database->sync_tracks_removed();
   }
-
diff --git a/src/gmutils.cpp b/src/gmutils.cpp
index 7ef97a59..fd3eb02d 100644
--- a/src/gmutils.cpp
+++ b/src/gmutils.cpp
@@ -159,8 +159,13 @@ FXString gm_url_encode(const FXString& url){
 //    if(!Ascii::isAlphaNumeric(c) && ((c<=' ' || c>='{') || strchr(URL_UNSAFE URL_RESERVED,c))){
     if (!Ascii::isAlphaNumeric(c)){
       result.append('%');
+#if FOXVERSION < FXVERSION(1, 7, 83)
       result.append(FXString::value2Digit[(c>>4)&15]);
       result.append(FXString::value2Digit[c&15]);
+#else
+      result.append(Ascii::valueDigit((c>>4)&15));
+      result.append(Ascii::valueDigit(c&15));
+#endif
       continue;
       }
     result.append(c);
@@ -553,6 +558,7 @@ void gm_bgra_to_rgba(FXColor * inbuf,FXColor * outbuf, FXint len) {
 */
 
 
+#if FOXVERSION < FXVERSION(1, 7, 83)
 #define ONE_DIGIT_VALUE(d1) (FXString::digit2Value[(FXuchar)d1])
 #define TWO_DIGIT_VALUE(d1,d2) (FXString::digit2Value[(FXuchar)d1]*10) + (FXString::digit2Value[(FXuchar)d2])
 #define THREE_DIGIT_VALUE(d1,d2,d3) (FXString::digit2Value[(FXuchar)d1]*100) +\
@@ -563,6 +569,19 @@ void gm_bgra_to_rgba(FXColor * inbuf,FXColor * outbuf, FXint len) {
                                       (FXString::digit2Value[(FXuchar)d2]*100) + \
                                       (FXString::digit2Value[(FXuchar)d3]*10) +\
                                       (FXString::digit2Value[(FXuchar)d4])
+#else
+#define ONE_DIGIT_VALUE(d1) (Ascii::digitValue((FXuchar)d1))
+#define TWO_DIGIT_VALUE(d1,d2) (Ascii::digitValue((FXuchar)d1)*10) + (Ascii::digitValue((FXuchar)d2))
+#define THREE_DIGIT_VALUE(d1,d2,d3) (Ascii::digitValue((FXuchar)d1)*100) +\
+                                    (Ascii::digitValue((FXuchar)d2)*10) +\
+                                    (Ascii::digitValue((FXuchar)d3))
+
+#define FOUR_DIGIT_VALUE(d1,d2,d3,d4) (Ascii::digitValue((FXuchar)d1)*1000) + \
+                                      (Ascii::digitValue((FXuchar)d2)*100) + \
+                                      (Ascii::digitValue((FXuchar)d3)*10) +\
+                                      (Ascii::digitValue((FXuchar)d4))
+#endif
+
 
 FXbool gm_parse_datetime(const FXString & str,FXTime & timestamp) {
   if (str.empty()) return false;
