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

« back to all changes in this revision

Viewing changes to debian/patches/03-spawn.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2006-10-01 22:23:00 UTC
  • mfrom: (2.1.7 edgy)
  • Revision ID: james.westby@ubuntu.com-20061001222300-08nd1wqc92mxggdq
Tags: 5.43.0-8
* Added patch from Niko Tyni <ntyni@iki.fi> to fix static library name on
  alpha, mips and mipsel (Closes: #390366).
* Added *.so symlink (Closes: #390365).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh /usr/share/dpatch/dpatch-run
 
2
## 03-spawn.dpatch by HJ Lu <hjl@lucon.org>
 
3
##
 
4
## DP: Fixes problems when running GCCs testsuite (Closes: #156854).
 
5
 
 
6
@DPATCH@
 
7
 
 
8
diff -Naur expect-5.43.0.orig/exp_chan.c expect-5.43.0/exp_chan.c
 
9
--- expect-5.43.0.orig/exp_chan.c       2005-02-08 02:01:20.000000000 +0000
 
10
+++ expect-5.43.0/exp_chan.c    2006-07-10 15:24:46.000000000 +0000
 
11
@@ -622,6 +622,7 @@
 
12
     esPtr->buffer = Tcl_NewStringObj("",0);
 
13
     Tcl_IncrRefCount(esPtr->buffer);
 
14
     esPtr->umsize = exp_default_match_max;
 
15
+    esPtr->umsize_changed = exp_default_match_max_changed;
 
16
     /* this will reallocate object with an appropriate sized buffer */
 
17
     expAdjust(esPtr);
 
18
 
 
19
diff -Naur expect-5.43.0.orig/exp_command.h expect-5.43.0/exp_command.h
 
20
--- expect-5.43.0.orig/exp_command.h    2004-07-30 15:35:28.000000000 +0000
 
21
+++ expect-5.43.0/exp_command.h 2006-07-10 15:24:46.000000000 +0000
 
22
@@ -30,6 +30,7 @@
 
23
 EXTERN char *          exp_get_var _ANSI_ARGS_((Tcl_Interp *,char *));
 
24
 
 
25
 EXTERN int exp_default_match_max;
 
26
+EXTERN int exp_default_match_max_changed;
 
27
 EXTERN int exp_default_parity;
 
28
 EXTERN int exp_default_rm_nulls;
 
29
 EXTERN int exp_default_close_on_eof;
 
30
@@ -103,6 +104,7 @@
 
31
     int msize;         /* # of bytes that buffer can hold (max) */
 
32
     int umsize;                /* # of bytes (min) that is guaranteed to match */
 
33
                        /* this comes from match_max command */
 
34
+    int umsize_changed;        /* is umsize changed by user?  */
 
35
     int printed;       /* # of bytes written to stdout (if logging on) */
 
36
                         /* but not actually returned via a match yet */
 
37
     int echoed;                /* additional # of bytes (beyond "printed" above) */
 
38
diff -Naur expect-5.43.0.orig/expect.c expect-5.43.0/expect.c
 
39
--- expect-5.43.0.orig/expect.c 2004-07-06 23:26:02.000000000 +0000
 
40
+++ expect-5.43.0/expect.c      2006-07-10 15:24:46.000000000 +0000
 
41
@@ -41,8 +41,17 @@
 
42
 #include "tcldbg.h"
 
43
 #endif
 
44
 
 
45
+/* The initial length is 2000. We increment it by 2000. The maximum
 
46
+   is 8MB (0x800000).  */
 
47
+#define EXP_MATCH_MAX          2000
 
48
+#define EXP_MATCH_INC          2000
 
49
+#define EXP_MATCH_STEP_LIMIT   0x700000
 
50
+#define EXP_MATCH_LIMIT                0x800000
 
51
+#define EXP_MATCH_LIMIT_QUOTE  "0x800000"
 
52
+
 
53
 /* initial length of strings that we can guarantee patterns can match */
 
54
-int exp_default_match_max =    2000;
 
55
+int exp_default_match_max =    EXP_MATCH_MAX;
 
56
+int exp_default_match_max_changed = 0;
 
57
 #define INIT_EXPECT_TIMEOUT_LIT        "10"    /* seconds */
 
58
 #define INIT_EXPECT_TIMEOUT    10      /* seconds */
 
59
 int exp_default_parity =       TRUE;
 
60
@@ -1619,6 +1628,76 @@
 
61
     return newsize;
 
62
 }
 
63
 
 
64
+/* returns # of bytes until we see a newline at the end or EOF.  */
 
65
+/*ARGSUSED*/
 
66
+static int
 
67
+expReadNewLine(interp,esPtr,save_flags) /* INTL */
 
68
+Tcl_Interp *interp;
 
69
+ExpState *esPtr;
 
70
+int save_flags;
 
71
+{
 
72
+    int size;
 
73
+    int exp_size;
 
74
+    int full_size;
 
75
+    int count;
 
76
+    char *str;
 
77
+
 
78
+    count = 0;
 
79
+    for (;;) {
 
80
+       exp_size = expSizeGet(esPtr);
 
81
+
 
82
+       /* When we reach the limit, we will only read one char at a
 
83
+          time.  */
 
84
+       if (esPtr->umsize >= EXP_MATCH_STEP_LIMIT)
 
85
+           size = TCL_UTF_MAX;
 
86
+       else
 
87
+           size = exp_size;
 
88
+
 
89
+       if (exp_size + TCL_UTF_MAX >= esPtr->msize) {
 
90
+           if (esPtr->umsize >= EXP_MATCH_LIMIT) {
 
91
+               expDiagLogU("WARNING: interact buffer is full. probably your program\r\n");
 
92
+               expDiagLogU("is not interactive or has a very long output line. The\r\n");
 
93
+               expDiagLogU("current limit is " EXP_MATCH_LIMIT_QUOTE ".\r\n");
 
94
+               expDiagLogU("Dumping first half of buffer in order to continue\r\n");
 
95
+               expDiagLogU("Recommend you enlarge the buffer.\r\n");
 
96
+               exp_buffer_shuffle(interp,esPtr,save_flags,EXPECT_OUT,"expect");
 
97
+               return count;
 
98
+           }
 
99
+           else {
 
100
+               esPtr->umsize += EXP_MATCH_INC;
 
101
+               expAdjust(esPtr);
 
102
+           }
 
103
+       }
 
104
+
 
105
+       full_size = esPtr->msize - (size / TCL_UTF_MAX);
 
106
+       size = Tcl_ReadChars(esPtr->channel,
 
107
+                       esPtr->buffer,
 
108
+                       full_size,
 
109
+                       1 /* append */);
 
110
+       if (size > 0) {
 
111
+           count += size;
 
112
+           /* We try again if there are more to read and we haven't
 
113
+              seen a newline at the end. */
 
114
+           if (size == full_size) {
 
115
+               str = Tcl_GetStringFromObj(esPtr->buffer, &size);
 
116
+               if (str[size - 1] != '\n')
 
117
+                   continue;
 
118
+           }
 
119
+       }
 
120
+       else {
 
121
+           /* It is even trickier. We got an error from read. We have
 
122
+              to recover from it. Let's make sure the size of
 
123
+              buffer is correct. It can be corrupted. */
 
124
+           str = Tcl_GetString(esPtr->buffer);
 
125
+           Tcl_SetObjLength(esPtr->buffer, strlen(str));
 
126
+       }
 
127
+
 
128
+       break;
 
129
+    }
 
130
+
 
131
+    return count;
 
132
+}
 
133
+
 
134
 /* returns # of bytes read or (non-positive) error of form EXP_XXX */
 
135
 /* returns 0 for end of file */
 
136
 /* If timeout is non-zero, set an alarm before doing the read, else assume */
 
137
@@ -1633,6 +1712,8 @@
 
138
 {
 
139
     int cc = EXP_TIMEOUT;
 
140
     int size = expSizeGet(esPtr);
 
141
+    int full_size;
 
142
+    int count;
 
143
 
 
144
     if (size + TCL_UTF_MAX >= esPtr->msize) 
 
145
        exp_buffer_shuffle(interp,esPtr,save_flags,EXPECT_OUT,"expect");
 
146
@@ -1649,11 +1730,43 @@
 
147
     }
 
148
 #endif
 
149
 
 
150
-    
 
151
+    /* FIXME: If we ask less than what is available in the tcl buffer
 
152
+       when tcl has seen EOF, we will throw away the remaining data
 
153
+       since the next read will get EOF. Since expect is line-oriented,
 
154
+       we exand our buffer to get EOF or the next newline at the end of
 
155
+       the input buffer. I don't know if it is the right fix.  H.J. */
 
156
+    count = 0;
 
157
+    full_size = esPtr->msize - (size / TCL_UTF_MAX);
 
158
     cc = Tcl_ReadChars(esPtr->channel,
 
159
-           esPtr->buffer,
 
160
-           esPtr->msize - (size / TCL_UTF_MAX),
 
161
-           1 /* append */);
 
162
+               esPtr->buffer,
 
163
+               full_size,
 
164
+               1 /* append */);
 
