shorten strchr and runestrchr

This commit is contained in:
Amavect 2022-05-22 22:38:11 +00:00 committed by Ori Bernstein
parent 47cff2e833
commit 761bf6c347
2 changed files with 14 additions and 20 deletions

View file

@ -4,17 +4,14 @@
Rune*
runestrchr(Rune *s, Rune c)
{
Rune c0 = c;
Rune c1;
Rune r;
if(c == 0) {
if(c == 0)
while(*s++)
;
return s-1;
}
while(c1 = *s++)
if(c1 == c0)
return s-1;
return 0;
else
while((r = *s++) != c)
if(r == 0)
return 0;
return s-1;
}

View file

@ -4,17 +4,14 @@
char*
strchr(char *s, int c)
{
char c0 = c;
char c1;
char r;
if(c == 0) {
if(c == 0)
while(*s++)
;
return s-1;
}
while(c1 = *s++)
if(c1 == c0)
return s-1;
return 0;
else
while((r = *s++) != c)
if(r == 0)
return 0;
return s-1;
}