Skip to content

Commit e621024

Browse files
Fix some int to size_t conversion warnings in cpp2regex.h2 (#1193)
1 parent 8903883 commit e621024

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

include/cpp2regex.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,9 +2229,9 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){}
22292229
#line 735 "cpp2regex.h2"
22302230
[[nodiscard]] auto parse_context::grab_n(cpp2::impl::in<int> n, cpp2::impl::out<std::string> r) & -> bool
22312231
{
2232-
if (cpp2::impl::cmp_less_eq(pos + n,regex.size())) {
2233-
r.construct(regex.substr(pos, n));
2234-
pos += n - 1;
2232+
if (cpp2::impl::cmp_less_eq(pos + cpp2::impl::as_<size_t>(n),regex.size())) {
2233+
r.construct(regex.substr(pos, cpp2::impl::as_<size_t>(n)));
2234+
pos += (cpp2::impl::as_<size_t>(n)) - 1;
22352235
return true;
22362236
}
22372237
else {
@@ -2412,7 +2412,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){}
24122412

24132413
#line 920 "cpp2regex.h2"
24142414
auto generation_function_context::remove_tabs(cpp2::impl::in<int> c) & -> void{
2415-
tabs = tabs.substr(0, c * 2);
2415+
tabs = tabs.substr(0, (cpp2::impl::as_<size_t>(c)) * 2);
24162416
}
24172417

24182418
generation_function_context::generation_function_context(auto const& code_, auto const& tabs_)

include/cpp2regex.h2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,9 @@ parse_context: type =
734734

735735
grab_n: (inout this, in n: int, out r: std::string) -> bool =
736736
{
737-
if pos + n <= regex..size() {
738-
r = regex..substr(pos, n);
739-
pos += n - 1;
737+
if pos + n as size_t <= regex..size() {
738+
r = regex..substr(pos, n as size_t);
739+
pos += (n as size_t) - 1;
740740
return true;
741741
}
742742
else {
@@ -918,7 +918,7 @@ generation_function_context: @struct type = {
918918
}
919919

920920
remove_tabs: (inout this, c: int) = {
921-
tabs = tabs..substr(0, c * 2);
921+
tabs = tabs..substr(0, (c as size_t) * 2);
922922
}
923923
}
924924

0 commit comments

Comments
 (0)