Skip to content

Releases: eyalroz/printf

Version 0.6.2: Partial long double support, various bug fixes

10 Nov 18:03
Compare
Choose a tag to compare

Dear users: Your feedback from building and using the library in a wide variety of environments is what allows me to make safer and more portable releases. Please email me or post an issue if you notice a bug or unexpected behavior.

Changes since v6.1.0:

Features

  • #171 Now supporting the long double specifier and long double input arguments - but not yet using long doubles internally.

Library behavior control/options

  • #84 Can now decide whether the library uses double or float for its own internal representation of floating-point values - using the USE_DOUBLE_INTERNALLY
  • #141, #146 Changed the build options regarding C-library-printf-functions aliasing: We now have a single CMake option, ALIAS_STANDARD_FUNCTION_NAMES, which can one of three values: NONE (default), SOFT or HARD. And this is consistently respected.

Bug fixes

  • #155 printf("%# 01.1g, 9.8)" now produces correct number of zeros (but still incorrect)
  • #153 Fixed error in banker's rounding logic used when separating the integral and fractional components of a floating-point value
  • #149 Better (and faster) handling of NULL output gadgets

Build configuration

  • #174 Now utilizing the standard BUILD_SHARED_LIBS variable to control whether the library is built statically
  • #166 Now installing a printf-config.cmake so that find_package(printf) works.

Compatibility

  • #168 Now supporting the case of size_t and ptrdiff_t being of smaller size than long (e.g. for the msp430-elf-gcc target)
  • #167 Avoiding clang compiler warnings about -Wmaybe-initialized
  • #123 Avoiding yet another spurious GCC warning about an uninitialized variable

