>Bart Smaalders <bart.smaald...@sun.com> wrote:
>
>> All early strcpy implementations handle some overlapping copies
>> incorrectly.  In order to determine safety, it is necessary to
>> find the length of the string before beginning the copy.
>
>Could you please give us an example where this typical implementation:
>
>char *
>strcpy(s1, s2)
>        register char           *s1;
>        register const char     *s2;
>{
>        char     *ret   =3D s1;
>
>        while ((*s1++ =3D *s2++) !=3D '\0')
>                ;
>        return (ret);
>}
>
>would handle overlapped strings incorrectly?


        char buf[] = "foo";

        strcpy(buf+3, buf);

It's clearly not useful.

You want this to work:

        char buf[] = "foo\\abaz"";

        strcpy(buf+4, buf+5);  /* Remove "\" at position 4. */


Casper
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to