Commit 45b3ca5b authored by Denis Khachko's avatar Denis Khachko

Merge branch 'master' of git.lpm.org.ru:niisi/kumir2

parents c4222243 3583afcd
import re
import subprocess
import os
import os.path
import sys
if 3 == sys.version_info.major:
from urllib.parse import unquote
def to_str(x):
return x.decode("utf-8")
else:
from urllib import unquote
def to_str(x):
return unicode(x)
def get_version_information(top_level_dir):
assert isinstance(top_level_dir, str) or isinstance(top_level_dir, unicode)
if os.path.exists(top_level_dir + os.path.sep + ".git"):
try:
version_info = to_str(subprocess.check_output(
"git describe --abbrev=0 --tags --exact-match",
shell=True,
stderr=subprocess.PIPE
)).strip()
except subprocess.CalledProcessError:
version_info = to_str(subprocess.check_output(
"git rev-parse --abbrev-ref HEAD",
shell=True
)).strip()
version_info += "-" + to_str(subprocess.check_output(
"git --no-pager log -1 --pretty=format:%H",
shell=True
)).strip()
else:
dir_name = os.path.basename(top_level_dir)
match = re.match(r"kumir2-(.+)", dir_name)
version_info = match.group(1)
return version_info
def main():
version_name = get_version_information(os.getcwd())
prefix = ""
suffix = ""
nl = ""
outfile = sys.stdout
for arg in sys.argv:
if arg.startswith("--prefix="):
prefix = unquote(arg[9:].replace('@', '%'))
elif arg.startswith("--suffix="):
suffix = unquote(arg[9:].replace('@', '%'))
elif arg.startswith("--out="):
outfile = open(arg[6:], 'w')
elif "--nl" == arg:
if os.name.startswith("nt"):
nl = "\r\n"
else:
nl = "\n"
output = prefix + version_name + suffix + nl
outfile.write(output)
outfile.close()
if __name__ == "__main__":
main()
......@@ -2089,7 +2089,7 @@ void SyntaxAnalizer::parseOutput(int str)
expr3->baseType.kind = AST::TypeInteger;
expr3->dimension = 0;
expr3->kind = AST::ExprConst;
expr3->constant = QVariant(0);
expr3->constant = QVariant(-1);
}
if (expr->baseType.kind==AST::TypeUser) {
bool canConvert = makeCustomUnaryOperation<bool>(lexer_->outputLexemName(), expr, st.mod);
......
......@@ -171,7 +171,7 @@ public /*methods*/:
inline virtual QVariantList algOptResults() const { return QVariantList(); }
/** Terminate long-running evaluation in case of program interrupt */
inline virtual void terminateEvaluation() = 0;
virtual void terminateEvaluation() = 0;
/*=== Actor GUI specification === */
......
......@@ -935,7 +935,7 @@ public:
static String sprintfReal(real value, Char dot, bool expform, int width, int decimals, char al) {
std::stringstream stream;
if (0 == decimals && !expform) {
if (0 > decimals && !expform) {
double absVal = fabs(double(value));
if (0.0 != value && (absVal < 0.0001 || absVal > 999999.))
expform = true;
......@@ -946,7 +946,7 @@ public:
}
else {
stream << std::fixed;
stream.precision(0==decimals ? 6 : decimals);
stream.precision(0>decimals ? 6 : decimals);
}
stream << value;
......@@ -967,7 +967,7 @@ public:
if (std::string::npos != dotPos) {
rpart.replace(dotPos, 1, ".");
}
if ((expform || 0==decimals) && std::string::npos != rpart.find('.')) {
if ((expform || 0>decimals) && std::string::npos != rpart.find('.')) {
while (rpart.size() > 1 && '0' == rpart.at(rpart.size()-1)) {
rpart.resize(rpart.length()-1);
}
......
......@@ -2403,7 +2403,7 @@ void KumirVM::do_store(uint8_t s, uint16_t id)
svalue = Kumir::Converter::sprintfInt(value.toInt(), 10, 0, 0);
}
else if (t==VT_real) {
svalue = Kumir::Converter::sprintfReal(value.toReal(), '.', false, 0 ,0, 0);
svalue = Kumir::Converter::sprintfReal(value.toReal(), '.', false, 0 ,-1, 0);
}
else if (t==VT_bool) {
static const String YES = Kumir::Core::fromUtf8("да");
......
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