move endofname() to libbb

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2013-02-26 00:36:53 +01:00
parent 3305c008ed
commit 1961aea305
5 changed files with 30 additions and 38 deletions

26
libbb/endofname.c Normal file
View File

@@ -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;
}