Mail Archives: djgpp-workers/1997/09/23/10:23:01
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 -