Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienos.com/blob/main/om/site/verify-text.om # aienos.com Source of www.aienos.com, served from my own hardware Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienos.com / om / site / verify-text.om` 636 lines ยท 14177 bytes Raw Blame History 1 note verify-text.om: the HTML reading the oracle does (oracle.rs, seo.rs attr/tag_name, 2 note boxlink.rs, voice.rs), ported byte for byte. Every function works on arena slots 3 note (verify-core.om); positions are slot-relative. A function that builds text returns a new 4 note slot that the caller drops. 5 global vtn uchar 64 6 global vtnn ulong 1 7 global vav ulong 2 8 global vax ulong 4 9 global vlab uchar 64 10 global vlabn ulong 1 11 text vxscr "script" 12 text vxsty "style" 13 text vxtpl "template" 14 text vxnos "noscript" 15 text vxvoid "area\nbase\nbr\ncol\nembed\nhr\nimg\ninput\nlink\nmeta\nsource\ntrack\nwbr\n" 16 text vxcom "" 18 text vxhid "hidden" 19 text vxah "aria-hidden" 20 text vxtrue "true" 21 text vxclass "class" 22 text vxhref "href" 23 text vxa "" 25 text vxclo "" 27 text vxlt "<" 28 text vxid "id" 29 text vxmain "" 32 note entity tables: pattern LF replacement LF ... in the order Rust applies its replace calls 33 text vxent1 " \n \n"\n\"\n'\n'\n<\n<\n>\n>\n&\n&\n" 34 text vxent2 "&\n&\n'\n'\n'\n'\n"\n\"\n<\n<\n>\n>\n \n \n" 35 36 note ---------------------------------------------------------------- bytes in a slot 37 fn sv_aws c uchar to bool 38 ret or or eq c 32 eq c 9 or or eq c 10 eq c 12 eq c 13 39 end 40 fn sv_awsr c uchar to bool 41 note the set Rust's starts_with(['>', ' ', '\t', '\n', '\r']) accepts after a tag name 42 ret or or eq c 62 eq c 32 or or eq c 9 eq c 10 eq c 13 43 end 44 fn sv_bat s ulong i ulong to uchar 45 if ge i sv_n s 46 ret 0 47 end 48 ret sv_b s i 49 end 50 note sv_tagend: index of the first '>' at or after i, VNONE. 51 fn sv_tagend s ulong i ulong to ulong 52 ret sv_findb2 s 62 i 53 end 54 fn sv_findb2 s ulong c uchar from ulong to ulong 55 wn = sv_n s 56 wb = sv_off s 57 wi = from 58 while lt wi wn bound 64 59 wk = ulong 0 60 while and lt wi wn lt wk 262144 bound 262144 61 if eq get va add wb wi c 62 ret wi 63 end 64 wi = add wi 1 65 wk = add wk 1 66 end 67 end 68 ret VNONE 69 end 70 note sv_tname: seo.rs tag_name: skip every leading '<', then every '/', then ASCII alphanumerics, 71 note lowercased, into vtn; returns the length. 72 fn sv_tname s ulong i ulong to ulong 73 while eq sv_bat s i 60 bound 999999 74 i = add i 1 75 end 76 while eq sv_bat s i 47 bound 999999 77 i = add i 1 78 end 79 wn = ulong 0 80 while lt wn 64 bound 64 81 c = sv_bat s i 82 if not or sv_isdig c or and ge c 65 le c 90 and ge c 97 le c 122 83 break 84 end 85 put vtn wn sv_lc c 86 wn = add wn 1 87 i = add i 1 88 end 89 put vtnn 0 wn 90 ret wn 91 end 92 fn sv_tnis pat view uchar * to bool 93 if ne get vtnn 0 len pat 94 ret false 95 end 96 for wj ulong len pat 97 if ne get vtn wj get pat wj 98 ret false 99 end 100 end 101 ret true 102 end 103 fn sv_tnin t view uchar * to bool 104 for wk ulong sv_tcount t 105 wa = sv_tat t wk 106 if sv_tnis part t wa sv_tlen t wa 107 ret true 108 end 109 end 110 ret false 111 end 112 note sv_aqval: the quoted value opening at wj (< we) for sv_attr: its start (>= 1, length in 113 note vav[0]); VNONE when unterminated before we; 0 when wj holds no quote (keep scanning). 114 fn sv_aqval s ulong wj ulong we ulong to ulong 115 wq = sv_bat s wj 116 if and lt wj we or eq wq 34 eq wq 39 117 wz = sv_findb2 s wq add wj 1 118 if or eq wz VNONE ge wz we 119 ret VNONE 120 end 121 put vav 0 sub wz add wj 1 122 ret add wj 1 123 end 124 ret 0 125 end 126 note sv_attr: seo.rs attr(tag, name) over the tag bytes [t0, t1] ('>' at t1). Found: value offset, 127 note vav[0] its length. Missing: VNONE. A value whose closing quote is missing ends the search 128 note (Rust's `?`). 129 fn sv_attr s ulong t0 ulong t1 ulong name view uchar * to ulong 130 wi = t0 131 we = add t1 1 132 while true bound 999999 133 wst = sv_findn s name wi we 134 if eq wst VNONE 135 ret VNONE 136 end 137 wok = and gt wst t0 sv_aws sv_b s sub wst 1 138 wj = add wst len name 139 while and lt wj we sv_aws sv_bat s wj bound 999999 140 wj = add wj 1 141 end 142 if and wok and lt wj we eq sv_bat s wj 61 143 wj = add wj 1 144 while and lt wj we sv_aws sv_bat s wj bound 999999 145 wj = add wj 1 146 end 147 wv = sv_aqval s wj we 148 if ne wv 0 149 ret wv 150 end 151 end 152 wi = add wst len name 153 end 154 ret VNONE 155 end 156 note sv_aeq: the attribute value at v (length vav[0], from sv_attr) equals want; v VNONE is false. 157 fn sv_aeq s ulong v ulong want view uchar * to bool 158 if eq v VNONE 159 ret false 160 end 161 if ne get vav 0 len want 162 ret false 163 end 164 ret sv_eqat s v want 165 end 166 note sv_anstp: byte i of slot s ends an attribute-name run (space, '>' or '/'). 167 fn sv_anstp s ulong i ulong to bool 168 c = sv_bat s i 169 ret or or sv_aws c eq c 62 eq c 47 170 end 171 note sv_anend: byte i of slot s ends an attribute name (space, '=', '>' or '/'). 172 fn sv_anend s ulong i ulong to bool 173 c = sv_bat s i 174 ret or or sv_aws c eq c 61 or eq c 62 eq c 47 175 end 176 note sv_anames: oracle.rs attr_names(tag) contains the lowercase name. 177 fn sv_anames s ulong t0 ulong t1 ulong name view uchar * to bool 178 we = add t1 1 179 wi = add t0 1 180 while and lt wi we not sv_anstp s wi bound 999999 181 wi = add wi 1 182 end 183 while true bound 999999 184 while and lt wi we or sv_aws sv_bat s wi eq sv_bat s wi 47 bound 999999 185 wi = add wi 1 186 end 187 if or ge wi we eq sv_bat s wi 62 188 ret false 189 end 190 wst = wi 191 while and lt wi we not sv_anend s wi bound 999999 192 wi = add wi 1 193 end 194 if eq sub wi wst len name 195 if sv_eqatc s wst name 196 ret true 197 end 198 end 199 wi = sv_anval s wi we 200 end 201 ret false 202 end 203 fn sv_anval s ulong wi ulong we ulong to ulong 204 while and lt wi we sv_aws sv_bat s wi bound 999999 205 wi = add wi 1 206 end 207 if and lt wi we eq sv_bat s wi 61 208 wi = add wi 1 209 while and lt wi we sv_aws sv_bat s wi bound 999999 210 wi = add wi 1 211 end 212 wq = sv_bat s wi 213 if and lt wi we or eq wq 34 eq wq 39 214 wi = add wi 1 215 while and lt wi we ne sv_bat s wi wq bound 999999 216 wi = add wi 1 217 end 218 ret add wi 1 219 end 220 while and lt wi we not or sv_aws sv_bat s wi eq sv_bat s wi 62 bound 999999 221 wi = add wi 1 222 end 223 end 224 ret wi 225 end 226 note sv_eend: oracle.rs element_end(html, body, name) with name in vtn: index just past the 227 note matching close tag (ASCII case-insensitive), counting nested opens; VNONE. 228 fn sv_eend s ulong body ulong to ulong 229 wd = ulong 1 230 wi = body 231 wn = get vtnn 0 232 while true bound 999999 233 wl = sv_findb2 s 60 wi 234 if eq wl VNONE 235 ret VNONE 236 end 237 if sv_isclose s wl 238 wd = sub wd 1 239 if eq wd 0 240 ret add add wl 3 wn 241 end 242 else 243 if sv_isopen s wl 244 wd = add wd 1 245 end 246 end 247 wi = add wl 1 248 end 249 ret VNONE 250 end 251 fn sv_vtnat s ulong i ulong to bool 252 wn = get vtnn 0 253 if gt add i wn sv_n s 254 ret false 255 end 256 for wj ulong wn 257 if ne sv_lc sv_b s add i wj get vtn wj 258 ret false 259 end 260 end 261 ret true 262 end 263 fn sv_isclose s ulong wl ulong to bool 264 if ne sv_bat s add wl 1 47 265 ret false 266 end 267 if not sv_vtnat s add wl 2 268 ret false 269 end 270 ret eq sv_bat s add add wl 2 get vtnn 0 62 271 end 272 fn sv_isopen s ulong wl ulong to bool 273 if not sv_vtnat s add wl 1 274 ret false 275 end 276 wi = add add wl 1 get vtnn 0 277 if ge wi sv_n s 278 ret false 279 end 280 c = sv_b s wi 281 ret or sv_awsr c eq c 47 282 end 283 284 note ---------------------------------------------------------------- strip 285 note sv_strip: oracle.rs strip(html, drop, hidden) over slot s. Flags: 1 script, 2 style, 286 note 4 template, 8 noscript dropped; 16 hidden (the hidden attribute or aria-hidden="true"). 287 note markup = 7, reachable = 31, the noscript source = 23, reader text = 23, page_assets = 0. 288 fn sv_dropn fl ulong to bool 289 if and ne and fl 1 0 sv_tnis vxscr 290 ret true 291 end 292 if and ne and fl 2 0 sv_tnis vxsty 293 ret true 294 end 295 if and ne and fl 4 0 sv_tnis vxtpl 296 ret true 297 end 298 ret and ne and fl 8 0 sv_tnis vxnos 299 end 300 fn sv_strip s ulong fl ulong to ulong 301 wo = sv_snew 302 wi = ulong 0 303 wn = sv_n s 304 while lt wi wn bound 999999 305 wl = sv_findb2 s 60 wi 306 if eq wl VNONE 307 break 308 end 309 sv_pusha add sv_off s wi sub wl wi 310 wi = sv_strip1 s fl wl 311 end 312 if lt wi wn 313 sv_pusha add sv_off s wi sub wn wi 314 end 315 ret wo 316 end 317 note sv_strip1: one '<' at wl: push what the pass keeps, return where scanning resumes. 318 fn sv_strip1 s ulong fl ulong wl ulong to ulong 319 wn = sv_n s 320 if sv_eqat s wl vxcom 321 wz = sv_find s vxcomx wl 322 sv_push 32 323 if eq wz VNONE 324 ret wn 325 end 326 ret add wz 3 327 end 328 wnl = sv_tname s wl 329 wg = sv_tagend s wl 330 if eq wg VNONE 331 ret wn 332 end 333 wop = and gt wnl 0 not or eq sv_bat s add wl 1 47 eq sv_bat s add wl 1 33 334 whide = false 335 if wop 336 whide = sv_dropn fl 337 if and not whide ne and fl 16 0 338 whide = or sv_anames s wl wg vxhid sv_aeq s sv_attr s wl wg vxah vxtrue 339 end 340 end 341 if whide 342 sv_push 32 343 if or sv_tnin vxvoid eq sv_b s sub wg 1 47 344 ret add wg 1 345 end 346 wz = sv_eend s add wg 1 347 if eq wz VNONE 348 ret wn 349 end 350 ret wz 351 end 352 sv_pusha add sv_off s wl add sub wg wl 1 353 ret add wg 1 354 end 355 356 note ---------------------------------------------------------------- reader text 357 fn sv_slot1 a ulong b ulong src ulong to ulong 358 ws = sv_snew 359 sv_pusha add sv_off src a sub b a 360 ret ws 361 end 362 note sv_coll: move slot g (the newest) down onto slot f and pop everything above f. 363 fn sv_coll f ulong g ulong to void 364 wn = sv_n g 365 wfo = sv_off f 366 wgo = sv_off g 367 sv_amove wfo wgo wn 368 put vns 0 add f 1 369 put vsn f wn 370 put vtop 0 add wfo wn 371 end 372 note sv_untag: in place, '<' opens a tag, '>' in a tag becomes one space (oracle reader_text). 373 fn sv_untag s ulong to void 374 wo = sv_off s 375 wn = sv_n s 376 wout = ulong 0 377 win = false 378 for wi ulong wn 379 c = get va add wo wi 380 if eq c 60 381 win = true 382 else 383 if and eq c 62 win 384 win = false 385 put va add wo wout 32 386 wout = add wout 1 387 else 388 if not win 389 put va add wo wout c 390 wout = add wout 1 391 end 392 end 393 end 394 end 395 sv_trunc s wout 396 end 397 note sv_aput: copy rep into the arena at dst (split out of sv_repl for registers). 398 fn sv_aput dst ulong rep view uchar * to void 399 for wj ulong len rep 400 put va add dst wj get rep wj 401 end 402 end 403 note sv_repl: in place, every non-overlapping pat (left to right) becomes rep (len rep <= len pat). 404 fn sv_repl s ulong pat view uchar * rep view uchar * to void 405 note the slot offset and length are read per use (unchanged until sv_trunc): register budget. 406 wout = ulong 0 407 wi = ulong 0 408 while lt wi sv_n s bound 64 409 wk = ulong 0 410 while and lt wi sv_n s lt wk 262144 bound 262144 411 if sv_eqat s wi pat 412 sv_aput add sv_off s wout rep 413 wout = add wout len rep 414 wi = add wi len pat 415 else 416 sv_amove add sv_off s wout add sv_off s wi 1 417 wout = add wout 1 418 wi = add wi 1 419 end 420 wk = add wk 1 421 end 422 end 423 sv_trunc s wout 424 end 425 fn sv_ents s ulong t view uchar * to void 426 wk = ulong 0 427 note wrep: the replacement half of one pair; omc error 19 refuses two parts of t in one call. 428 wrep = new uchar 64 0 429 while lt wk sv_tcount t bound 64 430 wa = sv_tat t wk 431 wb = sv_tat t add wk 1 432 wn = sv_tlen t wb 433 if gt wn 64 434 trap 10 435 end 436 for wj ulong wn 437 put wrep wj get t add wb wj 438 end 439 sv_repl s part t wa sv_tlen t wa part wrep 0 wn 440 wk = add wk 2 441 end 442 end 443 note sv_rtext: oracle reader_text of [a, b) in slot src, as a new slot. 444 fn sv_rtext src ulong a ulong b ulong to ulong 445 wf = sv_slot1 a b src 446 wg = sv_strip wf 23 447 sv_untag wg 448 sv_ents wg vxent1 449 sv_squash wg 450 sv_coll wf wg 451 ret wf 452 end 453 454 note ---------------------------------------------------------------- anchors 455 note sv_anx: the next anchor at or after i in [0, lim) of slot r (oracle anchors over the prefix 456 note r[..lim]). Returns its '<' or VNONE; vax[0] = '>' of the open tag, vax[1] = the close (or lim), 457 note vax[2] = href offset or VNONE, vax[3] = href length. 458 fn sv_anx r ulong i ulong lim ulong to ulong 459 while true bound 999999 460 wa = sv_findx r vxa i lim true 461 if eq wa VNONE 462 ret VNONE 463 end 464 i = add wa 2 465 if lt i lim 466 if sv_awsr sv_lc sv_b r i 467 wg = sv_findb2 r 62 wa 468 if or eq wg VNONE ge wg lim 469 ret VNONE 470 end 471 wc = sv_findx r vxaend wg lim true 472 if eq wc VNONE 473 wc = lim 474 end 475 put vax 0 wg 476 put vax 1 wc 477 put vax 2 sv_attr r wa wg vxhref 478 put vax 3 get vav 0 479 ret wa 480 end 481 end 482 end 483 ret VNONE 484 end 485 fn sv_hrefis r ulong want view uchar * to bool 486 if eq get vax 2 VNONE 487 ret eq len want 0 488 end 489 if ne get vax 3 len want 490 ret false 491 end 492 ret sv_eqat r get vax 2 want 493 end 494 note sv_alink: first anchor from i in r[..lim] with href == want whose reader text satisfies mode: 495 note 0 not empty, 1 contains 'X', 2 equals the label set by sv_setlab. Returns the index after it 496 note (its close) or VNONE. 497 fn sv_setlab label view uchar * to void 498 if gt len label len vlab 499 sr_fail vtcap 500 end 501 for wj ulong len label 502 put vlab wj get label wj 503 end 504 put vlabn 0 len label 505 end 506 fn sv_labis t ulong to bool 507 if ne sv_n t get vlabn 0 508 ret false 509 end 510 for wj ulong sv_n t 511 if ne sv_b t wj get vlab wj 512 ret false 513 end 514 end 515 ret true 516 end 517 fn sv_alink r ulong i ulong lim ulong want view uchar * mode ulong to ulong 518 while true bound 999999 519 wa = sv_anx r i lim 520 if eq wa VNONE 521 ret VNONE 522 end 523 wc = get vax 1 524 if sv_hrefis r want 525 wt = sv_rtext r add get vax 0 1 wc 526 wok = gt sv_n wt 0 527 if eq mode 1 528 wok = ne sv_findb wt 88 VNONE 529 end 530 if eq mode 2 531 wok = sv_labis wt 532 end 533 sv_drop wt 534 if wok 535 ret wc 536 end 537 end 538 i = wc 539 end 540 ret VNONE 541 end 542 543 note ---------------------------------------------------------------- classes and ids 544 note sv_fclass: oracle find_class: the first tag from i (not '), VNONE. 546 fn sv_fclass s ulong i ulong token view uchar * to ulong 547 while true bound 999999 548 wl = sv_findb2 s 60 i 549 if eq wl VNONE 550 ret VNONE 551 end 552 wg = sv_tagend s wl 553 if eq wg VNONE 554 ret VNONE 555 end 556 wc = sv_bat s add wl 1 557 if not or eq wc 47 eq wc 33 558 wv = sv_attr s wl wg vxclass 559 if ne wv VNONE 560 if sv_hastok s wv get vav 0 token false 561 put vax 0 wg 562 ret wl 563 end 564 end 565 end 566 i = add wg 1 567 end 568 ret VNONE 569 end 570 note sv_hastok: the value [v, v+n) split on whitespace (ASCII, or Unicode when uni) holds token. 571 fn sv_hastok s ulong v ulong n ulong token view uchar * uni bool to bool 572 wi = v 573 we = add v n 574 while lt wi we bound 999999 575 while and lt wi we sv_tokws s wi uni bound 999999 576 wi = add wi sv_cpl s wi 577 end 578 wst = wi 579 while and lt wi we not sv_tokws s wi uni bound 999999 580 wi = add wi sv_cpl s wi 581 end 582 if and gt wi wst eq sub wi wst len token 583 if sv_eqat s wst token 584 ret true 585 end 586 end 587 end 588 ret false 589 end 590 fn sv_tokws s ulong i ulong uni bool to bool 591 if uni 592 ret sv_ins sv_cp s i 593 end 594 ret sv_aws sv_b s i 595 end 596 note sv_hasid: oracle has_id over the markup slot m (already stripped with flags 7). 597 fn sv_hasid m ulong id view uchar * to bool 598 wi = ulong 0 599 while true bound 999999 600 wl = sv_findb2 m 60 wi 601 if eq wl VNONE 602 ret false 603 end 604 wg = sv_tagend m wl 605 if eq wg VNONE 606 ret false 607 end 608 if ne sv_bat m add wl 1 47 609 if sv_aeq m sv_attr m wl wg vxid id 610 ret true 611 end 612 end 613 wi = add wg 1 614 end 615 ret false 616 end 617 note sv_mains: the number of " or whitespace in r (ASCII case-insensitive), 618 note vax[0] = the first one. 619 fn sv_mains r ulong to ulong 620 wc = ulong 0 621 wi = ulong 0 622 while true bound 999999 623 wm = sv_findc r vxmain wi 624 if eq wm VNONE 625 ret wc 626 end 627 if sv_awsr sv_lc sv_bat r add wm 5 628 if eq wc 0 629 put vax 0 wm 630 end 631 wc = add wc 1 632 end 633 wi = add wm 1 634 end 635 ret wc 636 end