Browse Source

fix various win32 ONLY problems

Pal Lockheart 2 years ago
parent
commit
5541564ada
5 changed files with 27 additions and 14 deletions
  1. 2 1
      common.h
  2. 14 11
      palcfg.c
  3. 1 1
      video.c
  4. 3 1
      win32/pal_config.h
  5. 7 0
      win32/win32.cpp

+ 2 - 1
common.h

@@ -51,6 +51,8 @@
 # include <math.h>
 #endif
 
+#include <float.h>
+
 #ifndef max
 # define max fmax
 #endif
@@ -115,7 +117,6 @@ typedef const BYTE *LPCBYTE;
 
 # include <unistd.h>
 # include <dirent.h>
-# include <float.h>
 # ifdef __APPLE__
 #  include <objc/objc.h>
 # endif

+ 14 - 11
palcfg.c

@@ -418,22 +418,25 @@ PAL_LoadConfig(
 				case PALCFG_MIDICLIENT:
 					gConfig.pszMIDIClient = ParseStringValue(value.sValue, gConfig.pszMIDIClient);
 					break;
-                case PALCFG_SCALEQUALITY:
-                    gConfig.pszScaleQuality = ParseStringValue(value.sValue, gConfig.pszScaleQuality);
-                    break;
-                case PALCFG_ASPECTRATIO:
-                {
-                    char *origAspectRatio = strdup(value.sValue);
-                    char *aspectRatio = ParseStringValue(value.sValue, origAspectRatio);
-                    char *lasts;
+				case PALCFG_SCALEQUALITY:
+					gConfig.pszScaleQuality = ParseStringValue(value.sValue, gConfig.pszScaleQuality);
+					break;
+				case PALCFG_ASPECTRATIO:
+				{
+					size_t len = strlen(value.sValue) + 1;
+					char *origAspectRatio = (char*)malloc(len);
+					memset(origAspectRatio, 0, len);
+					strncpy(origAspectRatio, value.sValue, strlen(value.sValue));
+					char *aspectRatio = ParseStringValue(value.sValue, origAspectRatio);
+					char *lasts;
 					if( strchr(aspectRatio,':') == NULL ) {
 						aspectRatio = ParseStringValue(item->DefaultValue.sValue, origAspectRatio);
 					}
 					dwAspectX = atoi(strtok_r(aspectRatio,":",&lasts));
 					dwAspectY = atoi(strtok_r(NULL,       ":",&lasts));
-                    free(origAspectRatio);
-                    break;
-                }
+					free(aspectRatio);
+					break;
+				}
 				default:
 					values[item->Item] = value;
 					break;

+ 1 - 1
video.c

@@ -19,7 +19,7 @@
 // You should have received a copy of the GNU General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
-
+#include <float.h>
 #include "main.h"
 
 // Screen buffer

+ 3 - 1
win32/pal_config.h

@@ -63,6 +63,8 @@
 #ifndef __MINGW__
 #define strtok_r strtok_s
 #define strncasecmp _strnicmp
+#define strdup _strdup //https://msdn.microsoft.com/en-us/library/ms235454(v=vs.140).aspx 
 #endif
 
-#define strcasestr(a,b) strstr(_strupr((a)),_strupr((b)))
+PAL_C_LINKAGE char* stoupper(char* s);
+#define strcasestr(a,b) strstr(stoupper((a)),stoupper((b)))

+ 7 - 0
win32/win32.cpp

@@ -38,6 +38,13 @@
 #include "../palcfg.h"
 #include "../resampler.h"
 
+PAL_C_LINKAGE char* stoupper(char* s)
+{
+	char* p = strdup(s);
+	while (*p = toupper(*p)) p++;
+	return s;
+}
+
 #define ComboBox_AddString(hwndDlg, idCtrl, lpsz) \
             (BOOL)SNDMSG(GetDlgItem((hwndDlg), (idCtrl)), CB_ADDSTRING, (WPARAM)(0), (LPARAM)(lpsz))
 #define ComboBox_SetCurSel(hwndDlg, idCtrl, index) \