Fujii Masao <masao(dot)fujii(at)gmail(dot)com> writes:
> OK. Attached patch fixes the problem as you suggested, i.e., it backs up
> "endword" if the second loop exits in an escape pair.
Applied with a bit of further adjustment of the comments. Thanks!
regards, tom lane