From 0fe04040a7500825b39a60f73c25c3ab687bf6c0 Mon Sep 17 00:00:00 2001 From: tastytea Date: Tue, 6 Feb 2018 13:53:34 +0100 Subject: [PATCH] small fixes --- CMakeLists.txt | 2 +- src/rss2mastodon.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a9ab89..c9a6182 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.7) include(GNUInstallDirs) project (rss2mastodon - VERSION 0.1.7 + VERSION 0.1.8 LANGUAGES CXX ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall") diff --git a/src/rss2mastodon.cpp b/src/rss2mastodon.cpp index ad0ec77..7c3f2a4 100644 --- a/src/rss2mastodon.cpp +++ b/src/rss2mastodon.cpp @@ -37,7 +37,7 @@ using std::cout; using std::cerr; using std::string; -uint16_t max_size = 500; +std::uint16_t max_size = 500; const string filepath = string(getenv("HOME")) + "/.config/rss2mastodon/"; void read_config(pt::ptree &config, const string &profile, string &instance, string &access_token, string &feedurl) @@ -161,12 +161,12 @@ std::vector parse_website(const string &profile, const string &xml) for (const string &hashtag : watchwords) { - std::regex rehashtag("([[:space:][:punct:]^])(" + hashtag + ")([[:space:][:punct:]$])", + std::regex rehashtag("([[:space:][:punct:]]|^)(" + hashtag + ")([[:space:][:punct:]]|$)", std::regex_constants::icase); str = std::regex_replace(str, rehashtag, "$1#$2$3", std::regex_constants::format_first_only); } - if ((str.size() + link.size()) > (max_size - 15)) + if ((str.size() + link.size()) > (std::uint16_t)(max_size - 15)) { str.resize((max_size - link.size() - 15)); str += " […]"; @@ -209,7 +209,8 @@ int main(int argc, char *argv[]) string answer; string last_entry = config.get(profile + ".last_entry", ""); std::vector entries; - ret = http_get(hostname, path, answer); + //FIXME: User-Agent + ret = http_get(hostname, path, answer, "rss2mastodon/experimental"); if (ret != 0) { return ret;