Skip to content

Commit

Permalink
✨ use reinterpret_cast and static_cast
Browse files Browse the repository at this point in the history
  • Loading branch information
ValKmjolnir committed Nov 5, 2023
1 parent 336139d commit e8c8a64
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 150 deletions.
6 changes: 3 additions & 3 deletions src/nasal_builtin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ var builtin_substr(context* ctx, gc* ngc) {
if (len.type!=vm_num || len.num()<0) {
return nas_err("substr", "\"length\" should be number >= 0");
}
usize begin = (usize)beg.num();
usize length = (usize)len.num();
auto begin = static_cast<usize>(beg.num());
auto length = static_cast<usize>(len.num());
if (begin>=str.str().length()) {
return nas_err("susbtr", "begin index out of range: "+std::to_string(begin));
}
Expand Down Expand Up @@ -397,7 +397,7 @@ var builtin_chr(context* ctx, gc* ngc) {
};
auto num = static_cast<i32>(ctx->localr[1].num());
if (0<=num && num<128) {
return ngc->newstr((char)num);
return ngc->newstr(static_cast<char>(num));
} else if (128<=num && num<256) {
return ngc->newstr(extend[num-128]);
}
Expand Down
Loading

0 comments on commit e8c8a64

Please sign in to comment.