aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2017-05-08 23:01:06 -0500
committerRob Landley <rob@landley.net>2017-05-08 23:01:06 -0500
commitd74b562f508475192b6783b0b2d4dae4e5c2fa93 (patch)
treefd654c847b9b50924b26b37ed47af16b28e63a64 /lib/lib.c
parent71921dc74d051fb352bbb65dc92c3416e219dbb9 (diff)
downloadtoybox-d74b562f508475192b6783b0b2d4dae4e5c2fa93.tar.gz
Move strend() to lib/lib.c
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/lib.c b/lib/lib.c
index f6776142..ceced263 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -392,6 +392,15 @@ int unescape(char c)
return (idx == -1) ? 0 : to[idx];
}
+char *strend(char *str, char *suffix)
+{
+ long a = strlen(str), b = strlen(suffix);
+
+ if (a>b && !strcmp(str += a-b, suffix)) return str;
+
+ return 0;
+}
+
// If *a starts with b, advance *a past it and return 1, else return 0;
int strstart(char **a, char *b)
{