add >string on byte-array for string comparison

use ERROR:
db4
Doug Coleman 2008-04-26 12:55:10 -05:00
parent 658ec32b67
commit 0b72829d07
1 changed files with 7 additions and 3 deletions

View File

@ -25,10 +25,14 @@ TUPLE: bitmap magic size reserved offset header-length width
{ 1 [ "1bit" throw ] }
} case ;
ERROR: bitmap-magic ;
M: bitmap-magic summary
drop "First two bytes of bitmap stream must be 'BM'" ;
: parse-file-header ( bitmap -- )
2 read [ over set-bitmap-magic ] keep "BM" = [
"BITMAPFILEHEADER: First two bytes must be BM" throw
] unless
2 read >string dup "BM" = [ bitmap-magic ] unless
[ over set-bitmap-magic ] keep
4 read le> over set-bitmap-size
4 read le> over set-bitmap-reserved
4 read le> swap set-bitmap-offset ;