[m-rev.] diff: fix .mh rebuild problem

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Feb 7 23:44:08 AEDT 2004


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.

Workspace: /home/jupiter/fjh/ws-jupiter/mercury
Index: compiler/export.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.72
diff -u -d -r1.72 export.m
--- compiler/export.m	5 Jan 2004 14:31:54 -0000	1.72
+++ compiler/export.m	7 Feb 2004 12:22:02 -0000
@@ -622,7 +622,7 @@
 			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 @@
 			"\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)
 	).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list