Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: How to copy a string safely and efficiently in C? Date: Thu, 15 Sep 2016 15:53:29 -0700 Organization: None to speak of Lines: 33 Message-ID: References: <0b30b0cc-f7c5-4928-8acb-56bf2364797b@googlegroups.com> <2439e64e-39d5-4982-a5d6-625f68acf636@googlegroups.com> <849f0366-4440-43f0-8936-f0d9b5a71e88@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="24704"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18X5LYmQFFLkkNeOt4xW/4D" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:XJP/FSvduMwFNLe/rgeT9pXjWeU= sha1:RWt1ZtK/XfkVkhH+9gv8o4V9xeI= Xref: csiph.com comp.lang.c:93576 supercat@casperkitty.com writes: > On Thursday, September 15, 2016 at 2:46:11 PM UTC-5, luser droog wrote: >> On Thursday, September 15, 2016 at 2:32:39 PM UTC-5, Tim Rentsch wrote: >> > The problem with strncpy() is not what functionality it provides >> > but the name used to provide it. In retrospect I think it should >> > have been called something like strnotwhatyouexpectcpy(). >> >> I suggest char_array_cpy() or fixed_field_cpy(). Maybe *fld*. > > Since the functions were defined before the preprocessor became an > essential part of the language, the names were limited to six characters; > I think it might have been good to apply a looser constraint that all > library functions must be *unique* in the first 6 characters, but I don't > think fixed_ would be a particularly good name even then. [...] C90 required external names to be unique in the first 6 characters, possibly ignoring case. The C90 standard library had several functions whose names are longer than 6 characters; vprintf, at 8 characters, is the longest I found in a quick search. There might have been some pre-ANSI implementations that didn't permit external names longer than 6 character -- but surely strncat, at 7 characters, must have been added after any such restrictions were removed. How is the preprocessor relevant? -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"