From 2a099d9ab725d8a9fb6523cd6c518204c31308ca Mon Sep 17 00:00:00 2001 From: Vaclav Petras Date: Sat, 4 May 2024 14:44:32 -0400 Subject: [PATCH] g.message: Do not require full gisinit (#3686) The g.message does not need any of the session setup and it can be used during a setup process to report standardized messages to the user. This removes the need to have a full session before running g.message. GISRC is still needed, but the data (file) structures for mapset don't need to exist. The code is combination of what is in g.proj (the 'no init' call and comment) and g.dirseps (memory mode for GISRC). It is also syncing the corresponding lines in g.proj. --- general/g.message/main.c | 7 ++++++- general/g.proj/main.c | 7 ++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/general/g.message/main.c b/general/g.message/main.c index a7a33589d4d..601ee15c56d 100644 --- a/general/g.message/main.c +++ b/general/g.message/main.c @@ -26,7 +26,12 @@ int main(int argc, char *argv[]) struct GModule *module; int debug_level; - G_gisinit(argv[0]); + /* We don't call G_gisinit() here because it validates the + * mapset, whereas this module may legitimately be even + * without a valid mapset. */ + G_set_program_name(argv[0]); + G_no_gisinit(); + G_set_gisrc_mode(G_GISRC_MODE_MEMORY); module = G_define_module(); G_add_keyword(_("general")); diff --git a/general/g.proj/main.c b/general/g.proj/main.c index 0c1acb222b1..2db200f8bfb 100644 --- a/general/g.proj/main.c +++ b/general/g.proj/main.c @@ -59,10 +59,11 @@ int main(int argc, char *argv[]) int formats; const char *epsg = NULL; + /* We don't call G_gisinit() here because it validates the + * mapset, whereas this module may legitimately be used + * (to create a new location) when none exists. */ G_set_program_name(argv[0]); - G_no_gisinit(); /* We don't call G_gisinit() here because it validates the - * mapset, whereas this module may legitmately be used - * (to create a new location) when none exists */ + G_no_gisinit(); module = G_define_module(); G_add_keyword(_("general"));