Skip to content

Inaccurate comment of flush #51

Open
@metab0t

Description

@metab0t

The comment says that flush returns the number of bytes written to output buffer, but it returns the encoder. Is the comment outdated?

# Flush input buffer and convert it into output buffer
# Returns the number of bytes written to output buffer
function flush(s::StringEncoder)
s.cd == C_NULL && return s
# We need to retry several times in case output buffer is too small to convert
# all of the input. Even so, some incomplete sequences may remain in the input
# until more data is written, which will only trigger an error on close().
s.outbytesleft[] = 0
while s.outbytesleft[] < BUFSIZE
iconv!(s.cd, s.inbuf, s.outbuf, s.inbufptr, s.outbufptr, s.inbytesleft, s.outbytesleft)
write(s.stream, view(s.outbuf, 1:(BUFSIZE - Int(s.outbytesleft[]))))
end
s
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions