From 6c1b4ecfd7e58d60b7d9881348b49a5cb106fe47 Mon Sep 17 00:00:00 2001 From: lcgamboa Date: Sat, 2 Mar 2024 18:07:15 -0300 Subject: [PATCH] fix: Fix support to multi byte char in command line file name --- VERSION | 2 +- bscripts/build_flatpak.sh | 2 +- .../com.github.lcgamboa.picsimlab.yaml | 2 +- src/devices/lcd_hd44780.cc | 2 +- src/lib/spareparts.cc | 2 +- src/picsimlab1.cc | 26 +++++++++++++++---- 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index f6ccede9d..358ff89e8 100644 --- a/VERSION +++ b/VERSION @@ -2,5 +2,5 @@ PACKAGE=picsimlab MAINVER=0 MINORVER=9 VERSION=0.9.2 -DATE=240224 +DATE=240302 VERSION_STABLE=0.9.1 diff --git a/bscripts/build_flatpak.sh b/bscripts/build_flatpak.sh index 3c7ff5bcf..47f8a8802 100755 --- a/bscripts/build_flatpak.sh +++ b/bscripts/build_flatpak.sh @@ -9,7 +9,7 @@ cl sudo apt-get -y upgrade cl sudo apt-get -y install flatpak flatpak-builder bzip2 flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo -flatpak --user install flathub org.freedesktop.Platform//21.08 org.freedesktop.Sdk//21.08 -y +flatpak --user install flathub org.freedesktop.Platform//22.08 org.freedesktop.Sdk//22.08 -y #VERSION="${VERSION_STABLE}" VERSION="${VERSION}_${DATE}" diff --git a/package/com.github.lcgamboa.picsimlab/com.github.lcgamboa.picsimlab.yaml b/package/com.github.lcgamboa.picsimlab/com.github.lcgamboa.picsimlab.yaml index 63ab950b9..d610b0d1e 100644 --- a/package/com.github.lcgamboa.picsimlab/com.github.lcgamboa.picsimlab.yaml +++ b/package/com.github.lcgamboa.picsimlab/com.github.lcgamboa.picsimlab.yaml @@ -1,6 +1,6 @@ app-id: com.github.lcgamboa.picsimlab runtime: org.freedesktop.Platform -runtime-version: '21.08' +runtime-version: '22.08' sdk: org.freedesktop.Sdk command: picsimlab rename-desktop-file: picsimlab.desktop diff --git a/src/devices/lcd_hd44780.cc b/src/devices/lcd_hd44780.cc index 80fff68ec..04eb2a7a7 100644 --- a/src/devices/lcd_hd44780.cc +++ b/src/devices/lcd_hd44780.cc @@ -442,7 +442,7 @@ void lcd_data(lcd_t* lcd, char data) { } unsigned char lcd_read_busyf_acounter(lcd_t* lcd) { - // busy flag aways 0 + // busy flag always 0 unsigned char status = (0x7F & lcd->addr_counter); // switch betwwen 8 or 4 bits communication diff --git a/src/lib/spareparts.cc b/src/lib/spareparts.cc index 904ea4bf8..a49c5063a 100644 --- a/src/lib/spareparts.cc +++ b/src/lib/spareparts.cc @@ -327,7 +327,7 @@ bool CSpareParts::LoadPinAlias(std::string fname, unsigned char show_error_msg) bool CSpareParts::LoadConfig(std::string fname, const int disable_debug) { char name[256]; char temp[4096]; - unsigned int x, y; + int x, y; int orient; std::vector prefs; int newformat = 0; diff --git a/src/picsimlab1.cc b/src/picsimlab1.cc index 45152295d..2af44e01e 100644 --- a/src/picsimlab1.cc +++ b/src/picsimlab1.cc @@ -792,7 +792,11 @@ void CPWindow1::_EvOnCreate(CControl* control) { printf("PICSimLab: Command Line: "); for (int i = 0; i < Application->Aargc; i++) { +#ifdef wxUSE_UNICODE + printf("%s ", (const char*)lxString(Application->Aargvw[i]).utf8_str()); +#else printf("%s ", Application->Aargv[i]); +#endif } printf("\n"); @@ -808,35 +812,47 @@ void CPWindow1::_EvOnCreate(CControl* control) { std::string(fname_error) + "\n If the problem persists, please consider opening an issue on github.\n "); } else if (Application->Aargc == 2) { // only .pzw file +#ifdef wxUSE_UNICODE + fn.Assign(Application->Aargvw[1]); +#else fn.Assign(Application->Aargv[1]); +#endif fn.MakeAbsolute(); // load options PICSimLab.Configure(home, 1, 1); // check if it is a demonstration - std::string fns = (const char*)fn.GetFullPath().c_str(); + std::string fns = (const char*)fn.GetFullPath().utf8_str(); lxFileName fn_dir; fn_dir.Assign(PICSimLab.GetSharePath() + "boards/"); fn_dir.MakeAbsolute(); if ((fns.find(fn_dir.GetFullPath()) != std::string::npos) && (fns.find("demo.pzw") != std::string::npos)) { - PICSimLab.LoadWorkspace((const char*)fn.GetFullPath().c_str(), 0); + PICSimLab.LoadWorkspace((const char*)fn.GetFullPath().utf8_str(), 0); PICSimLab.SetWorkspaceFileName(""); } else { - PICSimLab.LoadWorkspace((const char*)fn.GetFullPath().c_str()); + PICSimLab.LoadWorkspace((const char*)fn.GetFullPath().utf8_str()); } } else if ((Application->Aargc >= 3) && (Application->Aargc <= 5)) { // arguments: Board Processor File.hex(.bin) file.pcf if (Application->Aargc >= 4) { +#ifdef wxUSE_UNICODE + fn.Assign(Application->Aargvw[3]); +#else fn.Assign(Application->Aargv[3]); +#endif fn.MakeAbsolute(); } if (Application->Aargc == 5) { +#ifdef wxUSE_UNICODE + fn_spare.Assign(Application->Aargvw[4]); +#else fn_spare.Assign(Application->Aargv[4]); +#endif fn_spare.MakeAbsolute(); } @@ -870,9 +886,9 @@ void CPWindow1::_EvOnCreate(CControl* control) { // search for file name if (Application->Aargc >= 4) { // load options - PICSimLab.Configure(home, 0, 1, (const char*)fn.GetFullPath().c_str()); + PICSimLab.Configure(home, 0, 1, (const char*)fn.GetFullPath().utf8_str()); if (Application->Aargc == 5) { - SpareParts.LoadConfig((const char*)fn_spare.GetFullPath().c_str()); + SpareParts.LoadConfig((const char*)fn_spare.GetFullPath().utf8_str()); } } else { // load options