diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-03-24 11:05:51 +0100 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-03-24 11:05:51 +0100 |
commit | 00340610e70f3651d267a210e2c2914f1102d086 (patch) | |
tree | b7b627aaf45df77bb6d2984d93b998f5954feec5 /src/lstrlib.js | |
parent | a6fa99b44b6d536a1fb23f9ffd7a84786c63edab (diff) | |
download | fengari-00340610e70f3651d267a210e2c2914f1102d086.tar.gz fengari-00340610e70f3651d267a210e2c2914f1102d086.tar.bz2 fengari-00340610e70f3651d267a210e2c2914f1102d086.zip |
string.rep: don't repeat if n == 0
Diffstat (limited to 'src/lstrlib.js')
-rw-r--r-- | src/lstrlib.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js index 4bd8664..3a2ea39 100644 --- a/src/lstrlib.js +++ b/src/lstrlib.js @@ -668,7 +668,7 @@ const str_rep = function(L) { let n = lauxlib.luaL_checkinteger(L, 2); let sep = lauxlib.luaL_optstring(L, 3, ""); - lapi.lua_pushstring(L, (s + sep).repeat(n - 1) + s); + lapi.lua_pushstring(L, n > 0 ? (s + sep).repeat(n - 1) + s : ""); return 1; }; |