From: Eric S. Raymond Date: Tue, 15 Aug 2023 10:08:35 +0000 (-0400) Subject: Fix parsing of new-style coordinates with x=10. X-Git-Tag: 2.8~41 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=9322858151c37351d9a5de99904d919691912e23;p=super-star-trek.git Fix parsing of new-style coordinates with x=10. --- diff --git a/sst b/sst index beff5c9..6bb244f 100755 --- a/sst +++ b/sst @@ -6653,14 +6653,14 @@ class sstscanner: s = Coord() self.nexttok() if (game.options & OPTION_ALPHAMERIC): - if (self.type == "IHALPHA") and (self.token[0] in "abcdefghij") and (self.token[1] in "0123456789"): - s.i = ord(self.token[0]) - ord("a") - try: - s.j = int(self.token[-1:])-1 - except TypeError: - huh() - return None - return s + try: + if (self.type == "IHALPHA") and (self.token[0] in "abcdefghij") and (self.token[1] in "0123456789"): + s.i = ord(self.token[0]) - ord("a") + s.j = int(self.token[1:])-1 + return s + except (TypeError, IndexError): + huh() + return None if self.type != "IHREAL": huh() return None diff --git a/test/test21.chk b/test/test21.chk new file mode 100644 index 0000000..592e4d1 --- /dev/null +++ b/test/test21.chk @@ -0,0 +1,58 @@ + + +-SUPER- STAR TREK + + + +It is stardate 2877. The Federation is being attacked by +a deadly Klingon invasion force. As captain of the United +Starship U.S.S. Enterprise, it is your mission to seek out +and destroy this invasion force of 9 battle cruisers. +You have an initial allotment of 14 stardates to complete +your mission. As you proceed you may be given more time. + +You will have 2 supporting starbases. +Starbase locations- b1 b5 + +The Enterprise is currently in Quadrant b6 Sector c3 + +Good Luck! +COMMAND> # SST2K version 2.7 +# Test edge and failure cases in coordinate parsing +# recorded by esr@snark.thyrsus.com on Tue Aug 15 06:05:57 2023 +sr + Short-range scan + 1 2 3 4 5 6 7 8 9 10 +a . . . . . . . . . . +b . . . * . . . . . . +c . . E . . . . . . +d . . . . . . . . . . +e . . . . . . . . . . +f . . . . . . . . . +g . . . . . . . . . . +h . . . . . . . . . . +i . @ . . . . . . . . +j . . . . . . . . * . +COMMAND> m a a 3 + +Beg your pardon, Captain? +COMMAND> m a a3 + +COMMAND> sr + Short-range scan + 1 2 3 4 5 6 7 8 9 10 +a . . E . . . . . . . +b . . . * . . . . . . +c . . . . . . . . . +d . . . . . . . . . . +e . . . . . . . . . . +f . . . . . . . . . +g . . . . . . . . . . +h . . . . . . . . . . +i . @ . . . . . . . . +j . . . . . . . . * . +COMMAND> m a a10 + +COMMAND> quit + +May the Great Bird of the Galaxy roost upon your home planet. diff --git a/test/test21.log b/test/test21.log new file mode 100644 index 0000000..cea1818 --- /dev/null +++ b/test/test21.log @@ -0,0 +1,12 @@ +# seed 1692093957 +# arguments regular medium novice fancy +# SST2K version 2.7 +# Test edge and failure cases in coordinate parsing +# recorded by esr@snark.thyrsus.com on Tue Aug 15 06:05:57 2023 +sr +m a a 3 +m a a3 +sr +m a a10 +quit +n