[m-rev.] for review: disallow absolute-pathname targets
Ondrej Bojar
bojar at csse.unimelb.edu.au
Fri Feb 23 10:16:58 AEDT 2007
For review by anyone (Julien?)
Estimated hours taken: 0.5
Emit an error message is 'mmc --make' get a target specified using an absolute
pathname. Proceeding further led to the following uncaught exception:
Software Error: dir./: second argument is absolute
compiler/make.m:
Check for absolute pathnames.
Index: compiler/make.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.m,v
retrieving revision 1.43
diff -u -r1.43 make.m
--- compiler/make.m 1 Dec 2006 15:04:04 -0000 1.43
+++ compiler/make.m 22 Feb 2007 23:08:54 -0000
@@ -73,6 +73,7 @@
:- import_module top_level.mercury_compile. % XXX unwanted dependency
:- import_module bool.
+:- import_module dir.
:- import_module int.
:- import_module map.
:- import_module maybe.
@@ -234,23 +235,49 @@
MaybeMAIN_TARGET = yes(Targets),
(
Targets = [_ | _],
- Continue = yes
+ Continue0 = yes
;
Targets = [],
- Continue = no,
+ Continue0 = no,
io.write_string("** Error: no targets specified " ++
"and `MAIN_TARGET' not defined.\n", !IO)
)
;
MaybeMAIN_TARGET = no,
Targets = [],
- Continue = no
+ Continue0 = no
)
;
Targets0 = [_ | _],
- Continue = yes,
+ Continue0 = yes,
Targets = Targets0
),
+ %
+ % Ensure none of the targets is an absolute pathname. This is not
+ % supported by the rest of the code.
+ %
+ list.filter(dir.path_name_is_absolute, Targets, AbsTargets),
+ (
+ AbsTargets = [],
+ Continue = Continue0
+ ;
+ AbsTargets = [_ | AbsTargetsTail],
+ Continue = no,
+ (
+ AbsTargetsTail = [],
+ Plural = "target is an absolute pathname"
+ ;
+ AbsTargetsTail = [_ | _],
+ Plural = "targets are absolute pathnames"
+ ),
+ io.write_string("** Error: The following " ++ Plural ++ "\n", !IO),
+ list.foldl(
+ (pred(Target::in, !.I::di, !:I::uo) is det :-
+ io.write_string(" ", !I),
+ io.write_string(Target, !I),
+ io.nl(!I)
+ ), AbsTargets, !IO)
+ ),
(
Continue = no,
io.set_exit_status(1, !IO)
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list