mirror of https://github.com/rusefi/lua.git
new function "strrep"
This commit is contained in:
parent
82f9f3e552
commit
3636bbad3a
13
strlib.c
13
strlib.c
|
@ -3,7 +3,7 @@
|
||||||
** String library to LUA
|
** String library to LUA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_strlib="$Id: strlib.c,v 1.27 1996/08/09 13:14:11 roberto Exp roberto $";
|
char *rcs_strlib="$Id: strlib.c,v 1.28 1996/09/16 18:02:40 roberto Exp roberto $";
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -170,6 +170,16 @@ static void str_upper (void)
|
||||||
lua_pushstring(luaI_addchar(0));
|
lua_pushstring(luaI_addchar(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void str_rep (void)
|
||||||
|
{
|
||||||
|
char *s = lua_check_string(1, "strrep");
|
||||||
|
int n = (int)lua_check_number(2, "strrep");
|
||||||
|
luaI_addchar(0);
|
||||||
|
while (n-- > 0)
|
||||||
|
addstr(s);
|
||||||
|
lua_pushstring(luaI_addchar(0));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** get ascii value of a character in a string
|
** get ascii value of a character in a string
|
||||||
*/
|
*/
|
||||||
|
@ -522,6 +532,7 @@ static struct lua_reg strlib[] = {
|
||||||
{"strset", str_set},
|
{"strset", str_set},
|
||||||
{"strlower", str_lower},
|
{"strlower", str_lower},
|
||||||
{"strupper", str_upper},
|
{"strupper", str_upper},
|
||||||
|
{"strrep", str_rep},
|
||||||
{"ascii", str_ascii},
|
{"ascii", str_ascii},
|
||||||
{"format", str_format},
|
{"format", str_format},
|
||||||
{"strfind", str_find},
|
{"strfind", str_find},
|
||||||
|
|
Loading…
Reference in New Issue