Example #1
0
LUALIB_API lua_Unsigned luaL_checkunsigned (lua_State *L, int narg) {
  int isnum;
  lua_Unsigned d = lua_tounsignedx(L, narg, &isnum);
  if (!isnum)
    tag_error(L, narg, LUA_TNUMBER);
  return d;
}
Example #2
0
LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
  int isnum;
  lua_Number d = lua_tonumberx(L, narg, &isnum);
  if (!isnum)
	tag_error(L, narg, LUA_TNUMBER);
  return d;
}
Example #3
0
LUALIB_API lua_Number luaL_checknumber_noassert (lua_State *L, int narg) {
  lua_Number d = lua_tonumber(L, narg);
  if (d == 0 && !lua_isnumber(L, narg))  /* avoid extra test when d is not 0 */
    tag_error(L, narg, LUA_TNUMBER);

  return d;
}
Example #4
0
uint32_t luaL_checkunsigned (LuaThread *L, int narg) {
  THREAD_CHECK(L);
  int isnum;
  uint32_t d = lua_tounsignedx(L, narg, &isnum);
  if (!isnum)
    tag_error(L, narg, LUA_TNUMBER);
  return d;
}
Example #5
0
ptrdiff_t luaL_checkinteger (LuaThread *L, int narg) {
  THREAD_CHECK(L);
  int isnum;
  ptrdiff_t d = lua_tointegerx(L, narg, &isnum);
  if (!isnum)
    tag_error(L, narg, LUA_TNUMBER);
  return d;
}
Example #6
0
double luaL_checknumber (LuaThread *L, int narg) {
  THREAD_CHECK(L);
  LuaValue v1 = L->stack_.at(narg);
  LuaValue v2 = v1.convertToNumber();
  if(v2.isNone()) {
    tag_error(L, narg, LUA_TNUMBER);
  }
  return v2.getNumber();
}
Example #7
0
const char* luaX_checklstring (lua_State *L, int narg, const char *argname, size_t *len) {
	const char *s = lua_tolstring(L, narg, len);

	if (s == NULL) {
		tag_error(L, narg, argname, LUA_TSTRING);
	}

	return s;
}
Example #8
0
LUALIB_API void luaL_checktype (lua_State *L, int narg, int t)
{
    int actualType = lua_type( L, narg );

    if ( actualType != t )
    {
        tag_error(L, narg, t);
    }
}
Example #9
0
lua_Integer luaX_checkinteger (lua_State *L, int narg, const char *argname) {
	int isnum = false;
	lua_Integer d = lua_tointegerx(L, narg, &isnum);

	if (!isnum) {
		tag_error(L, narg, argname, LUA_TNUMBER);
	}

	return d;
}
Example #10
0
LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg)
{
    lua_Integer d = lua_tointeger(L, narg);

    if ( d == 0 && !lua_isnumber(L, narg) )  /* avoid extra test when d is not 0 */
    {
        tag_error(L, narg, LUA_TNUMBER);
    }

    return d;
}
Example #11
0
LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len)
{
    const char *s = lua_tolstring(L, narg, len);

    if ( !s )
    {
        tag_error(L, narg, LUA_TSTRING);
    }

    return s;
}
Example #12
0
LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
  lua_Number d = lua_tonumber(L, narg);
  if (d == 0 && !lua_isnumber(L, narg))  /* avoid extra test when d is not 0 */
    tag_error(L, narg, LUA_TNUMBER);

#if defined(DEBUG) || defined(DEBUG_LUANAN)
  // SPRING
  //   this is used by luaL_optnumber, luaL_optfloat (via luaL_optnumber),
  //   and luaL_checkfloat, so the asserts should cover 90% of all cases
  //   in which non-numbers can infect the engine -- lua_tofloat asserts
  //   take care of the rest
  if (math::isinf(d) || math::isnan(d)) luaL_argerror(L, narg, "number expected, got NAN (check your code for div0)");
  //assert(!math::isinf(d));
  //assert(!math::isnan(d));
#endif

  return d;
}
Example #13
0
const char *luaL_checklstring (LuaThread *L, int narg, size_t *len) {
  THREAD_CHECK(L);
  const char *s = lua_tolstring(L, narg, len);
  if (!s) tag_error(L, narg, LUA_TSTRING);
  return s;
}
Example #14
0
File: lauxlib.c Project: goolic/tup
static void interror (lua_State *L, int arg) {
  if (lua_isnumber(L, arg))
    luaL_argerror(L, arg, "number has no integer representation");
  else
    tag_error(L, arg, LUA_TNUMBER);
}
Example #15
0
LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
  lua_Integer v = lua_tointeger(L, narg);
  if (v == 0 && !lua_isinteger(L, narg))  /* avoid extra test when v is not 0 */
    tag_error(L, narg, LUA_TNUMBER);    /* use LUA_TNUMBER; that is the type for the user */
  return v;
}
Example #16
0
LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
  lua_Integer d = lua_tointeger(L, narg);
  if (d == 0 && !lua_isnumber(L, narg))  /* avoid extra test when d is not 0 */
    tag_error(L, narg, LUA_TNUMBER);
  return (d != 0) ? d : (int)0; //Little compatibility changes by LUAppArc 
}
Example #17
0
LUALIB_API lua_Integer luaL_checkboolean (lua_State *L, int narg) {
  if(!lua_isboolean(L, narg))
    tag_error(L, narg, LUA_TBOOLEAN);
  return lua_toboolean(L, narg);
}
LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) {
  const char *s = lua_tostring(L, narg);
  if (!s) tag_error(L, narg, LUA_TSTRING);
  if (len) *len = lua_strlen(L, narg);
  return s;
}
Example #19
0
LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) {
  if (lua_type(L, narg) != t)
	tag_error(L, narg, t);
}
Example #20
0
static int tag_parse(git_tag *tag, const char *buffer, const char *buffer_end)
{
    static const char *tag_types[] = {
        NULL, "commit\n", "tree\n", "blob\n", "tag\n"
    };

    unsigned int i;
    size_t text_len, alloc_len;
    char *search;

    if (git_oid__parse(&tag->target, &buffer, buffer_end, "object ") < 0)
        return tag_error("Object field invalid");

    if (buffer + 5 >= buffer_end)
        return tag_error("Object too short");

    if (memcmp(buffer, "type ", 5) != 0)
        return tag_error("Type field not found");
    buffer += 5;

    tag->type = GIT_OBJ_BAD;

    for (i = 1; i < ARRAY_SIZE(tag_types); ++i) {
        size_t type_length = strlen(tag_types[i]);

        if (buffer + type_length >= buffer_end)
            return tag_error("Object too short");

        if (memcmp(buffer, tag_types[i], type_length) == 0) {
            tag->type = i;
            buffer += type_length;
            break;
        }
    }

    if (tag->type == GIT_OBJ_BAD)
        return tag_error("Invalid object type");

    if (buffer + 4 >= buffer_end)
        return tag_error("Object too short");

    if (memcmp(buffer, "tag ", 4) != 0)
        return tag_error("Tag field not found");

    buffer += 4;

    search = memchr(buffer, '\n', buffer_end - buffer);
    if (search == NULL)
        return tag_error("Object too short");

    text_len = search - buffer;

    GITERR_CHECK_ALLOC_ADD(&alloc_len, text_len, 1);
    tag->tag_name = git__malloc(alloc_len);
    GITERR_CHECK_ALLOC(tag->tag_name);

    memcpy(tag->tag_name, buffer, text_len);
    tag->tag_name[text_len] = '\0';

    buffer = search + 1;

    tag->tagger = NULL;
    if (buffer < buffer_end && *buffer != '\n') {
        tag->tagger = git__malloc(sizeof(git_signature));
        GITERR_CHECK_ALLOC(tag->tagger);

        if (git_signature__parse(tag->tagger, &buffer, buffer_end, "tagger ", '\n') < 0)
            return -1;
    }

    tag->message = NULL;
    if (buffer < buffer_end) {
        if( *buffer != '\n' )
            return tag_error("No new line before message");

        text_len = buffer_end - ++buffer;

        GITERR_CHECK_ALLOC_ADD(&alloc_len, text_len, 1);
        tag->message = git__malloc(alloc_len);
        GITERR_CHECK_ALLOC(tag->message);

        memcpy(tag->message, buffer, text_len);
        tag->message[text_len] = '\0';
    }

    return 0;
}
Example #21
0
void luaX_checktype (lua_State *L, int narg, const char *argname, int t) {
	if (lua_type(L, narg) != t)
		tag_error(L, narg, argname, t);
}
Example #22
0
void luaL_checktype (LuaThread *L, int narg, int t) {
  THREAD_CHECK(L);
  if (lua_type(L, narg) != t)
    tag_error(L, narg, t);
}
Example #23
0
LUALIB_API lua_Integer luaL_checkboolean (lua_State *L, int narg) {
    lua_Integer d = lua_toboolean(L, narg);
    if (d == 0 && !lua_isboolean(L, narg))  /* avoid extra test when d is not 0 */
        tag_error(L, narg, LUA_TBOOLEAN);
    return d;
}