summaryrefslogtreecommitdiff
path: root/src/lstrlib.c
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2008-08-12 12:00:00 +0000
committerrepogen <>2008-08-12 12:00:00 +0000
commit22486e05cc9d1a6b207504e037de512240c0432f (patch)
treee1b29dc03c497c069b5360101e924850fba6aec2 /src/lstrlib.c
parent52441b3df3a2448a8a30548a19601c6fc5689934 (diff)
downloadlua-github-5.1.4-rc1.tar.gz
Lua 5.1.4-rc15.1.4-rc1
Diffstat (limited to 'src/lstrlib.c')
-rw-r--r--src/lstrlib.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lstrlib.c b/src/lstrlib.c
index ca333ba1..1b4763d4 100644
--- a/src/lstrlib.c
+++ b/src/lstrlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstrlib.c,v 1.132.1.3 2007/12/28 15:32:23 roberto Exp $
+** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
@@ -35,7 +35,8 @@ static int str_len (lua_State *L) {
static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) {
/* relative string position: negative means back from end */
- return (pos>=0) ? pos : (ptrdiff_t)len+pos+1;
+ if (pos < 0) pos += (ptrdiff_t)len + 1;
+ return (pos >= 0) ? pos : 0;
}