diff options
author | Rob Austein <sra@hactrn.net> | 2011-09-01 13:38:32 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2011-09-01 13:38:32 +0000 |
commit | cec3fec3003d90f921046efaee12af0a225a202a (patch) | |
tree | 8b94426ea39ec9d52ca6223e0ed3b343c76dcb77 | |
parent | 00e8ca2940143add3931051f1c7289539891ec03 (diff) |
Oops, memchr() is ISO C but memrchr() isn't.
svn path=/rcynic-ng/bio_f_linebreak.c; revision=3966
-rw-r--r-- | rcynic-ng/bio_f_linebreak.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/rcynic-ng/bio_f_linebreak.c b/rcynic-ng/bio_f_linebreak.c index f9988a3d..0376456e 100644 --- a/rcynic-ng/bio_f_linebreak.c +++ b/rcynic-ng/bio_f_linebreak.c @@ -120,8 +120,7 @@ static int linebreak_free(BIO *b) static int linebreak_read(BIO *b, char *out, int outl) { - int ret = 0, want, n; - char *s; + int ret = 0, want, n, i; if (out == NULL || b->next_bio == NULL || outl <= 0) return 0; @@ -146,8 +145,11 @@ static int linebreak_read(BIO *b, char *out, int outl) BIO_copy_next_retry(b); if (n > 0) { - if ((s = memrchr(out, '\n', n)) != NULL) - b->num = (out + n) - (s + 1); + for (i = n - 1; i >= 0; i--) + if (out[i] == '\n') + break; + if (i >= 0) + b->num = n - i - 1; else b->num += n; out += n; |