diff --git a/include/cubescript/cubescript.hh b/include/cubescript/cubescript.hh
index 18b8d369..3aa82341 100644
--- a/include/cubescript/cubescript.hh
+++ b/include/cubescript/cubescript.hh
@@ -531,12 +531,13 @@ struct CsErrorException {
{
char fbuf[512];
auto ret = ostd::format(
- ostd::CharRange(fbuf, sizeof(fbuf)), msg, std::forward(args)...
+ ostd::CharRange(fbuf, fbuf + sizeof(fbuf)), msg,
+ std::forward(args)...
);
if ((ret < 0) || (size_t(ret) > sizeof(fbuf))) {
p_errmsg = save_msg(cs, msg);
} else {
- p_errmsg = save_msg(cs, ostd::CharRange(fbuf, ret));
+ p_errmsg = save_msg(cs, ostd::CharRange(fbuf, fbuf + ret));
}
p_stack = save_stack(cs);
}
diff --git a/src/cs_gen.cc b/src/cs_gen.cc
index 4da0464e..a3f4a3aa 100644
--- a/src/cs_gen.cc
+++ b/src/cs_gen.cc
@@ -207,7 +207,7 @@ static inline void compileunescapestr(GenState &gs, bool macro = false) {
);
size_t bufs = (gs.code.capacity() - gs.code.size()) * sizeof(uint32_t);
char *buf = new char[bufs + 1];
- auto writer = ostd::CharRange(buf, bufs);
+ auto writer = ostd::CharRange(buf, buf + bufs);
size_t len = util::unescape_string(writer, str);
memset(&buf[len], 0, sizeof(uint32_t) - len % sizeof(uint32_t));
gs.code.back() |= len << 8;
diff --git a/src/cs_val.cc b/src/cs_val.cc
index a64a68df..8773365a 100644
--- a/src/cs_val.cc
+++ b/src/cs_val.cc
@@ -150,9 +150,10 @@ CsFloat CsValue::force_float() {
case CsValueType::String:
case CsValueType::Macro:
case CsValueType::Cstring:
- rf = cs_parse_float(
- ostd::ConstCharRange(csv_get(p_stor), p_len)
- );
+ rf = cs_parse_float(ostd::ConstCharRange(
+ csv_get(p_stor),
+ csv_get(p_stor) + p_len
+ ));
break;
case CsValueType::Float:
return csv_get(p_stor);
@@ -172,9 +173,10 @@ CsInt CsValue::force_int() {
case CsValueType::String:
case CsValueType::Macro:
case CsValueType::Cstring:
- ri = cs_parse_int(
- ostd::ConstCharRange(csv_get(p_stor), p_len)
- );
+ ri = cs_parse_int(ostd::ConstCharRange(
+ csv_get(p_stor),
+ csv_get(p_stor) + p_len
+ ));
break;
case CsValueType::Int:
return csv_get(p_stor);
@@ -196,15 +198,24 @@ ostd::ConstCharRange CsValue::force_str() {
break;
case CsValueType::Macro:
case CsValueType::Cstring:
- rs = ostd::ConstCharRange(csv_get(p_stor), p_len);
+ rs = ostd::ConstCharRange(
+ csv_get(p_stor),
+ csv_get(p_stor) + p_len
+ );
break;
case CsValueType::String:
- return ostd::ConstCharRange(csv_get(p_stor), p_len);
+ return ostd::ConstCharRange(
+ csv_get(p_stor),
+ csv_get(p_stor) + p_len
+ );
default:
break;
}
set_str(std::move(rs));
- return ostd::ConstCharRange(csv_get(p_stor), p_len);
+ return ostd::ConstCharRange(
+ csv_get(p_stor),
+ csv_get(p_stor) + p_len
+ );
}
CsInt CsValue::get_int() const {
@@ -216,9 +227,10 @@ CsInt CsValue::get_int() const {
case CsValueType::String:
case CsValueType::Macro:
case CsValueType::Cstring:
- return cs_parse_int(
- ostd::ConstCharRange(csv_get(p_stor), p_len)
- );
+ return cs_parse_int(ostd::ConstCharRange(
+ csv_get(p_stor),
+ csv_get(p_stor) + p_len
+ ));
default:
break;
}
@@ -234,9 +246,10 @@ CsFloat CsValue::get_float() const {
case CsValueType::String:
case CsValueType::Macro:
case CsValueType::Cstring:
- return cs_parse_float(
- ostd::ConstCharRange(csv_get(p_stor), p_len)
- );
+ return cs_parse_float(ostd::ConstCharRange(
+ csv_get(p_stor),
+ csv_get(p_stor) + p_len
+ ));
default:
break;
}
@@ -278,7 +291,10 @@ ostd::ConstCharRange CsValue::get_strr() const {
case CsValueType::String:
case CsValueType::Macro:
case CsValueType::Cstring:
- return ostd::ConstCharRange(csv_get(p_stor), p_len);
+ return ostd::ConstCharRange(
+ csv_get(p_stor),
+ csv_get(p_stor)+ p_len
+ );
default:
break;
}
@@ -348,9 +364,10 @@ bool CsValue::get_bool() const {
case CsValueType::String:
case CsValueType::Macro:
case CsValueType::Cstring:
- return cs_get_bool(
- ostd::ConstCharRange(csv_get(p_stor), p_len)
- );
+ return cs_get_bool(ostd::ConstCharRange(
+ csv_get(p_stor),
+ csv_get(p_stor) + p_len
+ ));
default:
return false;
}
diff --git a/src/cs_vm.cc b/src/cs_vm.cc
index fc5a53d0..fc527d3c 100644
--- a/src/cs_vm.cc
+++ b/src/cs_vm.cc
@@ -115,7 +115,7 @@ ostd::ConstCharRange CsErrorException::save_msg(
GenState *gs = cs.p_pstate;
if (gs) {
/* we can attach line number */
- ostd::CharRange r(cs.p_errbuf, sizeof(cs.p_errbuf));
+ ostd::CharRange r(cs.p_errbuf, cs.p_errbuf + sizeof(cs.p_errbuf));
std::ptrdiff_t sz = -1;
if (!gs->src_name.empty()) {
sz = ostd::format(r, "%s:%d: %s", gs->src_name, gs->current_line, msg);
@@ -123,11 +123,11 @@ ostd::ConstCharRange CsErrorException::save_msg(
sz = ostd::format(r, "%d: %s", gs->current_line, msg);
}
if (sz > 0) {
- return ostd::ConstCharRange(cs.p_errbuf, sz);
+ return ostd::ConstCharRange(cs.p_errbuf, cs.p_errbuf + sz);
}
}
memcpy(cs.p_errbuf, msg.data(), msg.size());
- return ostd::ConstCharRange(cs.p_errbuf, msg.size());
+ return ostd::ConstCharRange(cs.p_errbuf, cs.p_errbuf + msg.size());
}
static void bcode_ref(uint32_t *code) {
@@ -768,7 +768,8 @@ static uint32_t *runcode(CsState &cs, uint32_t *code, CsValue &result) {
case CsCodeMacro: {
uint32_t len = op >> 8;
args[numargs++].set_macro(ostd::ConstCharRange(
- reinterpret_cast(code), len
+ reinterpret_cast(code),
+ reinterpret_cast(code) + len
));
code += len / sizeof(uint32_t) + 1;
continue;
@@ -777,7 +778,8 @@ static uint32_t *runcode(CsState &cs, uint32_t *code, CsValue &result) {
case CsCodeVal | CsRetString: {
uint32_t len = op >> 8;
args[numargs++].set_str(CsString{
- reinterpret_cast(code), len
+ reinterpret_cast(code),
+ reinterpret_cast(code) + len
});
code += len / sizeof(uint32_t) + 1;
continue;
@@ -1825,7 +1827,7 @@ static bool cs_run_file(
}
buf[len] = '\0';
- cs_run(cs, fname, ostd::ConstCharRange(buf.get(), len), ret);
+ cs_run(cs, fname, ostd::ConstCharRange(buf.get(), buf.get() + len), ret);
return true;
}
diff --git a/src/lib_list.cc b/src/lib_list.cc
index 25f05eb4..85c061c9 100644
--- a/src/lib_list.cc
+++ b/src/lib_list.cc
@@ -479,7 +479,7 @@ end:
char const *qend = !quote.empty() ? "e[quote.size()] : list;
CsString buf;
if (qend > list) {
- buf += ostd::ConstCharRange(list, qend - list);
+ buf += ostd::ConstCharRange(list, qend);
}
if (!vals.empty()) {
if (!buf.empty()) {