parsav  Diff

Differences From Artifact [1d1d177061]:

To Artifact [60110bc615]:


224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253

254

255
256
257
258
259
260
261
262
263
	var sz: intptr = 0
	for i = 0, f.ct do
		if f(i) == @',' then goto skip end
		if f(i) >= 0x30 and f(i) <= 0x39 then
			sz = sz * 10
			sz = sz + f(i) - 0x30
		else
			if i+1 == f.ct or f(i) == 0 then return sz, true end
			if i+2 == f.ct or f(i+1) == 0 then
				if f(i) == @'b' then return sz/8, true end -- bits
			else
				var s: intptr = 0
				if i+3 == f.ct or f(i+2) == 0 then 
					s = i + 1
				elseif (i+4 == f.ct or f(i+3) == 0) and f(i+1) == @'i' then
				-- grudgingly tolerate ~mebibits~ and its ilk, without
				-- affecting the result in any way
					s = i + 2
				else return 0, false end

				if f(s) == @'b' then sz = sz/8 -- bits
				elseif f(s) ~= @'B' then return 0, false end -- wth
			end
			var c = f(i)
			if c >= @'A' and c <= @'Z' then c = c - 0x20 end
			switch c do -- normal char literal syntax doesn't work here, leads to llvm error (!!)
				case [uint8]([string.byte('k')]) then return sz * [1024ULL ^ 1], true end
				case [uint8]([string.byte('m')]) then return sz * [1024ULL ^ 2], true end
				case [uint8]([string.byte('g')]) then return sz * [1024ULL ^ 3], true end
				case [uint8]([string.byte('t')]) then return sz * [1024ULL ^ 4], true end

				case [uint8]([string.byte('e')]) then return sz * [1024ULL ^ 5], true end

				case [uint8]([string.byte('y')]) then return sz * [1024ULL ^ 6], true end
				else return sz, true
			end
		end
	::skip::end
	return sz, true
end

return m







|
|



|

|









|





>
|
>
|
|







224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
	var sz: intptr = 0
	for i = 0, f.ct do
		if f(i) == @',' then goto skip end
		if f(i) >= 0x30 and f(i) <= 0x39 then
			sz = sz * 10
			sz = sz + f(i) - 0x30
		else
			if i+0 == f.ct or f(i) == 0 then return sz, true end
			if i+1 == f.ct or f(i+1) == 0 then
				if f(i) == @'b' then return sz/8, true end -- bits
			else
				var s: intptr = 0
				if i+2 == f.ct or f(i+2) == 0 then 
					s = i + 1
				elseif (i+3 == f.ct or f(i+3) == 0) and f(i+1) == @'i' then
				-- grudgingly tolerate ~mebibits~ and its ilk, without
				-- affecting the result in any way
					s = i + 2
				else return 0, false end

				if f(s) == @'b' then sz = sz/8 -- bits
				elseif f(s) ~= @'B' then return 0, false end -- wth
			end
			var c = f(i)
			if c >= @'A' and c <= @'Z' then c = c + 0x20 end
			switch c do -- normal char literal syntax doesn't work here, leads to llvm error (!!)
				case [uint8]([string.byte('k')]) then return sz * [1024ULL ^ 1], true end
				case [uint8]([string.byte('m')]) then return sz * [1024ULL ^ 2], true end
				case [uint8]([string.byte('g')]) then return sz * [1024ULL ^ 3], true end
				case [uint8]([string.byte('t')]) then return sz * [1024ULL ^ 4], true end
				case [uint8]([string.byte('p')]) then return sz * [1024ULL ^ 5], true end
				case [uint8]([string.byte('e')]) then return sz * [1024ULL ^ 6], true end
				case [uint8]([string.byte('z')]) then return sz * [1024ULL ^ 7], true end
				case [uint8]([string.byte('y')]) then return sz * [1024ULL ^ 8], true end
				else return 0, false
			end
		end
	::skip::end
	return sz, true
end

return m