This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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] Remove index defines


As a minor cleanup remove the (r)index defines from include/string.h as they are only
used internally in a few places.  Rename a few uses that occur in libc.so.

ChangeLog:
2017-01-10  Wilco Dijkstra  <wdijkstr@arm.com>

	* include/string.h (index): Remove define.
	(rindex): Likewise.
	* misc/getttyent.c (__getttyent): Rename index to strchr.
	* misc/ttyslot.c (ttyslot): Rename rindex to strrchr.
--

diff --git a/include/string.h b/include/string.h
index e145bfdb4cb781fbced37634410dd2b844571f16..89e4bc4c91b0aea9480b21d43f95c75554d50383 100644
--- a/include/string.h
+++ b/include/string.h
@@ -149,15 +149,6 @@ extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy");
 extern __typeof (stpcpy) stpcpy __asm__ ("__stpcpy");
 #endif
 
-# ifndef _ISOMAC
-#  ifndef index
-#   define index(s, c)	(strchr ((s), (c)))
-#  endif
-#  ifndef rindex
-#   define rindex(s, c)	(strrchr ((s), (c)))
-#  endif
-# endif
-
 extern void *__memcpy_chk (void *__restrict __dest,
 			   const void *__restrict __src, size_t __len,
 			   size_t __destlen) __THROW;
diff --git a/misc/getttyent.c b/misc/getttyent.c
index d2af87012343b0596d50dfdecff14ecf55c16732..73002f52d10dc30af95d3163bc5f7a1992fe9dce 100644
--- a/misc/getttyent.c
+++ b/misc/getttyent.c
@@ -78,7 +78,7 @@ __getttyent (void)
 			return (NULL);
 		}
 		/* skip lines that are too big */
-		if (!index(p, '\n')) {
+		if (!strchr (p, '\n')) {
 			while ((c = getc_unlocked(tf)) != '\n' && c != EOF)
 				;
 			continue;
@@ -127,7 +127,7 @@ __getttyent (void)
 	tty.ty_comment = p;
 	if (*p == 0)
 		tty.ty_comment = 0;
-	if ((p = index(p, '\n')))
+	if ((p = strchr (p, '\n')))
 		*p = '\0';
 	return (&tty);
 }
@@ -179,7 +179,7 @@ internal_function
 value (char *p)
 {
 
-	return ((p = index(p, '=')) ? ++p : NULL);
+	return ((p = strchr (p, '=')) ? ++p : NULL);
 }
 
 int
diff --git a/misc/ttyslot.c b/misc/ttyslot.c
index 0ed14d73ea53e7ed09c58717316fea20fa0177eb..2f3c7953d75c8522f3b6447c43a9e33aa19e8f72 100644
--- a/misc/ttyslot.c
+++ b/misc/ttyslot.c
@@ -56,7 +56,7 @@ ttyslot (void)
 	__setttyent();
 	for (cnt = 0; cnt < 3; ++cnt)
 		if (__ttyname_r (cnt, name, buflen) == 0) {
-			if ((p = rindex(name, '/')))
+			if ((p = strrchr (name, '/')))
 				++p;
 			else
 				p = name;

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