Re: on the irresponsibility of pursuing C language reform
scs-qx95VtOkOx/[email protected] (Steve Summit) Sun, 02 Aug 2026 09:45:17 -0400
| Newsgroups | gmane.linux.man,gmane.comp.lib.gnulib.bugs,gmane.comp.lib.glibc.alpha |
|---|---|
| Message-ID | <[email protected]> |
Alejandro wrote: >> Certainly, today, strncpy and strncat are the new gets. > > This is deeply incorrect. That was a side point, but to clarify what I meant: Once upon a time (and still today), it's a reasonable thing to say: Never use gets. Don't worry if you don't understand the issue, don't worry if you heard someone say there's an obscure circumstance under which it might be useful, just don't ever use it; pretend it doesn't exist. Today I think it's equally reasonable to say: Never use strncpy and strncat. Don't worry if you don't understand the issue, don't worry if you heard someone say there's an obscure circumstance under which they might be useful, just don't ever use them; pretend they don't exist. Though perhaps not strictly true, this is good advice, because it will never lead the average programmer astray. strncpy is not a "fine function", because nobody is using (or should be using) fixed-width string buffers any more. (See, I can be opinionated, too! :-) ) But we don't need to argue about this. I said "strncpy and strncat are the new gets" to concede a point, to agree that discouraging the use of formerly-acceptable interfaces -- a point that I thought you, and certainly that various people, were trying to make -- might be reasonable, even though it's one I often find myself disagreeing with. But that's an opinion I decided to leave out of my previous message, and I'm not going to go down that road here, either.