Skip to content

Commit

Permalink
fix: Fix support to multi byte char in command line file name
Browse files Browse the repository at this point in the history
  • Loading branch information
lcgamboa committed Mar 2, 2024
1 parent dec4aa2 commit 6c1b4ec
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ PACKAGE=picsimlab
MAINVER=0
MINORVER=9
VERSION=0.9.2
DATE=240224
DATE=240302
VERSION_STABLE=0.9.1
2 changes: 1 addition & 1 deletion bscripts/build_flatpak.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/devices/lcd_hd44780.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lib/spareparts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> prefs;
int newformat = 0;
Expand Down
26 changes: 21 additions & 5 deletions src/picsimlab1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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();
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6c1b4ec

Please sign in to comment.