htsparse: extract the HTML-flush macro into a function, drop dead macros - #467
Merged
Conversation
The final HTML-flush step lived in the ~60-line HT_ADD_END macro, captured by lexical scope in htsparse(). Move it to a real function in htscore.c (next to its sibling hts_finish_makeindex), passing the output buffer as a plain pointer+length since the TypedArray is an anonymous struct type that can't cross a function boundary; the caller keeps the size guard and the trailing TypedArrayFree. Behavior-preserving: a two-crawl mirror produces byte-identical output against master. Also delete the _FILTERS/_FILTERS_PTR macros, dead in htsparse.c (htscore.c and htswizard.c keep their own local copies); _ROBOTS stays. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Xavier Roche <roche@httrack.com>
xroche
force-pushed
the
htsparse-t1-cleanup
branch
from
July 1, 2026 18:22
a2b87c8 to
4347889
Compare
This was referenced Jul 26, 2026
xroche
added a commit
that referenced
this pull request
Jul 27, 2026
…does not (#764) The MD5 comparison the comment promises left the tree in two steps: #467 extracted the function out of htsparse.c's HT_ADD_END macro without the skip branch, and #512 removed the //[HTML-MD5]// cache entry it read. Drop the parenthetical; the write is unconditional. Signed-off-by: Xavier Roche <roche@httrack.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The final disk-flush step for a parsed HTML page lived in
HT_ADD_END, a ~60-line macro that reached intohtsparse()'s locals by lexical scope. This moves it into a real function,hts_finish_html_file, next to its siblinghts_finish_makeindexin htscore.c. The output buffer can't be passed as-is:TypedArray(char)expands to a fresh anonymous struct type at every use, so two of them aren't compatible types across a function boundary. The function takes the buffer as a plain pointer plus length, and the caller keeps the size guard and the trailingTypedArrayFree(which always ran inside the old macro's outer braces). Behavior-preserving: crawling a small site twice with master and this branch yields byte-identical mirror trees.Also drops
_FILTERS/_FILTERS_PTR, dead in htsparse.c (htscore.c and htswizard.c keep their own local copies);_ROBOTSis still used and stays.Second in the htsparse macro-cleanup series after #465.