Fix compilation on GCC
This commit is contained in:
parent
74a3eb2ae0
commit
0dd921cd5d
|
@ -266,7 +266,7 @@ long MastodonClient::_response_status_code() {
|
|||
static void lowercase(std::string& str) {
|
||||
for (size_t i = 0; i < str.size(); i++) {
|
||||
if (str[i] >= 'A' && str[i] <= 'Z') {
|
||||
str[i] = str[i] - 'A' + 'a';
|
||||
str[i] = str[i] - static_cast<char>('A' + 'a');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
#include <lexbor/html/html.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
|
@ -49,13 +50,13 @@ public:
|
|||
lxb_html_document_destroy(this->_document);
|
||||
}
|
||||
|
||||
constexpr lxb_dom_node_t* body() const noexcept {
|
||||
inline lxb_dom_node_t* body() const noexcept {
|
||||
lxb_dom_node_t* node = lxb_dom_interface_node(this->_document);
|
||||
lxb_dom_node_t* html = lxb_dom_node_first_child(node);
|
||||
lxb_dom_node_t* body = lxb_dom_node_last_child(html);
|
||||
return body;
|
||||
}
|
||||
constexpr lxb_dom_element_t* body_element() const noexcept {
|
||||
inline lxb_dom_element_t* body_element() const noexcept {
|
||||
lxb_dom_node_t* body = this->body();
|
||||
assert(body->type == LXB_DOM_NODE_TYPE_ELEMENT);
|
||||
return lxb_dom_interface_element(body);
|
||||
|
|
|
@ -159,9 +159,12 @@ time_t parse_rfc3339(const std::string& str) {
|
|||
.tm_mday = to_int(sm.str(3)),
|
||||
.tm_mon = to_int(sm.str(2)) - 1,
|
||||
.tm_year = to_int(sm.str(1)) - 1900,
|
||||
.tm_wday = -1,
|
||||
.tm_yday = -1,
|
||||
|
||||
.tm_isdst = -1,
|
||||
.tm_gmtoff = !sm.str(7).empty() ? 0 : to_int(sm.str(8)) * 60 * 60 + to_int(sm.str(9)) * 60,
|
||||
.tm_zone = nullptr,
|
||||
};
|
||||
time_t time = mktime(&tm);
|
||||
if (time == -1) {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
static inline void preprocess_html(const httplib::Request& req, const std::string& domain_name, const std::vector<Emoji>& emojis, lxb_dom_element_t* element);
|
||||
static inline void preprocess_link(const httplib::Request& req, const std::string& domain_name, lxb_dom_element_t* element);
|
||||
static inline bool should_fix_link(lxb_dom_element_t* element, const std::string& cls);
|
||||
static inline bool should_fix_link(lxb_dom_element_t* element, const std::string& element_cls);
|
||||
static inline lxb_dom_node_t* emojify(lxb_dom_node_t* child, const std::vector<Emoji>& emojis);
|
||||
static inline std::vector<lxb_dom_node*> emojify(lxb_dom_document_t* document, std::string str, const std::vector<Emoji>& emojis);
|
||||
|
||||
|
@ -133,9 +133,13 @@ std::string proxy_mastodon_url(const httplib::Request& req, const std::string& u
|
|||
throw std::bad_alloc();
|
||||
}
|
||||
|
||||
CURLUcode code = curl_url_set(url.get(), CURLUPART_URL, url_str.c_str(), 0);
|
||||
if (code) {
|
||||
throw CurlUrlException(code);
|
||||
// in a block to avoid a (potential) gcc bug where it thinks the lambda below
|
||||
// shadows `code`, even if i do `[&url](...) { ... }`
|
||||
{
|
||||
CURLUcode code = curl_url_set(url.get(), CURLUPART_URL, url_str.c_str(), 0);
|
||||
if (code) {
|
||||
throw CurlUrlException(code);
|
||||
}
|
||||
}
|
||||
|
||||
auto get_part = [&](CURLUPart part, CURLUcode ignore = CURLUE_OK) {
|
||||
|
@ -266,9 +270,9 @@ static inline void preprocess_link(const httplib::Request& req, const std::strin
|
|||
}
|
||||
|
||||
static std::regex unhandled_link_re("\\bunhandled-link\\b");
|
||||
static inline bool should_fix_link(lxb_dom_element_t* element, const std::string& cls) {
|
||||
static inline bool should_fix_link(lxb_dom_element_t* element, const std::string& element_cls) {
|
||||
// https://vt.social/@LucydiaLuminous/111448085044245037
|
||||
if (std::regex_search(cls, unhandled_link_re)) {
|
||||
if (std::regex_search(element_cls, unhandled_link_re)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue