summaryrefslogtreecommitdiff
path: root/ccc/stringutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'ccc/stringutil.c')
-rw-r--r--ccc/stringutil.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ccc/stringutil.c b/ccc/stringutil.c
new file mode 100644
index 0000000..aab4f03
--- /dev/null
+++ b/ccc/stringutil.c
@@ -0,0 +1,22 @@
+#include "stringutil.h"
+
+
+char*
+strend(char* s)
+{
+ if (strlen(s) == 0) return '\0';
+ while(*s != '\0')
+ ++s;
+ return --s;
+}
+
+bool
+endswith(char* s, char* suff)
+{
+ if (strlen(s) < strlen(suff)) return false;
+ char* a = strend(s)-(strlen(suff)-1);
+ if (!a) return false;
+ if (!strcmp(a, suff)) return true;
+ return false;
+}
+