gcc 15 and C23 force some union trickery on buffer.h :-(
add a few buffer_init*_forread variants to pretend we have type safety make sure buffer_init_staticcontents handles flushing attempts
This commit is contained in:
32
buffer/buffer_init_staticcontents_forread.3
Normal file
32
buffer/buffer_init_staticcontents_forread.3
Normal file
@@ -0,0 +1,32 @@
|
||||
.TH buffer_init_staticcontents_forread 3
|
||||
.SH NAME
|
||||
buffer_init_staticcontents_forread \- initialize buffer structure
|
||||
.SH SYNTAX
|
||||
.B #include <libowfat/buffer.h>
|
||||
|
||||
void \fBbuffer_init_staticcontents_forread\fR(buffer &\fIb\fR,
|
||||
const char* \fIy\fR, size_t \fIylen\fR);
|
||||
|
||||
.SH DESCRIPTION
|
||||
buffer_init_staticcontents_forread sets up a buffer for reading,
|
||||
pointing to a pre-filled fixed buffer.
|
||||
|
||||
This is useful for writing unit tests.
|
||||
|
||||
.SH EXAMPLE
|
||||
#include <libowfat/buffer.h>
|
||||
#include <libowfat/open.h>
|
||||
|
||||
char buf[]="foo\\nbar\\n";
|
||||
buffer input;
|
||||
|
||||
char x;
|
||||
buffer_init_staticcontents_forread(&input,buf,sizeof buf);
|
||||
while (buffer_get(&input,&x,1)==1) {
|
||||
buffer_put(buffer_1,&x,1);
|
||||
if (x=='\\n') break;
|
||||
}
|
||||
buffer_flush(buffer_1);
|
||||
|
||||
.SH "SEE ALSO"
|
||||
buffer_init(3), buffer(3), buffer_init_staticcontents(3)
|
||||
Reference in New Issue
Block a user