Skip to content

Commit

Permalink
parser, std, lib_list: don't use use string_view iterators
Browse files Browse the repository at this point in the history
It seems msvc's stdlib uses weird representations for that that
cannot be converted to char pointers, so simulate it with data().
  • Loading branch information
q66 committed Jan 9, 2025
1 parent 6240e9b commit 6b0a28a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/cs_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ LIBCUBESCRIPT_EXPORT char const *parse_string(
if (str.empty() || (str.front() != '\"')) {
return str.data();
}
char const *beg = str.begin();
char const *end = str.end();
char const *beg = str.data();
char const *end = beg + str.size();
char const *orig = beg++;
++nl;
while (beg != end) {
Expand Down Expand Up @@ -67,8 +67,8 @@ LIBCUBESCRIPT_EXPORT char const *parse_string(
LIBCUBESCRIPT_EXPORT char const *parse_word(
state &cs, std::string_view str
) {
char const *it = str.begin();
char const *end = str.end();
char const *it = str.data();
char const *end = it + str.size();
for (; it != end; ++it) {
std::string_view chrs{"\"/;()[] \t\r\n"};
it = std::find_first_of(it, end, chrs.begin(), chrs.end());
Expand Down Expand Up @@ -253,8 +253,8 @@ static inline bool parse_gen_float(
}

float_type parse_float(std::string_view input, std::string_view *endstr) {
char const *beg = input.begin();
char const *end = input.end();
char const *beg = input.data();
char const *end = beg + input.size();
char const *orig = beg;
beg = p_skip_white(beg, end);
if (beg == end) {
Expand Down
2 changes: 1 addition & 1 deletion src/cs_std.hh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct charbuf: valbuf<char> {
}

void append(std::string_view v) {
append(static_cast<char const *>(v.begin()), static_cast<char const *>(v.end()));
append(v.data(), v.data() + v.size());
}

std::string_view str() {
Expand Down
4 changes: 2 additions & 2 deletions src/lib_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ LIBCUBESCRIPT_EXPORT void std_init_list(state &gcs) {
return;
}
auto quote = p.quoted_item();
auto *qend = quote.end();
auto *qend = quote.data() + quote.size();
res.set_string(make_str_view(list, qend), cs);
});

Expand Down Expand Up @@ -467,7 +467,7 @@ LIBCUBESCRIPT_EXPORT void std_init_list(state &gcs) {
}
}
std::string_view quote = p.quoted_item();
char const *qend = !quote.empty() ? quote.end() : list;
char const *qend = !quote.empty() ? quote.data() + quote.size() : list;
charbuf buf{cs};
if (qend > list) {
buf.append(list, qend);
Expand Down

0 comments on commit 6b0a28a

Please sign in to comment.