Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2000:
[Freeciv-Dev] Re: C99 vsnprintf().
Home

[Freeciv-Dev] Re: C99 vsnprintf().

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: C99 vsnprintf().
From: gs234@xxxxxxxxx (Gaute (B) Strokkenes)
Date: 02 Sep 2000 18:40:28 +0200

gs234@xxxxxxxxx (Gaute (B) Strokkenes) writes:

> That's my thinking.  Basically, I just counted the number of places in
> the source where the return value was stored somewhere.  If we narrow
> down to the number of places where it is used to do something
> meaningful, the number is even smaller (2, after a very cursory
> examination.)  I think that I can easily produce a patch that works
> around this.

I dunno how this escaped my computer.  It seems that it mailed a draft
rather than my finished message.  Odd.

Anyway, here is a patch that does just this:
* Allows vsnprintf() to return -1 as well in case of truncation.
* Changes a line in common/ioz.c to take this into account.
* Some minor changes in server/stdinhand.c to deal with -1 properly
  and to enforce consistent behaviour independent of whether a C99 or
  pre-C99 vsnprintf() implementation is used.

(For a number of reason, I didn't have the opportunity to test my
patch.  In any case I don't have acces to a system with a pre-C99
vsnprintf(), so it would be great if anyone actually tested this.)

Attachment: vsnprintf_cleanup.diff
Description: patch against current cvs

-- 
Big Gaute (not to be confused with LG)
I'm meditating on the FORMALDEHYDE and the ASBESTOS leaking into my
 PERSONAL SPACE!!

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