Skip to content

Commit

Permalink
Merge pull request #909 from openzim/windows_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr authored Aug 15, 2024
2 parents dc7b398 + bc65f30 commit 647dc12
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ else
private_conf.set('ENABLE_USE_MMAP', get_option('USE_MMAP'))
endif
private_conf.set('ENABLE_USE_BUFFER_HEADER', get_option('USE_BUFFER_HEADER'))
private_conf.set('ENABLE_XAPIAN_FULLER', get_option('with_xapian_fuller'))

static_linkage = get_option('static-linkage')
static_linkage = static_linkage or get_option('default_library')=='static'
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ option('tests', type : 'boolean', value : true,
description : 'Build the tests.')
option('with_xapian', type : 'boolean', value: true,
description: 'Build libzim with xapian support')
option('with_xapian_fuller', type: 'boolean', value: true,
description: 'Create xapian archive using "FULLER" compaction.\nThis is a workaround for a compilation issue on Windows. This will be removed soon')
option('test_data_dir', type : 'string', value: '',
description: 'Where the test data are. If not set, meson will use a internal directory in the build dir. If you want to download the data in the specified directory you can use `meson download_test_data`. As a special value, you can pass `none` to deactivate test using external test data.')
2 changes: 2 additions & 0 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#mesondefine ENABLE_XAPIAN

#mesondefine ENABLE_XAPIAN_FULLER

#mesondefine ENABLE_USE_MMAP

#mesondefine ENABLE_USE_BUFFER_HEADER
Expand Down
6 changes: 3 additions & 3 deletions src/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ uint32_t zim::countWords(const std::string& text)
unsigned int i = 0;

// Find first word
while ( i < length && std::isspace(text[i]) ) i++;
while ( i < length && std::isspace(static_cast<unsigned char>(text[i])) ) i++;

while ( i < length ) {
// Find end of word
while ( i < length && !std::isspace(text[i]) ) i++;
while ( i < length && !std::isspace(static_cast<unsigned char>(text[i])) ) i++;
numWords++;
// Find start of next word
while ( i < length && std::isspace(text[i]) ) i++;
while ( i < length && std::isspace(static_cast<unsigned char>(text[i])) ) i++;
}
return numWords;
}
Expand Down
7 changes: 6 additions & 1 deletion src/writer/xapianIndexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@ void XapianIndexer::indexTitle(const std::string& path, const std::string& title
void XapianIndexer::indexingPostlude()
{
this->writableDatabase.commit();
this->writableDatabase.compact(indexPath, Xapian::DBCOMPACT_SINGLE_FILE|Xapian::Compactor::FULLER);
#if defined ENABLE_XAPIAN_FULLER
auto flags = Xapian::DBCOMPACT_SINGLE_FILE|Xapian::Compactor::FULLER;
#else
auto flags = Xapian::DBCOMPACT_SINGLE_FILE;
#endif
this->writableDatabase.compact(indexPath, flags);
this->writableDatabase.close();
}

5 changes: 4 additions & 1 deletion test/tooltesting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ namespace {
auto accentedString(ss.str());
// Check our input data (that we have a char in the middle of a batch boundary)
// Indexing is made on u16
icu::UnicodeString ustring(accentedString.c_str());
// `zim::removeAccents` calls `ucnv_setDefaultName` before creating the UnicodeString
// so it will be converted using the right encoding ("utf8").
// But we don't so we need to be explicit on the encoding here.
icu::UnicodeString ustring(accentedString.c_str(), "utf8");

// Test input data.
// "bépo" is 4 chars
Expand Down

0 comments on commit 647dc12

Please sign in to comment.