2009-07-05 Bean <bean123ch@gmail.com>
* conf/common.rmk (lua_mode_SOURCES): Add script/lua/lstrlib.c. * script/lua/grub_lib.c (grub_lua_run): Check input parameter. (grub_lua_getenv): Likewise. (grub_lua_setenv): Likewise. (save_errno): New function. (push_result): Likewise. (grub_lua_enum_device): Likewise. (grub_lua_enum_file): Likewise. (grub_lua_file_open): Likewise. (grub_lua_file_close): Likewise. (grub_lua_file_seek): Likewise. (grub_lua_file_read): Likewise. (grub_lua_file_getline): Likewise. (grub_lua_file_getsize): Likewise. (grub_lua_file_getpos): Likewise. (grub_lua_file_eof): Likewise. (grub_lua_file_exist): Likewise. (grub_lua_add_menu): Likewise. * script/lua/grub_lua.h (isupper): New inline function. (islower): Likewise. (ispunct): Likewise. (isxdigit): Likewise. (strcspn): Change to normal function. (strpbkr): New function declaration. (memchr): Likewise. * script/lua/grub_main.c (scan_str): New function. (strcspn): Likewise. (strpbrk): Likewise. (memchr): Likewise. * script/lua/linit.c (lualibs): Enable the string library. * util/osdetect.lua: New file.
This commit is contained in:
parent
2da9229550
commit
b4a1dc7990
7 changed files with 581 additions and 41 deletions
|
@ -77,26 +77,28 @@ iscntrl (int c)
|
|||
}
|
||||
|
||||
static inline int
|
||||
strcspn(const char *s1, const char *s2)
|
||||
isupper (int c)
|
||||
{
|
||||
int size = 0;
|
||||
return ((c >= 'A') && (c <= 'Z'));
|
||||
}
|
||||
|
||||
while (*s1)
|
||||
{
|
||||
const char *p = s2;
|
||||
static inline int
|
||||
islower (int c)
|
||||
{
|
||||
return ((c >= 'a') && (c <= 'z'));
|
||||
}
|
||||
|
||||
while (*p)
|
||||
{
|
||||
if (*s1 == *p)
|
||||
return size;
|
||||
p++;
|
||||
}
|
||||
static inline int
|
||||
ispunct (int c)
|
||||
{
|
||||
return ((! isspace (c)) && (! isalnum (c)));
|
||||
}
|
||||
|
||||
s1++;
|
||||
size++;
|
||||
}
|
||||
|
||||
return size;
|
||||
static inline int
|
||||
isxdigit (int c)
|
||||
{
|
||||
return (isdigit (c) || ((c >= 'a') && (c <= 'f')) ||
|
||||
((c >= 'A') && (c <= 'F')));
|
||||
}
|
||||
|
||||
static inline int
|
||||
|
@ -105,4 +107,8 @@ abs (int c)
|
|||
return (c >= 0) ? : -c;
|
||||
}
|
||||
|
||||
int strcspn (const char *s1, const char *s2);
|
||||
char *strpbrk (const char *s1, const char *s2);
|
||||
void *memchr (const void *s, int c, size_t n);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue