summaryrefslogtreecommitdiff
path: root/appl/lib/tcl_utils.b
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
commit37da2899f40661e3e9631e497da8dc59b971cbd0 (patch)
treecbc6d4680e347d906f5fa7fca73214418741df72 /appl/lib/tcl_utils.b
parent54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff)
20060303a
Diffstat (limited to 'appl/lib/tcl_utils.b')
-rw-r--r--appl/lib/tcl_utils.b61
1 files changed, 61 insertions, 0 deletions
diff --git a/appl/lib/tcl_utils.b b/appl/lib/tcl_utils.b
new file mode 100644
index 00000000..8dcf13bf
--- /dev/null
+++ b/appl/lib/tcl_utils.b
@@ -0,0 +1,61 @@
+implement Tcl_Utils;
+include "sys.m";
+include "draw.m";
+include "tk.m";
+include "tcl.m";
+include "tcllib.m";
+include "utils.m";
+
+break_it(s : string) : array of string {
+ argv:= array[200] of string;
+ buf : string;
+ argc := 0;
+ nc := 0;
+ outer:
+ for (i := 0; i < len s ; ) {
+ case int s[i] {
+ ' ' or '\t' or '\n' =>
+ if (nc > 0) { # end of a word?
+ argv[argc++] = buf;
+ buf = nil;
+ nc = 0;
+ }
+ i++;
+ '{' =>
+ if (s[i+1]=='}'){
+ argv[argc++] = nil;
+ buf = nil;
+ nc = 0;
+ i+=2;
+ }else{
+ nbra := 1;
+ for (i++; i < len s; i++) {
+ if (s[i] == '{')
+ nbra++;
+ else if (s[i] == '}') {
+ nbra--;
+ if (nbra == 0) {
+ i++;
+ continue outer;
+ }
+ }
+ buf[nc++] = s[i];
+ }
+ }
+ * =>
+ buf[nc++] = s[i++];
+ }
+ }
+ if (nc > 0) # fix up last word if present
+ argv[argc++] = buf;
+ ret := array[argc] of string;
+ ret[0:] = argv[0:argc];
+ return ret;
+}
+
+arr_resize(argv : array of string) : array of string {
+ ret := array[len argv + 25] of string;
+ ret[0:]=argv;
+ return ret;
+}
+