Author: minz
Date: 2011-01-07 13:14:58 -0500 (Fri, 07 Jan 2011)
New Revision: 3449

Modified:
   trunk/osprey/be/be/driver.cxx
   trunk/osprey/be/be/driver_util.cxx
   trunk/osprey/be/com/comp_driver.cxx
   trunk/osprey/be/com/comp_driver.h
Log:
Fix for bug700.

The problem is in newly checked-in componentization code for processing the 
option (rev3390).

The logic to process the option ("-componentname:optionlist") was not exact. 
The change is made to check the first char to be "-" and then check the 
componentname by parsing ':' .

Another change is the place of processing options for the new 
componentization-based approach. Now it is inside Process_Command_Line().

Code Review: Sun Chan




Modified: trunk/osprey/be/be/driver.cxx
===================================================================
--- trunk/osprey/be/be/driver.cxx       2010-12-27 06:24:31 UTC (rev 3448)
+++ trunk/osprey/be/be/driver.cxx       2011-01-07 18:14:58 UTC (rev 3449)
@@ -2256,8 +2256,6 @@
   Set_Error_Phase ( "Back End Driver" );
 
   Preconfigure ();
-  // setup options from the command line to O64_Driver
-  O64_Driver::GetInstance()->SetupOptions(argc, argv);
   Process_Command_Line (argc, argv);
 
   if (Inhibit_EH_opt && Opt_Level > 1) Opt_Level = 1;

Modified: trunk/osprey/be/be/driver_util.cxx
===================================================================
--- trunk/osprey/be/be/driver_util.cxx  2010-12-27 06:24:31 UTC (rev 3448)
+++ trunk/osprey/be/be/driver_util.cxx  2011-01-07 18:14:58 UTC (rev 3449)
@@ -79,6 +79,7 @@
 #include "wn_fio.h"
 #include "wn_instrument.h"
 #include "driver_util.h"
+#include "comp_decl.h"
 
 BOOL warnings_are_errors = FALSE;
 
@@ -205,6 +206,11 @@
            if (Process_Command_Line_Group (cp, Common_Option_Groups))
                continue;
 
+        /* process a command-line option group using componentization-based
+        new approach */
+        if (O64_Driver::GetInstance()->ProcessComponentOption(argv[i]))
+        continue;
+
            switch ( *cp++ ) {
               
 #ifdef TARG_IA64         

Modified: trunk/osprey/be/com/comp_driver.cxx
===================================================================
--- trunk/osprey/be/com/comp_driver.cxx 2010-12-27 06:24:31 UTC (rev 3448)
+++ trunk/osprey/be/com/comp_driver.cxx 2011-01-07 18:14:58 UTC (rev 3449)
@@ -124,28 +124,23 @@
     _NumRegisteredComponents++;
 }
 
-// Setup O64_Option class to store option values from the command line.
+// Process O64_Option class to store option values from the command line.
 // The new option handling mechnisam co-exists with the old option handling
-// mechnisam. The option is changed to " ", if it is handled by new mechnisam. 
-void
-O64_Driver::SetupOptions(INT32 argc, char ** argv)
+// mechnisam.
+bool
+O64_Driver::ProcessComponentOption(char * argv)
 {
-    FmtAssert(_NumRegisteredComponents == COMPONENT_last, 
+    FmtAssert(_NumRegisteredComponents == COMPONENT_last,
         ("[O64_Driver] Component Registration Error"));
 
-    _CurrentOption = CXX_NEW(O64_Option, &_DriverPool);
+    if (_CurrentOption == NULL) {
+        _CurrentOption = CXX_NEW(O64_Option, &_DriverPool);
+        Is_True(_CurrentOption, ("[O64_Driver] Null CurrentOption"));
+    }
 
-    Is_True(_CurrentOption, ("[O64_Driver] Null CurrentOption"));
-
-    for (INT32 i = 1; i < argc; i++) {
-        if (argv[i] != NULL) {
-            if (_CurrentOption->ProcessComponentOption_(argv[i]))
-                argv[i] = " ";
-        }    
-    }        
+    return (_CurrentOption->ProcessComponentOption_(argv));
 }
 
-
 TRACE_OPTION_KIND
 O64_Driver::GetTraceKind()
 {
@@ -280,24 +275,30 @@
     if (!component_options) return true;
 
     char * option_dup, * option_start;
-    option_dup = STRDUP(component_options);
-    option_start = STRTOK(option_dup, "-:");
-    if (!STRCMP("OPTIONS", option_start)) {
+
+    // the first char should be '-'
+    option_start = component_options;
+    if (*option_start != '-') return false;
+
+    option_start++;
+    if (*option_start == '\0') return false;
+
+    option_dup = STRDUP(option_start);
+
+    if (!STRCMP("OPTIONS", option_dup)) {
         PrintOptionsUsage_();
         return true;
     }
-    
-    while (option_start != NULL) {
-        bool component_found = false;
-        for (INT32 component = 0; component <= GetNumOfComponents_(); 
++component)
-            if (!STRCASECMP(GetComponentName_(component), option_start)) {
-                option_start = STRTOK(NULL, "-:");
-                if (ProcessOptionList_(component, option_start))
-                    component_found = true;
-            }
 
-        if (component_found) return true;    
-        option_start = STRTOK(NULL, "-:");
+    option_start = STRTOK(option_dup, ":");
+    if (option_start == NULL) return false;
+
+    for (INT32 component = 0; component <= GetNumOfComponents_(); ++component) 
{
+        if (!STRCASECMP(GetComponentName_(component), option_start)) {
+            option_start = STRTOK(NULL, ":");
+            if (ProcessOptionList_(component, option_start))
+                return true;
+        }
     }
 
     return false;

Modified: trunk/osprey/be/com/comp_driver.h
===================================================================
--- trunk/osprey/be/com/comp_driver.h   2010-12-27 06:24:31 UTC (rev 3448)
+++ trunk/osprey/be/com/comp_driver.h   2011-01-07 18:14:58 UTC (rev 3449)
@@ -151,7 +151,7 @@
     MEM_POOL *          GetLocalMemPool()   { return &_LocalPool; };
     WN*                 GetCurrentWN()      { return _CurrentWN; };
     void                SetCurrentWN(WN* wn){ _CurrentWN = wn; };
-    void                SetupOptions(INT32 argc, char ** argv);
+    bool                ProcessComponentOption(char *argv);
     TRACE_OPTION_KIND   GetTraceKind();
     BOOL                TimeStats();
     BOOL                MemStats();


------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
Open64-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to