diff options
author | actsofcreation <actsofcreation@656d521f-e311-0410-88e0-e7920216d269> | 2004-04-24 20:44:03 +0000 |
---|---|---|
committer | actsofcreation <actsofcreation@656d521f-e311-0410-88e0-e7920216d269> | 2004-04-24 20:44:03 +0000 |
commit | f0a73c9f1a172de5de0e209d4863c297e4030451 (patch) | |
tree | 010d0145060715b2be8d2e725fdf4acdbd58c372 | |
parent | 831a8cb03d243098abce75b99b8f268a374b9aa1 (diff) | |
download | pexpect-patch_876859.tar.gz |
Turned off maxsearchsize by default and put in some optimizations to avoid slicingpatch_876859
git-svn-id: http://pexpect.svn.sourceforge.net/svnroot/pexpect/branches/patch_876859@229 656d521f-e311-0410-88e0-e7920216d269
-rw-r--r-- | pexpect/pexpect.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/pexpect/pexpect.py b/pexpect/pexpect.py index c83df56..0dda93d 100644 --- a/pexpect/pexpect.py +++ b/pexpect/pexpect.py @@ -130,7 +130,7 @@ class spawn: self.maxread = 1 # Maximum to read at a time ### IMPLEMENT THIS FEATURE!!! # anything before maxsearchsize point is preserved, but not searched. - self.maxsearchsize = 1000 + self.maxsearchsize = None # If command is an int type then it must represent an open file descriptor. if type (command) == type(0): @@ -671,11 +671,12 @@ class spawn: index = index + 1 if str_target is EOF or str_target is TIMEOUT: continue # The Exception patterns are handled differently. - if(self.maxsearchsize != None): - searchbuffer = incoming[-self.maxsearchsize:] + if(self.maxsearchsize != None and + self.maxsearchsize < len(incoming)): + pos = len(incoming) - self.maxsearchsize + match_index = incoming.find(str_target,pos) else: - searchbuffer = incoming - match_index = searchbuffer.find (str_target) + match_index = searchbuffer.find (str_target) if match_index >= 0: self.before = incoming [ : match_index] self.after = incoming [match_index : ] @@ -737,11 +738,12 @@ class spawn: index = index + 1 if cre is EOF or cre is TIMEOUT: continue # The patterns for PexpectExceptions are handled differently. - if(self.maxsearchsize != None): - searchbuffer = incoming[-self.maxsearchsize:] + if(self.maxsearchsize != None and + self.maxsearchsize < len(incoming)): + pos = len(incoming) - self.maxsearchsize + match = cre.search(incoming,pos) else: - searchbuffer = incoming - match = cre.search(searchbuffer) + match = cre.search(incoming) if match is not None: self.before = incoming[ : match.start()] self.after = incoming[match.start() : ] |