Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 11 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* This code is automatically generated by "mktclapp" version 3.9 */ |
1 | /* This code is automatically generated by "mktclapp" version 3.9 */ |
2 | /* DO NOT EDIT */ |
2 | /* DO NOT EDIT */ |
3 | #include <tcl.h> |
3 | #include <tcl.h> |
4 | #define INTERFACE 1 |
4 | #define INTERFACE 1 |
5 | #if INTERFACE |
5 | #if INTERFACE |
6 | #define ET_TCLARGS ClientData clientData, Tcl_Interp *interp, int argc, char **argv |
6 | #define ET_TCLARGS ClientData clientData,Tcl_Interp*interp,int argc,char**argv |
7 | #define ET_OBJARGS ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] |
7 | #define ET_OBJARGS ClientData clientData,Tcl_Interp*interp,int objc,Tcl_Obj*CONST objv[] |
8 | #endif |
8 | #endif |
9 | #define ET_ENABLE_OBJ 0 |
9 | #define ET_ENABLE_OBJ 0 |
10 | #define ET_ENABLE_TK 1 |
10 | #define ET_ENABLE_TK 1 |
11 | #define ET_AUTO_FORK 0 |
11 | #define ET_AUTO_FORK 0 |
12 | #define ET_STANDALONE 0 |
12 | #define ET_STANDALONE 0 |
Line 21... | Line 21... | ||
21 | #define ET_MAIN_SCRIPT "C:/cygwin/home/vertical/scripts/trial.tcl" |
21 | #define ET_MAIN_SCRIPT "C:/cygwin/home/vertical/scripts/trial.tcl" |
22 | #define ET_EXTENSION 0 |
22 | #define ET_EXTENSION 0 |
23 | #define ET_SHROUD_KEY 0 |
23 | #define ET_SHROUD_KEY 0 |
24 | #define ET_READ_STDIN 1 |
24 | #define ET_READ_STDIN 1 |
25 | #define ET_CONSOLE 0 |
25 | #define ET_CONSOLE 0 |
26 | extern int ET_COMMAND_vertical (ET_TCLARGS); |
26 | extern int ET_COMMAND_vertical(ET_TCLARGS); |
27 | extern int ET_COMMAND_wossat (ET_TCLARGS); |
27 | extern int ET_COMMAND_wossat(ET_TCLARGS); |
28 | static struct |
28 | static struct { |
29 | { |
29 | char *zName; |
30 | char *zName; |
30 | int (*xProc)(ET_TCLARGS); |
31 | int (*xProc) (ET_TCLARGS); |
31 | } Et_CmdSet[] = { |
32 | } Et_CmdSet[] = {{"vertical", ET_COMMAND_vertical}, {"wossat", ET_COMMAND_wossat}, {0, 0}}; |
32 | { "vertical", ET_COMMAND_vertical }, |
33 | static char Et_zFile0[] = |
33 | { "wossat", ET_COMMAND_wossat }, |
34 | "# Tcl autoload index file, version 2.0\n" |
34 | {0, 0}}; |
35 | "# This file is generated by the \"auto_mkindex\" command\n" |
35 | static char Et_zFile0[] = |
36 | "# and sourced to set up indexing information for one or\n" |
36 | "# Tcl autoload index file, version 2.0\n" |
37 | "# more commands. Typically each line is a command that\n" |
37 | "# This file is generated by the \"auto_mkindex\" command\n" |
38 | "# sets an element in the auto_index array, where the\n" |
38 | "# and sourced to set up indexing information for one or\n" |
39 | "# element name is the name of a command and the value is\n" |
39 | "# more commands. Typically each line is a command that\n" |
40 | "# a script that loads the command.\n" |
40 | "# sets an element in the auto_index array, where the\n" |
41 | "\n" |
41 | "# element name is the name of a command and the value is\n" |
42 | "set auto_index(history) [list source [file join $dir history.tcl]]\n" |
42 | "# a script that loads the command.\n" |
43 | "set auto_index(tclLdAout) [list source [file join $dir ldAout.tcl]]\n" |
43 | "\n" |
44 | "set auto_index(parray) [list source [file join $dir parray.tcl]]\n" |
44 | "set auto_index(history) [list source [file join $dir history.tcl]]\n" |
45 | "set auto_index(::safe::interpCreate) [list source [file join $dir safe.tcl]]\n" |
45 | "set auto_index(tclLdAout) [list source [file join $dir ldAout.tcl]]\n" |
46 | "set auto_index(::safe::interpInit) [list source [file join $dir safe.tcl]]\n" |
46 | "set auto_index(parray) [list source [file join $dir parray.tcl]]\n" |
47 | "set auto_index(::safe::interpConfigure) [list source [file join $dir safe.tcl]]\n" |
47 | "set auto_index(::safe::interpCreate) [list source [file join $dir safe.tcl]]\n" |
48 | "set auto_index(::safe::interpFindInAccessPath) [list source [file join $dir safe.tcl]]\n" |
48 | "set auto_index(::safe::interpInit) [list source [file join $dir safe.tcl]]\n" |
49 | "set auto_index(::safe::interpAddToAccessPath) [list source [file join $dir safe.tcl]]\n" |
49 | "set auto_index(::safe::interpConfigure) [list source [file join $dir safe.tcl]]\n" |
50 | "set auto_index(::safe::interpDelete) [list source [file join $dir safe.tcl]]\n" |
50 | "set auto_index(::safe::interpFindInAccessPath) [list source [file join $dir safe.tcl]]\n" |
51 | "set auto_index(::safe::setLogCmd) [list source [file join $dir safe.tcl]]\n" |
51 | "set auto_index(::safe::interpAddToAccessPath) [list source [file join $dir safe.tcl]]\n" |
52 | "set auto_index(tcl_wordBreakAfter) [list source [file join $dir word.tcl]]\n" |
52 | "set auto_index(::safe::interpDelete) [list source [file join $dir safe.tcl]]\n" |
53 | "set auto_index(tcl_wordBreakBefore) [list source [file join $dir word.tcl]]\n" |
53 | "set auto_index(::safe::setLogCmd) [list source [file join $dir safe.tcl]]\n" |
54 | "set auto_index(tcl_endOfWord) [list source [file join $dir word.tcl]]\n" |
54 | "set auto_index(tcl_wordBreakAfter) [list source [file join $dir word.tcl]]\n" |
55 | "set auto_index(tcl_startOfNextWord) [list source [file join $dir word.tcl]]\n" |
55 | "set auto_index(tcl_wordBreakBefore) [list source [file join $dir word.tcl]]\n" |
56 | "set auto_index(tcl_startOfPreviousWord) [list source [file join $dir word.tcl]]\n"; |
56 | "set auto_index(tcl_endOfWord) [list source [file join $dir word.tcl]]\n" |
57 | static char Et_zFile1[] = |
57 | "set auto_index(tcl_startOfNextWord) [list source [file join $dir word.tcl]]\n" |
58 | "# Tcl autoload index file, version 2.0\n" |
58 | "set auto_index(tcl_startOfPreviousWord) [list source [file join $dir word.tcl]]\n" |
59 | "# This file is generated by the \"auto_mkindex\" command\n" |
59 | ; |
60 | "# and sourced to set up indexing information for one or\n" |
60 | static char Et_zFile1[] = |
61 | "# more commands. Typically each line is a command that\n" |
61 | "# Tcl autoload index file, version 2.0\n" |
62 | "# sets an element in the auto_index array, where the\n" |
62 | "# This file is generated by the \"auto_mkindex\" command\n" |
63 | "# element name is the name of a command and the value is\n" |
63 | "# and sourced to set up indexing information for one or\n" |
64 | "# a script that loads the command.\n" |
64 | "# more commands. Typically each line is a command that\n" |
65 | "\n" |
65 | "# sets an element in the auto_index array, where the\n" |
66 | "set auto_index(tkButtonEnter) [list source [file join $dir button.tcl]]\n" |
66 | "# element name is the name of a command and the value is\n" |
67 | "set auto_index(tkButtonLeave) [list source [file join $dir button.tcl]]\n" |
67 | "# a script that loads the command.\n" |
68 | "set auto_index(tkCheckRadioEnter) [list source [file join $dir button.tcl]]\n" |
68 | "\n" |
69 | "set auto_index(tkButtonDown) [list source [file join $dir button.tcl]]\n" |
69 | "set auto_index(tkButtonEnter) [list source [file join $dir button.tcl]]\n" |
70 | "set auto_index(tkCheckRadioDown) [list source [file join $dir button.tcl]]\n" |
70 | "set auto_index(tkButtonLeave) [list source [file join $dir button.tcl]]\n" |
71 | "set auto_index(tkButtonUp) [list source [file join $dir button.tcl]]\n" |
71 | "set auto_index(tkCheckRadioEnter) [list source [file join $dir button.tcl]]\n" |
72 | "set auto_index(tkButtonEnter) [list source [file join $dir button.tcl]]\n" |
72 | "set auto_index(tkButtonDown) [list source [file join $dir button.tcl]]\n" |
73 | "set auto_index(tkButtonLeave) [list source [file join $dir button.tcl]]\n" |
73 | "set auto_index(tkCheckRadioDown) [list source [file join $dir button.tcl]]\n" |
74 | "set auto_index(tkButtonDown) [list source [file join $dir button.tcl]]\n" |
74 | "set auto_index(tkButtonUp) [list source [file join $dir button.tcl]]\n" |
75 | "set auto_index(tkButtonUp) [list source [file join $dir button.tcl]]\n" |
75 | "set auto_index(tkButtonEnter) [list source [file join $dir button.tcl]]\n" |
76 | "set auto_index(tkButtonEnter) [list source [file join $dir button.tcl]]\n" |
76 | "set auto_index(tkButtonLeave) [list source [file join $dir button.tcl]]\n" |
77 | "set auto_index(tkButtonLeave) [list source [file join $dir button.tcl]]\n" |
77 | "set auto_index(tkButtonDown) [list source [file join $dir button.tcl]]\n" |
78 | "set auto_index(tkButtonDown) [list source [file join $dir button.tcl]]\n" |
78 | "set auto_index(tkButtonUp) [list source [file join $dir button.tcl]]\n" |
79 | "set auto_index(tkButtonUp) [list source [file join $dir button.tcl]]\n" |
79 | "set auto_index(tkButtonEnter) [list source [file join $dir button.tcl]]\n" |
80 | "set auto_index(tkButtonInvoke) [list source [file join $dir button.tcl]]\n" |
80 | "set auto_index(tkButtonLeave) [list source [file join $dir button.tcl]]\n" |
81 | "set auto_index(tkCheckRadioInvoke) [list source [file join $dir button.tcl]]\n" |
81 | "set auto_index(tkButtonDown) [list source [file join $dir button.tcl]]\n" |
82 | "set auto_index(tk_dialog) [list source [file join $dir dialog.tcl]]\n" |
82 | "set auto_index(tkButtonUp) [list source [file join $dir button.tcl]]\n" |
83 | "set auto_index(tkEntryClosestGap) [list source [file join $dir entry.tcl]]\n" |
83 | "set auto_index(tkButtonInvoke) [list source [file join $dir button.tcl]]\n" |
84 | "set auto_index(tkEntryButton1) [list source [file join $dir entry.tcl]]\n" |
84 | "set auto_index(tkCheckRadioInvoke) [list source [file join $dir button.tcl]]\n" |
85 | "set auto_index(tkEntryMouseSelect) [list source [file join $dir entry.tcl]]\n" |
85 | "set auto_index(tk_dialog) [list source [file join $dir dialog.tcl]]\n" |
86 | "set auto_index(tkEntryPaste) [list source [file join $dir entry.tcl]]\n" |
86 | "set auto_index(tkEntryClosestGap) [list source [file join $dir entry.tcl]]\n" |
87 | "set auto_index(tkEntryAutoScan) [list source [file join $dir entry.tcl]]\n" |
87 | "set auto_index(tkEntryButton1) [list source [file join $dir entry.tcl]]\n" |
88 | "set auto_index(tkEntryKeySelect) [list source [file join $dir entry.tcl]]\n" |
88 | "set auto_index(tkEntryMouseSelect) [list source [file join $dir entry.tcl]]\n" |
89 | "set auto_index(tkEntryInsert) [list source [file join $dir entry.tcl]]\n" |
89 | "set auto_index(tkEntryPaste) [list source [file join $dir entry.tcl]]\n" |
90 | "set auto_index(tkEntryBackspace) [list source [file join $dir entry.tcl]]\n" |
90 | "set auto_index(tkEntryAutoScan) [list source [file join $dir entry.tcl]]\n" |
91 | "set auto_index(tkEntrySeeInsert) [list source [file join $dir entry.tcl]]\n" |
91 | "set auto_index(tkEntryKeySelect) [list source [file join $dir entry.tcl]]\n" |
92 | "set auto_index(tkEntrySetCursor) [list source [file join $dir entry.tcl]]\n" |
92 | "set auto_index(tkEntryInsert) [list source [file join $dir entry.tcl]]\n" |
93 | "set auto_index(tkEntryTranspose) [list source [file join $dir entry.tcl]]\n" |
93 | "set auto_index(tkEntryBackspace) [list source [file join $dir entry.tcl]]\n" |
94 | "set auto_index(tkEntryPreviousWord) [list source [file join $dir entry.tcl]]\n" |
94 | "set auto_index(tkEntrySeeInsert) [list source [file join $dir entry.tcl]]\n" |
95 | "set auto_index(tkListboxBeginSelect) [list source [file join $dir listbox.tcl]]\n" |
95 | "set auto_index(tkEntrySetCursor) [list source [file join $dir entry.tcl]]\n" |
96 | "set auto_index(tkListboxMotion) [list source [file join $dir listbox.tcl]]\n" |
96 | "set auto_index(tkEntryTranspose) [list source [file join $dir entry.tcl]]\n" |
97 | "set auto_index(tkListboxBeginExtend) [list source [file join $dir listbox.tcl]]\n" |
97 | "set auto_index(tkEntryPreviousWord) [list source [file join $dir entry.tcl]]\n" |
98 | "set auto_index(tkListboxBeginToggle) [list source [file join $dir listbox.tcl]]\n" |
98 | "set auto_index(tkListboxBeginSelect) [list source [file join $dir listbox.tcl]]\n" |
99 | "set auto_index(tkListboxAutoScan) [list source [file join $dir listbox.tcl]]\n" |
99 | "set auto_index(tkListboxMotion) [list source [file join $dir listbox.tcl]]\n" |
100 | "set auto_index(tkListboxUpDown) [list source [file join $dir listbox.tcl]]\n" |
100 | "set auto_index(tkListboxBeginExtend) [list source [file join $dir listbox.tcl]]\n" |
101 | "set auto_index(tkListboxExtendUpDown) [list source [file join $dir listbox.tcl]]\n" |
101 | "set auto_index(tkListboxBeginToggle) [list source [file join $dir listbox.tcl]]\n" |
102 | "set auto_index(tkListboxDataExtend) [list source [file join $dir listbox.tcl]]\n" |
102 | "set auto_index(tkListboxAutoScan) [list source [file join $dir listbox.tcl]]\n" |
103 | "set auto_index(tkListboxCancel) [list source [file join $dir listbox.tcl]]\n" |
103 | "set auto_index(tkListboxUpDown) [list source [file join $dir listbox.tcl]]\n" |
104 | "set auto_index(tkListboxSelectAll) [list source [file join $dir listbox.tcl]]\n" |
104 | "set auto_index(tkListboxExtendUpDown) [list source [file join $dir listbox.tcl]]\n" |
105 | "set auto_index(tkMbEnter) [list source [file join $dir menu.tcl]]\n" |
105 | "set auto_index(tkListboxDataExtend) [list source [file join $dir listbox.tcl]]\n" |
106 | "set auto_index(tkMbLeave) [list source [file join $dir menu.tcl]]\n" |
106 | "set auto_index(tkListboxCancel) [list source [file join $dir listbox.tcl]]\n" |
107 | "set auto_index(tkMbPost) [list source [file join $dir menu.tcl]]\n" |
107 | "set auto_index(tkListboxSelectAll) [list source [file join $dir listbox.tcl]]\n" |
108 | "set auto_index(tkMenuUnpost) [list source [file join $dir menu.tcl]]\n" |
108 | "set auto_index(tkMbEnter) [list source [file join $dir menu.tcl]]\n" |
109 | "set auto_index(tkMbMotion) [list source [file join $dir menu.tcl]]\n" |
109 | "set auto_index(tkMbLeave) [list source [file join $dir menu.tcl]]\n" |
110 | "set auto_index(tkMbButtonUp) [list source [file join $dir menu.tcl]]\n" |
110 | "set auto_index(tkMbPost) [list source [file join $dir menu.tcl]]\n" |
111 | "set auto_index(tkMenuMotion) [list source [file join $dir menu.tcl]]\n" |
111 | "set auto_index(tkMenuUnpost) [list source [file join $dir menu.tcl]]\n" |
112 | "set auto_index(tkMenuButtonDown) [list source [file join $dir menu.tcl]]\n" |
112 | "set auto_index(tkMbMotion) [list source [file join $dir menu.tcl]]\n" |
113 | "set auto_index(tkMenuLeave) [list source [file join $dir menu.tcl]]\n" |
113 | "set auto_index(tkMbButtonUp) [list source [file join $dir menu.tcl]]\n" |
114 | "set auto_index(tkMenuInvoke) [list source [file join $dir menu.tcl]]\n" |
114 | "set auto_index(tkMenuMotion) [list source [file join $dir menu.tcl]]\n" |
115 | "set auto_index(tkMenuEscape) [list source [file join $dir menu.tcl]]\n" |
115 | "set auto_index(tkMenuButtonDown) [list source [file join $dir menu.tcl]]\n" |
116 | "set auto_index(tkMenuUpArrow) [list source [file join $dir menu.tcl]]\n" |
116 | "set auto_index(tkMenuLeave) [list source [file join $dir menu.tcl]]\n" |
117 | "set auto_index(tkMenuDownArrow) [list source [file join $dir menu.tcl]]\n" |
117 | "set auto_index(tkMenuInvoke) [list source [file join $dir menu.tcl]]\n" |
118 | "set auto_index(tkMenuLeftArrow) [list source [file join $dir menu.tcl]]\n" |
118 | "set auto_index(tkMenuEscape) [list source [file join $dir menu.tcl]]\n" |
119 | "set auto_index(tkMenuRightArrow) [list source [file join $dir menu.tcl]]\n" |
119 | "set auto_index(tkMenuUpArrow) [list source [file join $dir menu.tcl]]\n" |
120 | "set auto_index(tkMenuNextMenu) [list source [file join $dir menu.tcl]]\n" |
120 | "set auto_index(tkMenuDownArrow) [list source [file join $dir menu.tcl]]\n" |
121 | "set auto_index(tkMenuNextEntry) [list source [file join $dir menu.tcl]]\n" |
121 | "set auto_index(tkMenuLeftArrow) [list source [file join $dir menu.tcl]]\n" |
122 | "set auto_index(tkMenuFind) [list source [file join $dir menu.tcl]]\n" |
122 | "set auto_index(tkMenuRightArrow) [list source [file join $dir menu.tcl]]\n" |
123 | "set auto_index(tkTraverseToMenu) [list source [file join $dir menu.tcl]]\n" |
123 | "set auto_index(tkMenuNextMenu) [list source [file join $dir menu.tcl]]\n" |
124 | "set auto_index(tkFirstMenu) [list source [file join $dir menu.tcl]]\n" |
124 | "set auto_index(tkMenuNextEntry) [list source [file join $dir menu.tcl]]\n" |
125 | "set auto_index(tkTraverseWithinMenu) [list source [file join $dir menu.tcl]]\n" |
125 | "set auto_index(tkMenuFind) [list source [file join $dir menu.tcl]]\n" |
126 | "set auto_index(tkMenuFirstEntry) [list source [file join $dir menu.tcl]]\n" |
126 | "set auto_index(tkTraverseToMenu) [list source [file join $dir menu.tcl]]\n" |
127 | "set auto_index(tkMenuFindName) [list source [file join $dir menu.tcl]]\n" |
127 | "set auto_index(tkFirstMenu) [list source [file join $dir menu.tcl]]\n" |
128 | "set auto_index(tkPostOverPoint) [list source [file join $dir menu.tcl]]\n" |
128 | "set auto_index(tkTraverseWithinMenu) [list source [file join $dir menu.tcl]]\n" |
129 | "set auto_index(tkSaveGrabInfo) [list source [file join $dir menu.tcl]]\n" |
129 | "set auto_index(tkMenuFirstEntry) [list source [file join $dir menu.tcl]]\n" |
130 | "set auto_index(tkRestoreOldGrab) [list source [file join $dir menu.tcl]]\n" |
130 | "set auto_index(tkMenuFindName) [list source [file join $dir menu.tcl]]\n" |
131 | "set auto_index(tk_menuSetFocus) [list source [file join $dir menu.tcl]]\n" |
131 | "set auto_index(tkPostOverPoint) [list source [file join $dir menu.tcl]]\n" |
132 | "set auto_index(tkGenerateMenuSelect) [list source [file join $dir menu.tcl]]\n" |
132 | "set auto_index(tkSaveGrabInfo) [list source [file join $dir menu.tcl]]\n" |
133 | "set auto_index(tk_popup) [list source [file join $dir menu.tcl]]\n" |
133 | "set auto_index(tkRestoreOldGrab) [list source [file join $dir menu.tcl]]\n" |
134 | "set auto_index(tkScrollButtonDown) [list source [file join $dir scrlbar.tcl]]\n" |
134 | "set auto_index(tk_menuSetFocus) [list source [file join $dir menu.tcl]]\n" |
135 | "set auto_index(tkScrollButtonUp) [list source [file join $dir scrlbar.tcl]]\n" |
135 | "set auto_index(tkGenerateMenuSelect) [list source [file join $dir menu.tcl]]\n" |
136 | "set auto_index(tkScrollSelect) [list source [file join $dir scrlbar.tcl]]\n" |
136 | "set auto_index(tk_popup) [list source [file join $dir menu.tcl]]\n" |
137 | "set auto_index(tkScrollStartDrag) [list source [file join $dir scrlbar.tcl]]\n" |
137 | "set auto_index(tkScrollButtonDown) [list source [file join $dir scrlbar.tcl]]\n" |
138 | "set auto_index(tkScrollDrag) [list source [file join $dir scrlbar.tcl]]\n" |
138 | "set auto_index(tkScrollButtonUp) [list source [file join $dir scrlbar.tcl]]\n" |
139 | "set auto_index(tkScrollEndDrag) [list source [file join $dir scrlbar.tcl]]\n" |
139 | "set auto_index(tkScrollSelect) [list source [file join $dir scrlbar.tcl]]\n" |
140 | "set auto_index(tkScrollByUnits) [list source [file join $dir scrlbar.tcl]]\n" |
140 | "set auto_index(tkScrollStartDrag) [list source [file join $dir scrlbar.tcl]]\n" |
141 | "set auto_index(tkScrollByPages) [list source [file join $dir scrlbar.tcl]]\n" |
141 | "set auto_index(tkScrollDrag) [list source [file join $dir scrlbar.tcl]]\n" |
142 | "set auto_index(tkScrollToPos) [list source [file join $dir scrlbar.tcl]]\n" |
142 | "set auto_index(tkScrollEndDrag) [list source [file join $dir scrlbar.tcl]]\n" |
143 | "set auto_index(tkScrollTopBottom) [list source [file join $dir scrlbar.tcl]]\n" |
143 | "set auto_index(tkScrollByUnits) [list source [file join $dir scrlbar.tcl]]\n" |
144 | "set auto_index(tkScrollButton2Down) [list source [file join $dir scrlbar.tcl]]\n" |
144 | "set auto_index(tkScrollByPages) [list source [file join $dir scrlbar.tcl]]\n" |
145 | "set auto_index(tkTextClosestGap) [list source [file join $dir text.tcl]]\n" |
145 | "set auto_index(tkScrollToPos) [list source [file join $dir scrlbar.tcl]]\n" |
146 | "set auto_index(tkTextButton1) [list source [file join $dir text.tcl]]\n" |
146 | "set auto_index(tkScrollTopBottom) [list source [file join $dir scrlbar.tcl]]\n" |
147 | "set auto_index(tkTextSelectTo) [list source [file join $dir text.tcl]]\n" |
147 | "set auto_index(tkScrollButton2Down) [list source [file join $dir scrlbar.tcl]]\n" |
148 | "set auto_index(tkTextKeyExtend) [list source [file join $dir text.tcl]]\n" |
148 | "set auto_index(tkTextClosestGap) [list source [file join $dir text.tcl]]\n" |
149 | "set auto_index(tkTextPaste) [list source [file join $dir text.tcl]]\n" |
149 | "set auto_index(tkTextButton1) [list source [file join $dir text.tcl]]\n" |
150 | "set auto_index(tkTextAutoScan) [list source [file join $dir text.tcl]]\n" |
150 | "set auto_index(tkTextSelectTo) [list source [file join $dir text.tcl]]\n" |
151 | "set auto_index(tkTextSetCursor) [list source [file join $dir text.tcl]]\n" |
151 | "set auto_index(tkTextKeyExtend) [list source [file join $dir text.tcl]]\n" |
152 | "set auto_index(tkTextKeySelect) [list source [file join $dir text.tcl]]\n" |
152 | "set auto_index(tkTextPaste) [list source [file join $dir text.tcl]]\n" |
153 | "set auto_index(tkTextResetAnchor) [list source [file join $dir text.tcl]]\n" |
153 | "set auto_index(tkTextAutoScan) [list source [file join $dir text.tcl]]\n" |
154 | "set auto_index(tkTextInsert) [list source [file join $dir text.tcl]]\n" |
154 | "set auto_index(tkTextSetCursor) [list source [file join $dir text.tcl]]\n" |
155 | "set auto_index(tkTextUpDownLine) [list source [file join $dir text.tcl]]\n" |
155 | "set auto_index(tkTextKeySelect) [list source [file join $dir text.tcl]]\n" |
156 | "set auto_index(tkTextPrevPara) [list source [file join $dir text.tcl]]\n" |
156 | "set auto_index(tkTextResetAnchor) [list source [file join $dir text.tcl]]\n" |
157 | "set auto_index(tkTextNextPara) [list source [file join $dir text.tcl]]\n" |
157 | "set auto_index(tkTextInsert) [list source [file join $dir text.tcl]]\n" |
158 | "set auto_index(tkTextScrollPages) [list source [file join $dir text.tcl]]\n" |
158 | "set auto_index(tkTextUpDownLine) [list source [file join $dir text.tcl]]\n" |
159 | "set auto_index(tkTextTranspose) [list source [file join $dir text.tcl]]\n" |
159 | "set auto_index(tkTextPrevPara) [list source [file join $dir text.tcl]]\n" |
160 | "set auto_index(tk_textCopy) [list source [file join $dir text.tcl]]\n" |
160 | "set auto_index(tkTextNextPara) [list source [file join $dir text.tcl]]\n" |
161 | "set auto_index(tk_textCut) [list source [file join $dir text.tcl]]\n" |
161 | "set auto_index(tkTextScrollPages) [list source [file join $dir text.tcl]]\n" |
162 | "set auto_index(tk_textPaste) [list source [file join $dir text.tcl]]\n" |
162 | "set auto_index(tkTextTranspose) [list source [file join $dir text.tcl]]\n" |
163 | "set auto_index(tkTextNextPos) [list source [file join $dir text.tcl]]\n" |
163 | "set auto_index(tk_textCopy) [list source [file join $dir text.tcl]]\n" |
164 | "set auto_index(tkTextPrevPos) [list source [file join $dir text.tcl]]\n" |
164 | "set auto_index(tk_textCut) [list source [file join $dir text.tcl]]\n" |
165 | "set auto_index(tkScreenChanged) [list source [file join $dir tk.tcl]]\n" |
165 | "set auto_index(tk_textPaste) [list source [file join $dir text.tcl]]\n" |
166 | "set auto_index(tkEventMotifBindings) [list source [file join $dir tk.tcl]]\n" |
166 | "set auto_index(tkTextNextPos) [list source [file join $dir text.tcl]]\n" |
167 | "set auto_index(tkCancelRepeat) [list source [file join $dir tk.tcl]]\n" |
167 | "set auto_index(tkTextPrevPos) [list source [file join $dir text.tcl]]\n" |
168 | "set auto_index(tkTabToWindow) [list source [file join $dir tk.tcl]]\n" |
168 | "set auto_index(tkScreenChanged) [list source [file join $dir tk.tcl]]\n" |
169 | "set auto_index(bgerror) [list source [file join $dir bgerror.tcl]]\n" |
169 | "set auto_index(tkEventMotifBindings) [list source [file join $dir tk.tcl]]\n" |
170 | "set auto_index(tkScaleActivate) [list source [file join $dir scale.tcl]]\n" |
170 | "set auto_index(tkCancelRepeat) [list source [file join $dir tk.tcl]]\n" |
171 | "set auto_index(tkScaleButtonDown) [list source [file join $dir scale.tcl]]\n" |
171 | "set auto_index(tkTabToWindow) [list source [file join $dir tk.tcl]]\n" |
172 | "set auto_index(tkScaleDrag) [list source [file join $dir scale.tcl]]\n" |
172 | "set auto_index(bgerror) [list source [file join $dir bgerror.tcl]]\n" |
173 | "set auto_index(tkScaleEndDrag) [list source [file join $dir scale.tcl]]\n" |
173 | "set auto_index(tkScaleActivate) [list source [file join $dir scale.tcl]]\n" |
174 | "set auto_index(tkScaleIncrement) [list source [file join $dir scale.tcl]]\n" |
174 | "set auto_index(tkScaleButtonDown) [list source [file join $dir scale.tcl]]\n" |
175 | "set auto_index(tkScaleControlPress) [list source [file join $dir scale.tcl]]\n" |
175 | "set auto_index(tkScaleDrag) [list source [file join $dir scale.tcl]]\n" |
176 | "set auto_index(tkScaleButton2Down) [list source [file join $dir scale.tcl]]\n" |
176 | "set auto_index(tkScaleEndDrag) [list source [file join $dir scale.tcl]]\n" |
177 | "set auto_index(tk_optionMenu) [list source [file join $dir optMenu.tcl]]\n" |
177 | "set auto_index(tkScaleIncrement) [list source [file join $dir scale.tcl]]\n" |
178 | "set auto_index(tkTearOffMenu) [list source [file join $dir tearoff.tcl]]\n" |
178 | "set auto_index(tkScaleControlPress) [list source [file join $dir scale.tcl]]\n" |
179 | "set auto_index(tkMenuDup) [list source [file join $dir tearoff.tcl]]\n" |
179 | "set auto_index(tkScaleButton2Down) [list source [file join $dir scale.tcl]]\n" |
180 | "set auto_index(tk_menuBar) [list source [file join $dir obsolete.tcl]]\n" |
180 | "set auto_index(tk_optionMenu) [list source [file join $dir optMenu.tcl]]\n" |
181 | "set auto_index(tk_bindForTraversal) [list source [file join $dir obsolete.tcl]]\n" |
181 | "set auto_index(tkTearOffMenu) [list source [file join $dir tearoff.tcl]]\n" |
182 | "set auto_index(tk_focusNext) [list source [file join $dir focus.tcl]]\n" |
182 | "set auto_index(tkMenuDup) [list source [file join $dir tearoff.tcl]]\n" |
183 | "set auto_index(tk_focusPrev) [list source [file join $dir focus.tcl]]\n" |
183 | "set auto_index(tk_menuBar) [list source [file join $dir obsolete.tcl]]\n" |
184 | "set auto_index(tkFocusOK) [list source [file join $dir focus.tcl]]\n" |
184 | "set auto_index(tk_bindForTraversal) [list source [file join $dir obsolete.tcl]]\n" |
185 | "set auto_index(tk_focusFollowsMouse) [list source [file join $dir focus.tcl]]\n" |
185 | "set auto_index(tk_focusNext) [list source [file join $dir focus.tcl]]\n" |
186 | "set auto_index(tkConsoleInit) [list source [file join $dir console.tcl]]\n" |
186 | "set auto_index(tk_focusPrev) [list source [file join $dir focus.tcl]]\n" |
187 | "set auto_index(tkConsoleSource) [list source [file join $dir console.tcl]]\n" |
187 | "set auto_index(tkFocusOK) [list source [file join $dir focus.tcl]]\n" |
188 | "set auto_index(tkConsoleInvoke) [list source [file join $dir console.tcl]]\n" |
188 | "set auto_index(tk_focusFollowsMouse) [list source [file join $dir focus.tcl]]\n" |
189 | "set auto_index(tkConsoleHistory) [list source [file join $dir console.tcl]]\n" |
189 | "set auto_index(tkConsoleInit) [list source [file join $dir console.tcl]]\n" |
190 | "set auto_index(tkConsolePrompt) [list source [file join $dir console.tcl]]\n" |
190 | "set auto_index(tkConsoleSource) [list source [file join $dir console.tcl]]\n" |
191 | "set auto_index(tkConsoleBind) [list source [file join $dir console.tcl]]\n" |
191 | "set auto_index(tkConsoleInvoke) [list source [file join $dir console.tcl]]\n" |
192 | "set auto_index(tkConsoleInsert) [list source [file join $dir console.tcl]]\n" |
192 | "set auto_index(tkConsoleHistory) [list source [file join $dir console.tcl]]\n" |
193 | "set auto_index(tkConsoleOutput) [list source [file join $dir console.tcl]]\n" |
193 | "set auto_index(tkConsolePrompt) [list source [file join $dir console.tcl]]\n" |
194 | "set auto_index(tkConsoleExit) [list source [file join $dir console.tcl]]\n" |
194 | "set auto_index(tkConsoleBind) [list source [file join $dir console.tcl]]\n" |
195 | "set auto_index(tkConsoleAbout) [list source [file join $dir console.tcl]]\n" |
195 | "set auto_index(tkConsoleInsert) [list source [file join $dir console.tcl]]\n" |
196 | "set auto_index(tk_setPalette) [list source [file join $dir palette.tcl]]\n" |
196 | "set auto_index(tkConsoleOutput) [list source [file join $dir console.tcl]]\n" |
197 | "set auto_index(tkRecolorTree) [list source [file join $dir palette.tcl]]\n" |
197 | "set auto_index(tkConsoleExit) [list source [file join $dir console.tcl]]\n" |
198 | "set auto_index(tkDarken) [list source [file join $dir palette.tcl]]\n" |
198 | "set auto_index(tkConsoleAbout) [list source [file join $dir console.tcl]]\n" |
199 | "set auto_index(tk_bisque) [list source [file join $dir palette.tcl]]\n" |
199 | "set auto_index(tk_setPalette) [list source [file join $dir palette.tcl]]\n" |
200 | "set auto_index(tkColorDialog) [list source [file join $dir clrpick.tcl]]\n" |
200 | "set auto_index(tkRecolorTree) [list source [file join $dir palette.tcl]]\n" |
201 | "set auto_index(tkColorDialog_InitValues) [list source [file join $dir clrpick.tcl]]\n" |
201 | "set auto_index(tkDarken) [list source [file join $dir palette.tcl]]\n" |
202 | "set auto_index(tkColorDialog_Config) [list source [file join $dir clrpick.tcl]]\n" |
202 | "set auto_index(tk_bisque) [list source [file join $dir palette.tcl]]\n" |
203 | "set auto_index(tkColorDialog_BuildDialog) [list source [file join $dir clrpick.tcl]]\n" |
203 | "set auto_index(tkColorDialog) [list source [file join $dir clrpick.tcl]]\n" |
204 | "set auto_index(tkColorDialog_SetRGBValue) [list source [file join $dir clrpick.tcl]]\n" |
204 | "set auto_index(tkColorDialog_InitValues) [list source [file join $dir clrpick.tcl]]\n" |
205 | "set auto_index(tkColorDialog_XToRgb) [list source [file join $dir clrpick.tcl]]\n" |
205 | "set auto_index(tkColorDialog_Config) [list source [file join $dir clrpick.tcl]]\n" |
206 | "set auto_index(tkColorDialog_RgbToX) [list source [file join $dir clrpick.tcl]]\n" |
206 | "set auto_index(tkColorDialog_BuildDialog) [list source [file join $dir clrpick.tcl]]\n" |
207 | "set auto_index(tkColorDialog_DrawColorScale) [list source [file join $dir clrpick.tcl]]\n" |
207 | "set auto_index(tkColorDialog_SetRGBValue) [list source [file join $dir clrpick.tcl]]\n" |
208 | "set auto_index(tkColorDialog_CreateSelector) [list source [file join $dir clrpick.tcl]]\n" |
208 | "set auto_index(tkColorDialog_XToRgb) [list source [file join $dir clrpick.tcl]]\n" |
209 | "set auto_index(tkColorDialog_RedrawFinalColor) [list source [file join $dir " |
209 | "set auto_index(tkColorDialog_RgbToX) [list source [file join $dir clrpick.tcl]]\n" |
210 | "clrpick.tcl]]\n" |
210 | "set auto_index(tkColorDialog_DrawColorScale) [list source [file join $dir clrpick.tcl]]\n" |
211 | "set auto_index(tkColorDialog_RedrawColorBars) [list source [file join $dir " |
211 | "set auto_index(tkColorDialog_CreateSelector) [list source [file join $dir clrpick.tcl]]\n" |
212 | "clrpick.tcl]]\n" |
212 | "set auto_index(tkColorDialog_RedrawFinalColor) [list source [file join $dir clrpick.tcl]]\n" |
213 | "set auto_index(tkColorDialog_StartMove) [list source [file join $dir clrpick.tcl]]\n" |
213 | "set auto_index(tkColorDialog_RedrawColorBars) [list source [file join $dir clrpick.tcl]]\n" |
214 | "set auto_index(tkColorDialog_MoveSelector) [list source [file join $dir clrpick.tcl]]\n" |
214 | "set auto_index(tkColorDialog_StartMove) [list source [file join $dir clrpick.tcl]]\n" |
215 | "set auto_index(tkColorDialog_ReleaseMouse) [list source [file join $dir clrpick.tcl]]\n" |
215 | "set auto_index(tkColorDialog_MoveSelector) [list source [file join $dir clrpick.tcl]]\n" |
216 | "set auto_index(tkColorDialog_ResizeColorBars) [list source [file join $dir " |
216 | "set auto_index(tkColorDialog_ReleaseMouse) [list source [file join $dir clrpick.tcl]]\n" |
217 | "clrpick.tcl]]\n" |
217 | "set auto_index(tkColorDialog_ResizeColorBars) [list source [file join $dir clrpick.tcl]]\n" |
218 | "set auto_index(tkColorDialog_HandleSelEntry) [list source [file join $dir clrpick.tcl]]\n" |
218 | "set auto_index(tkColorDialog_HandleSelEntry) [list source [file join $dir clrpick.tcl]]\n" |
219 | "set auto_index(tkColorDialog_HandleRGBEntry) [list source [file join $dir clrpick.tcl]]\n" |
219 | "set auto_index(tkColorDialog_HandleRGBEntry) [list source [file join $dir clrpick.tcl]]\n" |
220 | "set auto_index(tkColorDialog_EnterColorBar) [list source [file join $dir clrpick.tcl]]\n" |
220 | "set auto_index(tkColorDialog_EnterColorBar) [list source [file join $dir clrpick.tcl]]\n" |
221 | "set auto_index(tkColorDialog_LeaveColorBar) [list source [file join $dir clrpick.tcl]]\n" |
221 | "set auto_index(tkColorDialog_LeaveColorBar) [list source [file join $dir clrpick.tcl]]\n" |
222 | "set auto_index(tkColorDialog_OkCmd) [list source [file join $dir clrpick.tcl]]\n" |
222 | "set auto_index(tkColorDialog_OkCmd) [list source [file join $dir clrpick.tcl]]\n" |
223 | "set auto_index(tkColorDialog_CancelCmd) [list source [file join $dir clrpick.tcl]]\n" |
223 | "set auto_index(tkColorDialog_CancelCmd) [list source [file join $dir clrpick.tcl]]\n" |
224 | "set auto_index(tclParseConfigSpec) [list source [file join $dir comdlg.tcl]]\n" |
224 | "set auto_index(tclParseConfigSpec) [list source [file join $dir comdlg.tcl]]\n" |
225 | "set auto_index(tclListValidFlags) [list source [file join $dir comdlg.tcl]]\n" |
225 | "set auto_index(tclListValidFlags) [list source [file join $dir comdlg.tcl]]\n" |
226 | "set auto_index(tclSortNoCase) [list source [file join $dir comdlg.tcl]]\n" |
226 | "set auto_index(tclSortNoCase) [list source [file join $dir comdlg.tcl]]\n" |
227 | "set auto_index(tclVerifyInteger) [list source [file join $dir comdlg.tcl]]\n" |
227 | "set auto_index(tclVerifyInteger) [list source [file join $dir comdlg.tcl]]\n" |
228 | "set auto_index(tkFocusGroup_Create) [list source [file join $dir comdlg.tcl]]\n" |
228 | "set auto_index(tkFocusGroup_Create) [list source [file join $dir comdlg.tcl]]\n" |
229 | "set auto_index(tkFocusGroup_BindIn) [list source [file join $dir comdlg.tcl]]\n" |
229 | "set auto_index(tkFocusGroup_BindIn) [list source [file join $dir comdlg.tcl]]\n" |
230 | "set auto_index(tkFocusGroup_BindOut) [list source [file join $dir comdlg.tcl]]\n" |
230 | "set auto_index(tkFocusGroup_BindOut) [list source [file join $dir comdlg.tcl]]\n" |
231 | "set auto_index(tkFocusGroup_Destroy) [list source [file join $dir comdlg.tcl]]\n" |
231 | "set auto_index(tkFocusGroup_Destroy) [list source [file join $dir comdlg.tcl]]\n" |
232 | "set auto_index(tkFocusGroup_In) [list source [file join $dir comdlg.tcl]]\n" |
232 | "set auto_index(tkFocusGroup_In) [list source [file join $dir comdlg.tcl]]\n" |
233 | "set auto_index(tkFocusGroup_Out) [list source [file join $dir comdlg.tcl]]\n" |
233 | "set auto_index(tkFocusGroup_Out) [list source [file join $dir comdlg.tcl]]\n" |
234 | "set auto_index(tkFDGetFileTypes) [list source [file join $dir comdlg.tcl]]\n" |
234 | "set auto_index(tkFDGetFileTypes) [list source [file join $dir comdlg.tcl]]\n" |
235 | "set auto_index(::safe::loadTk) [list source [file join $dir safetk.tcl]]\n" |
235 | "set auto_index(::safe::loadTk) [list source [file join $dir safetk.tcl]]\n" |
236 | "set auto_index(::safe::TkInit) [list source [file join $dir safetk.tcl]]\n" |
236 | "set auto_index(::safe::TkInit) [list source [file join $dir safetk.tcl]]\n" |
237 | "set auto_index(::safe::allowTk) [list source [file join $dir safetk.tcl]]\n" |
237 | "set auto_index(::safe::allowTk) [list source [file join $dir safetk.tcl]]\n" |
238 | "set auto_index(::safe::tkTopLevel) [list source [file join $dir safetk.tcl]]\n" |
238 | "set auto_index(::safe::tkTopLevel) [list source [file join $dir safetk.tcl]]\n" |
239 | "set auto_index(tkMessageBox) [list source [file join $dir msgbox.tcl]]\n" |
239 | "set auto_index(tkMessageBox) [list source [file join $dir msgbox.tcl]]\n" |
240 | "set auto_index(tkIconList) [list source [file join $dir tkfbox.tcl]]\n" |
240 | "set auto_index(tkIconList) [list source [file join $dir tkfbox.tcl]]\n" |
241 | "set auto_index(tkIconList_Config) [list source [file join $dir tkfbox.tcl]]\n" |
241 | "set auto_index(tkIconList_Config) [list source [file join $dir tkfbox.tcl]]\n" |
242 | "set auto_index(tkIconList_Create) [list source [file join $dir tkfbox.tcl]]\n" |
242 | "set auto_index(tkIconList_Create) [list source [file join $dir tkfbox.tcl]]\n" |
243 | "set auto_index(tkIconList_AutoScan) [list source [file join $dir tkfbox.tcl]]\n" |
243 | "set auto_index(tkIconList_AutoScan) [list source [file join $dir tkfbox.tcl]]\n" |
244 | "set auto_index(tkIconList_DeleteAll) [list source [file join $dir tkfbox.tcl]]\n" |
244 | "set auto_index(tkIconList_DeleteAll) [list source [file join $dir tkfbox.tcl]]\n" |
245 | "set auto_index(tkIconList_Add) [list source [file join $dir tkfbox.tcl]]\n" |
245 | "set auto_index(tkIconList_Add) [list source [file join $dir tkfbox.tcl]]\n" |
246 | "set auto_index(tkIconList_Arrange) [list source [file join $dir tkfbox.tcl]]\n" |
246 | "set auto_index(tkIconList_Arrange) [list source [file join $dir tkfbox.tcl]]\n" |
247 | "set auto_index(tkIconList_Invoke) [list source [file join $dir tkfbox.tcl]]\n" |
247 | "set auto_index(tkIconList_Invoke) [list source [file join $dir tkfbox.tcl]]\n" |
248 | "set auto_index(tkIconList_See) [list source [file join $dir tkfbox.tcl]]\n" |
248 | "set auto_index(tkIconList_See) [list source [file join $dir tkfbox.tcl]]\n" |
249 | "set auto_index(tkIconList_SelectAtXY) [list source [file join $dir tkfbox.tcl]]\n" |
249 | "set auto_index(tkIconList_SelectAtXY) [list source [file join $dir tkfbox.tcl]]\n" |
250 | "set auto_index(tkIconList_Select) [list source [file join $dir tkfbox.tcl]]\n" |
250 | "set auto_index(tkIconList_Select) [list source [file join $dir tkfbox.tcl]]\n" |
251 | "set auto_index(tkIconList_Unselect) [list source [file join $dir tkfbox.tcl]]\n" |
251 | "set auto_index(tkIconList_Unselect) [list source [file join $dir tkfbox.tcl]]\n" |
252 | "set auto_index(tkIconList_Get) [list source [file join $dir tkfbox.tcl]]\n" |
252 | "set auto_index(tkIconList_Get) [list source [file join $dir tkfbox.tcl]]\n" |
253 | "set auto_index(tkIconList_Btn1) [list source [file join $dir tkfbox.tcl]]\n" |
253 | "set auto_index(tkIconList_Btn1) [list source [file join $dir tkfbox.tcl]]\n" |
254 | "set auto_index(tkIconList_Motion1) [list source [file join $dir tkfbox.tcl]]\n" |
254 | "set auto_index(tkIconList_Motion1) [list source [file join $dir tkfbox.tcl]]\n" |
255 | "set auto_index(tkIconList_Double1) [list source [file join $dir tkfbox.tcl]]\n" |
255 | "set auto_index(tkIconList_Double1) [list source [file join $dir tkfbox.tcl]]\n" |
256 | "set auto_index(tkIconList_ReturnKey) [list source [file join $dir tkfbox.tcl]]\n" |
256 | "set auto_index(tkIconList_ReturnKey) [list source [file join $dir tkfbox.tcl]]\n" |
257 | "set auto_index(tkIconList_Leave1) [list source [file join $dir tkfbox.tcl]]\n" |
257 | "set auto_index(tkIconList_Leave1) [list source [file join $dir tkfbox.tcl]]\n" |
258 | "set auto_index(tkIconList_FocusIn) [list source [file join $dir tkfbox.tcl]]\n" |
258 | "set auto_index(tkIconList_FocusIn) [list source [file join $dir tkfbox.tcl]]\n" |
259 | "set auto_index(tkIconList_UpDown) [list source [file join $dir tkfbox.tcl]]\n" |
259 | "set auto_index(tkIconList_UpDown) [list source [file join $dir tkfbox.tcl]]\n" |
260 | "set auto_index(tkIconList_LeftRight) [list source [file join $dir tkfbox.tcl]]\n" |
260 | "set auto_index(tkIconList_LeftRight) [list source [file join $dir tkfbox.tcl]]\n" |
261 | "set auto_index(tkIconList_KeyPress) [list source [file join $dir tkfbox.tcl]]\n" |
261 | "set auto_index(tkIconList_KeyPress) [list source [file join $dir tkfbox.tcl]]\n" |
262 | "set auto_index(tkIconList_Goto) [list source [file join $dir tkfbox.tcl]]\n" |
262 | "set auto_index(tkIconList_Goto) [list source [file join $dir tkfbox.tcl]]\n" |
263 | "set auto_index(tkIconList_Reset) [list source [file join $dir tkfbox.tcl]]\n" |
263 | "set auto_index(tkIconList_Reset) [list source [file join $dir tkfbox.tcl]]\n" |
264 | "set auto_index(tkFDialog) [list source [file join $dir tkfbox.tcl]]\n" |
264 | "set auto_index(tkFDialog) [list source [file join $dir tkfbox.tcl]]\n" |
265 | "set auto_index(tkFDialog_Config) [list source [file join $dir tkfbox.tcl]]\n" |
265 | "set auto_index(tkFDialog_Config) [list source [file join $dir tkfbox.tcl]]\n" |
266 | "set auto_index(tkFDialog_Create) [list source [file join $dir tkfbox.tcl]]\n" |
266 | "set auto_index(tkFDialog_Create) [list source [file join $dir tkfbox.tcl]]\n" |
267 | "set auto_index(tkFDialog_UpdateWhenIdle) [list source [file join $dir tkfbox.tcl]]\n" |
267 | "set auto_index(tkFDialog_UpdateWhenIdle) [list source [file join $dir tkfbox.tcl]]\n" |
268 | "set auto_index(tkFDialog_Update) [list source [file join $dir tkfbox.tcl]]\n" |
268 | "set auto_index(tkFDialog_Update) [list source [file join $dir tkfbox.tcl]]\n" |
269 | "set auto_index(tkFDialog_SetPathSilently) [list source [file join $dir tkfbox.tcl]]\n" |
269 | "set auto_index(tkFDialog_SetPathSilently) [list source [file join $dir tkfbox.tcl]]\n" |
270 | "set auto_index(tkFDialog_SetPath) [list source [file join $dir tkfbox.tcl]]\n" |
270 | "set auto_index(tkFDialog_SetPath) [list source [file join $dir tkfbox.tcl]]\n" |
271 | "set auto_index(tkFDialog_SetFilter) [list source [file join $dir tkfbox.tcl]]\n" |
271 | "set auto_index(tkFDialog_SetFilter) [list source [file join $dir tkfbox.tcl]]\n" |
272 | "set auto_index(tkFDialogResolveFile) [list source [file join $dir tkfbox.tcl]]\n" |
272 | "set auto_index(tkFDialogResolveFile) [list source [file join $dir tkfbox.tcl]]\n" |
273 | "set auto_index(tkFDialog_EntFocusIn) [list source [file join $dir tkfbox.tcl]]\n" |
273 | "set auto_index(tkFDialog_EntFocusIn) [list source [file join $dir tkfbox.tcl]]\n" |
274 | "set auto_index(tkFDialog_EntFocusOut) [list source [file join $dir tkfbox.tcl]]\n" |
274 | "set auto_index(tkFDialog_EntFocusOut) [list source [file join $dir tkfbox.tcl]]\n" |
275 | "set auto_index(tkFDialog_ActivateEnt) [list source [file join $dir tkfbox.tcl]]\n" |
275 | "set auto_index(tkFDialog_ActivateEnt) [list source [file join $dir tkfbox.tcl]]\n" |
276 | "set auto_index(tkFDialog_InvokeBtn) [list source [file join $dir tkfbox.tcl]]\n" |
276 | "set auto_index(tkFDialog_InvokeBtn) [list source [file join $dir tkfbox.tcl]]\n" |
277 | "set auto_index(tkFDialog_UpDirCmd) [list source [file join $dir tkfbox.tcl]]\n" |
277 | "set auto_index(tkFDialog_UpDirCmd) [list source [file join $dir tkfbox.tcl]]\n" |
278 | "set auto_index(tkFDialog_JoinFile) [list source [file join $dir tkfbox.tcl]]\n" |
278 | "set auto_index(tkFDialog_JoinFile) [list source [file join $dir tkfbox.tcl]]\n" |
279 | "set auto_index(tkFDialog_OkCmd) [list source [file join $dir tkfbox.tcl]]\n" |
279 | "set auto_index(tkFDialog_OkCmd) [list source [file join $dir tkfbox.tcl]]\n" |
280 | "set auto_index(tkFDialog_CancelCmd) [list source [file join $dir tkfbox.tcl]]\n" |
280 | "set auto_index(tkFDialog_CancelCmd) [list source [file join $dir tkfbox.tcl]]\n" |
281 | "set auto_index(tkFDialog_ListBrowse) [list source [file join $dir tkfbox.tcl]]\n" |
281 | "set auto_index(tkFDialog_ListBrowse) [list source [file join $dir tkfbox.tcl]]\n" |
282 | "set auto_index(tkFDialog_ListInvoke) [list source [file join $dir tkfbox.tcl]]\n" |
282 | "set auto_index(tkFDialog_ListInvoke) [list source [file join $dir tkfbox.tcl]]\n" |
283 | "set auto_index(tkFDialog_Done) [list source [file join $dir tkfbox.tcl]]\n" |
283 | "set auto_index(tkFDialog_Done) [list source [file join $dir tkfbox.tcl]]\n" |
284 | "set auto_index(tkMotifFDialog) [list source [file join $dir xmfbox.tcl]]\n" |
284 | "set auto_index(tkMotifFDialog) [list source [file join $dir xmfbox.tcl]]\n" |
285 | "set auto_index(tkMotifFDialog_Config) [list source [file join $dir xmfbox.tcl]]\n" |
285 | "set auto_index(tkMotifFDialog_Config) [list source [file join $dir xmfbox.tcl]]\n" |
286 | "set auto_index(tkMotifFDialog_Create) [list source [file join $dir xmfbox.tcl]]\n" |
286 | "set auto_index(tkMotifFDialog_Create) [list source [file join $dir xmfbox.tcl]]\n" |
287 | "set auto_index(tkMotifFDialog_MakeSList) [list source [file join $dir xmfbox.tcl]]\n" |
287 | "set auto_index(tkMotifFDialog_MakeSList) [list source [file join $dir xmfbox.tcl]]\n" |
288 | "set auto_index(tkMotifFDialog_BrowseDList) [list source [file join $dir xmfbox.tcl]]\n" |
288 | "set auto_index(tkMotifFDialog_BrowseDList) [list source [file join $dir xmfbox.tcl]]\n" |
289 | "set auto_index(tkMotifFDialog_ActivateDList) [list source [file join $dir xmfbox.tcl]]\n" |
289 | "set auto_index(tkMotifFDialog_ActivateDList) [list source [file join $dir xmfbox.tcl]]\n" |
290 | "set auto_index(tkMotifFDialog_BrowseFList) [list source [file join $dir xmfbox.tcl]]\n" |
290 | "set auto_index(tkMotifFDialog_BrowseFList) [list source [file join $dir xmfbox.tcl]]\n" |
291 | "set auto_index(tkMotifFDialog_ActivateFList) [list source [file join $dir xmfbox.tcl]]\n" |
291 | "set auto_index(tkMotifFDialog_ActivateFList) [list source [file join $dir xmfbox.tcl]]\n" |
292 | "set auto_index(tkMotifFDialog_ActivateFEnt) [list source [file join $dir xmfbox.tcl]]\n" |
292 | "set auto_index(tkMotifFDialog_ActivateFEnt) [list source [file join $dir xmfbox.tcl]]\n" |
293 | "set auto_index(tkMotifFDialog_InterpFilter) [list source [file join $dir xmfbox.tcl]]\n" |
293 | "set auto_index(tkMotifFDialog_InterpFilter) [list source [file join $dir xmfbox.tcl]]\n" |
294 | "set auto_index(tkMotifFDialog_ActivateSEnt) [list source [file join $dir xmfbox.tcl]]\n" |
294 | "set auto_index(tkMotifFDialog_ActivateSEnt) [list source [file join $dir xmfbox.tcl]]\n" |
295 | "set auto_index(tkMotifFDialog_OkCmd) [list source [file join $dir xmfbox.tcl]]\n" |
295 | "set auto_index(tkMotifFDialog_OkCmd) [list source [file join $dir xmfbox.tcl]]\n" |
296 | "set auto_index(tkMotifFDialog_FilterCmd) [list source [file join $dir xmfbox.tcl]]\n" |
296 | "set auto_index(tkMotifFDialog_FilterCmd) [list source [file join $dir xmfbox.tcl]]\n" |
297 | "set auto_index(tkMotifFDialog_CancelCmd) [list source [file join $dir xmfbox.tcl]]\n" |
297 | "set auto_index(tkMotifFDialog_CancelCmd) [list source [file join $dir xmfbox.tcl]]\n" |
298 | "set auto_index(tkMotifFDialog_Update) [list source [file join $dir xmfbox.tcl]]\n" |
298 | "set auto_index(tkMotifFDialog_Update) [list source [file join $dir xmfbox.tcl]]\n" |
299 | "set auto_index(tkMotifFDialog_LoadFiles) [list source [file join $dir xmfbox.tcl]]\n" |
299 | "set auto_index(tkMotifFDialog_LoadFiles) [list source [file join $dir xmfbox.tcl]]\n" |
300 | "set auto_index(tkListBoxKeyAccel_Set) [list source [file join $dir xmfbox.tcl]]\n" |
300 | "set auto_index(tkListBoxKeyAccel_Set) [list source [file join $dir xmfbox.tcl]]\n" |
301 | "set auto_index(tkListBoxKeyAccel_Unset) [list source [file join $dir xmfbox.tcl]]\n" |
301 | "set auto_index(tkListBoxKeyAccel_Unset) [list source [file join $dir xmfbox.tcl]]\n" |
302 | "set auto_index(tkListBoxKeyAccel_Key) [list source [file join $dir xmfbox.tcl]]\n" |
302 | "set auto_index(tkListBoxKeyAccel_Key) [list source [file join $dir xmfbox.tcl]]\n" |
303 | "set auto_index(tkListBoxKeyAccel_Goto) [list source [file join $dir xmfbox.tcl]]\n" |
303 | "set auto_index(tkListBoxKeyAccel_Goto) [list source [file join $dir xmfbox.tcl]]\n" |
304 | "set auto_index(tkListBoxKeyAccel_Reset) [list source [file join $dir xmfbox.tcl]]\n"; |
304 | "set auto_index(tkListBoxKeyAccel_Reset) [list source [file join $dir xmfbox.tcl]]\n" |
305 | struct EtFile |
305 | ; |
306 | { |
306 | struct EtFile { |
307 | char *zName; |
307 | char *zName; |
308 | char *zData; |
308 | char *zData; |
309 | int nData; |
309 | int nData; |
310 | int shrouded; |
310 | int shrouded; |
311 | struct EtFile *pNext; |
311 | struct EtFile *pNext; |
312 | }; |
312 | }; |
313 | static struct EtFile Et_FileSet[] = { |
313 | static struct EtFile Et_FileSet[] = { |
314 | {"C:/cygwin/usr/share/tcl8.0/tclIndex", Et_zFile0, sizeof (Et_zFile0) - 1, 0, 0}, |
314 | { "C:/cygwin/usr/share/tcl8.0/tclIndex", Et_zFile0, sizeof(Et_zFile0)-1, 0, 0 }, |
315 | {"C:/cygwin/usr/share/tk8.0/tclIndex", Et_zFile1, sizeof (Et_zFile1) - 1, 0, 0}, |
315 | { "C:/cygwin/usr/share/tk8.0/tclIndex", Et_zFile1, sizeof(Et_zFile1)-1, 0, 0 }, |
316 | {0, 0}}; |
316 | {0, 0}}; |
317 | static struct EtFile *Et_FileHashTable[71]; |
317 | static struct EtFile *Et_FileHashTable[71]; |
318 | /* The following copyright notice applies to code generated by |
318 | /* The following copyright notice applies to code generated by |
319 | ** "mktclapp". The "mktclapp" program itself is covered by the |
319 | ** "mktclapp". The "mktclapp" program itself is covered by the |
320 | ** GNU Public License. |
320 | ** GNU Public License. |
321 | ** |
321 | ** |
Line 332... | Line 332... | ||
332 | ** they apply. |
332 | ** they apply. |
333 | ** |
333 | ** |
334 | ** In no event shall the author or the distributors be liable to any party |
334 | ** In no event shall the author or the distributors be liable to any party |
335 | ** for direct, indirect, special, incidental, or consequential damages |
335 | ** for direct, indirect, special, incidental, or consequential damages |
336 | ** arising out of the use of this software, its documentation, or any |
336 | ** arising out of the use of this software, its documentation, or any |
337 | ** derivatives thereof, even if the author has been advised of the |
337 | ** derivatives thereof, even if the author has been advised of the |
338 | ** possibility of such damage. The author and distributors specifically |
338 | ** possibility of such damage. The author and distributors specifically |
339 | ** disclaim any warranties, including but not limited to the implied |
339 | ** disclaim any warranties, including but not limited to the implied |
340 | ** warranties of merchantability, fitness for a particular purpose, and |
340 | ** warranties of merchantability, fitness for a particular purpose, and |
341 | ** non-infringment. This software is provided at no fee on an |
341 | ** non-infringment. This software is provided at no fee on an |
342 | ** "as is" basis. The author and/or distritutors have no obligation |
342 | ** "as is" basis. The author and/or distritutors have no obligation |
343 | ** to provide maintenance, support, updates, enhancements and/or |
343 | ** to provide maintenance, support, updates, enhancements and/or |
344 | ** modifications. |
344 | ** modifications. |
345 | ** |
345 | ** |
346 | ** GOVERNMENT USE: If you are acquiring this software on behalf of the |
346 | ** GOVERNMENT USE: If you are acquiring this software on behalf of the |
347 | ** U.S. government, the Government shall have only "Restricted Rights" |
347 | ** U.S. government, the Government shall have only "Restricted Rights" |
348 | ** in the software and related documentation as defined in the Federal |
348 | ** in the software and related documentation as defined in the Federal |
349 | ** Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you |
349 | ** Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you |
350 | ** are acquiring the software on behalf of the Department of Defense, the |
350 | ** are acquiring the software on behalf of the Department of Defense, the |
351 | ** software shall be classified as "Commercial Computer Software" and the |
351 | ** software shall be classified as "Commercial Computer Software" and the |
352 | ** Government shall have only "Restricted Rights" as defined in Clause |
352 | ** Government shall have only "Restricted Rights" as defined in Clause |
353 | ** 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the |
353 | ** 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the |
354 | ** author grants the U.S. Government and others acting in its behalf |
354 | ** author grants the U.S. Government and others acting in its behalf |
355 | ** permission to use and distribute the software in accordance with the |
355 | ** permission to use and distribute the software in accordance with the |
356 | ** terms specified in this license. |
356 | ** terms specified in this license. |
357 | */ |
357 | */ |
358 | #include <ctype.h> |
358 | #include <ctype.h> |
359 | #include <fcntl.h> |
359 | #include <string.h> |
360 | #include <stdarg.h> |
360 | #include <stdarg.h> |
361 | #include <stdio.h> |
361 | #include <stdio.h> |
362 | #include <stdlib.h> |
362 | #include <stdlib.h> |
363 | #include <string.h> |
- | |
364 | #include <sys/stat.h> |
- | |
365 | #include <sys/types.h> |
363 | #include <sys/types.h> |
- | 364 | #include <sys/stat.h> |
|
- | 365 | #include <fcntl.h> |
|
366 | 366 | ||
367 | /* Include either the Tcl or the Tk header file. Use the "Internal" |
367 | /* Include either the Tcl or the Tk header file. Use the "Internal" |
368 | ** version of the header file if and only if we are generating an |
368 | ** version of the header file if and only if we are generating an |
369 | ** extension that is linking against the Stub library. |
369 | ** extension that is linking against the Stub library. |
370 | ** Many installations do not have the internal header files |
370 | ** Many installations do not have the internal header files |
371 | ** available, so using the internal headers only when absolutely |
371 | ** available, so using the internal headers only when absolutely |
372 | ** necessary will help to reduce compilation problems. |
372 | ** necessary will help to reduce compilation problems. |
373 | */ |
373 | */ |
374 | #if ET_EXTENSION && defined(TCL_USE_STUBS) |
374 | #if ET_EXTENSION && defined(TCL_USE_STUBS) |
375 | #if ET_ENABLE_TK |
375 | # if ET_ENABLE_TK |
376 | #include <tkInt.h> |
376 | # include <tkInt.h> |
- | 377 | # else |
|
- | 378 | # include <tclInt.h> |
|
- | 379 | # endif |
|
377 | #else |
380 | #else |
378 | #include <tclInt.h> |
- | |
379 | #endif |
- | |
380 | #else |
- | |
381 | #if ET_ENABLE_TK |
381 | # if ET_ENABLE_TK |
382 | #include <tk.h> |
382 | # include <tk.h> |
383 | #else |
383 | # else |
384 | #include <tcl.h> |
384 | # include <tcl.h> |
385 | #endif |
385 | # endif |
386 | #endif |
386 | #endif |
387 | 387 | ||
388 | /* |
388 | /* |
389 | ** ET_WIN32 is true if we are running Tk under windows. The |
389 | ** ET_WIN32 is true if we are running Tk under windows. The |
390 | ** <tcl.h> module will define __WIN32__ for us if we are compiling |
390 | ** <tcl.h> module will define __WIN32__ for us if we are compiling |
391 | ** for windows. |
391 | ** for windows. |
392 | */ |
392 | */ |
393 | #if defined(__WIN32__) && ET_ENABLE_TK |
393 | #if defined(__WIN32__) && ET_ENABLE_TK |
394 | #define ET_WIN32 1 |
394 | # define ET_WIN32 1 |
395 | #include <windows.h> |
395 | # include <windows.h> |
396 | #else |
396 | #else |
397 | #define ET_WIN32 0 |
397 | # define ET_WIN32 0 |
398 | #endif |
398 | #endif |
399 | 399 | ||
400 | /* |
400 | /* |
401 | ** Always disable ET_AUTO_FORK under windows. Windows doesn't |
401 | ** Always disable ET_AUTO_FORK under windows. Windows doesn't |
402 | ** fork well. |
402 | ** fork well. |
403 | */ |
403 | */ |
404 | #if defined(__WIN32__) |
404 | #if defined(__WIN32__) |
405 | #undef ET_AUTO_FORK |
405 | # undef ET_AUTO_FORK |
406 | #define ET_AUTO_FORK 0 |
406 | # define ET_AUTO_FORK 0 |
407 | #endif |
407 | #endif |
408 | 408 | ||
409 | /* |
409 | /* |
410 | ** Omit <unistd.h> under windows. But we need it for Unix. |
410 | ** Omit <unistd.h> under windows. But we need it for Unix. |
411 | */ |
411 | */ |
412 | #if !defined(__WIN32__) |
412 | #if !defined(__WIN32__) |
413 | #include <unistd.h> |
413 | # include <unistd.h> |
414 | #endif |
414 | #endif |
415 | 415 | ||
416 | /* |
416 | /* |
417 | ** The Tcl*InsertProc functions allow the system calls "stat", |
417 | ** The Tcl*InsertProc functions allow the system calls "stat", |
418 | ** "access" and "open" to be overloaded. This in turns allows us |
418 | ** "access" and "open" to be overloaded. This in turns allows us |
Line 421... | Line 421... | ||
421 | ** and later. |
421 | ** and later. |
422 | ** |
422 | ** |
423 | ** Define the ET_HAVE_INSERTPROC macro if and only if we are dealing |
423 | ** Define the ET_HAVE_INSERTPROC macro if and only if we are dealing |
424 | ** with Tcl8.0.3 or later. |
424 | ** with Tcl8.0.3 or later. |
425 | */ |
425 | */ |
426 | #if TCL_MAJOR_VERSION == 8 && (TCL_MINOR_VERSION > 0 || TCL_RELEASE_SERIAL >= 3) |
426 | #if TCL_MAJOR_VERSION==8 && (TCL_MINOR_VERSION>0 || TCL_RELEASE_SERIAL>=3) |
427 | #define ET_HAVE_INSERTPROC |
427 | # define ET_HAVE_INSERTPROC |
428 | #endif |
428 | #endif |
429 | 429 | ||
430 | /* |
430 | /* |
431 | ** If we are using the Tcl*InsertProc() functions, we should provide |
431 | ** If we are using the Tcl*InsertProc() functions, we should provide |
432 | ** prototypes for them. But the prototypes are in the tclInt.h include |
432 | ** prototypes for them. But the prototypes are in the tclInt.h include |
433 | ** file, which we don't want to require the user to have on hand. So |
433 | ** file, which we don't want to require the user to have on hand. So |
434 | ** we provide our own prototypes here. |
434 | ** we provide our own prototypes here. |
435 | ** |
435 | ** |
436 | ** Note that if TCL_USE_STUBS is defined, then the tclInt.h is required |
436 | ** Note that if TCL_USE_STUBS is defined, then the tclInt.h is required |
437 | ** anyway, so these prototypes are not included if TCL_USE_STUBS is |
437 | ** anyway, so these prototypes are not included if TCL_USE_STUBS is |
438 | ** defined. |
438 | ** defined. |
439 | */ |
439 | */ |
440 | #if defined(ET_HAVE_INSERTPROC) && !defined(TCL_USE_STUBS) |
440 | #if defined(ET_HAVE_INSERTPROC) && !defined(TCL_USE_STUBS) |
441 | #ifdef __cplusplus |
441 | #ifdef __cplusplus |
442 | extern "C" int TclStatInsertProc (int (*) (char *, struct stat *)); |
442 | extern "C" int TclStatInsertProc(int (*)(char*, struct stat *)); |
443 | extern "C" int TclAccessInsertProc (int (*) (char *, int)); |
443 | extern "C" int TclAccessInsertProc(int (*)(char*, int)); |
444 | extern "C" int |
- | |
445 | TclOpenFileChannelInsertProc (Tcl_Channel (*) (Tcl_Interp *, char *, char *, int)); |
444 | extern "C" int TclOpenFileChannelInsertProc(Tcl_Channel (*)(Tcl_Interp*,char*, |
- | 445 | char*,int)); |
|
446 | #else |
446 | #else |
447 | extern int TclStatInsertProc (int (*) (char *, struct stat *)); |
447 | extern int TclStatInsertProc(int (*)(char*, struct stat *)); |
448 | extern int TclAccessInsertProc (int (*) (char *, int)); |
448 | extern int TclAccessInsertProc(int (*)(char*, int)); |
449 | extern int TclOpenFileChannelInsertProc (Tcl_Channel (*) (Tcl_Interp *, char *, char *, int)); |
449 | extern int TclOpenFileChannelInsertProc(Tcl_Channel (*)(Tcl_Interp*,char*, |
- | 450 | char*,int)); |
|
450 | #endif |
451 | #endif |
451 | #endif |
452 | #endif |
452 | 453 | ||
- | 454 | ||
453 | /* |
455 | /* |
454 | ** Don't allow Win32 applications to read from stdin. Nor |
456 | ** Don't allow Win32 applications to read from stdin. Nor |
455 | ** programs that automatically go into the background. Force |
457 | ** programs that automatically go into the background. Force |
456 | ** the use of a console in these cases. |
458 | ** the use of a console in these cases. |
457 | */ |
459 | */ |
458 | #if (ET_WIN32 || ET_AUTO_FORK) && ET_READ_STDIN |
460 | #if (ET_WIN32 || ET_AUTO_FORK) && ET_READ_STDIN |
459 | #undef ET_READ_STDIN |
461 | # undef ET_READ_STDIN |
460 | #undef ET_CONSOLE |
462 | # undef ET_CONSOLE |
461 | #define ET_READ_STDIN 0 |
463 | # define ET_READ_STDIN 0 |
462 | #define ET_CONSOLE 1 |
464 | # define ET_CONSOLE 1 |
463 | #endif |
465 | #endif |
464 | 466 | ||
465 | /* |
467 | /* |
466 | ** The console won't work without Tk. |
468 | ** The console won't work without Tk. |
467 | */ |
469 | */ |
468 | #if ET_ENABLE_TK == 0 && ET_CONSOLE |
470 | #if ET_ENABLE_TK==0 && ET_CONSOLE |
469 | #undef ET_CONSOLE |
471 | # undef ET_CONSOLE |
470 | #define ET_CONSOLE 0 |
472 | # define ET_CONSOLE 0 |
471 | #undef ET_READ_STDIN |
473 | # undef ET_READ_STDIN |
472 | #define ET_READ_STDIN 1 |
474 | # define ET_READ_STDIN 1 |
473 | #endif |
475 | #endif |
474 | 476 | ||
475 | /* |
477 | /* |
476 | ** Set ET_HAVE_OBJ to true if we are able to link against the |
478 | ** Set ET_HAVE_OBJ to true if we are able to link against the |
477 | ** new Tcl_Obj interface. This is only the case for Tcl version |
479 | ** new Tcl_Obj interface. This is only the case for Tcl version |
478 | ** 8.0 and later. |
480 | ** 8.0 and later. |
479 | */ |
481 | */ |
480 | #if ET_ENABLE_OBJ || TCL_MAJOR_VERSION >= 8 |
482 | #if ET_ENABLE_OBJ || TCL_MAJOR_VERSION>=8 |
481 | #define ET_HAVE_OBJ 1 |
483 | # define ET_HAVE_OBJ 1 |
482 | #else |
484 | #else |
483 | #define ET_HAVE_OBJ 0 |
485 | # define ET_HAVE_OBJ 0 |
484 | #endif |
486 | #endif |
485 | 487 | ||
486 | /* |
488 | /* |
487 | ** The Tcl_GetByteArrayFromObj() only appears in Tcl version 8.1 |
489 | ** The Tcl_GetByteArrayFromObj() only appears in Tcl version 8.1 |
488 | ** and later. Substitute Tcl_GetStringFromObj() in Tcl version 8.0.X |
490 | ** and later. Substitute Tcl_GetStringFromObj() in Tcl version 8.0.X |
489 | */ |
491 | */ |
490 | #if ET_HAVE_OBJ && TCL_MINOR_VERSION == 0 |
492 | #if ET_HAVE_OBJ && TCL_MINOR_VERSION==0 |
491 | #define Tcl_GetByteArrayFromObj Tcl_GetStringFromObj |
493 | # define Tcl_GetByteArrayFromObj Tcl_GetStringFromObj |
492 | #endif |
494 | #endif |
493 | 495 | ||
494 | /* |
496 | /* |
495 | ** Tcl code to implement the console. |
497 | ** Tcl code to implement the console. |
496 | ** |
498 | ** |
497 | ** This code is written and tested separately, then run through |
499 | ** This code is written and tested separately, then run through |
498 | ** "mktclapp -stringify" and then pasted in here. |
500 | ** "mktclapp -stringify" and then pasted in here. |
499 | */ |
501 | */ |
500 | #if ET_ENABLE_TK && !ET_EXTENSION |
502 | #if ET_ENABLE_TK && !ET_EXTENSION |
501 | static char zEtConsole[] = |
503 | static char zEtConsole[] = |
502 | "proc console:create {w prompt title} {\n" |
504 | "proc console:create {w prompt title} {\n" |
503 | "upvar #0 $w.t v\n" |
505 | "upvar #0 $w.t v\n" |
504 | "if {[winfo exists $w]} {destroy $w}\n" |
506 | "if {[winfo exists $w]} {destroy $w}\n" |
505 | "catch {unset v}\n" |
507 | "catch {unset v}\n" |
506 | "toplevel $w\n" |
508 | "toplevel $w\n" |
507 | "wm title $w $title\n" |
509 | "wm title $w $title\n" |
508 | "wm iconname $w $title\n" |
510 | "wm iconname $w $title\n" |
509 | "frame $w.mb -bd 2 -relief raised\n" |
511 | "frame $w.mb -bd 2 -relief raised\n" |
510 | "pack $w.mb -side top -fill x\n" |
512 | "pack $w.mb -side top -fill x\n" |
511 | "menubutton $w.mb.file -text File -menu $w.mb.file.m\n" |
513 | "menubutton $w.mb.file -text File -menu $w.mb.file.m\n" |
512 | "menubutton $w.mb.edit -text Edit -menu $w.mb.edit.m\n" |
514 | "menubutton $w.mb.edit -text Edit -menu $w.mb.edit.m\n" |
513 | "pack $w.mb.file $w.mb.edit -side left -padx 8 -pady 1\n" |
515 | "pack $w.mb.file $w.mb.edit -side left -padx 8 -pady 1\n" |
514 | "set m [menu $w.mb.file.m]\n" |
516 | "set m [menu $w.mb.file.m]\n" |
515 | "$m add command -label {Source...} -command \"console:SourceFile $w.t\"\n" |
517 | "$m add command -label {Source...} -command \"console:SourceFile $w.t\"\n" |
516 | "$m add command -label {Save As...} -command \"console:SaveFile $w.t\"\n" |
518 | "$m add command -label {Save As...} -command \"console:SaveFile $w.t\"\n" |
517 | "$m add separator\n" |
519 | "$m add separator\n" |
518 | "$m add command -label {Close} -command \"destroy $w\"\n" |
520 | "$m add command -label {Close} -command \"destroy $w\"\n" |
519 | "$m add command -label {Exit} -command exit\n" |
521 | "$m add command -label {Exit} -command exit\n" |
520 | "set m [menu $w.mb.edit.m]\n" |
522 | "set m [menu $w.mb.edit.m]\n" |
521 | "$m add command -label Cut -command \"console:Cut $w.t\"\n" |
523 | "$m add command -label Cut -command \"console:Cut $w.t\"\n" |
522 | "$m add command -label Copy -command \"console:Copy $w.t\"\n" |
524 | "$m add command -label Copy -command \"console:Copy $w.t\"\n" |
523 | "$m add command -label Paste -command \"console:Paste $w.t\"\n" |
525 | "$m add command -label Paste -command \"console:Paste $w.t\"\n" |
524 | "$m add command -label {Clear Screen} -command \"console:Clear $w.t\"\n" |
526 | "$m add command -label {Clear Screen} -command \"console:Clear $w.t\"\n" |
525 | "catch {$m config -postcommand \"console:EnableEditMenu $w\"}\n" |
527 | "catch {$m config -postcommand \"console:EnableEditMenu $w\"}\n" |
526 | "scrollbar $w.sb -orient vertical -command \"$w.t yview\"\n" |
528 | "scrollbar $w.sb -orient vertical -command \"$w.t yview\"\n" |
527 | "pack $w.sb -side right -fill y\n" |
529 | "pack $w.sb -side right -fill y\n" |
528 | "text $w.t -font fixed -yscrollcommand \"$w.sb set\"\n" |
530 | "text $w.t -font fixed -yscrollcommand \"$w.sb set\"\n" |
529 | "pack $w.t -side right -fill both -expand 1\n" |
531 | "pack $w.t -side right -fill both -expand 1\n" |
530 | "bindtags $w.t Console\n" |
532 | "bindtags $w.t Console\n" |
531 | "set v(text) $w.t\n" |
533 | "set v(text) $w.t\n" |
532 | "set v(history) 0\n" |
534 | "set v(history) 0\n" |
533 | "set v(historycnt) 0\n" |
535 | "set v(historycnt) 0\n" |
534 | "set v(current) -1\n" |
536 | "set v(current) -1\n" |
535 | "set v(prompt) $prompt\n" |
537 | "set v(prompt) $prompt\n" |
536 | "set v(prior) {}\n" |
538 | "set v(prior) {}\n" |
537 | "set v(plength) [string length $v(prompt)]\n" |
539 | "set v(plength) [string length $v(prompt)]\n" |
538 | "set v(x) 0\n" |
540 | "set v(x) 0\n" |
539 | "set v(y) 0\n" |
541 | "set v(y) 0\n" |
540 | "$w.t mark set insert end\n" |
542 | "$w.t mark set insert end\n" |
541 | "$w.t tag config ok -foreground blue\n" |
543 | "$w.t tag config ok -foreground blue\n" |
542 | "$w.t tag config err -foreground red\n" |
544 | "$w.t tag config err -foreground red\n" |
543 | "$w.t insert end $v(prompt)\n" |
545 | "$w.t insert end $v(prompt)\n" |
544 | "$w.t mark set out 1.0\n" |
546 | "$w.t mark set out 1.0\n" |
545 | "catch {rename puts console:oldputs$w}\n" |
547 | "catch {rename puts console:oldputs$w}\n" |
546 | "proc puts args [format {\n" |
548 | "proc puts args [format {\n" |
547 | "if {![winfo exists %s]} {\n" |
549 | "if {![winfo exists %s]} {\n" |
548 | "rename puts {}\n" |
550 | "rename puts {}\n" |
549 | "rename console:oldputs%s puts\n" |
551 | "rename console:oldputs%s puts\n" |
550 | "return [uplevel #0 puts $args]\n" |
552 | "return [uplevel #0 puts $args]\n" |
551 | "}\n" |
553 | "}\n" |
552 | "switch -glob -- \"[llength $args] $args\" {\n" |
554 | "switch -glob -- \"[llength $args] $args\" {\n" |
553 | "{1 *} {\n" |
555 | "{1 *} {\n" |
554 | "set msg [lindex $args 0]\\n\n" |
556 | "set msg [lindex $args 0]\\n\n" |
555 | "set tag ok\n" |
557 | "set tag ok\n" |
556 | "}\n" |
558 | "}\n" |
557 | "{2 stdout *} {\n" |
559 | "{2 stdout *} {\n" |
558 | "set msg [lindex $args 1]\\n\n" |
560 | "set msg [lindex $args 1]\\n\n" |
559 | "set tag ok\n" |
561 | "set tag ok\n" |
560 | "}\n" |
562 | "}\n" |
561 | "{2 stderr *} {\n" |
563 | "{2 stderr *} {\n" |
562 | "set msg [lindex $args 1]\\n\n" |
564 | "set msg [lindex $args 1]\\n\n" |
563 | "set tag err\n" |
565 | "set tag err\n" |
564 | "}\n" |
566 | "}\n" |
565 | "{2 -nonewline *} {\n" |
567 | "{2 -nonewline *} {\n" |
566 | "set msg [lindex $args 1]\n" |
568 | "set msg [lindex $args 1]\n" |
567 | "set tag ok\n" |
569 | "set tag ok\n" |
568 | "}\n" |
570 | "}\n" |
569 | "{3 -nonewline stdout *} {\n" |
571 | "{3 -nonewline stdout *} {\n" |
570 | "set msg [lindex $args 2]\n" |
572 | "set msg [lindex $args 2]\n" |
571 | "set tag ok\n" |
573 | "set tag ok\n" |
572 | "}\n" |
574 | "}\n" |
573 | "{3 -nonewline stderr *} {\n" |
575 | "{3 -nonewline stderr *} {\n" |
574 | "set msg [lindex $args 2]\n" |
576 | "set msg [lindex $args 2]\n" |
575 | "set tag err\n" |
577 | "set tag err\n" |
576 | "}\n" |
578 | "}\n" |
577 | "default {\n" |
579 | "default {\n" |
578 | "uplevel #0 console:oldputs%s $args\n" |
580 | "uplevel #0 console:oldputs%s $args\n" |
579 | "return\n" |
581 | "return\n" |
580 | "}\n" |
582 | "}\n" |
581 | "}\n" |
583 | "}\n" |
582 | "console:Puts %s $msg $tag\n" |
584 | "console:Puts %s $msg $tag\n" |
583 | "} $w $w $w $w.t]\n" |
585 | "} $w $w $w $w.t]\n" |
584 | "after idle \"focus $w.t\"\n" |
586 | "after idle \"focus $w.t\"\n" |
585 | "}\n" |
587 | "}\n" |
586 | "bind Console <1> {console:Button1 %W %x %y}\n" |
588 | "bind Console <1> {console:Button1 %W %x %y}\n" |
587 | "bind Console <B1-Motion> {console:B1Motion %W %x %y}\n" |
589 | "bind Console <B1-Motion> {console:B1Motion %W %x %y}\n" |
588 | "bind Console <B1-Leave> {console:B1Leave %W %x %y}\n" |
590 | "bind Console <B1-Leave> {console:B1Leave %W %x %y}\n" |
589 | "bind Console <B1-Enter> {console:cancelMotor %W}\n" |
591 | "bind Console <B1-Enter> {console:cancelMotor %W}\n" |
590 | "bind Console <ButtonRelease-1> {console:cancelMotor %W}\n" |
592 | "bind Console <ButtonRelease-1> {console:cancelMotor %W}\n" |
591 | "bind Console <KeyPress> {console:Insert %W %A}\n" |
593 | "bind Console <KeyPress> {console:Insert %W %A}\n" |
592 | "bind Console <Left> {console:Left %W}\n" |
594 | "bind Console <Left> {console:Left %W}\n" |
593 | "bind Console <Control-b> {console:Left %W}\n" |
595 | "bind Console <Control-b> {console:Left %W}\n" |
594 | "bind Console <Right> {console:Right %W}\n" |
596 | "bind Console <Right> {console:Right %W}\n" |
595 | "bind Console <Control-f> {console:Right %W}\n" |
597 | "bind Console <Control-f> {console:Right %W}\n" |
596 | "bind Console <BackSpace> {console:Backspace %W}\n" |
598 | "bind Console <BackSpace> {console:Backspace %W}\n" |
597 | "bind Console <Control-h> {console:Backspace %W}\n" |
599 | "bind Console <Control-h> {console:Backspace %W}\n" |
598 | "bind Console <Delete> {console:Delete %W}\n" |
600 | "bind Console <Delete> {console:Delete %W}\n" |
599 | "bind Console <Control-d> {console:Delete %W}\n" |
601 | "bind Console <Control-d> {console:Delete %W}\n" |
600 | "bind Console <Home> {console:Home %W}\n" |
602 | "bind Console <Home> {console:Home %W}\n" |
601 | "bind Console <Control-a> {console:Home %W}\n" |
603 | "bind Console <Control-a> {console:Home %W}\n" |
602 | "bind Console <End> {console:End %W}\n" |
604 | "bind Console <End> {console:End %W}\n" |
603 | "bind Console <Control-e> {console:End %W}\n" |
605 | "bind Console <Control-e> {console:End %W}\n" |
604 | "bind Console <Return> {console:Enter %W}\n" |
606 | "bind Console <Return> {console:Enter %W}\n" |
605 | "bind Console <KP_Enter> {console:Enter %W}\n" |
607 | "bind Console <KP_Enter> {console:Enter %W}\n" |
606 | "bind Console <Up> {console:Prior %W}\n" |
608 | "bind Console <Up> {console:Prior %W}\n" |
607 | "bind Console <Control-p> {console:Prior %W}\n" |
609 | "bind Console <Control-p> {console:Prior %W}\n" |
608 | "bind Console <Down> {console:Next %W}\n" |
610 | "bind Console <Down> {console:Next %W}\n" |
609 | "bind Console <Control-n> {console:Next %W}\n" |
611 | "bind Console <Control-n> {console:Next %W}\n" |
610 | "bind Console <Control-k> {console:EraseEOL %W}\n" |
612 | "bind Console <Control-k> {console:EraseEOL %W}\n" |
611 | "bind Console <<Cut>> {console:Cut %W}\n" |
613 | "bind Console <<Cut>> {console:Cut %W}\n" |
612 | "bind Console <<Copy>> {console:Copy %W}\n" |
614 | "bind Console <<Copy>> {console:Copy %W}\n" |
613 | "bind Console <<Paste>> {console:Paste %W}\n" |
615 | "bind Console <<Paste>> {console:Paste %W}\n" |
614 | "bind Console <<Clear>> {console:Clear %W}\n" |
616 | "bind Console <<Clear>> {console:Clear %W}\n" |
615 | "proc console:Puts {w t tag} {\n" |
617 | "proc console:Puts {w t tag} {\n" |
616 | "set nc [string length $t]\n" |
618 | "set nc [string length $t]\n" |
617 | "set endc [string index $t [expr $nc-1]]\n" |
619 | "set endc [string index $t [expr $nc-1]]\n" |
618 | "if {$endc==\"\\n\"} {\n" |
620 | "if {$endc==\"\\n\"} {\n" |
619 | "if {[$w index out]<[$w index {insert linestart}]} {\n" |
621 | "if {[$w index out]<[$w index {insert linestart}]} {\n" |
620 | "$w insert out [string range $t 0 [expr $nc-2]] $tag\n" |
622 | "$w insert out [string range $t 0 [expr $nc-2]] $tag\n" |
621 | "$w mark set out {out linestart +1 lines}\n" |
623 | "$w mark set out {out linestart +1 lines}\n" |
622 | "} else {\n" |
624 | "} else {\n" |
623 | "$w insert out $t $tag\n" |
625 | "$w insert out $t $tag\n" |
624 | "}\n" |
626 | "}\n" |
625 | "} else {\n" |
627 | "} else {\n" |
626 | "if {[$w index out]<[$w index {insert linestart}]} {\n" |
628 | "if {[$w index out]<[$w index {insert linestart}]} {\n" |
627 | "$w insert out $t $tag\n" |
629 | "$w insert out $t $tag\n" |
628 | "} else {\n" |
630 | "} else {\n" |
629 | "$w insert out $t\\n $tag\n" |
631 | "$w insert out $t\\n $tag\n" |
630 | "$w mark set out {out -1 char}\n" |
632 | "$w mark set out {out -1 char}\n" |
631 | "}\n" |
633 | "}\n" |
632 | "}\n" |
634 | "}\n" |
633 | "$w yview insert\n" |
635 | "$w yview insert\n" |
634 | "}\n" |
636 | "}\n" |
635 | "proc console:Insert {w a} {\n" |
637 | "proc console:Insert {w a} {\n" |
636 | "$w insert insert $a\n" |
638 | "$w insert insert $a\n" |
637 | "$w yview insert\n" |
639 | "$w yview insert\n" |
638 | "}\n" |
640 | "}\n" |
639 | "proc console:Left {w} {\n" |
641 | "proc console:Left {w} {\n" |
640 | "upvar #0 $w v\n" |
642 | "upvar #0 $w v\n" |
641 | "scan [$w index insert] %d.%d row col\n" |
643 | "scan [$w index insert] %d.%d row col\n" |
642 | "if {$col>$v(plength)} {\n" |
644 | "if {$col>$v(plength)} {\n" |
643 | "$w mark set insert \"insert -1c\"\n" |
645 | "$w mark set insert \"insert -1c\"\n" |
644 | "}\n" |
646 | "}\n" |
645 | "}\n" |
647 | "}\n" |
646 | "proc console:Backspace {w} {\n" |
648 | "proc console:Backspace {w} {\n" |
647 | "upvar #0 $w v\n" |
649 | "upvar #0 $w v\n" |
648 | "scan [$w index insert] %d.%d row col\n" |
650 | "scan [$w index insert] %d.%d row col\n" |
649 | "if {$col>$v(plength)} {\n" |
651 | "if {$col>$v(plength)} {\n" |
650 | "$w delete {insert -1c}\n" |
652 | "$w delete {insert -1c}\n" |
651 | "}\n" |
653 | "}\n" |
652 | "}\n" |
654 | "}\n" |
653 | "proc console:EraseEOL {w} {\n" |
655 | "proc console:EraseEOL {w} {\n" |
654 | "upvar #0 $w v\n" |
656 | "upvar #0 $w v\n" |
655 | "scan [$w index insert] %d.%d row col\n" |
657 | "scan [$w index insert] %d.%d row col\n" |
656 | "if {$col>=$v(plength)} {\n" |
658 | "if {$col>=$v(plength)} {\n" |
657 | "$w delete insert {insert lineend}\n" |
659 | "$w delete insert {insert lineend}\n" |
658 | "}\n" |
660 | "}\n" |
659 | "}\n" |
661 | "}\n" |
660 | "proc console:Right {w} {\n" |
662 | "proc console:Right {w} {\n" |
661 | "$w mark set insert \"insert +1c\"\n" |
663 | "$w mark set insert \"insert +1c\"\n" |
662 | "}\n" |
664 | "}\n" |
663 | "proc console:Delete w {\n" |
665 | "proc console:Delete w {\n" |
664 | "$w delete insert\n" |
666 | "$w delete insert\n" |
665 | "}\n" |
667 | "}\n" |
666 | "proc console:Home w {\n" |
668 | "proc console:Home w {\n" |
667 | "upvar #0 $w v\n" |
669 | "upvar #0 $w v\n" |
668 | "scan [$w index insert] %d.%d row col\n" |
670 | "scan [$w index insert] %d.%d row col\n" |
669 | "$w mark set insert $row.$v(plength)\n" |
671 | "$w mark set insert $row.$v(plength)\n" |
670 | "}\n" |
672 | "}\n" |
671 | "proc console:End w {\n" |
673 | "proc console:End w {\n" |
672 | "$w mark set insert {insert lineend}\n" |
674 | "$w mark set insert {insert lineend}\n" |
673 | "}\n" |
675 | "}\n" |
674 | "proc console:Enter w {\n" |
676 | "proc console:Enter w {\n" |
675 | "upvar #0 $w v\n" |
677 | "upvar #0 $w v\n" |
676 | "scan [$w index insert] %d.%d row col\n" |
678 | "scan [$w index insert] %d.%d row col\n" |
677 | "set start $row.$v(plength)\n" |
679 | "set start $row.$v(plength)\n" |
678 | "set line [$w get $start \"$start lineend\"]\n" |
680 | "set line [$w get $start \"$start lineend\"]\n" |
679 | "if {$v(historycnt)>0} {\n" |
681 | "if {$v(historycnt)>0} {\n" |
680 | "set last [lindex $v(history) [expr $v(historycnt)-1]]\n" |
682 | "set last [lindex $v(history) [expr $v(historycnt)-1]]\n" |
681 | "if {[string compare $last $line]} {\n" |
683 | "if {[string compare $last $line]} {\n" |
682 | "lappend v(history) $line\n" |
684 | "lappend v(history) $line\n" |
683 | "incr v(historycnt)\n" |
685 | "incr v(historycnt)\n" |
684 | "}\n" |
686 | "}\n" |
685 | "} else {\n" |
687 | "} else {\n" |
686 | "set v(history) [list $line]\n" |
688 | "set v(history) [list $line]\n" |
687 | "set v(historycnt) 1\n" |
689 | "set v(historycnt) 1\n" |
688 | "}\n" |
690 | "}\n" |
689 | "set v(current) $v(historycnt)\n" |
691 | "set v(current) $v(historycnt)\n" |
690 | "$w insert end \\n\n" |
692 | "$w insert end \\n\n" |
691 | "$w mark set out end\n" |
693 | "$w mark set out end\n" |
692 | "if {$v(prior)==\"\"} {\n" |
694 | "if {$v(prior)==\"\"} {\n" |
693 | "set cmd $line\n" |
695 | "set cmd $line\n" |
694 | "} else {\n" |
696 | "} else {\n" |
695 | "set cmd $v(prior)\\n$line\n" |
697 | "set cmd $v(prior)\\n$line\n" |
696 | "}\n" |
698 | "}\n" |
697 | "if {[info complete $cmd]} {\n" |
699 | "if {[info complete $cmd]} {\n" |
698 | "set rc [catch {uplevel #0 $cmd} res]\n" |
700 | "set rc [catch {uplevel #0 $cmd} res]\n" |
699 | "if {![winfo exists $w]} return\n" |
701 | "if {![winfo exists $w]} return\n" |
700 | "if {$rc} {\n" |
702 | "if {$rc} {\n" |
701 | "$w insert end $res\\n err\n" |
703 | "$w insert end $res\\n err\n" |
702 | "} elseif {[string length $res]>0} {\n" |
704 | "} elseif {[string length $res]>0} {\n" |
703 | "$w insert end $res\\n ok\n" |
705 | "$w insert end $res\\n ok\n" |
704 | "}\n" |
706 | "}\n" |
705 | "set v(prior) {}\n" |
707 | "set v(prior) {}\n" |
706 | "$w insert end $v(prompt)\n" |
708 | "$w insert end $v(prompt)\n" |
707 | "} else {\n" |
709 | "} else {\n" |
708 | "set v(prior) $cmd\n" |
710 | "set v(prior) $cmd\n" |
709 | "regsub -all {[^ ]} $v(prompt) . x\n" |
711 | "regsub -all {[^ ]} $v(prompt) . x\n" |
710 | "$w insert end $x\n" |
712 | "$w insert end $x\n" |
711 | "}\n" |
713 | "}\n" |
712 | "$w mark set insert end\n" |
714 | "$w mark set insert end\n" |
713 | "$w mark set out {insert linestart}\n" |
715 | "$w mark set out {insert linestart}\n" |
714 | "$w yview insert\n" |
716 | "$w yview insert\n" |
715 | "}\n" |
717 | "}\n" |
716 | "proc console:Prior w {\n" |
718 | "proc console:Prior w {\n" |
717 | "upvar #0 $w v\n" |
719 | "upvar #0 $w v\n" |
718 | "if {$v(current)<=0} return\n" |
720 | "if {$v(current)<=0} return\n" |
719 | "incr v(current) -1\n" |
721 | "incr v(current) -1\n" |
720 | "set line [lindex $v(history) $v(current)]\n" |
722 | "set line [lindex $v(history) $v(current)]\n" |
721 | "console:SetLine $w $line\n" |
723 | "console:SetLine $w $line\n" |
722 | "}\n" |
724 | "}\n" |
723 | "proc console:Next w {\n" |
725 | "proc console:Next w {\n" |
724 | "upvar #0 $w v\n" |
726 | "upvar #0 $w v\n" |
725 | "if {$v(current)>=$v(historycnt)} return\n" |
727 | "if {$v(current)>=$v(historycnt)} return\n" |
726 | "incr v(current) 1\n" |
728 | "incr v(current) 1\n" |
727 | "set line [lindex $v(history) $v(current)]\n" |
729 | "set line [lindex $v(history) $v(current)]\n" |
728 | "console:SetLine $w $line\n" |
730 | "console:SetLine $w $line\n" |
729 | "}\n" |
731 | "}\n" |
730 | "proc console:SetLine {w line} {\n" |
732 | "proc console:SetLine {w line} {\n" |
731 | "upvar #0 $w v\n" |
733 | "upvar #0 $w v\n" |
732 | "scan [$w index insert] %d.%d row col\n" |
734 | "scan [$w index insert] %d.%d row col\n" |
733 | "set start $row.$v(plength)\n" |
735 | "set start $row.$v(plength)\n" |
734 | "$w delete $start end\n" |
736 | "$w delete $start end\n" |
735 | "$w insert end $line\n" |
737 | "$w insert end $line\n" |
736 | "$w mark set insert end\n" |
738 | "$w mark set insert end\n" |
737 | "$w yview insert\n" |
739 | "$w yview insert\n" |
738 | "}\n" |
740 | "}\n" |
739 | "proc console:Button1 {w x y} {\n" |
741 | "proc console:Button1 {w x y} {\n" |
740 | "global tkPriv\n" |
742 | "global tkPriv\n" |
741 | "upvar #0 $w v\n" |
743 | "upvar #0 $w v\n" |
742 | "set v(mouseMoved) 0\n" |
744 | "set v(mouseMoved) 0\n" |
743 | "set v(pressX) $x\n" |
745 | "set v(pressX) $x\n" |
744 | "set p [console:nearestBoundry $w $x $y]\n" |
746 | "set p [console:nearestBoundry $w $x $y]\n" |
745 | "scan [$w index insert] %d.%d ix iy\n" |
747 | "scan [$w index insert] %d.%d ix iy\n" |
746 | "scan $p %d.%d px py\n" |
748 | "scan $p %d.%d px py\n" |
747 | "if {$px==$ix} {\n" |
749 | "if {$px==$ix} {\n" |
748 | "$w mark set insert $p\n" |
750 | "$w mark set insert $p\n" |
749 | "}\n" |
751 | "}\n" |
750 | "$w mark set anchor $p\n" |
752 | "$w mark set anchor $p\n" |
751 | "focus $w\n" |
753 | "focus $w\n" |
752 | "}\n" |
754 | "}\n" |
753 | "proc console:nearestBoundry {w x y} {\n" |
755 | "proc console:nearestBoundry {w x y} {\n" |
754 | "set p [$w index @$x,$y]\n" |
756 | "set p [$w index @$x,$y]\n" |
755 | "set bb [$w bbox $p]\n" |
757 | "set bb [$w bbox $p]\n" |
756 | "if {![string compare $bb \"\"]} {return $p}\n" |
758 | "if {![string compare $bb \"\"]} {return $p}\n" |
757 | "if {($x-[lindex $bb 0])<([lindex $bb 2]/2)} {return $p}\n" |
759 | "if {($x-[lindex $bb 0])<([lindex $bb 2]/2)} {return $p}\n" |
758 | "$w index \"$p + 1 char\"\n" |
760 | "$w index \"$p + 1 char\"\n" |
759 | "}\n" |
761 | "}\n" |
760 | "proc console:SelectTo {w x y} {\n" |
762 | "proc console:SelectTo {w x y} {\n" |
761 | "upvar #0 $w v\n" |
763 | "upvar #0 $w v\n" |
762 | "set cur [console:nearestBoundry $w $x $y]\n" |
764 | "set cur [console:nearestBoundry $w $x $y]\n" |
763 | "if {[catch {$w index anchor}]} {\n" |
765 | "if {[catch {$w index anchor}]} {\n" |
764 | "$w mark set anchor $cur\n" |
766 | "$w mark set anchor $cur\n" |
765 | "}\n" |
767 | "}\n" |
766 | "set anchor [$w index anchor]\n" |
768 | "set anchor [$w index anchor]\n" |
767 | "if {[$w compare $cur != $anchor] || (abs($v(pressX) - $x) >= 3)} {\n" |
769 | "if {[$w compare $cur != $anchor] || (abs($v(pressX) - $x) >= 3)} {\n" |
768 | "if {$v(mouseMoved)==0} {\n" |
770 | "if {$v(mouseMoved)==0} {\n" |
769 | "$w tag remove sel 0.0 end\n" |
771 | "$w tag remove sel 0.0 end\n" |
770 | "}\n" |
772 | "}\n" |
771 | "set v(mouseMoved) 1\n" |
773 | "set v(mouseMoved) 1\n" |
772 | "}\n" |
774 | "}\n" |
773 | "if {[$w compare $cur < anchor]} {\n" |
775 | "if {[$w compare $cur < anchor]} {\n" |
774 | "set first $cur\n" |
776 | "set first $cur\n" |
775 | "set last anchor\n" |
777 | "set last anchor\n" |
776 | "} else {\n" |
778 | "} else {\n" |
777 | "set first anchor\n" |
779 | "set first anchor\n" |
778 | "set last $cur\n" |
780 | "set last $cur\n" |
779 | "}\n" |
781 | "}\n" |
780 | "if {$v(mouseMoved)} {\n" |
782 | "if {$v(mouseMoved)} {\n" |
781 | "$w tag remove sel 0.0 $first\n" |
783 | "$w tag remove sel 0.0 $first\n" |
782 | "$w tag add sel $first $last\n" |
784 | "$w tag add sel $first $last\n" |
783 | "$w tag remove sel $last end\n" |
785 | "$w tag remove sel $last end\n" |
784 | "update idletasks\n" |
786 | "update idletasks\n" |
785 | "}\n" |
787 | "}\n" |
786 | "}\n" |
788 | "}\n" |
787 | "proc console:B1Motion {w x y} {\n" |
789 | "proc console:B1Motion {w x y} {\n" |
788 | "upvar #0 $w v\n" |
790 | "upvar #0 $w v\n" |
789 | "set v(y) $y\n" |
791 | "set v(y) $y\n" |
790 | "set v(x) $x\n" |
792 | "set v(x) $x\n" |
791 | "console:SelectTo $w $x $y\n" |
793 | "console:SelectTo $w $x $y\n" |
792 | "}\n" |
794 | "}\n" |
793 | "proc console:B1Leave {w x y} {\n" |
795 | "proc console:B1Leave {w x y} {\n" |
794 | "upvar #0 $w v\n" |
796 | "upvar #0 $w v\n" |
795 | "set v(y) $y\n" |
797 | "set v(y) $y\n" |
796 | "set v(x) $x\n" |
798 | "set v(x) $x\n" |
797 | "console:motor $w\n" |
799 | "console:motor $w\n" |
798 | "}\n" |
800 | "}\n" |
799 | "proc console:motor w {\n" |
801 | "proc console:motor w {\n" |
800 | "upvar #0 $w v\n" |
802 | "upvar #0 $w v\n" |
801 | "if {![winfo exists $w]} return\n" |
803 | "if {![winfo exists $w]} return\n" |
802 | "if {$v(y)>=[winfo height $w]} {\n" |
804 | "if {$v(y)>=[winfo height $w]} {\n" |
803 | "$w yview scroll 1 units\n" |
805 | "$w yview scroll 1 units\n" |
804 | "} elseif {$v(y)<0} {\n" |
806 | "} elseif {$v(y)<0} {\n" |
805 | "$w yview scroll -1 units\n" |
807 | "$w yview scroll -1 units\n" |
806 | "} else {\n" |
808 | "} else {\n" |
807 | "return\n" |
809 | "return\n" |
808 | "}\n" |
810 | "}\n" |
809 | "console:SelectTo $w $v(x) $v(y)\n" |
811 | "console:SelectTo $w $v(x) $v(y)\n" |
810 | "set v(timer) [after 50 console:motor $w]\n" |
812 | "set v(timer) [after 50 console:motor $w]\n" |
811 | "}\n" |
813 | "}\n" |
812 | "proc console:cancelMotor w {\n" |
814 | "proc console:cancelMotor w {\n" |
813 | "upvar #0 $w v\n" |
815 | "upvar #0 $w v\n" |
814 | "catch {after cancel $v(timer)}\n" |
816 | "catch {after cancel $v(timer)}\n" |
815 | "catch {unset v(timer)}\n" |
817 | "catch {unset v(timer)}\n" |
816 | "}\n" |
818 | "}\n" |
817 | "proc console:Copy w {\n" |
819 | "proc console:Copy w {\n" |
818 | "if {![catch {set text [$w get sel.first sel.last]}]} {\n" |
820 | "if {![catch {set text [$w get sel.first sel.last]}]} {\n" |
819 | "clipboard clear -displayof $w\n" |
821 | "clipboard clear -displayof $w\n" |
820 | "clipboard append -displayof $w $text\n" |
822 | "clipboard append -displayof $w $text\n" |
821 | "}\n" |
823 | "}\n" |
822 | "}\n" |
824 | "}\n" |
823 | "proc console:canCut w {\n" |
825 | "proc console:canCut w {\n" |
824 | "set r [catch {\n" |
826 | "set r [catch {\n" |
825 | "scan [$w index sel.first] %d.%d s1x s1y\n" |
827 | "scan [$w index sel.first] %d.%d s1x s1y\n" |
826 | "scan [$w index sel.last] %d.%d s2x s2y\n" |
828 | "scan [$w index sel.last] %d.%d s2x s2y\n" |
827 | "scan [$w index insert] %d.%d ix iy\n" |
829 | "scan [$w index insert] %d.%d ix iy\n" |
828 | "}]\n" |
830 | "}]\n" |
829 | "if {$r==1} {return 0}\n" |
831 | "if {$r==1} {return 0}\n" |
830 | "if {$s1x==$ix && $s2x==$ix} {return 1}\n" |
832 | "if {$s1x==$ix && $s2x==$ix} {return 1}\n" |
831 | "return 2\n" |
833 | "return 2\n" |
832 | "}\n" |
834 | "}\n" |
833 | "proc console:Cut w {\n" |
835 | "proc console:Cut w {\n" |
834 | "if {[console:canCut $w]==1} {\n" |
836 | "if {[console:canCut $w]==1} {\n" |
835 | "console:Copy $w\n" |
837 | "console:Copy $w\n" |
836 | "$w delete sel.first sel.last\n" |
838 | "$w delete sel.first sel.last\n" |
837 | "}\n" |
839 | "}\n" |
838 | "}\n" |
840 | "}\n" |
839 | "proc console:Paste w {\n" |
841 | "proc console:Paste w {\n" |
840 | "if {[console:canCut $w]==1} {\n" |
842 | "if {[console:canCut $w]==1} {\n" |
841 | "$w delete sel.first sel.last\n" |
843 | "$w delete sel.first sel.last\n" |
842 | "}\n" |
844 | "}\n" |
843 | "if {[catch {selection get -displayof $w -selection CLIPBOARD} topaste]} {\n" |
845 | "if {[catch {selection get -displayof $w -selection CLIPBOARD} topaste]} {\n" |
844 | "return\n" |
846 | "return\n" |
845 | "}\n" |
847 | "}\n" |
846 | "set prior 0\n" |
848 | "set prior 0\n" |
847 | "foreach line [split $topaste \\n] {\n" |
849 | "foreach line [split $topaste \\n] {\n" |
848 | "if {$prior} {\n" |
850 | "if {$prior} {\n" |
849 | "console:Enter $w\n" |
851 | "console:Enter $w\n" |
850 | "update\n" |
852 | "update\n" |
851 | "}\n" |
853 | "}\n" |
852 | "set prior 1\n" |
854 | "set prior 1\n" |
853 | "$w insert insert $line\n" |
855 | "$w insert insert $line\n" |
854 | "}\n" |
856 | "}\n" |
855 | "}\n" |
857 | "}\n" |
856 | "proc console:EnableEditMenu w {\n" |
858 | "proc console:EnableEditMenu w {\n" |
857 | "set m $w.mb.edit.m\n" |
859 | "set m $w.mb.edit.m\n" |
858 | "switch [console:canCut $w.t] {\n" |
860 | "switch [console:canCut $w.t] {\n" |
859 | "0 {\n" |
861 | "0 {\n" |
860 | "$m entryconf Copy -state disabled\n" |
862 | "$m entryconf Copy -state disabled\n" |
861 | "$m entryconf Cut -state disabled\n" |
863 | "$m entryconf Cut -state disabled\n" |
862 | "}\n" |
864 | "}\n" |
863 | "1 {\n" |
865 | "1 {\n" |
864 | "$m entryconf Copy -state normal\n" |
866 | "$m entryconf Copy -state normal\n" |
865 | "$m entryconf Cut -state normal\n" |
867 | "$m entryconf Cut -state normal\n" |
866 | "}\n" |
868 | "}\n" |
867 | "2 {\n" |
869 | "2 {\n" |
868 | "$m entryconf Copy -state normal\n" |
870 | "$m entryconf Copy -state normal\n" |
869 | "$m entryconf Cut -state disabled\n" |
871 | "$m entryconf Cut -state disabled\n" |
870 | "}\n" |
872 | "}\n" |
871 | "}\n" |
873 | "}\n" |
872 | "}\n" |
874 | "}\n" |
873 | "proc console:SourceFile w {\n" |
875 | "proc console:SourceFile w {\n" |
874 | "set types {\n" |
876 | "set types {\n" |
875 | "{{TCL Scripts} {.tcl}}\n" |
877 | "{{TCL Scripts} {.tcl}}\n" |
876 | "{{All Files} *}\n" |
878 | "{{All Files} *}\n" |
877 | "}\n" |
879 | "}\n" |
878 | "set f [tk_getOpenFile -filetypes $types -title \"TCL Script To Source...\"]\n" |
880 | "set f [tk_getOpenFile -filetypes $types -title \"TCL Script To Source...\"]\n" |
879 | "if {$f!=\"\"} {\n" |
881 | "if {$f!=\"\"} {\n" |
880 | "uplevel #0 source $f\n" |
882 | "uplevel #0 source $f\n" |
881 | "}\n" |
883 | "}\n" |
882 | "}\n" |
884 | "}\n" |
883 | "proc console:SaveFile w {\n" |
885 | "proc console:SaveFile w {\n" |
884 | "set types {\n" |
886 | "set types {\n" |
885 | "{{Text Files} {.txt}}\n" |
887 | "{{Text Files} {.txt}}\n" |
886 | "{{All Files} *}\n" |
888 | "{{All Files} *}\n" |
887 | "}\n" |
889 | "}\n" |
888 | "set f [tk_getSaveFile -filetypes $types -title \"Write Screen To...\"]\n" |
890 | "set f [tk_getSaveFile -filetypes $types -title \"Write Screen To...\"]\n" |
889 | "if {$f!=\"\"} {\n" |
891 | "if {$f!=\"\"} {\n" |
890 | "if {[catch {open $f w} fd]} {\n" |
892 | "if {[catch {open $f w} fd]} {\n" |
891 | "tk_messageBox -type ok -icon error -message $fd\n" |
893 | "tk_messageBox -type ok -icon error -message $fd\n" |
892 | "} else {\n" |
894 | "} else {\n" |
893 | "puts $fd [string trimright [$w get 1.0 end] \\n]\n" |
895 | "puts $fd [string trimright [$w get 1.0 end] \\n]\n" |
894 | "close $fd\n" |
896 | "close $fd\n" |
895 | "}\n" |
897 | "}\n" |
896 | "}\n" |
898 | "}\n" |
897 | "}\n" |
899 | "}\n" |
898 | "proc console:Clear w {\n" |
900 | "proc console:Clear w {\n" |
899 | "$w delete 1.0 {insert linestart}\n" |
901 | "$w delete 1.0 {insert linestart}\n" |
900 | "}\n"; /* End of the console code */ |
902 | "}\n" |
901 | #endif /* ET_ENABLE_TK */ |
903 | ; /* End of the console code */ |
- | 904 | #endif /* ET_ENABLE_TK */ |
|
902 | 905 | ||
903 | /* |
906 | /* |
904 | ** The "printf" code that follows dates from the 1980's. It is in |
907 | ** The "printf" code that follows dates from the 1980's. It is in |
905 | ** the public domain. The original comments are included here for |
908 | ** the public domain. The original comments are included here for |
906 | ** completeness. They are slightly out-of-date. |
909 | ** completeness. They are slightly out-of-date. |
Line 957... | Line 960... | ||
957 | 960 | ||
958 | /* |
961 | /* |
959 | ** Characters that need to be escaped inside a TCL string. |
962 | ** Characters that need to be escaped inside a TCL string. |
960 | */ |
963 | */ |
961 | static char NeedEsc[] = { |
964 | static char NeedEsc[] = { |
- | 965 | 1, 1, 1, 1, 1, 1, 1, 1, 'b', 't', 'n', 1, 'f', 'r', 1, 1, |
|
962 | 1, 1, 1, 1, 1, 1, 1, 1, 'b', 't', 'n', 1, 'f', 'r', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
966 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
- | 967 | 0, 0, '"', 0, '$', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
963 | 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, '"', 0, '$', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
968 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
964 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
969 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
965 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '[', '\\', ']', 0, 0, |
970 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '[','\\', ']', 0, 0, |
966 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
971 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
- | 972 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, |
|
- | 973 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
- | 974 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
967 | 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
975 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
968 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
976 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
969 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
977 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
970 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
978 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
971 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
979 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
972 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
980 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
973 | }; |
981 | }; |
974 | 982 | ||
975 | /* |
983 | /* |
976 | ** Conversion types fall into various categories as defined by the |
984 | ** Conversion types fall into various categories as defined by the |
977 | ** following enumeration. |
985 | ** following enumeration. |
978 | */ |
986 | */ |
979 | enum et_type |
- | |
980 | { /* The type of the format field */ |
987 | enum et_type { /* The type of the format field */ |
981 | etRADIX, /* Integer types. %d, %x, %o, and so forth */ |
988 | etRADIX, /* Integer types. %d, %x, %o, and so forth */ |
982 | etFLOAT, /* Floating point. %f */ |
989 | etFLOAT, /* Floating point. %f */ |
983 | etEXP, /* Exponentional notation. %e and %E */ |
990 | etEXP, /* Exponentional notation. %e and %E */ |
984 | etGENERIC, /* Floating or exponential, depending on exponent. %g */ |
991 | etGENERIC, /* Floating or exponential, depending on exponent. %g */ |
985 | etSIZE, /* Return number of characters processed so far. %n */ |
992 | etSIZE, /* Return number of characters processed so far. %n */ |
986 | etSTRING, /* Strings. %s */ |
993 | etSTRING, /* Strings. %s */ |
987 | etPERCENT, /* Percent symbol. %% */ |
994 | etPERCENT, /* Percent symbol. %% */ |
988 | etCHARX, /* Characters. %c */ |
995 | etCHARX, /* Characters. %c */ |
989 | etERROR, /* Used to indicate no such conversion type */ |
996 | etERROR, /* Used to indicate no such conversion type */ |
990 | /* The rest are extensions, not normally found in printf() */ |
997 | /* The rest are extensions, not normally found in printf() */ |
991 | etCHARLIT, /* Literal characters. %' */ |
998 | etCHARLIT, /* Literal characters. %' */ |
992 | etTCLESCAPE, /* Strings with special characters escaped. %q */ |
999 | etTCLESCAPE, /* Strings with special characters escaped. %q */ |
993 | etMEMSTRING, /* A string which should be deleted after use. %z */ |
1000 | etMEMSTRING, /* A string which should be deleted after use. %z */ |
994 | etORDINAL /* 1st, 2nd, 3rd and so forth */ |
1001 | etORDINAL /* 1st, 2nd, 3rd and so forth */ |
995 | }; |
1002 | }; |
996 | 1003 | ||
997 | /* |
1004 | /* |
998 | ** Each builtin conversion character (ex: the 'd' in "%d") is described |
1005 | ** Each builtin conversion character (ex: the 'd' in "%d") is described |
999 | ** by an instance of the following structure |
1006 | ** by an instance of the following structure |
1000 | */ |
1007 | */ |
1001 | typedef struct et_info |
- | |
1002 | { /* Information about each format field */ |
1008 | typedef struct et_info { /* Information about each format field */ |
1003 | int fmttype; /* The format field code letter */ |
1009 | int fmttype; /* The format field code letter */ |
1004 | int base; /* The base for radix conversion */ |
1010 | int base; /* The base for radix conversion */ |
1005 | char *charset; /* The character set for conversion */ |
1011 | char *charset; /* The character set for conversion */ |
1006 | int flag_signed; /* Is the quantity signed? */ |
1012 | int flag_signed; /* Is the quantity signed? */ |
1007 | char *prefix; /* Prefix on non-zero values in alt format */ |
1013 | char *prefix; /* Prefix on non-zero values in alt format */ |
1008 | enum et_type type; /* Conversion paradigm */ |
1014 | enum et_type type; /* Conversion paradigm */ |
1009 | } et_info; |
1015 | } et_info; |
1010 | 1016 | ||
1011 | /* |
1017 | /* |
1012 | ** The following table is searched linearly, so it is good to put the |
1018 | ** The following table is searched linearly, so it is good to put the |
1013 | ** most frequently used conversion types first. |
1019 | ** most frequently used conversion types first. |
1014 | */ |
1020 | */ |
1015 | static et_info fmtinfo[] = { |
1021 | static et_info fmtinfo[] = { |
1016 | { |
- | |
1017 | 'd', |
- | |
1018 | 10, |
- | |
1019 | "0123456789", |
1022 | { 'd', 10, "0123456789", 1, 0, etRADIX, }, |
1020 | 1, |
- | |
1021 | 0, |
- | |
1022 | etRADIX, |
- | |
1023 | }, |
- | |
1024 | { |
- | |
1025 | 's', |
- | |
1026 | 0, |
- | |
1027 | 0, |
- | |
1028 | 0, |
- | |
1029 | 0, |
- | |
1030 | etSTRING, |
1023 | { 's', 0, 0, 0, 0, etSTRING, }, |
1031 | }, |
- | |
1032 | { |
- | |
1033 | 'q', |
- | |
1034 | 0, |
- | |
1035 | 0, |
- | |
1036 | 0, |
- | |
1037 | 0, |
- | |
1038 | etTCLESCAPE, |
1024 | { 'q', 0, 0, 0, 0, etTCLESCAPE, }, |
1039 | }, |
- | |
1040 | { |
- | |
1041 | 'z', |
- | |
1042 | 0, |
- | |
1043 | 0, |
- | |
1044 | 0, |
- | |
1045 | 0, |
- | |
1046 | etMEMSTRING, |
1025 | { 'z', 0, 0, 0, 0, etMEMSTRING, }, |
1047 | }, |
- | |
1048 | { |
- | |
1049 | 'c', |
- | |
1050 | 0, |
- | |
1051 | 0, |
- | |
1052 | 0, |
- | |
1053 | 0, |
- | |
1054 | etCHARX, |
1026 | { 'c', 0, 0, 0, 0, etCHARX, }, |
1055 | }, |
- | |
1056 | { |
- | |
1057 | 'o', |
- | |
1058 | 8, |
- | |
1059 | "01234567", |
1027 | { 'o', 8, "01234567", 0, "0", etRADIX, }, |
1060 | 0, |
- | |
1061 | "0", |
- | |
1062 | etRADIX, |
- | |
1063 | }, |
- | |
1064 | { |
- | |
1065 | 'u', |
- | |
1066 | 10, |
- | |
1067 | "0123456789", |
1028 | { 'u', 10, "0123456789", 0, 0, etRADIX, }, |
1068 | 0, |
- | |
1069 | 0, |
- | |
1070 | etRADIX, |
- | |
1071 | }, |
- | |
1072 | { |
- | |
1073 | 'x', |
- | |
1074 | 16, |
- | |
1075 | "0123456789abcdef", |
1029 | { 'x', 16, "0123456789abcdef", 0, "x0", etRADIX, }, |
1076 | 0, |
- | |
1077 | "x0", |
- | |
1078 | etRADIX, |
- | |
1079 | }, |
- | |
1080 | { |
- | |
1081 | 'X', |
- | |
1082 | 16, |
- | |
1083 | "0123456789ABCDEF", |
1030 | { 'X', 16, "0123456789ABCDEF", 0, "X0", etRADIX, }, |
1084 | 0, |
- | |
1085 | "X0", |
- | |
1086 | etRADIX, |
- | |
1087 | }, |
- | |
1088 | { |
- | |
1089 | 'r', |
- | |
1090 | 10, |
- | |
1091 | "0123456789", |
1031 | { 'r', 10, "0123456789", 0, 0, etORDINAL, }, |
1092 | 0, |
- | |
1093 | 0, |
- | |
1094 | etORDINAL, |
- | |
1095 | }, |
- | |
1096 | { |
- | |
1097 | 'f', |
- | |
1098 | 0, |
- | |
1099 | 0, |
- | |
1100 | 1, |
- | |
1101 | 0, |
- | |
1102 | etFLOAT, |
1032 | { 'f', 0, 0, 1, 0, etFLOAT, }, |
1103 | }, |
- | |
1104 | { |
- | |
1105 | 'e', |
- | |
1106 | 0, |
- | |
1107 | "e", |
- | |
1108 | 1, |
- | |
1109 | 0, |
- | |
1110 | etEXP, |
1033 | { 'e', 0, "e", 1, 0, etEXP, }, |
1111 | }, |
- | |
1112 | { |
- | |
1113 | 'E', |
- | |
1114 | 0, |
- | |
1115 | "E", |
- | |
1116 | 1, |
- | |
1117 | 0, |
- | |
1118 | etEXP, |
1034 | { 'E', 0, "E", 1, 0, etEXP, }, |
1119 | }, |
- | |
1120 | { |
- | |
1121 | 'g', |
- | |
1122 | 0, |
- | |
1123 | "e", |
- | |
1124 | 1, |
- | |
1125 | 0, |
- | |
1126 | etGENERIC, |
1035 | { 'g', 0, "e", 1, 0, etGENERIC, }, |
1127 | }, |
- | |
1128 | { |
- | |
1129 | 'G', |
- | |
1130 | 0, |
- | |
1131 | "E", |
- | |
1132 | 1, |
- | |
1133 | 0, |
- | |
1134 | etGENERIC, |
1036 | { 'G', 0, "E", 1, 0, etGENERIC, }, |
1135 | }, |
- | |
1136 | { |
- | |
1137 | 'i', |
- | |
1138 | 10, |
- | |
1139 | "0123456789", |
1037 | { 'i', 10, "0123456789", 1, 0, etRADIX, }, |
1140 | 1, |
- | |
1141 | 0, |
- | |
1142 | etRADIX, |
- | |
1143 | }, |
- | |
1144 | { |
- | |
1145 | 'n', |
- | |
1146 | 0, |
- | |
1147 | 0, |
- | |
1148 | 0, |
- | |
1149 | 0, |
- | |
1150 | etSIZE, |
1038 | { 'n', 0, 0, 0, 0, etSIZE, }, |
1151 | }, |
- | |
1152 | { |
- | |
1153 | '%', |
- | |
1154 | 0, |
- | |
1155 | 0, |
- | |
1156 | 0, |
- | |
1157 | 0, |
- | |
1158 | etPERCENT, |
1039 | { '%', 0, 0, 0, 0, etPERCENT, }, |
1159 | }, |
- | |
1160 | { |
- | |
1161 | 'b', |
- | |
1162 | 2, |
- | |
1163 | "01", |
- | |
1164 | 0, |
- | |
1165 | "b0", |
- | |
1166 | etRADIX, |
- | |
1167 | }, /* Binary */ |
1040 | { 'b', 2, "01", 0, "b0", etRADIX, }, /* Binary */ |
1168 | { |
- | |
1169 | 'p', |
- | |
1170 | 10, |
- | |
1171 | "0123456789", |
- | |
1172 | 0, |
- | |
1173 | 0, |
- | |
1174 | etRADIX, |
- | |
1175 | }, /* Pointers */ |
1041 | { 'p', 10, "0123456789", 0, 0, etRADIX, }, /* Pointers */ |
1176 | { |
- | |
1177 | '\'', |
- | |
1178 | 0, |
- | |
1179 | 0, |
- | |
1180 | 0, |
- | |
1181 | 0, |
- | |
1182 | etCHARLIT, |
- | |
1183 | }, /* Literal char */ |
1042 | { '\'', 0, 0, 0, 0, etCHARLIT, }, /* Literal char */ |
1184 | }; |
1043 | }; |
1185 | #define etNINFO (sizeof (fmtinfo) / sizeof (fmtinfo[0])) |
1044 | #define etNINFO (sizeof(fmtinfo)/sizeof(fmtinfo[0])) |
1186 | 1045 | ||
1187 | /* |
1046 | /* |
1188 | ** If NOFLOATINGPOINT is defined, then none of the floating point |
1047 | ** If NOFLOATINGPOINT is defined, then none of the floating point |
1189 | ** conversions will work. |
1048 | ** conversions will work. |
1190 | */ |
1049 | */ |
Line 1200... | Line 1059... | ||
1200 | ** |
1059 | ** |
1201 | ** The counter *cnt is incremented each time. After counter exceeds |
1060 | ** The counter *cnt is incremented each time. After counter exceeds |
1202 | ** 16 (the number of significant digits in a 64-bit float) '0' is |
1061 | ** 16 (the number of significant digits in a 64-bit float) '0' is |
1203 | ** always returned. |
1062 | ** always returned. |
1204 | */ |
1063 | */ |
1205 | static int et_getdigit (double *val, int *cnt) |
1064 | static int et_getdigit(double *val, int *cnt){ |
1206 | { |
- | |
1207 | int digit; |
1065 | int digit; |
1208 | double d; |
1066 | double d; |
1209 | if ((*cnt)++ >= 16) |
- | |
1210 | return '0'; |
1067 | if( (*cnt)++ >= 16 ) return '0'; |
1211 | digit = (int) *val; |
1068 | digit = (int)*val; |
1212 | d = digit; |
1069 | d = digit; |
1213 | digit += '0'; |
1070 | digit += '0'; |
1214 | *val = (*val - d) * 10.0; |
1071 | *val = (*val - d)*10.0; |
1215 | return digit; |
1072 | return digit; |
1216 | } |
1073 | } |
1217 | #endif |
1074 | #endif |
1218 | 1075 | ||
1219 | #define etBUFSIZE 1000 /* Size of the output buffer */ |
1076 | #define etBUFSIZE 1000 /* Size of the output buffer */ |
1220 | 1077 | ||
1221 | /* |
1078 | /* |
1222 | ** The root program. All variations call this core. |
1079 | ** The root program. All variations call this core. |
1223 | ** |
1080 | ** |
1224 | ** INPUTS: |
1081 | ** INPUTS: |
Line 1243... | Line 1100... | ||
1243 | ** |
1100 | ** |
1244 | ** Note that the order in which automatic variables are declared below |
1101 | ** Note that the order in which automatic variables are declared below |
1245 | ** seems to make a big difference in determining how fast this beast |
1102 | ** seems to make a big difference in determining how fast this beast |
1246 | ** will run. |
1103 | ** will run. |
1247 | */ |
1104 | */ |
- | 1105 | int vxprintf( |
|
1248 | int vxprintf (void (*func) (void *, char *, int), void *arg, const char *format, va_list ap) |
1106 | void (*func)(void*,char*,int), |
- | 1107 | void *arg, |
|
- | 1108 | const char *format, |
|
- | 1109 | va_list ap |
|
1249 | { |
1110 | ){ |
1250 | register const char *fmt; /* The format string. */ |
1111 | register const char *fmt; /* The format string. */ |
1251 | register int c; /* Next character in the format string */ |
1112 | register int c; /* Next character in the format string */ |
1252 | register char *bufpt; /* Pointer to the conversion buffer */ |
1113 | register char *bufpt; /* Pointer to the conversion buffer */ |
1253 | register int precision; /* Precision of the current field */ |
1114 | register int precision; /* Precision of the current field */ |
1254 | register int length; /* Length of the field */ |
1115 | register int length; /* Length of the field */ |
1255 | register int idx; /* A general purpose loop counter */ |
1116 | register int idx; /* A general purpose loop counter */ |
1256 | int count; /* Total number of characters output */ |
1117 | int count; /* Total number of characters output */ |
1257 | int width; /* Width of the current field */ |
1118 | int width; /* Width of the current field */ |
1258 | int flag_leftjustify; /* True if "-" flag is present */ |
1119 | int flag_leftjustify; /* True if "-" flag is present */ |
1259 | int flag_plussign; /* True if "+" flag is present */ |
1120 | int flag_plussign; /* True if "+" flag is present */ |
1260 | int flag_blanksign; /* True if " " flag is present */ |
1121 | int flag_blanksign; /* True if " " flag is present */ |
1261 | int flag_alternateform; /* True if "#" flag is present */ |
1122 | int flag_alternateform; /* True if "#" flag is present */ |
1262 | int flag_zeropad; /* True if field width constant starts with zero */ |
1123 | int flag_zeropad; /* True if field width constant starts with zero */ |
1263 | int flag_long; /* True if "l" flag is present */ |
1124 | int flag_long; /* True if "l" flag is present */ |
1264 | int flag_center; /* True if "=" flag is present */ |
1125 | int flag_center; /* True if "=" flag is present */ |
1265 | unsigned long longvalue; /* Value for integer types */ |
1126 | unsigned long longvalue; /* Value for integer types */ |
1266 | double realvalue; /* Value for real types */ |
1127 | double realvalue; /* Value for real types */ |
1267 | et_info *infop; /* Pointer to the appropriate info structure */ |
1128 | et_info *infop; /* Pointer to the appropriate info structure */ |
1268 | char buf[etBUFSIZE]; /* Conversion buffer */ |
1129 | char buf[etBUFSIZE]; /* Conversion buffer */ |
1269 | char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ |
1130 | char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ |
1270 | int errorflag = 0; /* True if an error is encountered */ |
1131 | int errorflag = 0; /* True if an error is encountered */ |
1271 | enum et_type xtype; /* Conversion paradigm */ |
1132 | enum et_type xtype; /* Conversion paradigm */ |
1272 | char *zMem; /* String to be freed */ |
1133 | char *zMem; /* String to be freed */ |
1273 | char *zExtra; /* Extra memory used for etTCLESCAPE conversions */ |
1134 | char *zExtra; /* Extra memory used for etTCLESCAPE conversions */ |
1274 | static char spaces[] = " " |
1135 | static char spaces[] = " " |
1275 | " " |
1136 | " "; |
1276 | " "; |
- | |
1277 | #define etSPACESIZE (sizeof (spaces) - 1) |
1137 | #define etSPACESIZE (sizeof(spaces)-1) |
1278 | #ifndef etNOFLOATINGPOINT |
1138 | #ifndef etNOFLOATINGPOINT |
1279 | int exp; /* exponent of real numbers */ |
1139 | int exp; /* exponent of real numbers */ |
1280 | double rounder; /* Used for rounding floating point values */ |
1140 | double rounder; /* Used for rounding floating point values */ |
1281 | int flag_dp; /* True if decimal point should be shown */ |
1141 | int flag_dp; /* True if decimal point should be shown */ |
1282 | int flag_rtz; /* True if trailing zeros should be removed */ |
1142 | int flag_rtz; /* True if trailing zeros should be removed */ |
1283 | int flag_exp; /* True to force display of the exponent */ |
1143 | int flag_exp; /* True to force display of the exponent */ |
1284 | int nsd; /* Number of significant digits returned */ |
1144 | int nsd; /* Number of significant digits returned */ |
1285 | #endif |
1145 | #endif |
1286 | 1146 | ||
1287 | fmt = format; /* Put in a register for speed */ |
1147 | fmt = format; /* Put in a register for speed */ |
1288 | count = length = 0; |
1148 | count = length = 0; |
1289 | bufpt = 0; |
1149 | bufpt = 0; |
1290 | for (; (c = (*fmt)) != 0; ++fmt) |
1150 | for(; (c=(*fmt))!=0; ++fmt){ |
1291 | { |
- | |
1292 | if (c != '%') |
- | |
1293 | { |
1151 | if( c!='%' ){ |
1294 | register int amt; |
1152 | register int amt; |
1295 | bufpt = (char *) fmt; |
1153 | bufpt = (char *)fmt; |
1296 | amt = 1; |
1154 | amt = 1; |
1297 | while ((c = (*++fmt)) != '%' && c != 0) |
1155 | while( (c=(*++fmt))!='%' && c!=0 ) amt++; |
1298 | amt++; |
- | |
1299 | (*func) (arg, bufpt, amt); |
1156 | (*func)(arg,bufpt,amt); |
1300 | count += amt; |
1157 | count += amt; |
1301 | if (c == 0) |
- | |
1302 | break; |
1158 | if( c==0 ) break; |
1303 | } |
1159 | } |
1304 | if ((c = (*++fmt)) == 0) |
1160 | if( (c=(*++fmt))==0 ){ |
1305 | { |
- | |
1306 | errorflag = 1; |
1161 | errorflag = 1; |
1307 | (*func) (arg, "%", 1); |
1162 | (*func)(arg,"%",1); |
1308 | count++; |
1163 | count++; |
1309 | break; |
1164 | break; |
1310 | } |
1165 | } |
1311 | /* Find out what flags are present */ |
1166 | /* Find out what flags are present */ |
1312 | flag_leftjustify = flag_plussign = flag_blanksign = flag_alternateform = |
1167 | flag_leftjustify = flag_plussign = flag_blanksign = |
1313 | flag_zeropad = flag_center = 0; |
1168 | flag_alternateform = flag_zeropad = flag_center = 0; |
1314 | do |
1169 | do{ |
1315 | { |
1170 | switch( c ){ |
1316 | switch (c) |
- | |
1317 | { |
- | |
1318 | case '-': |
- | |
1319 | flag_leftjustify = 1; |
- | |
1320 | c = 0; |
- | |
1321 | break; |
1171 | case '-': flag_leftjustify = 1; c = 0; break; |
1322 | case '+': |
- | |
1323 | flag_plussign = 1; |
- | |
1324 | c = 0; |
- | |
1325 | break; |
1172 | case '+': flag_plussign = 1; c = 0; break; |
1326 | case ' ': |
- | |
1327 | flag_blanksign = 1; |
- | |
1328 | c = 0; |
- | |
1329 | break; |
1173 | case ' ': flag_blanksign = 1; c = 0; break; |
1330 | case '#': |
- | |
1331 | flag_alternateform = 1; |
1174 | case '#': flag_alternateform = 1; c = 0; break; |
1332 | c = 0; |
- | |
1333 | break; |
- | |
1334 | case '0': |
- | |
1335 | flag_zeropad = 1; |
- | |
1336 | c = 0; |
- | |
1337 | break; |
1175 | case '0': flag_zeropad = 1; c = 0; break; |
1338 | case '=': |
- | |
1339 | flag_center = 1; |
- | |
1340 | c = 0; |
- | |
1341 | break; |
1176 | case '=': flag_center = 1; c = 0; break; |
1342 | default: |
- | |
1343 | break; |
1177 | default: break; |
1344 | } |
1178 | } |
1345 | } while (c == 0 && (c = (*++fmt)) != 0); |
1179 | }while( c==0 && (c=(*++fmt))!=0 ); |
1346 | if (flag_center) |
- | |
1347 | flag_leftjustify = 0; |
1180 | if( flag_center ) flag_leftjustify = 0; |
1348 | /* Get the field width */ |
1181 | /* Get the field width */ |
1349 | width = 0; |
1182 | width = 0; |
1350 | if (c == '*') |
- | |
1351 | { |
1183 | if( c=='*' ){ |
1352 | width = va_arg (ap, int); |
1184 | width = va_arg(ap,int); |
1353 | if (width < 0) |
- | |
1354 | { |
1185 | if( width<0 ){ |
1355 | flag_leftjustify = 1; |
1186 | flag_leftjustify = 1; |
1356 | width = -width; |
- | |
1357 | } |
1187 | width = -width; |
1358 | c = *++fmt; |
- | |
1359 | } |
1188 | } |
1360 | else |
1189 | c = *++fmt; |
1361 | { |
1190 | }else{ |
1362 | while (isdigit (c)) |
- | |
1363 | { |
1191 | while( isdigit(c) ){ |
1364 | width = width * 10 + c - '0'; |
1192 | width = width*10 + c - '0'; |
1365 | c = *++fmt; |
1193 | c = *++fmt; |
1366 | } |
1194 | } |
1367 | } |
1195 | } |
1368 | if (width > etBUFSIZE - 10) |
1196 | if( width > etBUFSIZE-10 ){ |
1369 | { |
- | |
1370 | width = etBUFSIZE - 10; |
1197 | width = etBUFSIZE-10; |
1371 | } |
1198 | } |
1372 | /* Get the precision */ |
1199 | /* Get the precision */ |
1373 | if (c == '.') |
- | |
1374 | { |
1200 | if( c=='.' ){ |
1375 | precision = 0; |
1201 | precision = 0; |
1376 | c = *++fmt; |
1202 | c = *++fmt; |
1377 | if (c == '*') |
- | |
1378 | { |
1203 | if( c=='*' ){ |
1379 | precision = va_arg (ap, int); |
1204 | precision = va_arg(ap,int); |
1380 | #ifndef etCOMPATIBILITY |
1205 | #ifndef etCOMPATIBILITY |
1381 | /* This is sensible, but SUN OS 4.1 doesn't do it. */ |
1206 | /* This is sensible, but SUN OS 4.1 doesn't do it. */ |
1382 | if (precision < 0) |
- | |
1383 | precision = -precision; |
1207 | if( precision<0 ) precision = -precision; |
1384 | #endif |
1208 | #endif |
1385 | c = *++fmt; |
- | |
1386 | } |
1209 | c = *++fmt; |
1387 | else |
1210 | }else{ |
1388 | { |
1211 | while( isdigit(c) ){ |
1389 | while (isdigit (c)) |
- | |
1390 | { |
- | |
1391 | precision = precision * 10 + c - '0'; |
1212 | precision = precision*10 + c - '0'; |
1392 | c = *++fmt; |
1213 | c = *++fmt; |
1393 | } |
1214 | } |
1394 | } |
1215 | } |
1395 | /* Limit the precision to prevent overflowing buf[] during conversion |
1216 | /* Limit the precision to prevent overflowing buf[] during conversion */ |
1396 | */ |
- | |
1397 | if (precision > etBUFSIZE - 40) |
- | |
1398 | precision = etBUFSIZE - 40; |
1217 | if( precision>etBUFSIZE-40 ) precision = etBUFSIZE-40; |
1399 | } |
- | |
1400 | else |
1218 | }else{ |
1401 | { |
- | |
1402 | precision = -1; |
1219 | precision = -1; |
1403 | } |
1220 | } |
1404 | /* Get the conversion type modifier */ |
1221 | /* Get the conversion type modifier */ |
1405 | if (c == 'l') |
- | |
1406 | { |
1222 | if( c=='l' ){ |
1407 | flag_long = 1; |
1223 | flag_long = 1; |
1408 | c = *++fmt; |
- | |
1409 | } |
1224 | c = *++fmt; |
1410 | else |
1225 | }else{ |
1411 | { |
- | |
1412 | flag_long = 0; |
1226 | flag_long = 0; |
1413 | } |
1227 | } |
1414 | /* Fetch the info entry for the field */ |
1228 | /* Fetch the info entry for the field */ |
1415 | infop = 0; |
1229 | infop = 0; |
1416 | for (idx = 0; idx < etNINFO; idx++) |
1230 | for(idx=0; idx<etNINFO; idx++){ |
1417 | { |
- | |
1418 | if (c == fmtinfo[idx].fmttype) |
1231 | if( c==fmtinfo[idx].fmttype ){ |
1419 | { |
- | |
1420 | infop = &fmtinfo[idx]; |
1232 | infop = &fmtinfo[idx]; |
1421 | break; |
1233 | break; |
1422 | } |
1234 | } |
1423 | } |
1235 | } |
1424 | /* No info entry found. It must be an error. */ |
1236 | /* No info entry found. It must be an error. */ |
1425 | if (infop == 0) |
- | |
1426 | { |
1237 | if( infop==0 ){ |
1427 | xtype = etERROR; |
1238 | xtype = etERROR; |
1428 | } |
- | |
1429 | else |
1239 | }else{ |
1430 | { |
- | |
1431 | xtype = infop->type; |
1240 | xtype = infop->type; |
1432 | } |
1241 | } |
1433 | zExtra = 0; |
1242 | zExtra = 0; |
1434 | 1243 | ||
1435 | /* |
1244 | /* |
1436 | ** At this point, variables are initialized as follows: |
1245 | ** At this point, variables are initialized as follows: |
1437 | ** |
1246 | ** |
1438 | ** flag_alternateform TRUE if a '#' is present. |
1247 | ** flag_alternateform TRUE if a '#' is present. |
1439 | ** flag_plussign TRUE if a '+' is present. |
1248 | ** flag_plussign TRUE if a '+' is present. |
1440 | ** flag_leftjustify TRUE if a '-' is present or if the |
1249 | ** flag_leftjustify TRUE if a '-' is present or if the |
1441 | ** field width was negative. |
1250 | ** field width was negative. |
1442 | ** flag_zeropad TRUE if the width began with 0. |
1251 | ** flag_zeropad TRUE if the width began with 0. |
1443 | ** flag_long TRUE if the letter 'l' (ell) prefixed |
1252 | ** flag_long TRUE if the letter 'l' (ell) prefixed |
1444 | ** the conversion character. |
1253 | ** the conversion character. |
1445 | ** flag_blanksign TRUE if a ' ' is present. |
1254 | ** flag_blanksign TRUE if a ' ' is present. |
1446 | ** width The specified field width. This is |
1255 | ** width The specified field width. This is |
1447 | ** always non-negative. Zero is the default. |
1256 | ** always non-negative. Zero is the default. |
1448 | ** precision The specified precision. The default |
1257 | ** precision The specified precision. The default |
1449 | ** is -1. |
1258 | ** is -1. |
1450 | ** xtype The class of the conversion. |
1259 | ** xtype The class of the conversion. |
1451 | ** infop Pointer to the appropriate info struct. |
1260 | ** infop Pointer to the appropriate info struct. |
1452 | */ |
1261 | */ |
1453 | switch (xtype) |
1262 | switch( xtype ){ |
1454 | { |
- | |
1455 | case etORDINAL: |
1263 | case etORDINAL: |
1456 | case etRADIX: |
1264 | case etRADIX: |
1457 | if (flag_long) |
- | |
1458 | longvalue = va_arg (ap, long); |
1265 | if( flag_long ) longvalue = va_arg(ap,long); |
1459 | else |
- | |
1460 | longvalue = va_arg (ap, int); |
1266 | else longvalue = va_arg(ap,int); |
1461 | #ifdef etCOMPATIBILITY |
1267 | #ifdef etCOMPATIBILITY |
1462 | /* For the format %#x, the value zero is printed "0" not "0x0". |
1268 | /* For the format %#x, the value zero is printed "0" not "0x0". |
1463 | ** I think this is stupid. */ |
1269 | ** I think this is stupid. */ |
1464 | if (longvalue == 0) |
- | |
1465 | flag_alternateform = 0; |
1270 | if( longvalue==0 ) flag_alternateform = 0; |
1466 | #else |
1271 | #else |
1467 | /* More sensible: turn off the prefix for octal (to prevent "00"), |
1272 | /* More sensible: turn off the prefix for octal (to prevent "00"), |
1468 | ** but leave the prefix for hex. */ |
1273 | ** but leave the prefix for hex. */ |
1469 | if (longvalue == 0 && infop->base == 8) |
- | |
1470 | flag_alternateform = 0; |
1274 | if( longvalue==0 && infop->base==8 ) flag_alternateform = 0; |
1471 | #endif |
1275 | #endif |
1472 | if (infop->flag_signed) |
1276 | if( infop->flag_signed ){ |
1473 | { |
- | |
1474 | if (*(long *) &longvalue < 0) |
1277 | if( *(long*)&longvalue<0 ){ |
1475 | { |
- | |
1476 | longvalue = -*(long *) &longvalue; |
1278 | longvalue = -*(long*)&longvalue; |
1477 | prefix = '-'; |
- | |
1478 | } |
1279 | prefix = '-'; |
1479 | else if (flag_plussign) |
- | |
1480 | prefix = '+'; |
1280 | }else if( flag_plussign ) prefix = '+'; |
1481 | else if (flag_blanksign) |
- | |
1482 | prefix = ' '; |
1281 | else if( flag_blanksign ) prefix = ' '; |
1483 | else |
- | |
1484 | prefix = 0; |
1282 | else prefix = 0; |
1485 | } |
- | |
1486 | else |
- | |
1487 | prefix = 0; |
1283 | }else prefix = 0; |
1488 | if (flag_zeropad && precision < width - (prefix != 0)) |
1284 | if( flag_zeropad && precision<width-(prefix!=0) ){ |
1489 | { |
- | |
1490 | precision = width - (prefix != 0); |
1285 | precision = width-(prefix!=0); |
1491 | } |
1286 | } |
1492 | bufpt = &buf[etBUFSIZE]; |
1287 | bufpt = &buf[etBUFSIZE]; |
1493 | if (xtype == etORDINAL) |
1288 | if( xtype==etORDINAL ){ |
1494 | { |
1289 | long a,b; |
1495 | long a, b; |
- | |
1496 | a = longvalue % 10; |
1290 | a = longvalue%10; |
1497 | b = longvalue % 100; |
1291 | b = longvalue%100; |
1498 | bufpt -= 2; |
1292 | bufpt -= 2; |
1499 | if (a == 0 || a > 3 || (b > 10 && b < 14)) |
1293 | if( a==0 || a>3 || (b>10 && b<14) ){ |
1500 | { |
1294 | bufpt[0] = 't'; |
1501 | bufpt[0] = 't'; |
- | |
1502 | bufpt[1] = 'h'; |
- | |
1503 | } |
1295 | bufpt[1] = 'h'; |
1504 | else if (a == 1) |
- | |
1505 | { |
1296 | }else if( a==1 ){ |
1506 | bufpt[0] = 's'; |
1297 | bufpt[0] = 's'; |
1507 | bufpt[1] = 't'; |
- | |
1508 | } |
1298 | bufpt[1] = 't'; |
1509 | else if (a == 2) |
- | |
1510 | { |
1299 | }else if( a==2 ){ |
1511 | bufpt[0] = 'n'; |
1300 | bufpt[0] = 'n'; |
1512 | bufpt[1] = 'd'; |
- | |
1513 | } |
1301 | bufpt[1] = 'd'; |
1514 | else if (a == 3) |
- | |
1515 | { |
1302 | }else if( a==3 ){ |
1516 | bufpt[0] = 'r'; |
1303 | bufpt[0] = 'r'; |
1517 | bufpt[1] = 'd'; |
1304 | bufpt[1] = 'd'; |
1518 | } |
1305 | } |
1519 | } |
1306 | } |
1520 | { |
1307 | { |
1521 | register char *cset; /* Use registers for speed */ |
1308 | register char *cset; /* Use registers for speed */ |
1522 | register int base; |
1309 | register int base; |
1523 | cset = infop->charset; |
1310 | cset = infop->charset; |
1524 | base = infop->base; |
1311 | base = infop->base; |
1525 | do |
- | |
1526 | { /* Convert to ascii */ |
1312 | do{ /* Convert to ascii */ |
1527 | *(--bufpt) = cset[longvalue % base]; |
1313 | *(--bufpt) = cset[longvalue%base]; |
1528 | longvalue = longvalue / base; |
1314 | longvalue = longvalue/base; |
1529 | } while (longvalue > 0); |
1315 | }while( longvalue>0 ); |
1530 | } |
1316 | } |
1531 | length = (long) &buf[etBUFSIZE] - (long) bufpt; |
1317 | length = (long)&buf[etBUFSIZE]-(long)bufpt; |
1532 | for (idx = precision - length; idx > 0; idx--) |
1318 | for(idx=precision-length; idx>0; idx--){ |
1533 | { |
- | |
1534 | *(--bufpt) = '0'; /* Zero pad */ |
1319 | *(--bufpt) = '0'; /* Zero pad */ |
1535 | } |
1320 | } |
1536 | if (prefix) |
- | |
1537 | *(--bufpt) = prefix; /* Add sign */ |
1321 | if( prefix ) *(--bufpt) = prefix; /* Add sign */ |
1538 | if (flag_alternateform && infop->prefix) |
- | |
1539 | { /* Add "0" or "0x" */ |
1322 | if( flag_alternateform && infop->prefix ){ /* Add "0" or "0x" */ |
1540 | char *pre, x; |
1323 | char *pre, x; |
1541 | pre = infop->prefix; |
1324 | pre = infop->prefix; |
1542 | if (*bufpt != pre[0]) |
- | |
1543 | { |
1325 | if( *bufpt!=pre[0] ){ |
1544 | for (pre = infop->prefix; (x = (*pre)) != 0; pre++) |
- | |
1545 | *(--bufpt) = x; |
1326 | for(pre=infop->prefix; (x=(*pre))!=0; pre++) *(--bufpt) = x; |
1546 | } |
1327 | } |
1547 | } |
1328 | } |
1548 | length = (long) &buf[etBUFSIZE] - (long) bufpt; |
1329 | length = (long)&buf[etBUFSIZE]-(long)bufpt; |
1549 | break; |
1330 | break; |
1550 | case etFLOAT: |
1331 | case etFLOAT: |
1551 | case etEXP: |
1332 | case etEXP: |
1552 | case etGENERIC: |
1333 | case etGENERIC: |
1553 | realvalue = va_arg (ap, double); |
1334 | realvalue = va_arg(ap,double); |
1554 | #ifndef etNOFLOATINGPOINT |
1335 | #ifndef etNOFLOATINGPOINT |
1555 | if (precision < 0) |
- | |
1556 | precision = 6; /* Set default precision */ |
1336 | if( precision<0 ) precision = 6; /* Set default precision */ |
1557 | if (precision > etBUFSIZE - 10) |
- | |
1558 | precision = etBUFSIZE - 10; |
1337 | if( precision>etBUFSIZE-10 ) precision = etBUFSIZE-10; |
1559 | if (realvalue < 0.0) |
1338 | if( realvalue<0.0 ){ |
1560 | { |
- | |
1561 | realvalue = -realvalue; |
1339 | realvalue = -realvalue; |
1562 | prefix = '-'; |
- | |
1563 | } |
1340 | prefix = '-'; |
1564 | else |
1341 | }else{ |
1565 | { |
- | |
1566 | if (flag_plussign) |
- | |
1567 | prefix = '+'; |
1342 | if( flag_plussign ) prefix = '+'; |
1568 | else if (flag_blanksign) |
- | |
1569 | prefix = ' '; |
1343 | else if( flag_blanksign ) prefix = ' '; |
1570 | else |
- | |
1571 | prefix = 0; |
1344 | else prefix = 0; |
1572 | } |
1345 | } |
1573 | if (infop->type == etGENERIC && precision > 0) |
1346 | if( infop->type==etGENERIC && precision>0 ) precision--; |
1574 | precision--; |
- | |
1575 | rounder = 0.0; |
1347 | rounder = 0.0; |
1576 | #ifdef COMPATIBILITY |
1348 | #ifdef COMPATIBILITY |
1577 | /* Rounding works like BSD when the constant 0.4999 is used. Wierd! */ |
1349 | /* Rounding works like BSD when the constant 0.4999 is used. Wierd! */ |
1578 | for (idx = precision, rounder = 0.4999; idx > 0; idx--, rounder *= 0.1) |
1350 | for(idx=precision, rounder=0.4999; idx>0; idx--, rounder*=0.1); |
1579 | ; |
- | |
1580 | #else |
1351 | #else |
1581 | /* It makes more sense to use 0.5 */ |
1352 | /* It makes more sense to use 0.5 */ |
1582 | for (idx = precision, rounder = 0.5; idx > 0; idx--, rounder *= 0.1) |
1353 | for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1); |
1583 | ; |
1354 | #endif |
1584 | #endif |
1355 | if( infop->type==etFLOAT ) realvalue += rounder; |
1585 | if (infop->type == etFLOAT) |
1356 | /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */ |
1586 | realvalue += rounder; |
1357 | exp = 0; |
1587 | /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */ |
1358 | if( realvalue>0.0 ){ |
1588 | exp = 0; |
1359 | int k = 0; |
1589 | if (realvalue > 0.0) |
1360 | while( realvalue>=1e8 && k++<100 ){ realvalue *= 1e-8; exp+=8; } |
1590 | { |
1361 | while( realvalue>=10.0 && k++<100 ){ realvalue *= 0.1; exp++; } |
1591 | int k = 0; |
1362 | while( realvalue<1e-8 && k++<100 ){ realvalue *= 1e8; exp-=8; } |
1592 | while (realvalue >= 1e8 && k++ < 100) |
1363 | while( realvalue<1.0 && k++<100 ){ realvalue *= 10.0; exp--; } |
1593 | { |
1364 | if( k>=100 ){ |
1594 | realvalue *= 1e-8; |
1365 | bufpt = "NaN"; |
1595 | exp += 8; |
1366 | length = 3; |
1596 | } |
1367 | break; |
1597 | while (realvalue >= 10.0 && k++ < 100) |
1368 | } |
1598 | { |
1369 | } |
1599 | realvalue *= 0.1; |
1370 | bufpt = buf; |
1600 | exp++; |
1371 | /* |
1601 | } |
1372 | ** If the field type is etGENERIC, then convert to either etEXP |
1602 | while (realvalue < 1e-8 && k++ < 100) |
1373 | ** or etFLOAT, as appropriate. |
1603 | { |
1374 | */ |
1604 | realvalue *= 1e8; |
1375 | flag_exp = xtype==etEXP; |
1605 | exp -= 8; |
1376 | if( xtype!=etFLOAT ){ |
1606 | } |
1377 | realvalue += rounder; |
1607 | while (realvalue < 1.0 && k++ < 100) |
1378 | if( realvalue>=10.0 ){ realvalue *= 0.1; exp++; } |
1608 | { |
1379 | } |
1609 | realvalue *= 10.0; |
1380 | if( xtype==etGENERIC ){ |
1610 | exp--; |
1381 | flag_rtz = !flag_alternateform; |
1611 | } |
1382 | if( exp<-4 || exp>precision ){ |
1612 | if (k >= 100) |
1383 | xtype = etEXP; |
1613 | { |
1384 | }else{ |
1614 | bufpt = "NaN"; |
1385 | precision = precision - exp; |
1615 | length = 3; |
1386 | xtype = etFLOAT; |
1616 | break; |
1387 | } |
1617 | } |
1388 | }else{ |
1618 | } |
1389 | flag_rtz = 0; |
1619 | bufpt = buf; |
1390 | } |
1620 | /* |
1391 | /* |
1621 | ** If the field type is etGENERIC, then convert to either etEXP |
1392 | ** The "exp+precision" test causes output to be of type etEXP if |
1622 | ** or etFLOAT, as appropriate. |
1393 | ** the precision is too large to fit in buf[]. |
1623 | */ |
1394 | */ |
1624 | flag_exp = xtype == etEXP; |
1395 | nsd = 0; |
1625 | if (xtype != etFLOAT) |
1396 | if( xtype==etFLOAT && exp+precision<etBUFSIZE-30 ){ |
1626 | { |
1397 | flag_dp = (precision>0 || flag_alternateform); |
1627 | realvalue += rounder; |
1398 | if( prefix ) *(bufpt++) = prefix; /* Sign */ |
1628 | if (realvalue >= 10.0) |
1399 | if( exp<0 ) *(bufpt++) = '0'; /* Digits before "." */ |
1629 | { |
1400 | else for(; exp>=0; exp--) *(bufpt++) = et_getdigit(&realvalue,&nsd); |
1630 | realvalue *= 0.1; |
1401 | if( flag_dp ) *(bufpt++) = '.'; /* The decimal point */ |
1631 | exp++; |
1402 | for(exp++; exp<0 && precision>0; precision--, exp++){ |
1632 | } |
1403 | *(bufpt++) = '0'; |
1633 | } |
1404 | } |
1634 | if (xtype == etGENERIC) |
1405 | while( (precision--)>0 ) *(bufpt++) = et_getdigit(&realvalue,&nsd); |
1635 | { |
1406 | *(bufpt--) = 0; /* Null terminate */ |
1636 | flag_rtz = !flag_alternateform; |
1407 | if( flag_rtz && flag_dp ){ /* Remove trailing zeros and "." */ |
1637 | if (exp < -4 || exp > precision) |
1408 | while( bufpt>=buf && *bufpt=='0' ) *(bufpt--) = 0; |
1638 | { |
1409 | if( bufpt>=buf && *bufpt=='.' ) *(bufpt--) = 0; |
1639 | xtype = etEXP; |
1410 | } |
1640 | } |
1411 | bufpt++; /* point to next free slot */ |
1641 | else |
1412 | }else{ /* etEXP or etGENERIC */ |
1642 | { |
1413 | flag_dp = (precision>0 || flag_alternateform); |
1643 | precision = precision - exp; |
1414 | if( prefix ) *(bufpt++) = prefix; /* Sign */ |
1644 | xtype = etFLOAT; |
1415 | *(bufpt++) = et_getdigit(&realvalue,&nsd); /* First digit */ |
1645 | } |
1416 | if( flag_dp ) *(bufpt++) = '.'; /* Decimal point */ |
1646 | } |
1417 | while( (precision--)>0 ) *(bufpt++) = et_getdigit(&realvalue,&nsd); |
1647 | else |
1418 | bufpt--; /* point to last digit */ |
1648 | { |
1419 | if( flag_rtz && flag_dp ){ /* Remove tail zeros */ |
1649 | flag_rtz = 0; |
1420 | while( bufpt>=buf && *bufpt=='0' ) *(bufpt--) = 0; |
1650 | } |
1421 | if( bufpt>=buf && *bufpt=='.' ) *(bufpt--) = 0; |
1651 | /* |
1422 | } |
1652 | ** The "exp+precision" test causes output to be of type etEXP if |
1423 | bufpt++; /* point to next free slot */ |
1653 | ** the precision is too large to fit in buf[]. |
1424 | if( exp || flag_exp ){ |
1654 | */ |
1425 | *(bufpt++) = infop->charset[0]; |
1655 | nsd = 0; |
1426 | if( exp<0 ){ *(bufpt++) = '-'; exp = -exp; } /* sign of exp */ |
1656 | if (xtype == etFLOAT && exp + precision < etBUFSIZE - 30) |
1427 | else { *(bufpt++) = '+'; } |
1657 | { |
1428 | if( exp>=100 ){ |
1658 | flag_dp = (precision > 0 || flag_alternateform); |
1429 | *(bufpt++) = (exp/100)+'0'; /* 100's digit */ |
1659 | if (prefix) |
1430 | exp %= 100; |
1660 | *(bufpt++) = prefix; /* Sign */ |
1431 | } |
1661 | if (exp < 0) |
1432 | *(bufpt++) = exp/10+'0'; /* 10's digit */ |
1662 | *(bufpt++) = '0'; /* Digits before "." */ |
1433 | *(bufpt++) = exp%10+'0'; /* 1's digit */ |
1663 | else |
1434 | } |
1664 | for (; exp >= 0; exp--) |
1435 | } |
1665 | *(bufpt++) = et_getdigit (&realvalue, &nsd); |
1436 | /* The converted number is in buf[] and zero terminated. Output it. |
1666 | if (flag_dp) |
1437 | ** Note that the number is in the usual order, not reversed as with |
1667 | *(bufpt++) = '.'; /* The decimal point */ |
1438 | ** integer conversions. */ |
1668 | for (exp++; exp < 0 && precision > 0; precision--, exp++) |
1439 | length = (long)bufpt-(long)buf; |
1669 | { |
1440 | bufpt = buf; |
1670 | *(bufpt++) = '0'; |
1441 | |
1671 | } |
1442 | /* Special case: Add leading zeros if the flag_zeropad flag is |
1672 | while ((precision--) > 0) |
1443 | ** set and we are not left justified */ |
1673 | *(bufpt++) = et_getdigit (&realvalue, &nsd); |
1444 | if( flag_zeropad && !flag_leftjustify && length < width){ |
1674 | *(bufpt--) = 0; /* Null terminate */ |
1445 | int i; |
1675 | if (flag_rtz && flag_dp) |
1446 | int nPad = width - length; |
1676 | { /* Remove trailing zeros and "." */ |
1447 | for(i=width; i>=nPad; i--){ |
1677 | while (bufpt >= buf && *bufpt == '0') |
1448 | bufpt[i] = bufpt[i-nPad]; |
1678 | *(bufpt--) = 0; |
1449 | } |
1679 | if (bufpt >= buf && *bufpt == '.') |
1450 | i = prefix!=0; |
1680 | *(bufpt--) = 0; |
1451 | while( nPad-- ) bufpt[i++] = '0'; |
1681 | } |
1452 | length = width; |
1682 | bufpt++; /* point to next free slot */ |
1453 | } |
1683 | } |
1454 | #endif |
1684 | else |
1455 | break; |
1685 | { /* etEXP or etGENERIC */ |
1456 | case etSIZE: |
1686 | flag_dp = (precision > 0 || flag_alternateform); |
1457 | *(va_arg(ap,int*)) = count; |
1687 | if (prefix) |
1458 | length = width = 0; |
1688 | *(bufpt++) = prefix; /* Sign */ |
1459 | break; |
1689 | *(bufpt++) = et_getdigit (&realvalue, &nsd); /* First digit */ |
1460 | case etPERCENT: |
1690 | if (flag_dp) |
1461 | buf[0] = '%'; |
1691 | *(bufpt++) = '.'; /* Decimal point */ |
1462 | bufpt = buf; |
1692 | while ((precision--) > 0) |
1463 | length = 1; |
1693 | *(bufpt++) = et_getdigit (&realvalue, &nsd); |
1464 | break; |
1694 | bufpt--; /* point to last digit */ |
1465 | case etCHARLIT: |
1695 | if (flag_rtz && flag_dp) |
1466 | case etCHARX: |
1696 | { /* Remove tail zeros */ |
1467 | c = buf[0] = (xtype==etCHARX ? va_arg(ap,int) : *++fmt); |
1697 | while (bufpt >= buf && *bufpt == '0') |
1468 | if( precision>=0 ){ |
1698 | *(bufpt--) = 0; |
1469 | for(idx=1; idx<precision; idx++) buf[idx] = c; |
1699 | if (bufpt >= buf && *bufpt == '.') |
1470 | length = precision; |
1700 | *(bufpt--) = 0; |
1471 | }else{ |
1701 | } |
1472 | length =1; |
1702 | bufpt++; /* point to next free slot */ |
1473 | } |
1703 | if (exp || flag_exp) |
1474 | bufpt = buf; |
1704 | { |
1475 | break; |
1705 | *(bufpt++) = infop->charset[0]; |
1476 | case etSTRING: |
1706 | if (exp < 0) |
1477 | case etMEMSTRING: |
1707 | { |
1478 | zMem = bufpt = va_arg(ap,char*); |
1708 | *(bufpt++) = '-'; |
1479 | if( bufpt==0 ) bufpt = "(null)"; |
1709 | exp = -exp; |
1480 | length = strlen(bufpt); |
1710 | } /* sign of exp */ |
1481 | if( precision>=0 && precision<length ) length = precision; |
1711 | else |
1482 | break; |
1712 | { |
1483 | case etTCLESCAPE: |
1713 | *(bufpt++) = '+'; |
1484 | { |
1714 | } |
1485 | int i, j, n, c, k; |
1715 | if (exp >= 100) |
1486 | char *arg = va_arg(ap,char*); |
1716 | { |
1487 | if( arg==0 ) arg = "(NULL)"; |
1717 | *(bufpt++) = |
1488 | for(i=n=0; (c=arg[i])!=0; i++){ |
1718 | (exp / 100) + '0'; /* 100's digit */ |
1489 | k = NeedEsc[c&0xff]; |
1719 | exp %= 100; |
1490 | if( k==0 ){ |
1720 | } |
1491 | n++; |
1721 | *(bufpt++) = exp / 10 + '0'; /* 10's digit */ |
1492 | }else if( k==1 ){ |
1722 | *(bufpt++) = exp % 10 + '0'; /* 1's digit */ |
1493 | n+=4; |
1723 | } |
1494 | }else{ |
1724 | } |
1495 | n+=2; |
1725 | /* The converted number is in buf[] and zero terminated. Output it. |
1496 | } |
1726 | ** Note that the number is in the usual order, not reversed as with |
1497 | } |
1727 | ** integer conversions. */ |
1498 | n++; |
1728 | length = (long) bufpt - (long) buf; |
1499 | if( n>etBUFSIZE ){ |
1729 | bufpt = buf; |
1500 | bufpt = zExtra = Tcl_Alloc( n ); |
1730 | 1501 | }else{ |
|
1731 | /* Special case: Add leading zeros if the flag_zeropad flag is |
1502 | bufpt = buf; |
1732 | ** set and we are not left justified */ |
1503 | } |
1733 | if (flag_zeropad && !flag_leftjustify && length < width) |
1504 | for(i=j=0; (c=arg[i])!=0; i++){ |
1734 | { |
1505 | k = NeedEsc[c&0xff]; |
1735 | int i; |
1506 | if( k==0 ){ |
1736 | int nPad = width - length; |
1507 | bufpt[j++] = c; |
1737 | for (i = width; i >= nPad; i--) |
1508 | }else if( k==1 ){ |
1738 | { |
1509 | bufpt[j++] = '\\'; |
1739 | bufpt[i] = bufpt[i - nPad]; |
1510 | bufpt[j++] = ((c>>6) & 3) + '0'; |
1740 | } |
1511 | bufpt[j++] = ((c>>3) & 7) + '0'; |
1741 | i = prefix != 0; |
1512 | bufpt[j++] = (c & 7) + '0'; |
1742 | while (nPad--) |
1513 | }else{ |
1743 | bufpt[i++] = '0'; |
1514 | bufpt[j++] = '\\'; |
1744 | length = width; |
1515 | bufpt[j++] = k; |
1745 | } |
1516 | } |
1746 | #endif |
1517 | } |
1747 | break; |
1518 | bufpt[j] = 0; |
1748 | case etSIZE: |
1519 | length = j; |
1749 | *(va_arg (ap, int *)) = count; |
1520 | if( precision>=0 && precision<length ) length = precision; |
1750 | length = width = 0; |
1521 | } |
1751 | break; |
1522 | break; |
1752 | case etPERCENT: |
1523 | case etERROR: |
1753 | buf[0] = '%'; |
1524 | buf[0] = '%'; |
1754 | bufpt = buf; |
1525 | buf[1] = c; |
1755 | length = 1; |
1526 | errorflag = 0; |
1756 | break; |
1527 | idx = 1+(c!=0); |
1757 | case etCHARLIT: |
1528 | (*func)(arg,"%",idx); |
1758 | case etCHARX: |
1529 | count += idx; |
1759 | c = buf[0] = (xtype == etCHARX ? va_arg (ap, int) : *++fmt); |
1530 | if( c==0 ) fmt--; |
1760 | if (precision >= 0) |
1531 | break; |
1761 | { |
1532 | }/* End switch over the format type */ |
1762 | for (idx = 1; idx < precision; idx++) |
1533 | /* |
1763 | buf[idx] = c; |
1534 | ** The text of the conversion is pointed to by "bufpt" and is |
1764 | length = precision; |
1535 | ** "length" characters long. The field width is "width". Do |
1765 | } |
1536 | ** the output. |
1766 | else |
1537 | */ |
1767 | { |
1538 | if( !flag_leftjustify ){ |
1768 | length = 1; |
1539 | register int nspace; |
1769 | } |
1540 | nspace = width-length; |
1770 | bufpt = buf; |
1541 | if( nspace>0 ){ |
1771 | break; |
1542 | if( flag_center ){ |
1772 | case etSTRING: |
1543 | nspace = nspace/2; |
1773 | case etMEMSTRING: |
1544 | width -= nspace; |
1774 | zMem = bufpt = va_arg (ap, char *); |
1545 | flag_leftjustify = 1; |
1775 | if (bufpt == 0) |
1546 | } |
1776 | bufpt = "(null)"; |
1547 | count += nspace; |
1777 | length = strlen (bufpt); |
1548 | while( nspace>=etSPACESIZE ){ |
1778 | if (precision >= 0 && precision < length) |
1549 | (*func)(arg,spaces,etSPACESIZE); |
1779 | length = precision; |
1550 | nspace -= etSPACESIZE; |
1780 | break; |
1551 | } |
1781 | case etTCLESCAPE: |
1552 | if( nspace>0 ) (*func)(arg,spaces,nspace); |
1782 | { |
1553 | } |
1783 | int i, j, n, c, k; |
1554 | } |
1784 | char *arg = va_arg (ap, char *); |
1555 | if( length>0 ){ |
1785 | if (arg == 0) |
1556 | (*func)(arg,bufpt,length); |
1786 | arg = "(NULL)"; |
1557 | count += length; |
1787 | for (i = n = 0; (c = arg[i]) != 0; i++) |
1558 | } |
1788 | { |
1559 | if( xtype==etMEMSTRING && zMem ){ |
1789 | k = NeedEsc[c & 0xff]; |
1560 | Tcl_Free(zMem); |
1790 | if (k == 0) |
1561 | } |
1791 | { |
1562 | if( flag_leftjustify ){ |
1792 | n++; |
1563 | register int nspace; |
1793 | } |
1564 | nspace = width-length; |
1794 | else if (k == 1) |
1565 | if( nspace>0 ){ |
1795 | { |
1566 | count += nspace; |
1796 | n += 4; |
1567 | while( nspace>=etSPACESIZE ){ |
1797 | } |
1568 | (*func)(arg,spaces,etSPACESIZE); |
1798 | else |
1569 | nspace -= etSPACESIZE; |
1799 | { |
1570 | } |
1800 | n += 2; |
1571 | if( nspace>0 ) (*func)(arg,spaces,nspace); |
1801 | } |
1572 | } |
1802 | } |
1573 | } |
1803 | n++; |
1574 | if( zExtra ){ |
1804 | if (n > etBUFSIZE) |
1575 | Tcl_Free(zExtra); |
1805 | { |
1576 | } |
1806 | bufpt = zExtra = Tcl_Alloc (n); |
1577 | }/* End for loop over the format string */ |
1807 | } |
1578 | return errorflag ? -1 : count; |
1808 | else |
- | |
1809 | { |
- | |
1810 | bufpt = buf; |
- | |
1811 | } |
- | |
1812 | for (i = j = 0; (c = arg[i]) != 0; i++) |
- | |
1813 | { |
- | |
1814 | k = NeedEsc[c & 0xff]; |
- | |
1815 | if (k == 0) |
- | |
1816 | { |
- | |
1817 | bufpt[j++] = c; |
- | |
1818 | } |
- | |
1819 | else if (k == 1) |
- | |
1820 | { |
- | |
1821 | bufpt[j++] = '\\'; |
- | |
1822 | bufpt[j++] = ((c >> 6) & 3) + '0'; |
- | |
1823 | bufpt[j++] = ((c >> 3) & 7) + '0'; |
- | |
1824 | bufpt[j++] = (c & 7) + '0'; |
- | |
1825 | } |
- | |
1826 | else |
- | |
1827 | { |
- | |
1828 | bufpt[j++] = '\\'; |
- | |
1829 | bufpt[j++] = k; |
- | |
1830 | } |
- | |
1831 | } |
- | |
1832 | bufpt[j] = 0; |
- | |
1833 | length = j; |
- | |
1834 | if (precision >= 0 && precision < length) |
- | |
1835 | length = precision; |
- | |
1836 | } |
- | |
1837 | break; |
- | |
1838 | case etERROR: |
- | |
1839 | buf[0] = '%'; |
- | |
1840 | buf[1] = c; |
- | |
1841 | errorflag = 0; |
- | |
1842 | idx = 1 + (c != 0); |
- | |
1843 | (*func) (arg, "%", idx); |
- | |
1844 | count += idx; |
- | |
1845 | if (c == 0) |
- | |
1846 | fmt--; |
- | |
1847 | break; |
- | |
1848 | } /* End switch over the format type */ |
- | |
1849 | /* |
- | |
1850 | ** The text of the conversion is pointed to by "bufpt" and is |
- | |
1851 | ** "length" characters long. The field width is "width". Do |
- | |
1852 | ** the output. |
- | |
1853 | */ |
- | |
1854 | if (!flag_leftjustify) |
- | |
1855 | { |
- | |
1856 | register int nspace; |
- | |
1857 | nspace = width - length; |
- | |
1858 | if (nspace > 0) |
- | |
1859 | { |
- | |
1860 | if (flag_center) |
- | |
1861 | { |
- | |
1862 | nspace = nspace / 2; |
- | |
1863 | width -= nspace; |
- | |
1864 | flag_leftjustify = 1; |
- | |
1865 | } |
- | |
1866 | count += nspace; |
- | |
1867 | while (nspace >= etSPACESIZE) |
- | |
1868 | { |
- | |
1869 | (*func) (arg, spaces, etSPACESIZE); |
- | |
1870 | nspace -= etSPACESIZE; |
- | |
1871 | } |
- | |
1872 | if (nspace > 0) |
- | |
1873 | (*func) (arg, spaces, nspace); |
- | |
1874 | } |
- | |
1875 | } |
- | |
1876 | if (length > 0) |
- | |
1877 | { |
- | |
1878 | (*func) (arg, bufpt, length); |
- | |
1879 | count += length; |
- | |
1880 | } |
- | |
1881 | if (xtype == etMEMSTRING && zMem) |
- | |
1882 | { |
- | |
1883 | Tcl_Free (zMem); |
- | |
1884 | } |
- | |
1885 | if (flag_leftjustify) |
- | |
1886 | { |
- | |
1887 | register int nspace; |
- | |
1888 | nspace = width - length; |
- | |
1889 | if (nspace > 0) |
- | |
1890 | { |
- | |
1891 | count += nspace; |
- | |
1892 | while (nspace >= etSPACESIZE) |
- | |
1893 | { |
- | |
1894 | (*func) (arg, spaces, etSPACESIZE); |
- | |
1895 | nspace -= etSPACESIZE; |
- | |
1896 | } |
- | |
1897 | if (nspace > 0) |
- | |
1898 | (*func) (arg, spaces, nspace); |
- | |
1899 | } |
- | |
1900 | } |
- | |
1901 | if (zExtra) |
- | |
1902 | { |
- | |
1903 | Tcl_Free (zExtra); |
- | |
1904 | } |
- | |
1905 | } /* End for loop over the format string */ |
- | |
1906 | return errorflag ? -1 : count; |
- | |
1907 | } /* End of function */ |
1579 | } /* End of function */ |
1908 | 1580 | ||
1909 | /* |
1581 | /* |
1910 | ** The following section of code handles the mprintf routine, that |
1582 | ** The following section of code handles the mprintf routine, that |
1911 | ** writes to memory obtained from malloc(). |
1583 | ** writes to memory obtained from malloc(). |
1912 | */ |
1584 | */ |
1913 | 1585 | ||
1914 | /* This structure is used to store state information about the |
1586 | /* This structure is used to store state information about the |
1915 | ** write to memory that is currently in progress. |
1587 | ** write to memory that is currently in progress. |
1916 | */ |
1588 | */ |
1917 | struct sgMprintf |
1589 | struct sgMprintf { |
1918 | { |
- | |
1919 | char *zBase; /* A base allocation */ |
1590 | char *zBase; /* A base allocation */ |
1920 | char *zText; /* The string collected so far */ |
1591 | char *zText; /* The string collected so far */ |
1921 | int nChar; /* Length of the string so far */ |
1592 | int nChar; /* Length of the string so far */ |
1922 | int nAlloc; /* Amount of space allocated in zText */ |
1593 | int nAlloc; /* Amount of space allocated in zText */ |
1923 | }; |
1594 | }; |
1924 | 1595 | ||
1925 | /* |
1596 | /* |
1926 | ** The xprintf callback function. |
1597 | ** The xprintf callback function. |
1927 | ** |
1598 | ** |
1928 | ** This routine add nNewChar characters of text in zNewText to |
1599 | ** This routine add nNewChar characters of text in zNewText to |
1929 | ** the sgMprintf structure pointed to by "arg". |
1600 | ** the sgMprintf structure pointed to by "arg". |
1930 | */ |
1601 | */ |
1931 | static void mout (void *arg, char *zNewText, int nNewChar) |
1602 | static void mout(void *arg, char *zNewText, int nNewChar){ |
1932 | { |
- | |
1933 | struct sgMprintf *pM = (struct sgMprintf *) arg; |
1603 | struct sgMprintf *pM = (struct sgMprintf*)arg; |
1934 | if (pM->nChar + nNewChar + 1 > pM->nAlloc) |
1604 | if( pM->nChar + nNewChar + 1 > pM->nAlloc ){ |
1935 | { |
- | |
1936 | pM->nAlloc = pM->nChar + nNewChar * 2 + 1; |
1605 | pM->nAlloc = pM->nChar + nNewChar*2 + 1; |
1937 | if (pM->zText == pM->zBase) |
1606 | if( pM->zText==pM->zBase ){ |
1938 | { |
- | |
1939 | pM->zText = Tcl_Alloc (pM->nAlloc); |
1607 | pM->zText = Tcl_Alloc(pM->nAlloc); |
1940 | if (pM->zText && pM->nChar) |
- | |
1941 | memcpy (pM->zText, pM->zBase, pM->nChar); |
1608 | if( pM->zText && pM->nChar ) memcpy(pM->zText,pM->zBase,pM->nChar); |
1942 | } |
- | |
1943 | else |
1609 | }else{ |
1944 | { |
- | |
1945 | pM->zText = Tcl_Realloc (pM->zText, pM->nAlloc); |
1610 | pM->zText = Tcl_Realloc(pM->zText, pM->nAlloc); |
1946 | } |
1611 | } |
1947 | } |
1612 | } |
1948 | if (pM->zText) |
1613 | if( pM->zText ){ |
1949 | { |
- | |
1950 | memcpy (&pM->zText[pM->nChar], zNewText, nNewChar); |
1614 | memcpy(&pM->zText[pM->nChar], zNewText, nNewChar); |
1951 | pM->nChar += nNewChar; |
1615 | pM->nChar += nNewChar; |
1952 | pM->zText[pM->nChar] = 0; |
1616 | pM->zText[pM->nChar] = 0; |
1953 | } |
1617 | } |
1954 | } |
1618 | } |
1955 | 1619 | ||
1956 | /* |
1620 | /* |
1957 | ** mprintf() works like printf(), but allocations memory to hold the |
1621 | ** mprintf() works like printf(), but allocations memory to hold the |
1958 | ** resulting string and returns a pointer to the allocated memory. |
1622 | ** resulting string and returns a pointer to the allocated memory. |
1959 | */ |
1623 | */ |
1960 | char *mprintf (const char *zFormat, ...) |
1624 | char *mprintf(const char *zFormat, ...){ |
1961 | { |
- | |
1962 | va_list ap; |
1625 | va_list ap; |
1963 | struct sgMprintf sMprintf; |
1626 | struct sgMprintf sMprintf; |
1964 | char *zNew; |
1627 | char *zNew; |
1965 | char zBuf[200]; |
1628 | char zBuf[200]; |
1966 | 1629 | ||
1967 | sMprintf.nChar = 0; |
1630 | sMprintf.nChar = 0; |
1968 | sMprintf.nAlloc = sizeof (zBuf); |
1631 | sMprintf.nAlloc = sizeof(zBuf); |
1969 | sMprintf.zText = zBuf; |
1632 | sMprintf.zText = zBuf; |
1970 | sMprintf.zBase = zBuf; |
1633 | sMprintf.zBase = zBuf; |
1971 | va_start (ap, zFormat); |
1634 | va_start(ap,zFormat); |
1972 | vxprintf (mout, &sMprintf, zFormat, ap); |
1635 | vxprintf(mout,&sMprintf,zFormat,ap); |
1973 | va_end (ap); |
1636 | va_end(ap); |
1974 | sMprintf.zText[sMprintf.nChar] = 0; |
1637 | sMprintf.zText[sMprintf.nChar] = 0; |
1975 | if (sMprintf.zText == sMprintf.zBase) |
1638 | if( sMprintf.zText==sMprintf.zBase ){ |
1976 | { |
- | |
1977 | zNew = Tcl_Alloc (sMprintf.nChar + 1); |
1639 | zNew = Tcl_Alloc( sMprintf.nChar+1 ); |
1978 | if (zNew) |
- | |
1979 | strcpy (zNew, zBuf); |
1640 | if( zNew ) strcpy(zNew,zBuf); |
1980 | } |
- | |
1981 | else |
- | |
1982 | { |
1641 | }else{ |
1983 | zNew = Tcl_Realloc (sMprintf.zText, sMprintf.nChar + 1); |
1642 | zNew = Tcl_Realloc(sMprintf.zText,sMprintf.nChar+1); |
1984 | } |
1643 | } |
1985 | return zNew; |
1644 | return zNew; |
1986 | } |
1645 | } |
1987 | 1646 | ||
1988 | /* This is the varargs version of mprintf. |
1647 | /* This is the varargs version of mprintf. |
1989 | */ |
1648 | */ |
1990 | char *vmprintf (const char *zFormat, va_list ap) |
1649 | char *vmprintf(const char *zFormat, va_list ap){ |
1991 | { |
- | |
1992 | struct sgMprintf sMprintf; |
1650 | struct sgMprintf sMprintf; |
1993 | char zBuf[200]; |
1651 | char zBuf[200]; |
1994 | sMprintf.nChar = 0; |
1652 | sMprintf.nChar = 0; |
1995 | sMprintf.zText = zBuf; |
1653 | sMprintf.zText = zBuf; |
1996 | sMprintf.nAlloc = sizeof (zBuf); |
1654 | sMprintf.nAlloc = sizeof(zBuf); |
1997 | sMprintf.zBase = zBuf; |
1655 | sMprintf.zBase = zBuf; |
1998 | vxprintf (mout, &sMprintf, zFormat, ap); |
1656 | vxprintf(mout,&sMprintf,zFormat,ap); |
1999 | sMprintf.zText[sMprintf.nChar] = 0; |
1657 | sMprintf.zText[sMprintf.nChar] = 0; |
2000 | if (sMprintf.zText == sMprintf.zBase) |
1658 | if( sMprintf.zText==sMprintf.zBase ){ |
2001 | { |
- | |
2002 | sMprintf.zText = Tcl_Alloc (strlen (zBuf) + 1); |
1659 | sMprintf.zText = Tcl_Alloc( strlen(zBuf)+1 ); |
2003 | if (sMprintf.zText) |
- | |
2004 | strcpy (sMprintf.zText, zBuf); |
1660 | if( sMprintf.zText ) strcpy(sMprintf.zText,zBuf); |
2005 | } |
- | |
2006 | else |
- | |
2007 | { |
1661 | }else{ |
2008 | sMprintf.zText = Tcl_Realloc (sMprintf.zText, sMprintf.nChar + 1); |
1662 | sMprintf.zText = Tcl_Realloc(sMprintf.zText,sMprintf.nChar+1); |
2009 | } |
1663 | } |
2010 | return sMprintf.zText; |
1664 | return sMprintf.zText; |
2011 | } |
1665 | } |
2012 | 1666 | ||
2013 | /* |
1667 | /* |
2014 | ** Add text output to a Tcl_DString. |
1668 | ** Add text output to a Tcl_DString. |
2015 | ** |
1669 | ** |
2016 | ** This routine is called by vxprintf(). It's job is to add |
1670 | ** This routine is called by vxprintf(). It's job is to add |
2017 | ** nNewChar characters of text from zNewText to the Tcl_DString |
1671 | ** nNewChar characters of text from zNewText to the Tcl_DString |
2018 | ** that "arg" is pointing to. |
1672 | ** that "arg" is pointing to. |
2019 | */ |
1673 | */ |
2020 | static void dstringout (void *arg, char *zNewText, int nNewChar) |
1674 | static void dstringout(void *arg, char *zNewText, int nNewChar){ |
2021 | { |
- | |
2022 | Tcl_DString *str = (Tcl_DString *) arg; |
1675 | Tcl_DString *str = (Tcl_DString*)arg; |
2023 | Tcl_DStringAppend (str, zNewText, nNewChar); |
1676 | Tcl_DStringAppend(str,zNewText,nNewChar); |
2024 | } |
1677 | } |
2025 | 1678 | ||
2026 | /* |
1679 | /* |
2027 | ** Append formatted output to a DString. |
1680 | ** Append formatted output to a DString. |
2028 | */ |
1681 | */ |
2029 | char *Et_DStringAppendF (Tcl_DString *str, const char *zFormat, ...) |
1682 | char *Et_DStringAppendF(Tcl_DString *str, const char *zFormat, ...){ |
2030 | { |
- | |
2031 | va_list ap; |
1683 | va_list ap; |
2032 | va_start (ap, zFormat); |
1684 | va_start(ap,zFormat); |
2033 | vxprintf (dstringout, str, zFormat, ap); |
1685 | vxprintf(dstringout,str,zFormat,ap); |
2034 | va_end (ap); |
1686 | va_end(ap); |
2035 | return Tcl_DStringValue (str); |
1687 | return Tcl_DStringValue(str); |
2036 | } |
1688 | } |
2037 | 1689 | ||
2038 | /* |
1690 | /* |
2039 | ** Make this variable true to trace all calls to EvalF |
1691 | ** Make this variable true to trace all calls to EvalF |
2040 | */ |
1692 | */ |
2041 | int Et_EvalTrace = 0; |
1693 | int Et_EvalTrace = 0; |
2042 | 1694 | ||
2043 | /* |
1695 | /* |
2044 | ** Eval the results of a string. |
1696 | ** Eval the results of a string. |
2045 | */ |
1697 | */ |
2046 | int Et_EvalF (Tcl_Interp *interp, const char *zFormat, ...) |
1698 | int Et_EvalF(Tcl_Interp *interp, const char *zFormat, ...){ |
2047 | { |
- | |
2048 | char *zCmd; |
1699 | char *zCmd; |
2049 | va_list ap; |
1700 | va_list ap; |
2050 | int result; |
1701 | int result; |
2051 | va_start (ap, zFormat); |
1702 | va_start(ap,zFormat); |
2052 | zCmd = vmprintf (zFormat, ap); |
1703 | zCmd = vmprintf(zFormat,ap); |
2053 | if (Et_EvalTrace) |
- | |
2054 | printf ("%s\n", zCmd); |
1704 | if( Et_EvalTrace ) printf("%s\n",zCmd); |
2055 | result = Tcl_Eval (interp, zCmd); |
1705 | result = Tcl_Eval(interp,zCmd); |
2056 | if (Et_EvalTrace) |
- | |
2057 | printf ("%d %s\n", result, interp->result); |
1706 | if( Et_EvalTrace ) printf("%d %s\n",result,interp->result); |
2058 | Tcl_Free (zCmd); |
1707 | Tcl_Free(zCmd); |
2059 | return result; |
1708 | return result; |
2060 | } |
1709 | } |
2061 | int Et_GlobalEvalF (Tcl_Interp *interp, const char *zFormat, ...) |
1710 | int Et_GlobalEvalF(Tcl_Interp *interp, const char *zFormat, ...){ |
2062 | { |
- | |
2063 | char *zCmd; |
1711 | char *zCmd; |
2064 | va_list ap; |
1712 | va_list ap; |
2065 | int result; |
1713 | int result; |
2066 | va_start (ap, zFormat); |
1714 | va_start(ap,zFormat); |
2067 | zCmd = vmprintf (zFormat, ap); |
1715 | zCmd = vmprintf(zFormat,ap); |
2068 | if (Et_EvalTrace) |
- | |
2069 | printf ("%s\n", zCmd); |
1716 | if( Et_EvalTrace ) printf("%s\n",zCmd); |
2070 | result = Tcl_GlobalEval (interp, zCmd); |
1717 | result = Tcl_GlobalEval(interp,zCmd); |
2071 | if (Et_EvalTrace) |
- | |
2072 | printf ("%d %s\n", result, interp->result); |
1718 | if( Et_EvalTrace ) printf("%d %s\n",result,interp->result); |
2073 | Tcl_Free (zCmd); |
1719 | Tcl_Free(zCmd); |
2074 | return result; |
1720 | return result; |
2075 | } |
1721 | } |
2076 | 1722 | ||
2077 | /* |
1723 | /* |
2078 | ** Set the result of an interpreter using printf-like arguments. |
1724 | ** Set the result of an interpreter using printf-like arguments. |
2079 | */ |
1725 | */ |
2080 | void Et_ResultF (Tcl_Interp *interp, const char *zFormat, ...) |
1726 | void Et_ResultF(Tcl_Interp *interp, const char *zFormat, ...){ |
2081 | { |
- | |
2082 | Tcl_DString str; |
1727 | Tcl_DString str; |
2083 | va_list ap; |
1728 | va_list ap; |
2084 | 1729 | ||
2085 | Tcl_DStringInit (&str); |
1730 | Tcl_DStringInit(&str); |
2086 | va_start (ap, zFormat); |
1731 | va_start(ap,zFormat); |
2087 | vxprintf (dstringout, &str, zFormat, ap); |
1732 | vxprintf(dstringout,&str,zFormat,ap); |
2088 | va_end (ap); |
1733 | va_end(ap); |
2089 | Tcl_DStringResult (interp, &str); |
1734 | Tcl_DStringResult(interp,&str); |
2090 | } |
1735 | } |
2091 | 1736 | ||
2092 | #if ET_HAVE_OBJ |
1737 | #if ET_HAVE_OBJ |
2093 | /* |
1738 | /* |
2094 | ** Append text to a string object. |
1739 | ** Append text to a string object. |
2095 | */ |
1740 | */ |
2096 | int Et_AppendObjF (Tcl_Obj *pObj, const char *zFormat, ...) |
1741 | int Et_AppendObjF(Tcl_Obj *pObj, const char *zFormat, ...){ |
2097 | { |
- | |
2098 | va_list ap; |
1742 | va_list ap; |
2099 | int rc; |
1743 | int rc; |
2100 | 1744 | ||
2101 | va_start (ap, zFormat); |
1745 | va_start(ap,zFormat); |
2102 | rc = vxprintf ((void (*) (void *, char *, int)) Tcl_AppendToObj, pObj, zFormat, ap); |
1746 | rc = vxprintf((void(*)(void*,char*,int))Tcl_AppendToObj, pObj, zFormat, ap); |
2103 | va_end (ap); |
1747 | va_end(ap); |
2104 | return rc; |
1748 | return rc; |
2105 | } |
1749 | } |
2106 | #endif |
1750 | #endif |
2107 | 1751 | ||
- | 1752 | ||
2108 | #if ET_WIN32 |
1753 | #if ET_WIN32 |
2109 | /* |
1754 | /* |
2110 | ** This array translates all characters into themselves. Except |
1755 | ** This array translates all characters into themselves. Except |
2111 | ** for the \ which gets translated into /. And all upper-case |
1756 | ** for the \ which gets translated into /. And all upper-case |
2112 | ** characters are translated into lower case. This is used for |
1757 | ** characters are translated into lower case. This is used for |
Line 2119... | Line 1764... | ||
2119 | ** We also define a macro ET_TRANS() that actually does |
1764 | ** We also define a macro ET_TRANS() that actually does |
2120 | ** the character translation. ET_TRANS() is a no-op under |
1765 | ** the character translation. ET_TRANS() is a no-op under |
2121 | ** unix. |
1766 | ** unix. |
2122 | */ |
1767 | */ |
2123 | static char charTrans[256]; |
1768 | static char charTrans[256]; |
2124 | #define ET_TRANS(X) (charTrans[0xff & (int) (X)]) |
1769 | #define ET_TRANS(X) (charTrans[0xff&(int)(X)]) |
2125 | #else |
1770 | #else |
2126 | #define ET_TRANS(X) (X) |
1771 | #define ET_TRANS(X) (X) |
2127 | #endif |
1772 | #endif |
2128 | 1773 | ||
2129 | /* |
1774 | /* |
2130 | ** Hash a filename. The value returned is appropriate for |
1775 | ** Hash a filename. The value returned is appropriate for |
2131 | ** indexing into the Et_FileHashTable[] array. |
1776 | ** indexing into the Et_FileHashTable[] array. |
2132 | */ |
1777 | */ |
2133 | static int FilenameHash (char *zName) |
1778 | static int FilenameHash(char *zName){ |
2134 | { |
- | |
2135 | int h = 0; |
1779 | int h = 0; |
2136 | while (*zName) |
1780 | while( *zName ){ |
2137 | { |
- | |
2138 | h = h ^ (h << 5) ^ ET_TRANS (*(zName++)); |
1781 | h = h ^ (h<<5) ^ ET_TRANS(*(zName++)); |
2139 | } |
1782 | } |
2140 | if (h < 0) |
- | |
2141 | h = -h; |
1783 | if( h<0 ) h = -h; |
2142 | return h % (sizeof (Et_FileHashTable) / sizeof (Et_FileHashTable[0])); |
1784 | return h % (sizeof(Et_FileHashTable)/sizeof(Et_FileHashTable[0])); |
2143 | } |
1785 | } |
2144 | 1786 | ||
2145 | /* |
1787 | /* |
2146 | ** Compare two filenames. Return 0 if they are the same and |
1788 | ** Compare two filenames. Return 0 if they are the same and |
2147 | ** non-zero if they are different. |
1789 | ** non-zero if they are different. |
2148 | */ |
1790 | */ |
2149 | static int FilenameCmp (char *z1, char *z2) |
1791 | static int FilenameCmp(char *z1, char *z2){ |
2150 | { |
- | |
2151 | int diff; |
1792 | int diff; |
2152 | while ((diff = ET_TRANS (*z1) - ET_TRANS (*z2)) == 0 && *z1 != 0) |
1793 | while( (diff = ET_TRANS(*z1)-ET_TRANS(*z2))==0 && *z1!=0){ |
2153 | { |
1794 | z1++; |
2154 | z1++; |
- | |
2155 | z2++; |
1795 | z2++; |
2156 | } |
1796 | } |
2157 | return diff; |
1797 | return diff; |
2158 | } |
1798 | } |
2159 | 1799 | ||
2160 | /* |
1800 | /* |
2161 | ** Initialize the file hash table |
1801 | ** Initialize the file hash table |
2162 | */ |
1802 | */ |
2163 | static void FilenameHashInit (void) |
1803 | static void FilenameHashInit(void){ |
2164 | { |
- | |
2165 | int i; |
1804 | int i; |
2166 | #if ET_WIN32 |
1805 | #if ET_WIN32 |
2167 | for (i = 0; i < sizeof (charTrans); i++) |
1806 | for(i=0; i<sizeof(charTrans); i++){ |
2168 | { |
- | |
2169 | charTrans[i] = i; |
1807 | charTrans[i] = i; |
2170 | } |
1808 | } |
2171 | for (i = 'A'; i <= 'Z'; i++) |
1809 | for(i='A'; i<='Z'; i++){ |
2172 | { |
- | |
2173 | charTrans[i] = i + 'a' - 'A'; |
1810 | charTrans[i] = i + 'a' - 'A'; |
2174 | } |
1811 | } |
2175 | charTrans['\\'] = '/'; |
1812 | charTrans['\\'] = '/'; |
2176 | #endif |
1813 | #endif |
2177 | for (i = 0; i < sizeof (Et_FileSet) / sizeof (Et_FileSet[0]) - 1; i++) |
1814 | for(i=0; i<sizeof(Et_FileSet)/sizeof(Et_FileSet[0]) - 1; i++){ |
2178 | { |
- | |
2179 | struct EtFile *p; |
1815 | struct EtFile *p; |
2180 | int h; |
1816 | int h; |
2181 | p = &Et_FileSet[i]; |
1817 | p = &Et_FileSet[i]; |
2182 | h = FilenameHash (p->zName); |
1818 | h = FilenameHash(p->zName); |
2183 | p->pNext = Et_FileHashTable[h]; |
1819 | p->pNext = Et_FileHashTable[h]; |
2184 | Et_FileHashTable[h] = p; |
1820 | Et_FileHashTable[h] = p; |
2185 | } |
1821 | } |
2186 | } |
1822 | } |
2187 | 1823 | ||
2188 | /* |
1824 | /* |
2189 | ** Locate the text of a built-in file given its name. |
1825 | ** Locate the text of a built-in file given its name. |
2190 | ** Return 0 if not found. Return this size of the file (not |
1826 | ** Return 0 if not found. Return this size of the file (not |
2191 | ** counting the null-terminator) in *pSize if pSize!=NULL. |
1827 | ** counting the null-terminator) in *pSize if pSize!=NULL. |
2192 | ** |
1828 | ** |
2193 | ** If deshroud==1 and the file is shrouded, then descramble |
1829 | ** If deshroud==1 and the file is shrouded, then descramble |
2194 | ** the text. |
1830 | ** the text. |
2195 | */ |
1831 | */ |
2196 | static char *FindBuiltinFile (char *zName, int deshroud, int *pSize) |
1832 | static char *FindBuiltinFile(char *zName, int deshroud, int *pSize){ |
2197 | { |
- | |
2198 | int h; |
1833 | int h; |
2199 | struct EtFile *p; |
1834 | struct EtFile *p; |
2200 | 1835 | ||
2201 | h = FilenameHash (zName); |
1836 | h = FilenameHash(zName); |
2202 | p = Et_FileHashTable[h]; |
1837 | p = Et_FileHashTable[h]; |
2203 | while (p && FilenameCmp (p->zName, zName) != 0) |
1838 | while( p && FilenameCmp(p->zName,zName)!=0 ){ p = p->pNext; } |
2204 | { |
- | |
2205 | p = p->pNext; |
- | |
2206 | } |
- | |
2207 | #if ET_SHROUD_KEY > 0 |
1839 | #if ET_SHROUD_KEY>0 |
2208 | if (p && p->shrouded && deshroud) |
1840 | if( p && p->shrouded && deshroud ){ |
2209 | { |
1841 | char *z; |
2210 | char *z; |
- | |
2211 | int xor = ET_SHROUD_KEY; |
1842 | int xor = ET_SHROUD_KEY; |
2212 | for (z = p->zData; *z; z++) |
1843 | for(z=p->zData; *z; z++){ |
2213 | { |
- | |
2214 | if (*z >= 0x20) |
- | |
2215 | { |
- | |
2216 | *z ^= xor; |
- | |
2217 | xor = (xor+1) & 0x1f; |
1844 | if( *z>=0x20 ){ *z ^= xor; xor = (xor+1)&0x1f; } |
2218 | } |
- | |
2219 | } |
1845 | } |
2220 | p->shrouded = 0; |
1846 | p->shrouded = 0; |
2221 | } |
1847 | } |
2222 | #endif |
1848 | #endif |
2223 | if (p && pSize) |
1849 | if( p && pSize ){ |
2224 | { |
- | |
2225 | *pSize = p->nData; |
1850 | *pSize = p->nData; |
2226 | } |
1851 | } |
2227 | return p ? p->zData : 0; |
1852 | return p ? p->zData : 0; |
2228 | } |
1853 | } |
2229 | 1854 | ||
2230 | /* |
1855 | /* |
2231 | ** Add a new file to the list of built-in files. |
1856 | ** Add a new file to the list of built-in files. |
2232 | ** |
1857 | ** |
2233 | ** This routine makes a copy of zFilename. But it does NOT make |
1858 | ** This routine makes a copy of zFilename. But it does NOT make |
2234 | ** a copy of zData. It just holds a pointer to zData and uses |
1859 | ** a copy of zData. It just holds a pointer to zData and uses |
2235 | ** that for all file access. So after calling this routine, |
1860 | ** that for all file access. So after calling this routine, |
2236 | ** you should never change zData! |
1861 | ** you should never change zData! |
2237 | */ |
1862 | */ |
2238 | void Et_NewBuiltinFile ( |
1863 | void Et_NewBuiltinFile( |
2239 | char *zFilename, /* Name of the new file */ |
1864 | char *zFilename, /* Name of the new file */ |
2240 | char *zData, /* Data for the new file */ |
1865 | char *zData, /* Data for the new file */ |
2241 | int nData /* Number of bytes in the new file */ |
1866 | int nData /* Number of bytes in the new file */ |
2242 | ) |
- | |
2243 | { |
1867 | ){ |
2244 | int h; |
1868 | int h; |
2245 | struct EtFile *p; |
1869 | struct EtFile *p; |
2246 | 1870 | ||
2247 | p = (struct EtFile *) Tcl_Alloc (sizeof (struct EtFile) + strlen (zFilename) + 1); |
1871 | p = (struct EtFile*)Tcl_Alloc( sizeof(struct EtFile) + strlen(zFilename) + 1); |
2248 | if (p == 0) |
- | |
2249 | return; |
1872 | if( p==0 ) return; |
2250 | p->zName = (char *) &p[1]; |
1873 | p->zName = (char*)&p[1]; |
2251 | strcpy (p->zName, zFilename); |
1874 | strcpy(p->zName, zFilename); |
2252 | p->zData = zData; |
1875 | p->zData = zData; |
2253 | p->nData = nData; |
1876 | p->nData = nData; |
2254 | p->shrouded = 0; |
1877 | p->shrouded = 0; |
2255 | h = FilenameHash (zFilename); |
1878 | h = FilenameHash(zFilename); |
2256 | p->pNext = Et_FileHashTable[h]; |
1879 | p->pNext = Et_FileHashTable[h]; |
2257 | Et_FileHashTable[h] = p; |
1880 | Et_FileHashTable[h] = p; |
2258 | } |
1881 | } |
2259 | 1882 | ||
2260 | /* |
1883 | /* |
2261 | ** A TCL interface to the Et_NewBuiltinFile function. For Tcl8.0 |
1884 | ** A TCL interface to the Et_NewBuiltinFile function. For Tcl8.0 |
2262 | ** and later, we make this an Obj command so that it can deal with |
1885 | ** and later, we make this an Obj command so that it can deal with |
2263 | ** binary data. |
1886 | ** binary data. |
2264 | */ |
1887 | */ |
2265 | #if ET_HAVE_OBJ |
1888 | #if ET_HAVE_OBJ |
2266 | static int Et_NewBuiltinFileCmd (ET_OBJARGS) |
1889 | static int Et_NewBuiltinFileCmd(ET_OBJARGS){ |
2267 | { |
- | |
2268 | char *zData, *zNew; |
1890 | char *zData, *zNew; |
2269 | int nData; |
1891 | int nData; |
2270 | if (objc != 3) |
1892 | if( objc!=3 ){ |
2271 | { |
- | |
2272 | Tcl_WrongNumArgs (interp, 1, objv, "filename data"); |
1893 | Tcl_WrongNumArgs(interp, 1, objv, "filename data"); |
2273 | return TCL_ERROR; |
1894 | return TCL_ERROR; |
2274 | } |
1895 | } |
2275 | zData = (char *) Tcl_GetByteArrayFromObj (objv[2], &nData); |
1896 | zData = (char*)Tcl_GetByteArrayFromObj(objv[2], &nData); |
2276 | zNew = Tcl_Alloc (nData + 1); |
1897 | zNew = Tcl_Alloc( nData + 1 ); |
2277 | if (zNew) |
1898 | if( zNew ){ |
2278 | { |
- | |
2279 | memcpy (zNew, zData, nData); |
1899 | memcpy(zNew, zData, nData); |
2280 | zNew[nData] = 0; |
1900 | zNew[nData] = 0; |
2281 | Et_NewBuiltinFile (Tcl_GetStringFromObj (objv[1], 0), zNew, nData); |
1901 | Et_NewBuiltinFile(Tcl_GetStringFromObj(objv[1], 0), zNew, nData); |
2282 | } |
1902 | } |
2283 | return TCL_OK; |
1903 | return TCL_OK; |
2284 | } |
1904 | } |
2285 | #else |
1905 | #else |
2286 | static int Et_NewBuiltinFileCmd (ET_TCLARGS) |
1906 | static int Et_NewBuiltinFileCmd(ET_TCLARGS){ |
2287 | { |
- | |
2288 | char *zData; |
1907 | char *zData; |
2289 | int nData; |
1908 | int nData; |
2290 | if (argc != 3) |
1909 | if( argc!=3 ){ |
2291 | { |
- | |
2292 | Et_ResultF (interp, "wrong # args: should be \"%s FILENAME DATA\"", argv[0]); |
1910 | Et_ResultF(interp,"wrong # args: should be \"%s FILENAME DATA\"", argv[0]); |
2293 | return TCL_ERROR; |
1911 | return TCL_ERROR; |
2294 | } |
1912 | } |
2295 | nData = strlen (argv[2]) + 1; |
1913 | nData = strlen(argv[2]) + 1; |
2296 | zData = Tcl_Alloc (nData); |
1914 | zData = Tcl_Alloc( nData ); |
2297 | if (zData) |
1915 | if( zData ){ |
2298 | { |
- | |
2299 | strcpy (zData, argv[2]); |
1916 | strcpy(zData, argv[2]); |
2300 | Et_NewBuiltinFile (argv[1], zData, nData); |
1917 | Et_NewBuiltinFile(argv[1], zData, nData); |
2301 | } |
1918 | } |
2302 | return TCL_OK; |
1919 | return TCL_OK; |
2303 | } |
1920 | } |
2304 | #endif |
1921 | #endif |
2305 | 1922 | ||
2306 | /* |
1923 | /* |
2307 | ** The following section implements the InsertProc functionality. The |
1924 | ** The following section implements the InsertProc functionality. The |
Line 2309... | Line 1926... | ||
2309 | ** the usual system call commands for file I/O and replace them with |
1926 | ** the usual system call commands for file I/O and replace them with |
2310 | ** commands that operate on the built-in files. |
1927 | ** commands that operate on the built-in files. |
2311 | */ |
1928 | */ |
2312 | #ifdef ET_HAVE_INSERTPROC |
1929 | #ifdef ET_HAVE_INSERTPROC |
2313 | 1930 | ||
2314 | /* |
1931 | /* |
2315 | ** Each open channel to a built-in file is an instance of the |
1932 | ** Each open channel to a built-in file is an instance of the |
2316 | ** following structure. |
1933 | ** following structure. |
2317 | */ |
1934 | */ |
2318 | typedef struct Et_FileStruct |
1935 | typedef struct Et_FileStruct { |
2319 | { |
- | |
2320 | char *zData; /* All of the data */ |
1936 | char *zData; /* All of the data */ |
2321 | int nData; /* Bytes of data, not counting the null terminator */ |
1937 | int nData; /* Bytes of data, not counting the null terminator */ |
2322 | int cursor; /* How much of the data has been read so far */ |
1938 | int cursor; /* How much of the data has been read so far */ |
2323 | } Et_FileStruct; |
1939 | } Et_FileStruct; |
2324 | 1940 | ||
2325 | /* |
1941 | /* |
2326 | ** Close a previously opened built-in file. |
1942 | ** Close a previously opened built-in file. |
2327 | */ |
1943 | */ |
2328 | static int Et_FileClose (ClientData instanceData, Tcl_Interp *interp) |
1944 | static int Et_FileClose(ClientData instanceData, Tcl_Interp *interp){ |
2329 | { |
- | |
2330 | Et_FileStruct *p = (Et_FileStruct *) instanceData; |
1945 | Et_FileStruct *p = (Et_FileStruct*)instanceData; |
2331 | Tcl_Free ((char *) p); |
1946 | Tcl_Free((char*)p); |
2332 | return 0; |
1947 | return 0; |
2333 | } |
1948 | } |
2334 | 1949 | ||
2335 | /* |
1950 | /* |
2336 | ** Read from a built-in file. |
1951 | ** Read from a built-in file. |
2337 | */ |
1952 | */ |
2338 | static int Et_FileInput ( |
1953 | static int Et_FileInput( |
2339 | ClientData instanceData, /* The file structure */ |
1954 | ClientData instanceData, /* The file structure */ |
2340 | char *buf, /* Write the data read here */ |
1955 | char *buf, /* Write the data read here */ |
2341 | int bufSize, /* Read this much data */ |
1956 | int bufSize, /* Read this much data */ |
2342 | int *pErrorCode /* Write the error code here */ |
1957 | int *pErrorCode /* Write the error code here */ |
2343 | ) |
- | |
2344 | { |
1958 | ){ |
2345 | Et_FileStruct *p = (Et_FileStruct *) instanceData; |
1959 | Et_FileStruct *p = (Et_FileStruct*)instanceData; |
2346 | *pErrorCode = 0; |
1960 | *pErrorCode = 0; |
2347 | if (p->cursor + bufSize > p->nData) |
1961 | if( p->cursor+bufSize>p->nData ){ |
2348 | { |
- | |
2349 | bufSize = p->nData - p->cursor; |
1962 | bufSize = p->nData - p->cursor; |
2350 | } |
1963 | } |
2351 | memcpy (buf, &p->zData[p->cursor], bufSize); |
1964 | memcpy(buf, &p->zData[p->cursor], bufSize); |
2352 | p->cursor += bufSize; |
1965 | p->cursor += bufSize; |
2353 | return bufSize; |
1966 | return bufSize; |
2354 | } |
1967 | } |
2355 | 1968 | ||
2356 | /* |
1969 | /* |
2357 | ** Writes to a built-in file always return EOF. |
1970 | ** Writes to a built-in file always return EOF. |
2358 | */ |
1971 | */ |
2359 | static int Et_FileOutput ( |
1972 | static int Et_FileOutput( |
2360 | ClientData instanceData, /* The file structure */ |
1973 | ClientData instanceData, /* The file structure */ |
2361 | char *buf, /* Read the data from here */ |
1974 | char *buf, /* Read the data from here */ |
2362 | int toWrite, /* Write this much data */ |
1975 | int toWrite, /* Write this much data */ |
2363 | int *pErrorCode /* Write the error code here */ |
1976 | int *pErrorCode /* Write the error code here */ |
2364 | ) |
- | |
2365 | { |
1977 | ){ |
2366 | *pErrorCode = 0; |
1978 | *pErrorCode = 0; |
2367 | return 0; |
1979 | return 0; |
2368 | } |
1980 | } |
2369 | 1981 | ||
2370 | /* |
1982 | /* |
2371 | ** Move the cursor around within the built-in file. |
1983 | ** Move the cursor around within the built-in file. |
2372 | */ |
1984 | */ |
2373 | static int Et_FileSeek ( |
1985 | static int Et_FileSeek( |
2374 | ClientData instanceData, /* The file structure */ |
1986 | ClientData instanceData, /* The file structure */ |
2375 | long offset, /* Offset to seek to */ |
1987 | long offset, /* Offset to seek to */ |
2376 | int mode, /* One of SEEK_CUR, SEEK_SET or SEEK_END */ |
1988 | int mode, /* One of SEEK_CUR, SEEK_SET or SEEK_END */ |
2377 | int *pErrorCode /* Write the error code here */ |
1989 | int *pErrorCode /* Write the error code here */ |
2378 | ) |
- | |
2379 | { |
1990 | ){ |
2380 | Et_FileStruct *p = (Et_FileStruct *) instanceData; |
1991 | Et_FileStruct *p = (Et_FileStruct*)instanceData; |
2381 | switch (mode) |
1992 | switch( mode ){ |
2382 | { |
- | |
2383 | case SEEK_CUR: |
- | |
2384 | offset += p->cursor; |
1993 | case SEEK_CUR: offset += p->cursor; break; |
2385 | break; |
- | |
2386 | case SEEK_END: |
- | |
2387 | offset += p->nData; |
1994 | case SEEK_END: offset += p->nData; break; |
2388 | break; |
- | |
2389 | default: |
- | |
2390 | break; |
1995 | default: break; |
2391 | } |
1996 | } |
2392 | if (offset < 0) |
- | |
2393 | offset = 0; |
1997 | if( offset<0 ) offset = 0; |
2394 | if (offset > p->nData) |
- | |
2395 | offset = p->nData; |
1998 | if( offset>p->nData ) offset = p->nData; |
2396 | p->cursor = offset; |
1999 | p->cursor = offset; |
2397 | return offset; |
2000 | return offset; |
2398 | } |
2001 | } |
2399 | 2002 | ||
2400 | /* |
2003 | /* |
2401 | ** The Watch method is a no-op |
2004 | ** The Watch method is a no-op |
2402 | */ |
2005 | */ |
2403 | static void Et_FileWatch (ClientData instanceData, int mask) |
2006 | static void Et_FileWatch(ClientData instanceData, int mask){ |
2404 | { |
- | |
2405 | } |
2007 | } |
2406 | 2008 | ||
2407 | /* |
2009 | /* |
2408 | ** The Handle method always returns an error. |
2010 | ** The Handle method always returns an error. |
2409 | */ |
2011 | */ |
2410 | static int Et_FileHandle (ClientData notUsed, int dir, ClientData *handlePtr) |
2012 | static int Et_FileHandle(ClientData notUsed, int dir, ClientData *handlePtr){ |
2411 | { |
- | |
2412 | return TCL_ERROR; |
2013 | return TCL_ERROR; |
2413 | } |
2014 | } |
2414 | 2015 | ||
2415 | /* |
2016 | /* |
2416 | ** This is the channel type that will access the built-in files. |
2017 | ** This is the channel type that will access the built-in files. |
2417 | */ |
2018 | */ |
2418 | static Tcl_ChannelType builtinChannelType = { |
2019 | static Tcl_ChannelType builtinChannelType = { |
2419 | "builtin", /* Type name. */ |
2020 | "builtin", /* Type name. */ |
2420 | NULL, /* Always non-blocking.*/ |
2021 | NULL, /* Always non-blocking.*/ |
2421 | Et_FileClose, /* Close proc. */ |
2022 | Et_FileClose, /* Close proc. */ |
2422 | Et_FileInput, /* Input proc. */ |
2023 | Et_FileInput, /* Input proc. */ |
2423 | Et_FileOutput, /* Output proc. */ |
2024 | Et_FileOutput, /* Output proc. */ |
2424 | Et_FileSeek, /* Seek proc. */ |
2025 | Et_FileSeek, /* Seek proc. */ |
2425 | NULL, /* Set option proc. */ |
2026 | NULL, /* Set option proc. */ |
2426 | NULL, /* Get option proc. */ |
2027 | NULL, /* Get option proc. */ |
2427 | Et_FileWatch, /* Watch for events on console. */ |
2028 | Et_FileWatch, /* Watch for events on console. */ |
2428 | Et_FileHandle, /* Get a handle from the device. */ |
2029 | Et_FileHandle, /* Get a handle from the device. */ |
2429 | }; |
2030 | }; |
2430 | 2031 | ||
2431 | /* |
2032 | /* |
2432 | ** This routine attempts to do an open of a built-in file. |
2033 | ** This routine attempts to do an open of a built-in file. |
2433 | */ |
2034 | */ |
2434 | static Tcl_Channel Et_FileOpen ( |
2035 | static Tcl_Channel Et_FileOpen( |
2435 | Tcl_Interp *interp, /* The TCL interpreter doing the open */ |
2036 | Tcl_Interp *interp, /* The TCL interpreter doing the open */ |
2436 | char *zFilename, /* Name of the file to open */ |
2037 | char *zFilename, /* Name of the file to open */ |
2437 | char *modeString, /* Mode string for the open (ignored) */ |
2038 | char *modeString, /* Mode string for the open (ignored) */ |
2438 | int permissions /* Permissions for a newly created file (ignored) */ |
2039 | int permissions /* Permissions for a newly created file (ignored) */ |
2439 | ) |
- | |
2440 | { |
2040 | ){ |
2441 | char *zData; |
2041 | char *zData; |
2442 | Et_FileStruct *p; |
2042 | Et_FileStruct *p; |
2443 | int nData; |
2043 | int nData; |
2444 | char zName[50]; |
2044 | char zName[50]; |
2445 | Tcl_Channel chan; |
2045 | Tcl_Channel chan; |
2446 | static int count = 1; |
2046 | static int count = 1; |
2447 | 2047 | ||
2448 | zData = FindBuiltinFile (zFilename, 1, &nData); |
2048 | zData = FindBuiltinFile(zFilename, 1, &nData); |
2449 | if (zData == 0) |
- | |
2450 | return NULL; |
2049 | if( zData==0 ) return NULL; |
2451 | p = (Et_FileStruct *) Tcl_Alloc (sizeof (Et_FileStruct)); |
2050 | p = (Et_FileStruct*)Tcl_Alloc( sizeof(Et_FileStruct) ); |
2452 | if (p == 0) |
- | |
2453 | return NULL; |
2051 | if( p==0 ) return NULL; |
2454 | p->zData = zData; |
2052 | p->zData = zData; |
2455 | p->nData = nData; |
2053 | p->nData = nData; |
2456 | p->cursor = 0; |
2054 | p->cursor = 0; |
2457 | sprintf (zName, "etbi_%x_%x", ((int) Et_FileOpen) >> 12, count++); |
2055 | sprintf(zName,"etbi_%x_%x",((int)Et_FileOpen)>>12,count++); |
2458 | chan = Tcl_CreateChannel (&builtinChannelType, zName, (ClientData) p, TCL_READABLE); |
2056 | chan = Tcl_CreateChannel(&builtinChannelType, zName, |
- | 2057 | (ClientData)p, TCL_READABLE); |
|
2459 | return chan; |
2058 | return chan; |
2460 | } |
2059 | } |
2461 | 2060 | ||
2462 | /* |
2061 | /* |
2463 | ** This routine does a stat() system call for a built-in file. |
2062 | ** This routine does a stat() system call for a built-in file. |
2464 | */ |
2063 | */ |
2465 | static int Et_FileStat (char *path, struct stat *buf) |
2064 | static int Et_FileStat(char *path, struct stat *buf){ |
2466 | { |
- | |
2467 | char *zData; |
2065 | char *zData; |
2468 | int nData; |
2066 | int nData; |
2469 | 2067 | ||
2470 | zData = FindBuiltinFile (path, 0, &nData); |
2068 | zData = FindBuiltinFile(path, 0, &nData); |
2471 | if (zData == 0) |
2069 | if( zData==0 ){ |
2472 | { |
- | |
2473 | return -1; |
2070 | return -1; |
2474 | } |
2071 | } |
2475 | memset (buf, 0, sizeof (*buf)); |
2072 | memset(buf, 0, sizeof(*buf)); |
2476 | buf->st_mode = 0400; |
2073 | buf->st_mode = 0400; |
2477 | buf->st_size = nData; |
2074 | buf->st_size = nData; |
2478 | return 0; |
2075 | return 0; |
2479 | } |
2076 | } |
2480 | 2077 | ||
2481 | /* |
2078 | /* |
2482 | ** This routien does an access() system call for a built-in file. |
2079 | ** This routien does an access() system call for a built-in file. |
2483 | */ |
2080 | */ |
2484 | static int Et_FileAccess (char *path, int mode) |
2081 | static int Et_FileAccess(char *path, int mode){ |
2485 | { |
- | |
2486 | char *zData; |
2082 | char *zData; |
2487 | 2083 | ||
2488 | if (mode & 3) |
2084 | if( mode & 3 ){ |
2489 | { |
- | |
2490 | return -1; |
2085 | return -1; |
2491 | } |
2086 | } |
2492 | zData = FindBuiltinFile (path, 0, 0); |
2087 | zData = FindBuiltinFile(path, 0, 0); |
2493 | if (zData == 0) |
2088 | if( zData==0 ){ |
2494 | { |
- | |
2495 | return -1; |
2089 | return -1; |
2496 | } |
2090 | } |
2497 | return 0; |
2091 | return 0; |
2498 | } |
2092 | } |
2499 | #endif /* ET_HAVE_INSERTPROC */ |
2093 | #endif /* ET_HAVE_INSERTPROC */ |
2500 | 2094 | ||
2501 | /* |
2095 | /* |
2502 | ** An overloaded version of "source". First check for the file |
2096 | ** An overloaded version of "source". First check for the file |
2503 | ** is one of the built-ins. If it isn't a built-in, then check the |
2097 | ** is one of the built-ins. If it isn't a built-in, then check the |
2504 | ** disk. But if ET_STANDALONE is set (which corresponds to the |
2098 | ** disk. But if ET_STANDALONE is set (which corresponds to the |
2505 | ** "Strict" option in the user interface) then never check the disk. |
2099 | ** "Strict" option in the user interface) then never check the disk. |
2506 | ** This gives us a quick way to check for the common error of |
2100 | ** This gives us a quick way to check for the common error of |
2507 | ** sourcing a file that exists on the development by mistake, |
2101 | ** sourcing a file that exists on the development by mistake, |
2508 | ** and only discovering the mistake when you move the program |
2102 | ** and only discovering the mistake when you move the program |
2509 | ** to your customer's machine. |
2103 | ** to your customer's machine. |
2510 | */ |
2104 | */ |
2511 | static int Et_Source (ET_TCLARGS) |
2105 | static int Et_Source(ET_TCLARGS){ |
2512 | { |
- | |
2513 | char *z; |
2106 | char *z; |
2514 | 2107 | ||
2515 | if (argc != 2) |
2108 | if( argc!=2 ){ |
2516 | { |
- | |
2517 | Et_ResultF (interp, "wrong # args: should be \"%s FILENAME\"", argv[0]); |
2109 | Et_ResultF(interp,"wrong # args: should be \"%s FILENAME\"", argv[0]); |
2518 | return TCL_ERROR; |
2110 | return TCL_ERROR; |
2519 | } |
2111 | } |
2520 | z = FindBuiltinFile (argv[1], 1, 0); |
2112 | z = FindBuiltinFile(argv[1], 1, 0); |
2521 | if (z) |
- | |
2522 | { |
2113 | if( z ){ |
2523 | int rc; |
2114 | int rc; |
2524 | rc = Tcl_Eval (interp, z); |
2115 | rc = Tcl_Eval(interp,z); |
2525 | if (rc == TCL_ERROR) |
2116 | if (rc == TCL_ERROR) { |
2526 | { |
- | |
2527 | char msg[200]; |
2117 | char msg[200]; |
2528 | sprintf ( |
- | |
2529 | msg, |
- | |
2530 | "\n (file \"%.150s\" line %d)", |
2118 | sprintf(msg, "\n (file \"%.150s\" line %d)", argv[1], |
2531 | argv[1], |
- | |
2532 | interp->errorLine); |
2119 | interp->errorLine); |
2533 | Tcl_AddErrorInfo (interp, msg); |
2120 | Tcl_AddErrorInfo(interp, msg); |
2534 | } |
2121 | } else { |
2535 | else |
- | |
2536 | { |
2122 | rc = TCL_OK; |
2537 | rc = TCL_OK; |
- | |
2538 | } |
2123 | } |
2539 | return rc; |
2124 | return rc; |
2540 | } |
2125 | } |
2541 | #if ET_STANDALONE |
2126 | #if ET_STANDALONE |
2542 | Et_ResultF (interp, "no such file: \"%s\"", argv[1]); |
2127 | Et_ResultF(interp,"no such file: \"%s\"", argv[1]); |
2543 | return TCL_ERROR; |
2128 | return TCL_ERROR; |
2544 | #else |
2129 | #else |
2545 | return Tcl_EvalFile (interp, argv[1]); |
2130 | return Tcl_EvalFile(interp,argv[1]); |
2546 | #endif |
2131 | #endif |
2547 | } |
2132 | } |
2548 | 2133 | ||
2549 | #ifndef ET_HAVE_INSERTPROC |
2134 | #ifndef ET_HAVE_INSERTPROC |
2550 | /* |
2135 | /* |
2551 | ** An overloaded version of "file exists". First check for the file |
2136 | ** An overloaded version of "file exists". First check for the file |
2552 | ** in the file table, then go to disk. |
2137 | ** in the file table, then go to disk. |
2553 | ** |
2138 | ** |
2554 | ** We only overload "file exists" if we don't have InsertProc() |
2139 | ** We only overload "file exists" if we don't have InsertProc() |
2555 | ** procedures. If we do have InsertProc() procedures, they will |
2140 | ** procedures. If we do have InsertProc() procedures, they will |
2556 | ** handle this more efficiently. |
2141 | ** handle this more efficiently. |
2557 | */ |
2142 | */ |
2558 | static int Et_FileExists (ET_TCLARGS) |
2143 | static int Et_FileExists(ET_TCLARGS){ |
2559 | { |
- | |
2560 | int i, rc; |
2144 | int i, rc; |
2561 | Tcl_DString str; |
2145 | Tcl_DString str; |
2562 | if (argc == 3 && strncmp (argv[1], "exis", 4) == 0) |
2146 | if( argc==3 && strncmp(argv[1],"exis",4)==0 ){ |
2563 | { |
- | |
2564 | if (FindBuiltinFile (argv[2], 0, 0) != 0) |
2147 | if( FindBuiltinFile(argv[2], 0, 0)!=0 ){ |
2565 | { |
- | |
2566 | interp->result = "1"; |
2148 | interp->result = "1"; |
2567 | return TCL_OK; |
2149 | return TCL_OK; |
2568 | } |
2150 | } |
2569 | } |
2151 | } |
2570 | Tcl_DStringInit (&str); |
2152 | Tcl_DStringInit(&str); |
2571 | Tcl_DStringAppendElement (&str, "Et_FileCmd"); |
2153 | Tcl_DStringAppendElement(&str,"Et_FileCmd"); |
2572 | for (i = 1; i < argc; i++) |
2154 | for(i=1; i<argc; i++){ |
2573 | { |
- | |
2574 | Tcl_DStringAppendElement (&str, argv[i]); |
2155 | Tcl_DStringAppendElement(&str, argv[i]); |
2575 | } |
2156 | } |
2576 | rc = Tcl_Eval (interp, Tcl_DStringValue (&str)); |
2157 | rc = Tcl_Eval(interp, Tcl_DStringValue(&str)); |
2577 | Tcl_DStringFree (&str); |
2158 | Tcl_DStringFree(&str); |
2578 | return rc; |
2159 | return rc; |
2579 | } |
2160 | } |
2580 | #endif |
2161 | #endif |
2581 | 2162 | ||
2582 | /* |
2163 | /* |
2583 | ** This is the main Tcl interpreter. It's a global variable so it |
2164 | ** This is the main Tcl interpreter. It's a global variable so it |
2584 | ** can be accessed easily from C code. |
2165 | ** can be accessed easily from C code. |
2585 | */ |
2166 | */ |
2586 | Tcl_Interp *Et_Interp = 0; |
2167 | Tcl_Interp *Et_Interp = 0; |
2587 | 2168 | ||
- | 2169 | ||
2588 | #if ET_WIN32 |
2170 | #if ET_WIN32 |
2589 | /* |
2171 | /* |
2590 | ** Implement the Et_MessageBox command on Windows platforms. We |
2172 | ** Implement the Et_MessageBox command on Windows platforms. We |
2591 | ** use the MessageBox() function from the Win32 API so that the |
2173 | ** use the MessageBox() function from the Win32 API so that the |
2592 | ** error message will be displayed as a dialog box. Writing to |
2174 | ** error message will be displayed as a dialog box. Writing to |
2593 | ** standard error doesn't do anything on windows. |
2175 | ** standard error doesn't do anything on windows. |
2594 | */ |
2176 | */ |
2595 | int Et_MessageBox (ET_TCLARGS) |
2177 | int Et_MessageBox(ET_TCLARGS){ |
2596 | { |
- | |
2597 | char *zMsg = "(Empty Message)"; |
2178 | char *zMsg = "(Empty Message)"; |
2598 | char *zTitle = "Message..."; |
2179 | char *zTitle = "Message..."; |
2599 | 2180 | ||
2600 | if (argc > 1) |
2181 | if( argc>1 ){ |
2601 | { |
- | |
2602 | zTitle = argv[1]; |
2182 | zTitle = argv[1]; |
2603 | } |
2183 | } |
2604 | if (argc > 2) |
2184 | if( argc>2 ){ |
2605 | { |
- | |
2606 | zMsg = argv[2]; |
2185 | zMsg = argv[2]; |
2607 | } |
2186 | } |
2608 | MessageBox (0, zMsg, zTitle, MB_ICONSTOP | MB_OK); |
2187 | MessageBox(0, zMsg, zTitle, MB_ICONSTOP | MB_OK); |
2609 | return TCL_OK; |
2188 | return TCL_OK; |
2610 | } |
2189 | } |
2611 | #endif |
2190 | #endif |
2612 | 2191 | ||
2613 | /* |
2192 | /* |
2614 | ** A default implementation for "bgerror" |
2193 | ** A default implementation for "bgerror" |
2615 | */ |
2194 | */ |
- | 2195 | static char zBgerror[] = |
|
2616 | static char zBgerror[] = "proc Et_Bgerror err {\n" |
2196 | "proc Et_Bgerror err {\n" |
2617 | " global errorInfo tk_library\n" |
2197 | " global errorInfo tk_library\n" |
2618 | " if {[info exists errorInfo]} {\n" |
2198 | " if {[info exists errorInfo]} {\n" |
2619 | " set ei $errorInfo\n" |
2199 | " set ei $errorInfo\n" |
2620 | " } else {\n" |
2200 | " } else {\n" |
2621 | " set ei {}\n" |
2201 | " set ei {}\n" |
2622 | " }\n" |
2202 | " }\n" |
2623 | " if {[catch {bgerror $err}]==0} return\n" |
2203 | " if {[catch {bgerror $err}]==0} return\n" |
2624 | " if {[string length $ei]>0} {\n" |
2204 | " if {[string length $ei]>0} {\n" |
2625 | " set err $ei\n" |
2205 | " set err $ei\n" |
2626 | " }\n" |
2206 | " }\n" |
2627 | " if {[catch {Et_MessageBox {Error} $err}]} {\n" |
2207 | " if {[catch {Et_MessageBox {Error} $err}]} {\n" |
2628 | " puts stderr $err\n" |
2208 | " puts stderr $err\n" |
2629 | " }\n" |
2209 | " }\n" |
2630 | " exit\n" |
2210 | " exit\n" |
2631 | "}\n"; |
2211 | "}\n" |
- | 2212 | ; |
|
2632 | 2213 | ||
2633 | /* |
2214 | /* |
2634 | ** Do the initialization. |
2215 | ** Do the initialization. |
2635 | ** |
2216 | ** |
2636 | ** This routine is called after the interpreter is created, but |
2217 | ** This routine is called after the interpreter is created, but |
2637 | ** before Et_PreInit() or Et_AppInit() have been run. |
2218 | ** before Et_PreInit() or Et_AppInit() have been run. |
2638 | */ |
2219 | */ |
2639 | static int Et_DoInit (Tcl_Interp *interp) |
2220 | static int Et_DoInit(Tcl_Interp *interp){ |
2640 | { |
- | |
2641 | int i; |
2221 | int i; |
2642 | extern int Et_PreInit (Tcl_Interp *); |
2222 | extern int Et_PreInit(Tcl_Interp*); |
2643 | extern int Et_AppInit (Tcl_Interp *); |
2223 | extern int Et_AppInit(Tcl_Interp*); |
2644 | 2224 | ||
2645 | /* Insert our alternative stat(), access() and open() procedures |
2225 | /* Insert our alternative stat(), access() and open() procedures |
2646 | ** so that any attempt to work with a file will check our built-in |
2226 | ** so that any attempt to work with a file will check our built-in |
2647 | ** scripts first. |
2227 | ** scripts first. |
2648 | */ |
2228 | */ |
2649 | #ifdef ET_HAVE_INSERTPROC |
2229 | #ifdef ET_HAVE_INSERTPROC |
2650 | TclStatInsertProc (Et_FileStat); |
2230 | TclStatInsertProc(Et_FileStat); |
2651 | TclAccessInsertProc (Et_FileAccess); |
2231 | TclAccessInsertProc(Et_FileAccess); |
2652 | TclOpenFileChannelInsertProc (Et_FileOpen); |
2232 | TclOpenFileChannelInsertProc(Et_FileOpen); |
2653 | #endif |
2233 | #endif |
2654 | 2234 | ||
2655 | /* Initialize the hash-table for built-in scripts |
2235 | /* Initialize the hash-table for built-in scripts |
2656 | */ |
2236 | */ |
2657 | FilenameHashInit (); |
2237 | FilenameHashInit(); |
2658 | 2238 | ||
2659 | /* The Et_NewBuiltFile command is inserted for use by FreeWrap |
2239 | /* The Et_NewBuiltFile command is inserted for use by FreeWrap |
2660 | ** and similar tools. |
2240 | ** and similar tools. |
2661 | */ |
2241 | */ |
2662 | #if ET_HAVE_OBJ |
2242 | #if ET_HAVE_OBJ |
2663 | Tcl_CreateObjCommand (interp, "Et_NewBuiltinFile", Et_NewBuiltinFileCmd, 0, 0); |
2243 | Tcl_CreateObjCommand(interp,"Et_NewBuiltinFile",Et_NewBuiltinFileCmd,0,0); |
2664 | #else |
2244 | #else |
2665 | Tcl_CreateCommand (interp, "Et_NewBuiltinFile", Et_NewBuiltinFileCmd, 0, 0); |
2245 | Tcl_CreateCommand(interp,"Et_NewBuiltinFile",Et_NewBuiltinFileCmd,0,0); |
2666 | #endif |
2246 | #endif |
2667 | 2247 | ||
2668 | /* Overload the "file" and "source" commands |
2248 | /* Overload the "file" and "source" commands |
2669 | */ |
2249 | */ |
2670 | #ifndef ET_HAVE_INSERTPROC |
2250 | #ifndef ET_HAVE_INSERTPROC |
2671 | { |
2251 | { |
2672 | static char zRename[] = "rename file Et_FileCmd"; |
2252 | static char zRename[] = "rename file Et_FileCmd"; |
2673 | Tcl_Eval (interp, zRename); |
2253 | Tcl_Eval(interp,zRename); |
2674 | Tcl_CreateCommand (interp, "file", Et_FileExists, 0, 0); |
2254 | Tcl_CreateCommand(interp,"file",Et_FileExists,0,0); |
2675 | } |
2255 | } |
2676 | #endif |
2256 | #endif |
2677 | Tcl_CreateCommand (interp, "source", Et_Source, 0, 0); |
2257 | Tcl_CreateCommand(interp,"source",Et_Source,0,0); |
2678 | 2258 | ||
2679 | Et_Interp = interp; |
2259 | Et_Interp = interp; |
2680 | #ifdef ET_TCL_LIBRARY |
2260 | #ifdef ET_TCL_LIBRARY |
2681 | Tcl_SetVar (interp, "tcl_library", ET_TCL_LIBRARY, TCL_GLOBAL_ONLY); |
2261 | Tcl_SetVar(interp,"tcl_library",ET_TCL_LIBRARY,TCL_GLOBAL_ONLY); |
2682 | Tcl_SetVar (interp, "tcl_libPath", ET_TCL_LIBRARY, TCL_GLOBAL_ONLY); |
2262 | Tcl_SetVar(interp,"tcl_libPath",ET_TCL_LIBRARY,TCL_GLOBAL_ONLY); |
2683 | Tcl_SetVar2 (interp, "env", "TCL_LIBRARY", ET_TCL_LIBRARY, TCL_GLOBAL_ONLY); |
2263 | Tcl_SetVar2(interp,"env","TCL_LIBRARY",ET_TCL_LIBRARY,TCL_GLOBAL_ONLY); |
2684 | #endif |
2264 | #endif |
2685 | #ifdef ET_TK_LIBRARY |
2265 | #ifdef ET_TK_LIBRARY |
2686 | Tcl_SetVar (interp, "tk_library", ET_TK_LIBRARY, TCL_GLOBAL_ONLY); |
2266 | Tcl_SetVar(interp,"tk_library",ET_TK_LIBRARY,TCL_GLOBAL_ONLY); |
2687 | Tcl_SetVar2 (interp, "env", "TK_LIBRARY", ET_TK_LIBRARY, TCL_GLOBAL_ONLY); |
2267 | Tcl_SetVar2(interp,"env","TK_LIBRARY",ET_TK_LIBRARY,TCL_GLOBAL_ONLY); |
2688 | #endif |
2268 | #endif |
2689 | #if ET_WIN32 |
2269 | #if ET_WIN32 |
2690 | Tcl_CreateCommand (interp, "Et_MessageBox", Et_MessageBox, 0, 0); |
2270 | Tcl_CreateCommand(interp,"Et_MessageBox",Et_MessageBox, 0, 0); |
2691 | #endif |
2271 | #endif |
2692 | Tcl_Eval (interp, zBgerror); |
2272 | Tcl_Eval(interp,zBgerror); |
2693 | #if ET_HAVE_PREINIT |
2273 | #if ET_HAVE_PREINIT |
2694 | if (Et_PreInit (interp) == TCL_ERROR) |
2274 | if( Et_PreInit(interp) == TCL_ERROR ){ |
2695 | { |
- | |
2696 | goto initerr; |
2275 | goto initerr; |
2697 | } |
2276 | } |
2698 | #endif |
2277 | #endif |
2699 | if (Tcl_Init (interp) == TCL_ERROR) |
2278 | if( Tcl_Init(interp) == TCL_ERROR ){ |
2700 | { |
- | |
2701 | goto initerr; |
2279 | goto initerr; |
2702 | } |
2280 | } |
2703 | Et_GlobalEvalF (interp, "set dir $tcl_library;source $dir/tclIndex;unset dir"); |
2281 | Et_GlobalEvalF(interp,"set dir $tcl_library;source $dir/tclIndex;unset dir"); |
2704 | #if ET_ENABLE_TK |
2282 | #if ET_ENABLE_TK |
2705 | if (Tk_Init (interp) == TCL_ERROR) |
2283 | if( Tk_Init(interp) == TCL_ERROR ){ |
2706 | { |
- | |
2707 | goto initerr; |
2284 | goto initerr; |
2708 | } |
2285 | } |
2709 | Tcl_StaticPackage (interp, "Tk", Tk_Init, 0); |
2286 | Tcl_StaticPackage(interp,"Tk", Tk_Init, 0); |
2710 | Et_GlobalEvalF (interp, "set dir $tk_library;source $dir/tclIndex;unset dir"); |
2287 | Et_GlobalEvalF(interp,"set dir $tk_library;source $dir/tclIndex;unset dir"); |
2711 | #endif |
2288 | #endif |
2712 | /* Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY); */ |
2289 | /* Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY); */ |
2713 | for (i = 0; i < sizeof (Et_CmdSet) / sizeof (Et_CmdSet[0]) - 1; i++) |
2290 | for(i=0; i<sizeof(Et_CmdSet)/sizeof(Et_CmdSet[0]) - 1; i++){ |
2714 | { |
- | |
2715 | Tcl_CreateCommand (interp, Et_CmdSet[i].zName, Et_CmdSet[i].xProc, 0, 0); |
2291 | Tcl_CreateCommand(interp, Et_CmdSet[i].zName, Et_CmdSet[i].xProc, 0, 0); |
2716 | } |
2292 | } |
2717 | #if ET_ENABLE_OBJ |
2293 | #if ET_ENABLE_OBJ |
2718 | for (i = 0; i < sizeof (Et_ObjSet) / sizeof (Et_ObjSet[0]) - 1; i++) |
2294 | for(i=0; i<sizeof(Et_ObjSet)/sizeof(Et_ObjSet[0]) - 1; i++){ |
2719 | { |
- | |
2720 | Tcl_CreateObjCommand (interp, Et_ObjSet[i].zName, Et_ObjSet[i].xProc, 0, 0); |
2295 | Tcl_CreateObjCommand(interp, Et_ObjSet[i].zName, Et_ObjSet[i].xProc, 0, 0); |
2721 | } |
2296 | } |
2722 | #endif |
2297 | #endif |
2723 | Tcl_LinkVar (interp, "Et_EvalTrace", (char *) &Et_EvalTrace, TCL_LINK_BOOLEAN); |
2298 | Tcl_LinkVar(interp,"Et_EvalTrace",(char*)&Et_EvalTrace,TCL_LINK_BOOLEAN); |
2724 | Tcl_SetVar (interp, "et_version", ET_VERSION, TCL_GLOBAL_ONLY); |
2299 | Tcl_SetVar(interp,"et_version",ET_VERSION,TCL_GLOBAL_ONLY); |
2725 | #if ET_HAVE_APPINIT |
2300 | #if ET_HAVE_APPINIT |
2726 | if (Et_AppInit (interp) == TCL_ERROR) |
2301 | if( Et_AppInit(interp) == TCL_ERROR ){ |
2727 | { |
- | |
2728 | goto initerr; |
2302 | goto initerr; |
2729 | } |
2303 | } |
2730 | #endif |
2304 | #endif |
2731 | #if ET_ENABLE_TK && !ET_EXTENSION |
2305 | #if ET_ENABLE_TK && !ET_EXTENSION |
2732 | Et_NewBuiltinFile ("builtin:/console.tcl", zEtConsole, sizeof (zEtConsole)); |
2306 | Et_NewBuiltinFile("builtin:/console.tcl", zEtConsole, sizeof(zEtConsole)); |
2733 | #if ET_CONSOLE |
2307 | #if ET_CONSOLE |
2734 | Tcl_Eval ( |
- | |
2735 | interp, |
2308 | Tcl_Eval(interp, |
2736 | "source builtin:/console.tcl\n" |
2309 | "source builtin:/console.tcl\n" |
2737 | "console:create {.@console} {% } {Tcl/Tk Console}\n"); |
2310 | "console:create {.@console} {% } {Tcl/Tk Console}\n" |
- | 2311 | ); |
|
2738 | #endif |
2312 | #endif |
2739 | #endif |
2313 | #endif |
2740 | #ifdef ET_MAIN_SCRIPT |
2314 | #ifdef ET_MAIN_SCRIPT |
2741 | if (Et_EvalF (interp, "source \"%q\"", ET_MAIN_SCRIPT) != TCL_OK) |
2315 | if( Et_EvalF(interp,"source \"%q\"", ET_MAIN_SCRIPT)!=TCL_OK ){ |
2742 | { |
- | |
2743 | goto initerr; |
2316 | goto initerr; |
2744 | } |
2317 | } |
2745 | #endif |
2318 | #endif |
2746 | return TCL_OK; |
2319 | return TCL_OK; |
2747 | 2320 | ||
2748 | initerr: |
2321 | initerr: |
2749 | Et_EvalF (interp, "Et_Bgerror \"%q\"", interp->result); |
2322 | Et_EvalF(interp,"Et_Bgerror \"%q\"", interp->result); |
2750 | return TCL_ERROR; |
2323 | return TCL_ERROR; |
2751 | } |
2324 | } |
2752 | 2325 | ||
2753 | #if ET_READ_STDIN == 0 || ET_AUTO_FORK != 0 |
2326 | #if ET_READ_STDIN==0 || ET_AUTO_FORK!=0 |
2754 | /* |
2327 | /* |
2755 | ** Initialize everything. |
2328 | ** Initialize everything. |
2756 | */ |
2329 | */ |
2757 | static int Et_Local_Init (int argc, char **argv) |
2330 | static int Et_Local_Init(int argc, char **argv){ |
2758 | { |
- | |
2759 | Tcl_Interp *interp; |
2331 | Tcl_Interp *interp; |
2760 | char *args; |
2332 | char *args; |
2761 | char buf[100]; |
2333 | char buf[100]; |
2762 | #if !ET_HAVE_CUSTOM_MAINLOOP |
2334 | #if !ET_HAVE_CUSTOM_MAINLOOP |
2763 | static char zWaitForever[] = |
2335 | static char zWaitForever[] = |
2764 | #if ET_ENABLE_TK |
2336 | #if ET_ENABLE_TK |
2765 | "bind . <Destroy> {if {![winfo exists .]} exit}\n" |
2337 | "bind . <Destroy> {if {![winfo exists .]} exit}\n" |
2766 | #endif |
2338 | #endif |
2767 | "while 1 {vwait forever}"; |
2339 | "while 1 {vwait forever}"; |
2768 | #endif |
2340 | #endif |
2769 | 2341 | ||
2770 | Tcl_FindExecutable (argv[0]); |
2342 | Tcl_FindExecutable(argv[0]); |
2771 | interp = Tcl_CreateInterp (); |
2343 | interp = Tcl_CreateInterp(); |
2772 | args = Tcl_Merge (argc - 1, argv + 1); |
2344 | args = Tcl_Merge(argc-1, argv+1); |
2773 | Tcl_SetVar (interp, "argv", args, TCL_GLOBAL_ONLY); |
2345 | Tcl_SetVar(interp, "argv", args, TCL_GLOBAL_ONLY); |
2774 | ckfree (args); |
2346 | ckfree(args); |
2775 | sprintf (buf, "%d", argc - 1); |
2347 | sprintf(buf, "%d", argc-1); |
2776 | Tcl_SetVar (interp, "argc", buf, TCL_GLOBAL_ONLY); |
2348 | Tcl_SetVar(interp, "argc", buf, TCL_GLOBAL_ONLY); |
2777 | Tcl_SetVar (interp, "argv0", argv[0], TCL_GLOBAL_ONLY); |
2349 | Tcl_SetVar(interp, "argv0", argv[0], TCL_GLOBAL_ONLY); |
2778 | Tcl_SetVar (interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); |
2350 | Tcl_SetVar(interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); |
2779 | Et_DoInit (interp); |
2351 | Et_DoInit(interp); |
2780 | #if ET_HAVE_CUSTOM_MAINLOOP |
2352 | #if ET_HAVE_CUSTOM_MAINLOOP |
2781 | Et_CustomMainLoop (interp); |
2353 | Et_CustomMainLoop(interp); |
2782 | #else |
2354 | #else |
2783 | Tcl_Eval (interp, zWaitForever); |
2355 | Tcl_Eval(interp,zWaitForever); |
2784 | #endif |
2356 | #endif |
2785 | return 0; |
2357 | return 0; |
2786 | } |
2358 | } |
2787 | #endif |
2359 | #endif |
2788 | 2360 | ||
2789 | /* |
2361 | /* |
2790 | ** This routine is called to do the complete initialization. |
2362 | ** This routine is called to do the complete initialization. |
2791 | */ |
2363 | */ |
2792 | int Et_Init (int argc, char **argv) |
2364 | int Et_Init(int argc, char **argv){ |
2793 | { |
- | |
2794 | #ifdef ET_TCL_LIBRARY |
2365 | #ifdef ET_TCL_LIBRARY |
2795 | putenv ("TCL_LIBRARY=" ET_TCL_LIBRARY); |
2366 | putenv("TCL_LIBRARY=" ET_TCL_LIBRARY); |
2796 | #endif |
2367 | #endif |
2797 | #ifdef ET_TK_LIBRARY |
2368 | #ifdef ET_TK_LIBRARY |
2798 | putenv ("TK_LIBRARY=" ET_TK_LIBRARY); |
2369 | putenv("TK_LIBRARY=" ET_TK_LIBRARY); |
2799 | #endif |
2370 | #endif |
2800 | #if ET_CONSOLE || !ET_READ_STDIN |
2371 | #if ET_CONSOLE || !ET_READ_STDIN |
2801 | Et_Local_Init (argc, argv); |
2372 | Et_Local_Init(argc, argv); |
2802 | #else |
- | |
2803 | #if ET_ENABLE_TK |
- | |
2804 | Tk_Main (argc, argv, Et_DoInit); |
- | |
2805 | #else |
2373 | #else |
- | 2374 | # if ET_ENABLE_TK |
|
- | 2375 | Tk_Main(argc,argv,Et_DoInit); |
|
- | 2376 | # else |
|
2806 | Tcl_Main (argc, argv, Et_DoInit); |
2377 | Tcl_Main(argc, argv, Et_DoInit); |
- | 2378 | # endif |
|
2807 | #endif |
2379 | #endif |
2808 | #endif |
- | |
2809 | return 0; |
2380 | return 0; |
2810 | } |
2381 | } |
2811 | 2382 | ||
2812 | #if !ET_HAVE_MAIN && !ET_EXTENSION |
2383 | #if !ET_HAVE_MAIN && !ET_EXTENSION |
2813 | /* |
2384 | /* |
2814 | ** Main routine for UNIX programs. If the user has supplied |
2385 | ** Main routine for UNIX programs. If the user has supplied |
2815 | ** their own main() routine in a C module, then the ET_HAVE_MAIN |
2386 | ** their own main() routine in a C module, then the ET_HAVE_MAIN |
2816 | ** macro will be set to 1 and this code will be skipped. |
2387 | ** macro will be set to 1 and this code will be skipped. |
2817 | */ |
2388 | */ |
2818 | int main (int argc, char **argv) |
2389 | int main(int argc, char **argv){ |
2819 | { |
- | |
2820 | #if ET_AUTO_FORK |
2390 | #if ET_AUTO_FORK |
2821 | int rc = fork (); |
2391 | int rc = fork(); |
2822 | if (rc < 0) |
- | |
2823 | { |
2392 | if( rc<0 ){ |
2824 | perror ("can't fork"); |
2393 | perror("can't fork"); |
2825 | exit (1); |
2394 | exit(1); |
2826 | } |
2395 | } |
2827 | if (rc > 0) |
- | |
2828 | return 0; |
2396 | if( rc>0 ) return 0; |
2829 | close (0); |
2397 | close(0); |
2830 | open ("/dev/null", O_RDONLY); |
2398 | open("/dev/null",O_RDONLY); |
2831 | close (1); |
2399 | close(1); |
2832 | open ("/dev/null", O_WRONLY); |
2400 | open("/dev/null",O_WRONLY); |
2833 | #endif |
2401 | #endif |
2834 | return Et_Init (argc, argv) != TCL_OK; |
2402 | return Et_Init(argc,argv)!=TCL_OK; |
2835 | } |
2403 | } |
2836 | #endif |
2404 | #endif |
2837 | 2405 | ||
2838 | #if ET_EXTENSION |
2406 | #if ET_EXTENSION |
2839 | /* |
2407 | /* |
2840 | ** If the -extension flag is used, then generate code that will be |
2408 | ** If the -extension flag is used, then generate code that will be |
2841 | ** turned into a loadable shared library or DLL, not a standalone |
2409 | ** turned into a loadable shared library or DLL, not a standalone |
2842 | ** executable. |
2410 | ** executable. |
2843 | */ |
2411 | */ |
2844 | int ET_EXTENSION_NAME (Tcl_Interp *interp) |
2412 | int ET_EXTENSION_NAME(Tcl_Interp *interp){ |
2845 | { |
- | |
2846 | int i; |
2413 | int i; |
2847 | #ifndef ET_HAVE_INSERTPROC |
2414 | #ifndef ET_HAVE_INSERTPROC |
2848 | Tcl_AppendResult ( |
2415 | Tcl_AppendResult(interp, |
2849 | interp, |
- | |
2850 | "mktclapp can only generate extensions for Tcl/Tk version " |
2416 | "mktclapp can only generate extensions for Tcl/Tk version " |
2851 | "8.0.3 and later. This is version " TCL_MAJOR_VERSION "." TCL_MINOR_VERSION |
2417 | "8.0.3 and later. This is version " |
2852 | "." TCL_RELEASE_SERIAL, |
2418 | TCL_MAJOR_VERSION "." TCL_MINOR_VERSION "." TCL_RELEASE_SERIAL, 0); |
2853 | 0); |
- | |
2854 | return TCL_ERROR; |
2419 | return TCL_ERROR; |
2855 | #endif |
2420 | #endif |
2856 | #ifdef ET_HAVE_INSERTPROC |
2421 | #ifdef ET_HAVE_INSERTPROC |
2857 | #ifdef USE_TCL_STUBS |
2422 | #ifdef USE_TCL_STUBS |
2858 | if (Tcl_InitStubs (interp, "8.0", 0) == 0) |
2423 | if( Tcl_InitStubs(interp,"8.0",0)==0 ){ |
2859 | { |
- | |
2860 | return TCL_ERROR; |
2424 | return TCL_ERROR; |
2861 | } |
2425 | } |
2862 | if (Tk_InitStubs (interp, "8.0", 0) == 0) |
2426 | if( Tk_InitStubs(interp,"8.0",0)==0 ){ |
2863 | { |
- | |
2864 | return TCL_ERROR; |
2427 | return TCL_ERROR; |
2865 | } |
2428 | } |
2866 | #endif |
2429 | #endif |
2867 | Et_Interp = interp; |
2430 | Et_Interp = interp; |
2868 | TclStatInsertProc (Et_FileStat); |
2431 | TclStatInsertProc(Et_FileStat); |
2869 | TclAccessInsertProc (Et_FileAccess); |
2432 | TclAccessInsertProc(Et_FileAccess); |
2870 | TclOpenFileChannelInsertProc (Et_FileOpen); |
2433 | TclOpenFileChannelInsertProc(Et_FileOpen); |
2871 | FilenameHashInit (); |
2434 | FilenameHashInit(); |
2872 | for (i = 0; i < sizeof (Et_CmdSet) / sizeof (Et_CmdSet[0]) - 1; i++) |
2435 | for(i=0; i<sizeof(Et_CmdSet)/sizeof(Et_CmdSet[0]) - 1; i++){ |
2873 | { |
- | |
2874 | Tcl_CreateCommand (interp, Et_CmdSet[i].zName, Et_CmdSet[i].xProc, 0, 0); |
2436 | Tcl_CreateCommand(interp, Et_CmdSet[i].zName, Et_CmdSet[i].xProc, 0, 0); |
2875 | } |
2437 | } |
2876 | #if ET_ENABLE_OBJ |
2438 | #if ET_ENABLE_OBJ |
2877 | for (i = 0; i < sizeof (Et_ObjSet) / sizeof (Et_ObjSet[0]) - 1; i++) |
2439 | for(i=0; i<sizeof(Et_ObjSet)/sizeof(Et_ObjSet[0]) - 1; i++){ |
2878 | { |
- | |
2879 | Tcl_CreateObjCommand (interp, Et_ObjSet[i].zName, Et_ObjSet[i].xProc, 0, 0); |
2440 | Tcl_CreateObjCommand(interp, Et_ObjSet[i].zName, Et_ObjSet[i].xProc, 0, 0); |
2880 | } |
2441 | } |
2881 | #endif |
2442 | #endif |
2882 | Tcl_LinkVar (interp, "Et_EvalTrace", (char *) &Et_EvalTrace, TCL_LINK_BOOLEAN); |
2443 | Tcl_LinkVar(interp,"Et_EvalTrace",(char*)&Et_EvalTrace,TCL_LINK_BOOLEAN); |
2883 | Tcl_SetVar (interp, "et_version", ET_VERSION, TCL_GLOBAL_ONLY); |
2444 | Tcl_SetVar(interp,"et_version",ET_VERSION,TCL_GLOBAL_ONLY); |
2884 | #if ET_HAVE_APPINIT |
2445 | #if ET_HAVE_APPINIT |
2885 | if (Et_AppInit (interp) == TCL_ERROR) |
2446 | if( Et_AppInit(interp) == TCL_ERROR ){ |
2886 | { |
- | |
2887 | return TCL_ERROR; |
2447 | return TCL_ERROR; |
2888 | } |
2448 | } |
2889 | #endif |
2449 | #endif |
2890 | #ifdef ET_MAIN_SCRIPT |
2450 | #ifdef ET_MAIN_SCRIPT |
2891 | if (Et_EvalF (interp, "source \"%q\"", ET_MAIN_SCRIPT) != TCL_OK) |
2451 | if( Et_EvalF(interp,"source \"%q\"", ET_MAIN_SCRIPT)!=TCL_OK ){ |
2892 | { |
- | |
2893 | return TCL_ERROR; |
2452 | return TCL_ERROR; |
2894 | } |
2453 | } |
2895 | #endif |
2454 | #endif |
2896 | return TCL_OK; |
2455 | return TCL_OK; |
2897 | #endif /* ET_HAVE_INSERTPROC */ |
2456 | #endif /* ET_HAVE_INSERTPROC */ |
2898 | } |
2457 | } |
2899 | int ET_SAFE_EXTENSION_NAME (Tcl_Interp *interp) |
2458 | int ET_SAFE_EXTENSION_NAME(Tcl_Interp *interp){ |
2900 | { |
- | |
2901 | return ET_EXTENSION_NAME (interp); |
2459 | return ET_EXTENSION_NAME(interp); |
2902 | } |
2460 | } |
2903 | #endif |
2461 | #endif |