From 88b1ae93b33a07c9da98c86c8484d6af05bb7cb1 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Mon, 12 Jun 2023 18:27:02 +0000 Subject: [PATCH] add: strchr --- src/strchr.🗿 | 12 ++++++++++++ tests/strchr.🗿 | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/strchr.🗿 create mode 100644 tests/strchr.🗿 diff --git a/src/strchr.🗿 b/src/strchr.🗿 new file mode 100644 index 0000000..c778d15 --- /dev/null +++ b/src/strchr.🗿 @@ -0,0 +1,12 @@ +strchr(str, c) +{ + local i; + i = 0; + loop { + if ([str + i] == c) + return (str + i); + if ([str + i] == 0) + return (0); + i = i + 1; + } +} diff --git a/tests/strchr.🗿 b/tests/strchr.🗿 new file mode 100644 index 0000000..5fb630d --- /dev/null +++ b/tests/strchr.🗿 @@ -0,0 +1,12 @@ +global name; + +main() +{ + local str; + name = "strchr"; + str = "bozoman du 36"; + test(strchr(str, 'z'), str + 2, ""); + test(strchr(str, 0), str + 13, ""); + test(strchr(str, '5'), 0, ""); + test(strchr(str, '6'), str + 12, ""); +}