Additional debug information
This commit is contained in:
@@ -305,25 +305,38 @@ struct ParserState {
|
|||||||
|
|
||||||
size_t matchedOffset = 0;
|
size_t matchedOffset = 0;
|
||||||
bool exact = false;
|
bool exact = false;
|
||||||
bool matched = pickBestAnchorByPath(normalized, false, matchedOffset, exact);
|
const char* matchTier = nullptr;
|
||||||
|
|
||||||
if (!matched) {
|
bool matched = pickBestAnchorByPath(normalized, false, matchedOffset, exact);
|
||||||
matched = pickBestAnchorByPath(normalized, true, matchedOffset, exact);
|
if (matched) {
|
||||||
if (matched) exact = false;
|
matchTier = exact ? "exact" : "ancestor";
|
||||||
|
} else {
|
||||||
|
bool exactRaw = false;
|
||||||
|
matched = pickBestAnchorByPath(normalized, true, matchedOffset, exactRaw);
|
||||||
|
if (matched) {
|
||||||
|
exact = false;
|
||||||
|
matchTier = exactRaw ? "index-insensitive" : "index-insensitive-ancestor";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!matched) {
|
if (!matched) {
|
||||||
|
LOG_DBG("KOX", "Reverse: spine=%d no anchor match for '%s' (%zu anchors)", spineIndex, normalized.c_str(),
|
||||||
|
anchors.size());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
outExactMatch = exact;
|
outExactMatch = exact;
|
||||||
if (totalTextBytes == 0) {
|
if (totalTextBytes == 0) {
|
||||||
outIntraSpineProgress = 0.0f;
|
outIntraSpineProgress = 0.0f;
|
||||||
|
LOG_DBG("KOX", "Reverse: spine=%d %s match offset=%zu -> progress=0.0 (no text)", spineIndex, matchTier,
|
||||||
|
matchedOffset);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
outIntraSpineProgress = static_cast<float>(matchedOffset) / static_cast<float>(totalTextBytes);
|
outIntraSpineProgress = static_cast<float>(matchedOffset) / static_cast<float>(totalTextBytes);
|
||||||
outIntraSpineProgress = std::max(0.0f, std::min(1.0f, outIntraSpineProgress));
|
outIntraSpineProgress = std::max(0.0f, std::min(1.0f, outIntraSpineProgress));
|
||||||
|
LOG_DBG("KOX", "Reverse: spine=%d %s match offset=%zu/%zu -> progress=%.3f", spineIndex, matchTier, matchedOffset,
|
||||||
|
totalTextBytes, outIntraSpineProgress);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -397,7 +410,10 @@ std::string ChapterXPathIndexer::findXPathForProgress(const std::shared_ptr<Epub
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return state.chooseXPath(intraSpineProgress);
|
const std::string result = state.chooseXPath(intraSpineProgress);
|
||||||
|
LOG_DBG("KOX", "Forward: spine=%d progress=%.3f anchors=%zu textBytes=%zu -> %s", spineIndex, intraSpineProgress,
|
||||||
|
state.anchors.size(), state.totalTextBytes, result.c_str());
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChapterXPathIndexer::findProgressForXPath(const std::shared_ptr<Epub>& epub, const int spineIndex,
|
bool ChapterXPathIndexer::findProgressForXPath(const std::shared_ptr<Epub>& epub, const int spineIndex,
|
||||||
@@ -450,6 +466,8 @@ bool ChapterXPathIndexer::findProgressForXPath(const std::shared_ptr<Epub>& epub
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_DBG("KOX", "Reverse: spine=%d anchors=%zu textBytes=%zu for '%s'", spineIndex, state.anchors.size(),
|
||||||
|
state.totalTextBytes, xpath.c_str());
|
||||||
return state.chooseProgressForXPath(xpath, outIntraSpineProgress, outExactMatch);
|
return state.chooseProgressForXPath(xpath, outIntraSpineProgress, outExactMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,6 +481,7 @@ bool ChapterXPathIndexer::tryExtractSpineIndexFromXPath(const std::string& xpath
|
|||||||
const std::string key = "/docfragment[";
|
const std::string key = "/docfragment[";
|
||||||
const size_t pos = normalized.find(key);
|
const size_t pos = normalized.find(key);
|
||||||
if (pos == std::string::npos) {
|
if (pos == std::string::npos) {
|
||||||
|
LOG_DBG("KOX", "No DocFragment in xpath: '%s'", xpath.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user