Subject: bug#16233: sh-smie-sh-forward-toke recurses forever

From: Daniel Colascione <[email-masked]>
Date: Mon, 23 Dec 2013 15:30:47 -0800

On 12/23/2013 03:07 PM, Daniel Colascione wrote:
> In latest trunk, sh-smie-sh-forward-token has started to recurse
> forever. Here's the repro:
>
> "if "
>
> Create a buffer containing these three characters, put it in
> shell-script-mode, goto-char 2, and eval (funcall show-paren-data-function)

This patch appears to be fix the problem. Okay to apply?

=== modified file 'lisp/progmodes/sh-script.el'
--- lisp/progmodes/sh-script.el	2013-12-20 21:41:57 +0000
+++ lisp/progmodes/sh-script.el	2013-12-23 23:29:31 +0000
@@ -1844,7 +1844,7 @@
              ";")
          (let ((semi (sh-smie--newline-semi-p)))
            (forward-line 1)
-          (if semi ";"
+          (if (or semi (eobp)) ";"
              (sh-smie-sh-forward-token))))
      (forward-comment (point-max))
      (cond
@@ -2070,7 +2070,7 @@
              ";")
          (let ((semi (sh-smie--rc-newline-semi-p)))
            (forward-line 1)
-          (if semi ";"
+          (if (or semi (eobp)) ";"
              (sh-smie-rc-forward-token))))
      (forward-comment (point-max))
      (cond