Skip to content

Commit 57d10d4

Browse files
committed
[cmake] reorg some stuff to fix build
1 parent e930385 commit 57d10d4

18 files changed

+391
-232
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ set(lnav_LIBS
3434
PkgConfig::readline
3535
LibArchive::LibArchive
3636
ZLIB::ZLIB
37+
${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libunistring.a
3738
)
3839

3940
add_subdirectory(src)

src/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ target_include_directories(base64 PUBLIC third-party/base64/include)
353353

354354
add_library(
355355
lnavnotcurses STATIC
356+
third-party/notcurses/src/compat/compat.c
356357
third-party/notcurses/src/lib/automaton.c
357358
third-party/notcurses/src/lib/blit.c
358359
third-party/notcurses/src/lib/debug.c
@@ -402,15 +403,14 @@ add_library(lnavfileio STATIC
402403
grep_proc.hh
403404
line_buffer.hh
404405
log_level.hh
405-
piper.looper.cfg.hh
406-
piper.looper.hh
406+
piper.header.hh
407407
pollable.hh
408408
shared_buffer.hh
409409

410410
grep_proc.cc
411411
line_buffer.cc
412412
log_level.cc
413-
piper.looper.cc
413+
piper.header.cc
414414
pollable.cc
415415
shared_buffer.cc
416416
)
@@ -485,6 +485,8 @@ add_library(
485485
data_scanner_re.cc
486486
data_parser.cc
487487
file_converter_manager.cc
488+
piper.looper.cc
489+
piper.match.cc
488490
plain_text_source.cc
489491
pretty_printer.cc
490492
pugixml/pugixml.cpp
@@ -606,6 +608,9 @@ add_library(
606608
md2attr_line.hh
607609
md4cpp.hh
608610
file_converter_manager.hh
611+
piper.looper.cfg.hh
612+
piper.looper.hh
613+
piper.match.hh
609614
plain_text_source.hh
610615
pretty_printer.hh
611616
preview_status_source.hh

src/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,10 @@ noinst_HEADERS = \
307307
mapbox/variant_visitor.hpp \
308308
md2attr_line.hh \
309309
md4cpp.hh \
310+
piper.header.hh \
310311
piper.looper.hh \
311312
piper.looper.cfg.hh \
313+
piper.match.hh \
312314
plain_text_source.hh \
313315
pollable.hh \
314316
pretty_printer.hh \
@@ -484,7 +486,9 @@ libdiag_a_SOURCES = \
484486
md4cpp.cc \
485487
network-extension-functions.cc \
486488
data_parser.cc \
489+
piper.header.cc \
487490
piper.looper.cc \
491+
piper.match.cc \
488492
plain_text_source.cc \
489493
pollable.cc \
490494
pretty_printer.cc \

src/base/piper.file.cc

Lines changed: 2 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,8 @@
3535
#include "base/injector.hh"
3636
#include "base/lnav_log.hh"
3737
#include "base/paths.hh"
38-
#include "base/snippet_highlighters.hh"
39-
#include "piper.looper.cfg.hh"
40-
#include "readline_highlighters.hh"
4138

42-
using namespace lnav::roles::literals;
43-
44-
namespace lnav {
45-
namespace piper {
39+
namespace lnav::piper {
4640

4741
const char HEADER_MAGIC[4] = {'L', 0, 'N', 1};
4842

@@ -83,143 +77,4 @@ read_header(int fd, const char* first8)
8377
return meta_buf;
8478
}
8579

86-
multiplex_matcher::match_result
87-
multiplex_matcher::match(const string_fragment& line)
88-
{
89-
const auto& cfg = injector::get<const config&>();
90-
auto md = lnav::pcre2pp::match_data::unitialized();
91-
92-
for (const auto& demux_pair : cfg.c_demux_definitions) {
93-
const auto& df = demux_pair.second;
94-
95-
if (!df.dd_valid) {
96-
continue;
97-
}
98-
99-
if (!this->mm_partial_match_ids.empty()
100-
&& this->mm_partial_match_ids.count(demux_pair.first) == 0)
101-
{
102-
continue;
103-
}
104-
105-
log_info("attempting to demux using: %s", demux_pair.first.c_str());
106-
{
107-
md = df.dd_pattern.pp_value->create_match_data();
108-
if (df.dd_pattern.pp_value->capture_from(line)
109-
.into(md)
110-
.matches()
111-
.ignore_error())
112-
{
113-
log_info(" demuxer pattern matched");
114-
if (!md[df.dd_muxid_capture_index].has_value()) {
115-
log_info(" however, mux_id was not captured");
116-
117-
const auto match_um = lnav::console::user_message::warning(
118-
attr_line_t("demuxer ")
119-
.append_quoted(demux_pair.first)
120-
.append(" matched, however the ")
121-
.append("mux_id"_symbol)
122-
.append(" was not captured"));
123-
this->mm_details.emplace_back(match_um);
124-
continue;
125-
}
126-
if (!md[df.dd_body_capture_index].has_value()) {
127-
log_info(" however, body was not captured");
128-
const auto match_um = lnav::console::user_message::warning(
129-
attr_line_t("demuxer ")
130-
.append_quoted(demux_pair.first)
131-
.append(" matched, however the ")
132-
.append("body"_symbol)
133-
.append(" was not captured"));
134-
this->mm_details.emplace_back(match_um);
135-
continue;
136-
}
137-
log_info(" and required captures were found, using demuxer");
138-
139-
if (df.dd_enabled) {
140-
auto match_um = lnav::console::user_message::ok(
141-
attr_line_t("demuxer ")
142-
.append_quoted(demux_pair.first)
143-
.append(" matched line ")
144-
.append(lnav::roles::number(
145-
fmt::to_string(this->mm_line_count))));
146-
this->mm_details.emplace_back(match_um);
147-
return found{demux_pair.first};
148-
}
149-
auto config_al
150-
= attr_line_t()
151-
.append(fmt::format(
152-
FMT_STRING(":config /log/demux/{}/enabled "
153-
"true"),
154-
demux_pair.first))
155-
.move();
156-
readline_lnav_highlighter(config_al, -1);
157-
auto match_um
158-
= lnav::console::user_message::info(
159-
attr_line_t("demuxer ")
160-
.append_quoted(demux_pair.first)
161-
.append(" matched line ")
162-
.append(lnav::roles::number(
163-
fmt::to_string(this->mm_line_count)))
164-
.append(", however, it is disabled"))
165-
.with_help(
166-
attr_line_t("Use ")
167-
.append_quoted(
168-
lnav::roles::quoted_code(config_al))
169-
.append(" to enable this demuxer"))
170-
.move();
171-
this->mm_details.emplace_back(match_um);
172-
}
173-
174-
auto partial_size = df.dd_pattern.pp_value->match_partial(
175-
line.sub_range(0, 1024));
176-
auto regex_al = attr_line_t(df.dd_pattern.pp_value->get_pattern());
177-
lnav::snippets::regex_highlighter(
178-
regex_al, -1, line_range{0, (int) regex_al.length()});
179-
auto in_line = line.sub_range(0, 1024).rtrim("\n").to_string();
180-
auto esc_res
181-
= fmt::v10::detail::find_escape(&in_line[0], &(*in_line.end()));
182-
if (esc_res.end != nullptr) {
183-
in_line = fmt::format(FMT_STRING("{:?}"), in_line);
184-
}
185-
auto note = attr_line_t("pattern: ")
186-
.append(regex_al)
187-
.append("\n ")
188-
.append(lnav::roles::quoted_code(in_line))
189-
.append("\n")
190-
.append(partial_size + 2, ' ')
191-
.append("^ matched up to here")
192-
.move();
193-
auto match_um = lnav::console::user_message::info(
194-
attr_line_t("demuxer ")
195-
.append_quoted(demux_pair.first)
196-
.append(" did not match line ")
197-
.append(lnav::roles::number(
198-
fmt::to_string(this->mm_line_count))))
199-
.with_note(note)
200-
.move();
201-
this->mm_details.emplace_back(match_um);
202-
}
203-
if (df.dd_control_pattern.pp_value) {
204-
md = df.dd_control_pattern.pp_value->create_match_data();
205-
if (df.dd_control_pattern.pp_value->capture_from(line)
206-
.into(md)
207-
.matches()
208-
.ignore_error())
209-
{
210-
log_info(" demuxer control pattern matched");
211-
this->mm_partial_match_ids.emplace(demux_pair.first);
212-
}
213-
}
214-
}
215-
216-
this->mm_line_count += 1;
217-
if (this->mm_partial_match_ids.empty()) {
218-
return not_found{};
219-
}
220-
221-
return partial{};
222-
}
223-
224-
} // namespace piper
225-
} // namespace lnav
80+
} // namespace lnav::piper

src/base/piper.file.hh

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,14 @@
3333
#include <filesystem>
3434
#include <map>
3535
#include <optional>
36-
#include <set>
3736
#include <string>
3837

3938
#include <sys/time.h>
4039

4140
#include "auto_mem.hh"
42-
#include "base/intern_string.hh"
43-
#include "lnav.console.hh"
44-
#include "mapbox/variant_io.hpp"
4541
#include "time_util.hh"
4642

47-
namespace lnav {
48-
namespace piper {
43+
namespace lnav::piper {
4944

5045
enum class demux_output_t {
5146
not_applicable,
@@ -84,27 +79,6 @@ extern const char HEADER_MAGIC[4];
8479

8580
std::optional<auto_buffer> read_header(int fd, const char* first8);
8681

87-
class multiplex_matcher {
88-
public:
89-
struct found {
90-
std::string f_id;
91-
};
92-
93-
struct partial {};
94-
struct not_found {};
95-
96-
using match_result = mapbox::util::variant<found, partial, not_found>;
97-
98-
match_result match(const string_fragment& line);
99-
100-
std::vector<lnav::console::user_message> mm_details;
101-
102-
private:
103-
std::set<std::string> mm_partial_match_ids;
104-
size_t mm_line_count{0};
105-
};
106-
107-
} // namespace piper
108-
} // namespace lnav
82+
} // namespace lnav::piper
10983

11084
#endif

src/base/snippet_highlighters.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ regex_highlighter(attr_line_t& al, std::optional<int> x, line_range sub)
203203
}
204204
break;
205205
case '?': {
206-
struct line_range lr(lpc, lpc + 1);
206+
line_range lr(lpc, lpc + 1);
207207

208208
if (lpc == sub.lr_start || (lpc - sub.lr_start) == 0) {
209209
alb.overlay_attr_for_char(

src/command_executor.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,25 +1054,24 @@ sql_callback(exec_context& ec, sqlite3_stmt* stmt)
10541054
auto row_number = dls.dls_rows.size();
10551055
dls.dls_rows.resize(row_number + 1);
10561056
for (int lpc = 0; lpc < ncols; lpc++) {
1057-
auto* raw_value = sqlite3_column_value(stmt, lpc);
1058-
const auto value_type = sqlite3_value_type(raw_value);
1057+
const auto value_type = sqlite3_column_type(stmt, lpc);
10591058
scoped_value_t value;
10601059
auto& hm = dls.dls_headers[lpc];
10611060

10621061
switch (value_type) {
10631062
case SQLITE_INTEGER:
1064-
value = (int64_t) sqlite3_value_int64(raw_value);
1063+
value = (int64_t) sqlite3_column_int64(stmt, lpc);
10651064
break;
10661065
case SQLITE_FLOAT:
1067-
value = sqlite3_value_double(raw_value);
1066+
value = sqlite3_column_double(stmt, lpc);
10681067
break;
10691068
case SQLITE_NULL:
10701069
value = null_value_t{};
10711070
break;
10721071
default:
10731072
value = string_fragment::from_bytes(
1074-
sqlite3_value_text(raw_value),
1075-
sqlite3_value_bytes(raw_value));
1073+
sqlite3_column_text(stmt, lpc),
1074+
sqlite3_column_bytes(stmt, lpc));
10761075
break;
10771076
}
10781077
dls.push_column(value);
@@ -1082,6 +1081,7 @@ sql_callback(exec_context& ec, sqlite3_stmt* stmt)
10821081
{
10831082
switch (value_type) {
10841083
case SQLITE_TEXT:
1084+
auto *raw_value = sqlite3_column_value(stmt, lpc);
10851085
hm.hm_column_type = SQLITE_TEXT;
10861086
hm.hm_sub_type = sqlite3_value_subtype(raw_value);
10871087
break;
@@ -1121,22 +1121,22 @@ internal_sql_callback(exec_context& ec, sqlite3_stmt* stmt)
11211121
continue;
11221122
}
11231123

1124-
auto* raw_value = sqlite3_column_value(stmt, lpc);
11251124
auto value_type = sqlite3_column_type(stmt, lpc);
11261125
scoped_value_t value;
11271126
switch (value_type) {
11281127
case SQLITE_INTEGER:
1129-
value = (int64_t) sqlite3_value_int64(raw_value);
1128+
value = (int64_t) sqlite3_column_int64(stmt, lpc);
11301129
break;
11311130
case SQLITE_FLOAT:
1132-
value = sqlite3_value_double(raw_value);
1131+
value = sqlite3_column_double(stmt, lpc);
11331132
break;
11341133
case SQLITE_NULL:
11351134
value = null_value_t{};
11361135
break;
11371136
default:
1138-
value = std::string((const char*) sqlite3_value_text(raw_value),
1139-
sqlite3_value_bytes(raw_value));
1137+
value
1138+
= std::string((const char*) sqlite3_column_text(stmt, lpc),
1139+
sqlite3_column_bytes(stmt, lpc));
11401140
break;
11411141
}
11421142
vars[column_name] = value;

src/file_format.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "base/lnav_log.hh"
3939
#include "config.h"
4040
#include "line_buffer.hh"
41+
#include "piper.match.hh"
4142
#include "text_format.hh"
4243

4344
detect_file_format_result

src/line_buffer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#include "fmtlib/fmt/format.h"
6060
#include "hasher.hh"
6161
#include "line_buffer.hh"
62-
#include "piper.looper.hh"
62+
#include "piper.header.hh"
6363
#include "scn/scan.h"
6464

6565
using namespace std::chrono_literals;

src/lnav.management_cli.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#include "log_format.hh"
4949
#include "log_format_ext.hh"
5050
#include "mapbox/variant.hpp"
51-
#include "piper.looper.hh"
51+
#include "piper.header.hh"
5252
#include "regex101.import.hh"
5353
#include "session_data.hh"
5454

0 commit comments

Comments
 (0)