suppressed a few wasteful string-cstr conversions
This commit is contained in:
parent
0460f1016c
commit
022e0e5f43
@ -62,7 +62,7 @@ Address::Address(const string &wholeaddress)
|
||||
if (start != string::npos)
|
||||
name = wholeaddress.substr(0, start);
|
||||
else
|
||||
name = "";
|
||||
name = string();
|
||||
trim(name);
|
||||
trim(name, "\"");
|
||||
|
||||
@ -79,11 +79,11 @@ Address::Address(const string &wholeaddress)
|
||||
string Address::toParenList(void) const
|
||||
{
|
||||
string tmp = "(";
|
||||
tmp += name == "" ? "NIL" : toImapString(name);
|
||||
tmp += name.empty() ? "NIL" : toImapString(name);
|
||||
tmp += " NIL ";
|
||||
tmp += local == "" ? "\"\"" : toImapString(local);
|
||||
tmp += local.empty() ? "\"\"" : toImapString(local);
|
||||
tmp += " ";
|
||||
tmp += host == "" ? "\"\"" : toImapString(host);
|
||||
tmp += host.empty() ? "\"\"" : toImapString(host);
|
||||
tmp += ")";
|
||||
|
||||
return tmp;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: mh_mail.cpp,v 1.32 2008-07-01 10:29:45 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: mh_mail.cpp,v 1.33 2008-07-01 11:51:51 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -45,6 +45,11 @@ static char rcsid[] = "@(#$Id: mh_mail.cpp,v 1.32 2008-07-01 10:29:45 dockes Exp
|
||||
using namespace std;
|
||||
|
||||
static const int maxdepth = 20;
|
||||
static const string cstr_mimetype = "mimetype";
|
||||
static const string cstr_content = "content";
|
||||
static const string cstr_author = "author";
|
||||
static const string cstr_modificationdate = "modificationdate";
|
||||
static const string cstr_title = "title";
|
||||
|
||||
MimeHandlerMail::~MimeHandlerMail()
|
||||
{
|
||||
@ -126,10 +131,10 @@ bool MimeHandlerMail::next_document()
|
||||
bool res = false;
|
||||
|
||||
if (m_idx == -1) {
|
||||
m_metaData["mimetype"] = "text/plain";
|
||||
m_metaData[cstr_mimetype] = "text/plain";
|
||||
res = processMsg(m_bincdoc, 0);
|
||||
LOGDEB1(("MimeHandlerMail::next_document: mimetype %s\n",
|
||||
m_metaData["mimetype"].c_str()));
|
||||
m_metaData[cstr_mimetype].c_str()));
|
||||
} else {
|
||||
res = processAttach();
|
||||
}
|
||||
@ -181,18 +186,18 @@ bool MimeHandlerMail::processAttach()
|
||||
}
|
||||
MHMailAttach *att = m_attachments[m_idx];
|
||||
|
||||
m_metaData["mimetype"] = att->m_contentType;
|
||||
m_metaData[cstr_mimetype] = att->m_contentType;
|
||||
m_metaData["charset"] = att->m_charset;
|
||||
m_metaData["filename"] = att->m_filename;
|
||||
// Change the title to something helpul
|
||||
m_metaData["title"] = att->m_filename + " (" + m_subject + ")";
|
||||
m_metaData[cstr_title] = att->m_filename + " (" + m_subject + ")";
|
||||
LOGDEB1((" processAttach:ct [%s] cs [%s] fn [%s]\n",
|
||||
att->m_contentType.c_str(),
|
||||
att->m_charset.c_str(),
|
||||
att->m_filename.c_str()));
|
||||
|
||||
m_metaData["content"] = string();
|
||||
string& body = m_metaData["content"];
|
||||
m_metaData[cstr_content] = string();
|
||||
string& body = m_metaData[cstr_content];
|
||||
att->m_part->getBody(body, 0, att->m_part->bodylength);
|
||||
string decoded;
|
||||
const string *bdp;
|
||||
@ -205,7 +210,7 @@ bool MimeHandlerMail::processAttach()
|
||||
// Special case for text/plain content. Internfile should deal
|
||||
// with this but it expects text/plain to be utf-8 already, so we
|
||||
// handle the transcoding if needed
|
||||
if (m_metaData["mimetype"] == "text/plain" &&
|
||||
if (m_metaData[cstr_mimetype] == "text/plain" &&
|
||||
stringicmp(m_metaData["charset"], "UTF-8")) {
|
||||
string utf8;
|
||||
if (!transcode(body, utf8, m_metaData["charset"], "UTF-8")) {
|
||||
@ -219,12 +224,12 @@ bool MimeHandlerMail::processAttach()
|
||||
|
||||
// Special case for application/octet-stream: try to better
|
||||
// identify content, using file name if set
|
||||
if (m_metaData["mimetype"] == "application/octet-stream" &&
|
||||
if (m_metaData[cstr_mimetype] == "application/octet-stream" &&
|
||||
!m_metaData["filename"].empty()) {
|
||||
string mt = mimetype(m_metaData["filename"], 0,
|
||||
RclConfig::getMainConfig(), false);
|
||||
if (!mt.empty())
|
||||
m_metaData["mimetype"] = mt;
|
||||
m_metaData[cstr_mimetype] = mt;
|
||||
}
|
||||
|
||||
// Ipath
|
||||
@ -254,14 +259,14 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth)
|
||||
}
|
||||
|
||||
// Handle some headers.
|
||||
string& text = m_metaData["content"];
|
||||
string& text = m_metaData[cstr_content];
|
||||
Binc::HeaderItem hi;
|
||||
string transcoded;
|
||||
if (doc->h.getFirstHeader("From", hi)) {
|
||||
rfc2047_decode(hi.getValue(), transcoded);
|
||||
text += string("From: ") + transcoded + string("\n");
|
||||
if (depth == 1) {
|
||||
m_metaData["author"] = transcoded;
|
||||
m_metaData[cstr_author] = transcoded;
|
||||
}
|
||||
}
|
||||
if (doc->h.getFirstHeader("To", hi)) {
|
||||
@ -275,7 +280,7 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth)
|
||||
if (t != (time_t)-1) {
|
||||
char ascuxtime[100];
|
||||
sprintf(ascuxtime, "%ld", (long)t);
|
||||
m_metaData["modificationdate"] = ascuxtime;
|
||||
m_metaData[cstr_modificationdate] = ascuxtime;
|
||||
} else {
|
||||
// Leave mtime field alone, ftime will be used instead.
|
||||
LOGDEB(("rfc2822Date...: failed: [%s]\n", transcoded.c_str()));
|
||||
@ -286,7 +291,7 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth)
|
||||
if (doc->h.getFirstHeader("Subject", hi)) {
|
||||
rfc2047_decode(hi.getValue(), transcoded);
|
||||
if (depth == 1) {
|
||||
m_metaData["title"] = transcoded;
|
||||
m_metaData[cstr_title] = transcoded;
|
||||
m_subject = transcoded;
|
||||
}
|
||||
text += string("Subject: ") + transcoded + string("\n");
|
||||
@ -298,7 +303,7 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth)
|
||||
walkmime(doc, depth);
|
||||
|
||||
LOGDEB2(("MimeHandlerMail::processMsg:text:[%s]\n",
|
||||
m_metaData["content"].c_str()));
|
||||
m_metaData[cstr_content].c_str()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -320,7 +325,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
|
||||
return;
|
||||
}
|
||||
|
||||
string& out = m_metaData["content"];
|
||||
string& out = m_metaData[cstr_content];
|
||||
|
||||
if (doc->isMultipart()) {
|
||||
LOGDEB2(("walkmime: ismultipart %d subtype '%s'\n",
|
||||
@ -512,7 +517,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
|
||||
mh.set_document_string(body);
|
||||
mh.next_document();
|
||||
map<string, string>::const_iterator it =
|
||||
mh.get_meta_data().find("content");
|
||||
mh.get_meta_data().find(cstr_content);
|
||||
if (it != mh.get_meta_data().end())
|
||||
out += it->second;
|
||||
} else {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: wasastringtoquery.cpp,v 1.6 2007-11-16 12:21:46 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: wasastringtoquery.cpp,v 1.7 2008-07-01 11:51:51 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -44,7 +44,7 @@ WasaQuery::~WasaQuery()
|
||||
void WasaQuery::describe(string &desc) const
|
||||
{
|
||||
desc += "(";
|
||||
string fieldspec = m_fieldspec.empty() ? "" : m_fieldspec + ": ";
|
||||
string fieldspec = m_fieldspec.empty() ? string() : m_fieldspec + ": ";
|
||||
switch (m_op) {
|
||||
case OP_NULL:
|
||||
desc += "NULL";
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: xadump.cpp,v 1.17 2008-04-18 11:39:47 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: xadump.cpp,v 1.18 2008-07-01 11:51:51 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -168,8 +168,8 @@ int main(int argc, char **argv)
|
||||
if (op_flags & OPT_T) {
|
||||
Xapian::TermIterator term;
|
||||
string printable;
|
||||
string op = (op_flags & OPT_n) ? "": "[";
|
||||
string cl = (op_flags & OPT_n) ? "": "]";
|
||||
string op = (op_flags & OPT_n) ? string(): "[";
|
||||
string cl = (op_flags & OPT_n) ? string(): "]";
|
||||
if (op_flags & OPT_i) {
|
||||
for (term = db->termlist_begin(docid);
|
||||
term != db->termlist_end(docid);term++) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.133 2008-06-13 18:22:46 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.134 2008-07-01 11:51:51 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -122,7 +122,7 @@ bool Db::Native::subDocs(const string &hash, vector<Xapian::docid>& docids)
|
||||
if (ermsg.empty())
|
||||
ermsg = "Empty error message";
|
||||
} catch (const char *s) {
|
||||
ermsg = s ? s : "";
|
||||
ermsg = s ? s : string();
|
||||
if (ermsg.empty())
|
||||
ermsg = "Empty error message";
|
||||
} catch (...) {
|
||||
@ -202,7 +202,7 @@ string Db::Native::makeAbstract(Xapian::docid docid, Query *query)
|
||||
|
||||
list<string> terms = noPrefixList(iterms);
|
||||
if (terms.empty()) {
|
||||
return "";
|
||||
return string();
|
||||
}
|
||||
|
||||
// Retrieve db-wide frequencies for the query terms
|
||||
@ -289,7 +289,7 @@ string Db::Native::makeAbstract(Xapian::docid docid, Query *query)
|
||||
// This can't happen, but would crash us
|
||||
if (totalweight == 0.0) {
|
||||
LOGERR(("makeAbstract: 0 totalweight!\n"));
|
||||
return "";
|
||||
return string();
|
||||
}
|
||||
|
||||
// Let's go populate
|
||||
@ -348,7 +348,7 @@ string Db::Native::makeAbstract(Xapian::docid docid, Query *query)
|
||||
// This can happen if there are term occurences in the keywords
|
||||
// etc. but not elsewhere ?
|
||||
if (qtermposs.size() == 0)
|
||||
return "";
|
||||
return string();
|
||||
|
||||
// Walk all document's terms position lists and populate slots
|
||||
// around the query terms. We arbitrarily truncate the list to
|
||||
@ -593,7 +593,7 @@ bool Db::reOpen()
|
||||
if (m_ndb && m_ndb->m_isopen) {
|
||||
if (!close())
|
||||
return false;
|
||||
if (!open(m_basedir, "", m_mode, true)) {
|
||||
if (!open(m_basedir, string(), m_mode, true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -684,7 +684,7 @@ bool Db::fieldToPrefix(const string& fldname, string &pfx)
|
||||
// This is the default table
|
||||
static map<string, string> fldToPrefs;
|
||||
if (fldToPrefs.empty()) {
|
||||
fldToPrefs["abstract"] = "";
|
||||
fldToPrefs["abstract"] = string();
|
||||
fldToPrefs["ext"] = "XE";
|
||||
|
||||
fldToPrefs["title"] = "S";
|
||||
@ -778,14 +778,14 @@ bool mySplitterCB::takeword(const std::string &term, int pos, int, int)
|
||||
// want to stop indexation because of a bad string
|
||||
bool dumb_string(const string &in, string &out)
|
||||
{
|
||||
out.erase();
|
||||
out.clear();
|
||||
if (in.empty())
|
||||
return true;
|
||||
|
||||
string s1 = neutchars(in, "\n\r");
|
||||
if (!unacmaybefold(s1, out, "UTF-8", true)) {
|
||||
LOGINFO(("dumb_string: unac failed for [%s]\n", in.c_str()));
|
||||
out.erase();
|
||||
out.clear();
|
||||
// See comment at start of func
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.2 2008-07-01 08:31:08 dockes Exp $ (C) 2008 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.3 2008-07-01 11:51:51 dockes Exp $ (C) 2008 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
@ -101,7 +101,7 @@ bool Query::setQuery(RefCntr<SearchData> sdata, int opts,
|
||||
}
|
||||
|
||||
Xapian::Query xq;
|
||||
if (!sdata->toNativeQuery(*m_db, &xq, (opts & QO_STEM) ? stemlang : "")) {
|
||||
if (!sdata->toNativeQuery(*m_db, &xq, (opts & QO_STEM) ? stemlang : string())) {
|
||||
m_reason += sdata->getReason();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _SEARCHDATA_H_INCLUDED_
|
||||
#define _SEARCHDATA_H_INCLUDED_
|
||||
/* @(#$Id: searchdata.h,v 1.14 2008-06-13 18:22:46 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: searchdata.h,v 1.15 2008-07-01 11:51:51 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
/**
|
||||
* Structures to hold data coming almost directly from the gui
|
||||
@ -160,7 +160,7 @@ protected:
|
||||
class SearchDataClauseSimple : public SearchDataClause {
|
||||
public:
|
||||
SearchDataClauseSimple(SClType tp, const string& txt,
|
||||
const string& fld = "")
|
||||
const string& fld = string())
|
||||
: SearchDataClause(tp), m_text(txt), m_field(fld), m_slack(0) {
|
||||
m_haveWildCards = (txt.find_first_of("*?[") != string::npos);
|
||||
}
|
||||
@ -212,7 +212,7 @@ public:
|
||||
class SearchDataClauseDist : public SearchDataClauseSimple {
|
||||
public:
|
||||
SearchDataClauseDist(SClType tp, const string& txt, int slack,
|
||||
const string& fld = "")
|
||||
const string& fld = string())
|
||||
: SearchDataClauseSimple(tp, txt, fld) {m_slack = slack;}
|
||||
virtual ~SearchDataClauseDist() {}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid [] = "@(#$Id: conftree.cpp,v 1.15 2007-12-13 06:58:22 dockes Exp $ (C) 2003 J.F.Dockes";
|
||||
static char rcsid [] = "@(#$Id: conftree.cpp,v 1.16 2008-07-01 11:51:51 dockes Exp $ (C) 2003 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -389,7 +389,7 @@ ConfSimple::sortwalk(WalkerCode (*walker)(void *,const string&,const string&),
|
||||
sit != m_submaps.end(); sit++) {
|
||||
|
||||
// Possibly emit submap name:
|
||||
if (!sit->first.empty() && walker(clidata, "", sit->first.c_str())
|
||||
if (!sit->first.empty() && walker(clidata, string(), sit->first.c_str())
|
||||
== WALK_STOP)
|
||||
return WALK_STOP;
|
||||
|
||||
@ -539,7 +539,7 @@ int ConfTree::get(const std::string &name, string &value, const string &sk)
|
||||
return 1;
|
||||
string::size_type pos = msk.rfind("/");
|
||||
if (pos != string::npos) {
|
||||
msk.replace(pos, string::npos, "");
|
||||
msk.replace(pos, string::npos, string());
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
@ -95,9 +95,9 @@ public:
|
||||
enum StatusCode {STATUS_ERROR=0, STATUS_RO=1, STATUS_RW=2};
|
||||
virtual ~ConfNull() {};
|
||||
virtual int get(const string &name, string &value,
|
||||
const string &sk = "") = 0;
|
||||
const string &sk = string()) = 0;
|
||||
virtual int set(const string &nm, const string &val,
|
||||
const string &sk = "") = 0;
|
||||
const string &sk = string()) = 0;
|
||||
virtual bool ok() = 0;
|
||||
virtual list<string> getNames(const string &sk) = 0;
|
||||
virtual int erase(const string &, const string &) = 0;
|
||||
@ -156,13 +156,13 @@ public:
|
||||
* global space if sk is empty).
|
||||
* @return 0 if name not found, 1 else
|
||||
*/
|
||||
virtual int get(const string &name, string &value, const string &sk = "");
|
||||
virtual int get(const string &name, string &value, const string &sk = string());
|
||||
|
||||
/**
|
||||
* Set value for named parameter in specified subsection (or global)
|
||||
* @return 0 for error, 1 else
|
||||
*/
|
||||
virtual int set(const string &nm, const string &val, const string &sk = "");
|
||||
virtual int set(const string &nm, const string &val, const string &sk = string());
|
||||
|
||||
/**
|
||||
* Remove name and value from config
|
||||
@ -363,7 +363,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual int set(const string &nm, const string &val, const string &sk = "")
|
||||
virtual int set(const string &nm, const string &val, const string &sk = string())
|
||||
{
|
||||
if (!m_ok)
|
||||
return 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: idfile.cpp,v 1.8 2008-05-21 07:21:37 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: idfile.cpp,v 1.9 2008-07-01 11:51:51 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -68,7 +68,7 @@ string idFile(const char *fn)
|
||||
input.open(fn, ios::in);
|
||||
if (!input.is_open()) {
|
||||
LOGERR(("idFile: could not open [%s]\n", fn));
|
||||
return string("");
|
||||
return string();
|
||||
}
|
||||
|
||||
bool line1HasFrom = false;
|
||||
@ -88,7 +88,7 @@ string idFile(const char *fn)
|
||||
if (input.fail()) {
|
||||
if (input.bad()) {
|
||||
LOGERR(("idfile: error while reading [%s]\n", fn));
|
||||
return string("");
|
||||
return string();
|
||||
}
|
||||
// Must be eof ?
|
||||
break;
|
||||
@ -121,7 +121,7 @@ string idFile(const char *fn)
|
||||
// emacs vm can insert VERY long header lines.
|
||||
if (ll > 800) {
|
||||
LOGDEB2(("idFile: Line too long\n"));
|
||||
return string("");
|
||||
return string();
|
||||
}
|
||||
|
||||
// Check for mbox 'From ' line
|
||||
@ -159,7 +159,7 @@ string idFile(const char *fn)
|
||||
if (lookslikemail >= wantnhead)
|
||||
return line1HasFrom ? string("text/x-mail") : string("message/rfc822");
|
||||
|
||||
return string("");
|
||||
return string();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: mimeparse.cpp,v 1.20 2007-12-13 06:58:22 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: mimeparse.cpp,v 1.21 2008-07-01 11:51:51 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -360,7 +360,7 @@ bool parseMimeHeaderValue(const string& value, MimeHeaderValue& parsed)
|
||||
string nm = it->first;
|
||||
// Create the name entry
|
||||
if (parsed.params.find(nm) == parsed.params.end())
|
||||
parsed.params[nm] = "";
|
||||
parsed.params[nm].clear();
|
||||
// Concatenate all chunks and decode the whole if the first one needs
|
||||
// to. Yes, this is not quite right.
|
||||
string value;
|
||||
@ -437,7 +437,7 @@ static bool rfc2047_decodeParsed(const std::string& charset,
|
||||
{
|
||||
DPRINT((stderr, "DecodeParsed: charset [%s] enc [%s] val [%s]\n",
|
||||
charset.c_str(), encoding.c_str(), value.c_str()));
|
||||
utf8 = "";
|
||||
utf8.clear();
|
||||
|
||||
string decoded;
|
||||
if (!stringlowercmp("b", encoding)) {
|
||||
@ -485,7 +485,7 @@ bool rfc2047_decode(const std::string& in, std::string &out)
|
||||
Rfc2047States state = rfc2047ready;
|
||||
string encoding, charset, value, utf8;
|
||||
|
||||
out = "";
|
||||
out.clear();
|
||||
|
||||
for (string::size_type ii = 0; ii < in.length(); ii++) {
|
||||
char ch = in[ii];
|
||||
@ -523,7 +523,7 @@ bool rfc2047_decode(const std::string& in, std::string &out)
|
||||
if (value.length() > 0) {
|
||||
transcode(value, utf8, "ISO-8859-1", "UTF-8");
|
||||
out += utf8;
|
||||
value = "";
|
||||
value.clear();
|
||||
}
|
||||
state = rfc2047charset;
|
||||
}
|
||||
@ -568,7 +568,9 @@ bool rfc2047_decode(const std::string& in, std::string &out)
|
||||
return false;
|
||||
}
|
||||
out += utf8;
|
||||
charset = encoding = value = "";
|
||||
charset.clear();
|
||||
encoding.clear();
|
||||
value.clear();
|
||||
}
|
||||
break;
|
||||
default: state = rfc2047value; value += '?';value += ch;break;
|
||||
@ -583,7 +585,7 @@ bool rfc2047_decode(const std::string& in, std::string &out)
|
||||
if (value.length() > 0) {
|
||||
transcode(value, utf8, "ISO-8859-1", "UTF-8");
|
||||
out += utf8;
|
||||
value = "";
|
||||
value.clear();
|
||||
}
|
||||
if (state != rfc2047base)
|
||||
return false;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: pathut.cpp,v 1.21 2008-07-01 08:26:08 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: pathut.cpp,v 1.22 2008-07-01 11:51:51 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -273,7 +273,7 @@ extern std::string path_absolute(const std::string &is)
|
||||
if (s[0] != '/') {
|
||||
char buf[MAXPATHLEN];
|
||||
if (!getcwd(buf, MAXPATHLEN)) {
|
||||
return "";
|
||||
return string();
|
||||
}
|
||||
s = path_cat(string(buf), s);
|
||||
}
|
||||
@ -289,7 +289,7 @@ extern std::string path_canon(const std::string &is)
|
||||
if (s[0] != '/') {
|
||||
char buf[MAXPATHLEN];
|
||||
if (!getcwd(buf, MAXPATHLEN)) {
|
||||
return "";
|
||||
return string();
|
||||
}
|
||||
s = path_cat(string(buf), s);
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _PATHUT_H_INCLUDED_
|
||||
#define _PATHUT_H_INCLUDED_
|
||||
/* @(#$Id: pathut.h,v 1.14 2008-07-01 08:26:08 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: pathut.h,v 1.15 2008-07-01 11:51:51 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
@ -34,7 +34,7 @@ extern string path_cat(const string &s1, const string &s2);
|
||||
/// Get the simple file name (get rid of any directory path prefix
|
||||
extern string path_getsimple(const string &s);
|
||||
/// Simple file name + optional suffix stripping
|
||||
extern string path_basename(const string &s, const string &suff="");
|
||||
extern string path_basename(const string &s, const string &suff=string());
|
||||
/// Get the father directory
|
||||
extern string path_getfather(const string &s);
|
||||
/// Get the current user's home directory
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: smallut.cpp,v 1.28 2008-05-08 09:57:29 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: smallut.cpp,v 1.29 2008-07-01 11:51:51 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -185,7 +185,7 @@ template <class T> bool stringToStrings(const string &s, T &tokens)
|
||||
continue;
|
||||
case INQUOTE:
|
||||
tokens.push_back(current);
|
||||
current = "";
|
||||
current.clear();
|
||||
state = SPACE;
|
||||
continue;
|
||||
case ESCAPE:
|
||||
@ -220,7 +220,7 @@ template <class T> bool stringToStrings(const string &s, T &tokens)
|
||||
continue;
|
||||
case TOKEN:
|
||||
tokens.push_back(current);
|
||||
current = "";
|
||||
current.clear();
|
||||
state = SPACE;
|
||||
continue;
|
||||
case INQUOTE:
|
||||
@ -336,14 +336,14 @@ void trimstring(string &s, const char *ws)
|
||||
{
|
||||
string::size_type pos = s.find_first_not_of(ws);
|
||||
if (pos == string::npos) {
|
||||
s = "";
|
||||
s.clear();
|
||||
return;
|
||||
}
|
||||
s.replace(0, pos, "");
|
||||
s.replace(0, pos, string());
|
||||
|
||||
pos = s.find_last_not_of(ws);
|
||||
if (pos != string::npos && pos != s.length()-1)
|
||||
s.replace(pos+1, string::npos, "");
|
||||
s.replace(pos+1, string::npos, string());
|
||||
}
|
||||
|
||||
// Remove some chars and replace them with spaces
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user