X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/1691e80890e5d8ba258c51c214a3e91880e1db2b..95e0df2af:/sbr/r1bindex.c?ds=inline diff --git a/sbr/r1bindex.c b/sbr/r1bindex.c index 087ed78d..b4ad0e8f 100644 --- a/sbr/r1bindex.c +++ b/sbr/r1bindex.c @@ -5,28 +5,24 @@ * -- character. If the character doesn't occur, the * -- pointer will be at the beginning of the string. * - * $Id$ + * This code is Copyright (c) 2002, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. */ #include - char * r1bindex(char *str, int chr) { - char *cp; - - /* find null at the end of the string */ - for (cp = str; *cp; cp++) - continue; + char *r; - /* backup to the rightmost character */ - --cp; + if (!chr) + return str; /* Match old behaviour, don't know if it's used. */ - /* now search for the rightmost occurrence of the character */ - while (cp >= str && *cp != chr) - --cp; + r = strrchr(str, chr); + if (r) + return r + 1; - /* now move one to the right */ - return (++cp); + return str; }