This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: Fix tree dump switch option handling


Already installed on tree-ssa-branch.
Without this patch, if you had two options, -fdump-tree-ssa and 
-fdump-tree-ssapre, you could never activate the dump for 
-fdump-tree-ssapre (unless it came first in the option array), because 
it would stop when it matched against -fdump-tree-ssa.

With this patch, it looks for the longest match, not the first one.

2002-09-14  Daniel Berlin  <dberlin@dberlin.org>

       * tree-dump.c (dump_switch_p): Search for longest match, not first
       match.


Index: tree-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-dump.c,v
retrieving revision 1.7
diff -c -3 -p -w -B -b -r1.7 tree-dump.c
*** tree-dump.c	26 Jul 2002 13:45:34 -0000	1.7
--- tree-dump.c	14 Sep 2002 22:22:10 -0000
*************** dump_switch_p (arg)
*** 747,755 ****
--- 747,766 ----
  {
    unsigned ix;
    const char *option_value;
+   signed best=-1;
+   unsigned bestlen=-1;
    
    for (ix = 0; ix != TDI_end; ix++)
      if ((option_value = skip_leading_substring (arg, dump_files[ix].swtch)))
+       if (strlen (option_value) < bestlen)
+ 	{
+ 	  best = ix;
+ 	  bestlen = strlen (option_value);
+ 	}
+   
+   if (best >= 0)
+     {
+       if ((option_value = skip_leading_substring (arg, dump_files[ix].swtch)))
  	{
  	  const char *ptr = option_value;
  	  int flags = 0;
*************** dump_switch_p (arg)
*** 776,790 ****
  		  goto found;
  		}
  	    warning ("ignoring unknown option `%.*s' in `-f%s'",
! 		     length, ptr, dump_files[ix].swtch);
  	  found:;
  	    ptr = end_ptr;
  	  }
  
! 	dump_files[ix].state = -1;
! 	dump_files[ix].flags = flags;
  
  	return 1;
        }
    return 0;
  }
--- 787,802 ----
  		    goto found;
  		  }
  	      warning ("ignoring unknown option `%.*s' in `-f%s'",
! 		       length, ptr, dump_files[best].swtch);
  	    found:;
  	      ptr = end_ptr;
  	    }
  	  
! 	  dump_files[best].state = -1;
! 	  dump_files[best].flags = flags;
  	  
  	  return 1;
  	}
+     }
    return 0;
  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]