165
+    if (cc > 0) {
 
166
+       count += cc;
 
167
+       /* It gets very tricky. There are more to read. We will expand
 
168
+          our buffer and get EOF or a newline at the end unless the
 
169
+          buffer length has been changed.  */
 
170
+       if (cc == full_size) {
 
171
+           char *str;
 
172
+           str = Tcl_GetStringFromObj(esPtr->buffer, &size);
 
173
+           if (str[size - 1] != '\n') {
 
174
+               if (esPtr->umsize_changed) {
 
175
+                   char buf[20];       /* big enough for 64bit int in hex.  */
 
176
+                   snprintf(buf,sizeof(buf),"0x%x", esPtr->umsize);
 
177
+                   expDiagLogU("WARNING: interact buffer is not large enough to hold\r\n");
 
178
+                   expDiagLogU("all output. probably your program is not interactive or\r\n");
 
179
+                   expDiagLogU("has a very long output line. The current limit is ");
 
180
+                   expDiagLogU(buf);
 
181
+                   expDiagLogU(".\r\n");
 
182
+               }
 
183
+               else {
 
184
+                   cc = expReadNewLine(interp,esPtr,save_flags);
 
185
+                   if (cc > 0)
 
186
+                       count += cc;
 
187
+               }
 
188
+           }
 
189
+       }
 
190
+    }
 
191
     i_read_errno = errno;
 
192
 
 
193
 #ifdef SIMPLE_EVENT
 
194
@@ -1674,7 +1787,7 @@
 
195
        }
 
196
     }
 
197
 #endif
 
198
-    return cc; 
 
199
+    return count > 0 ? count : cc;
 
200
 }
 
201
 
 
202
 /*
 
203
@@ -2751,8 +2864,14 @@
 
204
        return(TCL_ERROR);
 
205
     }
 
206
 
 
207
-    if (Default) exp_default_match_max = size;
 
208
-    else esPtr->umsize = size;
 
209
+    if (Default) {
 
210
+       exp_default_match_max = size;
 
211
+       exp_default_match_max_changed = 1;
 
212
+    }
 
213
+    else {
 
214
+       esPtr->umsize = size;
 
215
+       esPtr->umsize_changed = 1;
 
216
+    }
 
217
 
 
218
     return(TCL_OK);
 
219
 }