Skip to content

Commit

Permalink
LuaFAR: улучшено сообщение об ошибке при передаче аргумента - несущес…
Browse files Browse the repository at this point in the history
…твующего флага типа string. Сообщение теперь включает в себя переданный флаг.
  • Loading branch information
shmuz committed Sep 29, 2016
1 parent 587c25c commit 5184c22
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion plugins/luamacro/_globalinfo.lua
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
Version = { 1, 0, 0, 585 },
Version = { 1, 0, 0, 586 },
MinFarVersion = { 3, 0, 0, 4582 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
Expand Down
7 changes: 6 additions & 1 deletion plugins/luamacro/changelog
@@ -1,4 +1,9 @@
shmuel 25.09.2016 21:29:41 +0200 - build 585
shmuel 29.09.2016 18:57:45 +0200 - build 586

1. LuaFAR: улучшено сообщение об ошибке при передаче аргумента - несуществующего флага типа string.
Сообщение теперь включает в себя переданный флаг.

shmuel 25.09.2016 21:29:41 +0200 - build 585

1. Продолжение 584: заменяем в traceback табы тремя пробелами - для лучшего восприятия.

Expand Down
31 changes: 18 additions & 13 deletions plugins/luamacro/luafar/service.c
Expand Up @@ -249,8 +249,16 @@ static UINT64 check_env_flag(lua_State *L, int pos)
int success = FALSE;
UINT64 ret = get_env_flag(L, pos, &success);

if(!success)
luaL_argerror(L, pos, "invalid flag");
if (!success)
{
if (lua_isstring(L, pos))
{
lua_pushfstring(L, "invalid flag: \"%s\"", lua_tostring(L, pos));
luaL_argerror(L, pos, lua_tostring(L, -1));
}
else
luaL_argerror(L, pos, "invalid flag");
}

return ret;
}
Expand Down Expand Up @@ -1172,7 +1180,7 @@ static int FillEditorSelect(lua_State *L, int pos_table, struct EditorSelect *es

static int editor_Select(lua_State *L)
{
int success = 0;
int success = TRUE;
intptr_t EditorId = luaL_optinteger(L, 1, CURRENT_EDITOR);
PSInfo *Info = GetPluginData(L)->Info;
struct EditorSelect es;
Expand All @@ -1182,14 +1190,11 @@ static int editor_Select(lua_State *L)
success = FillEditorSelect(L, 2, &es);
else
{
es.BlockType = CAST(int, get_env_flag(L, 2, &success));
if(success)
{
es.BlockStartLine = luaL_optinteger(L, 3, 0) - 1;
es.BlockStartPos = luaL_optinteger(L, 4, 0) - 1;
es.BlockWidth = luaL_optinteger(L, 5, -1);
es.BlockHeight = luaL_optinteger(L, 6, -1);
}
es.BlockType = CAST(int, check_env_flag(L, 2));
es.BlockStartLine = luaL_optinteger(L, 3, 0) - 1;
es.BlockStartPos = luaL_optinteger(L, 4, 0) - 1;
es.BlockWidth = luaL_optinteger(L, 5, -1);
es.BlockHeight = luaL_optinteger(L, 6, -1);
}

lua_pushboolean(L, success && Info->EditorControl(EditorId, ECTL_SELECT, 0, &es));
Expand Down Expand Up @@ -2976,7 +2981,7 @@ static int far_SendDlgMessage(lua_State *L)
Param2 = (void*)opt_utf8_string(L, 4, NULL);
break;
case DM_SETCHECK:
Param2 = (void*)(intptr_t)get_env_flag(L, 4, NULL);
Param2 = (void*)(intptr_t)check_env_flag(L, 4);
break;
case DM_GETCURSORPOS:

Expand Down Expand Up @@ -4170,7 +4175,7 @@ static int far_GetReparsePointInfo(lua_State *L)
const wchar_t* Src = check_utf8_string(L, 1, NULL);
size_t size = FSF->GetReparsePointInfo(Src, NULL, 0);

if(size <= 0)
if(size == 0)
return lua_pushnil(L), 1;

Dest = (wchar_t*)lua_newuserdata(L, size * sizeof(wchar_t));
Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/luamacro.rc
@@ -1,6 +1,6 @@
#include <farversion.hpp>

#define PLUGIN_BUILD 585
#define PLUGIN_BUILD 586
#define PLUGIN_DESC "Lua Macros for Far Manager"
#define PLUGIN_NAME "LuaMacro"
#define PLUGIN_FILENAME "luamacro.dll"
Expand Down

0 comments on commit 5184c22

Please sign in to comment.