www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/09/23/10:23:01

From: molnarl AT cdata DOT tvnet DOT hu
Date: Tue, 23 Sep 1997 16:22:43 +0200 (MET DST)
To: djgpp-workers AT delorie DOT com
Subject: perl and stdio test
Message-ID: <Pine.SOL.3.95.970923155740.3138B-100000@dumballah.tvnet.hu>
MIME-Version: 1.0

Perl's Configure script uses this test, to decide whether libc's stdio is
"standard". I was a little bit surprised, when I saw that the script wrote
that "Your stdio isn't very std.". I looked at libc's source, and found,
that _filbuf doesn't convert 0x0d 0x0a -> 0x0a if the file is opened in
text mode, but getc() does. Then I found why: there is an optimalization
in fseek() which wants the bytes unaltered. I'm just curious, is there
another reason why filbuf doesn't make the conversion?

-- 

echo "Checking how std your stdio is..." >&4
$cat >try.c <<EOP
#include <stdio.h>
#define FILE_ptr(fp)	(fp)->_ptr
#define FILE_cnt(fp)	(fp)->_cnt
main() {
	FILE *fp = fopen("try.c", "r");
	char c = getc(fp);
	if (
		18 <= FILE_cnt(fp) &&
		strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
	)
		exit(0);
	exit(1);
}
EOP
val="$undef"
if $cc $ccflags $ldflags -o try try.c $libs >/dev/null 2>&1; then
	if ./try; then
		echo "Your stdio acts pretty std."
		val="$define"
	else
		echo "Your stdio isn't very std."
	fi
else
	echo "Your stdio doesn't appear very std."
fi

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019