Other changes

  • Added testcase for the correct behavior of printf("%# 01.1g",, 9.8) - which is failing at the moment (this is bug #156 , which has not yet been fixed).
  • #161 Add a CodeQL action for some kind of security analysis, although frankly I haven't figured out how to use the results.
  • #154 Renamed rounding_threshold -> one_half

Caveats

  • Still no special handling for denormals.

Version 6.1.0: Flexible aliasing, mingw compatibility, CMake improvements

17 Oct 12:00
Compare
Choose a tag to compare

Dear users: Your feedback from building and using the library in a wide variety of environments is what allows me to make safer and more portable releases. Please email me or post an issue if you notice a bug or unexpected behavior.

Changes since v6.0.0:

Bug fixes

Compatibility

  • #130 : _vsprintf() renamed to avoid clash with msys/mingw headers
  • #132 : Now avoiding ssize_t declaration conflict with mingw
  • #129 : Differentiating the printf and gnu_printf function format attribute, due to msys2 "sensibilities"
  • #144 : Removed redundant extern "C" which is disliked by Apple clang 13

Other bug fixes

  • #126 : Dropped gratuitous parentheses in the definition of ATTR_PRINTF for non-GNUC compiler,

Build configuration

  • #142 : Use CMake's export() and install the resulting exported targets
  • #139 : Repository can be used with CMake's FetchContent mechanism (using the Craig Scott approach).

Other changes

  • #141 Now supporting two forms of aliasing of standard library functions:
    • hard aliasing (supported since v5.0.0, in this repository): The compiled library exposes printf(), sprintf() etc. rather than printf_(), sprintf_() etc.
    • soft aliasing (supported before v5.0.0, in mpaland's repository): The compiled library exposes printf_(), sprintf_() etc. and does not clas with the standard library; when including its headers, macros replace printf_ with printf_, sprintf with sprintf_ etc.
      The hard-aliasing is more robust and less error-prone - but for some people it's imperative for the exported symbols to differ from the standard library's. So, the CMake configuration now has three possible values for the aliasing option (the two modes + no-aliasing, which is the default).
  • #140 _vsprintf() now avoids reading past the end of the format string even if it is malfored
  • #137 : Now using proper C prototypes (e.g. int foo(void) rather than int foo()).
  • #145 : Standard header inclusion re-arrange

Caveats

  • Still no special handling for denormals.

Version 6.0.0: Internal refactoring, accuracy improvements, bug fixes

11 Feb 09:31
Compare
Choose a tag to compare

Changes since v5.3.0:

Bug fixes

  • #95 : Now always including <limits.h> (which we need)
  • #114 : Fixed a bug exposed by other changes in these versions, with slightly-sub-normal numbers such as 1e-308.
  • #115 : Now "playing it safe" with powers close to the extremal ones (-307 to 308 for double) w.r.t. precision - sacrificing some accuracy to ensure we don't exceed representation range.
  • #121 : %#b no longer exceeding the specified width by 1 in some cases.
  • #122 : Now properly respecting the PRINTF_DECIMAL_BUFFER_SIZE preprocessor flag (and the corresponding CMake option).

Build configuration

  • #76: Now helping library users prevent gcc and clang from substituting their builtins for our standard-library-aliasing functions (using PUBLIC compilation flag -fno-builtin-printf for the library's CMake target; if you don't use CMake - make sure to do that yourself).
  • Now building with the -Wconversion flag.
  • Can now set the number of terms in the Taylor series expansion used in computing the base-10 logarithm

Other changes

  • #109: Better rounding-down of the computed base-10 exponent.
  • Added some precision to the constants in the Taylor series expansion of ln(x)/ln(10) in the base-10 logarithm computation - improving accuracy slightly.
  • #113: Added support for using more Taylor series terms in the base-10 logarithm computation.
  • README.md updates.
  • Now using GitHub actions to build the library and run the tests! :-)
  • #32: Now using a convenient uniform gadget for the inner implementation for all library functions. This is a significant internal refactoring of the code.
  • #105: Making all potentially-value-altering conversions explicit
  • Copyright & attribution text fixup.
  • Factored out the code computing a power-of-10 and a base-10-logarithm into their own functions
  • More comments about what we're doing, especially algorithmically.

Testing code

  • #111: Test suite now properly respects printf_config.h
  • Split the "float" testcase into several cases regarding float-point specifiers.
  • Added a few testcases with non-numeric floating-point values and the E specifier.
  • Added more warning-disabling where appropriate
  • Remove a duplicated non-standard test
  • #112: Test suite now accounts for the value of PRINTF_MAX_INTEGRAL_DIGITS_FOR_DECIMAL when deciding what to expect
  • Increased visibility of failures within the loops over larger ranges of floating-point values in the test suite.
  • Added an "precision latter" sequence of testcases to see when we start introducing errors due to our approximation shortcuts.
  • Some refactoring of the test suite code.

Caveats

  • Still no special handling for denormals.

Version 5.3.0: Cleanup, MISRA rules, MSVC-style Inn specifiers

11 Feb 09:31
Compare
Choose a tag to compare

Changes since v5.2.0:

API and feature-set

  • #51 : Now optionally supporting MSVC-style specific-size specifiers: I8, I16, I32, I64 (e.g. %I64d or %I32u). These are not part of the C standard, but they are convenient and appropriate for size-specific types like int64_t or uint32_t. A preprocessor (and CMake) option controls whether or not this support is included in the library - and it defaults to OFF for C standard compliance.
  • #89 : Now using the same parameter names in printf.h as defined in the C standard (the parameter _types_were already standard-compliant, this is merely a cosmetic change).
  • #90 : Doyxgen comment improvements in printf.h.

Build configuration

  • The previous version, 5.2.0 was unfortunately released with an invalid version number (it was still 5.1.0); this time the version is set correctly in the CMakeLists.txt file.

Other changes

  • #74 : All functions in printf.c without declarations in printf.h are now declared static, and should not be symbols exported by the compiled object file.
  • Now Commenting-out additional code when PRINTF_EXPONENTIAL_SPECIFIERS is disabled.
  • #77 : Applied several MISRA coding guidelines rules. The printf()-family functions themselves are not in line with the MISRA guidelines, but this can't be helped, since they must conform to the standard library signatures.
  • #87 : Avoiding potential narrowing-conversion errors due to the int return type of printf()-family function vs the size_t type of the buffer range.
  • Various purely-internal changes (#88, #91

Testing code

  • #85 : No longer trying (and failing) to build the test suite when library function names are set to alias the standard library function names (since they conflict with catch).

Caveats

  • Still no special handling for denormals.

Version 5.2.0

03 Dec 17:17
Compare
Choose a tag to compare

Changes since v5.1.0:

Standard C feature support

  • #61 : Added support for the %n format specifier..

Repository structure and other general changes

  • Moved printf.h and printf.c into the src/printf directory. When using the library, you now #include <printf/printf.h>; this avoids a clash with glibc's printf.h header.

Build configuration

  • #56 : Now supporting build via CMake add_subdirectory (and thus also CMake's FetchContent module).

Caveats

  • Still no special handling for denormals.

Version 5.1.0

12 Nov 19:40
Compare
Choose a tag to compare

Changes since v5.0.0:

Repository structure and other general changes

  • #58 : Moved printf.h and printf.c into the src/ directory

Build configuration

  • #59: Unified names of CMake variable and C preprocessor defines for the integer-to-string buffer size. It's now PRINTF_INTEGER_BUFFER_SIZE everywhere.
  • #54: Changed the mechanism for aliasing the standard printf() family of functions. (And it's not broken now...)

Library API changes

  • #55: Using putchar_() instead of _putchar().

Code formatting, naming, comments etc.

  • #54: Avoiding the ifdef-if preprocessor directive idiom, in favor of ifndef-define-endif-if.
  • Change include guard name - avoiding heading underscore.

Other issues

  • Dropped Travis CI metadata file.
  • README.md documentation update
  • More pedantic use of NULL in the test suite.
  • Fixed: Was not passing TEST_WITH_NON_STANDARD_FORMAT_STRINGS properly to the test suite.
  • Added a test for aliasing the standard library's printf(): aliasing.cpp
  • Change include guard name - avoiding heading underscore.
  • #52: Test suite no longer checks for "10e+2", "10e+5" etc. but rather "1e+3", "1e+6" etc. (like it should.)
  • Disabling a format warning about invalid formats, which we are testing as such intentionally.

Caveats

  • Still no special handling for denormals.

Version 5.0.0

27 Sep 11:04
Compare
Choose a tag to compare

This is the first version following the fork from Macro Paland's repository:

Repository structure and general changes

  • mpaland#106: The repository is now built using CMake (minimum CMake version 3.13) rather than a Makefile which needs manual editing for different platforms
  • Library users have verified builds on Windows + MSVC, Windows + Cygwin + GCC, and various Linux distributions
  • The library may be built either statically or dynamically
  • An additional test program - a autotest/fuzzer, has been added (Michael Clift)
  • Not using coverity and codecov like Macro Paland's repository was.

Build configuration

  • #19: The threshold for transition from decimal to exponential floating-point representation is now specified using a number of decimal digits rather than a float value.
  • preprocessor define names have changed, hopefully becoming somewhat clearer semantically; see README.md for details.
  • #18: The preprocessor defines can now alternatively be taken from a printf_config.h, which may be more convenient when building within other, larger, projects. When building with CMake, this file will be generated based on CMake option choices.
  • #14: Can now choose whether or not to have the standard library function names (printf, sprintf etc) alias this library's function names.
  • #17: We now check the values of preprocessor defines rather than whether they're defined or not, even for boolean settings (with a default value fallback for the undefined case)
  • #20: The catch2 testing framework header has been updated to v2.13.6

Library API changes

  • Added vfctprintf_(), a va_list-based variant of fctprintf() (fivdi; Damian Pala; Jonathan Lenz)
  • Added vsprintf_(), the va_list-based variant of sprintf() (Alexander Olenyev)
  • mpaland#79: Marked the various functions with __attribute__((format)) for compilers supporting it (Sam van Kampen; Josh Klodnicki).
  • #14: No longer forcing the aliasing the standard library function names nor polluting the global set of macros with those names.

Code formatting, naming comments etc.

  • Now using less shorthand names in the code, for hopefully better readability (e.g. prec -> precision, pow10 -> powers_of_10)
  • Redone doxygen comments in the header file.
  • Consistent spacing: 2-space indentation, no tabs
  • mpaland#104: Now using linefeed-only line breaks in all files (i.e. rather than DOS-style CRLF).

Other issues fixed before the fork from mpaland/printf

  • mpaland#45: Incorrect comment regarding the return value of snprintf_ and vsnprintf_
  • Dropped the assumption of char being signed (Erik Hallberg)
  • Additional bug fixes which have been obviated by later changes to the code.

Other issues fixed after the fork from mpaland/printf

  • Avoiding careless use of unsized integer types for values requiring larger sizes.
  • Formatting of "%p" now uses a 0x prefix, matching glibc (Eli Lipsitz)
  • Formatting of "%p" now uses (nil) for NULL pointers, matching glibc (Eli Lipsitz)
  • Avoided numerous warnings from different compilers in stricter warning modes (especially GCC, clang, MSVC), both in the library itself and
  • Added numerous additional checks to the test suite; it currently has 484 checks.
  • #49, #38 : Test suite checks involving disabled features should now all be guarded by #if-#else to only be used when support for these features is enabled
  • mpaland#63: Explicitly checking pointer values against NULL, just in case, somehow, its value is not 0.
  • The test suite now uses CHECK() rather than REQUIRE(), so if anything fails you see all the failures.
  • mpaland#99, mpaland#113 : Corrected issues with properly respecting precision when padding is applied.
  • mpaland#75: Corrected standard-non-compliant expected string in some test suite checks.
  • mpaland#99, mpaland#109, mpaland#110, mpaland#114: Corrected some issues involving the interplay of the hash modifier (#), hexadecimal and octal representations, and trailing and leading zero printing.
  • mpaland#115 : Unified the two functions formatting long and long long values into just one (now named print_integer)
  • mpaland#116 : More properly representing numeric bases in the code.
  • mpaland#54: Corrected zero and negative zero formatting in exponential format.
  • #26 : Improved floating point accuracy
  • Partially merged the functions for printing in decimal and exponential formats
  • mpaland#120 : Fixed a situation where rounding was making us print "10" as the integral part in an exponential representation.
  • mpaland#122, #28, mpaland#124 : Fixed cases of incorrect choice between exponential and decimal with g specifier.
  • #37: Now supporting the possibility of the double type having 32 bits (single-precision) rather than 64 bits (double precision).
  • #46: Consistent, properly-documented "%zi" behavior with build-time checks

Caveats

  • mpaland#119 : The library is missing special handling for denormals, to determine their true exponent. It only handles the special-case of 0 (or -0), while other denormals are assumed to have the exponent in their exponent bits.
  • Issues which were introduced, then resolved, after the last version and before this one are not listed.