Why Is Escaping Data Considered So Magical?

David Cournapeau cournape at gmail.com
Fri Jul 2 23:09:45 EDT 2010


On Mon, Jun 28, 2010 at 6:44 PM, Gregory Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Carl Banks wrote:
>
>> Indeed, strncpy does not copy that final NUL if it's at or beyond the
>> nth element.  Probably the most mind-bogglingly stupid thing about the
>> standard C library, which has lots of mind-boggling stupidity.
>
> I don't think it was as stupid as that back when C was
> designed

Actually, strncpy had a very specific use case when it was introduced
(dealing with limited-size entries in very old unix filesystem). It
should never be used for C string handling, and I don't think it is
fair to say it is stupid: it does exactly what it was designed for. It
just happens that most people don't know what it was designed for.

David



More information about the Python-list mailing list