const string cleanup

This commit is contained in:
Jean-Francois Dockes
2011-10-01 16:39:38 +02:00
parent 7f0ca13e7f
commit 38e0957962
29 changed files with 268 additions and 170 deletions
+20 -20
View File
@@ -20,7 +20,7 @@
#include <sys/types.h>
#include <string.h>
#include "autoconfig.h"
#include "cstr.h"
#include "pathut.h"
#include "debuglog.h"
#include "fstreewalk.h"
@@ -127,11 +127,11 @@ public:
confstr += line + "\n";
}
ConfSimple fields(confstr, 1);
list<string> names = fields.getNames("");
list<string> names = fields.getNames(cstr_null);
for (list<string>::iterator it = names.begin();
it != names.end(); it++) {
string value;
fields.get(*it, value, "");
fields.get(*it, value, cstr_null);
if (!value.compare("undefined") || !value.compare("null"))
continue;
@@ -158,10 +158,10 @@ public:
// something homogenous and easy to save.
for (map<string,string>::const_iterator it = doc.meta.begin();
it != doc.meta.end(); it++) {
m_fields.set((*it).first, (*it).second, "");
m_fields.set((*it).first, (*it).second, cstr_null);
}
m_fields.set("url", doc.url, "");
m_fields.set("mimetype", doc.mimetype, "");
m_fields.set(cstr_url, doc.url, cstr_null);
m_fields.set(cstr_mimetype, doc.mimetype, cstr_null);
return true;
}
@@ -215,10 +215,10 @@ bool BeagleQueueIndexer::indexFromCache(const string& udi)
if (!stringlowercmp("bookmark", hittype)) {
// Just index the dotdoc
dotdoc.meta[Rcl::Doc::keybcknd] = "BGL";
return m_db->addOrUpdate(udi, "", dotdoc);
return m_db->addOrUpdate(udi, cstr_null, dotdoc);
} else if (stringlowercmp("webhistory", dotdoc.meta[Rcl::Doc::keybght]) ||
(dotdoc.mimetype.compare("text/html") &&
dotdoc.mimetype.compare("text/plain"))) {
dotdoc.mimetype.compare(cstr_textplain))) {
LOGDEB(("BeagleQueueIndexer: skipping: hittype %s mimetype %s\n",
dotdoc.meta[Rcl::Doc::keybght].c_str(), dotdoc.mimetype.c_str()));
return true;
@@ -243,9 +243,9 @@ bool BeagleQueueIndexer::indexFromCache(const string& udi)
doc.fmtime = dotdoc.fmtime;
doc.url = dotdoc.url;
doc.fbytes = dotdoc.fbytes;
doc.sig = "";
doc.sig.clear();
doc.meta[Rcl::Doc::keybcknd] = "BGL";
return m_db->addOrUpdate(udi, "", doc);
return m_db->addOrUpdate(udi, cstr_null, doc);
}
}
@@ -289,7 +289,7 @@ bool BeagleQueueIndexer::index()
}
if (udi.empty())
continue;
if (m_db->needUpdate(udi, "")) {
if (m_db->needUpdate(udi, cstr_null)) {
try {
// indexFromCache does a CirCache::get(). We could
// arrange to use a getCurrent() instead, would be more
@@ -390,7 +390,7 @@ BeagleQueueIndexer::processone(const string &path,
// Have to use the hit type for the udi, because the same url can exist
// as a bookmark or a page.
udipath = path_cat(dotdoc.meta[Rcl::Doc::keybght], url_gpath(dotdoc.url));
make_udi(udipath, "", udi);
make_udi(udipath, cstr_null, udi);
LOGDEB(("BeagleQueueIndexer: prc1: udi [%s]\n", udi.c_str()));
char ascdate[30];
@@ -408,15 +408,15 @@ BeagleQueueIndexer::processone(const string &path,
dotdoc.fbytes = cbuf;
// Document signature for up to date checks: none.
dotdoc.sig = "";
dotdoc.sig.clear();
dotdoc.meta[Rcl::Doc::keybcknd] = "BGL";
if (!m_db->addOrUpdate(udi, "", dotdoc))
if (!m_db->addOrUpdate(udi, cstr_null, dotdoc))
return FsTreeWalker::FtwError;
} else if (stringlowercmp("webhistory", dotdoc.meta[Rcl::Doc::keybght]) ||
(dotdoc.mimetype.compare("text/html") &&
dotdoc.mimetype.compare("text/plain"))) {
dotdoc.mimetype.compare(cstr_textplain))) {
LOGDEB(("BeagleQueueIndexer: skipping: hittype %s mimetype %s\n",
dotdoc.meta[Rcl::Doc::keybght].c_str(), dotdoc.mimetype.c_str()));
// Unlink them anyway
@@ -454,20 +454,20 @@ BeagleQueueIndexer::processone(const string &path,
sprintf(cbuf, OFFTPC, stp->st_size);
doc.fbytes = cbuf;
// Document signature for up to date checks: none.
doc.sig = "";
doc.sig.clear();
doc.url = dotdoc.url;
doc.meta[Rcl::Doc::keybcknd] = "BGL";
if (!m_db->addOrUpdate(udi, "", doc))
if (!m_db->addOrUpdate(udi, cstr_null, doc))
return FsTreeWalker::FtwError;
}
// Copy to cache
{
// doc fields not in meta, needing saving to the cache
dotfile.m_fields.set("fmtime", dotdoc.fmtime, "");
dotfile.m_fields.set("fbytes", dotdoc.fbytes, "");
dotfile.m_fields.set("udi", udi, "");
dotfile.m_fields.set("fmtime", dotdoc.fmtime, cstr_null);
dotfile.m_fields.set("fbytes", dotdoc.fbytes, cstr_null);
dotfile.m_fields.set("udi", udi, cstr_null);
string fdata;
file_to_string(path, fdata);
if (!m_cache || !m_cache->cc()) {
+9 -9
View File
@@ -30,6 +30,7 @@
#include <map>
#include <algorithm>
#include "cstr.h"
#include "pathut.h"
#include "conftree.h"
#include "rclconfig.h"
@@ -241,7 +242,7 @@ bool FsIndexer::purgeFiles(list<string>& files)
return false;
for (list<string>::iterator it = files.begin(); it != files.end(); ) {
string udi;
make_udi(*it, "", udi);
make_udi(*it, cstr_null, udi);
// rcldb::purgefile returns true if the udi was either not
// found or deleted, false only in case of actual error
bool existed;
@@ -342,7 +343,7 @@ FsIndexer::processone(const std::string &fn, const struct stat *stp,
string sig;
makesig(stp, sig);
string udi;
make_udi(fn, "", udi);
make_udi(fn, cstr_null, udi);
if (!m_db->needUpdate(udi, sig)) {
LOGDEB0(("processone: up to date: %s\n", fn.c_str()));
if (m_updater) {
@@ -384,9 +385,8 @@ FsIndexer::processone(const std::string &fn, const struct stat *stp,
"UTF-8"));
string parent_udi;
make_udi(fn, "", parent_udi);
make_udi(fn, cstr_null, parent_udi);
Rcl::Doc doc;
const string plus("+");
char ascdate[30];
sprintf(ascdate, "%ld", long(stp->st_mtime));
@@ -413,7 +413,7 @@ FsIndexer::processone(const std::string &fn, const struct stat *stp,
if (doc.fmtime.empty())
doc.fmtime = ascdate;
if (doc.url.empty())
doc.url = string("file://") + fn;
doc.url = cstr_fileu + fn;
if (doc.utf8fn.empty())
doc.utf8fn = utf8fn;
@@ -432,7 +432,7 @@ FsIndexer::processone(const std::string &fn, const struct stat *stp,
// myriads of such files, the ext script is executed for them
// and fails every time)
if (fis == FileInterner::FIError) {
doc.sig += plus;
doc.sig += cstr_plus;
}
// Possibly add fields from local config
@@ -442,7 +442,7 @@ FsIndexer::processone(const std::string &fn, const struct stat *stp,
// of the file document.
string udi;
make_udi(fn, doc.ipath, udi);
if (!m_db->addOrUpdate(udi, doc.ipath.empty() ? "" : parent_udi, doc))
if (!m_db->addOrUpdate(udi, doc.ipath.empty() ? cstr_null : parent_udi, doc))
return FsTreeWalker::FtwError;
// Tell what we are doing and check for interrupt request
@@ -468,14 +468,14 @@ FsIndexer::processone(const std::string &fn, const struct stat *stp,
fileDoc.fmtime = ascdate;
fileDoc.utf8fn = utf8fn;
fileDoc.mimetype = interner.getMimetype();
fileDoc.url = string("file://") + fn;
fileDoc.url = cstr_fileu + fn;
char cbuf[100];
sprintf(cbuf, OFFTPC, stp->st_size);
fileDoc.fbytes = cbuf;
// Document signature for up to date checks.
makesig(stp, fileDoc.sig);
if (!m_db->addOrUpdate(parent_udi, "", fileDoc))
if (!m_db->addOrUpdate(parent_udi, cstr_null, fileDoc))
return FsTreeWalker::FtwError;
}
+4 -3
View File
@@ -25,6 +25,7 @@
#include <algorithm>
#include "cstr.h"
#include "debuglog.h"
#include "indexer.h"
#include "fsindexer.h"
@@ -58,7 +59,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun)
return false;
}
m_config->setKeyDir("");
m_config->setKeyDir(cstr_null);
if (typestorun & IxTFs) {
deleteZ(m_fsindexer);
m_fsindexer = new FsIndexer(m_config, &m_db, m_updater);
@@ -118,7 +119,7 @@ bool ConfIndexer::indexFiles(std::list<string>& ifiles, IxFlag flag)
m_config->getDbDir().c_str()));
return false;
}
m_config->setKeyDir("");
m_config->setKeyDir(cstr_null);
bool ret = false;
if (!m_fsindexer)
m_fsindexer = new FsIndexer(m_config, &m_db, m_updater);
@@ -163,7 +164,7 @@ bool ConfIndexer::purgeFiles(std::list<string> &files)
return false;
}
bool ret = false;
m_config->setKeyDir("");
m_config->setKeyDir(cstr_null);
if (!m_fsindexer)
m_fsindexer = new FsIndexer(m_config, &m_db, m_updater);
if (m_fsindexer)