Consider the original filename of `dir??/file'. Thanks, I see now.
Now I think rms's implicit desire not to map this too strongly to C strings is a a good thing. The goal is to make it easy/unambiguous for programs like Emacs to parse the filenames out of the message. Doing full parsing of C strings is not exactly easy, as evidenced by the above. And for the present situation, the complications are unnecessary -- ? is not a problematic character for parsing the error message. So I think the ideal would be an original filename of `dir??/file' to be output as exactly that: dir??/file. I see no need even for quotes (although they could be present, then we'd have "dir??/file"). So the biggest issues are newlines and : characters, both of which you've already dealt with. For completeness, we'll handle other control characters, and we'll have to handle \ and " themselves of course. Are there any other chars that can be troublesome for next-error (or whatever tool)? I can't see any, but wdyt? As for shell special chars like space and ? and * and [], I don't see how they would interfere with next-error parsing the messages, so I'd say none of them should be considered special for this purpose. In a nutshell, if the source file name contains : or \ or " or any control character, we enclose it in quotes and escape as needed. Otherwise, no quotes needed. Wdyt? Sorry for not realizing the whole trigraph complication. Thanks, karl