From: Xan Phung <xan.phung@gmail.com>
To: musl@lists.openwall.com
Subject: Re: stdio glitch & questions
Date: Sat, 1 Dec 2018 19:02:02 +1100 [thread overview]
Message-ID: <CAO6moYuWzEN4u66H5XL8zWptxkm4ZBjCQKqKSj3QLE00zNBr4Q@mail.gmail.com> (raw)
In-Reply-To: <20181201031736.GU23599@brightrain.aerifal.cx>
[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]
>
> So anyway, I think there are probably some good reasons to do the
> merging in __fwritex rather than in the __stdio_write backend. But it
> should be a lot simpler than what you initially proposed.
>
> Rich
>
Thanks for your feedback! In interest of keeping the proposal as simple as
possible, I've gone with just one extra line of code (see below). It
simply does copying for i <= 8.
It works on my initial testing and I'm getting zero lengths in the 2nd
writev iovec (as expected), but I'll test it more in coming week.
size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict
f)
{
size_t i=0;
if (!f->wend && __towrite(f)) return 0;
if (l > f->wend - f->wpos) return f->write(f, s, l);
if (f->lbf >= 0) {
/* Match /^(.*\n|)/ */
for (i=l; i && s[i-1] != '\n'; i--);
if (i) {
*if (i <= 8) for (; i; i--, l--) *(f->wpos)++ = *s++;*
size_t n = f->write(f, s, i);
if (*!f->wpos ||* n < i) return n;
l -= i;
s += i;
}
}
memcpy(f->wpos, s, l);
f->wpos += l;
return l+i;
}
[-- Attachment #2: Type: text/html, Size: 9327 bytes --]
prev parent reply other threads:[~2018-12-01 8:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-30 10:51 Xan Phung
2018-11-30 16:09 ` Rich Felker
2018-11-30 22:15 ` Xan Phung
2018-12-01 0:02 ` Rich Felker
2018-12-01 2:42 ` Xan Phung
2018-12-01 3:17 ` Rich Felker
2018-12-01 8:02 ` Xan Phung [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAO6moYuWzEN4u66H5XL8zWptxkm4ZBjCQKqKSj3QLE00zNBr4Q@mail.gmail.com \
--to=xan.phung@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).