lua-users home
lua-l archive

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


>
> I think this change does not work with the regular setting:
>

You are right.

This is how I ended up solving it (note the LUA_NUMBER_INTEGER define):


        case 'd':  case 'i': {
          lua_Number n = luaL_checknumber(L, arg);
#ifndef LUA_NUMBER_INTEGER
          luaL_argcheck(L, (MIN_INTFRM - 1) < n && n < (MAX_INTFRM + 1), arg,
                        "not a number in proper range");
#endif
          addlenmod(form, LUA_INTFRMLEN);
          nb = sprintf(buff, form, (LUA_INTFRM_T)n);
          break;
        }
        case 'o':  case 'u':  case 'x':  case 'X': {
          lua_Number n = luaL_checknumber(L, arg);
#ifndef LUA_NUMBER_INTEGER
          luaL_argcheck(L, 0 <= n && n < (MAX_UINTFRM + 1), arg,
                        "not a non-negative number in proper range");
#endif
          addlenmod(form, LUA_INTFRMLEN);
          nb = sprintf(buff, form, (unsigned LUA_INTFRM_T)n);
          break;
        }