Windows: fixed a number of int size warnings mostly by casting them away
This commit is contained in:
parent
d5aa8db282
commit
970935f130
13 changed files with 21 additions and 42 deletions
|
@ -199,7 +199,7 @@ namespace Binc {
|
||||||
s.seekg(0, ios::end);
|
s.seekg(0, ios::end);
|
||||||
std::streampos lst = s.tellg();
|
std::streampos lst = s.tellg();
|
||||||
s.seekg(st);
|
s.seekg(st);
|
||||||
size_t nbytes = lst - st;
|
size_t nbytes = size_t(lst - st);
|
||||||
if (nbytes > nb) {
|
if (nbytes > nb) {
|
||||||
nbytes = nb;
|
nbytes = nb;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ typedef int mode_t;
|
||||||
typedef int ssize_t;
|
typedef int ssize_t;
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
#define ftruncate _chsize
|
#define ftruncate _chsize_s
|
||||||
#define PATH_MAX MAX_PATH
|
#define PATH_MAX MAX_PATH
|
||||||
#define MAXPATHLEN PATH_MAX
|
#define MAXPATHLEN PATH_MAX
|
||||||
#define R_OK 4
|
#define R_OK 4
|
||||||
|
@ -56,7 +56,7 @@ typedef int ssize_t;
|
||||||
#define S_ISLNK(X) false
|
#define S_ISLNK(X) false
|
||||||
#define lstat stat
|
#define lstat stat
|
||||||
#define fseeko _fseeki64
|
#define fseeko _fseeki64
|
||||||
#define ftello _ftelli64
|
#define ftello (off_t)_ftelli64
|
||||||
#define timegm _mkgmtime
|
#define timegm _mkgmtime
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -329,7 +329,7 @@ bool FsIndexer::indexFiles(list<string>& files, int flags)
|
||||||
{
|
{
|
||||||
LOGDEB(("FsIndexer::indexFiles\n"));
|
LOGDEB(("FsIndexer::indexFiles\n"));
|
||||||
m_noretryfailed = (flags & ConfIndexer::IxFNoRetryFailed) != 0;
|
m_noretryfailed = (flags & ConfIndexer::IxFNoRetryFailed) != 0;
|
||||||
int ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if (!init())
|
if (!init())
|
||||||
return false;
|
return false;
|
||||||
|
@ -702,7 +702,7 @@ FsIndexer::processonefile(RclConfig *config,
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGDEB0(("processone: processing: [%s] %s\n",
|
LOGDEB0(("processone: processing: [%s] %s\n",
|
||||||
displayableBytes(stp->st_size).c_str(), fn.c_str()));
|
displayableBytes(off_t(stp->st_size)).c_str(), fn.c_str()));
|
||||||
|
|
||||||
string utf8fn = compute_utf8fn(config, fn);
|
string utf8fn = compute_utf8fn(config, fn);
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ namespace Dijon
|
||||||
stat() calls The value is stored inside metaData, docsize
|
stat() calls The value is stored inside metaData, docsize
|
||||||
key
|
key
|
||||||
*/
|
*/
|
||||||
virtual void set_docsize(size_t size) = 0;
|
virtual void set_docsize(off_t size) = 0;
|
||||||
|
|
||||||
// Going from one nested document to the next.
|
// Going from one nested document to the next.
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
|
||||||
l_mime = *imime;
|
l_mime = *imime;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t docsize = stp->st_size;
|
off_t docsize = stp->st_size;
|
||||||
|
|
||||||
if (!l_mime.empty()) {
|
if (!l_mime.empty()) {
|
||||||
// Has mime: check for a compressed file. If so, create a
|
// Has mime: check for a compressed file. If so, create a
|
||||||
|
|
|
@ -91,7 +91,7 @@ public:
|
||||||
return set_document_string(mtype, std::string(cp, sz));
|
return set_document_string(mtype, std::string(cp, sz));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void set_docsize(size_t size)
|
virtual void set_docsize(off_t size)
|
||||||
{
|
{
|
||||||
char csize[30];
|
char csize[30];
|
||||||
sprintf(csize, "%lld", (long long)size);
|
sprintf(csize, "%lld", (long long)size);
|
||||||
|
|
|
@ -386,7 +386,7 @@ int Query::Native::makeAbstract(Xapian::docid docid,
|
||||||
for (multimap<double, vector<string> >::reverse_iterator mit = byQ.rbegin();
|
for (multimap<double, vector<string> >::reverse_iterator mit = byQ.rbegin();
|
||||||
mit != byQ.rend(); mit++) {
|
mit != byQ.rend(); mit++) {
|
||||||
unsigned int maxgrpoccs;
|
unsigned int maxgrpoccs;
|
||||||
float q;
|
double q;
|
||||||
if (byQ.size() == 1) {
|
if (byQ.size() == 1) {
|
||||||
maxgrpoccs = maxtotaloccs;
|
maxgrpoccs = maxtotaloccs;
|
||||||
q = 1.0;
|
q = 1.0;
|
||||||
|
|
|
@ -549,8 +549,7 @@ bool Db::Native::getPagePositions(Xapian::docid docid, vector<int>& vpos)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Db::Native::getPageNumberForPosition(const vector<int>& pbreaks,
|
int Db::Native::getPageNumberForPosition(const vector<int>& pbreaks, int pos)
|
||||||
unsigned int pos)
|
|
||||||
{
|
{
|
||||||
if (pos < baseTextPosition) // Not in text body
|
if (pos < baseTextPosition) // Not in text body
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -120,7 +120,7 @@ class Db::Native {
|
||||||
const string& uniterm);
|
const string& uniterm);
|
||||||
|
|
||||||
bool getPagePositions(Xapian::docid docid, vector<int>& vpos);
|
bool getPagePositions(Xapian::docid docid, vector<int>& vpos);
|
||||||
int getPageNumberForPosition(const vector<int>& pbreaks, unsigned int pos);
|
int getPageNumberForPosition(const vector<int>& pbreaks, int pos);
|
||||||
|
|
||||||
bool dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc);
|
bool dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc);
|
||||||
|
|
||||||
|
|
|
@ -956,10 +956,10 @@ bool CirCache::erase(const string& udi)
|
||||||
// entry.
|
// entry.
|
||||||
class CCScanHookSpacer : public CCScanHook {
|
class CCScanHookSpacer : public CCScanHook {
|
||||||
public:
|
public:
|
||||||
UINT sizewanted;
|
off_t sizewanted;
|
||||||
UINT sizeseen;
|
off_t sizeseen;
|
||||||
vector<pair<string, off_t> > squashed_udis;
|
vector<pair<string, off_t> > squashed_udis;
|
||||||
CCScanHookSpacer(int sz)
|
CCScanHookSpacer(off_t sz)
|
||||||
: sizewanted(sz), sizeseen(0) {assert(sz > 0);}
|
: sizewanted(sz), sizeseen(0) {assert(sz > 0);}
|
||||||
|
|
||||||
virtual status takeone(off_t offs, const string& udi,
|
virtual status takeone(off_t offs, const string& udi,
|
||||||
|
@ -1035,15 +1035,15 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf,
|
||||||
|
|
||||||
// Characteristics for the new entry.
|
// Characteristics for the new entry.
|
||||||
int nsize = CIRCACHE_HEADER_SIZE + dic.size() + datalen;
|
int nsize = CIRCACHE_HEADER_SIZE + dic.size() + datalen;
|
||||||
int nwriteoffs = m_d->m_oheadoffs;
|
off_t nwriteoffs = m_d->m_oheadoffs;
|
||||||
int npadsize = 0;
|
off_t npadsize = 0;
|
||||||
bool extending = false;
|
bool extending = false;
|
||||||
|
|
||||||
LOGDEB(("CirCache::put: nsz %d oheadoffs %d\n", nsize, m_d->m_oheadoffs));
|
LOGDEB(("CirCache::put: nsz %d oheadoffs %d\n", nsize, m_d->m_oheadoffs));
|
||||||
|
|
||||||
// Check if we can recover some pad space from the (physically) previous
|
// Check if we can recover some pad space from the (physically) previous
|
||||||
// entry.
|
// entry.
|
||||||
int recovpadsize = m_d->m_oheadoffs == CIRCACHE_FIRSTBLOCK_SIZE ?
|
off_t recovpadsize = m_d->m_oheadoffs == CIRCACHE_FIRSTBLOCK_SIZE ?
|
||||||
0 : m_d->m_npadsize;
|
0 : m_d->m_npadsize;
|
||||||
if (recovpadsize != 0) {
|
if (recovpadsize != 0) {
|
||||||
// Need to read the latest entry's header, to rewrite it with a
|
// Need to read the latest entry's header, to rewrite it with a
|
||||||
|
@ -1082,7 +1082,7 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf,
|
||||||
} else {
|
} else {
|
||||||
// Scan the file until we have enough space for the new entry,
|
// Scan the file until we have enough space for the new entry,
|
||||||
// and determine the pad size up to the 1st preserved entry
|
// and determine the pad size up to the 1st preserved entry
|
||||||
int scansize = nsize - recovpadsize;
|
off_t scansize = nsize - recovpadsize;
|
||||||
LOGDEB(("CirCache::put: scanning for size %d from offs %u\n",
|
LOGDEB(("CirCache::put: scanning for size %d from offs %u\n",
|
||||||
scansize, (UINT)m_d->m_oheadoffs));
|
scansize, (UINT)m_d->m_oheadoffs));
|
||||||
CCScanHookSpacer spacer(scansize);
|
CCScanHookSpacer spacer(scansize);
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <glob.h>
|
|
||||||
#endif
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -420,25 +419,6 @@ bool makepath(const string& ipath)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string> path_dirglob(const string &dir, const string pattern)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
return vector<string>();
|
|
||||||
#else
|
|
||||||
vector<string> res;
|
|
||||||
glob_t mglob;
|
|
||||||
string mypat=path_cat(dir, pattern);
|
|
||||||
if (glob(mypat.c_str(), 0, 0, &mglob)) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < int(mglob.gl_pathc); i++) {
|
|
||||||
res.push_back(mglob.gl_pathv[i]);
|
|
||||||
}
|
|
||||||
globfree(&mglob);
|
|
||||||
return res;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool path_isdir(const string& path)
|
bool path_isdir(const string& path)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
|
@ -104,7 +104,7 @@ bool file_scan(const string &fn, FileScanDo* doer, off_t startoffs,
|
||||||
if (cnttoread != (size_t)-1 && cnttoread) {
|
if (cnttoread != (size_t)-1 && cnttoread) {
|
||||||
doer->init(cnttoread+1, reason);
|
doer->init(cnttoread+1, reason);
|
||||||
} else if (st.st_size > 0) {
|
} else if (st.st_size > 0) {
|
||||||
doer->init(st.st_size+1, reason);
|
doer->init(size_t(st.st_size+1), reason);
|
||||||
} else {
|
} else {
|
||||||
doer->init(0, reason);
|
doer->init(0, reason);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ bool file_scan(const string &fn, FileScanDo* doer, off_t startoffs,
|
||||||
for (;;) {
|
for (;;) {
|
||||||
size_t toread = RDBUFSZ;
|
size_t toread = RDBUFSZ;
|
||||||
if (startoffs > 0 && curoffs < startoffs) {
|
if (startoffs > 0 && curoffs < startoffs) {
|
||||||
toread = MIN(RDBUFSZ, startoffs - curoffs);
|
toread = size_t(MIN(RDBUFSZ, startoffs - curoffs));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cnttoread != size_t(-1)) {
|
if (cnttoread != size_t(-1)) {
|
||||||
|
|
|
@ -637,7 +637,7 @@ string displayableBytes(off_t size)
|
||||||
unit = " GB ";
|
unit = " GB ";
|
||||||
roundable = double(size) / 1E9;
|
roundable = double(size) / 1E9;
|
||||||
}
|
}
|
||||||
size = round(roundable);
|
size = off_t(round(roundable));
|
||||||
sprintf(sizebuf, "%lld" "%s", (long long)size, unit);
|
sprintf(sizebuf, "%lld" "%s", (long long)size, unit);
|
||||||
return string(sizebuf);
|
return string(sizebuf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue