[DGD] Re: sprintf

Bart van Leeuwen bart at wotf.org
Fri Apr 2 14:57:02 CEST 2004



On Fri, 2 Apr 2004, Kirk Turner wrote:

> On Fri, 2004-04-02 at 17:44, Bart van Leeuwen wrote:
> > On Thu, 1 Apr 2004, Robert Forshaw wrote:
> >
> > I am kindof happy not having a binary implementation.. tho it is quite
> > possible to do it well,
> I'd be curious to know how it is done. I was having a look at this issue
> today, and the problem that I couldn't overcome without writing assembly
> was passing the array of data to the variable argument function without
> having a huge switch statement calling snprintf with the appropriate
> number of arguments.

Yep, something like that is often done, and 'the appropriate number of
arguments' is where it usually goes wrong also ;P

I have had some fun with an LPC object on a traditional lpmud that did a
sprintf(var) where var was my input.. so it ended up with only one
argument.. and a nice option for crashing the driver or manipulating the
stack :)

>
> I'm not a C guru, but using the dgd extensions I couldn't see an easy
> way of doing it. Unless you mean implementing the equivalent snprintf
> code in C, rather than using the system libraries (much the same as the
> lower_case function in the example doesn't call tolower).

Well, what I meant is that its not too difficult to implement such a thing
securely in general, I wasn't trying to say anything about how easy or
difficult it would be with the dgd extensions.

I'd want to use the system provided snprintf for a 'binary' version btw,

But hmm, I didn't try a precompiled version of the LPC sprintf so far.. I
did stick it into its own object (which gets called from a
sprintf() in the auto object) without any outside dependencies, so that
should be easy to try actually and something I'll look into if I ever end
up having a performance problem with it.

Bart.


_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list