mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2024-12-28 04:23:38 +01:00
stdio: stdin/stdout/stderr, perror, final adjustments
Support for <stdio.h> will stop here for now.
This commit is contained in:
parent
ed873a652e
commit
71866ed769
5 changed files with 50 additions and 15 deletions
|
@ -143,6 +143,7 @@ set(SOURCES
|
|||
src/libc/stdio/getc.c
|
||||
src/libc/stdio/getchar.c
|
||||
src/libc/stdio/gets.c
|
||||
src/libc/stdio/perror.c
|
||||
src/libc/stdio/printf.c
|
||||
src/libc/stdio/printf/format_fixed.c
|
||||
src/libc/stdio/printf/format_fp.c
|
||||
|
@ -158,6 +159,7 @@ set(SOURCES
|
|||
src/libc/stdio/setvbuf.c
|
||||
src/libc/stdio/snprintf.c
|
||||
src/libc/stdio/sprintf.c
|
||||
src/libc/stdio/streams.c
|
||||
src/libc/stdio/ungetc.c
|
||||
src/libc/stdio/vasprintf.c
|
||||
src/libc/stdio/vdprintf.c
|
||||
|
|
28
STATUS
28
STATUS
|
@ -84,8 +84,8 @@ TEST: Function/symbol/macro needs to be tested
|
|||
7.18 <stdint.h> => GCC
|
||||
|
||||
7.19 <stdio.h>
|
||||
7.19.1 Introduction TEST (no wide-oriented streams *)
|
||||
7.19.1 stdin, stdout, stderr TODO
|
||||
7.19.1 Introduction - (no wide-oriented streams *)
|
||||
7.19.1 stdin, stdout, stderr -
|
||||
|
||||
7.19.4.1 remove TEST
|
||||
7.19.4.2 rename TODO
|
||||
|
@ -93,42 +93,42 @@ TEST: Function/symbol/macro needs to be tested
|
|||
7.19.4.4 tmpnam TODO
|
||||
|
||||
7.19.5.1 fclose -
|
||||
7.19.5.2 fflush -
|
||||
7.19.5.2 fflush - (fflush(NULL) not supported yet)
|
||||
7.19.5.3 fopen -
|
||||
(EXT) fdopen -
|
||||
7.19.5.4 freopen -
|
||||
7.19.5.5 setbuf -
|
||||
7.19.5.6 setvbuf -
|
||||
|
||||
7.19.6.1 fprintf TEST
|
||||
7.19.6.1 fprintf -
|
||||
7.19.6.2 fscanf TODO
|
||||
7.19.6.3 printf LDEPS(stdout)
|
||||
7.19.6.3 printf -
|
||||
7.19.6.4 scanf TODO
|
||||
7.19.6.5 snprintf -
|
||||
7.19.6.6 sprintf -
|
||||
7.19.6.7 sscanf TODO
|
||||
7.19.6.8 vfprintf TEST
|
||||
7.19.6.8 vfprintf -
|
||||
7.19.6.9 vfscanf TODO
|
||||
7.19.6.10 vprintf LDEPS(stdout)
|
||||
7.19.6.10 vprintf -
|
||||
7.19.6.11 vscanf TODO
|
||||
7.19.6.12 vsnprintf -
|
||||
7.19.6.13 vsprintf -
|
||||
7.19.6.14 vsscanf TODO
|
||||
(EXT) asprintf -
|
||||
(EXT) vasprintf -
|
||||
(EXT) dprintf TEST
|
||||
(EXT) vdprintf TEST
|
||||
(EXT) dprintf -
|
||||
(EXT) vdprintf -
|
||||
|
||||
7.19.7.1 fgetc -
|
||||
7.19.7.2 fgets -
|
||||
7.19.7.3 fputc -
|
||||
7.19.7.4 fputs -
|
||||
7.19.7.5 getc -
|
||||
7.19.7.6 getchar LDEPS(stdin)
|
||||
7.19.7.7 gets LDEPS(stdin)
|
||||
7.19.7.6 getchar -
|
||||
7.19.7.7 gets -
|
||||
7.19.7.8 putc -
|
||||
7.19.7.9 putchar LDEPS(stdout)
|
||||
7.19.7.10 puts LDEPS(stdout)
|
||||
7.19.7.9 putchar -
|
||||
7.19.7.10 puts -
|
||||
7.19.7.11 ungetc -
|
||||
|
||||
7.19.8.1 fread -
|
||||
|
@ -143,7 +143,7 @@ TEST: Function/symbol/macro needs to be tested
|
|||
7.19.10.1 clearerr -
|
||||
7.19.10.2 feof -
|
||||
7.19.10.3 ferror -
|
||||
7.19.10.4 perror TODO
|
||||
7.19.10.4 perror -
|
||||
|
||||
7.20 <stdlib.h>
|
||||
7.20 MB_CUR_MAX TODO
|
||||
|
|
15
src/libc/stdio/perror.c
Normal file
15
src/libc/stdio/perror.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
void perror(char const *s)
|
||||
{
|
||||
int errno_copy = errno;
|
||||
|
||||
if(s != NULL) {
|
||||
fputs(s, stderr);
|
||||
fputs(": ", stderr);
|
||||
}
|
||||
fputs(strerror(errno_copy), stderr);
|
||||
fputc('\n', stderr);
|
||||
}
|
|
@ -107,7 +107,7 @@ void __printf_flush(struct __printf_output *out)
|
|||
/* File pointer: output with fwrite */
|
||||
else if(out->fp)
|
||||
{
|
||||
// fwrite(out->buffer, out->ptr - out->buffer, 1, out->fp);
|
||||
fwrite(out->buffer, 1, out->ptr - out->buffer, out->fp);
|
||||
}
|
||||
/* File pointer: output with write */
|
||||
else if(out->fd)
|
||||
|
|
18
src/libc/stdio/streams.c
Normal file
18
src/libc/stdio/streams.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
FILE *stdin;
|
||||
FILE *stdout;
|
||||
FILE *stderr;
|
||||
|
||||
__attribute__((constructor))
|
||||
static void initialize_streams(void)
|
||||
{
|
||||
stdin = fdopen(STDIN_FILENO, "r");
|
||||
|
||||
stdout = fdopen(STDOUT_FILENO, "w");
|
||||
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
|
||||
|
||||
stderr = fdopen(STDERR_FILENO, "w");
|
||||
setvbuf(stderr, NULL, _IONBF, 0);
|
||||
}
|
Loading…
Reference in a new issue