Complete.Org: Mailing Lists: Archives: freeciv-dev: May 1999:
RE: [Freeciv-Dev] patch: provide snprintf
Home

RE: [Freeciv-Dev] patch: provide snprintf

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "'David Pfitzner'" <dwp@xxxxxxxxxxxxxx>, <freeciv-dev@xxxxxxxxxxx>
Subject: RE: [Freeciv-Dev] patch: provide snprintf
From: "Todd Goodman" <tsg1@xxxxxxxxxxxxx>
Date: Mon, 31 May 1999 18:17:17 -0400

Unfortunately, as far as I know cygwin doesn't include vsnprintf
(mingw32 does though).

I determined this through grep'ing the header files and trying
a simple test program so I could be wrong.

I'll look into it further and let you all know what I find.

Thanks,

Todd

> -----Original Message-----
> From: freeciv-dev-bounce@xxxxxxxxxxx
> [mailto:freeciv-dev-bounce@xxxxxxxxxxx]On Behalf Of David Pfitzner
> Sent: Sunday, May 30, 1999 11:39 PM
> To: freeciv-dev@xxxxxxxxxxx
> Subject: Re: [Freeciv-Dev] patch: provide snprintf
> 
> 
> Greg Wooledge wrote:
> 
> > If I'm reading this right, it allocates a region of memory and uses
> > mprotect(2) to cause the program to get a SIGSEGV if it 
> writes outside
> > this version.  Then it writes chars to this region using 
> the standard
> > vsprintf(3).
> > 
> > Does this work on all Unix systems?  I would imagine that 
> there may be
> > a few without sigaction(2) or mprotect(2) (or both).
> 
> Yeah, I agree it looks pretty scary.  Other alternatives used by
> other projects/libs to provide snprintf seem to be:
> 
> - Mostly full re-implementation of printf (at least format/argument
>   parsing).  (Eg JitterBug does this.)  Ouch.
> 
> - Implement enough to calculate an upper bound on the output length,
>   dynamically allocate that, vsprintf to it, then strncpy, then free
>   the temporary memory.  (Eg glib does this for g_snprintf if there
>   is no native snprintf.)
> 
> Maybe one of these would suit us better.
> 
> > I don't have a clue what this would do under Win32, OS/2, 
> AmigaOS, etc.
> 
> The current Win32 version uses Cygwin, which I would guess 
> already provides a vsnprintf (?), in which case the ugly 
> Unix-specific stuff would not be used at all.  No idea about 
> others.
> 
> -- David
> 
> 

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