aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-05-31 19:20:45 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-05-31 19:20:45 -0300
commit6152973f9c8a263de4c28d635f76a4e15fb6d297 (patch)
tree4127e014499815acb242016afe3938606775826c
parent243a8080671c7df29a77a2e4bf8a08b8ee735de9 (diff)
downloadlua-6152973f9c8a263de4c28d635f76a4e15fb6d297.tar.gz
lua-6152973f9c8a263de4c28d635f76a4e15fb6d297.tar.bz2
lua-6152973f9c8a263de4c28d635f76a4e15fb6d297.zip
new names for 'ascii' ('strbyte') and 'int2str' ('strchar')
-rw-r--r--lstrlib.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/lstrlib.c b/lstrlib.c
index 4117f2e1..a42a6118 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.12 1998/03/24 20:14:25 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.13 1998/05/18 22:21:55 roberto Exp roberto $
3** Standard library for strings and pattern-matching 3** Standard library for strings and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -92,7 +92,7 @@ static void str_rep (void)
92} 92}
93 93
94 94
95static void str_ascii (void) 95static void str_byte (void)
96{ 96{
97 long l; 97 long l;
98 char *s = luaL_check_lstr(1, &l); 98 char *s = luaL_check_lstr(1, &l);
@@ -101,12 +101,14 @@ static void str_ascii (void)
101 lua_pushnumber((unsigned char)s[pos-1]); 101 lua_pushnumber((unsigned char)s[pos-1]);
102} 102}
103 103
104static void str_int2str (void) 104static void str_char (void) {
105{
106 int i = 0; 105 int i = 0;
107 luaL_resetbuffer(); 106 luaL_resetbuffer();
108 while (lua_getparam(++i) != LUA_NOOBJECT) 107 while (lua_getparam(++i) != LUA_NOOBJECT) {
109 luaL_addchar((int)luaL_check_number(i)); 108 double c = luaL_check_number(i);
109 luaL_arg_check((unsigned char)c == c, i, "invalid value");
110 luaL_addchar((int)c);
111 }
110 closeandpush(); 112 closeandpush();
111} 113}
112 114
@@ -518,9 +520,10 @@ static struct luaL_reg strlib[] = {
518{"strsub", str_sub}, 520{"strsub", str_sub},
519{"strlower", str_lower}, 521{"strlower", str_lower},
520{"strupper", str_upper}, 522{"strupper", str_upper},
521{"int2str", str_int2str}, 523{"strchar", str_char},
522{"strrep", str_rep}, 524{"strrep", str_rep},
523{"ascii", str_ascii}, 525{"ascii", str_byte}, /* for compatibility */
526{"strbyte", str_byte},
524{"format", str_format}, 527{"format", str_format},
525{"strfind", str_find}, 528{"strfind", str_find},
526{"gsub", str_gsub} 529{"gsub", str_gsub}