aboutsummaryrefslogtreecommitdiff
path: root/lobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'lobject.c')
-rw-r--r--lobject.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/lobject.c b/lobject.c
index 04ad92c4..b9aff12d 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 2.2 2004/04/30 20:13:38 roberto Exp roberto $ 2** $Id: lobject.c,v 2.3 2004/05/03 12:30:41 roberto Exp roberto $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -94,7 +94,7 @@ static void pushstr (lua_State *L, const char *str) {
94} 94}
95 95
96 96
97/* this function handles only `%d', `%c', %f, and `%s' formats */ 97/* this function handles only `%d', `%c', %f, %p, and `%s' formats */
98const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { 98const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
99 int n = 1; 99 int n = 1;
100 pushstr(L, ""); 100 pushstr(L, "");
@@ -104,9 +104,10 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
104 setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); 104 setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt));
105 incr_top(L); 105 incr_top(L);
106 switch (*(e+1)) { 106 switch (*(e+1)) {
107 case 's': 107 case 's': {
108 pushstr(L, va_arg(argp, char *)); 108 pushstr(L, va_arg(argp, char *));
109 break; 109 break;
110 }
110 case 'c': { 111 case 'c': {
111 char buff[2]; 112 char buff[2];
112 buff[0] = cast(char, va_arg(argp, int)); 113 buff[0] = cast(char, va_arg(argp, int));
@@ -114,17 +115,26 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
114 pushstr(L, buff); 115 pushstr(L, buff);
115 break; 116 break;
116 } 117 }
117 case 'd': 118 case 'd': {
118 setnvalue(L->top, cast(lua_Number, va_arg(argp, int))); 119 setnvalue(L->top, cast(lua_Number, va_arg(argp, int)));
119 incr_top(L); 120 incr_top(L);
120 break; 121 break;
121 case 'f': 122 }
123 case 'f': {
122 setnvalue(L->top, cast(lua_Number, va_arg(argp, l_uacNumber))); 124 setnvalue(L->top, cast(lua_Number, va_arg(argp, l_uacNumber)));
123 incr_top(L); 125 incr_top(L);
124 break; 126 break;
125 case '%': 127 }
128 case 'p': {
129 char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */
130 sprintf(buff, "%p", va_arg(argp, void *));
131 pushstr(L, buff);
132 break;
133 }
134 case '%': {
126 pushstr(L, "%"); 135 pushstr(L, "%");
127 break; 136 break;
137 }
128 default: { 138 default: {
129 char buff[3]; 139 char buff[3];
130 buff[0] = '%'; 140 buff[0] = '%';