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 10, 2017
1 parent 033bf10 commit 8d2be85
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 111 deletions.
2 changes: 1 addition & 1 deletion plugins/luamacro/_globalinfo.lua
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
Version = { 1, 0, 0, 602 },
Version = { 1, 0, 0, 603 },
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
@@ -1,4 +1,8 @@
shmuel 08.04.2017 14:16:00 +0200 - build 602
shmuel 10.04.2017 11:12:30 +0200 - build 603

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

shmuel 08.04.2017 14:16:00 +0200 - build 602

1. LuaFAR: оптимизация unicode.utf8.sub для неотрицательных аргументов + рефакторинг.

Expand Down
20 changes: 14 additions & 6 deletions plugins/luamacro/luafar/slnunico.c
Expand Up @@ -425,16 +425,21 @@ static int unic_sub(lua_State *L)

if(IS_MBYTE(mode))
{
ptrdiff_t max = (start>=0 && end>=0) ? end : -1;
p=s; len = utf8_count(&p, len, IS_GRAPH(mode), (size_t)max);
ptrdiff_t max = (start>=0 && end>=0) ? end : -1; /* non-negative arguments */
p = s;
len = utf8_count(&p, len, IS_GRAPH(mode), (size_t)max);
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 All @@ -448,8 +453,11 @@ static int unic_sub(lua_State *L)
{
if(start) utf8_count(&s, e-s, IS_GRAPH(mode), start); /* skip */

p = s;
utf8_count(&p, e-p, IS_GRAPH(mode), len);
if (p == 0)
{
p = s;
utf8_count(&p, e-p, IS_GRAPH(mode), len);
}
len = p-s;
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/luamacro.rc
@@ -1,6 +1,6 @@
#include <farversion.hpp>

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

0 comments on commit 8d2be85

Please sign in to comment.