diff --git a/strlib.c b/strlib.c index be9e7734..78c6012c 100644 --- a/strlib.c +++ b/strlib.c @@ -3,7 +3,7 @@ ** 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 #include @@ -170,6 +170,16 @@ static void str_upper (void) 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 */ @@ -522,6 +532,7 @@ static struct lua_reg strlib[] = { {"strset", str_set}, {"strlower", str_lower}, {"strupper", str_upper}, +{"strrep", str_rep}, {"ascii", str_ascii}, {"format", str_format}, {"strfind", str_find},