[Python-Dev] snprintf breaks build (original) (raw)
Tim Peters tim_one@email.msn.com
Fri, 4 Aug 2000 01:22:23 -0400
- Previous message: [Python-Dev] snprintf breaks build
- Next message: [Python-Dev] FW: submitting patches against 1.6a2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Moshe Zadka]
(Tidbit: since sizeof(long) measures in bytes, and %d prints in decimals, then a buffer of length sizeof(long) is enough to hold a decimal represntation of a long).
[Greg Ewing]
Pardon? I think you're a bit out in your calculation there!
3*sizeof(long) should be enough, though (unless some weird C implementation measures sizes in units of more than 8 bits).
Getting closer, but the sign bit can consume a character all by itself, so 3*sizeof(long) sitll isn't enough. To do this correctly and minimally requires that we implement an arbitrary-precision log10 function, use the platform MIN/MIX #define's for longs and chars, and malloc the buffers at runtime.
Note that instead I boosted the buffer sizes in the module from 80 to 250. That's obviously way more than enough for 64-bit platforms, and "obviously way more" is the correct thing to do for programmers . If one of the principled alternatives is ever checked in (be it an snprintf or /F's custom solution (which I like better)), we can go back and use those instead.
- Previous message: [Python-Dev] snprintf breaks build
- Next message: [Python-Dev] FW: submitting patches against 1.6a2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]