Exemplo n.º 1
0
Arquivo: lauxlib.c Projeto: lua/lua
/*
** Emit a warning. '*previoustocont' signals whether previous message
** was to be continued by the current one.
*/
static void warnf (void *ud, const char *message, int tocont) {
  int *previoustocont = (int *)ud;
  if (!*previoustocont)  /* previous message was the last? */
    lua_writestringerror("%s", "Lua warning: ");  /* start a new warning */
  lua_writestringerror("%s", message);  /* write message */
  if (!tocont)  /* is this the last part? */
    lua_writestringerror("%s", "\n");  /* finish message with end-of-line */
  *previoustocont = tocont;
}
Exemplo n.º 2
0
static int db_debug (lua_State *L) {
  for (;;) {
    char buffer[250];
    lua_writestringerror("%s", "lua_debug> ");
    if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
        strcmp(buffer, "cont\n") == 0)
      return 0;
    if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") ||
        lua_pcall(L, 0, 0, 0))
      lua_writestringerror("%s\n", lua_tostring(L, -1));
    lua_settop(L, 0);  /* remove eventual returns */
  }
}
Exemplo n.º 3
0
static int db_debug (lua_State *L) {
  /* Ravi change - disallow when debugging via VSCode */
  if (ravi_get_debugger_data(L) != NULL)
    return 0;
  for (;;) {
    char buffer[250];
    lua_writestringerror("%s", "lua_debug> ");
    if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
        strcmp(buffer, "cont\n") == 0)
      return 0;
    if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") ||
        lua_pcall(L, 0, 0, 0))
      lua_writestringerror("%s\n", lua_tostring(L, -1));
    lua_settop(L, 0);  /* remove eventual returns */
  }
}
Exemplo n.º 4
0
static void print_usage (const char *badoption) {
  lua_writestringerror("%s: ", progname);
  if (badoption[1] == 'e' || badoption[1] == 'l')
    lua_writestringerror("'%s' needs argument\n", badoption);
  else
    lua_writestringerror("unrecognized option '%s'\n", badoption);
  lua_writestringerror(
  "usage: %s [options] [script [args]]\n"
  "Available options are:\n"
  "  -e stat  execute string 'stat'\n"
  "  -i       enter interactive mode after executing 'script'\n"
  "  -l name  require library 'name'\n"
  "  -v       show version information\n"
  "  -E       ignore environment variables\n"
  "  --       stop handling options\n"
  "  -        stop handling options and execute stdin\n"
  ,
  progname);
}
Exemplo n.º 5
0
/*
 * Arguments: ..., error_message (string)
 */
static void
thread_error_abort (lua_State *L)
{
  const char *msg = (lua_type(L, -1) == LUA_TSTRING)
   ? lua_tostring(L, -1) : NULL;

  if (!msg) msg = "(error object is not a string)";
  lua_writestringerror("%s\n", msg);
  abort();
}
Exemplo n.º 6
0
Arquivo: lauxlib.c Projeto: goolic/tup
static int panic (lua_State *L) {
  lua_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n",
                        lua_tostring(L, -1));
  return 0;  /* return to Lua to abort */
}
Exemplo n.º 7
0
/*
** Prints an error message, adding the program name in front of it
** (if present)
*/
static void l_message (const char *pname, const char *msg) {
  if (pname) lua_writestringerror("%s: ", pname);
  lua_writestringerror("%s\n", msg);
}