~ubuntu-branches/ubuntu/trusty/expect/trusty

« back to all changes in this revision

Viewing changes to debian/patches/19-tk-init.patch

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2011-08-17 21:50:29 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110817215029-0cfarscc630tfc5v
Tags: 5.45-1
* New upstream release.
* Removed unnecessary patches.
* Removed the expectk package because expectk was dropped from the upstream
  distribution. See NEWS.Debian for possible workarounds.
* Updated package to standards version 3.9.2 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Author: Sergei Golovan <sgolovan@debian.org>
2
 
Description: Fixes Tk intialization by calling Tk_Init instead of using
3
 
 copied&pasted Tk_Init from older Tk.
4
 
Bug: https://sourceforge.net/tracker/?func=detail&aid=2585764&group_id=13179&atid=113179
5
 
Last-Update: 2009-11-12
6
 
 
7
 
--- expect-5.44.1.15.orig/exp_main_tk.c
8
 
+++ expect-5.44.1.15/exp_main_tk.c
9
 
@@ -29,7 +29,7 @@
10
 
  */
11
 
 
12
 
 #ifndef lint
13
 
-static char sccsid[] = "@(#) tkAppInit.c 1.19 95/12/23 17:09:24";
14
 
+/* static char sccsid[] = "@(#) tkAppInit.c 1.19 95/12/23 17:09:24"; */
15
 
 #endif /* not lint */
16
 
 
17
 
 /* Don't use stubs since we are in the main application. */
18
 
@@ -166,25 +166,12 @@
19
 
 
20
 
 
21
 
 
22
 
-
23
 
-/*
24
 
- * Count of number of main windows currently open in this process.
25
 
- */
26
 
-
27
 
-static int numMainWindows;
28
 
-
29
 
 /*
30
 
  * The variables and table below are used to parse arguments from
31
 
  * the "argv" variable in Tk_Init.
32
 
  */
33
 
 
34
 
-static int synchronize;
35
 
-static CONST char *name;
36
 
-static char *display;
37
 
-static char *geometry;
38
 
-static char *colormap;
39
 
-static char *visual;
40
 
-static int rest = 0;
41
 
+static int rest;
42
 
 
43
 
 /* for Expect */
44
 
 static int optcmd_eval();
45
 
@@ -195,21 +182,6 @@
46
 
 int print_version = 0;
