Skip to content

Commit

Permalink
Nift (aka nsm) v3.0.2 - see release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
n-ham committed Jul 8, 2023
1 parent 1db2726 commit 9497b4f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cstdio>
#include <iostream>

const std::string NSM_VERSION = "3.0.1";
const std::string NSM_VERSION = "3.0.2";

const int HASH_RS = -2011;
const int HASH_JS = -2012;
Expand Down
76 changes: 54 additions & 22 deletions Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3257,31 +3257,38 @@ int Parser::read_and_process_fn(const bool& indent,
{
if(!get_bool(result, conditions[b]))
{
if(conditions[b] != "" && expr.compile(conditions[b]))
result = expr.evaluate();
else
{
parsedCondition = conditions[b];
VPos vpos;
if(vars.find(conditions[b], vpos)) {
vars.get_bool_from_var(vpos, result);
}
else {
if(conditions[b] != "" && expr.compile(conditions[b])) {
result = expr.evaluate();
}
else
{
parsedCondition = conditions[b];

if(parse_replace('f', parsedCondition, "if/else-if condition", readPath, antiDepsOfReadPath, conditionLineNo, "if(" + params[0] + ")", sLineNo, eos))
return 1;
if(parse_replace('f', parsedCondition, "if/else-if condition", readPath, antiDepsOfReadPath, conditionLineNo, "if(" + params[0] + ")", sLineNo, eos))
return 1;

if(replace_var(parsedCondition, readPath, conditionLineNo, "if/else-if", eos))
return 1;
if(replace_var(parsedCondition, readPath, conditionLineNo, "if/else-if", eos))
return 1;

if(!get_bool(result, parsedCondition))
{
if(parsedCondition != "" && expr.compile(parsedCondition))
result = expr.evaluate();
else
if(!get_bool(result, parsedCondition))
{
if(!consoleLocked)
os_mtx->lock();
start_err(eos, readPath, conditionLineNo) << "if/else-if: cannot convert " << quote(parsedCondition) << " to bool" << std::endl;
start_err(eos, readPath, conditionLineNo) << "if/else-if: possible errors from ExprTk:" << std::endl;
print_exprtk_parser_errs(eos, expr.parser, expr.expr_str, readPath, sLineNo);
os_mtx->unlock();
return 1;
if(parsedCondition != "" && expr.compile(parsedCondition))
result = expr.evaluate();
else
{
if(!consoleLocked)
os_mtx->lock();
start_err(eos, readPath, conditionLineNo) << "if/else-if: cannot convert " << quote(parsedCondition) << " to bool" << std::endl;
start_err(eos, readPath, conditionLineNo) << "if/else-if: possible errors from ExprTk:" << std::endl;
print_exprtk_parser_errs(eos, expr.parser, expr.expr_str, readPath, sLineNo);
os_mtx->unlock();
return 1;
}
}
}
}
Expand Down Expand Up @@ -7711,7 +7718,7 @@ int Parser::read_and_process_fn(const bool& indent,
}
else if(funcName[0] == ':')
{
if(funcName == ":=" && params.size())
if(funcName == ":=" && paramsStr != "")
{
std::string varType;
std::vector<std::pair<std::string, std::vector<std::string> > > inputVars;
Expand Down Expand Up @@ -7847,6 +7854,20 @@ int Parser::read_and_process_fn(const bool& indent,
os_mtx->unlock();
return 1;
}
else if(inputVars[v].second[0] == "1" || inputVars[v].second[0] == "true")
{
vars.layers[layer].doubles[inputVars[v].first] = 1;

if(addToExpr)
symbol_table.add_variable(inputVars[v].first, vars.layers[layer].doubles[inputVars[v].first]);
}
else if(inputVars[v].second[0] == "0" || inputVars[v].second[0] == "false")
{
vars.layers[layer].doubles[inputVars[v].first] = 0;

if(addToExpr)
symbol_table.add_variable(inputVars[v].first, vars.layers[layer].doubles[inputVars[v].first]);
}
else if(isInt(inputVars[v].second[0]))
{
vars.layers[layer].doubles[inputVars[v].first] = (bool)std::atoi(inputVars[v].second[0].c_str());
Expand Down Expand Up @@ -8002,6 +8023,10 @@ int Parser::read_and_process_fn(const bool& indent,
os_mtx->unlock();
return 1;
}
else if(inputVars[v].second[0] == "1" || inputVars[v].second[0] == "true")
vars.layers[layer].bools[inputVars[v].first] = 1;
else if(inputVars[v].second[0] == "0" || inputVars[v].second[0] == "false")
vars.layers[layer].bools[inputVars[v].first] = 1;
else if(isInt(inputVars[v].second[0]))
vars.layers[layer].bools[inputVars[v].first] = (bool)std::atoi(inputVars[v].second[0].c_str());
else if(isDouble(inputVars[v].second[0]))
Expand Down Expand Up @@ -14818,6 +14843,13 @@ int Parser::get_bool(bool& bVal, const std::string& str)
return 1;
}

/*VPos vpos;
if(vars.find(str, vpos)) {
vars.get_bool_from_var(vpos, bVal);

return 1;
}*/

return 0;
}

Expand Down
4 changes: 4 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Nift Release Notes
------------------

Version 3.0.2 of Nift
* fixed bug with variable definitions
* fixed bug with variable if conditions (trying to compile exprtk expression segmentation faults)

Version 3.0.1 of Nift
* fixed bug copying/moving pages with non-default content and/or output extension(s)
* fixed bug with copying whitespace when parsing functionstein, especially for string definitions
Expand Down

0 comments on commit 9497b4f

Please sign in to comment.