[gnu.g++.bug] rindex/strrchr in cplus-lex.c

jonathan@comp.vuw.ac.nz (11/14/89)

A properly configured g++-1.36.1 fails to build cc1plus on a Pyramid 90x.
_strrchr is undefined.

cplus-lex.c from 1.36.1 assumes that all machines fall into two
classes: (i) those that have system V string/memory functions, and
        (ii) those that are sequents.  :-)

Other systems based on 4.2bsd (such as many vendor-supplied systems)
do not have the 4.3bsd compatibility routines (or ANSI C libraries),
and therefore do not have str[r]chr or memcpy.

Associated GNU software (gcc, emacs, binutils) consistently uses BSD string
functions (index, rindex), and defines them to be their SystemV
equivalents on USG machines.  The following diff makes cplus-lex.c adhere
to this convention.

*** /usr/src/gnu/g++-1.36.1/cplus-lex.c	Fri Nov  3 20:14:34 1989
--- ./cplus-lex.c	Tue Nov 14 16:16:23 1989
***************
*** 45,50 ****
--- 45,55 ----
  
  extern double atof ();
  
+ #ifdef USG
+ #define index strchr
+ #define rindex strrchr
+ #endif /* USG */
+ 
  /* This obstack is needed to hold text.  It is not safe to use
     TOKEN_BUFFER because `check_newline' calls `yylex'.  */
  static struct obstack inline_text_obstack;
***************
*** 766,776 ****
      /* Our only interest is _ref and _expr.  */
      if (tree_code_type[i][0] == 'r' || tree_code_type[i][0] == 'e')
        {
- #if defined (sequent)
  	char *end = (char *)rindex (tree_code_name[i], '_');        
- #else
- 	char *end = (char *)strrchr (tree_code_name[i], '_');
- #endif
  	if (end)
  	  opname_end[i] = end - tree_code_name[i];
        }
--- 771,777 ----
***************
*** 1481,1495 ****
    if (c == '\n')
      {
        char *tmp;
!       extern char* rindex(), *strrchr ();
        strcpy (dump_file_name, "dumped-");
- #if defined (sequent)
        if (tmp = rindex (dump_source_name, '/'))
  	dump_source_name = tmp + 1;
- #else
-       if (tmp = strrchr (dump_source_name, '/'))
- 	dump_source_name = tmp + 1;
- #endif
        strcat (dump_file_name, dump_source_name);
      }
    else
--- 1482,1491 ----
    if (c == '\n')
      {
        char *tmp;
!       extern char* rindex();
        strcpy (dump_file_name, "dumped-");
        if (tmp = rindex (dump_source_name, '/'))
  	dump_source_name = tmp + 1;
        strcat (dump_file_name, dump_source_name);
      }
    else