summaryrefslogtreecommitdiff
path: root/sys/src/libc
diff options
context:
space:
mode:
authorAmavect <amavect@gmail.com>2022-05-22 22:38:11 +0000
committerOri Bernstein <ori@eigenstate.org>2022-05-22 22:38:11 +0000
commit761bf6c3477b2bef675c20aad954acae02b923ed (patch)
tree277e15f8d0072e684e8c9f83c77903f7aeead6b8 /sys/src/libc
parent47cff2e833604ecf7e8f2742911efb444e2b912e (diff)
shorten strchr and runestrchr
Diffstat (limited to 'sys/src/libc')
-rw-r--r--sys/src/libc/port/runestrchr.c17
-rw-r--r--sys/src/libc/port/strchr.c17
2 files changed, 14 insertions, 20 deletions
diff --git a/sys/src/libc/port/runestrchr.c b/sys/src/libc/port/runestrchr.c
index af7fc4e88..e4c757dff 100644
--- a/sys/src/libc/port/runestrchr.c
+++ b/sys/src/libc/port/runestrchr.c
@@ -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;
}
diff --git a/sys/src/libc/port/strchr.c b/sys/src/libc/port/strchr.c
index 1e9aab597..72a8f1627 100644
--- a/sys/src/libc/port/strchr.c
+++ b/sys/src/libc/port/strchr.c
@@ -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;
}