Commit Graph

9 Commits

Author SHA1 Message Date
Björn Linse
1ebc96fe10 channels: allow bytes sockets and stdio, and buffered bytes output 2017-11-24 14:54:15 +01:00
ZyX
c2f3e361c5 *: Add comment to all C files 2017-04-19 19:11:50 +03:00
James McCoy
80b808dbfe rbuffer: Use xcalloc to ensure memory is initialized
Since the rbuffer contents are used by string functions (like sscan,
strlen, etc.), it is not safe to use uninitialized memory.  Using
xcalloc ensures the string-based functions do not run past the end of
the buffer.

Closes #5676
2016-11-28 19:32:39 -05:00
Justin M. Keyes
e9061117a5 Merge #4646 from oni-link/fix.issue.4569.3
Fix for missing output (#4569, ...)
2016-06-26 14:36:24 -04:00
ZyX
516b7071ca file: Add buffered reading and writing
Still no busted tests. Not tested without HAVE_PREADV.
2016-06-23 21:17:51 +03:00
oni-link
f0967b0f4c process.c: Prevent data loss for process output streams
For a terminating process, it's output streams could be closed,
before all data is read.
2016-05-15 02:54:09 +02:00
Thiago de Arruda
394c0c4402 rbuffer: Enhance rbuffer_reset to work with filled RBuffers 2015-10-01 15:22:49 -03:00
oni-link
b165145084 rbuffer: Fix for problems with escape input sequences.
If at least two escape sequences were read, the beginning of the
second sequence would be off by one and the sequence would be
misinterpreted.

An escape sequence could be split in two parts and be
misinterpreted, when saved in a ring buffer with wrap around.

Fixes #2936
2015-07-07 16:58:10 +02:00
Thiago de Arruda
0ef80b9c2b rbuffer: Reimplement as a ring buffer and decouple from rstream
Extract the RBuffer class from rstream.c and reimplement it as a ring buffer,
a more efficient version that doesn't need to relocate memory.

The old rbuffer_read/rbuffer_write interfaces are kept for simple
reading/writing, and the RBUFFER_UNTIL_{FULL,EMPTY} macros are introduced to
hide wrapping logic when more control is required(such as passing the buffer
pointer to a library function that writes directly to the pointer)

Also add a basic infrastructure for writing helper C files that are only
compiled in the unit test library, and use this to write unit tests for RBuffer
which contains some macros that can't be accessed directly by luajit.

Helped-by: oni-link <knil.ino@gmail.com>
Reviewed-by: oni-link <knil.ino@gmail.com>
Reviewed-by: Scott Prager <splinterofchaos@gmail.com>
Reviewed-by: Justin M. Keyes <justinkz@gmail.com>
Reviewed-by: Michael Reed <m.reed@mykolab.com>
2015-07-01 05:40:53 -03:00