# Static helper functions
############################################################################
-# Protect leading quotes and periods against interpretation as commands. A
-# leading *roff font escape apparently still leaves a period interpretable
-# as a command by some *roff implementations, so look for a period even
-# after one of those.
+# Protect leading quotes and periods against interpretation as commands.
+# Also protect anything starting with a backslash, since it could expand
+# or hide something that *roff would interpret as a command. This is
+# overkill, but it's much simpler than trying to parse *roff here.
sub protect {
local $_ = shift;
- s{ ^ ( (?: \\f(?:.|\(..) )* [.\'] ) } {\\&$1}xmg;
+ s/^([.\'\\])/\\&$1/mg;
$_;
}