new names for "lua_pushlstr" and "lua_getstrlen"

This commit is contained in:
Roberto Ierusalimschy 1998-03-06 15:47:42 -03:00
parent 88a2023c32
commit 043c2ac258
5 changed files with 16 additions and 16 deletions

8
lapi.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lapi.c,v 1.21 1998/02/12 19:23:32 roberto Exp roberto $ ** $Id: lapi.c,v 1.22 1998/03/06 16:54:42 roberto Exp roberto $
** Lua API ** Lua API
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -293,7 +293,7 @@ char *lua_getstring (lua_Object object)
else return (svalue(Address(object))); else return (svalue(Address(object)));
} }
long lua_getstrlen (lua_Object object) long lua_strlen (lua_Object object)
{ {
luaC_checkGC(); /* "tostring" may create a new string */ luaC_checkGC(); /* "tostring" may create a new string */
if (object == LUA_NOOBJECT || tostring(Address(object))) if (object == LUA_NOOBJECT || tostring(Address(object)))
@ -329,7 +329,7 @@ void lua_pushnumber (double n)
incr_top; incr_top;
} }
void lua_pushlstr (char *s, long len) void lua_pushlstring (char *s, long len)
{ {
tsvalue(L->stack.top) = luaS_newlstr(s, len); tsvalue(L->stack.top) = luaS_newlstr(s, len);
ttype(L->stack.top) = LUA_T_STRING; ttype(L->stack.top) = LUA_T_STRING;
@ -342,7 +342,7 @@ void lua_pushstring (char *s)
if (s == NULL) if (s == NULL)
lua_pushnil(); lua_pushnil();
else else
lua_pushlstr(s, strlen(s)); lua_pushlstring(s, strlen(s));
} }
void lua_pushCclosure (lua_CFunction fn, int n) void lua_pushCclosure (lua_CFunction fn, int n)

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lauxlib.c,v 1.8 1998/01/09 15:09:53 roberto Exp roberto $ ** $Id: lauxlib.c,v 1.9 1998/03/06 16:54:42 roberto Exp roberto $
** Auxiliar functions for building Lua libraries ** Auxiliar functions for building Lua libraries
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -35,7 +35,7 @@ char *luaL_check_lstr (int numArg, long *len)
{ {
lua_Object o = lua_getparam(numArg); lua_Object o = lua_getparam(numArg);
luaL_arg_check(lua_isstring(o), numArg, "string expected"); luaL_arg_check(lua_isstring(o), numArg, "string expected");
if (len) *len = lua_getstrlen(o); if (len) *len = lua_strlen(o);
return lua_getstring(o); return lua_getstring(o);
} }

View File

@ -1,5 +1,5 @@
/* /*
** $Id: liolib.c,v 1.14 1998/01/07 16:26:48 roberto Exp roberto $ ** $Id: liolib.c,v 1.15 1998/03/06 16:54:42 roberto Exp roberto $
** Standard I/O (and system) library ** Standard I/O (and system) library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -233,7 +233,7 @@ static void io_read (void)
ungetc(c, f); ungetc(c, f);
l = luaL_getsize(); l = luaL_getsize();
if (l > 0 || *p == 0) /* read something or did not fail? */ if (l > 0 || *p == 0) /* read something or did not fail? */
lua_pushlstr(luaL_buffer(), l); lua_pushlstring(luaL_buffer(), l);
} }

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lstrlib.c,v 1.8 1998/01/27 19:11:36 roberto Exp roberto $ ** $Id: lstrlib.c,v 1.9 1998/03/06 16:54:42 roberto Exp roberto $
** Standard library for strings and pattern-matching ** Standard library for strings and pattern-matching
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -34,7 +34,7 @@ static void str_len (void)
static void closeandpush (void) static void closeandpush (void)
{ {
lua_pushlstr(luaL_buffer(), luaL_getsize()); lua_pushlstring(luaL_buffer(), luaL_getsize());
} }
@ -52,7 +52,7 @@ static void str_sub (void)
long start = posrelat(luaL_check_number(2), l); long start = posrelat(luaL_check_number(2), l);
long end = posrelat(luaL_opt_number(3, -1), l); long end = posrelat(luaL_opt_number(3, -1), l);
if (1 <= start && start <= end && end <= l) if (1 <= start && start <= end && end <= l)
lua_pushlstr(s+start-1, end-start+1); lua_pushlstring(s+start-1, end-start+1);
else lua_pushstring(""); else lua_pushstring("");
} }
@ -128,7 +128,7 @@ static void push_captures (struct Capture *cap)
{ {
int i; int i;
for (i=0; i<cap->level; i++) for (i=0; i<cap->level; i++)
lua_pushlstr(cap->capture[i].init, cap->capture[i].len); lua_pushlstring(cap->capture[i].init, cap->capture[i].len);
} }
@ -379,7 +379,7 @@ static void add_s (lua_Object newp, struct Capture *cap)
} }
res = lua_getresult(1); res = lua_getresult(1);
if (lua_isstring(res)) if (lua_isstring(res))
addnchar(lua_getstring(res), lua_getstrlen(res)); addnchar(lua_getstring(res), lua_strlen(res));
else else
addnchar(NULL, 0); addnchar(NULL, 0);
lua_endblock(); lua_endblock();

6
lua.h
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lua.h,v 1.15 1998/02/12 19:23:32 roberto Exp roberto $ ** $Id: lua.h,v 1.16 1998/03/06 16:54:42 roberto Exp roberto $
** Lua - An Extensible Extension Language ** Lua - An Extensible Extension Language
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
** e-mail: lua@tecgraf.puc-rio.br ** e-mail: lua@tecgraf.puc-rio.br
@ -90,14 +90,14 @@ int lua_isfunction (lua_Object object);
double lua_getnumber (lua_Object object); double lua_getnumber (lua_Object object);
char *lua_getstring (lua_Object object); char *lua_getstring (lua_Object object);
long lua_getstrlen (lua_Object object); long lua_strlen (lua_Object object);
lua_CFunction lua_getcfunction (lua_Object object); lua_CFunction lua_getcfunction (lua_Object object);
void *lua_getuserdata (lua_Object object); void *lua_getuserdata (lua_Object object);
void lua_pushnil (void); void lua_pushnil (void);
void lua_pushnumber (double n); void lua_pushnumber (double n);
void lua_pushlstr (char *s, long len); void lua_pushlstring (char *s, long len);
void lua_pushstring (char *s); void lua_pushstring (char *s);
void lua_pushCclosure (lua_CFunction fn, int n); void lua_pushCclosure (lua_CFunction fn, int n);
void lua_pushusertag (void *u, int tag); void lua_pushusertag (void *u, int tag);