🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.unix
Article #124

Re: Query about <dirent.h>

#124
From: Dennis Ritchie
Date: Wed, 29 Nov 1989 07:51
24 lines
1496 bytes
From: dmr@research.att.com (Dennis Ritchie)

I wish Gwyn et. al had sounded a bit more embarrassed about using
`char d_name[1]' in struct dirent.  Tanenbaum is absolutely correct to
question it; it is an abuse of the language and would not pass a
compiler system with careful run-time checks.  From the language point
of view, there is no reason at all to forbid declaring an instance of
struct dirent, or copying the value pointed to by the value of readdir().
Gwyn's definition implies incorrect C.   (Well, the definition
is well-defined, but not the expectation that there is more than 1 character
actually in the d_name array).

There is no such type as char[], and `char d_name[]' may not appear
in a structure, and if the declaration is `char d_name[1]' then
you may not refer to d_name[i] when i>1.

I don't have the POSIX wording at hand, but if it forbids
`struct dirent d = *readdir(dp)' then it is flaky.

	Dennis Ritchie
	dmr@research.att.com
	att!research!dmr

Volume-Number: Volume 17, Number 76
Technical Details
Message-ID: <448@longway.TIC.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!longway!std-unix

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!longway!std-unix
From: dmr@research.att.com (Dennis Ritchie)
Newsgroups: comp.std.unix
Subject: Re: Query about <dirent.h>
Message-ID: <448@longway.TIC.COM>
Date: 29 Nov 89 07:51:16 GMT
Sender: std-unix@longway.TIC.COM
Reply-To: dmr@research.att.com (Dennis Ritchie)
Organization: AT&T Bell Laboratories, Murray Hill NJ
Lines: 24
Approved: jsq@longway.tic.com (Moderator, John S. Quarterman)