[GRASS-SVN] r67994 - grass/trunk/lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Mar 3 20:37:18 PST 2016
Author: wenzeslaus
Date: 2016-03-03 20:37:18 -0800 (Thu, 03 Mar 2016)
New Revision: 67994
Modified:
grass/trunk/lib/gis/parser.c
grass/trunk/lib/gis/progrm_nme.c
Log:
parser: provide wxGUI forms.py with a full path if available (#2133)
The GUI form/dialog now opens for a script
which is not on path and from command line
and main GUI the dialog will actually execute
the module because the full path is available.
(Needs also r67993.)
Modified: grass/trunk/lib/gis/parser.c
===================================================================
--- grass/trunk/lib/gis/parser.c 2016-03-04 04:23:41 UTC (rev 67993)
+++ grass/trunk/lib/gis/parser.c 2016-03-04 04:37:18 UTC (rev 67994)
@@ -619,9 +619,11 @@
* Creates a command-line that runs the current command completely
* non-interactive.
*
+ * \param original_path TRUE if original path should be used, FALSE for
+ * stripped and clean name of the module
* \return pointer to a char string
*/
-char *G_recreate_command(void)
+char *recreate_command(int original_path)
{
char *buff;
char flg[4];
@@ -638,7 +640,10 @@
buff = G_calloc(1024, sizeof(char));
nalloced += 1024;
- tmp = G_program_name();
+ if (original_path)
+ tmp = G_original_program_name();
+ else
+ tmp = G_program_name();
len = strlen(tmp);
if (len >= nalloced) {
nalloced += (1024 > len) ? 1024 : len + 1;
@@ -750,6 +755,37 @@
}
/*!
+ * \brief Creates command to run non-interactive.
+ *
+ * Creates a command-line that runs the current command completely
+ * non-interactive.
+ *
+ * \return pointer to a char string
+ */
+char *G_recreate_command(void)
+{
+ recreate_command(FALSE);
+}
+
+/* TODO: update to docs of these 3 functions to whatever general purpose
+ * they have now. */
+/*!
+ * \brief Creates command to run non-interactive.
+ *
+ * Creates a command-line that runs the current command completely
+ * non-interactive.
+ *
+ * This gives the same as G_recreate_command() but the original path
+ * from the command line is used instead of the module name only.
+ *
+ * \return pointer to a char string
+ */
+char *G_recreate_command_original_path(void)
+{
+ recreate_command(TRUE);
+}
+
+/*!
\brief Add keyword to the list
\param keyword keyword string
@@ -863,6 +899,7 @@
{
char script[GPATH_MAX];
+ /* TODO: the 4 following lines seems useless */
if (!st->pgm_path)
st->pgm_path = G_program_name();
if (!st->pgm_path)
@@ -872,7 +909,7 @@
getenv("GISBASE"));
if (access(script, F_OK) != -1)
G_spawn(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"),
- script, G_recreate_command(), NULL);
+ script, G_recreate_command_original_path(), NULL);
else
return -1;
Modified: grass/trunk/lib/gis/progrm_nme.c
===================================================================
--- grass/trunk/lib/gis/progrm_nme.c 2016-03-04 04:23:41 UTC (rev 67993)
+++ grass/trunk/lib/gis/progrm_nme.c 2016-03-04 04:37:18 UTC (rev 67994)
@@ -15,6 +15,7 @@
#include <grass/gis.h>
static const char *name = "?";
+static const char *original_name = "?";
/*!
* \brief Return module name
@@ -30,6 +31,24 @@
}
/*!
+ * \brief Return original path of the executed program
+ *
+ * This function returns the name of the program as set by the call to
+ * G_gisinit().
+ *
+ * Unlike G_program_name() which returns name of the module
+ * this function return original path which was used to execute
+ * the program. For standard GRASS modules, it will be the same as
+ * the result from G_program_name() function.
+ *
+ * \return pointer to string with program name or full path
+ */
+const char *G_original_program_name(void)
+{
+ return original_name;
+}
+
+/*!
\brief Set program name
Program name set to name (name will be returned by
@@ -44,6 +63,8 @@
int i;
char *temp;
+ original_name = G_store(s);
+
i = strlen(s);
while (--i >= 0) {
if (G_is_dirsep(s[i])) {
More information about the grass-commit
mailing list