From: tlaronde@polynum.com
To: ori@eigenstate.org
Cc: 9front@9front.org
Subject: Re: [FOUND] [9front] putc/fputc incorrect return
Date: Sat, 11 Jul 2020 16:39:22 +0200 [thread overview]
Message-ID: <20200711143922.GB563@polynum.com> (raw)
In-Reply-To: <9886E456A839F5CDF03974A2426A0518@eigenstate.org>
Here is the simple code exhibiting the problem. There are three
components:
1) int is negative;
2) there are at least two successive calls;
3) the stream is neither stdout nor stderr.
#include <u.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
FILE *fp;
short w;
if ( (fp = fopen("/tmp/bug.tfm", "wb")) == NULL ) {
(void)fprintf(stderr, "Unable to open '/tmp/bug.tfm' for writing.\n");
return 1;
}
/* Writing successively negative word on the file stream: bug.
*/
w = 0xffaa;
(void)fprintf(stderr, "\nWriting big endian '%#hx' on file stream returned"
" -> %#x %#x\n", w, putc(w >> 8, fp), putc(w, fp));
/* On stdout, no problem.
*/
(void)fprintf(stderr, "\nWriting big endian '%#hx' on stdout returned"
" -> %#x %#x\n", w, putc(w >> 8, stdout), putc(w, stdout));
return 0;
}
Best,
--
Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
http://www.kergis.com/
http://www.sbfa.fr/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C
next prev parent reply other threads:[~2020-07-11 14:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 8:21 putc/fputc incorrect return? tlaronde
2020-07-09 14:27 ` [9front] " ori
2020-07-09 16:17 ` tlaronde
2020-07-09 16:55 ` ori
2020-07-09 18:29 ` tlaronde
2020-07-09 18:39 ` ori
2020-07-11 14:39 ` tlaronde [this message]
2020-07-11 15:45 ` [FOUND] [9front] putc/fputc incorrect return ori
2020-07-11 16:43 ` tlaronde
2020-07-13 10:36 ` tlaronde
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=20200711143922.GB563@polynum.com \
--to=tlaronde@polynum.com \
--cc=9front@9front.org \
--cc=ori@eigenstate.org \
/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.
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).