Skip to content

Commit cb0283c

Browse files
committed
[scnlib] bump version
1 parent 4ec602e commit cb0283c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+27525
-21263
lines changed

src/CMakeLists.txt

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -323,63 +323,16 @@ target_link_libraries(datepp ${lnav_LIBS})
323323

324324
add_library(
325325
cppscnlib STATIC
326-
third-party/scnlib/src/reader_float.cpp
327-
third-party/scnlib/src/reader_int.cpp
328-
third-party/scnlib/src/locale.cpp
329-
third-party/scnlib/src/file.cpp
330-
third-party/scnlib/src/vscan.cpp
331-
332-
third-party/scnlib/include/scn/reader/reader.h
333-
third-party/scnlib/include/scn/reader/float.h
334-
third-party/scnlib/include/scn/reader/types.h
335-
third-party/scnlib/include/scn/reader/int.h
336-
third-party/scnlib/include/scn/reader/common.h
337-
third-party/scnlib/include/scn/reader/string.h
338-
third-party/scnlib/include/scn/ranges/custom_impl.h
339-
third-party/scnlib/include/scn/ranges/std_impl.h
340-
third-party/scnlib/include/scn/ranges/ranges.h
341-
third-party/scnlib/include/scn/ranges/util.h
326+
third-party/scnlib/src/scn/impl.cpp
327+
third-party/scnlib/src/scn/impl.h
328+
342329
third-party/scnlib/include/scn/fwd.h
343-
third-party/scnlib/include/scn/util/algorithm.h
344-
third-party/scnlib/include/scn/util/small_vector.h
345-
third-party/scnlib/include/scn/util/optional.h
346-
third-party/scnlib/include/scn/util/expected.h
347-
third-party/scnlib/include/scn/util/array.h
348-
third-party/scnlib/include/scn/util/unique_ptr.h
349-
third-party/scnlib/include/scn/util/math.h
350-
third-party/scnlib/include/scn/util/memory.h
351-
third-party/scnlib/include/scn/util/span.h
352-
third-party/scnlib/include/scn/util/meta.h
353-
third-party/scnlib/include/scn/util/string_view.h
354-
third-party/scnlib/include/scn/unicode/unicode.h
355-
third-party/scnlib/include/scn/unicode/common.h
356-
third-party/scnlib/include/scn/unicode/utf16.h
357-
third-party/scnlib/include/scn/unicode/utf8.h
358-
third-party/scnlib/include/scn/all.h
359-
third-party/scnlib/include/scn/tuple_return/tuple_return.h
360-
third-party/scnlib/include/scn/tuple_return/util.h
361-
third-party/scnlib/include/scn/scan/ignore.h
362-
third-party/scnlib/include/scn/scan/getline.h
363-
third-party/scnlib/include/scn/scan/list.h
364-
third-party/scnlib/include/scn/scan/common.h
365-
third-party/scnlib/include/scn/scan/istream.h
366-
third-party/scnlib/include/scn/scan/vscan.h
367-
third-party/scnlib/include/scn/scan/scan.h
368-
third-party/scnlib/include/scn/tuple_return.h
369-
third-party/scnlib/include/scn/detail/error.h
370-
third-party/scnlib/include/scn/detail/fwd.h
371-
third-party/scnlib/include/scn/detail/range.h
372-
third-party/scnlib/include/scn/detail/locale.h
373-
third-party/scnlib/include/scn/detail/config.h
374-
third-party/scnlib/include/scn/detail/file.h
375-
third-party/scnlib/include/scn/detail/context.h
376-
third-party/scnlib/include/scn/detail/result.h
377-
third-party/scnlib/include/scn/detail/visitor.h
378-
third-party/scnlib/include/scn/detail/args.h
379-
third-party/scnlib/include/scn/detail/parse_context.h
380-
third-party/scnlib/include/scn/detail/vectored.h
381-
third-party/scnlib/include/scn/scn.h
330+
third-party/scnlib/include/scn/ranges.h
331+
third-party/scnlib/include/scn/xchar.h
332+
third-party/scnlib/include/scn/chrono.h
333+
third-party/scnlib/include/scn/regex.h
382334
third-party/scnlib/include/scn/istream.h
335+
third-party/scnlib/include/scn/scan.h
383336
)
384337
target_include_directories(cppscnlib PRIVATE third-party/scnlib/src/deps/fast_float/single_include)
385338
target_include_directories(cppscnlib PUBLIC third-party/scnlib/include)

