parsing environment variables
This commit is contained in:
parent
2c0fa53c08
commit
f76efb0bfb
|
@ -0,0 +1,28 @@
|
|||
0 VAR TLSHASH
|
||||
0 VAR QUERY
|
||||
|
||||
: crap {
|
||||
dup 12 +
|
||||
dup @
|
||||
begin
|
||||
ENVHASH
|
||||
$40B37439 case ( over TLSHASH ! )
|
||||
$B00047B5 case ( over QUERY ! )
|
||||
drop drop
|
||||
4 +
|
||||
dup @
|
||||
dup while
|
||||
drop
|
||||
; }
|
||||
|
||||
|
||||
|
||||
( " 20 text/gemini" type $0D emit $0A emit )
|
||||
crap
|
||||
|
||||
." TLS: " TLSHASH @ ( dup if dup strlen type else drop thanx cr )
|
||||
|
||||
." QUERY: " QUERY @ ( dup if ( strlen type ) else ( drop ) thanx cr )
|
||||
|
||||
|
||||
0 bye
|
3
nf.f
3
nf.f
|
@ -1,4 +1,4 @@
|
|||
( ." nForth 0.0.1, Copyright (C) 2022 StackSmith" cr )
|
||||
\ ( ." nForth 0.0.1, Copyright (C) 2022 StackSmith" cr )
|
||||
|
||||
: lit, { \ (val--) compile value as a literal
|
||||
' lit , , ; }
|
||||
|
@ -105,7 +105,6 @@
|
|||
dotprim ;
|
||||
}
|
||||
sync
|
||||
( ." done" cr )
|
||||
|
||||
\ [ " tstamp.f" included; ]
|
||||
( " cgi.f" included; )
|
||||
|
|
28
nforth.asm
28
nforth.asm
|
@ -369,9 +369,9 @@ NEXT
|
|||
|
||||
|
||||
;;; ----------------------------------------------------------------------------
|
||||
;;; Hash a string at esi, advancing esi until WS. Hash overwrites EBX.
|
||||
;;;
|
||||
_FNV1a: ;from esi
|
||||
;;; Hash a string at esi, advancing esi until WS. Hash returned in TOS.
|
||||
;;; also, exits when cl is matched!
|
||||
_FNV1a: ;from esi
|
||||
DSTACK
|
||||
push ebx
|
||||
RSTACK
|
||||
|
@ -379,15 +379,15 @@ _FNV1a: ;from esi
|
|||
jmp .in
|
||||
.loop:
|
||||
inc esi
|
||||
xor eax,ebx ;eax = char xor hash
|
||||
xor eax,ebx ;eax = char xor hash
|
||||
mov edx,FNV_PRIME
|
||||
mul edx ;eax = (char xor hash) * FNV_PRIME
|
||||
mul edx ;eax = (char xor hash) * FNV_PRIME
|
||||
mov ebx,eax
|
||||
.in:
|
||||
movzx eax,byte[esi] ;eax = char
|
||||
movzx eax,byte[esi] ;eax = char
|
||||
cmp al,cl
|
||||
je .out
|
||||
_IS_WS al
|
||||
_IS_WS al ;set C if WS
|
||||
jnc .loop
|
||||
.out:
|
||||
ret
|
||||
|
@ -401,6 +401,20 @@ HEADN XHASH,"HASH",$+4
|
|||
NEXT
|
||||
;
|
||||
|
||||
;;-----------------------------------------------------------------------------
|
||||
;; Hash an environment variable, updating the variable to 0-terminated value
|
||||
;; (ptr--ptr,hash)
|
||||
HEADN ENVHASH,"ENVHASH",$+4
|
||||
push esi
|
||||
mov cl,'='
|
||||
mov esi,ebx
|
||||
call _FNV1a
|
||||
inc esi
|
||||
mov [ebp],esi ;save updated ptr
|
||||
pop esi
|
||||
NEXT
|
||||
|
||||
|
||||
HEAD strlen,$+4 ; (str--str,len)
|
||||
DSTACK
|
||||
push ebx
|
||||
|
|
Loading…
Reference in New Issue