Article View: comp.os.msdos.programmer
Article #236Bug in Borland C++ 2.0 stat() ?
From: Mark Hessling
Date: Wed, 05 Aug 1992 11:29
Date: Wed, 05 Aug 1992 11:29
80 lines
3357 bytes
3357 bytes
Based on the following comparison of the output of the following program
compiled with Borland C++ 2.0 and Microsoft C 6.00, it seems that there
is a bug in the Borland stat() function whenever the root directory is
referenced.
I hope that the behaviour of the Microsoft library is correct; this is
the behaviour under Unix.
Can anyone confirm this ?
What about the behaviour of other compilers.
Which behaviour do they follow ?
Can anyone with Borland C++ 3.0/3.1 test to see if the behavior of stat.c
has changed from version 2.00 ?
Any replies greatly appreciated.
Cheers, Mark
------------------------------------------------------------------------
Mark Hessling Email: mark@snark.itc.gu.edu.au
DBA,ITS Phone: +617 875 7691
Griffith University Fax: +617 875 7877
Nathan, Brisbane QLD 4111 Australia *** PDCurses Maintainer ***
------------------------------------------------------------------------
stat.c
------
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
int main(int argc, char *argv[])
{
struct stat stat_buf;
int rc;
rc = stat(argv[1],&stat_buf);
printf("Return from stat():%x\n",rc);
rc = S_IFDIR;
printf("S_IFDIR value:%x\n",rc);
rc = stat_buf.st_mode & S_IFMT;
printf("st_mode & S_IFMT value:%x\n",rc);
}
Microsoft C 6.00 Borland C++ 2.0
---------------- ---------------
cl -AL stat.c bcc -ml stat.c
stat \ stat \
Return from stat():0 Return from stat():ffff
S_IFDIR value:4000 S_IFDIR value:4000
st_mode & S_IFMT value:4000 st_mode & S_IFMT value:7000
stat c:\ stat c:\
Return from stat():0 Return from stat():ffff
S_IFDIR value:4000 S_IFDIR value:4000
st_mode & S_IFMT value:4000 st_mode & S_IFMT value:1000
stat c:\c600\include\..\.. stat c:\c600\include\..\..
Return from stat():0 Return from stat():ffff
S_IFDIR value:4000 S_IFDIR value:4000
st_mode & S_IFMT value:4000 st_mode & S_IFMT value:0
stat c:\c600\include stat c:\c600\include
Return from stat():0 Return from stat():0
S_IFDIR value:4000 S_IFDIR value:4000
st_mode & S_IFMT value:4000 st_mode & S_IFMT value:4000
stat . stat .
Return from stat():0 Return from stat():0
S_IFDIR value:4000 S_IFDIR value:4000
st_mode & S_IFMT value:4000 st_mode & S_IFMT value:4000
stat .. stat ..
Return from stat():0 Return from stat():0
S_IFDIR value:4000 S_IFDIR value:4000
st_mode & S_IFMT value:4000 st_mode & S_IFMT value:4000
Technical Details
Message-ID:
<mark.713014155@snark>Path:
arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!griffin!snark!markShow Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!griffin!snark!mark From: mark@snark.itc.gu.edu.au (Mark Hessling) Subject: Bug in Borland C++ 2.0 stat() ? Message-ID: <mark.713014155@snark> Sender: news@griffin.itc.gu.edu.au Nntp-Posting-Host: snark.itc.gu.edu.au Organization: ITC, Griffith University, Brisbane, Australia Date: 5 Aug 92 11:29:15 GMT Lines: 80