Skip to content

htsparse: extract the HTML-flush macro into a function, drop dead macros - #467

Merged
xroche merged 1 commit into
masterfrom
htsparse-t1-cleanup
Jul 1, 2026
Merged

htsparse: extract the HTML-flush macro into a function, drop dead macros#467
xroche merged 1 commit into
masterfrom
htsparse-t1-cleanup

Conversation

@xroche

@xroche xroche commented Jul 1, 2026

Copy link
Copy Markdown
Owner

The final disk-flush step for a parsed HTML page lived in HT_ADD_END, a ~60-line macro that reached into htsparse()'s locals by lexical scope. This moves it into a real function, hts_finish_html_file, next to its sibling hts_finish_makeindex in 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 trailing TypedArrayFree (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); _ROBOTS is still used and stays.

Second in the htsparse macro-cleanup series after #465.

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
xroche force-pushed the htsparse-t1-cleanup branch from a2b87c8 to 4347889 Compare July 1, 2026 18:22
@xroche
xroche merged commit d2d02d8 into master Jul 1, 2026
15 checks passed
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>
@xroche
xroche deleted the htsparse-t1-cleanup branch July 27, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant