From c3b9af3831762d7548eb1e72cfb62ab95e0d8490 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sat, 30 May 2020 21:32:05 +0200 Subject: common: bc_stdin_read() should set read length --- src/common/stdin.c | 6 +++++- src/common/stdin.h | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/stdin.c b/src/common/stdin.c index a460247..c4bf746 100644 --- a/src/common/stdin.c +++ b/src/common/stdin.c @@ -14,11 +14,15 @@ // splitted in single file to make it easier to test char* -bc_stdin_read(void) +bc_stdin_read(size_t *len) { + if (len == NULL) + return NULL; + int c; bc_string_t *rv = bc_string_new(); while (EOF != (c = fgetc(stdin))) bc_string_append_c(rv, c); + *len = rv->len; return bc_string_free(rv, false); } diff --git a/src/common/stdin.h b/src/common/stdin.h index e6bd7a0..be99922 100644 --- a/src/common/stdin.h +++ b/src/common/stdin.h @@ -9,6 +9,8 @@ #ifndef _STDIN_H #define _STDIN_H -char* bc_stdin_read(void); +#include + +char* bc_stdin_read(size_t *len); #endif /* _STDIN_H */ -- cgit v1.2.3-18-g5258