glibcprintfnewlib

Looking for C source code for snprintf()


I need to port snprintf() to another platform that does not fully support GLibC.

I am looking for the underlying declaration in the Glibc 2.14 source code. I follow many function calls, but get stuck on vfprintf(). It then seems to call _IO_vfprintf(), but I cannot find the definition. Probably a macro is obfuscating things.

I need to see the real C code that scans the format string and calculates the number of bytes it would write if input buffer was large enough.

I also tried looking in newlib 1.19.0, but I got stuck on _svfprintf_r(). I cannot find the definition anywhere.

Can someone point me to either definition or another one for snprintf()?


Solution

  • http://www.ijs.si/software/snprintf/ has what they claim is a portable implementation of snprintf, including vsnprintf.c, asnprintf, vasnprintf, asprintf, vasprintf. Perhaps it can help.