Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2001:
[Freeciv-Dev] Re: [PATCH] _final_ *snprintf cleanup. (PR#774)
Home

[Freeciv-Dev] Re: [PATCH] _final_ *snprintf cleanup. (PR#774)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Thue <thue@xxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] _final_ *snprintf cleanup. (PR#774)
From: Gaute B Strokkenes <gs234@xxxxxxxxx>
Date: 19 May 2001 10:41:04 +0100

On Sat, 19 May 2001, thue@xxxxxxx wrote:
> You define a function AC_FUNC_VSNPRINTF. That should probably be 
> FC_FUNC_VSNPRINTF like the other native freeciv functions.

I did it like that because I'm going to submit it to the GNU Autoconf
archive as soon as I finish my finals.  Most of the other functions
you can find there are named like that.  Feel free to change it to
whatever you feel like for the purposes of Freeciv, up to and
including AC_HOLGER_DANSKE ;-)

> Just curious, why not conform to the newer C99 standard?

Because it's more trouble to do.  The only difference is the return
value: if the given buffer is too small to hold the given string, then
-1 is returned C89, and the length of the string that would have been
written in C99.  Given a C89 vsnprintf(), the current code goes to a
lot of trouble to copy everything into a buffer and then strcpy() it
into the real buffer, so that it can see how long it is and adjust the
return value accordingly.  Comments in the source indicate that the
original author was not familiar with the differences in the C89 and
C99 standards, and probably thought that the C89 semantics are a sign
of brokenness, which isn't true.  I find it easier to convert a too
long return value to -1 than it is to guess how long the string would
have been.  Furthermore, since while grepping the source for
\\=.*snprintf I only found 2 (two!) places where use was made of the
added information in the C99 semantics, and both of these are error
messages.  So I hardly think this is a very useful feature.

-- 
Big Gaute                               http://www.srcf.ucam.org/~gs234/
..  I wonder if I ought to tell them about my PREVIOUS LIFE
 as a COMPLETE STRANGER?


[Prev in Thread] Current Thread [Next in Thread]