lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Lua 5.0 's code

typedef struct luaL_Buffer {
  char *p;                      /* current position in buffer */
  int lvl;  /* number of strings in the stack (level) */
  lua_State *L;
  char buffer[LUAL_BUFFERSIZE];
} luaL_Buffer;

#define luaL_putchar(B,c) \
  ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
   (*(B)->p++ = (char)(c)))


Lua 5.2 's code

typedef struct luaL_Buffer {
  char *b;  /* buffer address */
  size_t size;  /* buffer size */
  size_t n;  /* number of characters in buffer */
  lua_State *L;
  char initb[LUAL_BUFFERSIZE];  /* initial buffer */
} luaL_Buffer;

can not find luaL_putchar

I define it myself

#define luaL_putchar(B,c) \
  ((void)((B)->b < ((B)->initb+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
   (*(B)->b++ = (char)(c)))

Can I do that?