@@ -128,8 +128,8 @@ load-header: function/with [
128
128
not data: script? tmp [ ; no script header found
129
129
return either required ['no-header] [reduce [none tmp tail tmp]]
130
130
]
131
- set /any [key: rest: ] transcode/only data none ; get 'rebol keyword
132
- set /any [hdr: rest: ] transcode/next/error rest none ; get header block
131
+ set /any [key: rest: line: ] transcode/only/line data 1 none ; get 'rebol keyword
132
+ set /any [hdr: rest: line: ] transcode/next/error/line rest :line none ; get header block
133
133
not block? :hdr [return 'no-header] ; header block is incomplete
134
134
not attempt [hdr: construct /with :hdr system/standard/header ][return 'bad-header]
135
135
word? : hdr/options [hdr/options: to block! : hdr/options ]
@@ -138,10 +138,10 @@ load-header: function/with [
138
138
not tuple? : hdr/version [hdr/version: none]
139
139
find hdr/options 'content [repend hdr ['content data]] ; as of start of header
140
140
13 = rest/1 [rest: next rest] ; skip CR
141
- 10 = rest/1 [rest: next rest] ; skip LF
141
+ 10 = rest/1 [rest: next rest + + line ] ; skip LF
142
142
integer? tmp: select hdr 'length [end: skip rest tmp]
143
143
not end [end: tail data]
144
- only [return reduce [hdr rest end]] ; decompress and checksum not done
144
+ only [return reduce [hdr rest end line ]] ; decompress and checksum not done
145
145
sum: hdr/checksum none ;[print sum] ; none saved to simplify later code
146
146
:key = 'rebol [ ; regular script, binary or script encoded compression supported
147
147
case [
@@ -172,7 +172,7 @@ load-header: function/with [
172
172
]
173
173
;assert/type [hdr object! rest [binary! block!] end binary!]
174
174
;assert/type [hdr/checksum [binary! none!] hdr/options [block! none!]]
175
- reduce [hdr rest end]
175
+ reduce [hdr rest end line ]
176
176
][
177
177
non-ws: make bitset! [not 1 - 32 ]
178
178
]
@@ -270,7 +270,7 @@ read-decode: function [
270
270
; Try to load it (will fail if source is a url)
271
271
data: load-extension source ; returns an object or throws an error
272
272
][
273
- data: read source ; can be string, binary, block
273
+ data: read /binary source ; can be string, binary, block
274
274
if find system/options/file-types type [data: decode type :data ] ; e.g. not 'unbound
275
275
]
276
276
data
@@ -312,29 +312,32 @@ load: function [
312
312
any [file? source url? source] [
313
313
stype: file-type? source
314
314
type: case [
315
- lib/all ['unbound = as 'extension = stype] [stype]
315
+ lib/all ['unbound = type 'extension = stype] [stype]
316
316
as [type]
317
317
'else [stype]
318
318
]
319
319
data: read-decode source type
320
+ if not find [0 extension unbound] any [type 0 ] [return data]
320
321
]
321
322
none? data [data: source]
322
323
323
324
;-- Is it not source code? Then return it now:
324
325
any [block? data not find [0 extension unbound] any [type 0 ]][ ; due to make-boot issue with #[none]
325
- return data ; directory, image, txt, markup, etc.
326
+ unless type [return data]
327
+ try [return decode type to binary! data]
328
+ cause-error 'access 'no-codec type
326
329
]
327
330
328
331
;-- Try to load the header, handle error:
329
332
not all [
330
- set [hdr: data: end: ] either object? data [load-ext-module data] [load-header data]
333
+ set [hdr: data: end: line: ] either object? data [load-ext-module data] [load-header data]
331
334
if word? hdr [cause-error 'syntax hdr source]
332
335
unless tail? end [data: copy/part data end]
333
336
]
334
337
; data is binary or block now, hdr is object or none
335
338
336
339
;-- Convert code to block, insert header if requested:
337
- not block? data [data: make block! data]
340
+ not block? data [data: transcode /line data any [line 1 ] ]
338
341
header [insert data hdr]
339
342
340
343
;-- Bind code to user context:
0 commit comments