We have quite a few places where we have code like:

        char buf[20];
        sprintf(buf, "%d", someNumber);
        someString.append(buf);

with the commit below, these can now be written as:

        someString.appendNumber(someNumber);

or, if you want some other numeric format, you can add the format
specifier (standard printf formats):

        someString.appendNumber(someNumber,"%08x");

There was another routine that did this same job named 'XmlDecimal', but
it wasn't a method on UtlString and I just accidentally discovered it
shortly after adding this method - I have replaced the usages of it with
the new method.

If someone is looking for a useful and easy coding task, here's a
suggestion: search the code base for usages of 'sprintf' that fit the
pattern above, and replace them with the use of appendNumber.

The new method uses the 'snprintf' routine; if it turns out that isn't
available on some platform we care about, I'll do the autoconf work to
detect that and use the old form.
> 
> 
>            New Revision
> 13014
>              Committer
> xmlscott (Scott Lawrence)
>                Date
> 2008-07-03 09:46:00 -0400 (Thu, 03 Jul 2008)
> Log
> 
>  Add UtlString::appendNumber to append a formatted numeric value.
>  
>      This should allow us to remove many instances of sprintf,
>      or at least stop adding so many new ones.
>  
>      Replaced all instances of XmlDecimal with UtlString::appendNumber
>      XmlDecimal did the same thing as an external operation, but was
>      hidden in with other XML-specific code.
-- 
Scott Lawrence  tel:+1.781.229.0533;ext=162 or sip:[EMAIL PROTECTED]
  sipXecs project coordinator - SIPfoundry http://www.sipfoundry.org/sipXecs
  CTO, Voice Solutions   - Bluesocket Inc. http://www.bluesocket.com/ 
                                           http://www.pingtel.com/

_______________________________________________
sipx-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-dev
Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev

Reply via email to