47
 
 
48
 
 static Tk_ArgvInfo argTable[] = {
49
 
-    {"-colormap", TK_ARGV_STRING, (char *) NULL, (char *) &colormap,
50
 
-       "Colormap for main window"},
51
 
-    {"-display", TK_ARGV_STRING, (char *) NULL, (char *) &display,
52
 
-       "Display to use"},
53
 
-    {"-geometry", TK_ARGV_STRING, (char *) NULL, (char *) &geometry,
54
 
-       "Initial geometry for window"},
55
 
-    {"-name", TK_ARGV_STRING, (char *) NULL, (char *) &name,
56
 
-       "Name to use for application"},
57
 
-    {"-sync", TK_ARGV_CONSTANT, (char *) 1, (char *) &synchronize,
58
 
-       "Use synchronous mode for display server"},
59
 
-    {"-visual", TK_ARGV_STRING, (char *) NULL, (char *) &visual,
60
 
-       "Visual for main window"},
61
 
-    {"--", TK_ARGV_REST, (char *) 1, (char *) &rest,
62
 
-       "Pass all remaining arguments through to script"},
63
 
-/* for Expect */
64
 
     {"-command", TK_ARGV_GENFUNC, (char *) optcmd_eval, (char *)0,
65
 
        "Command(s) to execute immediately"},
66
 
     {"-diag", TK_ARGV_CONSTANT, (char *) optcmd_diagToStderr, (char *)0,
67
 
@@ -224,6 +196,8 @@
68
 
     {"-Debug", TK_ARGV_GENFUNC, (char *) optcmd_debug, (char *)0, 
69
 
        "Enable debugger"},
70
 
 #endif
71
 
+    {"--", TK_ARGV_REST, (char *) 1, (char *) &rest,
72
 
+       "Pass all remaining arguments through to script"},
73
 
     {(char *) NULL, TK_ARGV_END, (char *) NULL, (char *) NULL,
74
 
        (char *) NULL}
75
 
 };
76
 
@@ -257,11 +231,11 @@
77
 
     Tcl_Interp *interp;                /* Interpreter to initialize. */
78
 
 {
79
 
     CONST char *p;
80
 
-    char* alist, *cstr;
81
 
-    int argc, code;
82
 
-    char **argv, *args[20];
83
 
-    Tcl_DString class;
84
 
+    char *alist, *pp;
85
 
+    int argc, length, i, j;
86
 
+    char **argv, **newargv;
87
 
     char buffer[30];
88
 
+    size_t len;
89
 
 
90
 
     /*
91
 
      * If there is an "argv" variable, get its value, extract out
92
 
@@ -269,8 +243,7 @@
93
 
      * the arguments that we used.
94
 
      */
95
 
 
96
 
-    synchronize = 0;
97
 
-    name = display = geometry = colormap = visual = NULL; 
98
 
+    rest = -1;
99
 
     p = Tcl_GetVar2(interp, "argv", (char *) NULL, TCL_GLOBAL_ONLY);
100
 
     argv = NULL;
101
 
     if (p != NULL) {
102
 
@@ -299,115 +272,57 @@
103
 
            }
104
 
        }
105
 
 
106
 
-       alist = Tcl_Merge(argc, argv);
107
 
-       Tcl_SetVar2(interp, "argv", (char *) NULL, alist, TCL_GLOBAL_ONLY);
108
 
-       sprintf(buffer, "%d", argc);
109
 
-       Tcl_SetVar2(interp, "argc", (char *) NULL, buffer, TCL_GLOBAL_ONLY);
110
 
-       ckfree(alist);
111
 
-    }
112
 
-
113
 
-    /*
114
 
-     * Figure out the application's name and class.
115
 
-     */
116
 
