Commit f55b1ca8 by Michael Meissner Committed by Michael Meissner

Switch to strrchr if available instead of rindex

From-SVN: r19341
parent 0cd355fe
Mon Apr 20 14:48:29 1998 Michael Meissner <meissner@cygnus.com> Mon Apr 20 14:48:29 1998 Michael Meissner <meissner@cygnus.com>
* configure.in (AC_CHECK_FUNCS): Check for strchr and strrchr.
* configure: Regenerate.
* config.in: Add #undef's for strchr and strrchr.
* protoize.c (toplevel): If we have rindex, but not strrchr, map
rindex to strrchr.
(file_could_be_converted): Use strrchr, not rindex since rindex is
not defined on Linux systems when _POSIX_SOURCE is defined.
(file_normally_convertible): Ditto.
(process_aux_info_file): Ditto.
(main): Ditto.
* rs6000.md (mov{sf,df} define_splits): When splitting a move of * rs6000.md (mov{sf,df} define_splits): When splitting a move of
a constant to an integer register, don't split the insns that do a constant to an integer register, don't split the insns that do
the simple AND and OR operations, rather just split each word, and the simple AND and OR operations, rather just split each word, and
......
...@@ -92,12 +92,18 @@ ...@@ -92,12 +92,18 @@
/* Define if you have the rindex function. */ /* Define if you have the rindex function. */
#undef HAVE_RINDEX #undef HAVE_RINDEX
/* Define if you have the strchr function. */
#undef HAVE_STRCHR
/* Define if you have the setrlimit function. */ /* Define if you have the setrlimit function. */
#undef HAVE_SETRLIMIT #undef HAVE_SETRLIMIT
/* Define if you have the strerror function. */ /* Define if you have the strerror function. */
#undef HAVE_STRERROR #undef HAVE_STRERROR
/* Define if you have the strrchr function. */
#undef HAVE_STRRCHR
/* Define if you have the strtoul function. */ /* Define if you have the strtoul function. */
#undef HAVE_STRTOUL #undef HAVE_STRTOUL
......
...@@ -1676,7 +1676,7 @@ fi ...@@ -1676,7 +1676,7 @@ fi
echo "$ac_t""$gcc_cv_header_inttypes_h" 1>&6 echo "$ac_t""$gcc_cv_header_inttypes_h" 1>&6
for ac_func in strtoul bsearch strerror putenv popen vprintf bcopy bzero bcmp \ for ac_func in strtoul bsearch strerror putenv popen vprintf bcopy bzero bcmp \
index rindex kill getrlimit setrlimit atoll atoq sysconf index rindex strchr strrchr kill getrlimit setrlimit atoll atoq sysconf
do do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1683: checking for $ac_func" >&5 echo "configure:1683: checking for $ac_func" >&5
......
...@@ -181,7 +181,7 @@ AC_CACHE_VAL(gcc_cv_header_inttypes_h, ...@@ -181,7 +181,7 @@ AC_CACHE_VAL(gcc_cv_header_inttypes_h,
AC_MSG_RESULT($gcc_cv_header_inttypes_h) AC_MSG_RESULT($gcc_cv_header_inttypes_h)
AC_CHECK_FUNCS(strtoul bsearch strerror putenv popen vprintf bcopy bzero bcmp \ AC_CHECK_FUNCS(strtoul bsearch strerror putenv popen vprintf bcopy bzero bcmp \
index rindex kill getrlimit setrlimit atoll atoq sysconf) index rindex strchr strrchr kill getrlimit setrlimit atoll atoq sysconf)
GCC_FUNC_PRINTF_PTR GCC_FUNC_PRINTF_PTR
......
...@@ -74,6 +74,16 @@ Boston, MA 02111-1307, USA. */ ...@@ -74,6 +74,16 @@ Boston, MA 02111-1307, USA. */
#include <setjmp.h> #include <setjmp.h>
#include "gansidecl.h" #include "gansidecl.h"
/* Some systems like Linux don't declare rindex if _POSIX_SOURCE is declared,
but it normally does declare it. This means that configure thinks we don't
need to declare it. Favor using strrchr if it is available. */
#ifndef HAVE_STRRCHR
#ifdef HAVE_RINDEX
#define strrchr rindex
#endif
#endif
/* Include getopt.h for the sake of getopt_long. /* Include getopt.h for the sake of getopt_long.
We don't need the declaration of getopt, and it could conflict We don't need the declaration of getopt, and it could conflict
with something from a system header file, so effectively nullify that. */ with something from a system header file, so effectively nullify that. */
...@@ -897,7 +907,7 @@ file_could_be_converted (const char *path) ...@@ -897,7 +907,7 @@ file_could_be_converted (const char *path)
char *dir_last_slash; char *dir_last_slash;
strcpy (dir_name, path); strcpy (dir_name, path);
dir_last_slash = rindex (dir_name, '/'); dir_last_slash = strrchr (dir_name, '/');
if (dir_last_slash) if (dir_last_slash)
*dir_last_slash = '\0'; *dir_last_slash = '\0';
else else
...@@ -931,7 +941,7 @@ file_normally_convertible (const char *path) ...@@ -931,7 +941,7 @@ file_normally_convertible (const char *path)
char *dir_last_slash; char *dir_last_slash;
strcpy (dir_name, path); strcpy (dir_name, path);
dir_last_slash = rindex (dir_name, '/'); dir_last_slash = strrchr (dir_name, '/');
if (dir_last_slash) if (dir_last_slash)
*dir_last_slash = '\0'; *dir_last_slash = '\0';
else else
...@@ -2370,7 +2380,7 @@ start_over: ; ...@@ -2370,7 +2380,7 @@ start_over: ;
char *dir_end; char *dir_end;
aux_info_relocated_name = xmalloc (base_len + (p-invocation_filename)); aux_info_relocated_name = xmalloc (base_len + (p-invocation_filename));
strcpy (aux_info_relocated_name, base_source_filename); strcpy (aux_info_relocated_name, base_source_filename);
dir_end = rindex (aux_info_relocated_name, '/'); dir_end = strrchr (aux_info_relocated_name, '/');
if (dir_end) if (dir_end)
dir_end++; dir_end++;
else else
...@@ -4575,7 +4585,7 @@ main (argc, argv) ...@@ -4575,7 +4585,7 @@ main (argc, argv)
int c; int c;
const char *params = ""; const char *params = "";
pname = rindex (argv[0], '/'); pname = strrchr (argv[0], '/');
pname = pname ? pname+1 : argv[0]; pname = pname ? pname+1 : argv[0];
cwd_buffer = getpwd (); cwd_buffer = getpwd ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment