aboutsummaryrefslogtreecommitdiff
path: root/lutf8lib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-20 11:11:00 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-20 11:11:00 -0300
commit7707f3e7c3eea95551255f7dafa6ff918d3cf23a (patch)
tree6a4c0dd8f98397eee713a548d9e36611a122be50 /lutf8lib.c
parent16f8e449244f313e4e8b185948b363fd38a2f795 (diff)
downloadlua-7707f3e7c3eea95551255f7dafa6ff918d3cf23a.tar.gz
lua-7707f3e7c3eea95551255f7dafa6ff918d3cf23a.tar.bz2
lua-7707f3e7c3eea95551255f7dafa6ff918d3cf23a.zip
'posrelat' -> 'u_posrelat' (to avoid name conflict in 'one.c')
Diffstat (limited to 'lutf8lib.c')
-rw-r--r--lutf8lib.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lutf8lib.c b/lutf8lib.c
index df9a577a..bc3c7158 100644
--- a/lutf8lib.c
+++ b/lutf8lib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: $ 2** $Id: lutf8lib.c,v 1.2 2014/02/06 20:03:24 roberto Exp roberto $
3** Standard library for UTF-8 manipulation 3** Standard library for UTF-8 manipulation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -24,7 +24,7 @@
24 24
25/* from strlib */ 25/* from strlib */
26/* translate a relative string position: negative means back from end */ 26/* translate a relative string position: negative means back from end */
27static lua_Integer posrelat (lua_Integer pos, size_t len) { 27static lua_Integer u_posrelat (lua_Integer pos, size_t len) {
28 if (pos >= 0) return pos; 28 if (pos >= 0) return pos;
29 else if (0u - (size_t)pos > len) return 0; 29 else if (0u - (size_t)pos > len) return 0;
30 else return (lua_Integer)len + pos + 1; 30 else return (lua_Integer)len + pos + 1;
@@ -69,7 +69,7 @@ static int utflen (lua_State *L) {
69 const char *ends; 69 const char *ends;
70 size_t len; 70 size_t len;
71 const char *s = luaL_checklstring(L, 1, &len); 71 const char *s = luaL_checklstring(L, 1, &len);
72 lua_Integer posi = posrelat(luaL_optinteger(L, 2, 1), 1); 72 lua_Integer posi = u_posrelat(luaL_optinteger(L, 2, 1), 1);
73 luaL_argcheck(L, 1 <= posi && posi <= (lua_Integer)len, 1, 73 luaL_argcheck(L, 1 <= posi && posi <= (lua_Integer)len, 1,
74 "initial position out of string"); 74 "initial position out of string");
75 ends = s + len; 75 ends = s + len;
@@ -91,8 +91,8 @@ static int utflen (lua_State *L) {
91static int codepoint (lua_State *L) { 91static int codepoint (lua_State *L) {
92 size_t len; 92 size_t len;
93 const char *s = luaL_checklstring(L, 1, &len); 93 const char *s = luaL_checklstring(L, 1, &len);
94 lua_Integer posi = posrelat(luaL_optinteger(L, 2, 1), len); 94 lua_Integer posi = u_posrelat(luaL_optinteger(L, 2, 1), len);
95 lua_Integer pose = posrelat(luaL_optinteger(L, 3, posi), len); 95 lua_Integer pose = u_posrelat(luaL_optinteger(L, 3, posi), len);
96 int n; 96 int n;
97 const char *se; 97 const char *se;
98 luaL_argcheck(L, posi >= 1, 2, "out of range"); 98 luaL_argcheck(L, posi >= 1, 2, "out of range");
@@ -152,7 +152,7 @@ static int byteoffset (lua_State *L) {
152 size_t len; 152 size_t len;
153 const char *s = luaL_checklstring(L, 1, &len); 153 const char *s = luaL_checklstring(L, 1, &len);
154 int n = luaL_checkint(L, 2); 154 int n = luaL_checkint(L, 2);
155 lua_Integer posi = posrelat(luaL_optinteger(L, 3, 1), len) - 1; 155 lua_Integer posi = u_posrelat(luaL_optinteger(L, 3, 1), len) - 1;
156 luaL_argcheck(L, 0 <= posi && posi <= (lua_Integer)len, 3, 156 luaL_argcheck(L, 0 <= posi && posi <= (lua_Integer)len, 3,
157 "position out of range"); 157 "position out of range");
158 if (n == 0) { 158 if (n == 0) {