Skip to content

build-235 #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions mcsrc/src/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ mc_args_add_extended_info_to_help (void)
"Please send any bug reports (including the output of 'mc -V')\n"
"as tickets at www.midnight-commander.org\n")
#if defined(BUILD_NUMBER) //WIN32, build
, "win32, see tickets at https://github/adamyg/mcwin32\n"
, "win32, tickets at https://github/adamyg/mcwin32\n"
#endif
);
mc_args__loc__header_string =
Expand Down Expand Up @@ -646,6 +646,15 @@ mc_setup_run_mode (char **argv)

/* --------------------------------------------------------------------------------------------- */

#if defined(WIN32) //WIN32, utf8
static void
print_handler (const gchar *string)
{ // alternative g_printf(), avoids issues with
// tool-chain specific utf8 stream inconsistent behaviour.
tty_oputs (string);
}
#endif

gboolean
mc_args_parse (int *argc, char ***argv, const char *translation_domain, GError **mcerror)
{
Expand Down Expand Up @@ -686,9 +695,13 @@ mc_args_parse (int *argc, char ***argv, const char *translation_domain, GError *
g_option_context_add_group (context, color_group);
g_option_group_set_translation_domain (color_group, translation_domain);

#if defined(WIN32)
g_set_print_handler (print_handler);
#endif

if (!g_option_context_parse (context, argc, argv, mcerror))
{
if (*mcerror == NULL)
if (mcerror && *mcerror == NULL)
mc_propagate_error (mcerror, 0, "%s\n", _("Arguments parse error!"));
else
{
Expand Down Expand Up @@ -718,6 +731,10 @@ mc_args_parse (int *argc, char ***argv, const char *translation_domain, GError *
g_option_context_free (context);
mc_args_clean_temp_help_strings ();

#if defined(WIN32) //WIN32, utf8
g_set_print_handler (NULL);
#endif

#ifdef ENABLE_NLS
if (!str_isutf8 (_system_codepage))
bind_textdomain_codeset ("mc", _system_codepage);
Expand All @@ -728,6 +745,22 @@ mc_args_parse (int *argc, char ***argv, const char *translation_domain, GError *

/* --------------------------------------------------------------------------------------------- */

#if defined(WIN32) //WIN32, utf8
gboolean mc_args_show_info_original (void);

gboolean
mc_args_show_info(void) // replacement
{
#define mc_args_show_info mc_args_show_info_original
int old_utf8_mode, ret;

old_utf8_mode = tty_utf8_mode (1);
ret = mc_args_show_info_original ();
tty_utf8_mode (old_utf8_mode);
return ret;
}
#endif

gboolean
mc_args_show_info (void)
{
Expand Down
22 changes: 7 additions & 15 deletions mcsrc/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include <unistd.h> /* getsid() */

#include "lib/global.h"

#include "lib/event.h"
#include "lib/tty/tty.h"
#include "lib/tty/key.h" /* For init_key() */
Expand Down Expand Up @@ -269,8 +268,9 @@ main (int argc, char *argv[])
int exit_code = EXIT_FAILURE;
const char *tmpdir = NULL;

#if defined(WIN32)
#if defined(WIN32) //WIN32, config
WIN32_HeapInit ();
argc = WIN32_Arguments (argc, &argv);
#endif

mc_global.run_from_parent_mc = !check_sid ();
Expand All @@ -283,30 +283,22 @@ main (int argc, char *argv[])
(void) textdomain (PACKAGE);

#if defined(WIN32) //WIN32, config
WIN32_Setup();
WIN32_Setup ();
#endif

/* do this before args parsing */
str_init_strings (NULL);

#if defined(WIN32)
{ // tool-chain independent wide-char/utf8 conversion command-line parser.
int uargc = 0;
char **uargv;

uargv = GetUTF8Arguments(&uargc);
assert(uargv && uargc == argc);
argv = uargv;
argc = uargc;
}
#endif //WIN32

mc_setup_run_mode (argv); /* are we mc? editor? viewer? etc... */

if (!mc_args_parse (&argc, &argv, "mc", &mcerror))
{
startup_exit_falure:
#if defined(WIN32) //WIN32, utf8
tty_eprintf (_("Failed to run:\n%s\n"), mcerror->message);
#else
fprintf (stderr, _("Failed to run:\n%s\n"), mcerror->message);
#endif
g_error_free (mcerror);
startup_exit_ok:
mc_shell_deinit ();
Expand Down
16 changes: 0 additions & 16 deletions mcsrc/src/textconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,6 @@ show_version (void)
void
show_datadirs_extended (void)
{
#if defined(WIN32)
#ifndef CP_UTF8
#define CP_UTF8 65001 /* UTF-8 translation */
#endif
DWORD codepage;
if (CP_UTF8 != (codepage = GetConsoleOutputCP())) {
(void) SetConsoleOutputCP(CP_UTF8);
}
#endif

(void) printf ("%s %s\n", _("Home directory:"), mc_config_get_home_dir ());
(void) printf ("%s %s\n", _("Profile root directory:"), mc_get_profile_root ());
#if defined(WIN32)
Expand Down Expand Up @@ -302,12 +292,6 @@ show_datadirs_extended (void)
#endif //WIN32, conf
#endif
PRINTF_SECTION2 (_("Cache directory:"), mc_config_get_cache_path ());

#if defined(WIN32)
if (CP_UTF8 != codepage) {
(void) SetConsoleOutputCP(codepage);
}
#endif
}

#undef PRINTF
Expand Down
3 changes: 2 additions & 1 deletion mcwin32/BUILDNUMBER
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
234
235

8 changes: 8 additions & 0 deletions mcwin32/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Thu May 22 14:03:24 2025 adamy

* build-235

o improve command-line locale/utf-8 support (#147)
o screen buffer save/restore (#143)
o network drive enumeration (#141)

Wed May 14 10:50:13 2025 adamy

* build-234
Expand Down
7 changes: 6 additions & 1 deletion mcwin32/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ TARGETS=\
$(D_BIN)/mcmandoc$(E) \
$(D_BIN)/kbtest$(E) \
$(D_BIN)/coninfo$(E) \
$(D_BIN)/volinfo$(E) \
$(D_BIN)/man2hlp.pl

IMPORT=\
Expand Down Expand Up @@ -868,7 +869,7 @@ directories: $(DIRECTORIES)
artifacts: buildinfo busyboxcmds BUILDNUMBER

%/.created:
-@$(PERL) ./support/mkdir_p.pl $(@D)
-@$(MKDIR_P) $(@D)
@echo "++ do not delete, midnight commander managed content ++" > $@

targets: $(LIBRARIES) $(TARGETS)
Expand Down Expand Up @@ -973,6 +974,7 @@ clean:
$(MAKE) -C mandoc clean
$(MAKE) -C src/kbtest clean
$(MAKE) -C src/coninfo clean
$(MAKE) -C src/volinfo clean
$(MAKE) -C autoupdater clean
-$(RM) $(MSGOBJS) $(MSGDIRS) $(QUIETOUT)
-$(RM) $(CONFIGURATION) $(QUIETOUT)
Expand Down Expand Up @@ -1008,6 +1010,9 @@ $(D_BIN)/kbtest$(E):
$(D_BIN)/coninfo$(E):
$(MAKE) -C src/coninfo

$(D_BIN)/volinfo$(E):
$(MAKE) -C src/volinfo

$(MC_RES): config.h buildinfo.h

BUILD_DATE= $(shell $(BUSYBOX) date +'%Y%m%d')
Expand Down
8 changes: 7 additions & 1 deletion mcwin32/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ const char * mc_EXTHELPERSDIR(void);
#define EXTHELPERSDIR mc_EXTHELPERSDIR() /* ???, 4.8.7 */

extern void WIN32_Setup(void);
extern int WIN32_Arguments(int argc, char ***argv);

extern void WIN32_HeapInit(void);
extern int WIN32_HeapCheck(void);

Expand All @@ -124,8 +126,12 @@ extern char * strtok_r(char *s, const char *delim, char **lasts);
extern char * strcasestr(const char *s, const char *find);
#endif

extern char ** GetUTF8Arguments(int *pargc);
extern void tty_oprintf(const char *fmt, ...);
extern void tty_oputs(const char *str);
extern void tty_eprintf(const char *fmt, ...);
extern void tty_eputs(const char *str);

extern int tty_utf8_mode(int state);
extern void tty_set_title(const char *title);

/*
Expand Down
46 changes: 30 additions & 16 deletions mcwin32/doc/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ To build and install mcwin32, you shall need:
* Git tooling for windows.
* Perl 5 with core modules, see [NOTES-PERL.md](doc/NOTES-PERL.md).
* CoreUtils, includes various text and system utilities.
* Gettext
* Make.
* An ANSI C/C++ compiler.
* A development environment in the form of development libraries and C header files.
Expand Down Expand Up @@ -79,7 +80,7 @@ Several alternative profiles are available:
* Open-Watcom (OWC) 1.9 or 2.0; or

* owcconfig - Open Watcom 1.9
* owc20config - Open Watcom 2.0
* owc20config - Open Watcom 2.0

* MingW64, both 32 and 64 bit targets.

Expand Down Expand Up @@ -169,10 +170,10 @@ The follow offers a more detailed discussion of the requirements and instruction
- [Native builds using Visual C++](#native-builds-using-visual-c-c)
- [Native builds using MinGW64](#native-builds-using-mingw)

Finally, please review the packaged example alternative configurations as win32 development environments can be problematic, dependent on the host setup:
Finally, please review the packaged example alternative configurations as win32 development environments can be problematic, dependent on the host setup:

- .github/workflows, github build actions for owc, msvc and mingw64 toolchains.
- Appveyor CI integration notes [Appveyor CI](CINotes.md).
- Appveyor CI integration notes [Appveyor CI](CINotes.md).

Native builds using Open-Watcom C/C++
====================================
Expand Down Expand Up @@ -226,6 +227,14 @@ Minimal tools required are:

Once installed the required commands should be visible within the path.

* gettext - gettext utilities are a set of tools that provides a framework to help packages produce multi-lingual messages.

Several options are available including:

* msys64 - ```pacman --noconfirm -S mingw-w64-i686-gettext-tools```

* [gettext for windows](https://github.com/mlocati/gettext-iconv-windows)

To support native Windows builds, the make tool ``gmake-42``, web tool ``wget`` and the shell support tool ``busybox`` are bundled within the source repository sub-directory ``win32/``.

- ``gmake`` was built from its original source available from [GNU binutils](https://www.gnu.org/software/binutils/).
Expand Down Expand Up @@ -266,7 +275,7 @@ Quick start
From the source root, a suitable environment can be setup using the one of the following dependent on the desired toolchain, were ``C:\Watcom`` is the toolchain installation directory.

* owcconfig- Open Watcom 1.9
* owc20config - Open Watcom 2.0
* owc20config - Open Watcom 2.0

* From the root of the source directory perform the following:

Expand Down Expand Up @@ -314,7 +323,7 @@ The resulting work flow could look like the following, inside a Open Watcom 1.9
cd c:\projects

git clone https://github.com/adamyg/mcwin32.git mc

cd c:\projects\mc\mcwin32

git submodule update --init --recursive
Expand All @@ -338,18 +347,18 @@ Microsoft Visual is available in several, all are suitable:

* Microsoft Visual C++ 2015 - 2002 Professional -

Standard Microsoft Visual C++ installations.
Standard Microsoft Visual C++ installations.

* Microsoft Visual C++ 2015 - 2022 Community Edition -

These free versions of Visual C++ 2015-2022 Professional contain the same compilers and linkers that ship with the full versions,
These free versions of Visual C++ 2015-2022 Professional contain the same compilers and linkers that ship with the full versions,
and also contain everything necessary to build mcwin32.
* Microsoft C++ Build Tools -

* Microsoft C++ Build Tools -

There's also a standalone (IDE-less) version of the build tools mentioned above containing the MSVC compiler
available for download from https://visualstudio.microsoft.com/visual-cpp-build-tools/.

Note: Since these are proprietary and ever-changing I cannot test them all. Older versions may not work, it is recommended to use a recent version wherever possible.

* Install _Perl_
Expand Down Expand Up @@ -393,7 +402,7 @@ The resulting work flow could look like the following, inside a 2019 developer p
cd c:\projects

git clone https://github.com/adamyg/mcwin32.git mc

cd c:\projects\mc\mcwin32

git submodule update --init --recursive
Expand All @@ -412,8 +421,8 @@ Native builds using Mingw

Mingw64 (32/64) offers another alternative way to build native __mcwin32__, similar to Open-Watcom C/C++ builds.

MSYS2 provides GNU tools, a Unix-like command prompt, and a UNIX compatibility layer for applications,
available from https://www.mingw-w64.org. However, in this context it is only used for building mcwin32.
MSYS2 provides GNU tools, a Unix-like command prompt, and a UNIX compatibility layer for applications,
available from https://www.mingw-w64.org. However, in this context it is only used for building mcwin32.
The resulting application does not rely on MSYS2 to run and is fully native.

* _MSYS2_ shell, from https://www.msys2.org/
Expand All @@ -433,9 +442,14 @@ The resulting application does not rely on MSYS2 to run and is fully native.
$ pacman --noconfirm -S mingw-w64-x86_64-gcc
$ pacman --noconfirm -S mingw-w64-i686-gcc

These compilers must be on your MSYS2 \$PATH, example below assuming the default installation path ``c:/msys64/``.
These compilers must be on your MSYS2 \$PATH, example below assuming the default installation path ``c:/msys64/``.
A common error is to not have these on your \$PATH. The MSYS2 version of gcc will not work correctly here.

finally, any additional components

$ pacman --noconfirm -S mingw-w64-i686-gettext-tools
$ pacman --noconfirm -S zip

* From the root of the source directory perform the following:

* Configure and prime the build system.
Expand All @@ -457,7 +471,7 @@ The resulting application does not rely on MSYS2 to run and is fully native.
* Optionally, build the installer.

$ .\support\gmake-42 release package

The resulting work flow could look like the following, inside either a terminal/command or msys prompt:

Install any missing components
Expand All @@ -475,7 +489,7 @@ Prime sandbox and build
cd c:\projects

git clone https://github.com/adamyg/mcwin32.git mc

cd c:\projects\mc\mcwin32

git submodule update --init --recursive
Expand Down
Loading