Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/3/84; site teddy.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!talcott!panda!teddy!kps
From: kps@teddy.UUCP
Newsgroups: net.lang.c
Subject: Re: C programming hint
Message-ID: <913@teddy.UUCP>
Date: Fri, 12-Jul-85 08:37:12 EDT
Article-I.D.: teddy.913
Posted: Fri Jul 12 08:37:12 1985
Date-Received: Sat, 13-Jul-85 14:09:37 EDT
References: <899@teddy.UUCP> <2412@sun.uucp>
Reply-To: kps@teddy.UUCP
Distribution: net
Organization: GenRad, Inc., Concord, Mass.
Lines: 41
Summary: retraction: won't work all the time!!!


	char blanks[SIZE];
	blanks[0] = ' ';
	strncpy(blanks + 1, blanks, SIZE - 1);	/* initialize entire array */

Here's what people said about my method:

From panda!talcott!harvard!stew
>This is not portable.  There is no guarantee that strncpy() copies
>one char at a time in forward order.  If it is implemented using the
>VAX MOVC3 instruction, for example, the overlap of the source and
>destination strings does NOT affect the result!

From panda!genrad!decvax!harpo!whuxlm!whuxl!houxm!ihnp4!mhuxn!mhuxr!ulysses!allegra!alice!ark
>Don't.  There is no guarantee that strncpy copies one character at a time.

From panda!talcott!harvard!seismo!umcp-cs!chris
>Beware, that won't work on Vax systems that use movc3 for string copies
>(probably Sys VR2V2.2.2.2... [sorry :-)] and 4.3 both).

From panda!genrad!decvax!harpo!whuxlm!whuxl!houxm!mtuxo!mtunh!mtung!mtunf!ariel!vax135!petsd!gangal
>2)      I don't know exactly what the standard C library does, but many
>	string copy routines (in micro-code or higher level) check
>	for overlapping strings and would process your request in reverse
>	to avoid just the recursion you want.  (For instance, you may
>	have a string in there to which you want to prepend a character.)

From panda!genrad!decvax!harpo!whuxlm!whuxl!houxm!mtuxo!mtunh!mgh
>	2.	it only works if strncpy is implemented by starting with the
>		first character to be moved and not the last (you can move
>		up and down a string in either direction). I.e. it's
>		implementation dependent;

Well, as you can probably see, I've been bludgeoned to death
with the fact that my method is implementation dependent and
that it won't work all the time.

I stand connected, er, I mean corrected.

Thanks for a humbling experience,
			B.K.