This is an improved version of PR #637.
No more "--" - not needed. No guard for is_osx_bundle() under Windows - does not belong here. Split into proper sequential commits. Fixed the encoding of options and doc_name. Fixed the OSX bundle executable name. Created a function to return the reproduced arguments instead of exposing global variables. Re-tested under Windows and Linux.
There is only one problem left. As described in PR #637, under Windows, mscvrt often breaks unquoted locale strings on 2+ pieces, considering some characters "spaces". So spawn should quote any argv elements containing locale. But that must obviously be a separate PR. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/653
-- Commit Summary --
* Add reverse option parser to main * Add support for geany executable to utils_resource_dir() * Improve New Window: pass the proper arguments and save configuration
-- File Changes --
M src/libmain.c (121) M src/main.h (2) M src/plugins.c (2) M src/utils.c (111) M src/utils.h (17)
-- Patch Links --
https://github.com/geany/geany/pull/653.patch https://github.com/geany/geany/pull/653.diff
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/653
Now, a few words about app->confdir under *nix.
Geany assigns "app->confdir = alternate_config", and then in setup_config_dir() does "SETPTR(app->configdir, utils_get_locale_from_utf8(app->configdir))", freeing app->confdir, and thus alternate_config, leading to buggy reproduced option for New Window.
The original SM code counters this by "app->confdir = g_strdup(alternate_config)", but in my tests with a -c *locale_dir* under Linux:
- alternate_config was in locale (identical to *locale_dir*) - utils_get_locale_from_utf8(app->confdir) /from SETPTR/ failed to convert it to locale, and returned a copy of it - Help -> Debug Messages aborted Geany with an assertion that the text to be displayed (the 3 debug messages containing confdir, I checked that) is not valid UTF-8 - The above points are compliant (if that's the word) with the GLib spec, which states that the G_OPTION_ARG_FILENAME options are in the GLib filename encoding, and that is locale under POSIX, not UTF-8.
It seems to me then that the proper fix will be (a) not to convert app->configdir to locale, and (b) use an UTF-8 converted string for geany_debug(). I tried that, and it works on my system (bg_BG). So my questions are:
- Which way should I fix alternate_config being freed? Can you provide an example when converting app->configdir to locale makes sense? - If I'm to fix it by not converting app->confdir to locale, should I also include a fix for the Debug Messages?..
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/653#issuecomment-139356214
Hmm, there's one more bug: Geany executable is checked for being valid each time utils_resource_path() is invoked. I'll fix this soon. It's in the last commit, is it OK to replace it?
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/653#issuecomment-139555576
Fixed Geany executable to be checked only once. The bug wasn't in the last commit, so I'm not force-replacing it, but issuing a new one.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/653#issuecomment-139594753
Since app->confdir is usually initialized with the dynamically allocated utils_get_user_config_dir(), and is gfree-d, using g_strdup(alternate_config) seems ok, and the confdir locale issue should be fixed separatedly.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/653#issuecomment-139879403
Fixed configdir encoding in PR #658
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/653#issuecomment-141505776
Closing since this hasn't been touched in almost 4 years and AFAIK @zhekov is no longer using Geany as his main editor. Feel free to re-open if anyone wants to pick up working on this.
Closed #653.
github-comments@lists.geany.org