picrypt.cpp no-sodium fix

picodeparser now recognize assignment in declaration
This commit is contained in:
2021-04-12 23:17:13 +03:00
parent 77477a1853
commit 7a2a9ee7d0
2 changed files with 23 additions and 6 deletions

View File

@@ -513,6 +513,14 @@ PICodeParser::Typedef PICodeParser::parseTypedef(PIString fc) {
}
void removeAssignment(PIString & s) {
if (s.size() <= 2) return;
int ei = s.find('=');
if (ei < 0) return;
s.remove(ei, s.size_s() - ei);
s.trim();
}
bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
static const PIString s_operator = PIStringAscii("operator");
static const PIString s_ss = PIStringAscii(" ");
@@ -611,12 +619,15 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
parent->functions << me;
} else {
if (fc.endsWith(';')) fc.cutRight(1);
//piCout << "member" << fc;
if (fc.startsWith(s_using) || !(fc.contains(' ') || fc.contains('\t') || fc.contains('\n'))) return true;
int bits = extractMemberBits(fc);
tl = fc.split(',');
//piCout << "member" << fc << tl;
//piCout << "member after eb" << fc << ", bits =" << bits;
if (tl.isEmpty()) return true;
piForeach (PIString & v, tl)
removeAssignment(v);
bool vn = true;
ctemp = tl.front().trim();
PIString meta_t;
@@ -654,6 +665,7 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
type.trim();
normalizeEntityNamespace(type);
tl[0] = ctemp.trim();
//piCout << "vars" << tl;
piForeachC (PIString & v, tl) {
crepl.clear();
@@ -678,7 +690,7 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
me.dims << cdim;
}
//PICout(PICoutManipulators::AddAll) << "var" << me.type << me.name << me.bits;
//piCout << "var" << v;
//piCout << "var" << v << me.type << me.name << me.bits;
parent->members << me;
}
}