From ceae5f65f914b1a3384889143e2eeb3eb0f632ca Mon Sep 17 00:00:00 2001 From: Mohamed Akram Date: Tue, 1 Apr 2025 16:02:30 +0400 Subject: [PATCH] mlterm: fix reading config --- x11/mlterm/Portfile | 18 ++++--- .../files/patch-fix-undefined-behavior.diff | 54 +++++++++++++++++++ 2 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 x11/mlterm/files/patch-fix-undefined-behavior.diff diff --git a/x11/mlterm/Portfile b/x11/mlterm/Portfile index 94b303a68e9..521e8d0e225 100644 --- a/x11/mlterm/Portfile +++ b/x11/mlterm/Portfile @@ -5,7 +5,7 @@ PortGroup openssl 1.0 name mlterm version 3.9.4 -revision 1 +revision 2 checksums rmd160 8c11694b8f5faeb03d7e5efffef3ea38867fad06 \ sha256 171de4c4f3443bc1211cc51df5caa0e082ffcdd33ab3ce261bc0a4cfe85d9b5e \ size 4227568 @@ -45,6 +45,8 @@ depends_lib-append port:fontconfig \ port:fribidi \ port:libsdl2 +patchfiles-append patch-fix-undefined-behavior.diff + post-destroot { xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name} file copy {*}[glob ${worksrcpath}/doc/*] \ @@ -71,15 +73,17 @@ variant x11 conflicts sdl2 quartz { variant quartz conflicts sdl2 x11 { configure.args-append --with-gui=quartz post-destroot { - copy ${worksrcpath}/cocoa/mlterm.app ${destroot}${applications_dir} - set app_dir ${applications_dir}/mlterm.app/Contents/MacOS - xinstall -d ${destroot}${app_dir} - move ${destroot}${prefix}/bin/mlterm ${destroot}${app_dir} - ln -s ${prefix}/libexec/mlterm/mlconfig ${destroot}${app_dir}/ + set app_dir ${applications_dir}/mlterm.app + set bin_dir ${app_dir}/Contents/MacOS + copy ${worksrcpath}/cocoa/mlterm.app ${destroot}${app_dir} + ln -s ${prefix}/etc/mlterm ${destroot}${app_dir} + xinstall -d ${destroot}${bin_dir} + move ${destroot}${prefix}/bin/mlterm ${destroot}${bin_dir} + ln -s ${prefix}/libexec/mlterm/mlconfig ${destroot}${bin_dir} # Using a symlink doesn't work because the app can't find its data files. set fp [open ${destroot}${prefix}/bin/mlterm w 0755] puts ${fp} "#!/bin/sh" - puts ${fp} "exec '${app_dir}/mlterm' \"$@\"" + puts ${fp} "exec '${bin_dir}/mlterm' \"$@\"" close ${fp} } } diff --git a/x11/mlterm/files/patch-fix-undefined-behavior.diff b/x11/mlterm/files/patch-fix-undefined-behavior.diff new file mode 100644 index 00000000000..44f73f491db --- /dev/null +++ b/x11/mlterm/files/patch-fix-undefined-behavior.diff @@ -0,0 +1,54 @@ +diff --git main/main-cocoa.m main/main-cocoa.m +index 6a7039fd..6265798a 100644 +--- main/main-cocoa.m ++++ main/main-cocoa.m +@@ -51,17 +51,20 @@ int main(int argc, char* argv[]) + set_lang(); + } + +-#ifdef COCOA_TOUCH + const char *bundle = [[[NSBundle mainBundle] bundlePath] UTF8String]; + char *path; + ++#ifdef COCOA_TOUCH + if ((path = alloca(strlen(bundle) + 5))) { + strcpy(path, bundle); + strcat(path, "/etc"); + bl_set_sys_conf_dir(path); + } + #else +- bl_set_sys_conf_dir([[[NSBundle mainBundle] bundlePath] UTF8String]); ++ if ((path = alloca(strlen(bundle) + 1))) { ++ strcpy(path, bundle); ++ bl_set_sys_conf_dir(path); ++ } + #endif + } + @finally { +diff --git uitoolkit/quartz/ui_color.c uitoolkit/quartz/ui_color.c +index 2e01bda9..b0e853d3 100644 +--- uitoolkit/quartz/ui_color.c ++++ uitoolkit/quartz/ui_color.c +@@ -51,7 +51,8 @@ int ui_load_named_xcolor(ui_display_t *disp, ui_color_t *xcolor, const char *nam + + int ui_load_rgb_xcolor(ui_display_t *disp, ui_color_t *xcolor, u_int8_t red, u_int8_t green, + u_int8_t blue, u_int8_t alpha) { +- xcolor->pixel = (red << 16) | (green << 8) | blue | (alpha << 24); ++ xcolor->pixel = ((u_int32_t) alpha << 24) | ((u_int32_t) red << 16) | ++ ((u_int32_t) green << 8) | blue; + + return 1; + } +diff --git uitoolkit/ui_screen_manager.c uitoolkit/ui_screen_manager.c +index 80bb8a9f..705dcf8a 100644 +--- uitoolkit/ui_screen_manager.c ++++ uitoolkit/ui_screen_manager.c +@@ -1478,7 +1478,7 @@ void ui_close_dead_screens(void) { + int count; + + for (count = MSU - 1; count >= 0; count--) { +- if (dead_mask[idx] & (0x1 << count)) { ++ if (dead_mask[idx] & (0x1u << count)) { + ui_screen_t *screen; + + #ifdef __DEBUG