From 6b0a28afb6fabf097b1e0304764872b1bfe58d00 Mon Sep 17 00:00:00 2001 From: q66 Date: Thu, 9 Jan 2025 16:41:15 +0100 Subject: [PATCH] parser, std, lib_list: don't use use string_view iterators It seems msvc's stdlib uses weird representations for that that cannot be converted to char pointers, so simulate it with data(). --- src/cs_parser.cc | 12 ++++++------ src/cs_std.hh | 2 +- src/lib_list.cc | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cs_parser.cc b/src/cs_parser.cc index 9126f44..629bf09 100644 --- a/src/cs_parser.cc +++ b/src/cs_parser.cc @@ -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) { @@ -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()); @@ -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) { diff --git a/src/cs_std.hh b/src/cs_std.hh index e4ae694..866ae38 100644 --- a/src/cs_std.hh +++ b/src/cs_std.hh @@ -81,7 +81,7 @@ struct charbuf: valbuf { } void append(std::string_view v) { - append(static_cast(v.begin()), static_cast(v.end())); + append(v.data(), v.data() + v.size()); } std::string_view str() { diff --git a/src/lib_list.cc b/src/lib_list.cc index 8a9eed6..baf6a1a 100644 --- a/src/lib_list.cc +++ b/src/lib_list.cc @@ -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); }); @@ -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);