diff options
author | Niels Möller <nisse@lysator.liu.se> | 2014-10-22 19:30:02 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2014-10-22 19:30:02 +0200 |
commit | 94269a22013fac7bfc5591021ab142dffd45a845 (patch) | |
tree | 06c3a19c60366cd268696df750e68f0330e4a4bc | |
parent | 8df195405cb033ec4d13ef8b8ce4ae2029cd9db8 (diff) | |
download | nettle-94269a22013fac7bfc5591021ab142dffd45a845.tar.gz |
Fallback for missing getline (used in the testsuite).
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | testsuite/ed25519-test.c | 38 |
3 files changed, 44 insertions, 1 deletions
@@ -1,5 +1,9 @@ 2014-10-22 Niels Möller <nisse@lysator.liu.se> + * configure.ac: Check for getline function. + * testsuite/ed25519-test.c (getline) [!HAVE_GETLINE]: Fallback + definition. + * Makefile.in (clean-here): Unconditionally delete .so and .dll files. (IMPLICIT_TARGETS): Deleted variable. diff --git a/configure.ac b/configure.ac index 3e464e71..bb33962c 100644 --- a/configure.ac +++ b/configure.ac @@ -647,7 +647,8 @@ AC_CHECK_HEADERS([valgrind/memcheck.h]) LSH_FUNC_ALLOCA LSH_FUNC_STRERROR - +# Used in the testsuite +AC_CHECK_FUNCS(getline) AC_C_BIGENDIAN LSH_GCC_ATTRIBUTES diff --git a/testsuite/ed25519-test.c b/testsuite/ed25519-test.c index be131376..924ecea6 100644 --- a/testsuite/ed25519-test.c +++ b/testsuite/ed25519-test.c @@ -117,6 +117,44 @@ test_one (const char *line) free (msg); } +#ifndef HAVE_GETLINE +static ssize_t +getline(char **lineptr, size_t *n, FILE *f) +{ + size_t i; + int c; + if (!*lineptr) + { + *n = 500; + *lineptr = xalloc (*n); + } + + i = 0; + do + { + c = getc(f); + if (c < 0) + { + if (i > 0) + break; + return -1; + } + + (*lineptr) [i++] = c; + if (i == *n) + { + *n *= 2; + *lineptr = realloc (*lineptr, *n); + if (!*lineptr) + die ("Virtual memory exhausted.\n"); + } + } while (c != '\n'); + + (*lineptr) [i] = 0; + return i; +} +#endif + void test_main(void) { |