[GRASS-SVN] r39149 - in grass/branches/releasebranch_6_4:
gui/tcltk/gis.m gui/tcltk/gis.m/docs lib/form lib/gtcltk
lib/init vector/v.db.connect vector/v.digit
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Sep 12 11:51:40 EDT 2009
Author: marisn
Date: 2009-09-12 11:51:39 -0400 (Sat, 12 Sep 2009)
New Revision: 39149
Removed:
grass/branches/releasebranch_6_4/vector/v.digit/generate.c
grass/branches/releasebranch_6_4/vector/v.digit/open.c
Modified:
grass/branches/releasebranch_6_4/gui/tcltk/gis.m/chart.tcl
grass/branches/releasebranch_6_4/gui/tcltk/gis.m/cmd.tcl
grass/branches/releasebranch_6_4/gui/tcltk/gis.m/docs/gm_animate.html
grass/branches/releasebranch_6_4/gui/tcltk/gis.m/docs/gm_georect.html
grass/branches/releasebranch_6_4/gui/tcltk/gis.m/docs/gm_profile.html
grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gm.tcl
grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmmenu.tcl
grass/branches/releasebranch_6_4/gui/tcltk/gis.m/raster.tcl
grass/branches/releasebranch_6_4/gui/tcltk/gis.m/runandoutput.tcl
grass/branches/releasebranch_6_4/gui/tcltk/gis.m/thematic.tcl
grass/branches/releasebranch_6_4/gui/tcltk/gis.m/vector.tcl
grass/branches/releasebranch_6_4/lib/form/form.c
grass/branches/releasebranch_6_4/lib/form/generate.c
grass/branches/releasebranch_6_4/lib/gtcltk/gronsole.tcl
grass/branches/releasebranch_6_4/lib/gtcltk/select.tcl
grass/branches/releasebranch_6_4/lib/init/gis_set.tcl
grass/branches/releasebranch_6_4/lib/init/init.sh
grass/branches/releasebranch_6_4/vector/v.db.connect/
grass/branches/releasebranch_6_4/vector/v.db.connect/description.html
grass/branches/releasebranch_6_4/vector/v.db.connect/main.c
grass/branches/releasebranch_6_4/vector/v.digit/Makefile
Log:
Merge TCL/Tk UI and db realted path with spaces hacks from develbranch_6
Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/chart.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/chart.tcl 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/chart.tcl 2009-09-12 15:51:39 UTC (rev 39149)
@@ -10,12 +10,12 @@
##########################################################################
namespace eval GmChart {
- variable array opt # chart options
+ variable array opt ;# chart options
variable count 1
- variable array lfile # vector
- variable array lfilemask # vector
+ variable array lfile ;# vector
+ variable array lfilemask ;# vector
variable optlist
- variable array dup # vector
+ variable array dup ;# vector
}
@@ -121,7 +121,19 @@
variable opt
global bgcolor
set mapname $opt($id,1,map)
+ if {[string length $mapname] == 0} {
+ GmChart::select_map $id
+ set mapname $opt($id,1,map)
+ if {[string length $mapname] == 0} {
+ GmLib::errmsg [G_msg "This action requires map name to be set"]
+ return
+ }
+ }
set layernum $opt($id,1,layer)
+ if {[string is integer -strict $layernum] == 0 } {
+ GmLib::errmsg [G_msg "You must provide valid vector layer number"]
+ return
+ }
set cmd "v.info -c map=$mapname layer=$layernum"
run_panel $cmd
}
@@ -130,17 +142,29 @@
variable opt
global bgcolor
set mapname $opt($id,1,map)
- set layer $opt($id,1,layer)
- if ![catch {open "|v.db.connect map=$mapname layer=$layer -g" r} vdb] {
+ if {[string length $mapname] == 0} {
+ GmChart::select_map $id
+ set mapname $opt($id,1,map)
+ if {[string length $mapname] == 0} {
+ GmLib::errmsg [G_msg "This action requires map name to be set"]
+ return
+ }
+ }
+ set layernum $opt($id,1,layer)
+ if {[string is integer -strict $layernum] == 0 } {
+ GmLib::errmsg [G_msg "You must provide valid vector layer number"]
+ return
+ }
+ if ![catch {open "|v.db.connect map=$mapname layer=$layernum -g -l" r} vdb] {
set vectdb [read $vdb]
if {[catch {close $vdb} error]} {
GmLib::errmsg $error
}
set vdblist [split $vectdb " "]
- set tbl [lindex $vdblist 1]
- set db [lindex $vdblist 3]
- set drv [lindex $vdblist 4]
- set cmd "db.select table=$tbl database=$db driver=$drv"
+ set tbl [string trim [lindex $vdblist 1]]
+ set db [file normalize [join [lrange $vdblist 3 end-1]]]
+ set drv [string trim [lindex $vdblist end]]
+ set cmd [list db.select "table=$tbl" "database=$db" "driver=$drv"]
run_panel $cmd
}
}
Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/cmd.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/cmd.tcl 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/cmd.tcl 2009-09-12 15:51:39 UTC (rev 39149)
@@ -10,13 +10,13 @@
##########################################################################
namespace eval GmCmd {
- variable array opt # cmd current options
+ variable array opt ;# cmd current options
variable count 1
- variable array tree # mon
- variable array lfile # command
- variable array lfilemask # command
+ variable array tree ;# mon
+ variable array lfile ;# command
+ variable array lfilemask ;# command
variable optlist
- variable array dup # layer
+ variable array dup ;# layer
}
Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/docs/gm_animate.html
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/docs/gm_animate.html 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/docs/gm_animate.html 2009-09-12 15:51:39 UTC (rev 39149)
@@ -8,6 +8,7 @@
<body bgcolor="white">
+<!-- meta page description: ANIMATION TOOL (gis.m) -->
<h2>ANIMATION TOOL (gis.m)</h2>
The Animation Tool is an interactive interface to display a series of
Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/docs/gm_georect.html
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/docs/gm_georect.html 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/docs/gm_georect.html 2009-09-12 15:51:39 UTC (rev 39149)
@@ -7,6 +7,7 @@
</head>
<body bgcolor="white">
+<!-- meta page description: GEORECTIFY TOOL (gis.m) -->
<h2>GEORECTIFY TOOL (gis.m)</h2>
In order to use and overlay different forms of geospatial data in a
Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/docs/gm_profile.html
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/docs/gm_profile.html 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/docs/gm_profile.html 2009-09-12 15:51:39 UTC (rev 39149)
@@ -7,6 +7,7 @@
</head>
<body bgcolor="white">
+<!-- meta page description: PROFILE TOOL (gis.m) -->
<h2>PROFILE TOOL (gis.m)</h2>
The Profile Tool will draw a 2-dimensional profile of the surface of
Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gm.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gm.tcl 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gm.tcl 2009-09-12 15:51:39 UTC (rev 39149)
@@ -19,23 +19,23 @@
#
##########################################################################
-lappend auto_path $env(GISBASE)/bwidget
+lappend auto_path [file join "$env(GISBASE)" "bwidget"]
package require -exact BWidget 1.2.1
# Load up all the gis.m layers and things.
# pkgIndex.tcl only loads the files when they are first called.
-lappend auto_path $env(GISBASE)/etc/gm
+lappend auto_path [file join "$env(GISBASE)" "etc" "gm"]
package require -exact GisM 1.0
# path to GIS Manager files
-set gmpath $env(GISBASE)/etc/gm
+set gmpath [file join "$env(GISBASE)" "etc" "gm"]
# Load GUI stuff required for error reporting etc.
-source $env(GISBASE)/etc/gui.tcl
+source [file join "$env(GISBASE)" "etc" "gui.tcl"]
# Load common procedure library
-source $gmpath/gmlib.tcl
+source [file join "$gmpath" "gmlib.tcl"]
# gisenv errors are fatal.
if {[catch {set env(GISDBASE) [exec g.gisenv get=GISDBASE]} error]} {
@@ -72,7 +72,7 @@
# path to icons for GIS Manager
-set iconpath $env(GISBASE)/etc/gui/icons/grass
+set iconpath [file join "$env(GISBASE)" "etc" "gui" "icons" "grass"]
global iconpath
global gmpath
@@ -116,7 +116,7 @@
#fetch GRASS Version number:
-catch {set fp [open $env(GISBASE)/etc/VERSIONNUMBER r]}
+catch {set fp [open [file join "$env(GISBASE)" "etc" "VERSIONNUMBER"] r]}
set GRASSVERSION [read -nonewline $fp]
if {[catch {close $fp} error]} {
@@ -132,7 +132,7 @@
# $env(GISBASE)/etc/gtcltk/gronsole.tcl
# Load a console user interface
-source $gmpath/runandoutput.tcl
+source [file join "$gmpath" "runandoutput.tcl"]
namespace eval Gm {
variable gm_mainframe
Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmmenu.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmmenu.tcl 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmmenu.tcl 2009-09-12 15:51:39 UTC (rev 39149)
@@ -209,7 +209,7 @@
{command {[G_msg "Change region settings"]} {} "g.region: " {} -command {execute g.region }}
}}
{cascad {[G_msg "GRASS working environment"]} {} "" $tmenu {
- {command {[G_msg "Mapset access"]} {} "g.mapsets.tcl: Access other mapsets in current location" {} -command {exec $env(GRASS_WISH) $env(GISBASE)/etc/g.mapsets.tcl --tcltk &}}
+ {command {[G_msg "Mapset access"]} {} "g.mapsets.tcl: Access other mapsets in current location" {} -command {exec "$env(GRASS_WISH)" "$env(GISBASE)/etc/g.mapsets.tcl" --tcltk &}}
{command {[G_msg "Change working environment"]} {} "g.mapset: Change current working session to new mapset, location, or GISDBASE" {} -command {execute g.mapset }}
{command {[G_msg "User access"]} {} "g.access: Modify access by other users to current mapset" {} -command {execute g.access }}
{command {[G_msg "Show settings"]} {} "g.gisenv: Show current GRASS environment settings" {} -command {run_panel g.gisenv }}
@@ -641,8 +641,8 @@
{[G_msg "&Help"]} all options $tmenu {
{command {[G_msg "GRASS help"]} {} "g.manual" {} -command { exec g.manual -i > $devnull & } }
{command {[G_msg "GIS Manager &help"]} {} {[G_msg "GIS Manager help"]} {} -command { exec g.manual gis.m > $devnull & } }
- {command {[G_msg "About &GRASS"]} {} {[G_msg "About GRASS"]} {} -command { source $env(GISBASE)/etc/gm/grassabout.tcl} }
- {command {[G_msg "About &System"]} {} {[G_msg "About System"]} {} -command { exec $env(GRASS_WISH) $env(GISBASE)/etc/gm/tksys.tcl --tcltk & }}
+ {command {[G_msg "About &GRASS"]} {} {[G_msg "About GRASS"]} {} -command { source "$env(GISBASE)/etc/gm/grassabout.tcl" } }
+ {command {[G_msg "About &System"]} {} {[G_msg "About System"]} {} -command { exec "$env(GRASS_WISH)" "$env(GISBASE)/etc/gm/tksys.tcl" --tcltk & }}
}
}]
Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/raster.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/raster.tcl 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/raster.tcl 2009-09-12 15:51:39 UTC (rev 39149)
@@ -10,13 +10,13 @@
##########################################################################
namespace eval GmRaster {
- variable array opt # raster current options
+ variable array opt ;# raster current options
variable count 1
- variable array tree # mon
- variable array lfile # raster
- variable array lfilemask # raster
+ variable array tree ;# mon
+ variable array lfile ;# raster
+ variable array lfilemask ;# raster
variable optlist
- variable array dup # vector
+ variable array dup ;# vector
}
###############################################################################
@@ -137,6 +137,14 @@
proc GmRaster::show_info { id } {
variable opt
set mapname $opt($id,1,map)
+ if {[string length $mapname] == 0} {
+ GmRaster::select_map $id
+ set mapname $opt($id,1,map)
+ if {[string length $mapname] == 0} {
+ GmLib::errmsg [G_msg "This action requires map name to be set"]
+ return
+ }
+ }
set cmd "r.info map=$mapname"
run_panel $cmd
}
@@ -145,6 +153,14 @@
proc GmRaster::show_info_drape { id } {
variable opt
set mapname $opt($id,1,drapemap)
+ if {[string length $mapname] == 0} {
+ GmRaster::select_drapemap $id
+ set mapname $opt($id,1,drapemap)
+ if {[string length $mapname] == 0} {
+ GmLib::errmsg [G_msg "This action requires map name to be set"]
+ return
+ }
+ }
set cmd "r.info map=$mapname"
run_panel $cmd
}
Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/runandoutput.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/runandoutput.tcl 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/runandoutput.tcl 2009-09-12 15:51:39 UTC (rev 39149)
@@ -50,7 +50,7 @@
set opt($dlg,run_button) $buttonframe.run
# Turn off help button if the help file doesn't exist
- if {! [file exists $env(GISBASE)/docs/html/$pgm_name.html]} {
+ if {! [file exists [file join "$env(GISBASE)" "docs" "html" "$pgm_name.html"]]} {
$buttonframe.help configure -state disabled
}
Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/thematic.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/thematic.tcl 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/thematic.tcl 2009-09-12 15:51:39 UTC (rev 39149)
@@ -10,14 +10,14 @@
##########################################################################
namespace eval GmThematic {
- variable array opt # thematic current options
- variable array tlegend # mon id
- variable array tlegcan # mon id
+ variable array opt ;# thematic current options
+ variable array tlegend ;# mon id
+ variable array tlegcan ;# mon id
variable count 1
- variable array lfile # raster
- variable array lfilemask # raster
+ variable array lfile ;# raster
+ variable array lfilemask ;# raster
variable optlist
- variable array dup # vector
+ variable array dup ;# vector
}
@@ -162,7 +162,19 @@
variable opt
global bgcolor
set mapname $opt($id,1,map)
+ if {[string length $mapname] == 0} {
+ GmThematic::select_map $id
+ set mapname $opt($id,1,map)
+ if {[string length $mapname] == 0} {
+ GmLib::errmsg [G_msg "This action requires map name to be set"]
+ return
+ }
+ }
set layernum $opt($id,1,layer)
+ if {[string is integer -strict $layernum] == 0 } {
+ GmLib::errmsg [G_msg "You must provide valid vector layer number"]
+ return
+ }
set cmd "v.info -c map=$mapname layer=$layernum"
run_panel $cmd
}
@@ -171,17 +183,29 @@
variable opt
global bgcolor
set mapname $opt($id,1,map)
- set layer $opt($id,1,layer)
- if {![catch {open "|v.db.connect map=$mapname layer=$layer -g" r} vdb]} {
+ if {[string length $mapname] == 0} {
+ GmVector::select_map $id
+ set mapname $opt($id,1,map)
+ if {[string length $mapname] == 0} {
+ GmLib::errmsg [G_msg "This action requires map name to be set"]
+ return
+ }
+ }
+ set layernum $opt($id,1,layer)
+ if {[string is integer -strict $layernum] == 0 } {
+ GmLib::errmsg [G_msg "You must provide valid vector layer number"]
+ return
+ }
+ if {![catch {open "|v.db.connect map=$mapname layer=$layernum -g -l" r} vdb]} {
set vectdb [read $vdb]
if {[catch {close $vdb} error]} {
GmLib::errmsg $error
}
set vdblist [split $vectdb " "]
- set tbl [lindex $vdblist 1]
- set db [lindex $vdblist 3]
- set drv [lindex $vdblist 4]
- set cmd "db.select table=$tbl database=$db driver=$drv"
+ set tbl [string trim [lindex $vdblist 1]]
+ set db [file normalize [join [lrange $vdblist 3 end-1]]]
+ set drv [string trim [lindex $vdblist end]]
+ set cmd [list db.select "table=$tbl" "database=$db" "driver=$drv"]
run_panel $cmd
}
}
@@ -680,7 +704,7 @@
GmLib::errmsg $error [G_msg "Error creating tempfile"]
}
- set legfile "$tmpdir/gismlegend.txt"
+ set legfile [file join "$tmpdir" "gismlegend.txt"]
if {![file exists $legfile]} {return}
catch {set ltxt [open $legfile r]}
set x1 30
Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/vector.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/vector.tcl 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/vector.tcl 2009-09-12 15:51:39 UTC (rev 39149)
@@ -160,8 +160,8 @@
set opt($count,1,where) ""
set opt($count,1,_use_where) 1
set opt($count,1,qmap) ""
- set opt($count,1,qsave) 0
- set opt($count,1,qoverwrite) 0
+ set opt($count,1,qsave) 0
+ set opt($count,1,qoverwrite) 0
set opt($count,1,attribute) ""
set opt($count,1,xref) "left"
@@ -172,16 +172,17 @@
set opt($count,1,maxreg) ""
set opt($count,1,mod) 1
- set optlist { _check vect opacity display_shape display_cat display_topo display_dir \
- display_attr type_point type_line type_boundary type_centroid \
- type_area type_face color _use_color fcolor _use_fcolor lcolor \
- rdmcolor sqlcolor icon size lwidth layer lfield attribute \
- xref yref lsize cat where _use_where qmap qsave qoverwrite \
- minreg maxreg}
+ set optlist { _check vect opacity display_shape display_cat \
+ display_topo display_dir display_attr type_point \
+ type_line type_boundary type_centroid type_area \
+ type_face color _use_color fcolor _use_fcolor lcolor \
+ rdmcolor sqlcolor icon size lwidth \
+ layer lfield attribute xref yref lsize cat where \
+ _use_where qmap qsave qoverwrite minreg maxreg }
foreach key $optlist {
set opt($count,0,$key) $opt($count,1,$key)
- }
+ }
GmVector::legend $count
@@ -235,7 +236,19 @@
proc GmVector::show_columns { id } {
variable opt
set mapname $opt($id,1,vect)
+ if {[string length $mapname] == 0} {
+ GmVector::select_map $id
+ set mapname $opt($id,1,vect)
+ if {[string length $mapname] == 0} {
+ GmLib::errmsg [G_msg "This action requires map name to be set"]
+ return
+ }
+ }
set layernum $opt($id,1,layer)
+ if {[string is integer -strict $layernum] == 0 } {
+ GmLib::errmsg [G_msg "You must provide valid vector layer number"]
+ return
+ }
set cmd "v.info -c map=$mapname layer=$layernum"
run_panel $cmd
}
@@ -245,18 +258,30 @@
proc GmVector::show_data { id } {
variable opt
set mapname $opt($id,1,vect)
+ if {[string length $mapname] == 0} {
+ GmVector::select_map $id
+ set mapname $opt($id,1,vect)
+ if {[string length $mapname] == 0} {
+ GmLib::errmsg [G_msg "This action requires map name to be set"]
+ return
+ }
+ }
set layernum $opt($id,1,layer)
- if {![catch {open "|v.db.connect map=$mapname layer=$layernum -g" r} vdb]} {
+ if {[string is integer -strict $layernum] == 0 } {
+ GmLib::errmsg [G_msg "You must provide valid vector layer number"]
+ return
+ }
+ if {![catch {open "|v.db.connect map=$mapname layer=$layernum -g -l" r} vdb]} {
set vectdb [read $vdb]
if {[catch {close $vdb} error]} {
GmLib::errmsg $error
}
set vdblist [split $vectdb " "]
- set tbl [lindex $vdblist 1]
- set db [lindex $vdblist 3]
- set drv [lindex $vdblist 4]
- set cmd "db.select table=$tbl database=$db driver=dbf"
+ set tbl [string trim [lindex $vdblist 1]]
+ set db [file normalize [join [lrange $vdblist 3 end-1]]]
+ set drv [string trim [lindex $vdblist end]]
+ set cmd [list db.select "table=$tbl" "database=$db" "driver=$drv"]
run_panel $cmd
}
}
@@ -266,7 +291,19 @@
proc GmVector::show_info { id } {
variable opt
set mapname $opt($id,1,vect)
+ if {[string length $mapname] == 0} {
+ GmVector::select_map $id
+ set mapname $opt($id,1,vect)
+ if {[string length $mapname] == 0} {
+ GmLib::errmsg [G_msg "This action requires map name to be set"]
+ return
+ }
+ }
set layernum $opt($id,1,layer)
+ if {[string is integer -strict $layernum] == 0 } {
+ GmLib::errmsg [G_msg "You must provide valid vector layer number"]
+ return
+ }
set cmd "v.info map=$mapname layer=$layernum"
run_panel $cmd
}
@@ -364,6 +401,7 @@
pack $row.a $row.b $row.c $row.d $row.e $row.f $row.g -side left
pack $row -side top -fill both -expand yes
+
# points
set row [ frame $frm.icon ]
Label $row.a -text [G_msg "Point symbols:"]
@@ -424,7 +462,7 @@
pack $row.a $row.b $row.c $row.d $row.e $row.f -side left
pack $row -side top -fill both -expand yes
- # label alighment
+ # label alignment
set row [ frame $frm.label2 ]
Label $row.a -text " "
ComboBox $row.b -label [G_msg "Label part to align with vector point"] \
@@ -795,12 +833,14 @@
set opt($count,1,opacity) $opt($id,1,opacity)
- set optlist { _check vect display_shape display_cat display_topo display_dir \
- display_attr type_point type_line type_boundary type_centroid \
- type_area type_face color _use_color fcolor _use_fcolor lcolor \
- rdmcolor sqlcolor icon size lwidth layer lfield attribute \
- xref yref lsize cat where _use_where qmap qsave qoverwrite \
- minreg maxreg minreg maxreg}
+ set optlist { _check vect display_shape display_cat display_topo \
+ display_dir display_attr type_point type_line \
+ type_boundary type_centroid type_area type_face \
+ color _use_color fcolor _use_fcolor lcolor rdmcolor \
+ sqlcolor icon size lwidth layer \
+ lfield attribute xref yref lsize cat where \
+ _use_where qmap qsave qoverwrite minreg maxreg \
+ minreg maxreg }
foreach key $optlist {
set opt($count,1,$key) $opt($id,1,$key)
Modified: grass/branches/releasebranch_6_4/lib/form/form.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/form/form.c 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/lib/form/form.c 2009-09-12 15:51:39 UTC (rev 39149)
@@ -93,7 +93,7 @@
/* Check if all internal values are set */
if (Drvname == NULL || Dbname == NULL || Tblname == NULL || Key == NULL) {
- G_warning("db connection was not set by form\n");
+ G_warning("db connection was not set by form");
sprintf(buf, "set submit_msg \"db connection was not set by form.\"");
Tcl_Eval(interp, buf);
Tcl_Eval(interp, "set submit_result 0");
@@ -104,7 +104,7 @@
G_debug(2, "Open driver");
driver = db_start_driver(Drvname);
if (driver == NULL) {
- G_warning("Cannot open driver\n");
+ G_warning("Cannot open driver");
sprintf(buf, "set submit_msg \"Cannot open driver '%s'\"", Drvname);
Tcl_Eval(interp, buf);
Tcl_Eval(interp, "set submit_result 0");
@@ -116,11 +116,12 @@
db_set_handle(&handle, Dbname, NULL);
G_debug(2, "Open database");
if (db_open_database(driver, &handle) != DB_OK) {
- G_warning("Cannot open database\n");
+ G_warning("Cannot open database");
db_shutdown_driver(driver);
sprintf(buf,
"set submit_msg \"Cannot open database '%s' by driver '%s'\"",
Dbname, Drvname);
+
Tcl_Eval(interp, buf);
Tcl_Eval(interp, "set submit_result 0");
return TCL_OK;
@@ -129,7 +130,7 @@
db_set_string(&table_name, Tblname);
if (db_describe_table(driver, &table_name, &table) != DB_OK) {
- G_warning("Cannot describe table\n");
+ G_warning("Cannot describe table");
db_shutdown_driver(driver);
db_close_database(driver);
sprintf(buf, "set submit_msg \"Cannot describe table '%s'\"",
Modified: grass/branches/releasebranch_6_4/lib/form/generate.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/form/generate.c 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/lib/form/generate.c 2009-09-12 15:51:39 UTC (rev 39149)
@@ -4,6 +4,19 @@
#include <grass/dbmi.h>
#include <grass/form.h>
+/* Escape string for use in TCL */
+char *escape_tcl_string(char *input)
+{
+ char *escaped;
+
+ escaped = G_str_replace(input, "\\", "\\\\");
+ escaped = G_str_replace(escaped, "[", "\\[");
+ escaped = G_str_replace(escaped, "]", "\\]");
+ escaped = G_str_replace(escaped, "$", "\\$");
+
+ return escaped;
+}
+
/* Generate form in HTML/TXT format.
* Pointer to resulting string is stored to 'form'. This string must be freed by application.
*
@@ -60,8 +73,9 @@
G_debug(2, "Open driver");
driver = db_start_driver(drvname);
if (driver == NULL) {
- G_warning("Cannot open driver\n");
- sprintf(buf, "Cannot open driver '%s'<BR>", drvname);
+ G_warning("Cannot open driver");
+ sprintf(buf, "Cannot open driver '%s'<BR>",
+ escape_tcl_string(drvname));
*form = G_store(buf);
return -1;
}
@@ -71,10 +85,10 @@
db_set_handle(&handle, dbname, NULL);
G_debug(2, "Open database");
if (db_open_database(driver, &handle) != DB_OK) {
- G_warning("Cannot open database\n");
+ G_warning("Cannot open database");
db_shutdown_driver(driver);
- sprintf(buf, "Cannot open database '%s' by driver '%s'<BR>", dbname,
- drvname);
+ sprintf(buf, "Cannot open database '%s' by driver '%s'<BR>",
+ escape_tcl_string(dbname), escape_tcl_string(drvname));
*form = G_store(buf);
return -1;
}
@@ -88,12 +102,13 @@
G_debug(2, "%s", buf);
db_set_string(&sql, buf);
if (db_open_select_cursor(driver, &sql, &cursor, DB_SEQUENTIAL) != DB_OK) {
- G_warning("Cannot open select cursor\n");
+ G_warning("Cannot open select cursor");
db_close_database(driver);
db_shutdown_driver(driver);
sprintf(buf,
"Cannot open select cursor:<BR>'%s'<BR>on database '%s' by driver '%s'<BR>",
- db_get_string(&sql), dbname, drvname);
+ escape_tcl_string(db_get_string(&sql)),
+ escape_tcl_string(dbname), escape_tcl_string(drvname));
*form = G_store(buf);
return -1;
}
@@ -102,7 +117,7 @@
table = db_get_cursor_table(&cursor);
if (db_fetch(&cursor, DB_NEXT, &more) != DB_OK) {
- G_warning("Cannot fetch next record\n");
+ G_warning("Cannot fetch next record");
db_close_cursor(&cursor);
db_close_database(driver);
db_shutdown_driver(driver);
@@ -128,19 +143,23 @@
db_append_string(&html, "<FORM>");
sprintf(buf, "<INPUT type=hidden name=%s value=\"%s\">",
- F_DRIVER_FNAME, drvname);
+ escape_tcl_string(F_DRIVER_FNAME),
+ escape_tcl_string(drvname));
db_append_string(&html, buf);
/* 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 */
sprintf(buf, "<INPUT type=hidden value=\"%s\" name=%s>",
- dbname, F_DATABASE_FNAME);
+ escape_tcl_string(dbname),
+ escape_tcl_string(F_DATABASE_FNAME));
db_append_string(&html, buf);
sprintf(buf, "<INPUT type=hidden name=%s value=\"%s\">",
- F_TABLE_FNAME, tblname);
+ escape_tcl_string(F_TABLE_FNAME),
+ escape_tcl_string(tblname));
db_append_string(&html, buf);
sprintf(buf, "<INPUT type=hidden name=%s value=\"%s\">",
- F_KEY_FNAME, key);
+ escape_tcl_string(F_KEY_FNAME),
+ escape_tcl_string(key));
db_append_string(&html, buf);
}
@@ -156,19 +175,22 @@
G_debug(2, "%s: %s", colname, db_get_string(&str));
if (edit_mode == F_VIEW) {
- sprintf(buf, "<B>%s : </B> %s <BR>", colname,
- db_get_string(&str));
+ sprintf(buf, "<B>%s : </B> %s <BR>",
+ escape_tcl_string(G_strdup(colname)),
+ escape_tcl_string(db_get_string(&str)));
db_append_string(&html, buf);
}
else {
- sprintf(buf, "<B>%s : </B>", colname);
+ sprintf(buf, "<B>%s : </B>",
+ escape_tcl_string(G_strdup(colname)));
db_append_string(&html, buf);
if (G_strcasecmp(colname, key) == 0) {
sprintf(buf,
"%s<BR> <INPUT type=hidden name=%s value=\"%s\">",
- db_get_string(&str), colname,
- db_get_string(&str));
+ escape_tcl_string(db_get_string(&str)),
+ escape_tcl_string(G_strdup(colname)),
+ escape_tcl_string(db_get_string(&str)));
}
else {
switch (ctype) {
@@ -187,7 +209,9 @@
}
sprintf(buf,
"<INPUT type=text size=%s name=%s value=\"%s\"><BR>",
- buf1, colname, db_get_string(&str));
+ escape_tcl_string(buf1),
+ escape_tcl_string(G_strdup(colname)),
+ escape_tcl_string(db_get_string(&str)));
}
db_append_string(&html, buf);
}
Modified: grass/branches/releasebranch_6_4/lib/gtcltk/gronsole.tcl
===================================================================
--- grass/branches/releasebranch_6_4/lib/gtcltk/gronsole.tcl 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/lib/gtcltk/gronsole.tcl 2009-09-12 15:51:39 UTC (rev 39149)
@@ -468,7 +468,8 @@
# Actually run the program
# |& grocat merges stdout and stderr because Tcl treats
# anything written to stderr as an error condition
- set cmd [concat | $cmd |& $env(GISBASE)/etc/grocat]
+ set grocat [file join "$env(GISBASE)" "etc" "grocat"]
+ set cmd [concat | $cmd |& "\"$grocat\"" ]
set message_env [exec g.gisenv get=GRASS_MESSAGE_FORMAT]
set env(GRASS_MESSAGE_FORMAT) gui
Modified: grass/branches/releasebranch_6_4/lib/gtcltk/select.tcl
===================================================================
--- grass/branches/releasebranch_6_4/lib/gtcltk/select.tcl 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/lib/gtcltk/select.tcl 2009-09-12 15:51:39 UTC (rev 39149)
@@ -160,24 +160,24 @@
$tree bindText <Control-ButtonPress-1> "GSelect_::select $id $tree"
}
- set location_path "$env(GISDBASE)/$env(LOCATION_NAME)/"
- set current_mapset "$env(MAPSET)"
- set sympath "$env(GISBASE)/etc/symbol/"
+ set location_path [file normalize [file join "$env(GISDBASE)" "$env(LOCATION_NAME)"]]
+ set current_mapset [file normalize "$env(MAPSET)"]
+ set sympath [file normalize [file join "$env(GISBASE)" "etc" "symbol"]]
# main selection subroutine
if {$element != "symbol"} {
foreach dir [exec g.mapsets -p] {
- set windfile "$location_path/$dir/WIND"
+ set windfile [file normalize [file join "$location_path" "$dir" "WIND"]]
if { ! [ file exists $windfile ] } { continue }
- if { $dir == $current_mapset } {
+ if { $dir == [file tail "$current_mapset"] } {
$tree insert end root ms_$dir -text $dir -data $dir -open 1 \
-image [Bitmap::get openfold] -drawcross auto
} else {
$tree insert end root ms_$dir -text $dir -data $dir -open 0 \
-image [Bitmap::get folder] -drawcross auto
}
- set path "$location_path/$dir/$element/"
- foreach fp [ lsort -dictionary [glob -nocomplain $path/*] ] {
+ set path [file normalize [file join "$location_path" "$dir" "$element"]]
+ foreach fp [ lsort -dictionary [glob -nocomplain -directory $path *] ] {
set file [file tail $fp]
$tree insert end ms_$dir $file@$dir -text $file -data $file \
-image [Bitmap::get file] -drawcross never
@@ -190,14 +190,14 @@
$tree insert end root ms_$sympath -text SYMBOLS -data $sympath -open 1 \
-image [Bitmap::get openfold] -drawcross auto
- foreach ic_dir [ lsort -dictionary [glob -nocomplain $sympath/*] ] {
+ foreach ic_dir [ lsort -dictionary [glob -nocomplain -directory $sympath *] ] {
set dir_tail [file tail $ic_dir]
$tree insert end ms_$sympath ms_$dir_tail -text $dir_tail -data $dir_tail \
-image [Bitmap::get folder] -drawcross auto
- foreach ic_file [ lsort -dictionary [glob -nocomplain $sympath/$dir_tail/*] ] {
+ foreach ic_file [ lsort -dictionary [glob -nocomplain -directory [file join "$sympath" "$dir_tail"] *] ] {
set file [file tail $ic_file]
- $tree insert end ms_$dir_tail $dir_tail/$file -text $file -data $file \
+ $tree insert end ms_$dir_tail [file join "$dir_tail" "$file"] -text $file -data $file \
-image [Bitmap::get file] -drawcross never
}
}
Modified: grass/branches/releasebranch_6_4/lib/init/gis_set.tcl
===================================================================
--- grass/branches/releasebranch_6_4/lib/init/gis_set.tcl 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/lib/init/gis_set.tcl 2009-09-12 15:51:39 UTC (rev 39149)
@@ -59,10 +59,10 @@
if { [regexp -- {^GISDBASE: *(.*)$} $thisline dummy env_database] } {
set database $env_database
}
- if { [scan $thisline "LOCATION_NAME: %s" env_location] } {
+ if { [regexp -- {^LOCATION_NAME: *(.*)$} $thisline dummy env_location] } {
set location $env_location
}
- if { [scan $thisline "MAPSET: %s" env_mapset] } {
+ if { [regexp -- {^MAPSET: *(.*)$} $thisline dummy env_mapset] } {
set mapset $env_mapset
}
set thisline [gets $ifp]
@@ -119,8 +119,7 @@
global database location
set found 0
- set dir $database
- append dir "/$location"
+ set dir [file join "$database" "$location"]
set currDir [pwd]
# Special case - wrong GISDBASE
@@ -135,7 +134,7 @@
} else {
cdir $dir
.frame0.frameNMS.second.entry configure -state disabled
- if {[file isdirectory "PERMANENT"] && [file exists "$dir/PERMANENT/DEFAULT_WIND"]} {
+ if {[file isdirectory "PERMANENT"] && [file exists [file join "$dir" "PERMANENT" "DEFAULT_WIND"]]} {
set found 1
.frame0.frameNMS.second.entry configure -state normal
}
@@ -150,7 +149,7 @@
if { $mapset == "" } { return 0; }
- if { [file exists "$database/$location/$mapset/WIND"] } {
+ if { [file exists [file join "$database" "$location" "$mapset" "WIND"]] } {
return 1
}
return 0
@@ -393,11 +392,11 @@
puts $varfp "DB_DRIVER: dbf"
puts $varfp "DB_DATABASE: \$GISDBASE/\$LOCATION_NAME/\$MAPSET/dbf/"
close $varfp
- catch {file attributes $mymapset/VAR -permissions u+rw,go+r}
- file mkdir $mymapset/dbf
+ catch {file attributes [file join "$mymapset" "VAR"] -permissions u+rw,go+r}
+ file mkdir [file join "$mymapset" "dbf"]
#copy over the WIND definition:
- catch {file copy $mymapset/../PERMANENT/DEFAULT_WIND $mymapset/WIND}
- catch {file attributes $mymapset/WIND -permissions u+rw,go+r}
+ catch {file copy [file join "$mymapset" ".." "PERMANENT" "DEFAULT_WIND"] [file join "$mymapset" "WIND"]}
+ catch {file attributes [file join "$mymapset" "WIND"] -permissions u+rw,go+r}
.frame0.frameMS.listbox insert end $mymapset
selFromList .frame0.frameMS.listbox $mymapset
set mapset $mymapset
@@ -445,7 +444,7 @@
-relief raised -padx 15 \
-command {
if { $mingw == "1" } {
- exec -- cmd.exe /c start $env(GISBASE)/etc/set_data
+ exec -- cmd.exe /c start [file join "$env(GISBASE)" "etc" "set_data"]
} else {
exec -- $env(GISBASE)/etc/grass-xterm-wrapper -name xterm-grass -e $env(GISBASE)/etc/grass-run.sh $env(GISBASE)/etc/set_data
}
@@ -515,9 +514,9 @@
return
}
if { $mingw == "1" } {
- exec -- $env(GRASS_HTML_BROWSER) file://$env(GISBASE)/docs/html/helptext.html &;
+ exec -- "$env(GRASS_HTML_BROWSER)" "file://$env(GISBASE)/docs/html/helptext.html" &;
} else {
- exec -- $env(GRASS_HTML_BROWSER) file://$env(GISBASE)/docs/html/helptext.html >@stdout 2>@stderr &;
+ exec -- "$env(GRASS_HTML_BROWSER)" "file://$env(GISBASE)/docs/html/helptext.html" >@stdout 2>@stderr &;
}
}
Modified: grass/branches/releasebranch_6_4/lib/init/init.sh
===================================================================
--- grass/branches/releasebranch_6_4/lib/init/init.sh 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/lib/init/init.sh 2009-09-12 15:51:39 UTC (rev 39149)
@@ -952,7 +952,8 @@
rm -f "$bashrc"
echo "test -r ~/.alias && . ~/.alias" >> "$bashrc"
echo "PS1='GRASS GRASS_VERSION_NUMBER ($LOCATION_NAME):\w > '" >> "$bashrc"
- echo "PROMPT_COMMAND=$GISBASE/etc/prompt.sh" >> "$bashrc"
+ # Use \"' to allow spaces in $GISBASE
+ echo "PROMPT_COMMAND=\"'$GISBASE/etc/prompt.sh'\"" >> "$bashrc"
if [ -r "$USERHOME/.grass.bashrc" ]
then
Property changes on: grass/branches/releasebranch_6_4/vector/v.db.connect
___________________________________________________________________
Added: svn:mergeinfo
+ /grass/branches/develbranch_6/vector/v.db.connect:34936-39147
Modified: grass/branches/releasebranch_6_4/vector/v.db.connect/description.html
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.db.connect/description.html 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/vector/v.db.connect/description.html 2009-09-12 15:51:39 UTC (rev 39149)
@@ -13,7 +13,7 @@
<p>
When printing database connection (<em>p</em> or <em>g</em> flag) the parameter
<em>layer</em> is ignored, i.e. <b>all</b> connections are printed to the
-output.
+output, unless <em>l</em> flag is given.
<p>
<b>Attention:</b> Removing a vector map will also delete all tables
Modified: grass/branches/releasebranch_6_4/vector/v.db.connect/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.db.connect/main.c 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/vector/v.db.connect/main.c 2009-09-12 15:51:39 UTC (rev 39149)
@@ -34,7 +34,8 @@
struct GModule *module;
struct Option *inopt, *dbdriver, *dbdatabase, *dbtable, *field_opt,
*dbkey, *sep_opt;
- struct Flag *overwrite, *print, *columns, *delete, *shell_print;
+ struct Flag *overwrite, *print, *columns, *delete, *shell_print,
+ *limit_layer;
dbDriver *driver;
dbString table_name;
dbTable *table;
@@ -87,6 +88,15 @@
shell_print->description =
_("Format: layer[/layer name] table key database driver");
+ /* This should be changed in GRASS 7.
+ Printing options shouldn't ignore layer=%d option.
+ That would require us to override/unset the default layer=1 there :-/
+ or add a new -a flag for print all layers ?? */
+ limit_layer = G_define_flag();
+ limit_layer->key = 'l';
+ limit_layer->description =
+ _("When printing, limit to layer specified by the layer option");
+
columns = G_define_flag();
columns->key = 'c';
columns->description =
@@ -108,6 +118,7 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+
/* The check must allow '.' in the name (schema.table) */
/*
if (dbtable->answer) {
@@ -129,9 +140,6 @@
G_debug(3, "Mapset = %s", mapset);
- if (print->answer && shell_print->answer)
- G_fatal_error(_("Please choose only one print style"));
-
if (print->answer || shell_print->answer || columns->answer)
Vect_open_old(&Map, inopt->answer, mapset);
else {
@@ -156,8 +164,12 @@
if ((fi = Vect_get_dblink(&Map, i)) == NULL)
G_fatal_error(_("Database connection not defined"));
+ if (limit_layer->answer && fi->number != field)
+ continue;
+
if (shell_print->answer) {
const char *sep = sep_opt->answer;
+
if (fi->name) {
fprintf(stdout, "%d/%s%s%s%s%s%s%s%s%s\n",
fi->number, fi->name, sep,
@@ -174,8 +186,9 @@
else {
fprintf(stdout,
_("layer <%d> table <%s> in database <%s> through driver "
- "<%s> with key <%s>\n"), fi->number,
- fi->table, fi->database, fi->driver, fi->key);
+ "<%s> with key <%s>\n"), fi->number,
+ fi->table, fi->database, fi->driver,
+ fi->key);
}
}
} /* end print */
Modified: grass/branches/releasebranch_6_4/vector/v.digit/Makefile
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.digit/Makefile 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/vector/v.digit/Makefile 2009-09-12 15:51:39 UTC (rev 39149)
@@ -2,8 +2,8 @@
PGM = v.digit
-LIBES = $(DISPLAYLIB) $(RASTERLIB) $(VECTLIB) $(GISLIB) $(TCLTKLIBPATH) $(TCLTKLIBS)
-DEPENDENCIES= $(DISPLAYDEP) $(RASTERDEP) $(VECTDEP) $(GISDEP)
+LIBES = $(FORMLIB) $(DISPLAYLIB) $(RASTERLIB) $(VECTLIB) $(GISLIB) $(TCLTKLIBPATH) $(TCLTKLIBS)
+DEPENDENCIES= $(FORMDEP) $(DISPLAYDEP) $(RASTERDEP) $(VECTDEP) $(GISDEP)
EXTRA_CFLAGS = $(XCFLAGS) $(TCLINCDIR) $(TKINCDIR) $(VECT_CFLAGS)
XTRA_LDFLAGS=$(DFLAGS)
Deleted: grass/branches/releasebranch_6_4/vector/v.digit/generate.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.digit/generate.c 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/vector/v.digit/generate.c 2009-09-12 15:51:39 UTC (rev 39149)
@@ -1,253 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/dbmi.h>
-#include <grass/form.h>
-
-/* Generate form in HTML/TXT format.
- * Pointer to resulting string is stored to 'form'. This string must be freed by application.
- *
- * returns: -1 error
- * 0 success
- */
-int
-F_generate(char *drvname, char *dbname, char *tblname, char *key, int keyval,
- char *frmname, char *frmmapset,
- int edit_mode, int format, char **form)
-{
- int col, ncols, ctype, sqltype, more;
- char buf[5000], buf1[100];
- const char *colname;
- dbString sql, html, str;
- dbDriver *driver;
- dbHandle handle;
- dbCursor cursor;
- dbTable *table;
- dbColumn *column;
- dbValue *value;
-
- int i = 0;
-
- /* see /usr/lib/tcl8.4/encoding/ */
- static char *encoding_list[] = {
- "utf-8",
- "ascii",
- "iso8859-1",
- "iso8859-2",
- "iso8859-15",
- "iso2022-jp",
- "koi8-r",
- "euc-jp",
- NULL
- };
- char *enc_env;
-
- G__read_env();
- enc_env = G__getenv("GRASS_DB_ENCODING");
-
- /* TODO: support 'format' (txt, html), currently html only */
-
- G_debug(2,
- "F_generate(): drvname = '%s', dbname = '%s'\n tblname = '%s', key = '%s', keyval = %d\n"
- " form = '%s', form_mapset = '%s'\n edit_mode = %d",
- drvname, dbname, tblname, key, keyval, frmname, frmmapset,
- edit_mode);
-
- db_init_string(&sql);
- db_init_string(&html); /* here is the result stored */
- db_init_string(&str);
-
- G_debug(2, "Open driver");
- driver = db_start_driver(drvname);
- if (driver == NULL) {
- G_warning("Cannot open driver\n");
- sprintf(buf, "Cannot open driver '%s'<BR>", drvname);
- *form = G_store(buf);
- return -1;
- }
- G_debug(2, "Driver opened");
-
- db_init_handle(&handle);
- db_set_handle(&handle, dbname, NULL);
- G_debug(2, "Open database");
- if (db_open_database(driver, &handle) != DB_OK) {
- G_warning("Cannot open database\n");
- db_shutdown_driver(driver);
- sprintf(buf, "Cannot open database '%s' by driver '%s'<BR>", dbname,
- drvname);
- *form = G_store(buf);
- return -1;
- }
- G_debug(2, "Database opened");
-
- /* TODO: test if table exist first, but this should be tested by application befor
- * F_generate() is called, because it may be correct (connection defined in DB
- * but table does not exist) */
-
- sprintf(buf, "select * from %s where %s = %d", tblname, key, keyval);
- G_debug(2, "%s", buf);
- db_set_string(&sql, buf);
- if (db_open_select_cursor(driver, &sql, &cursor, DB_SEQUENTIAL) != DB_OK) {
- G_warning("Cannot open select cursor\n");
- db_close_database(driver);
- db_shutdown_driver(driver);
- sprintf(buf,
- "Cannot open select cursor:<BR>'%s'<BR>on database '%s' by driver '%s'<BR>",
- db_get_string(&sql), dbname, drvname);
- *form = G_store(buf);
- return -1;
- }
- G_debug(2, "Select Cursor opened");
-
- table = db_get_cursor_table(&cursor);
-
- if (db_fetch(&cursor, DB_NEXT, &more) != DB_OK) {
- G_warning("Cannot fetch next record\n");
- db_close_cursor(&cursor);
- db_close_database(driver);
- db_shutdown_driver(driver);
- *form = G_store("Cannot fetch next record");
- return -1;
- }
-
- if (!more) {
- G_warning("No database record");
- if (format == F_HTML) {
- *form = G_store("No record selected.<BR>");
- }
- else {
- *form = G_store("No record selected.");
- }
- }
- else {
- ncols = db_get_table_number_of_columns(table);
-
- /* Start form */
- if (format == F_HTML) {
- if (edit_mode == F_EDIT) {
- db_append_string(&html, "<FORM>");
-
- sprintf(buf, "<INPUT type=hidden name=%s value=\"%s\">",
- F_DRIVER_FNAME, drvname);
- db_append_string(&html, buf);
- /* 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 */
- sprintf(buf, "<INPUT type=hidden value=\"%s\" name=%s>",
- dbname, F_DATABASE_FNAME);
- db_append_string(&html, buf);
- sprintf(buf, "<INPUT type=hidden name=%s value=\"%s\">",
- F_TABLE_FNAME, tblname);
- db_append_string(&html, buf);
- sprintf(buf, "<INPUT type=hidden name=%s value=\"%s\">",
- F_KEY_FNAME, key);
- db_append_string(&html, buf);
-
- }
-
- for (col = 0; col < ncols; col++) {
- column = db_get_table_column(table, col);
- sqltype = db_get_column_sqltype(column);
- ctype = db_sqltype_to_Ctype(sqltype);
- value = db_get_column_value(column);
- db_convert_value_to_string(value, sqltype, &str);
- colname = db_get_column_name(column);
-
- G_debug(2, "%s: %s", colname, db_get_string(&str));
-
- if (edit_mode == F_VIEW) {
- sprintf(buf, "<B>%s : </B> %s <BR>", colname,
- db_get_string(&str));
- db_append_string(&html, buf);
- }
- else {
- sprintf(buf, "<B>%s : </B>", colname);
- db_append_string(&html, buf);
-
- if (G_strcasecmp(colname, key) == 0) {
- sprintf(buf,
- "%s<BR> <INPUT type=hidden name=%s value=\"%s\">",
- db_get_string(&str), colname,
- db_get_string(&str));
- }
- else {
- switch (ctype) {
- case DB_C_TYPE_INT:
- sprintf(buf1, "20");
- break;
- case DB_C_TYPE_DOUBLE:
- sprintf(buf1, "30");
- break;
- case DB_C_TYPE_STRING:
- sprintf(buf1, "%d", db_get_column_length(column));
- break;
- case DB_C_TYPE_DATETIME:
- sprintf(buf1, "20");
- break;
- }
- sprintf(buf,
- "<INPUT type=text size=%s name=%s value=\"%s\"><BR>",
- buf1, colname, db_get_string(&str));
- }
- db_append_string(&html, buf);
- }
- }
-
- if (edit_mode == F_EDIT) {
- sprintf(buf,
- "<HR> Assume data encoding as:<BR><BR><SELECT NAME=%s SIZE=4><HR><BR>",
- F_ENCODING);
- db_append_string(&html, buf);
-
- i = 0;
- while (encoding_list[i] != NULL) {
-
- if (G_strcasecmp(encoding_list[i], enc_env) == 0)
- sprintf(buf, "<OPTION VALUE=\"%s\" SELECTED>%s",
- encoding_list[i], encoding_list[i]);
- else
- sprintf(buf, "<OPTION VALUE=\"%s\">%s",
- encoding_list[i], encoding_list[i]);
- ++i;
- db_append_string(&html, buf);
- }
-
- sprintf(buf, "</SELECT>");
- db_append_string(&html, buf);
- }
-
- /* Close form */
- if (edit_mode == F_EDIT) {
- db_append_string(&html, "</FORM>");
- }
- }
- else { /* F_TXT */
- for (col = 0; col < ncols; col++) {
- column = db_get_table_column(table, col);
- sqltype = db_get_column_sqltype(column);
- ctype = db_sqltype_to_Ctype(sqltype);
- value = db_get_column_value(column);
- db_convert_value_to_string(value, sqltype, &str);
- colname = db_get_column_name(column);
-
- G_debug(2, "%s: %s", colname, db_get_string(&str));
-
- sprintf(buf, "%s : %s\n", colname, db_get_string(&str));
- db_append_string(&html, buf);
- }
- }
- }
- G_debug(2, "FORM STRING:\n%s\n", db_get_string(&html));
-
- db_close_cursor(&cursor);
- db_close_database(driver);
- db_shutdown_driver(driver);
-
- *form = G_store(db_get_string(&html));
-
- db_free_string(&sql);
- db_free_string(&html);
- db_free_string(&str);
-
- return 0;
-}
Deleted: grass/branches/releasebranch_6_4/vector/v.digit/open.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.digit/open.c 2009-09-12 15:40:06 UTC (rev 39148)
+++ grass/branches/releasebranch_6_4/vector/v.digit/open.c 2009-09-12 15:51:39 UTC (rev 39149)
@@ -1,58 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/dbmi.h>
-#include "global.h"
-#include "proto.h"
-
-int first = 1;
-
-/* Open new form
- *
- * returns: 0 success
- */
-int F_open(char *title, char *html)
-{
- int len;
- char *buf;
-
- if (first) {
- Tcl_Eval(Toolbox, "init_form");
- first = 0;
- }
-
- G_debug(2, "PARENT HTML:\n%s\n", html);
-
- len = strlen(title) + strlen(html) + 20;
- buf = G_malloc(len);
- sprintf(buf, "open_form {%s} {%s}", title, html);
- Tcl_Eval(Toolbox, buf);
- G_free(buf);
-
- return 0;
-}
-
-/* Clear old forms from window
- *
- */
-void F_clear(void)
-{
- G_debug(2, "F_clear()");
-
- if (first)
- return;
-
- Tcl_Eval(Toolbox, "clear_form");
-}
-
-void F_close(void)
-{
- G_debug(2, "F_close()");
-
- if (first)
- return;
-
- Tcl_Eval(Toolbox, "done_form");
-
- first = 1;
-}
More information about the grass-commit
mailing list