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]

Re: patch for c++filt


How about this ?
I'll admit to liking this better, as it is a bit smaller and easier to 
read, but this is not critical... 


Wed May 12 19:08:48 CEST 1999		Marc Espie <espie@cvs.openbsd.org>
	* cplus-dem.c:  Replace the _symbol_alphabet tables with a
	_symbol_characters string, and use strchr.


Index: cplus-dem.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/libiberty/cplus-dem.c,v
retrieving revision 1.45
diff -u -p -r1.45 cplus-dem.c
--- cplus-dem.c	1999/05/11 12:39:46	1.45
+++ cplus-dem.c	1999/05/12 17:06:20
@@ -4394,25 +4394,19 @@ fancy_abort ()
 }
 
 
-/* Fill in TABLE so that TABLE[C] is true iff C (as an unsigned char)
-   is a valid symbol component, in the standard assembler symbol
+/* Return the string of non-alnum characters that may occur 
+   as a valid symbol component, in the standard assembler symbol
    syntax.  */
-void
-standard_symbol_alphabet (char *table)
-{
-  int c;
-
-  for (c = 0; c < 256; c++)
-    table[c] = isalnum(c);
 
-  table['_'] = 1;
-  table['$'] = 1;
-  table['.'] = 1;
+static const char *
+standard_symbol_characters ()
+{
+  return "_$.";
 }
 
 
-/* Fill in TABLE so that TABLE[C] is true iff C (as an unsigned char)
-   is a valid symbol name component in an HP object file.
+/* Return the string of non-alnum characters that may occur
+   as a valid symbol name component in an HP object file.
 
    Note that, since HP's compiler generates object code straight from
    C++ source, without going through an assembler, its mangled
@@ -4441,15 +4435,10 @@ standard_symbol_alphabet (char *table)
        non-digit character.
 
    So have fun.  */
-void
-hp_symbol_alphabet (char *table)
+static const char *
+hp_symbol_characters ()
 {
-  char *c;
-
-  standard_symbol_alphabet (table);
-
-  for (c = "<>#,*&[]:(){}"; *c; c++)
-    table[(unsigned char) *c] = 1;
+  return "_$.<>#,*&[]:(){}";
 }
 
 
@@ -4460,7 +4449,7 @@ main (argc, argv)
 {
   char *result;
   int c;
-  char symbol_alphabet[256];
+  char *valid_symbols;
 
   program_name = argv[0];
 
@@ -4533,10 +4522,10 @@ main (argc, argv)
 	case lucid_demangling:
 	case arm_demangling:
 	case edg_demangling:
-	  standard_symbol_alphabet (symbol_alphabet);
+	  valid_symbols = standard_symbol_characters ();
 	  break;
 	case hp_demangling:
-	  hp_symbol_alphabet (symbol_alphabet);
+	  valid_symbols = hp_symbol_characters ();
 	  break;
 	default:
 	  /* Folks should explicitly indicate the appropriate alphabet for
@@ -4550,7 +4539,7 @@ main (argc, argv)
 	  int i = 0;
 	  c = getchar ();
 	  /* Try to read a label.  */
-	  while (c != EOF && symbol_alphabet[c])
+	  while (c != EOF && (isalnum (c) || strchr (valid_symbols, c)))
 	    {
 	      if (i >= MBUF_SIZE-1)
 		break;


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