Skip to content

Commit

Permalink
LuaFAR: ещё раз дополнительная оптимизация unicode.utf8.sub.
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuz committed Apr 12, 2017
1 parent 588a270 commit 458f21d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion plugins/luamacro/_globalinfo.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
Version = { 1, 0, 0, 603 },
Version = { 1, 0, 0, 604 },
MinFarVersion = { 3, 0, 0, 4829 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
Expand Down
6 changes: 5 additions & 1 deletion plugins/luamacro/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
shmuel 10.04.2017 11:12:30 +0200 - build 603
shmuel 12.04.2017 22:47:30 +0200 - build 604

1. LuaFAR: ещё раз дополнительная оптимизация unicode.utf8.sub.

shmuel 10.04.2017 11:12:30 +0200 - build 603

1. LuaFAR: дополнительная оптимизация unicode.utf8.sub.

Expand Down
19 changes: 13 additions & 6 deletions plugins/luamacro/luafar/slnunico.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,21 +425,28 @@ static int unic_sub(lua_State *L)

if(IS_MBYTE(mode))
{
ptrdiff_t max = (start>=0 && end>=0) ? end : -1; /* non-negative arguments */
if (start>=0 && end>=0)
{
if (start == 0) start = 1;
if (start > end) { lua_pushliteral(L, ""); return 1; }
utf8_count(&s, e-s, IS_GRAPH(mode), --start);
p = s;
utf8_count(&p, e-p, IS_GRAPH(mode), end-start);
lua_pushlstring(L, s, p-s);
return 1;
}
p = s;
len = utf8_count(&p, len, IS_GRAPH(mode), (size_t)max);
len = utf8_count(&p, len, IS_GRAPH(mode), (size_t)(-1));
if (end != -1 && end < (ptrdiff_t)len)
p = 0; /* invalidate p */
}

start = posrelat(start, len);
end = posrelat(end, len);

if(start < 1)
start = 1;
if(start < 1) start = 1;

if(end > (ptrdiff_t)len)
end = (ptrdiff_t)len;
if(end > (ptrdiff_t)len) end = (ptrdiff_t)len;

if(start > end)
lua_pushliteral(L, "");
Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/luamacro.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <farversion.hpp>

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

0 comments on commit 458f21d

Please sign in to comment.