From ca44435a26345df703bb257098f7d8c32e7ff6b9 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 19 Oct 2017 17:05:02 +1300 Subject: [PATCH] Fix __WIN32__ path handling in Database::check() The handling for '\' as an alternate path separator was broken. --- xapian-core/backends/dbcheck.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/xapian-core/backends/dbcheck.cc b/xapian-core/backends/dbcheck.cc index f27a1daa2..285063b38 100644 --- a/xapian-core/backends/dbcheck.cc +++ b/xapian-core/backends/dbcheck.cc @@ -220,10 +220,15 @@ check_db_table_(const string & filename, int opts, std::ostream *out, { size_t p = filename.find_last_of('/'); #if defined __WIN32__ || defined __OS2__ - if (p == string::npos) p = 0; - p = filename.find_last_of('\\', p); + // If no '/' was found, p == string::npos so p + 1 == 0. + size_t q = filename.find_last_of('\\', p + 1); + if (q != string::npos) + p = q; #endif - if (p == string::npos) p = 0; else ++p; + // If we found a directory separator, advance p to the next character. If + // we didn't, incrementing string::npos will give us 0, which is what we + // want. + ++p; string dir(filename, 0, p); -- 2.11.4.GIT