Commit Message
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.
--
Comments
On Tue, 10 Jan 2017, Wilco Dijkstra wrote:
> 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.
How did you identify where should be changed? Did you make sure installed
stripped shared libraries were unchanged by the patch?
I see calls in hurd/path-lookup.c and sunrpc/rpc_main.c that I'd expect to
be similarly changed.
Joseph Myers wrote:
> On Tue, 10 Jan 2017, Wilco Dijkstra wrote:
>
> > 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.
>
> How did you identify where should be changed? Did you make sure installed
> stripped shared libraries were unchanged by the patch?
>
> I see calls in hurd/path-lookup.c and sunrpc/rpc_main.c that I'd expect to
> be similarly changed.
I checked there are no local plt failures and no uses of it in the libc/libm.so.
sunrpc/rpc_main.c seems to be an application, so it's OK to use (r)index.
I can't find the functions in hurd/path-lookup.c in any .so, in fact none of the
files in hurd seem to be built. Is it dead or only used for a subset of targets?
Wilco
On Tue, 10 Jan 2017, Wilco Dijkstra wrote:
> Joseph Myers wrote:
> > On Tue, 10 Jan 2017, Wilco Dijkstra wrote:
> >
> > > 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.
> >
> > How did you identify where should be changed? Did you make sure installed
> > stripped shared libraries were unchanged by the patch?
> >
> > I see calls in hurd/path-lookup.c and sunrpc/rpc_main.c that I'd expect to
> > be similarly changed.
>
> I checked there are no local plt failures and no uses of it in the libc/libm.so.
> sunrpc/rpc_main.c seems to be an application, so it's OK to use (r)index.
That doesn't mean it's a good idea for it to use those obsolete symbols.
> I can't find the functions in hurd/path-lookup.c in any .so, in fact
> none of the files in hurd seem to be built. Is it dead or only used for
> a subset of targets?
It's built, as you would expect, for Hurd targets. Hurd and NaCl people
have not yet contributed build-many-glibcs.py patches to build unmodified
sources for those targets (or pointed to sufficiently clear instructions
on kernel headers etc. for someone unfamiliar with those targets to add
support), so they are not yet covered by that script.
@@ -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;
@@ -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
@@ -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;