From 17282292c2259b130ef7833bdac97c8ce8bf5515 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Wed, 28 May 2008 14:19:27 +0000 Subject: - add strrchr --- libbb/strrstr.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 libbb/strrstr.c (limited to 'libbb/strrstr.c') 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; +} + -- cgit v1.2.3