Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!sunybcs!boulder!hao!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: /bin/test and stat(2) Message-ID: <9013@mimsy.UUCP> Date: Thu, 15-Oct-87 19:13:39 EDT Article-I.D.: mimsy.9013 Posted: Thu Oct 15 19:13:39 1987 Date-Received: Sat, 17-Oct-87 10:23:27 EDT References: <9767@brl-adm.ARPA> <673@unmvax.unm.edu> <6569@brl-smoke.ARPA> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 47 >In article <673@unmvax.unm.edu> mike@turing.unm.edu.UUCP (Michael >I. Bushnell) writes: >>But "" is NOT "\0". In article <6569@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: >What the hell are you talking about? Colloquial usage confounds and confuses. To communicate in C: "" A `zero length string', actually an array containing one byte, the ASCII NUL (code 0/0 in ASCII tables) (this assumes your machine uses ASCII). This is also called `the null string'. The code NUL is also called the `null character'. (char *)0 A null-valued string, or a nil string, or (char *)NULL the nil pointer to char. Note that both of these use the word `null'. We have three things called *null*, namely NULL, NUL, and "". Only the last is a *string*. When properly cast, the first `looks like a string' from the outside. NUL is a character and never looks like a string. Now then, one `null' that is an invalid pathname is (char *)NULL. This is a value that is guaranteed not to point to any valid data object. On a 4BSD Vax, it happens to point to an (invalid of course) data object that is nonetheless accessible *and* starts with a zero byte, so that it looks for all the world just like the former null string. *This is mere happenstance*. The other `null' that is (sometimes) an invalid pathname is the null string, "". This is a perfectly valid pointer, pointing to a zero byte---the character NUL. On some machines, therefore, open("") and open((char *)NULL) do the same thing. This is an accident of the implementation. They are not required to do the same thing. On a 4BSD machine, the former is required to work, and acesses the current directory. On some 4BSD machines, the latter happens to do the same; on others, it returns an EFAULT error. Summary: the *null string* `""' is a pathname. The *nil pointer to char* `(char *)NULL' is not a pathname. The *NUL character* in position 0/0 on ASCII charts is not even a string. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris