[PATCH] Fix FreeBSD build
Vladimir Davydov
vdavydov.dev at gmail.com
Tue Mar 20 16:10:08 MSK 2018
Looks good to me.
On Tue, Mar 20, 2018 at 03:49:03PM +0300, Konstantin Belyavskiy wrote:
> Under FreeBSD getline prototype is not provided by
> default due to compatibility problems.
> Get rid of getline (use fgets instead).
> Based on @locker proposal.
>
> Closes #3217.
> ---
> branch: gh-3217-enable-getline-prototype-freebsd
> test/unit/say.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/test/unit/say.c b/test/unit/say.c
> index 4e4b3f94e..d3c70b345 100644
> --- a/test/unit/say.c
> +++ b/test/unit/say.c
> @@ -113,18 +113,18 @@ int main()
> log_say(&test_log, 0, NULL, 0, NULL, "hello %s", "user");
>
> FILE* fd = fopen(tmp_filename, "r");
> - char *line = NULL;
> - size_t len = 0;
> + const size_t len = 4096;
> + char line[len];
>
> - if (getline(&line, &len, fd) != -1) {
> + if (fgets(line, len, fd) != NULL) {
> ok(strstr(line, "hello user") != NULL, "plain");
> - getline(&line, &len, fd);
> + fgets(line, len, fd);
> }
> - if (getline(&line, &len, fd) != -1) {
> + if (fgets(line, len, fd) != NULL) {
> ok(strstr(line, "\"message\": \"hello user\"") != NULL, "json");
> }
>
> - if (getline(&line, &len, fd) != -1) {
> + if (fgets(line, len, fd) != NULL) {
> ok(strstr(line, "\"msg\" = \"hello user\"") != NULL, "custom");
> }
> log_destroy(&test_log);
More information about the Tarantool-patches
mailing list