Skip to content

Commit

Permalink
1. 0002912: В диалогах DM_SETTEXT, DM_GETTEXT не позволяют работать с…
Browse files Browse the repository at this point in the history
…о строками содержащими '\0'.
  • Loading branch information
zg0 committed Jan 20, 2015
1 parent 128ebdf commit 726f855
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 17 deletions.
6 changes: 5 additions & 1 deletion far/changelog
@@ -1,4 +1,8 @@
svs 19.01.2015 23:46:37 +0300 - build 4247
zg 20.01.2015 03:18:09 +0200 - build 4248

1. 0002912: В диалогах DM_SETTEXT, DM_GETTEXT не позволяют работать со строками содержащими '\0'.

svs 19.01.2015 23:46:37 +0300 - build 4247

1. SQLite 3.8.8

Expand Down
20 changes: 12 additions & 8 deletions far/dialog.cpp
Expand Up @@ -5655,7 +5655,7 @@ intptr_t Dialog::SendMessage(intptr_t Msg,intptr_t Param1,void* Param2)
auto InitItemData=[did,&Ptr,&Len]
{
if (!did->PtrLength)
did->PtrLength=Len;
did->PtrLength=Len; //BUGBUG: PtrLength ðàçìåð ïåðåäàííîãî íàì áóôåðà, çà÷åì ìû åãî ìåíÿåì?
else if (Len > did->PtrLength)
Len=did->PtrLength;

Expand All @@ -5677,11 +5677,16 @@ intptr_t Dialog::SendMessage(intptr_t Msg,intptr_t Param1,void* Param2)
case DI_EDIT:
case DI_PSWEDIT:
case DI_FIXEDIT:

if (!CurItem->ObjPtr)
break;

Ptr = static_cast<DlgEdit*>(CurItem->ObjPtr)->GetStringAddr();
{
auto edit=static_cast<DlgEdit*>(CurItem->ObjPtr);
if (edit)
{
Ptr = edit->GetStringAddr();
Len = edit->GetLength();
InitItemData();
}
break;
}
case DI_TEXT:
case DI_VTEXT:
case DI_SINGLEBOX:
Expand Down Expand Up @@ -5722,7 +5727,6 @@ intptr_t Dialog::SendMessage(intptr_t Msg,intptr_t Param1,void* Param2)
break;
}
default: // ïîäðàçóìåâàåì, ÷òî îñòàëèñü
did->PtrLength=0;
break;
}

Expand Down Expand Up @@ -5812,7 +5816,7 @@ intptr_t Dialog::SendMessage(intptr_t Msg,intptr_t Param1,void* Param2)
case DI_PSWEDIT:
case DI_FIXEDIT:
case DI_LISTBOX: // ìåíÿåò òîëüêî òåêóùèé ýëåìåíò
CurItem->strData = did->PtrData;
CurItem->strData = string(did->PtrData, did->PtrLength);
Len = CurItem->strData.size();
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion far/dlgedit.cpp
Expand Up @@ -332,7 +332,7 @@ void DlgEdit::SetString(const string& Str, bool disable_autocomplete, int pos)
if (disable_autocomplete && (acompl = lineEdit->GetAutocomplete()))
lineEdit->SetAutocomplete(false);

lineEdit->SetString(Str.data());
lineEdit->SetString(Str.data(),Str.size());
if (pos >= 0)
lineEdit->SetCurPos(pos);

Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,4247)m4_dnl
m4_define(BUILD,4248)m4_dnl
2 changes: 1 addition & 1 deletion plugins/luamacro/_globalinfo.lua
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
Version = { 1, 0, 0, 474 },
Version = { 1, 0, 0, 475 },
MinFarVersion = { 3, 0, 0, 4244 },
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 17.01.2015 23:05:52 +0200 - build 474
zg 20.01.2015 03:10:50 +0200 - build 475

1. 0002912: В диалогах DM_SETTEXT, DM_GETTEXT не позволяют работать со строками содержащими '\0'.

shmuel 17.01.2015 23:05:52 +0200 - build 474

1. Рефакторинг.

Expand Down
8 changes: 5 additions & 3 deletions plugins/luamacro/luafar/service.c
Expand Up @@ -3076,10 +3076,12 @@ static int far_SendDlgMessage(lua_State *L)
case DM_GETDIALOGTITLE:
{
struct FarDialogItemData fdid;
size_t size;
fdid.StructSize = sizeof(fdid);
fdid.PtrLength = (size_t) Info->SendDlgMessage(hDlg, Msg, Param1, NULL);
fdid.PtrData = (wchar_t*) malloc((fdid.PtrLength+1) * sizeof(wchar_t));
push_utf8_string(L, Info->SendDlgMessage(hDlg, Msg, Param1, &fdid)?fdid.PtrData:L"", -1);
size = Info->SendDlgMessage(hDlg, Msg, Param1, &fdid);
push_utf8_string(L, size?fdid.PtrData:L"", size);
free(fdid.PtrData);
return 1;
}
Expand All @@ -3093,8 +3095,8 @@ static int far_SendDlgMessage(lua_State *L)
{
struct FarDialogItemData fdid;
fdid.StructSize = sizeof(fdid);
fdid.PtrData = (wchar_t*)check_utf8_string(L, 4, NULL);
fdid.PtrLength = 0; // wcslen(fdid.PtrData);
fdid.PtrLength = 0;
fdid.PtrData = (wchar_t*)check_utf8_string(L, 4, &fdid.PtrLength);
lua_pushinteger(L, Info->SendDlgMessage(hDlg, Msg, Param1, &fdid));
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/luamacro.rc
@@ -1,6 +1,6 @@
#include <farversion.hpp>

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

0 comments on commit 726f855

Please sign in to comment.