svn commit: r219680 - in head/bin: ln rm test

Alexander Best arundel at freebsd.org
Tue Mar 15 23:54:19 UTC 2011


On Tue Mar 15 11, Jilles Tjoelker wrote:
> Author: jilles
> Date: Tue Mar 15 22:22:11 2011
> New Revision: 219680
> URL: http://svn.freebsd.org/changeset/base/219680
> 
> Log:
>   bin: Prefer strrchr() to rindex().

shouldn't the rindex(3) manual contain a note regarding it's depricated nature
and the fact that strchr(3) is preferred?

cheers.
alex

>   
>   This removes the last index/rindex usage from /bin.
> 
> Modified:
>   head/bin/ln/ln.c
>   head/bin/rm/rm.c
>   head/bin/test/test.c
> 
> Modified: head/bin/ln/ln.c
> ==============================================================================
> --- head/bin/ln/ln.c	Tue Mar 15 21:45:10 2011	(r219679)
> +++ head/bin/ln/ln.c	Tue Mar 15 22:22:11 2011	(r219680)
> @@ -80,7 +80,7 @@ main(int argc, char *argv[])
>  	 * "link", for which the functionality provided is greatly
>  	 * simplified.
>  	 */
> -	if ((p = rindex(argv[0], '/')) == NULL)
> +	if ((p = strrchr(argv[0], '/')) == NULL)
>  		p = argv[0];
>  	else
>  		++p;
> 
> Modified: head/bin/rm/rm.c
> ==============================================================================
> --- head/bin/rm/rm.c	Tue Mar 15 21:45:10 2011	(r219679)
> +++ head/bin/rm/rm.c	Tue Mar 15 22:22:11 2011	(r219680)
> @@ -90,7 +90,7 @@ main(int argc, char *argv[])
>  	 * "unlink", for which the functionality provided is greatly
>  	 * simplified.
>  	 */
> -	if ((p = rindex(argv[0], '/')) == NULL)
> +	if ((p = strrchr(argv[0], '/')) == NULL)
>  		p = argv[0];
>  	else
>  		++p;
> 
> Modified: head/bin/test/test.c
> ==============================================================================
> --- head/bin/test/test.c	Tue Mar 15 21:45:10 2011	(r219679)
> +++ head/bin/test/test.c	Tue Mar 15 22:22:11 2011	(r219680)
> @@ -194,7 +194,7 @@ main(int argc, char **argv)
>  	int	res;
>  	char	*p;
>  
> -	if ((p = rindex(argv[0], '/')) == NULL)
> +	if ((p = strrchr(argv[0], '/')) == NULL)
>  		p = argv[0];
>  	else
>  		p++;

-- 
a13x


More information about the svn-src-all mailing list