From be4a7604abed3b0a3ffb85c9ecb5f5bfa63e74fc Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 25 Jul 2013 10:33:25 +0200 Subject: reintroduce warning about line breaks --- nthash.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nthash.c b/nthash.c index ac3922a..6cd069b 100644 --- a/nthash.c +++ b/nthash.c @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -23,7 +24,7 @@ int main(int argc, char **argv) { char buffer[BUF_SIZE], buffernull[2 * BUF_SIZE]; char *in = buffer, *out = buffernull; uint8_t digest[MD4_DIGEST_SIZE]; - int i; + int i, linebreak = 0; size_t done, inbytes, outbytes; iconv_t conv; @@ -32,6 +33,9 @@ int main(int argc, char **argv) { done = inbytes = fread(buffer, 1, BUF_SIZE, stdin); outbytes = 2 * inbytes; + if (strstr(buffer, "\n") != NULL) + linebreak++; + conv = iconv_open(TOCODE, FROMCODE); iconv(conv, &in, &inbytes, &out, &outbytes); iconv_close(conv); @@ -43,6 +47,9 @@ int main(int argc, char **argv) { if (ferror(stdin)) return EXIT_FAILURE; + if (linebreak) + fprintf(stderr, "Warning: Input contains line break!\n"); + md4_digest(&ctx, MD4_DIGEST_SIZE, digest); for (i = 0; i < MD4_DIGEST_SIZE; i++) -- cgit v1.2.3-70-g09d2