aboutsummaryrefslogtreecommitdiff
path: root/lstrlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lstrlib.c')
-rw-r--r--lstrlib.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lstrlib.c b/lstrlib.c
index 656953b8..90dba169 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.165 2011/03/18 19:02:33 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.166 2011/04/20 16:36:28 roberto Exp roberto $
3** Standard library for string operations and pattern-matching 3** Standard library for string operations and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -118,10 +118,10 @@ static int str_rep (lua_State *L) {
118 luaL_Buffer b; 118 luaL_Buffer b;
119 char *p = luaL_buffinitsize(L, &b, totallen); 119 char *p = luaL_buffinitsize(L, &b, totallen);
120 while (n-- > 1) { /* first n-1 copies (followed by separator) */ 120 while (n-- > 1) { /* first n-1 copies (followed by separator) */
121 memcpy(p, s, l); p += l; 121 memcpy(p, s, l * sizeof(char)); p += l;
122 memcpy(p, sep, lsep); p += lsep; 122 memcpy(p, sep, lsep * sizeof(char)); p += lsep;
123 } 123 }
124 memcpy(p, s, l); /* last copy (not followed by separator) */ 124 memcpy(p, s, l * sizeof(char)); /* last copy (not followed by separator) */
125 luaL_pushresultsize(&b, totallen); 125 luaL_pushresultsize(&b, totallen);
126 } 126 }
127 return 1; 127 return 1;
@@ -820,7 +820,7 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
820 if (isdigit(uchar(*p))) 820 if (isdigit(uchar(*p)))
821 luaL_error(L, "invalid format (width or precision too long)"); 821 luaL_error(L, "invalid format (width or precision too long)");
822 *(form++) = '%'; 822 *(form++) = '%';
823 memcpy(form, strfrmt, p - strfrmt + 1); 823 memcpy(form, strfrmt, (p - strfrmt + 1) * sizeof(char));
824 form += p - strfrmt + 1; 824 form += p - strfrmt + 1;
825 *form = '\0'; 825 *form = '\0';
826 return p; 826 return p;