diff: fix some SICStus problems

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Mar 5 03:52:30 AEDT 1998


Fix some problems that broke the SICStus version of the Mercury compiler.

library/sicstus_builtin.nl:
library/np_builtin.nl:
	Ignore `:- impure ...' and `:- semipure ...' declarations.

library/io.nu.nl:
	Add (SICStus) Prolog implementations of
	io__rename_file_2, io__delete_file_2, io__tmpnam/5,
	and io__tmpnam_2.

cvs diff: Diffing .
Index: io.nu.nl
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.nu.nl,v
retrieving revision 1.57
diff -u -u -r1.57 io.nu.nl
--- io.nu.nl	1997/09/27 03:12:38	1.57
+++ io.nu.nl	1998/03/04 16:45:29
@@ -537,6 +537,47 @@
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
+% The following routines work only under SICStus, not under NU-Prolog.
+
+io__tmpnam_2(Name) -->
+	{ use_module(library(system)) }, % for tmpnam/1
+	{ tmpnam(Atom) },
+	{ name(Atom, Name) }.
+
+io__tmpnam(Dir, Prefix, Name) -->
+	{ use_module(library(system)) }, % for mktemp/2
+	{ dir__directory_separator(SepChar) },
+	{ string__char_to_string(SepChar, Sep) },
+	{ string__left(Prefix, 5, LeftPrefix) },
+	{ string__append_list([Dir, Sep, LeftPrefix, "XXXXXX"], TemplateName) },
+	{ name(TemplateAtom, TemplateName) },
+	{ mktemp(TemplateAtom, TmpAtom) },
+	{ name(TmpAtom, Name) }.
+
+io__rename_file_2(OldName, NewName, Result, ResultStr) -->
+	{ use_module(library(system)) }, % for rename_file/2
+	{ name(OldAtom, OldName) },
+	{ name(NewAtom, NewName) },
+	{ rename_file(OldAtom, NewAtom) ->
+		Result = 0
+	;
+		Result = -1,
+		Resultstr = "rename_file/2 failed"
+	}.
+
+io__remove_file_2(FileName, Result) -->
+	{ use_module(library(system)) }, % for delete_file/2
+	{ name(FileAtom, OldName) },
+	{ delete_file(FileAtom, []) ->
+		Result = 0
+	;
+		Result = -1,
+		Resultstr = "delete_file/2 failed"
+	}.
+
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
 % global state predicates
 
 io__progname(DefaultName, Name) --> 
Index: nc_builtin.nl
===================================================================
RCS file: /home/mercury1/repository/mercury/library/nc_builtin.nl,v
retrieving revision 1.19
diff -u -u -r1.19 nc_builtin.nl
--- nc_builtin.nl	1998/03/03 17:26:01	1.19
+++ nc_builtin.nl	1998/03/04 16:17:23
@@ -102,6 +102,9 @@
 termExpansion((:- mode(_)), (:- fail)).
 termExpansion((:- inst(_)), (:- fail)).
 
+termExpansion((:- impure(_)), (:- fail)).
+termExpansion((:- semipure(_)), (:- fail)).
+
 termExpansion((:- module(_)), (:- fail)).
 termExpansion((:- end_module(_)), (:- fail)).
 termExpansion((:- interface), (:- fail)).
Index: sp_builtin.nl
===================================================================
RCS file: /home/mercury1/repository/mercury/library/sp_builtin.nl,v
retrieving revision 1.15
diff -u -u -r1.15 sp_builtin.nl
--- sp_builtin.nl	1998/03/03 17:26:05	1.15
+++ sp_builtin.nl	1998/03/04 16:17:01
@@ -95,6 +95,9 @@
 mercury_declaration(mode(_)).
 mercury_declaration(inst(_)).
 
+mercury_declaration(impure(_)).
+mercury_declaration(semipure(_)).
+
 mercury_declaration(module(_)).
 mercury_declaration(end_module(_)).
 mercury_declaration(interface).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list