Re-apply r196439, with sed patterns modified to be more DOS-path friendly.