diff options
Diffstat (limited to '')
| -rw-r--r-- | lstrlib.c | 19 |
1 files changed, 11 insertions, 8 deletions
| @@ -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 | ||
| 95 | static void str_ascii (void) | 95 | static 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 | ||
| 104 | static void str_int2str (void) | 104 | static 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} |