+       if (rest >= 0) {
117
 
+           /* Resore '--' in arguments list
118
 
+            */
119
 
 
120
 
-    if (name == NULL) {
121
 
-       name = Tcl_GetVar(interp, "argv0", TCL_GLOBAL_ONLY);
122
 
-       if ((name == NULL) || (*name == 0)) {
123
 
-           name = "tk";
124
 
-       } else {
125
 
-           p = (char *)strrchr(name, '/');     /* added cast - DEL */
126
 
-           if (p != NULL) {
127
 
-               name = p+1;
128
 
+           length = 0;
129
 
+           for (i = 0; i < argc; i++) {
130
 
+               length += strlen(argv[i]) + 1;
131
 
            }
132
 
-       }
133
 
-    }
134
 
-    Tcl_DStringInit(&class);
135
 
-    Tcl_DStringAppend(&class, name, -1);
136
 
-    cstr = Tcl_DStringValue(&class);
137
 
-    if (islower(*cstr)) {
138
 
-       *cstr = toupper((unsigned char) *cstr);
139
 
-    }
140
 
 
141
 
-    /*
142
 
-     * Create an argument list for creating the top-level window,
143
 
-     * using the information parsed from argv, if any.
144
 
-     */
145
 
+           newargv = (char **) ckalloc((unsigned) ((argc+2)*sizeof(char *)) + length + 3);
146
 
 
147
 
-    args[0] = "toplevel";
148
 
-    args[1] = ".";
149
 
-    args[2] = "-class";
150
 
-    args[3] = Tcl_DStringValue(&class);
151
 
-    argc = 4;
152
 
-    if (display != NULL) {
153
 
-       args[argc] = "-screen";
154
 
-       args[argc+1] = display;
155
 
-       argc += 2;
156
 
-
157
 
-       /*
158
 
-        * If this is the first application for this process, save
159
 
-        * the display name in the DISPLAY environment variable so
160
 
-        * that it will be available to subprocesses created by us.
161
 
-        */
162
 
+           pp = ((char *) newargv) + (argc+2)*sizeof(char *);
163
 
+           j = 0;
164
 
+           for (i = 0; i < argc; i++) {
165
 
+               if (i == rest) {
166
 
+                   memcpy(pp, "--", 3);
167
 
+                   newargv[j++] = pp;
168
 
+                   pp += 3;
169
 
+               }
170
 
+
171
 
+               len = strlen(argv[i]) + 1;
172
 
+               memcpy(pp, argv[i], len);
173
 
+               newargv[j++] = pp;
174
 
+               pp += len;
175
 
+           }
176
 
+           newargv[j] = NULL;
177
 
 
178
 
-       if (numMainWindows == 0) {
179
 
-           Tcl_SetVar2(interp, "env", "DISPLAY", display, TCL_GLOBAL_ONLY);
180
 
+           alist = Tcl_Merge(argc+1, newargv);
181
 
+       } else {
182
 
+           newargv = NULL;
183
 
+           alist = Tcl_Merge(argc, argv);
184
 
        }
185
 
-    }
186
 
-    if (colormap != NULL) {
187
 
-       args[argc] = "-colormap";
188
 
-       args[argc+1] = colormap;
189
 
-       argc += 2;
190
 
-    }
191
 
-    if (visual != NULL) {
192
 
-       args[argc] = "-visual";
193
 
-       args[argc+1] = visual;
194
 
-       argc += 2;
195
 
-    }
196
 
-    args[argc] = NULL;
197
 
-    code = TkCreateFrame((ClientData) NULL, interp, argc, args, 1, name);
198
 
-    Tcl_DStringFree(&class);
199
 
-    if (code != TCL_OK) {
200
 
-       goto done;
201
 
-    }
202
 
-    Tcl_ResetResult(interp);
203
 
-#ifndef MAC_OSX_TK
204
 
-    if (synchronize) {
205
 
-       XSynchronize(Tk_Display(Tk_MainWindow(interp)), True);
206
 
-    }
207
 
-#endif
208
 
 
209
 
-    /*
210
 
-     * Set the geometry of the main window, if requested.  Put the
211
 
-     * requested geometry into the "geometry" variable.
212
 
-     */
213
 
-
214
 
-    if (geometry != NULL) {
215
 
-       Tcl_SetVar(interp, "geometry", geometry, TCL_GLOBAL_ONLY);
216
 
-       code = Tcl_VarEval(interp, "wm geometry . ", geometry, (char *) NULL);
217
 
-       if (code != TCL_OK) {
218
 
-           goto done;
219
 
-       }
220
 
-    }
221
 
-    if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 1) == NULL) {
222
 
-       code = TCL_ERROR;
223
 
-       goto done;
224
 
-    }
225
 
-    code = Tcl_PkgProvide(interp, "Tk", TK_VERSION);
226
 
-    if (code != TCL_OK) {
227
 
-       goto done;
228
 
+       Tcl_SetVar2(interp, "argv", (char *) NULL, alist, TCL_GLOBAL_ONLY);
229
 
+       sprintf(buffer, "%d", argc);
230
 
+       Tcl_SetVar2(interp, "argc", (char *) NULL, buffer, TCL_GLOBAL_ONLY);
231
 
+       ckfree(alist);
232
 
     }
233
 
 
234
 
-    /*
235
 
-     * Invoke platform-specific initialization.
236
 
-     */
237
 
-
238
 
-    code = TkpInit(interp, 0);
239
 
+    if (Tk_Init(interp) == TCL_ERROR) {
240
 
+       return TCL_ERROR;
241
 
+    }
242
 
 
243
 
-    done:
244
 
     if (argv != NULL) {
245
 
        ckfree((char *) argv);
246
 
     }
247
 
-    return code;
248
 
+    if (newargv != NULL) {
249
 
+       ckfree((char *) newargv);
250
 
+    }
251
 
+
252
 
+    return TCL_OK;
253
 
 }
254
 
 
255
 
 /*ARGSUSED*/