Commit 58c5282b authored by Victor Yacovlev's avatar Victor Yacovlev

Implemented lvalue string slices according to AGK/MR

parent ebcbb264
......@@ -1627,21 +1627,21 @@ public:
# if defined(WIN32) || defined(_WIN32)
const wchar_t * fmode;
if (mode==FileType::Read)
fmode = L"r";
fmode = L"rb";
else if (mode==FileType::Write)
fmode = L"w";
fmode = L"wb";
else if (mode==FileType::Append)
fmode = L"a";
fmode = L"ab";
FILE * res = 0;
_wfopen_s(&res, fileName.c_str(), fmode);
# else
const char * fmode;
if (mode==FileType::Read)
fmode = "r";
fmode = "rb";
else if (mode==FileType::Write)
fmode = "w";
fmode = "wb";
else if (mode==FileType::Append)
fmode = "a";
fmode = "ab";
FILE* res = fopen(path, fmode);
# endif
FileType f;
......
......@@ -1776,7 +1776,20 @@ void KumirVM::do_specialcall(uint16_t alg)
String ch = first.value().toString();
s_error = Kumir::Core::getError();
if (s_error.length()==0) {
if (start==source.length()+1 && end<=start) {
if (end<start && start==0) {
source = ch + source;
Variable r(source);
stack_values.push(r);
}
else if (start>source.length()) {
s_error = Kumir::Core::fromUtf8("Левая граница вырезки за пределами строки");
}
else if (end<start && start>0) {
source.insert(start, ch);
Variable r(source);
stack_values.push(r);
}
else if (start==source.length()+1 && end<=start) {
source.append(ch);
Variable r(source);
stack_values.push(r);
......@@ -1788,9 +1801,7 @@ void KumirVM::do_specialcall(uint16_t alg)
s_error = Kumir::Core::fromUtf8("Левая граница вырезки за пределами строки");
}
else if (end<start) {
source.insert(start-1, ch);
Variable r(source);
stack_values.push(r);
s_error = Kumir::Core::fromUtf8("Ошибка в границах вырезки");
}
else {
source = source.substr(0,start-1)+ch+source.substr(end);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment