clang-format
This commit is contained in:
@@ -43,27 +43,25 @@
|
||||
* C standard string function: find rightmost instance of a character
|
||||
* in a string.
|
||||
*/
|
||||
char *
|
||||
strrchr(const char *s, int ch_arg)
|
||||
{
|
||||
/* avoid sign-extension problems */
|
||||
const char ch = ch_arg;
|
||||
char *strrchr(const char *s, int ch_arg) {
|
||||
/* avoid sign-extension problems */
|
||||
const char ch = ch_arg;
|
||||
|
||||
/* start one past the last character INCLUDING NULL TERMINATOR */
|
||||
size_t i = strlen(s)+1;
|
||||
/* start one past the last character INCLUDING NULL TERMINATOR */
|
||||
size_t i = strlen(s) + 1;
|
||||
|
||||
/* go from right to left; stop at 0 */
|
||||
while (i > 0) {
|
||||
/* go from right to left; stop at 0 */
|
||||
while (i > 0) {
|
||||
|
||||
/* decrement first */
|
||||
i--;
|
||||
/* decrement first */
|
||||
i--;
|
||||
|
||||
/* now check the character we're over */
|
||||
if (s[i] == ch) {
|
||||
return (char *)(s+i);
|
||||
}
|
||||
}
|
||||
/* now check the character we're over */
|
||||
if (s[i] == ch) {
|
||||
return (char *)(s + i);
|
||||
}
|
||||
}
|
||||
|
||||
/* didn't find it */
|
||||
return NULL;
|
||||
/* didn't find it */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user