[M3commit] CVS Update: cm3

Jay K jay.krell at cornell.edu
Sat Jun 23 10:53:14 CEST 2012


Index: src/Main.m3
===================================================================
RCS file: /usr/cvs/cm3/m3-sys/cm3/src/Main.m3,v
retrieving revision 1.21
diff -u -r1.21 Main.m3
--- src/Main.m3    26 Oct 2009 14:54:52 -0000    1.21
+++ src/Main.m3    23 Jun 2012 08:50:15 -0000
@@ -29,6 +29,8 @@
     END;
     Process.RegisterExitor (CleanUp);
 
+    Makefile.ScanCommandLine1 ();
+
     config := MxConfig.FindFile ();
     IF (config = NIL) THEN
       Msg.FatalError (NIL, "unable to locate configuration file, \"",
@@ -40,7 +42,7 @@
       TRY
         (* figure out what we're trying to do *)
         VAR
-          defs := Makefile.ScanCommandLine ();
+          defs := Makefile.ScanCommandLine2 ();
           name, val: TEXT;
           iter := defs.iterate();
         BEGIN
Index: src/Makefile.i3
===================================================================
RCS file: /usr/cvs/cm3/m3-sys/cm3/src/Makefile.i3,v
retrieving revision 1.3
diff -u -r1.3 Makefile.i3
--- src/Makefile.i3    7 Mar 2001 21:52:26 -0000    1.3
+++ src/Makefile.i3    23 Jun 2012 08:50:15 -0000
@@ -5,7 +5,11 @@
 
 IMPORT TextTextTbl;
 
-PROCEDURE ScanCommandLine () : TextTextTbl.T;
+PROCEDURE ScanCommandLine1 ();
+(* Pre-scan the command line arguments for -help/-version.
+*)
+
+PROCEDURE ScanCommandLine2 () : TextTextTbl.T;
 (* Pre-scan the command line arguments to determine the major mode
    we're operating in, and print any requested help or version information.
    Return a set of pre-defined values for the quake evaluation.
Index: src/Makefile.m3
===================================================================
RCS file: /usr/cvs/cm3/m3-sys/cm3/src/Makefile.m3,v
retrieving revision 1.49
diff -u -r1.49 Makefile.m3
--- src/Makefile.m3    15 Feb 2011 03:02:59 -0000    1.49
+++ src/Makefile.m3    23 Jun 2012 08:50:15 -0000
@@ -514,7 +514,23 @@
 
 (*----------------------------------------- pre-scan command line ---*)
 
-PROCEDURE ScanCommandLine () : TextTextTbl.T =
+PROCEDURE ScanCommandLine1 () =
+  VAR arg: TEXT;
+  BEGIN
+    FOR i := 1 TO Params.Count-1 DO
+      arg := Params.Get (i);
+      IF Text.Length(arg) > 1 AND Text.GetChar (arg, 1) = '-' THEN
+        arg := Text.Sub (arg, 1);
+      END;
+      IF    Text.Equal (arg, "-?")         THEN  PrintHelp ();
+      ELSIF Text.Equal (arg, "-help")      THEN  PrintHelp ();
+      ELSIF Text.Equal (arg, "-config")    THEN  PrintVersion (TRUE);
+      ELSIF Text.Equal (arg, "-version")   THEN  PrintVersion (TRUE);
+      END;
+    END;
+  END ScanCommandLine1;
+
+PROCEDURE ScanCommandLine2 () : TextTextTbl.T =
   VAR 
     use_overrides := FALSE;
     cnt := 0;  arg: TEXT;
@@ -530,10 +546,6 @@
       ELSIF Text.Equal (arg, "-find")      THEN  SetMode (cnt, MM.Find);
       ELSIF Text.Equal (arg, "-ship")      THEN  SetMode (cnt, MM.Ship);
       ELSIF Text.Equal (arg, "-depend")    THEN  SetMode (cnt, MM.Depend);
-      ELSIF Text.Equal (arg, "-?")         THEN  PrintHelp ();
-      ELSIF Text.Equal (arg, "-help")      THEN  PrintHelp ();
-      ELSIF Text.Equal (arg, "-config")    THEN  PrintVersion (TRUE);
-      ELSIF Text.Equal (arg, "-version")   THEN  PrintVersion (TRUE);
       ELSIF Text.Equal (arg, "-silent") THEN  
         Msg.SetLevel (Msg.Level.Silent);
       ELSIF Text.Equal (arg, "-why") THEN  
@@ -562,7 +574,7 @@
     IF (cnt <= 0) THEN SetMode (cnt, MM.Build); END;
     EVAL defs.put("M3_USE_OVERRIDES", ARRAY BOOLEAN OF TEXT {"", "TRUE"}[use_overrides]);
     RETURN defs;
-  END ScanCommandLine;
+  END ScanCommandLine2;
 
 PROCEDURE SetMode (VAR cnt: INTEGER;  mode: MM) =
   BEGIN







----------------------------------------
> Date: Sat, 23 Jun 2012 10:52:03 +0000
> To: m3commit at elegosoft.com
> From: jkrell at elego.de
> Subject: [M3commit] CVS Update: cm3
>
> CVSROOT: /usr/cvs
> Changes by: jkrell at birch. 12/06/23 10:52:03
>
> Modified files:
> cm3/m3-sys/cm3/src/: Main.m3 Makefile.i3 Makefile.m3
>
> Log message:
> split ScanCommandLine into ScanCommandLine1 and ScanCommandLine2
> ScanCommandLine2 is most of the previous ScanCommandLine
> ScanCommandLine1 handles just -version and -help
>
> Maybe call them ScanCommandLineForHelpAndUsage
> and ScanCommadLine? or add a boolean parameter?
> Or just call it earlier? This is a smaller/safer change.
>
> The point is so that cm3 -version can be used to sniff
> for -host, even when there is no (not yet) a cm3.cfg file.
> This is useful e.g. in scripts/python/{pylib.py,boot2.sh}
>
 		 	   		  


More information about the M3commit mailing list