Ensure that we don't update the timestamp on the ".mh" file if

Estimated hours taken: 0.5
Branches: main

compiler/export.m:
	Ensure that we don't update the timestamp on the ".mh" file if
	it hasn't changed, by writing it out to <modulename>.mh.tmp and
	then using "update_interface" to rename it to <modulename>.mh.
This commit is contained in:
Fergus Henderson
2004-02-07 12:44:18 +00:00
parent da2fd6c8d5
commit 86cc65a170

View File

@@ -622,7 +622,7 @@ export__produce_header_file(ForeignExportDecls, ModuleName) -->
C_ExportDecls) },
{ HeaderExt = ".mh" },
module_name_to_file_name(ModuleName, HeaderExt, yes, FileName),
io__open_output(FileName, Result),
io__open_output(FileName ++ ".tmp", Result),
(
{ Result = ok(FileStream) }
->
@@ -670,13 +670,15 @@ export__produce_header_file(ForeignExportDecls, ModuleName) -->
"\n",
"#endif /* ", GuardMacroName, " */\n"]),
io__set_output_stream(OutputStream, _),
io__close_output(FileStream)
io__close_output(FileStream),
% rename "<ModuleName>.mh.tmp" to "<ModuleName>.mh".
update_interface(FileName)
;
io__progname_base("export.m", ProgName),
io__write_string("\n"),
io__write_string(ProgName),
io__write_string(": can't open `"),
io__write_string(FileName),
io__write_string(FileName ++ ".tmp"),
io__write_string("' for output\n"),
io__set_exit_status(1)
).