aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-02-26 00:36:53 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-02-26 00:36:53 +0100
commit1961aea305e258ba7ab3910d084451220f55ed44 (patch)
treebd889c8e596051c187b93af9c50508c6009f2683 /libbb
parent3305c008ed6084f58b59dde5198ae92e3a458e46 (diff)
downloadbusybox-1961aea305e258ba7ab3910d084451220f55ed44.tar.gz
move endofname() to libbb
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/endofname.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/libbb/endofname.c b/libbb/endofname.c
new file mode 100644
index 000000000..305f0932b
--- /dev/null
+++ b/libbb/endofname.c
@@ -0,0 +1,26 @@
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 2013 Denys Vlasenko
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+
+//kbuild:lib-y += endofname.o
+
+#include "libbb.h"
+
+#define is_name(c) ((c) == '_' || isalpha((unsigned char)(c)))
+#define is_in_name(c) ((c) == '_' || isalnum((unsigned char)(c)))
+
+const char* FAST_FUNC
+endofname(const char *name)
+{
+ if (!is_name(*name))
+ return name;
+ while (*++name) {
+ if (!is_in_name(*name))
+ break;
+ }
+ return name;
+}