From 3636bbad3acb6c1671f20ec3f7dc65507146d7f4 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 20 Sep 1996 15:20:44 -0300 Subject: [PATCH] new function "strrep" --- strlib.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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},