1
#!/bin/sh /usr/share/dpatch/dpatch-run
2
## 03-spawn.dpatch by HJ Lu <hjl@lucon.org>
4
## DP: Fixes problems when running GCCs testsuite (Closes: #156854).
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
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 */
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
23
EXTERN char * exp_get_var _ANSI_ARGS_((Tcl_Interp *,char *));
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;
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
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"
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 @@
64
+/* returns # of bytes until we see a newline at the end or EOF. */
67
+expReadNewLine(interp,esPtr,save_flags) /* INTL */
80
+ exp_size = expSizeGet(esPtr);
82
+ /* When we reach the limit, we will only read one char at a
84
+ if (esPtr->umsize >= EXP_MATCH_STEP_LIMIT)
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");
100
+ esPtr->umsize += EXP_MATCH_INC;
105
+ full_size = esPtr->msize - (size / TCL_UTF_MAX);
106
+ size = Tcl_ReadChars(esPtr->channel,
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')
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));
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 @@
139
int cc = EXP_TIMEOUT;
140
int size = expSizeGet(esPtr);
144
if (size + TCL_UTF_MAX >= esPtr->msize)
145
exp_buffer_shuffle(interp,esPtr,save_flags,EXPECT_OUT,"expect");
146
@@ -1649,11 +1730,43 @@
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. */
157
+ full_size = esPtr->msize - (size / TCL_UTF_MAX);
158
cc = Tcl_ReadChars(esPtr->channel,
160
- esPtr->msize - (size / TCL_UTF_MAX),
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) {
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 ");
181
+ expDiagLogU(".\r\n");
184
+ cc = expReadNewLine(interp,esPtr,save_flags);
191
i_read_errno = errno;
194
@@ -1674,7 +1787,7 @@
199
+ return count > 0 ? count : cc;
203
@@ -2751,8 +2864,14 @@
207
- if (Default) exp_default_match_max = size;
208
- else esPtr->umsize = size;
210
+ exp_default_match_max = size;
211
+ exp_default_match_max_changed = 1;
214
+ esPtr->umsize = size;
215
+ esPtr->umsize_changed = 1;