📄 readme-psnprintf-0.4
字号:
psnprintfA portable snprintf function----------------------------Contents of this file: 1. License 2. Brief Documentation 3. Unit tests 4. Benchmarking program 5. Known problems / TODO 6. Contact Details 7. Use of psnprintf in COS (Added by Paul Barker)1. License----------This work free for commercial and non-commercial use alike. See license.txt for details.2. Documentation----------------Copy psnprintf.cpp into your source directory and psnprintf into yourheader directory. In your source files: #include "psnprintf.h"The psnprintf function is defined as: int psnprintf(char *str, size_t n, const char *format, ...) str is your buffer n is the size of your buffer (including NULL) format is a printf style format string Return value is number of characters that would have been printed your buffer was large enough. If the size of your buffer >= the return value, the string was completely formatted into the buffer. Otherwise the buffer was completely filled, and the last byte is a terminating NULL.psnprintf does not quite conform to C99 specification as it ALWAYS terminatesyour buffer with a NULL, unless n is given as 0 (zero buffer size).3. Unit tests-------------The function is extensively tested with the unit test program providedin the test/ directory. See "test/build.txt" for information on how to build and run these unit tests on your platform.4. Benchmarking---------------A simple benchmarking program is provided in the test/ directory. Itcompares psnprintf's performance to your system's native sprintf andsnprintf. In my experiences psnprintf almost always comes out equalor faster. See "test/build.txt" for information on how to build andrun the benchmarking program on your platform.5. Known Problems / TODO------------------------ - Unit tests currently fail on Windows due to inconsitency in printf. On UNIX sprintf(buf, "%.0f", 0.0) gives "0.0", whereas on Windows it gives "0" (which is probably more correct). Currently psnpritnf follows the UNIX convention, though this might change. - Some unit tests fail on Linux due to inconsistency in printf. - Some unit tests fail on Solaris due to insconsistency in printf. - Floating point support not fully implemented. Format character 'f' is available but 'e', 'E', 'g' and 'G' will give no output unless the value is special (NaN or Infinity). - Both the numerical functions (double and integer) are quite messy due to various padding/alignment/precision options. Should look into this to clean it up a bit. - Unit testing code is UGLY and was written in a big hurry. Consists of way too many macros and is probably unnecessarily complicated. Demands a complete rewrite (perhaps not relying on system's sprintf?)6. Contact Details------------------The author of the function is Alex Holkner. He can be reached at: alex@partiallydisassembled.netor aholkner@cs.rmit.edu.au7. Use of psnprintf in COS (Added by Paul Barker)-------------------------------------------------I have made some changes in order to use the psnprintf library in the COSkernel. See the source and header files for information:kernel/psnprintf.cinclude/psnprintf.hAlso see the license at:license-psnprintf-0.4This code is used as the backend to my TRACE(...) and *printk(...) functions.Many thanks to Alex Holkner! - Paul Barker (16/10/04)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -