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

« back to all changes in this revision

Viewing changes to debian/patches/20-two-asterisks.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: Upstream (proposed by Per Cederqvist <ceder@lysator.liu.se>)
2
 
Description: The patch fixes regression with very slow regexp pattern
3
 
 processing which were converted into too complex glob patterns.
4
 
 The regression was added in version 5.44.
5
 
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=591695
6
 
Bug-Upstream: http://sourceforge.net/tracker/?func=detail&atid=113179&aid=3010684&group_id=13179
7
 
Forwarded: no
8
 
Last-updated: Sun, 05 Sep 2010 09:35:03 +0400
9
 
 
10
 
--- expect-5.44.1.15.orig/retoglob.c
11
 
+++ expect-5.44.1.15/retoglob.c
12
 
@@ -34,6 +34,10 @@
13
 
                         Tcl_UniChar* str,
14
 
                         int          strlen));
15
 
 
16
 
+static int
17
 
+ExpCountStar _ANSI_ARGS_ ((Tcl_UniChar* src, Tcl_UniChar* last));
18
 
+
19
 
+
20
 
 static char*
21
 
 xxx (Tcl_UniChar* x, int xl)
22
 
 {
23
 
@@ -465,6 +469,15 @@
24
 
   LOG (stderr,"ST '%s'\n",xxx(out,nexto-out)); FF;
25
 
 
26
 
   /*
27
 
+   * Heuristic: if there are more than two *s, the risk is far too
28
 
+   * large that the result actually is slower than the normal re
29
 
+   * matching.  So bail out.
30
 
+   */
31
 
+  if (ExpCountStar (out,nexto) > 2) {
32
 
+      goto error;
33
 
+  }
34
 
+
35
 
+  /*
36
 
    * Check if the result is actually useful.
37
 
    * Empty or just a *, or ? are not. A series
38
 
    * of ?'s is borderline, as they semi-count
39
 
@@ -717,6 +730,31 @@
40
 
   return dst;
41
 
 }
42
 
 
43
 
+static int
44
 
+ExpCountStar (src, last)
45
 
+    Tcl_UniChar* src;
46
 
+    Tcl_UniChar* last;
47
 
+{
48
 
+    int skip = 0;
49
 
+    int stars = 0;
50
 
+
51
 
+    /* Count number of *'s. State machine. The complexity is due to the
52
 
+     * need of handling escaped characters.
53
 
+     */
54
 
+
55
 
+    for (; src < last; src++) {
56
 
+       if (skip) {
57
 
+           skip = 0;
58
 
+       } else if (*src == '\\') {
59
 
+           skip = 1;
60
 
+       } else if (*src == '*') {
61
 
+           stars++;
62
 
+       }
63
 
+    }
64
 
+
65
 
+    return stars;
66
 
+}
67
 
+
68
 
 #undef CHOP
69
 
 #undef CHOPC
70
 
 #undef EMIT