#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
+#include <OSD_Path.hxx>
#include <string.h>
#include <tcl.h>
if (myInterp==NULL) Init();
CData* C = new CData(f,this);
- Standard_Size length, num_slashes, ii, jj, kk;
Tcl_CreateCommand(myInterp,pN,CommandCmd, (ClientData) C, CommandDelete);
// add the help
Tcl_SetVar2(myInterp,"Draw_Helps",pN,pHelp,TCL_GLOBAL_ONLY);
Tcl_SetVar2(myInterp,"Draw_Groups",pGroup,pN,
TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
- length = strlen(pFileName) ;
- char * a_string =
- new char[length + 1] ;
- jj = 0 ;
- num_slashes = 0 ;
- ii = length ;
- while (num_slashes < 3 && ii >= 0) {
- if (file_name[ii] == '/') {
- num_slashes += 1 ;
- }
- ii -= 1 ;
- }
- jj = 0 ;
- for (kk = ii+2 , jj =0 ; kk < length ; kk++) {
- a_string[jj] = file_name[kk] ;
- jj += 1 ;
- }
- a_string[jj] = '\0' ;
-
- Tcl_SetVar2(myInterp,"Draw_Files",pN,a_string,TCL_GLOBAL_ONLY);
-
- delete [] a_string;
+ // add path to source file (keep not more than two last subdirectories)
+ OSD_Path aPath (pFileName);
+ Standard_Integer nbTrek = aPath.TrekLength();
+ for (Standard_Integer i = 2; i < nbTrek; i++)
+ aPath.RemoveATrek (1);
+ aPath.SetDisk("");
+ aPath.SetNode("");
+ TCollection_AsciiString aSrcPath;
+ aPath.SystemName (aSrcPath);
+ Tcl_SetVar2(myInterp,"Draw_Files",pN,aSrcPath.ToCString(),TCL_GLOBAL_ONLY);
}
global Draw_Helps Draw_Groups Draw_Files
+ set out {}
if {$command == ""} {
# help general
foreach h [lsort [array names Draw_Groups]] {
- puts ""
- puts ""
- puts $h
+ lappend out "" "" "$h"
set i 0
foreach f [lsort $Draw_Groups($h)] {
if {$i == 0} {
- puts " "
+ lappend out ""
}
incr i
#
#
foreach command_that_has_file [array names Draw_Files] {
if {($command_that_has_file == $f)} {
-#
-# compute the length of the string to have the right spacing
-# with tabs
-#
- set ll [string length $f]
- if {($ll >= 1) && ($ll < 8)} {
- puts "$f\t\t: $Draw_Files($f) "
- }
- if {($ll >= 8)} {
- puts "$f\t: $Draw_Files($f) "
- }
-
+ lappend out [format {%-20s %s} $f $Draw_Files($f)]
}
}
}
append command "*"
foreach f [lsort [array names Draw_Files]] {
if {[string match $command $f]} {
- puts -nonewline $f
- for {set j [string length $f]} {$j < 15} {incr j} {
- puts -nonewline " "
- }
-
- puts " $Draw_Files($f)"
+ lappend out [format {%-20s %s} $f $Draw_Files($f)]
}
}
}
- flush stdout
+ return [join $out "\n"]
}
help getsourcefile {getsourcefile, or getsourcefile command } {DRAW General Commands}
# log only output to stdout and stderr, not to file!
if {[llength $args] > 1} {
- set optvarg [lindex $args end-1]
- if { $optarg == stdout || $optarg == stderr || $optarg == -newline } {
+ set optarg [lindex $args end-1]
+ if { $optarg == "stdout" || $optarg == "stderr" || $optarg == "-newline" } {
dlog add [lindex $args end]
}
} else {
--- /dev/null
+# test for command getsource
+
+# check that path returned for command pload is as expected
+set expected src/Draw/Draw_PloadCommands.cxx
+set path [lindex [getsourcefile pload] 1]
+if { [string compare $path $expected] } {
+ puts "Error: command 'getsourcefile pload' returned '$path' while expected '$expected'"
+}
+
+puts "TEST COMPLETED"