Ejemplo n.º 1
0
/** Push formatted string on top of stack.
 * @param format string format
 * @see man 3 sprintf
 */
void
LuaContext::push_fstring(const char *format, ...)
{
  MutexLocker lock(__lua_mutex);
  va_list arg;
  va_start(arg, format);
  lua_pushvfstring(__L, format, arg);
  va_end(arg);
}
Ejemplo n.º 2
0
LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
  va_list argp;
  va_start(argp, fmt);
  luaL_where(L, 1);
  lua_pushvfstring(L, fmt, argp);
  va_end(argp);
  lua_concat(L, 2);
  return lua_error(L);
}
Ejemplo n.º 3
0
int luaL_error (LuaThread *L, const char *fmt, ...) {
  THREAD_CHECK(L);
  va_list argp;
  va_start(argp, fmt);
  luaL_where(L, 1);
  lua_pushvfstring(L, fmt, argp);
  va_end(argp);
  lua_concat(L, 2);
  return lua_error(L);
}
Ejemplo n.º 4
0
/*****************************************************************************
  Internal api error function.
  Invoking this will cause Lua to stop executing the current context and
  throw an exception, so to speak.
*****************************************************************************/
int luascript_error_vargs(lua_State *L, const char *format, va_list vargs)
{
  fc_assert_ret_val(L != NULL, -1);

  luaL_where(L, 1);
  lua_pushvfstring(L, format, vargs);
  lua_concat(L, 2);

  return lua_error(L);
}
Ejemplo n.º 5
0
int luax_ioError(lua_State *L, const char *fmt, ...)
{
	va_list args;
	va_start(args, fmt);

	lua_pushnil(L);
	lua_pushvfstring(L, fmt, args);

	va_end(args);
	return 2;
}
Ejemplo n.º 6
0
int
zcp_argerror(lua_State *state, int narg, const char *msg, ...)
{
	va_list alist;

	va_start(alist, msg);
	const char *buf = lua_pushvfstring(state, msg, alist);
	va_end(alist);

	return (luaL_argerror(state, narg, buf));
}
Ejemplo n.º 7
0
/* {{{ ratchet_error_str_ln() */
int ratchet_error_str_ln (lua_State *L, const char *function, const char *code, const char *file, int line, const char *description, ...)
{
	lua_settop (L, 0);

	va_list args;
	va_start (args, description);
	lua_pushvfstring (L, description, args);
	va_end (args);

	return ratchet_error_top_ln (L, function, code, file, line);
}
Ejemplo n.º 8
0
/*---------------------------------------------------------------------------*/
int8_t LuaUtils_Error(lua_State *L, const char *format, ...)
{
  va_list args;
  va_start(args,  format);
  lua_pushnil(L);
  lua_pushvfstring(L, format, args);
  if (stopOnError)
    luaL_error(L, "[sys.stopOnError == true] %s", luaL_checkstring(L, -1));
  va_end(args);
  return 2;
}
Ejemplo n.º 9
0
/**************************************************************************
  Internal api error function.
  Invoking this will cause Lua to stop executing the current context and
  throw an exception, so to speak.
**************************************************************************/
int script_error(const char *fmt, ...)
{
  va_list argp;

  va_start(argp, fmt);
  luaL_where(state, 1);
  lua_pushvfstring(state, fmt, argp);
  va_end(argp);
  lua_concat(state, 2);

  return lua_error(state);
}
Ejemplo n.º 10
0
/*
| Lets the core print logmessages comfortably as formated string.
| This uses the lua_State for it easy string buffers only.
*/
extern void
printlogf0(lua_State *L,
	int priority,
	const char *cat,
	const char *fmt, ...)
{
	va_list ap;
	va_start(ap, fmt);
	lua_pushvfstring(L, fmt, ap);
	va_end(ap);
	logstring0(priority, cat, luaL_checkstring(L, -1));
	lua_pop(L, 1);
	return;
}
Ejemplo n.º 11
0
/* ------------------------------------------------------------------------
 * error helper
 */
int lixp_pusherrorf(lua_State *L, const char *fmt, ...)
{
	va_list ap;

	lua_pushnil(L);
	if (errno) {
		char *_fmt;
		const char *estr;
		size_t elen;

		estr = strerror(errno);
		elen = strlen(estr);

		_fmt = malloc(strlen(fmt) + 2 + (elen*2) + 1);
		if (!_fmt)
			goto do_short_fmt;

		copy_escaping_fmt(_fmt, estr);
		strcat(_fmt, "; ");
		strcat(_fmt, fmt);

		va_start(ap, fmt);
		lua_pushvfstring(L, _fmt, ap);
		va_end(ap);

		free(_fmt);

		lua_pushnumber(L, errno);
		return 3;
	}

do_short_fmt:
	va_start(ap, fmt);
	lua_pushvfstring(L, "%s", ap);
	va_end(ap);
	return 2;
}
Ejemplo n.º 12
0
static void
lua_tcp_push_error (struct lua_tcp_cbdata *cbd, const char *err, ...)
{
	va_list ap;

	va_start (ap, err);
	lua_rawgeti (cbd->L, LUA_REGISTRYINDEX, cbd->cbref);
	lua_pushvfstring (cbd->L, err, ap);
	va_end (ap);

	if (lua_pcall (cbd->L, 1, 0, 0) != 0) {
		msg_info ("callback call failed: %s", lua_tostring (cbd->L, -1));
		lua_pop (cbd->L, 1);
	}
}
Ejemplo n.º 13
0
/** Push formatted string on top of stack.
 * @param format string format
 * @param arg variadic argument list
 * @see man 3 sprintf
 */
void
LuaContext::push_vfstring(const char *format, va_list arg)
{
  MutexLocker lock(__lua_mutex);
  lua_pushvfstring(__L, format, arg);
}