For review: warn rather than abort for MERCURY_OPTIONS not applicable to current grade

Warwick Harvey wharvey at cs.monash.edu.au
Wed Aug 5 13:06:23 AEST 1998


Can somebody review this?  In particular, I'd like to know whether I'm using 
an appropriate method for printing warning messages, whether they are of an 
appropriate format, and whether printing anything at all is appropriate (as 
opposed to just remaining silent).


Estimated hours taken: 0.5 (but testing not done yet)

Currently, if an option specified via the MERCURY_OPTIONS environment 
variable is not applicable to the grade that the program being run was 
compiled with, the usual response is to abort with a usage message.  There 
are two problems with this.  First, there is no indication that the option 
was just inapplicable to the compiled grade, making it difficult to see the 
cause of the problem when every option you use is listed in the (scant :-) 
documentation.  Second, if you are using more than one program compiled with 
different grades (e.g. the compiler and the program you're developing :-), 
you may have to change the environment variable each time you swap between 
them.

This change fixes the above problems by printing a warning listing the 
option and the reason it's not applicable, rather than aborting.

runtime/mercury_wrapper.c:
	Print warnings for MERCURY_OPTIONS options that are not applicable
	for the current grade, rather than aborting (or in one case,
	silently ignoring).

Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.20
diff -u -r1.20 mercury_wrapper.c
--- mercury_wrapper.c	1998/07/27 18:04:32	1.20
+++ mercury_wrapper.c	1998/08/05 02:39:23
@@ -521,9 +521,10 @@
 				gotodebug    = TRUE;
 			else if (streq(optarg, "G"))
 #ifdef CONSERVATIVE_GC
-			GC_quiet = FALSE;
+				GC_quiet = FALSE;
 #else
-			fatal_error("-dG: GC not enabled");
+				fprintf(stderr, "Mercury runtime: warning: "
+						"-dG: GC not enabled");
 #endif
 			else if (streq(optarg, "s"))
 				detstackdebug   = TRUE;
@@ -563,9 +564,12 @@
 
 			if (streq(optarg, "i"))
 				MR_trace_handler = MR_TRACE_INTERNAL;
-#ifdef	MR_USE_EXTERNAL_DEBUGGER
 			else if (streq(optarg, "e"))
+#ifdef	MR_USE_EXTERNAL_DEBUGGER
 				MR_trace_handler = MR_TRACE_EXTERNAL;
+#else
+				fprintf(stderr, "Mercury runtime: warning: "
+					"-De: external debugger not enabled");
 #endif
 
 			else
@@ -604,9 +608,12 @@
 				detstack_size = size;
 			else if (optarg[0] == 'n')
 				nondstack_size = size;
-#ifdef MR_USE_TRAIL
 			else if (optarg[0] == 't')
+#ifdef MR_USE_TRAIL
 				trail_size = size;
+#else
+				fprintf(stderr, "Mercury runtime: warning: "
+						"-st: trail not enabled");
 #endif
 			else
 				usage();
@@ -641,6 +648,9 @@
 		case 'x':
 #ifdef CONSERVATIVE_GC
 			GC_dont_gc = TRUE;
+#else
+			fprintf(stderr, "Mercury runtime: warning: "
+					"-x: GC not enabled");
 #endif
 
 			break;
@@ -655,9 +665,12 @@
 				detstack_zone_size = size;
 			else if (optarg[0] == 'n')
 				nondstack_zone_size = size;
-#ifdef MR_USE_TRAIL
 			else if (optarg[0] == 't')
+#ifdef MR_USE_TRAIL
 				trail_zone_size = size;
+#else
+				fprintf(stderr, "Mercury runtime: warning: "
+						"-zt: trail not enabled");
 #endif
 			else
 				usage();





More information about the developers mailing list