Changeset 11599 for trunk/libtransmission/wildmat.c
- Timestamp:
- Dec 27, 2010, 7:18:17 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/wildmat.c
r10521 r11599 4 4 ** Do shell-style pattern matching for ?, \, [], and * characters. 5 5 ** Might not be robust in face of malformed patterns; e.g., "foo[a-" 6 ** could cause a segmentation violation. 6 ** could cause a segmentation violation. It is 8bit clean. 7 7 ** 8 8 ** Written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986. … … 12 12 ** 13 13 ** Special thanks to Lars Mathiesen <thorinn@diku.dk> for the ABORT code. 14 ** This can greatly speed up failing wildcard patterns. 14 ** This can greatly speed up failing wildcard patterns. For example: 15 15 ** pattern: -*-*-*-*-*-*-12-*-*-*-m-*-*-* 16 16 ** text 1: -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1 17 17 ** text 2: -adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1 18 ** Text 1 matches with 51 calls, while text 2 fails with 54 calls. 19 ** the ABORT, then it takes 22310 calls to fail. Ugh.The following18 ** Text 1 matches with 51 calls, while text 2 fails with 54 calls. Without 19 ** the ABORT, then it takes 22310 calls to fail. Ugh. The following 20 20 ** explanation is from Lars: 21 21 ** The precondition that must be fulfilled is that DoMatch will consume 22 ** at least one character in text. 22 ** at least one character in text. This is true if *p is neither '*' nor 23 23 ** '\0'.) The last return has ABORT instead of FALSE to avoid quadratic 24 ** behaviour in cases like pattern "*a*b*c*d" with text "abcxxxxx". 24 ** behaviour in cases like pattern "*a*b*c*d" with text "abcxxxxx". With 25 25 ** FALSE, each star-loop has to run to the end of the text; with ABORT 26 26 ** only the last one does. … … 29 29 ** instance will return either TRUE or ABORT, and any calling instance 30 30 ** will therefore return immediately after (without calling recursively 31 ** again). In effect, only one star-loop is ever active.It would be31 ** again). In effect, only one star-loop is ever active. It would be 32 32 ** possible to modify the code to maintain this context explicitly, 33 33 ** eliminating all recursive calls at the cost of some complication and 34 34 ** loss of clarity (and the ABORT stuff seems to be unclear enough by 35 ** itself). 35 ** itself). I think it would be unwise to try to get this into a 36 36 ** released version unless you have a good test data base to try it out 37 37 ** on. … … 111 111 112 112 /* 113 ** User-level routine. 113 ** User-level routine. Returns TRUE or FALSE. 114 114 */ 115 115 int
Note: See TracChangeset
for help on using the changeset viewer.