aboutsummaryrefslogtreecommitdiff
path: root/libbb/strrstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/strrstr.c')
-rw-r--r--libbb/strrstr.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libbb/strrstr.c b/libbb/strrstr.c
new file mode 100644
index 000000000..b314264f5
--- /dev/null
+++ b/libbb/strrstr.c
@@ -0,0 +1,20 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 2008 Bernhard Fischer
+ *
+ * Licensed under GPLv2 or later, see file License in this tarball for details.
+ */
+
+#include "libbb.h"
+
+/* reverse strstr() */
+char* strrstr(const char *haystack, const char *needle)
+{
+ char *tmp = strrchr(haystack, *needle);
+ if (tmp == NULL || strcmp(tmp, needle) != 0)
+ return NULL;
+ return tmp;
+}
+