[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: Re: svn commit: rev 1055 - trunk/subversion/clients/cmdline

From: Bill Tutt <rassilon_at_lyra.org>
Date: 2002-01-26 06:18:09 CET

> From: Philip Martin [mailto:philip@codematters.co.uk]
>
> A reasonable point I'll conceed. I'll refine my comment to "It's not
> the way I'd write it if I was starting from scratch". Why? Well seeing
>
> char buffer[5];
>
> in one file and
>
> sprintf(ptr, "%c%c%c%c", ...);
>
> in a different file, makes me uncomfortable. It was less of a problem
> when it was confined to one file.
>

Indeed. Calling sprintf(), and strcpy() is just asking for trouble
later. snprintf(), and strncpy() are so much safer APIs to call.

Part of a sane coding style one group I worked in was that you weren't
allowed to call a string function that didn't also take in the length of
data to operate on. (If you were passing 'char *'s, and weren't dealing
with an ADT for strings.) If this means you need to add more code to APR
to implement these APIs, that's no great loss.

Bill

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:37:00 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.