Skip to content

Commit

Permalink
Fix some arithmetic invalidations
Browse files Browse the repository at this point in the history
  • Loading branch information
omus committed Sep 30, 2020
1 parent 28330a2 commit 72ebdec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions base/ryu/shortest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ end
c1 = (c ÷ 100) << 1
d0 = (d % 100) << 1
d1 = (d ÷ 100) << 1
memcpy(ptr, pos + olength - 2, ptr2, c0 + 1, 2)
memcpy(ptr, pos + olength - 4, ptr2, c1 + 1, 2)
memcpy(ptr, pos + olength - 6, ptr2, d0 + 1, 2)
memcpy(ptr, pos + olength - 8, ptr2, d1 + 1, 2)
memcpy(ptr, pos + olength - 2, ptr2, (c0 + 1)::UInt, 2)
memcpy(ptr, pos + olength - 4, ptr2, (c1 + 1)::UInt, 2)
memcpy(ptr, pos + olength - 6, ptr2, (d0 + 1)::UInt, 2)
memcpy(ptr, pos + olength - 8, ptr2, (d1 + 1)::UInt, 2)
i += 8
end
output2 = output % UInt32
Expand All @@ -377,14 +377,14 @@ end
output2 = div(output2, UInt32(10000))
c0 = (c % 100) << 1
c1 = (c ÷ 100) << 1
memcpy(ptr, pos + olength - i - 2, ptr2, c0 + 1, 2)
memcpy(ptr, pos + olength - i - 4, ptr2, c1 + 1, 2)
memcpy(ptr, pos + olength - i - 2, ptr2, (c0 + 1)::UInt, 2)
memcpy(ptr, pos + olength - i - 4, ptr2, (c1 + 1)::UInt, 2)
i += 4
end
if output2 >= 100
c = (output2 % UInt32(100)) << 1
output2 = div(output2, UInt32(100))
memcpy(ptr, pos + olength - i - 2, ptr2, c + 1, 2)
memcpy(ptr, pos + olength - i - 2, ptr2, (c + 1)::UInt, 2)
i += 2
end
if output2 >= 10
Expand Down
2 changes: 1 addition & 1 deletion base/strings/string.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ String(s::CodeUnits{UInt8,String}) = s.s
## low-level functions ##

pointer(s::String) = unsafe_convert(Ptr{UInt8}, s)
pointer(s::String, i::Integer) = pointer(s)+(i-1)
pointer(s::String, i::Integer) = pointer(s) + (i - 1)::Integer

@pure ncodeunits(s::String) = Core.sizeof(s)
codeunit(s::String) = UInt8
Expand Down

0 comments on commit 72ebdec

Please sign in to comment.