reusable icon indicating copy to clipboard operation
reusable copied to clipboard

Console: a full buffer without an ENDLINE breaks the console

Open simap opened this issue 3 years ago • 0 comments

In ConsoleProcess, if the buffer is completely full, the call to ConsoleIoReceive will return 0 and no command parsing/processing will be done, and the buffer will remain full. https://github.com/eleciawhite/reusable/blob/22fe5a390a181338b0e21dac6c8d35101d78880d/source/console.c#L139

This can happen if you enter a single line longer than the buffer size (256).

The fix could take several routes with different implications.

The special "buffer full without an ENDLINE" condition could be detected and take of these actions:

  1. Remove the oldest character e.g. with ConsoleResetBuffer(mReceiveBuffer, mReceivedSoFar, 1)
  2. Clear the whole buffer e.g. with ConsoleResetBuffer(mReceiveBuffer, mReceivedSoFar, mReceivedSoFar)
  3. Assume that characters on this line received now and in the future are in a state that is not recoverable, and enter a line purge mode. Emit an error message, then the buffer would be cleared continuously without command processing until an ENDLINE appeared and started a new line, and line purge mode would end and normal processing would continue.

simap avatar Feb 22 '22 23:02 simap