From e3d6e5a39b7da5e79bb3c21571dcf3cca6c4bb93 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 8 Oct 2006 06:35:38 +0000 Subject: [PATCH] Simplify some corner cases in the scanner code. --- src/sst.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/sst.py b/src/sst.py index a1c08bb..e4681e2 100644 --- a/src/sst.py +++ b/src/sst.py @@ -6365,6 +6365,8 @@ def makemoves(): if game.options & OPTION_CURSES: makechart() continue + elif scanner.token == "": + continue game.ididit = False clrscr() setwnd(message_window) @@ -6375,7 +6377,7 @@ def makemoves(): cmd = candidates[0] break elif candidates and not (game.options & OPTION_PLAIN): - prout("Commands with that prefix: " + " ".join(candidates)) + prout("Commands with prefix '%s': %s" % (scanner.token, " ".join(candidates))) else: listCommands() continue @@ -6568,24 +6570,21 @@ class sstscanner: # Get a token from the user self.real = 0.0 self.token = '' - # Read a line if nothing here - if self.inqueue == None: + # Fill the token quue if nothing here + while self.inqueue == None: line = cgetline() if curwnd==prompt_window: clrscr() setwnd(message_window) clrscr() + if line == '': + return None # Skip leading white space line = line.lstrip() - if line: - self.inqueue = line.split() + if not line: + continue else: - self.inqueue = [] - self.type = IHEOL - return IHEOL - elif not self.inqueue: - self.type = IHEOL - return IHEOL + self.inqueue = line.lstrip().split() + [IHEOL] # From here on in it's all looking at the queue self.token = self.inqueue.pop(0) if self.token == IHEOL: -- 2.31.1