I'm attaching a revised patch, relative to the latest grep, to implement the idea of the Bug#18777 patch. This revision calls the new array "never_trail" instead of "always_character_boundary" to nail down the concept a bit more precisely. It also removes what appears to be an unnecessary p < mbp test, and adjusts to more-recent changes in the code. I'm not installing this into the master branch on savannah, as we'd like to release a new 'grep' soon and this patch should probably wait until after the release.