code wiki / _hdl_build / nx_cdata_probe.nx
nx_cdata_probe.nx source
↩ module page · 25 lines · 1252 B
1// nx_cdata_probe.nx -- DIAGNOSTIC: dump what rh_extract_styles() hands the CSS parser for the XHTML
2// green-square ref, to confirm the <![CDATA[ ... ]]> wrapper is polluting the stylesheet.
3import "nx_syscalls.nx"
4import "nx_html_tokenizer.nx"
5import "nx_dom_query.nx"
6import "nx_layout_box.nx"
7import "nx_layout_default_display.nx"
8import "nx_layout_from_dom.nx"
9import "nx_render_html.nx"
10const K_MAGIC_65536: i64 = 65536
11func g_w(s: *u8) -> i64 { var k: i64=0; while s[k]!=(0 as u8){k=k+1} sys_write(1,s,k); return 0 }
12func main() -> i64 {
13 let lp: *i64 = sys_mmap(8) as *i64
14 let buf: *u8 = sys_read_file("knowledge/wpt/ref-filled-green-100px-square.xht\x00" as *u8, lp)
15 let n: i64 = lp[0]
16 if n <= 0 { g_w("read fail\n" as *u8); return 1 }
17 let out: *u8 = sys_mmap(K_MAGIC_65536)
18 let m: i64 = rh_extract_styles(buf, n, out, K_MAGIC_65536)
19 g_w("=== extracted <style> bytes the CSS parser receives (len " as *u8)
20 var x: i64 = m; let d: *u8 = sys_mmap(24); var k: i64=0; if x==0 {d[0]=48;k=1} while x>0 {d[k]=(48+(x%10)) as u8; x=x/10; k=k+1} var j: i64=0; let o: *u8=sys_mmap(24); while j<k {o[j]=d[k-1-j];j=j+1} sys_write(1,o,k)
21 g_w(") ===\n[" as *u8)
22 sys_write(1, out, m)
23 g_w("]\n" as *u8)
24 return 0
25}