Skip to content

Commit

Permalink
adapted for building on Termux
Browse files Browse the repository at this point in the history
  • Loading branch information
PTz0uAH committed Oct 23, 2024
1 parent 5106b3b commit ae96a00
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 35 deletions.
2 changes: 1 addition & 1 deletion cmake/StandardProjectSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -Wl,--gc-sections -Wl,--strip-all")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS} -g")
else ()
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,-dead_strip")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,-dead_strip,-fPIE")
endif()

# Set build type to "Release" if user did not specify any build type yet
Expand Down
5 changes: 3 additions & 2 deletions external/floppybridge/src/FloppyBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void handleAbout(bool checkForUpdates, FloppyBridge::BridgeAbout** output) {
#endif
if ((checkForUpdates) && (!hasUpdateChecked)) {
hasUpdateChecked = true;

/*
#ifdef _WIN32
// Start winsock
WSADATA data;
Expand Down Expand Up @@ -194,7 +194,7 @@ void handleAbout(bool checkForUpdates, FloppyBridge::BridgeAbout** output) {
hostent* address = gethostbyname("floppybridge-amiga.robsmithdev.co.uk");
if ((address) && (address->h_addrtype == AF_INET)) {
if (address->h_addr_list[0] != 0) {
in_addr add = *((in_addr*)address->h_addr_list[0]);
const in_addr add = *((in_addr*)address->h_addr_list[0]);
uint32_t bytes = htonl(add.s_addr);
BridgeInformationUpdate.updateMajorVersion = bytes >> 24;
BridgeInformationUpdate.updateMinorVersion = (bytes >> 16) & 0xFF;
Expand All @@ -205,6 +205,7 @@ void handleAbout(bool checkForUpdates, FloppyBridge::BridgeAbout** output) {
}
}
#endif
*/
}
#ifdef _WIN32
if (output)
Expand Down
2 changes: 1 addition & 1 deletion src/blkdev_cdimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
#include "sysconfig.h"
#include "sysdeps.h"
#ifdef HAVE_SYS_TIMEB_H
#ifndef HAVE_SYS_TIMEB_H
#include <sys/timeb.h>
#endif
#include <sys/types.h>
Expand Down
2 changes: 1 addition & 1 deletion src/fsusage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <sys/stat.h>
#endif

#if defined(STAT_STATVFS) && !defined(__ANDROID__)
#if defined(STAT_STATVFS) && defined(__ANDROID__)
#include <sys/statvfs.h>
// For osx, sigurbjornl
#elif defined (__MACH__)
Expand Down
62 changes: 32 additions & 30 deletions src/osdep/amiberry_filesys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,38 @@ struct my_openfile_s {
static bool has_logged_iconv_fail = false;
void utf8_to_latin1_string(std::string& input, std::string& output)
{
std::vector<char> in_buf(input.begin(), input.end());
char* src_ptr = in_buf.data();
size_t src_size = input.size();
std::vector<char> buf(1024);
std::string dst;

auto* iconv_ = iconv_open("ISO-8859-1//TRANSLIT", "UTF-8");
if (iconv_ == (iconv_t)-1) {
if (!has_logged_iconv_fail) {
write_log("iconv_open failed: will be copying directory entries verbatim\n");
has_logged_iconv_fail = true;
}
output = input;
return;
}
while (src_size > 0) {
char* dst_ptr = buf.data();
size_t dst_size = buf.size();
size_t res = ::iconv(iconv_, &src_ptr, &src_size, &dst_ptr, &dst_size);
if (res == (size_t)-1) {
if (errno != E2BIG) {
// skip character
++src_ptr;
--src_size;
}
}
dst.append(buf.data(), buf.size() - dst_size);
}
output = std::move(dst);
iconv_close(iconv_);
output = input;
return;
//std::vector<char> in_buf(input.begin(), input.end());
//char* src_ptr = in_buf.data();
//size_t src_size = input.size();
//std::vector<char> buf(1024);
//std::string dst;
//iconv_
//auto* iconv_ = iconv_open("ISO-8859-1//TRANSLIT", "UTF-8");
//if (iconv_ == (iconv_t)-1) {
// if (!has_logged_iconv_fail) {
// write_log("iconv_open failed: will be copying directory entries verbatim\n");
// has_logged_iconv_fail = true;
// }
// output = input;
// return;
//}
//while (src_size > 0) {
// char* dst_ptr = buf.data();
// size_t dst_size = buf.size();
// size_t res = ::iconv(iconv_, &src_ptr, &src_size, &dst_ptr, &dst_size);
// if (res == (size_t)-1) {
// if (errno != E2BIG) {
// // skip character
// ++src_ptr;
// --src_size;
// }
// }
// dst.append(buf.data(), buf.size() - dst_size);
//}
//output = std::move(dst);
//iconv_close(iconv_);
}

std::string iso_8859_1_to_utf8(const std::string& str)
Expand Down

0 comments on commit ae96a00

Please sign in to comment.