[GRASS-SVN] r38898 - in grass/branches/develbranch_6: lib/form
vector/v.digit
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 28 05:00:23 EDT 2009
Author: marisn
Date: 2009-08-28 05:00:23 -0400 (Fri, 28 Aug 2009)
New Revision: 38898
Modified:
grass/branches/develbranch_6/lib/form/form.tcl
grass/branches/develbranch_6/lib/form/open.c
grass/branches/develbranch_6/vector/v.digit/generate.c
Log:
Fix v.digit attribute entry if db path contains spaces
Modified: grass/branches/develbranch_6/lib/form/form.tcl
===================================================================
--- grass/branches/develbranch_6/lib/form/form.tcl 2009-08-28 07:16:52 UTC (rev 38897)
+++ grass/branches/develbranch_6/lib/form/form.tcl 2009-08-28 09:00:23 UTC (rev 38898)
@@ -1,9 +1,9 @@
-lappend auto_path $env(GISBASE)/bwidget
+lappend auto_path "$env(GISBASE)/bwidget"
package require -exact BWidget 1.2.1
#package require http
-set formpath $env(GISBASE)/etc/form
-source $formpath/html_library.tcl
+set formpath [file normalize "$env(GISBASE)/etc/form"]
+source "$formpath/html_library.tcl"
proc create_submit_msg { formid } {
global submit_result submit_msg formf
Modified: grass/branches/develbranch_6/lib/form/open.c
===================================================================
--- grass/branches/develbranch_6/lib/form/open.c 2009-08-28 07:16:52 UTC (rev 38897)
+++ grass/branches/develbranch_6/lib/form/open.c 2009-08-28 09:00:23 UTC (rev 38898)
@@ -107,9 +107,9 @@
- sprintf(command, "%s/etc/form/form", G_gisbase());
- sprintf(script, "%s/etc/form/form.tcl", G_gisbase());
-
+ sprintf(command, "\"%s/etc/form/form\"", G_gisbase());
+ sprintf(script, "\"%s/etc/form/form.tcl\"", G_gisbase());
+G_message("FC: %s form -f %s", command, script);
execl(command, "form", "-f", script, NULL);
G_debug(2, "CHILD END\n");
Modified: grass/branches/develbranch_6/vector/v.digit/generate.c
===================================================================
--- grass/branches/develbranch_6/vector/v.digit/generate.c 2009-08-28 07:16:52 UTC (rev 38897)
+++ grass/branches/develbranch_6/vector/v.digit/generate.c 2009-08-28 09:00:23 UTC (rev 38898)
@@ -4,6 +4,34 @@
#include <grass/dbmi.h>
#include <grass/form.h>
+/* I was unable to find standard strrep function. */
+char *strrep(char *from, char *to, char symbol) {
+ int i = 0, j = 0, size;
+
+ size = sizeof(from)*strlen(from)+1;
+ to = (char *)malloc(size);
+ if (!to) {
+ return NULL;
+ }
+ while (from[i]) {
+ if (from[i]==symbol) {
+ size++;
+ to = realloc(to, size);
+ if (!to)
+ return NULL;
+ to[j] = '\\';
+ j++;
+ }
+ to[j] = from[i];
+ i++;
+ j++;
+ }
+ to[j]='\0';
+
+ return to;
+}
+
+
/* Generate form in HTML/TXT format.
* Pointer to resulting string is stored to 'form'. This string must be freed by application.
*
@@ -17,6 +45,7 @@
{
int col, ncols, ctype, sqltype, more;
char buf[5000], buf1[100];
+ char *escstr;
const char *colname;
dbString sql, html, str;
dbDriver *driver;
@@ -133,8 +162,14 @@
/* Note: because html_library.tcl failes to parse
* <INPUT name=abc value='dbname=xxx'> and returnes
* name="xxx" value="dbname=xxx" order of value and name parameters is changed */
+ /* Note: TCL will process \$[] chars in dbname (path) and thus we need to escape them.
+ * As {} chars are converted by html_library.tcl to HTML entities, it's no use to escape them.*/
+ escstr = strrep(dbname,escstr,'\\');
+ escstr = strrep(escstr,escstr,'$');
+ escstr = strrep(escstr,escstr,'[');
+ escstr = strrep(escstr,escstr,']');
sprintf(buf, "<INPUT type=hidden value=\"%s\" name=%s>",
- dbname, F_DATABASE_FNAME);
+ escstr, F_DATABASE_FNAME);
db_append_string(&html, buf);
sprintf(buf, "<INPUT type=hidden name=%s value=\"%s\">",
F_TABLE_FNAME, tblname);
@@ -238,7 +273,6 @@
}
}
G_debug(2, "FORM STRING:\n%s\n", db_get_string(&html));
-
db_close_cursor(&cursor);
db_close_database(driver);
db_shutdown_driver(driver);
More information about the grass-commit
mailing list