aboutsummaryrefslogtreecommitdiffstats
path: root/missing/strchr.c
diff options
context:
space:
mode:
Diffstat (limited to 'missing/strchr.c')
-rw-r--r--missing/strchr.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/missing/strchr.c b/missing/strchr.c
new file mode 100644
index 00000000..234ac883
--- /dev/null
+++ b/missing/strchr.c
@@ -0,0 +1,35 @@
+/*
+ * strchr --- search a string for a character
+ *
+ * We supply this routine for those systems that aren't standard yet.
+ */
+
+char *
+strchr (str, c)
+register char *str, c;
+{
+ for (; *str; str++)
+ if (*str == c)
+ return str;
+
+ return NULL;
+}
+
+/*
+ * strrchr --- find the last occurrence of a character in a string
+ *
+ * We supply this routine for those systems that aren't standard yet.
+ */
+
+char *
+strrchr (str, c)
+register char *str, c;
+{
+ register char *save = NULL;
+
+ for (; *str; str++)
+ if (*str == c)
+ save = str;
+
+ return save;
+}