msvc warning fixes
parent
e4c4c51055
commit
b9c74d86b5
122
src/cs_gen.cc
122
src/cs_gen.cc
|
@ -167,7 +167,7 @@ static inline std::pair<std::string_view, size_t> compileblock(
|
||||||
) {
|
) {
|
||||||
size_t start = gs.code.size();
|
size_t start = gs.code.size();
|
||||||
gs.code.push_back(BC_INST_BLOCK);
|
gs.code.push_back(BC_INST_BLOCK);
|
||||||
gs.code.push_back(BC_INST_OFFSET | ((start + 2) << 8));
|
gs.code.push_back(BC_INST_OFFSET | std::uint32_t((start + 2) << 8));
|
||||||
size_t retline = line;
|
size_t retline = line;
|
||||||
if (!p.empty()) {
|
if (!p.empty()) {
|
||||||
char const *op = gs.source, *oe = gs.send;
|
char const *op = gs.source, *oe = gs.send;
|
||||||
|
@ -432,13 +432,13 @@ invalid:
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool compileblockstr(codegen_state &gs, char const *str, char const *send) {
|
static bool compileblockstr(codegen_state &gs, char const *str, char const *send) {
|
||||||
int startc = gs.code.size();
|
std::size_t startc = gs.code.size();
|
||||||
gs.code.push_back(BC_INST_VAL | BC_RET_STRING);
|
gs.code.push_back(BC_INST_VAL | BC_RET_STRING);
|
||||||
gs.code.reserve(gs.code.size() + (send - str) / sizeof(uint32_t) + 1);
|
gs.code.reserve(gs.code.size() + (send - str) / sizeof(uint32_t) + 1);
|
||||||
auto alloc = std_allocator<char>{gs.ts.istate};
|
auto alloc = std_allocator<char>{gs.ts.istate};
|
||||||
auto asz = ((send - str) / sizeof(uint32_t) + 1) * sizeof(uint32_t);
|
auto asz = ((send - str) / sizeof(uint32_t) + 1) * sizeof(uint32_t);
|
||||||
char *buf = alloc.allocate(asz);
|
char *buf = alloc.allocate(asz);
|
||||||
int len = 0;
|
std::size_t len = 0;
|
||||||
while (str < send) {
|
while (str < send) {
|
||||||
std::string_view chrs{"\r/\"@]"};
|
std::string_view chrs{"\r/\"@]"};
|
||||||
char const *orig = str;
|
char const *orig = str;
|
||||||
|
@ -714,7 +714,7 @@ static bool compilearg(
|
||||||
compileunescapestr(gs);
|
compileunescapestr(gs);
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
size_t line = gs.current_line;
|
int line = int(gs.current_line);
|
||||||
auto s = gs.get_str_dup();
|
auto s = gs.get_str_dup();
|
||||||
s.push_back('\0');
|
s.push_back('\0');
|
||||||
gs.gen_value(wordtype, s.str_term(), line);
|
gs.gen_value(wordtype, s.str_term(), line);
|
||||||
|
@ -787,7 +787,7 @@ static bool compilearg(
|
||||||
return !w.empty();
|
return !w.empty();
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
size_t line = gs.current_line;
|
int line = int(gs.current_line);
|
||||||
auto s = gs.get_word();
|
auto s = gs.get_word();
|
||||||
if (s.empty()) {
|
if (s.empty()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -819,7 +819,11 @@ static void compile_cmd(
|
||||||
fakeargs++;
|
fakeargs++;
|
||||||
} else if ((it + 1) == fmt.end()) {
|
} else if ((it + 1) == fmt.end()) {
|
||||||
int numconc = 1;
|
int numconc = 1;
|
||||||
while ((more = compilearg(gs, VAL_STRING))) {
|
for (;;) {
|
||||||
|
more = compilearg(gs, VAL_STRING);
|
||||||
|
if (!more) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
numconc++;
|
numconc++;
|
||||||
}
|
}
|
||||||
if (numconc > 1) {
|
if (numconc > 1) {
|
||||||
|
@ -943,7 +947,11 @@ static void compile_cmd(
|
||||||
case 'C': /* concatenated string */
|
case 'C': /* concatenated string */
|
||||||
comtype = BC_INST_COM_C;
|
comtype = BC_INST_COM_C;
|
||||||
if (more) {
|
if (more) {
|
||||||
while ((more = compilearg(gs, VAL_ANY))) {
|
for (;;) {
|
||||||
|
more = compilearg(gs, VAL_ANY);
|
||||||
|
if (!more) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
numargs++;
|
numargs++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -951,7 +959,11 @@ static void compile_cmd(
|
||||||
case 'V': /* varargs */
|
case 'V': /* varargs */
|
||||||
comtype = BC_INST_COM_V;
|
comtype = BC_INST_COM_V;
|
||||||
if (more) {
|
if (more) {
|
||||||
while ((more = compilearg(gs, VAL_ANY))) {
|
for(;;) {
|
||||||
|
more = compilearg(gs, VAL_ANY);
|
||||||
|
if (!more) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
numargs++;
|
numargs++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -979,7 +991,11 @@ compilecomv:
|
||||||
|
|
||||||
static void compile_alias(codegen_state &gs, alias *id, bool &more) {
|
static void compile_alias(codegen_state &gs, alias *id, bool &more) {
|
||||||
std::uint32_t numargs = 0;
|
std::uint32_t numargs = 0;
|
||||||
while ((more = compilearg(gs, VAL_ANY))) {
|
for (;;) {
|
||||||
|
more = compilearg(gs, VAL_ANY);
|
||||||
|
if (!more) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
++numargs;
|
++numargs;
|
||||||
}
|
}
|
||||||
gs.code.push_back(
|
gs.code.push_back(
|
||||||
|
@ -991,7 +1007,11 @@ static void compile_alias(codegen_state &gs, alias *id, bool &more) {
|
||||||
static void compile_local(codegen_state &gs, bool &more) {
|
static void compile_local(codegen_state &gs, bool &more) {
|
||||||
std::uint32_t numargs = 0;
|
std::uint32_t numargs = 0;
|
||||||
if (more) {
|
if (more) {
|
||||||
while ((more = compilearg(gs, VAL_IDENT))) {
|
for (;;) {
|
||||||
|
more = compilearg(gs, VAL_IDENT);
|
||||||
|
if (!more) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
numargs++;
|
numargs++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1016,17 +1036,17 @@ static void compile_if(
|
||||||
if (!more) {
|
if (!more) {
|
||||||
gs.code.push_back(BC_INST_NULL | ret_code(rettype));
|
gs.code.push_back(BC_INST_NULL | ret_code(rettype));
|
||||||
} else {
|
} else {
|
||||||
int start1 = gs.code.size();
|
std::size_t start1 = gs.code.size();
|
||||||
more = compilearg(gs, VAL_CODE);
|
more = compilearg(gs, VAL_CODE);
|
||||||
if (!more) {
|
if (!more) {
|
||||||
gs.code.push_back(BC_INST_POP);
|
gs.code.push_back(BC_INST_POP);
|
||||||
gs.code.push_back(BC_INST_NULL | ret_code(rettype));
|
gs.code.push_back(BC_INST_NULL | ret_code(rettype));
|
||||||
} else {
|
} else {
|
||||||
int start2 = gs.code.size();
|
std::size_t start2 = gs.code.size();
|
||||||
more = compilearg(gs, VAL_CODE);
|
more = compilearg(gs, VAL_CODE);
|
||||||
uint32_t inst1 = gs.code[start1];
|
std::uint32_t inst1 = gs.code[start1];
|
||||||
uint32_t op1 = inst1 & ~BC_INST_RET_MASK;
|
std::uint32_t op1 = inst1 & ~BC_INST_RET_MASK;
|
||||||
uint32_t len1 = start2 - (start1 + 1);
|
auto len1 = std::uint32_t(start2 - (start1 + 1));
|
||||||
if (!more) {
|
if (!more) {
|
||||||
if (op1 == (BC_INST_BLOCK | (len1 << 8))) {
|
if (op1 == (BC_INST_BLOCK | (len1 << 8))) {
|
||||||
gs.code[start1] = (len1 << 8) | BC_INST_JUMP_B | BC_INST_FLAG_FALSE;
|
gs.code[start1] = (len1 << 8) | BC_INST_JUMP_B | BC_INST_FLAG_FALSE;
|
||||||
|
@ -1038,12 +1058,12 @@ static void compile_if(
|
||||||
}
|
}
|
||||||
compileblock(gs);
|
compileblock(gs);
|
||||||
} else {
|
} else {
|
||||||
uint32_t inst2 = gs.code[start2];
|
std::uint32_t inst2 = gs.code[start2];
|
||||||
uint32_t op2 = inst2 & ~BC_INST_RET_MASK;
|
std::uint32_t op2 = inst2 & ~BC_INST_RET_MASK;
|
||||||
uint32_t len2 = gs.code.size() - (start2 + 1);
|
auto len2 = std::uint32_t(gs.code.size() - (start2 + 1));
|
||||||
if (op2 == (BC_INST_BLOCK | (len2 << 8))) {
|
if (op2 == (BC_INST_BLOCK | (len2 << 8))) {
|
||||||
if (op1 == (BC_INST_BLOCK | (len1 << 8))) {
|
if (op1 == (BC_INST_BLOCK | (len1 << 8))) {
|
||||||
gs.code[start1] = ((start2 - start1) << 8)
|
gs.code[start1] = (std::uint32_t(start2 - start1) << 8)
|
||||||
| BC_INST_JUMP_B | BC_INST_FLAG_FALSE;
|
| BC_INST_JUMP_B | BC_INST_FLAG_FALSE;
|
||||||
gs.code[start1 + 1] = BC_INST_ENTER_RESULT;
|
gs.code[start1 + 1] = BC_INST_ENTER_RESULT;
|
||||||
gs.code[start1 + len1] = (
|
gs.code[start1 + len1] = (
|
||||||
|
@ -1085,8 +1105,12 @@ static void compile_and_or(
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
numargs++;
|
numargs++;
|
||||||
int start = gs.code.size(), end = start;
|
std::size_t start = gs.code.size(), end = start;
|
||||||
while ((more = compilearg(gs, VAL_COND))) {
|
for (;;) {
|
||||||
|
more = compilearg(gs, VAL_COND);
|
||||||
|
if (!more) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
numargs++;
|
numargs++;
|
||||||
if ((gs.code[end] & ~BC_INST_RET_MASK) != (
|
if ((gs.code[end] & ~BC_INST_RET_MASK) != (
|
||||||
BC_INST_BLOCK | (uint32_t(gs.code.size() - (end + 1)) << 8)
|
BC_INST_BLOCK | (uint32_t(gs.code.size() - (end + 1)) << 8)
|
||||||
|
@ -1096,7 +1120,11 @@ static void compile_and_or(
|
||||||
end = gs.code.size();
|
end = gs.code.size();
|
||||||
}
|
}
|
||||||
if (more) {
|
if (more) {
|
||||||
while ((more = compilearg(gs, VAL_COND))) {
|
for (;;) {
|
||||||
|
more = compilearg(gs, VAL_COND);
|
||||||
|
if (!more) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
numargs++;
|
numargs++;
|
||||||
}
|
}
|
||||||
gs.code.push_back(
|
gs.code.push_back(
|
||||||
|
@ -1104,14 +1132,14 @@ static void compile_and_or(
|
||||||
);
|
);
|
||||||
gs.code.push_back(numargs);
|
gs.code.push_back(numargs);
|
||||||
} else {
|
} else {
|
||||||
uint32_t op = (id->get_raw_type() == ID_AND)
|
std::uint32_t op = (id->get_raw_type() == ID_AND)
|
||||||
? (BC_INST_JUMP_RESULT | BC_INST_FLAG_FALSE)
|
? (BC_INST_JUMP_RESULT | BC_INST_FLAG_FALSE)
|
||||||
: (BC_INST_JUMP_RESULT | BC_INST_FLAG_TRUE);
|
: (BC_INST_JUMP_RESULT | BC_INST_FLAG_TRUE);
|
||||||
gs.code.push_back(op);
|
gs.code.push_back(op);
|
||||||
end = gs.code.size();
|
end = gs.code.size();
|
||||||
while ((start + 1) < end) {
|
while ((start + 1) < end) {
|
||||||
uint32_t len = gs.code[start] >> 8;
|
uint32_t len = gs.code[start] >> 8;
|
||||||
gs.code[start] = ((end - (start + 1)) << 8) | op;
|
gs.code[start] = std::uint32_t((end - (start + 1)) << 8) | op;
|
||||||
gs.code[start + 1] = BC_INST_ENTER;
|
gs.code[start + 1] = BC_INST_ENTER;
|
||||||
gs.code[start + len] = (
|
gs.code[start + len] = (
|
||||||
gs.code[start + len] & ~BC_INST_RET_MASK
|
gs.code[start + len] & ~BC_INST_RET_MASK
|
||||||
|
@ -1207,7 +1235,11 @@ static void compilestatements(codegen_state &gs, int rettype, int brak) {
|
||||||
if (idname.empty()) {
|
if (idname.empty()) {
|
||||||
noid:
|
noid:
|
||||||
std::uint32_t numargs = 0;
|
std::uint32_t numargs = 0;
|
||||||
while ((more = compilearg(gs, VAL_ANY))) {
|
for (;;) {
|
||||||
|
more = compilearg(gs, VAL_ANY);
|
||||||
|
if (!more) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
++numargs;
|
++numargs;
|
||||||
}
|
}
|
||||||
gs.code.push_back(BC_INST_CALL_U | (numargs << 8));
|
gs.code.push_back(BC_INST_CALL_U | (numargs << 8));
|
||||||
|
@ -1231,7 +1263,7 @@ noid:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
gs.gen_value(rettype, idname.str_term(), curline);
|
gs.gen_value(rettype, idname.str_term(), int(curline));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gs.code.push_back(BC_INST_RESULT);
|
gs.code.push_back(BC_INST_RESULT);
|
||||||
|
@ -1288,35 +1320,45 @@ noid:
|
||||||
compile_and_or(gs, id, more, rettype);
|
compile_and_or(gs, id, more, rettype);
|
||||||
break;
|
break;
|
||||||
case ID_IVAR:
|
case ID_IVAR:
|
||||||
if (!(more = compilearg(gs, VAL_INT))) {
|
more = compilearg(gs, VAL_INT); /* first arg */
|
||||||
|
if (!more) {
|
||||||
gs.code.push_back(BC_INST_PRINT | (id->get_index() << 8));
|
gs.code.push_back(BC_INST_PRINT | (id->get_index() << 8));
|
||||||
} else if (!(id->get_flags() & IDENT_FLAG_HEX) || !(
|
break;
|
||||||
more = compilearg(gs, VAL_INT)
|
|
||||||
)) {
|
|
||||||
gs.code.push_back(BC_INST_IVAR1 | (id->get_index() << 8));
|
|
||||||
} else if (!(
|
|
||||||
more = compilearg(gs, VAL_INT)
|
|
||||||
)) {
|
|
||||||
gs.code.push_back(BC_INST_IVAR2 | (id->get_index() << 8));
|
|
||||||
} else {
|
|
||||||
gs.code.push_back(BC_INST_IVAR3 | (id->get_index() << 8));
|
|
||||||
}
|
}
|
||||||
|
if (id->get_flags() & IDENT_FLAG_HEX) {
|
||||||
|
more = compilearg(gs, VAL_INT); /* second arg */
|
||||||
|
} else {
|
||||||
|
more = false;
|
||||||
|
}
|
||||||
|
if (!more) {
|
||||||
|
gs.code.push_back(BC_INST_IVAR1 | (id->get_index() << 8));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
more = compilearg(gs, VAL_INT); /* third arg */
|
||||||
|
if (!more) {
|
||||||
|
gs.code.push_back(BC_INST_IVAR2 | (id->get_index() << 8));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
gs.code.push_back(BC_INST_IVAR3 | (id->get_index() << 8));
|
||||||
break;
|
break;
|
||||||
case ID_FVAR:
|
case ID_FVAR:
|
||||||
if (!(more = compilearg(gs, VAL_FLOAT))) {
|
more = compilearg(gs, VAL_FLOAT);
|
||||||
|
if (!more) {
|
||||||
gs.code.push_back(BC_INST_PRINT | (id->get_index() << 8));
|
gs.code.push_back(BC_INST_PRINT | (id->get_index() << 8));
|
||||||
} else {
|
} else {
|
||||||
gs.code.push_back(BC_INST_FVAR1 | (id->get_index() << 8));
|
gs.code.push_back(BC_INST_FVAR1 | (id->get_index() << 8));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ID_SVAR:
|
case ID_SVAR:
|
||||||
if (!(more = compilearg(gs, VAL_STRING))) {
|
more = compilearg(gs, VAL_STRING);
|
||||||
|
if (!more) {
|
||||||
gs.code.push_back(BC_INST_PRINT | (id->get_index() << 8));
|
gs.code.push_back(BC_INST_PRINT | (id->get_index() << 8));
|
||||||
} else {
|
} else {
|
||||||
std::uint32_t numargs = 0;
|
std::uint32_t numargs = 0;
|
||||||
do {
|
do {
|
||||||
++numargs;
|
++numargs;
|
||||||
} while ((more = compilearg(gs, VAL_ANY)));
|
more = compilearg(gs, VAL_ANY);
|
||||||
|
} while (more);
|
||||||
if (numargs > 1) {
|
if (numargs > 1) {
|
||||||
gs.code.push_back(
|
gs.code.push_back(
|
||||||
BC_INST_CONC | BC_RET_STRING | (numargs << 8)
|
BC_INST_CONC | BC_RET_STRING | (numargs << 8)
|
||||||
|
|
|
@ -64,7 +64,9 @@ struct codegen_state {
|
||||||
code.push_back(op);
|
code.push_back(op);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
code.push_back(BC_INST_VAL | BC_RET_STRING | (word.size() << 8));
|
code.push_back(
|
||||||
|
BC_INST_VAL | BC_RET_STRING | std::uint32_t(word.size() << 8)
|
||||||
|
);
|
||||||
auto it = reinterpret_cast<std::uint32_t const *>(word.data());
|
auto it = reinterpret_cast<std::uint32_t const *>(word.data());
|
||||||
code.append(it, it + (word.size() / sizeof(std::uint32_t)));
|
code.append(it, it + (word.size() / sizeof(std::uint32_t)));
|
||||||
std::size_t esz = word.size() % sizeof(std::uint32_t);
|
std::size_t esz = word.size() % sizeof(std::uint32_t);
|
||||||
|
|
|
@ -256,7 +256,9 @@ LIBCUBESCRIPT_EXPORT ident *state::add_ident(
|
||||||
}
|
}
|
||||||
id->p_impl = impl;
|
id->p_impl = impl;
|
||||||
p_tstate->istate->idents[id->get_name()] = id;
|
p_tstate->istate->idents[id->get_name()] = id;
|
||||||
static_cast<ident_impl *>(impl)->p_index = p_tstate->istate->identmap.size();
|
static_cast<ident_impl *>(impl)->p_index = int(
|
||||||
|
p_tstate->istate->identmap.size()
|
||||||
|
);
|
||||||
p_tstate->istate->identmap.push_back(id);
|
p_tstate->istate->identmap.push_back(id);
|
||||||
return p_tstate->istate->identmap.back();
|
return p_tstate->istate->identmap.back();
|
||||||
}
|
}
|
||||||
|
@ -726,7 +728,6 @@ float_type clamp_fvar(state &cs, float_var *fv, float_type v) {
|
||||||
cs, "valid range for '%s' is %s..%s", fv->get_name().data(),
|
cs, "valid range for '%s' is %s..%s", fv->get_name().data(),
|
||||||
vmin.force_str(), vmax.force_str()
|
vmin.force_str(), vmax.force_str()
|
||||||
};
|
};
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBCUBESCRIPT_EXPORT void state::set_var_float_checked(
|
LIBCUBESCRIPT_EXPORT void state::set_var_float_checked(
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "cs_parser.hh"
|
#include "cs_parser.hh"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <cmath>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
namespace cubescript {
|
namespace cubescript {
|
||||||
|
@ -215,7 +216,7 @@ void exec_alias(
|
||||||
uargs[i] = true;
|
uargs[i] = true;
|
||||||
}
|
}
|
||||||
auto oldargs = anargs->get_value();
|
auto oldargs = anargs->get_value();
|
||||||
anargs->set_value(callargs);
|
anargs->set_value(integer_type(callargs));
|
||||||
int oldflags = ts.pstate->identflags;
|
int oldflags = ts.pstate->identflags;
|
||||||
ts.pstate->identflags |= a->get_flags()&IDENT_FLAG_OVERRIDDEN;
|
ts.pstate->identflags |= a->get_flags()&IDENT_FLAG_OVERRIDDEN;
|
||||||
ident_link aliaslink = {a, ts.callstack, uargs};
|
ident_link aliaslink = {a, ts.callstack, uargs};
|
||||||
|
@ -1023,9 +1024,9 @@ std::uint32_t *vm_exec(
|
||||||
continue;
|
continue;
|
||||||
case BC_INST_FVAR | BC_RET_STRING: {
|
case BC_INST_FVAR | BC_RET_STRING: {
|
||||||
auto &v = args.emplace_back(cs);
|
auto &v = args.emplace_back(cs);
|
||||||
v.set_int(static_cast<float_var *>(
|
v.set_int(integer_type(std::floor(static_cast<float_var *>(
|
||||||
ts.istate->identmap[op >> 8]
|
ts.istate->identmap[op >> 8]
|
||||||
)->get_value());
|
)->get_value())));
|
||||||
v.force_str();
|
v.force_str();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,10 +161,10 @@ void init_lib_math(state &cs) {
|
||||||
float_type step = args[1].get_float();
|
float_type step = args[1].get_float();
|
||||||
float_type r = args[0].get_float();
|
float_type r = args[0].get_float();
|
||||||
if (step > 0) {
|
if (step > 0) {
|
||||||
r += step * ((r < 0) ? -0.5 : 0.5);
|
r += float_type(step * ((r < 0) ? -0.5 : 0.5));
|
||||||
r -= std::fmod(r, step);
|
r -= float_type(std::fmod(r, step));
|
||||||
} else {
|
} else {
|
||||||
r = (r < 0) ? std::ceil(r - 0.5) : std::floor(r + 0.5);
|
r = float_type((r < 0) ? std::ceil(r - 0.5) : std::floor(r + 0.5));
|
||||||
}
|
}
|
||||||
res.set_float(r);
|
res.set_float(r);
|
||||||
});
|
});
|
||||||
|
|
|
@ -63,7 +63,7 @@ void init_lib_string(state &cs) {
|
||||||
auto *ics = ccs.thread_pointer()->istate;
|
auto *ics = ccs.thread_pointer()->istate;
|
||||||
auto *buf = ics->strman->alloc_buf(inps.size());
|
auto *buf = ics->strman->alloc_buf(inps.size());
|
||||||
for (std::size_t i = 0; i < inps.size(); ++i) {
|
for (std::size_t i = 0; i < inps.size(); ++i) {
|
||||||
buf[i] = tolower(inps[i]);
|
buf[i] = char(tolower(inps[i]));
|
||||||
}
|
}
|
||||||
res.set_str(ics->strman->steal(buf));
|
res.set_str(ics->strman->steal(buf));
|
||||||
});
|
});
|
||||||
|
@ -73,7 +73,7 @@ void init_lib_string(state &cs) {
|
||||||
auto *ics = ccs.thread_pointer()->istate;
|
auto *ics = ccs.thread_pointer()->istate;
|
||||||
auto *buf = ics->strman->alloc_buf(inps.size());
|
auto *buf = ics->strman->alloc_buf(inps.size());
|
||||||
for (std::size_t i = 0; i < inps.size(); ++i) {
|
for (std::size_t i = 0; i < inps.size(); ++i) {
|
||||||
buf[i] = toupper(inps[i]);
|
buf[i] = char(toupper(inps[i]));
|
||||||
}
|
}
|
||||||
res.set_str(ics->strman->steal(buf));
|
res.set_str(ics->strman->steal(buf));
|
||||||
});
|
});
|
||||||
|
|
|
@ -459,8 +459,8 @@ endargs:
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
std::string str;
|
std::string str;
|
||||||
for (signed char c = '\0'; (c = std::fgetc(stdin)) != EOF;) {
|
for (int c = '\0'; (c = std::fgetc(stdin)) != EOF;) {
|
||||||
str += c;
|
str += char(c);
|
||||||
}
|
}
|
||||||
do_call(gcs, str);
|
do_call(gcs, str);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue