]> git.proxmox.com Git - mirror_edk2.git/commit - StdLib/LibC/Uefi/InteractiveIO/IIO.c
StdLib: Fix IIO_Write() to return the number of bytes consumed, not characters output.
authorDaryl McDaniel <edk2-lists@mc2research.org>
Wed, 6 Jan 2016 00:44:24 +0000 (00:44 +0000)
committerdarylm503 <darylm503@Edk2>
Wed, 6 Jan 2016 00:44:24 +0000 (00:44 +0000)
commit86f2165dc37427f4a9f781ee1c6957eeca1460b1
tree0bfb1345e2f9ea0d05b04fec990d79923edb9bd9
parent450ea6d5b69cffd2b6c2154fdbeec5bf60c8c858
StdLib: Fix IIO_Write() to return the number of bytes consumed, not characters output.

Depending upon termios settings, writing to a terminal device may result in
many more characters being output than were in the buffer provided to the
IIO_Write() function.

IIO_Write() is supposed to return the number of BYTES written, not characters.
Since the provided buffer contains MBCS characters, there can be up to three
bytes per character.  Due to the expansion that may occur, "BYTES written"
is interpreted to mean the number of BYTES consumed from the MBCS buffer
provided as a parameter to IIO_Write.

These changes ensure that the correct number of characters are consumed from
the internal Output buffer and the correct number of BYTES consumed from the
buffer parameter are counted and returned.

Update copyright.
Fix some indentation and white space issues.
Improve comments for IIO_Write().
Add debugging instrumentation to count unconsumed data in the Input and Output buffers.
Modify IIO_Write() to:
  Accurately count input bytes CONSUMED.
  Consume only as many expanded (cooked) characters from the output buffer
  as were actually sent to the device.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Daryl McDaniel <edk2-lists@mc2research.org>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19589 6f19259b-4bc3-4df7-8a09-765794883524
StdLib/LibC/Uefi/InteractiveIO/IIO.c