Merge branch 'master' of https://git.shs.tools/SHS/pip into thread

This commit is contained in:
Бычков Андрей
2022-11-08 10:53:30 +03:00
3 changed files with 49 additions and 28 deletions

View File

@@ -311,6 +311,7 @@ bool PICodeParser::parseFileContent(PIString & fc, bool main) {
//piCout << PICoutManipulators::NewLine << "file" << cur_file << pfc;
int pl = -1;
cur_def_vis = Global;
while (!pfc.isEmpty()) {
pfc.trim();
int nl = pfc.size_s();
@@ -407,6 +408,7 @@ PICodeParser::Entity * PICodeParser::parseClassDeclaration(const PIString & fc)
}
PIString typename_ = cd.left(6).trim();
bool is_class = typename_ == s_class;
Visibility vis = cur_def_vis;
cur_def_vis = (is_class ? Private : Public);
PIString cn = cd.mid(6).trim();
bool has_name = !cn.isEmpty();
@@ -419,6 +421,7 @@ PICodeParser::Entity * PICodeParser::parseClassDeclaration(const PIString & fc)
e->type = typename_;
e->has_name = has_name;
e->parents = parents;
e->visibility = vis;
e->file = cur_file;
entities << e;
return e;

View File

@@ -341,14 +341,31 @@ PIString PIString::fromSystem(const char * s) {
PIString PIString::fromUTF8(const char * s) {
PIString ret;
if (!s) return ret;
if (s[0] != '\0') ret.appendFromChars(s, -1, __utf8name__);
if (s[0] != '\0') {
if ((uchar)s[0] == 0xEF && (uchar)s[1] == 0xBB && (uchar)s[2] == 0xBF) {
s += 3;
if (s[0] == '\0') return ret;
}
ret.appendFromChars(s, -1, __utf8name__);
}
return ret;
}
PIString PIString::fromUTF8(const PIByteArray & ba) {
PIString ret;
if (ba.isNotEmpty()) ret.appendFromChars((const char*)ba.data(), ba.size(), __utf8name__);
if (ba.isNotEmpty()) {
const char * data = (const char*)ba.data();
int size = ba.size();
if (ba.size() >= 3) {
if (ba[0] == 0xEF && ba[1] == 0xBB && ba[2] == 0xBF) {
data += 3;
size -= 3;
if (size == 0) return ret;
}
}
ret.appendFromChars(data, size, __utf8name__);
}
return ret;
}