src/base/ansi_scrubber.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "base/opt_util.hh"
3939
#include "config.h"
4040
#include "pcrepp/pcre2pp.hh"
41-
#include "scn/scn.h"
41+
#include "scn/scan.h"
4242
#include "view_curses.hh"
4343

4444
static const lnav::pcre2pp::code&
@@ -273,7 +273,7 @@ scrub_ansi_string(std::string& str, string_attrs_t* sa)
273273
auto osc_id = scn::scan_value<int32_t>(md[3]->to_string_view());
274274

275275
if (osc_id) {
276-
switch (osc_id.value()) {
276+
switch (osc_id->value()) {
277277
case 8:
278278
auto split_res = md[4]->split_pair(semi_pred);
279279
if (split_res) {
@@ -312,7 +312,7 @@ scrub_ansi_string(std::string& str, string_attrs_t* sa)
312312
if (!ansi_code_res) {
313313
break;
314314
}
315-
auto ansi_code = ansi_code_res.value();
315+
auto ansi_code = ansi_code_res->value();
316316
if (90 <= ansi_code && ansi_code <= 97) {
317317
ansi_code -= 60;
318318
// XXX attrs.ta_attrs |= A_STANDOUT;
@@ -337,25 +337,25 @@ scrub_ansi_string(std::string& str, string_attrs_t* sa)
337337
if (!color_type.has_value()) {
338338
break;
339339
}
340-
if (color_type.value() == 2) {
341-
} else if (color_type.value() == 5) {
340+
if (color_type->value() == 2) {
341+
} else if (color_type->value() == 5) {
342342
auto color_index_pair
343343
= color_code_pair->second.split_when(
344344
semi_pred);
345345
auto color_index = scn::scan_value<short>(
346346
color_index_pair.first.to_string_view());
347347
if (!color_index.has_value()
348-
|| color_index.value() < 0
349-
|| color_index.value() > 255)
348+
|| color_index->value() < 0
349+
|| color_index->value() > 255)
350350
{
351351
break;
352352
}
353353
if (ansi_code == 38) {
354354
attrs.ta_fg_color = palette_color{
355-
(uint8_t) color_index.value()};
355+
(uint8_t) color_index->value()};
356356
} else {
357357
attrs.ta_bg_color = palette_color{
358-
(uint8_t) color_index.value()};
358+
(uint8_t) color_index->value()};
359359
}
360360
seq = color_index_pair.second;
361361
}
@@ -421,7 +421,7 @@ scrub_ansi_string(std::string& str, string_attrs_t* sa)
421421
auto role_res = scn::scan_value<int>(seq.to_string_view());
422422

423423
if (role_res) {
424-
role_t role_tmp = (role_t) role_res.value();
424+
role_t role_tmp = (role_t) role_res->value();
425425
if (role_tmp > role_t::VCR_NONE
426426
&& role_tmp < role_t::VCR__MAX)
427427
{

src/base/date_time_scanner.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "injector.hh"
3939
#include "math_util.hh"
4040
#include "ptimec.hh"
41-
#include "scn/scn.h"
41+
#include "scn/scan.h"
4242

4343
size_t
4444
date_time_scanner::ftime(char* dst,
@@ -124,10 +124,10 @@ date_time_scanner::scan(const char* time_dest,
124124
tm_out->et_flags = 0;
125125
if (time_len > 1 && time_dest[0] == '+' && isdigit(time_dest[1])) {
126126
retval = nullptr;
127-
auto sv = scn::string_view{time_dest, time_len};
127+
auto sv = std::string_view{time_dest, time_len};
128128
auto epoch_scan_res = scn::scan_value<int64_t>(sv);
129129
if (epoch_scan_res) {
130-
time_t gmt = epoch_scan_res.value();
130+
time_t gmt = epoch_scan_res->value();
131131

132132
if (convert_local
133133
&& (this->dts_local_time || this->dts_zoned_to_local))
@@ -145,7 +145,7 @@ date_time_scanner::scan(const char* time_dest,
145145
| ETF_MACHINE_ORIENTED | ETF_EPOCH_TIME | ETF_ZONE_SET;
146146

147147
this->dts_fmt_lock = curr_time_fmt;
148-
this->dts_fmt_len = sv.length() - epoch_scan_res.range().size();
148+
this->dts_fmt_len = sv.length() - epoch_scan_res->range().size();
149149
retval = time_dest + this->dts_fmt_len;
150150
found = true;
151151
break;

src/base/intern_string.hh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include <optional>
3636
#include <ostream>
37+
#include <string_view>
3738
#include <vector>
3839

3940
#include <assert.h>
@@ -43,7 +44,6 @@
4344
#include "fmt/format.h"
4445
#include "mapbox/variant.hpp"
4546
#include "result.h"
46-
#include "scn/util/string_view.h"
4747
#include "strnatcmp.h"
4848

4949
unsigned long hash_str(const char* str, size_t len);
@@ -631,9 +631,11 @@ struct string_fragment {
631631
};
632632
}
633633

634-
scn::string_view to_string_view() const
634+
std::string_view to_string_view() const
635635
{
636-
return scn::string_view{this->begin(), this->end()};
636+
return std::string_view{
637+
this->data(),
638+
static_cast<std::string_view::size_type>(this->length())};
637639
}
638640

639641
enum class case_style {
@@ -960,7 +962,7 @@ to_string_fragment(const std::string& s)
960962
}
961963

962964
inline string_fragment
963-
to_string_fragment(const scn::string_view& sv)
965+
to_string_fragment(const std::string_view& sv)
964966
{
965967
return string_fragment::from_bytes(sv.data(), sv.length());
966968
}

src/db_sub_source.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "base/itertools.hh"
3535
#include "base/time_util.hh"
3636
#include "config.h"
37-
#include "scn/scn.h"
37+
#include "scn/scan.h"
3838
#include "yajlpp/json_ptr.hh"
3939

4040
const char db_label_source::NULL_STR[] = "<NULL>";
@@ -120,7 +120,7 @@ db_label_source::text_attrs_for_line(textview_curses& tc,
120120
}
121121
int cell_start = 0;
122122
for (size_t lpc = 0; lpc < this->dls_headers.size(); lpc++) {
123-
auto row_view = scn::string_view{this->dls_rows[row][lpc]};
123+
auto row_view = std::string_view{this->dls_rows[row][lpc]};
124124
const auto& hm = this->dls_headers[lpc];
125125

126126
int left = cell_start;
@@ -132,7 +132,7 @@ db_label_source::text_attrs_for_line(textview_curses& tc,
132132
left,
133133
this->dls_cell_width[lpc],
134134
hm.hm_name,
135-
num_scan_res.value(),
135+
num_scan_res->value(),
136136
sa);
137137

138138
for (const auto& attr : sa) {
@@ -163,7 +163,7 @@ db_label_source::text_attrs_for_line(textview_curses& tc,
163163
left,
164164
this->dls_cell_width[lpc],
165165
jpw_value.wt_ptr,
166-
num_scan_res.value(),
166+
num_scan_res->value(),
167167
sa);
168168
for (const auto& attr : sa) {
169169
require_ge(attr.sa_range.lr_start, 0);
@@ -281,7 +281,7 @@ db_label_source::push_column(const scoped_value_t& sv)
281281
auto num_scan_res = scn::scan_value<double>(jpw_value.wt_value);
282282
if (num_scan_res) {
283283
hm.hm_chart.add_value(jpw_value.wt_ptr,
284-
num_scan_res.value());
284+
num_scan_res->value());
285285
hm.hm_chart.with_attrs_for_ident(
286286
jpw_value.wt_ptr, vc.attrs_for_ident(jpw_value.wt_ptr));
287287
}
@@ -413,7 +413,7 @@ db_overlay_source::list_value_for_overlay(const listview_curses& lv,
413413
if (num_scan_res) {
414414
auto attrs = vc.attrs_for_ident(jpw_value.wt_ptr);
415415

416-
chart.add_value(jpw_value.wt_ptr, num_scan_res.value());
416+
chart.add_value(jpw_value.wt_ptr, num_scan_res->value());
417417
chart.with_attrs_for_ident(jpw_value.wt_ptr, attrs);
418418
}
419419
}
@@ -440,7 +440,7 @@ db_overlay_source::list_value_for_overlay(const listview_curses& lv,
440440
left,
441441
width,
442442
iter->wt_ptr,
443-
num_scan_res.value(),
443+
num_scan_res->value(),
444444
sa);
445445
}
446446
}

src/formats/logfmt/logfmt.parser.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
#include "base/intern_string.hh"
3535
#include "config.h"
36-
#include "scn/scn.h"
36+
#include "scn/scan.h"
3737

3838
logfmt::parser::parser(string_fragment sf) : p_next_input(sf) {}
3939

@@ -232,7 +232,7 @@ logfmt::parser::step()
232232
auto int_scan_res
233233
= scn::scan_value<int64_t>(value_pair->first.to_string_view());
234234
if (int_scan_res) {
235-
retval.iv_value = int_scan_res.value();
235+
retval.iv_value = int_scan_res->value();
236236
}
237237
retval.iv_str_value = value_pair->first;
238238

@@ -244,7 +244,7 @@ logfmt::parser::step()
244244
auto float_scan_res
245245
= scn::scan_value<double>(value_pair->first.to_string_view());
246246
if (float_scan_res) {
247-
retval.fv_value = float_scan_res.value();
247+
retval.fv_value = float_scan_res->value();
248248
}
249249
retval.fv_str_value = value_pair->first;
250250

src/grep_proc.cc

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include "base/string_util.hh"
4646
#include "config.h"
4747
#include "lnav_util.hh"
48-
#include "scn/scn.h"
48+
#include "scn/scan.h"
4949
#include "vis_line.hh"
5050

5151
template<typename LineType>
@@ -249,16 +249,22 @@ grep_proc<LineType>::dispatch_line(const string_fragment& line)
249249
require(line.is_valid());
250250

251251
auto sv = line.to_string_view();
252-
if (scn::scan(sv, "h{}", this->gp_highest_line.lvalue())) {
253-
} else if (scn::scan(sv, "{}", this->gp_last_line.lvalue())) {
254-
/* Starting a new line with matches. */
255-
ensure(this->gp_last_line >= 0);
256-
/* Pass the match offsets to the sink delegate. */
257-
if (this->gp_sink != nullptr) {
258-
this->gp_sink->grep_match(*this, this->gp_last_line);
259-
}
252+
auto h_scan_res = scn::scan<int>(sv, "h{}");
253+
if (h_scan_res) {
254+
this->gp_highest_line = LineType{h_scan_res->value()};
260255
} else {
261-
log_error("bad line from child -- %s", line);
256+
auto ll_scan_res = scn::scan<int>(sv, "{}");
257+
if (ll_scan_res) {
258+
this->gp_last_line = LineType{ll_scan_res->value()};
259+
/* Starting a new line with matches. */
260+
ensure(this->gp_last_line >= 0);
261+
/* Pass the match offsets to the sink delegate. */
262+
if (this->gp_sink != nullptr) {
263+
this->gp_sink->grep_match(*this, this->gp_last_line);
264+
}
265+
} else {
266+
log_error("bad line from child -- %s", line);
267+
}
262268
}
263269
}
264270

src/json-extension-functions.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
#include "config.h"
3636
#include "mapbox/variant.hpp"
37-
#include "scn/scn.h"
37+
#include "scn/scan.h"
3838
#include "sqlite-extension-func.hh"
3939
#include "sqlite3.h"
4040
#include "vtab_module.hh"
@@ -233,16 +233,16 @@ gen_handle_number(void* ctx, const char* numval, size_t numlen)
233233
yajl_gen gen = (yajl_gen) sjo->jo_ptr_data;
234234

235235
if (sjo->jo_ptr.jp_state == json_ptr::match_state_t::DONE) {
236-
auto num_sv = scn::string_view{numval, numlen};
236+
auto num_sv = std::string_view{numval, numlen};
237237
auto scan_int_res = scn::scan_value<int64_t>(num_sv);
238238

239-
if (scan_int_res && scan_int_res.empty()) {
240-
sjo->sjo_int = scan_int_res.value();
239+
if (scan_int_res && scan_int_res->range().empty()) {
240+
sjo->sjo_int = scan_int_res->value();
241241
sjo->sjo_type = SQLITE_INTEGER;
242242
} else {
243243
auto scan_float_res = scn::scan_value<double>(num_sv);
244244

245-
sjo->sjo_float = scan_float_res.value();
245+
sjo->sjo_float = scan_float_res->value();
246246
sjo->sjo_type = SQLITE_FLOAT;
247247
}
248248
} else {

0 commit comments

Comments
 (0)