Properly escape filenames in line directives.

Fixes PR17018.  Only partial test coverage because I don't want
to try to write a test which generates a file whose name contains a newline.