commit 12cbe34

Devine Lu Linvega  ·  2026-06-21 21:51:11 +0000 UTC
parent 25f89fd
Constraint state within length
2 files changed,  +14, -9
+10, -5
 1@@ -10,16 +10,17 @@
 2 	;meta #06 DEO2
 3 	#800f DEO
 4 	;dict/write file/test-write <test>
 5-	;dict/append file/test-append <test>
 6 	;dict/read file/test-read <test>
 7+	;dict/read-of file/test-read-of <test>
 8+	;dict/write-of file/test-write-of <test>
 9+	;dict/append file/test-append <test>
10+	( | Stat )
11 	;dict/stat file/test-stat <test>
12 	;dict/stat-oversize file/test-stat-oversize <test>
13 	;dict/stat-of file/test-stat-of <test>
14+	( | Delete )
15 	;dict/delete file/test-delete <test>
16-	( | overflows )
17-	;dict/write-of file/test-write-of <test>
18-	;dict/read-of file/test-read-of <test>
19-	( | dir )
20+	( | Dir )
21 	;dict/dir-spacer file/test-dir-spacer <test>
22 	;dict/dir-partial file/test-dir-partial <test>
23 	( ;dict/dir-nostream file/test-dir-nostream <test> ) ( | cleanup )
24@@ -80,6 +81,7 @@
25 @file/test-stat-oversize ( -- pass )
26 	;&name .File/name DEO2
27 	#0020 .File/length DEO2
28+	#00 .File/append DEO
29 	#f000 .File/write DEO2
30 	( | Read stat too small )
31 	;&name .File/name DEO2
32@@ -87,10 +89,13 @@
33 	;&sobuf .File/stat DEO2
34 	;&sobuf LDA #00 EQU ?{ #00 JMP2r }
35 	#0001 .File/length DEO2
36+	;&sobuf .File/stat DEO2
37 	;&sobuf LDA LIT "? EQU ?{ #00 JMP2r }
38 	#0002 .File/length DEO2
39+	;&sobuf .File/stat DEO2
40 	;&sobuf LDA2 LIT2 "20 EQU2 ?{ #00 JMP2r }
41 	#0003 .File/length DEO2
42+	;&sobuf .File/stat DEO2
43 	;&sobuf LDA2 LIT2 "02 EQU2 JMP2r
44 	&sobuf $4
45 
+4, -4
 1@@ -692,14 +692,14 @@ put_fill(Uint8 *dest, unsigned int *length, unsigned int len, char c)
 2 static unsigned int
 3 put_stat(Uint8 *dest, unsigned int *length, unsigned int len, unsigned int size, unsigned int err, unsigned int dir)
 4 {
 5+	unsigned int max = 1 << (len << 2);
 6 	if(dir)
 7 		return put_fill(dest, length, len, '-');
 8 	else if(err)
 9 		return put_fill(dest, length, len, '!');
10-	// TODO: Always check if fits in len
11-	else if(size >= 0x10000)
12-		return put_fill(dest, length, len, '?');
13-	return put_size(dest, length, len, size);
14+	else if(size < max)
15+		return put_size(dest, length, len, size);
16+	return put_fill(dest, length, len, '?');
17 }
18 
19 static unsigned int