Replaced more regular expressions with search & replace.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
344e77d8bf
commit
32040c277c
12
src/csv.cpp
12
src/csv.cpp
|
@ -14,14 +14,11 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <regex>
|
|
||||||
#include "time.hpp"
|
#include "time.hpp"
|
||||||
#include "export.hpp"
|
#include "export.hpp"
|
||||||
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::regex;
|
|
||||||
using std::regex_replace;
|
|
||||||
|
|
||||||
void export_csv(const vector<Database::entry> &entries, ostream &out)
|
void export_csv(const vector<Database::entry> &entries, ostream &out)
|
||||||
{
|
{
|
||||||
|
@ -55,7 +52,12 @@ void export_csv(const vector<Database::entry> &entries, ostream &out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const string quote_csv(const string &field)
|
const string quote_csv(string field)
|
||||||
{
|
{
|
||||||
return regex_replace(field, regex("\""), "\"\"");
|
size_t pos = 0;
|
||||||
|
while ((pos = field.find('"', pos)) != std::string::npos)
|
||||||
|
{
|
||||||
|
field.replace(pos, 1, "\"\"");
|
||||||
|
}
|
||||||
|
return field;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ using std::cout;
|
||||||
|
|
||||||
void export_csv(const vector<Database::entry> &entries, ostream &out = cout);
|
void export_csv(const vector<Database::entry> &entries, ostream &out = cout);
|
||||||
//! replaces " with "".
|
//! replaces " with "".
|
||||||
const string quote_csv(const string &field);
|
const string quote_csv(string field);
|
||||||
|
|
||||||
void export_adoc(const vector<Database::entry> &entries, ostream &out = cout);
|
void export_adoc(const vector<Database::entry> &entries, ostream &out = cout);
|
||||||
//! Replaces characters in tags that asciidoctor doesn't like.
|
//! Replaces characters in tags that asciidoctor doesn't like.
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <regex>
|
|
||||||
#include <basedir.h>
|
#include <basedir.h>
|
||||||
#include <sqlite/execute.hpp>
|
#include <sqlite/execute.hpp>
|
||||||
#include <sqlite/query.hpp>
|
#include <sqlite/query.hpp>
|
||||||
|
@ -26,8 +25,6 @@
|
||||||
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::regex;
|
|
||||||
using std::regex_replace;
|
|
||||||
|
|
||||||
Database::Database()
|
Database::Database()
|
||||||
: _connected(false)
|
: _connected(false)
|
||||||
|
@ -75,7 +72,13 @@ bool operator ==(const Database::entry &a, const Database::entry &b)
|
||||||
|
|
||||||
const string Database::entry::fulltext_oneline() const
|
const string Database::entry::fulltext_oneline() const
|
||||||
{
|
{
|
||||||
return regex_replace(fulltext, regex("\n"), "\\n");
|
string oneline = fulltext;
|
||||||
|
size_t pos = 0;
|
||||||
|
while ((pos = oneline.find('\n', pos)) != std::string::npos)
|
||||||
|
{
|
||||||
|
oneline.replace(pos, 1, "\\n");
|
||||||
|
}
|
||||||
|
return oneline;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::store(const Database::entry &data) const
|
void Database::store(const Database::entry &data) const
|
||||||
|
|
|
@ -119,7 +119,7 @@ const string URI::strip_html(const string &html)
|
||||||
out = remove_html_tags(out); // Remove tags.
|
out = remove_html_tags(out); // Remove tags.
|
||||||
|
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
while ((pos = out.find("\r")) != std::string::npos) // Remove CR.
|
while ((pos = out.find("\r", pos)) != std::string::npos) // Remove CR.
|
||||||
{
|
{
|
||||||
out.replace(pos, 1, "");
|
out.replace(pos, 1, "");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue