Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!ukc!dcl-cs!gdt!gdr!exspes From: exspes@gdr.bath.ac.uk (P E Smee) Newsgroups: comp.lang.c Subject: Re: strncpy Keywords: strncpy null termination Message-ID: <1989Dec22.102020.3960@gdt.bath.ac.uk> Date: 22 Dec 89 10:20:20 GMT References: <1231@srhqla.SR.COM> <11510@csli.Stanford.EDU> Reply-To: exspes@gdr.bath.ac.uk (P E Smee) Organization: University of Bristol c/o University of Bath Lines: 20 In article <11510@csli.Stanford.EDU> poser@csli.stanford.edu (Bill Poser) writes: > >I should clarify that: (a) I know perfectly well HOW strncpy works. My >question concerned the rationale for this design; I suspect it has to do with the original design of the unix directory structure. Filenames were limited to 12 (14? been so long since I used one, I'm not sure of the number) characters, and the directory structure had a char[exactly-that-size] variable to HOLD the filename. So, when putting a filename into or out of a directory structure, you wanted it to be null-terminated if and only if it was shorter than that variable. A maximum-length filename could NOT be null terminated in the describing structure. As to why they decided to do that, sheer byte-saving, I suppose (1 per file in your directory hierarchy). Maybe it made directory entries fit more nicely into whatever their disk blocksize was. -- Paul Smee, Univ of Bristol Comp Centre, Bristol BS8 1TW, Tel +44 272 303132 Smee@bristol.ac.uk :-) (..!uunet!ukc!gdr.bath.ac.uk!exspes if you MUST)