Browse Source

Fix Unix, MinGW32 & WinRT build bugs

LouYihua 7 years ago
parent
commit
8e02b1bdb3
5 changed files with 29 additions and 36 deletions
  1. 2 2
      global.c
  2. 6 4
      unix/native_midi.cpp
  3. 1 1
      unix/unix.cpp
  4. 13 26
      win32/sdlpal.rc
  5. 7 3
      winrt/SDLPal.Common/MainPage.xaml.cpp

+ 2 - 2
global.c

@@ -131,7 +131,7 @@ PAL_DetectCodePage(
 		word_len = ftell(fp);
 		word_buf = (char *)malloc(word_len);
 		fseek(fp, 0, SEEK_SET);
-		fread(word_buf, 1, word_len, fp);
+		word_len = fread(word_buf, 1, word_len, fp);
 		UTIL_CloseFile(fp);
 		// Eliminates null characters so that PAL_MultiByteToWideCharCP works properly
 		for (char *ptr = word_buf; ptr < word_buf + word_len; ptr++)
@@ -165,7 +165,7 @@ PAL_DetectCodePage(
 			for (int j = invalids = 0; j < length; j++)
 			{
 				int score = 1;
-				if (iswspace(wbuf[j])) continue;
+				if (iswspace(wbuf[j]) != 0) continue;
 				for (int k = 0; k < sizeof(valid_ranges) / sizeof(valid_ranges[0]); k++)
 				{
 					if (wbuf[j] >= valid_ranges[k][0] &&

+ 6 - 4
unix/native_midi.cpp

@@ -34,15 +34,17 @@ char* cliplayer = nullptr;
 
 static char *which(const char *cmd)
 {
-    char path[PATH_MAX];
+	static char path[PATH_MAX] = { '\0' };
     FILE *fp = popen(va("which %s", cmd), "r");
     if (fp == NULL) {
         return NULL;
     }else{
-        fgets(path, sizeof(path)-1, fp);
+        if (fgets(path, sizeof(path)-1, fp) != NULL)
+		{
+			if (path[strlen(path) - 1] == '\n') path[strlen(path) - 1] = '\0';
+			if (path[strlen(path) - 1] == '\r') path[strlen(path) - 1] = '\0';
+		}
         pclose(fp);
-        if( path[strlen(path)-1] == '\n' ) path[strlen(path)-1] = '\0';
-        if( path[strlen(path)-1] == '\r' ) path[strlen(path)-1] = '\0';
         return path;
     }
 }

+ 1 - 1
unix/unix.cpp

@@ -105,7 +105,7 @@ void InitControls()
    gWidgets.aspect->value(gConfig.fKeepAspectRatio ? 1 : 0);
    gWidgets.fullscreen->value(gConfig.fFullScreen ? 1 : 0);
    gWidgets.cd->value(gConfig.eCDType - MUSIC_MP3);
-   gWidgets.bgm->value(gConfig.eMusicType - MUSIC_MIN);
+   gWidgets.bgm->value(gConfig.eMusicType);
    gWidgets.stereo->value(gConfig.iAudioChannels == 2 ? 1 : 0);
    sprintf(buffer, "%d", gConfig.iSampleRate); gWidgets.samplerate->value(buffer);
    gWidgets.opl->value(gConfig.eOPLType);

+ 13 - 26
win32/sdlpal.rc

@@ -117,32 +117,19 @@ END
 
 IDD_LAUNCHER DLGINIT
 BEGIN
-    IDC_CD, 0x403, 4, 0
-0x504d, 0x0033, 
-    IDC_CD, 0x403, 4, 0
-0x474f, 0x0047, 
-    IDC_BGM, 0x403, 4, 0
-0x4952, 0x0058, 
-    IDC_BGM, 0x403, 5, 0
-0x494d, 0x4944, "\000" 
-    IDC_BGM, 0x403, 4, 0
-0x504d, 0x0033, 
-    IDC_BGM, 0x403, 4, 0
-0x474f, 0x0047, 
-    IDC_OPL, 0x403, 7, 0
-0x4f44, 0x4253, 0x584f, "\000" 
-    IDC_OPL, 0x403, 5, 0
-0x414d, 0x454d, "\000" 
-    IDC_LOGLEVEL, 0x403, 8, 0
-0x6556, 0x6272, 0x736f, 0x0065, 
-    IDC_LOGLEVEL, 0x403, 6, 0
-0x6544, 0x7562, 0x0067, 
-    IDC_LOGLEVEL, 0x403, 14, 0
-0x6e49, 0x6f66, 0x6d72, 0x7461, 0x6f69, 0x616e, 0x006c, 
-    IDC_LOGLEVEL, 0x403, 8, 0
-0x6157, 0x6e72, 0x6e69, 0x0067, 
-    IDC_LOGLEVEL, 0x403, 6, 0
-0x6146, 0x6174, 0x006c, 
+    IDC_CD, 0x403, 4, 0, 0x504d, 0x0033, 
+    IDC_CD, 0x403, 4, 0, 0x474f, 0x0047, 
+    IDC_BGM, 0x403, 4, 0, 0x4952, 0x0058, 
+    IDC_BGM, 0x403, 5, 0, 0x494d, 0x4944, "\000" 
+    IDC_BGM, 0x403, 4, 0, 0x504d, 0x0033, 
+    IDC_BGM, 0x403, 4, 0, 0x474f, 0x0047, 
+    IDC_OPL, 0x403, 7, 0, 0x4f44, 0x4253, 0x584f, "\000" 
+    IDC_OPL, 0x403, 5, 0, 0x414d, 0x454d, "\000" 
+    IDC_LOGLEVEL, 0x403, 8, 0, 0x6556, 0x6272, 0x736f, 0x0065, 
+    IDC_LOGLEVEL, 0x403, 6, 0, 0x6544, 0x7562, 0x0067, 
+    IDC_LOGLEVEL, 0x403, 14, 0, 0x6e49, 0x6f66, 0x6d72, 0x7461, 0x6f69, 0x616e, 0x006c, 
+    IDC_LOGLEVEL, 0x403, 8, 0, 0x6157, 0x6e72, 0x6e69, 0x0067, 
+    IDC_LOGLEVEL, 0x403, 6, 0, 0x6146, 0x6174, 0x006c, 
     0
 END
 

+ 7 - 3
winrt/SDLPal.Common/MainPage.xaml.cpp

@@ -23,14 +23,18 @@ using namespace Windows::UI::Xaml::Input;
 using namespace Windows::UI::Xaml::Media;
 using namespace Windows::UI::Xaml::Navigation;
 
+static Platform::String^ msg_file_exts[] = { ".msg" };
+static Platform::String^ font_file_exts[] = { ".bdf" };
+static Platform::String^ log_file_exts[] = { ".log" };
+
 MainPage::MainPage()
 {
 	InitializeComponent();
 
 	m_controls = ref new Platform::Collections::Map<Platform::String^, ButtonAttribute^>();
-	m_controls->Insert(btnBrowseMsgFile->Name, ref new ButtonAttribute(tbMsgFile, ref new Platform::Array<Platform::String^>{ ".bdf" }));
-	m_controls->Insert(btnBrowseFontFile->Name, ref new ButtonAttribute(tbFontFile, ref new Platform::Array<Platform::String^>{ ".msg" }));
-	m_controls->Insert(btnBrowseLogFile->Name, ref new ButtonAttribute(tbLogFile, ref new Platform::Array<Platform::String^>{ ".log" }));
+	m_controls->Insert(btnBrowseMsgFile->Name, ref new ButtonAttribute(tbMsgFile, ref new Platform::Array<Platform::String^>(msg_file_exts, sizeof(msg_file_exts) / sizeof(msg_file_exts[0]))));
+	m_controls->Insert(btnBrowseFontFile->Name, ref new ButtonAttribute(tbFontFile, ref new Platform::Array<Platform::String^>(font_file_exts, sizeof(font_file_exts) / sizeof(font_file_exts[0]))));
+	m_controls->Insert(btnBrowseLogFile->Name, ref new ButtonAttribute(tbLogFile, ref new Platform::Array<Platform::String^>(log_file_exts, sizeof(log_file_exts) / sizeof(log_file_exts[0]))));
 	m_controls->Insert(cbUseMsgFile->Name, ref new ButtonAttribute(gridMsgFile, nullptr));
 	m_controls->Insert(cbUseFontFile->Name, ref new ButtonAttribute(gridFontFile, nullptr));
 	m_controls->Insert(cbUseLogFile->Name, ref new ButtonAttribute(gridLogFile, nullptr));