Robert Elz <k...@munnari.oz.au> wrote: > > If we switch the implementation to no longer use a static buffer, > then we are going to have to find some way to return a (non-const) > version of "." in cases like dirname(NULL) or dirname("") (this > latter one not literally, obviously) where we cannot just copy a "." > on top of the input path string, and return that. > > Alternatively, you could add some text making it clear that the output > string might be a const char * pretending to be a char *, and cannot be > modified, in which case there is probably more code to fix... > > It might also be worth adding a warning to the effect that the same > input path cannot safely be used for multiple calls to either of these > functions, we have code that does, more or less (this is not literal)... > > if (strchr(basename(path), '.') == NULL) > sprintf(newbuf, "%s.foo", basename(path)); > else /*...*/
Given that Solaris still uses an implementation that is very similar to what was used 40 years ago, I would assume that older software does it right ;-) Jörg -- EMail:jo...@schily.net (home) Jörg Schilling D-13353 Berlin joerg.schill...@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/'