Make the fix a standalone function

This commit is contained in:
ergo720 2018-08-02 18:17:17 +02:00
parent 99ccc1d221
commit 59f8bb1b67
3 changed files with 28 additions and 34 deletions

View File

@ -44,7 +44,7 @@
#endif
// Acknowledgment: all the functions present at the moment are from XQEMU (GPLv2)
// Acknowledgment: some the functions present are from XQEMU (GPLv2)
// https://xqemu.com/
@ -175,3 +175,23 @@ void WriteWords(xbaddr Paddr, uint16_t* Buffer, int Number)
std::memcpy(reinterpret_cast<void*>(Paddr + CONTIGUOUS_MEMORY_BASE), Buffer, 2); // dropped big -> little endian conversion from XQEMU
}
}
void unix2dos(std::string& string)
{
size_t position = 0;
while (true) {
if (position > string.length()) {
break;
}
position = string.find('\n', position);
if (position == std::string::npos) {
break;
}
if (position != 0 && string.compare(position - 1, 2U, "\r\n") == 0) {
position++;
continue;
}
string.insert(position, 1, '\r');
position += 2;
}
}

View File

@ -40,6 +40,7 @@
#include "Cxbx.h"
#include <stdint.h>
#include <assert.h>
#include <string>
/* This is a linux struct for vectored I/O. See readv() and writev() */
struct IoVec
@ -68,6 +69,8 @@ void GetDwords(xbaddr Paddr, uint32_t* Buffer, int Number);
void GetWords(xbaddr Paddr, uint16_t* Buffer, int Number);
void WriteWords(xbaddr Paddr, uint16_t* Buffer, int Number);
void unix2dos(std::string& string);
#define GET_WORD_LOW(value) (uint8_t)((value) & 0xFF)
#define GET_WORD_HIGH(value) (uint8_t)(((value) >> 8) & 0xFF)

View File

@ -39,6 +39,7 @@
#include "CxbxVersion.h"
#include "DlgAbout.h"
#include "ResCxbx.h"
#include "CxbxCommon.h"
#include <commctrl.h>
#include <string>
@ -111,22 +112,7 @@ INT_PTR CALLBACK DlgAboutProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
SizeofResource(GetModuleHandle(NULL), rContributors)
);
size_t position = 0;
while (true) {
if (position > contributors.length()) {
break;
}
position = contributors.find('\n', position);
if (position == std::string::npos) {
break;
}
if (position != 0 && contributors.compare(position - 1, 2U, "\r\n") == 0) {
position++;
continue;
}
contributors.insert(position, 1, '\r');
position += 2;
}
unix2dos(contributors);
tab = CreateWindowEx(
NULL, "EDIT", contributors.c_str(),
@ -151,22 +137,7 @@ INT_PTR CALLBACK DlgAboutProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
SizeofResource(GetModuleHandle(NULL), rCopying)
);
position = 0;
while (true) {
if (position > copying.length()) {
break;
}
position = copying.find('\n', position);
if (position == std::string::npos) {
break;
}
if (position != 0 && copying.compare(position - 1, 2U, "\r\n") == 0) {
position++;
continue;
}
copying.insert(position, 1, '\r');
position += 2;
}
unix2dos(copying);
tab = CreateWindowEx(
NULL, "EDIT", copying.c_str(),