[PATCH] Fix FreeBSD build
Konstantin Belyavskiy
k.belyavskiy at tarantool.org
Tue Mar 20 15:49:03 MSK 2018
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);
--
2.14.3 (Apple Git-98)
More information about the Tarantool-patches
mailing list