Skip to content

Releases: biojppm/c4core

Release 0.2.8

26 Jan 15:05
828c552

Choose a tag to compare

Fixes

  • charconv: fix conversion warning (triggered in clang 21)

Release 0.2.7

30 Sep 07:37

Choose a tag to compare

  • enum symbols:
    • remove useless const in return value of c4::esyms()
    • add overload for building from ptr,len
  • dump.hpp: fix implicit typing in implementation of c4::format_dump()
  • utf.hpp: add missing C4_EXPORT to c4::decode_code_point()
  • fix warnings with cmake 4

Release 0.2.6

11 Apr 00:17

Choose a tag to compare

  • PR#150: fix configure with cmake 4.

Release 0.2.5

15 Feb 10:41

Choose a tag to compare

  • PR#149: Fix warnings from -Wundef

Release 0.2.4

11 Feb 14:40

Choose a tag to compare

  • Add header c4/version.hpp:
    • c4::version()
    • c4::version_major()
    • c4::version_minor()
    • c4::version_patch()
  • Update fast_float to 8.0.0

Release 0.2.3

07 Feb 18:30

Choose a tag to compare

  • PR#147: Add utf utilities:
    • c4::first_non_bom()
    • c4::get_bom()
    • c4::skip_bom()
  • PR#148: Improvements in dump.hpp:
    • add traits class c4::dump_directly<T> to enable selection of faster path where the intermediate dump buffer is not used for strings which can be directly dumped to the sink
    • improve c4::format_dump_resume() to ensure the needed buffer size is still computed after buffer exhaustion
  • PR#148: add noexcept to c4::overflows
  • PR#148: Add support for mips, mipsel, mips64, mips64el CPU architectures
  • PR#148: Add support for sparc, sparc64 CPU architectures
  • PR#148 and PR#12 cmake: Add support for loongarch, loongarch64 architectures
  • PR#148: Improve CPU detection in armv4 and armv5
  • PR#144: Include <cstddef> for ptrdiff_t usage
  • Minor improvements to doxygen documentation

Thanks

Release 0.2.2

15 Aug 16:25

Choose a tag to compare

  • Amalgamate: fix include of <charconv> (see rapidyaml#445).
  • Add C4_MINGW (PR#139)
  • Annotate c4::handle_error() with [[noreturn]] (PR#137).
  • Add bool from_chars(csubstr s, fmt::overflow_checked_<T> *wrapper). There was already a function receiving &wrapper, but *wrapper was missing for use with generic code.
  • Ensure posix_memalign() is never called with bad alignment values (PR#138)
  • Update fast_float to v6.1.1 (PR#136)

Thanks

Release 0.2.1

11 Jun 17:50

Choose a tag to compare

  • atod(): add missing assertion str.len > 0

Release 0.2.0

24 Apr 18:36

Choose a tag to compare

Breaking changes

  • #PR101: As part of the substr ctor cleanup, the to_substr(char (&arr)[N]) overload no longer decays to char* inside. This changes calling code by now returning a substr with length equal to N-1 instead of strlen(arr) as before:
    // longer than "foo", ie longer than {'f', 'o', 'o', '\0'}:
    char arr[] = "foo\0\0\0\0\0\0";
    assert(strlen(arr) == 3);
    assert(sizeof(arr) == 9);
    
    // previously:
    assert(to_substr(arr).len == 3);
    // now:
    assert(to_substr(arr).len == 9);
    
    // the breaking change happens only with arrays:
    assert(to_substr((char*)ptr).len == 3); // as before
  • PR#111 - Rename formatting overloads accepting c4::append:
    • catrs(append_t, ...) -> catrs_append(...)
    • catseprs(append_t, ...) -> catseprs_append(...)
    • formatrs(append_t, ...) -> formatrs_append(...)

New features

  • #PR101: For substr and csubstr:
    • add simultaneous ctors from char[] and char*. Using SFINAE to narrow the char* overload prevents it from overriding the char[] overload. Thanks to @huangqinjin for the idea (see #97).
    • remove unneeded constructors of csubstr from non-const chars.
    • to each single-argument ctor, add corresponding functions to_csubstr() and to_substr() to enable clients coercing their types in generic code such as c4::cat() and c4::format().
    • Add interop with std::string_view when the standard is at least C++17 (#PR101):
      • provided in the header c4/std/string_view.hpp
      • similarly to existing interop headers, this is opt-in and requires explicit inclusion
      • implemented:
        • to_csubstr() (since std::string_view is not writeable, cannot provide to_csubstr())
        • to_chars() (since std::string_view is not writeable, cannot provide from_chars())
        • comparison operators
  • substr: split .first_not_of() and .last_not_of() into different overloads, removing the defaulted start parameter:
    • .first_not_of(T, start=0) -> .first_not_of(T) , .first_not_of(T, start)
    • .last_not_of(T, start=npos) -> .first_not_of(T) , .first_not_of(T, npos)
      This may or may not result in a speedup.
  • PR#105: Add macros in c4/language.hpp for compile-time flow of exceptions:
    • C4_EXCEPTIONS: defined when exceptions are enabled
    • C4_IF_EXCEPTIONS(code_with_exc, code_without_exc): select statements for exceptions enabled/disabled
    • C4_IF_EXCEPTIONS_(code_with_exc, code_without_exc): select code tokens for exceptions enabled/disabled
  • PR#105: Add macros in c4/language.hpp for compile-time flow of RTTI:
    • C4_RTTI: defined when rtti is enabled
    • C4_IF_RTTI(code_with_rtti, code_without_rtti): select statements for rtti enabled/disabled
    • C4_IF_RTTI_(code_with_rtti, code_without_rtti): select code tokens for rtti enabled/disabled
  • PR#109: Add partial support for XTENSA processors (missing implementation of c4::aalloc()). See rapidyaml#358.
  • PR#119 Add LoongArch cpu support.
  • Add compiler annotation helper macros: C4_ASSUME, C4_NODISCARD, C4_DEPRECATED, C4_UNREACHABLE_AFTER_ERR

Fixes

  • Fix #126: bad Exception being used with C4_ERROR_THROWS_EXCEPTION.
  • PR#132:
    • Fix typo C_4MSVC_VERSION_2019 in src/compiler.hpp (#124).
    • Add check for definition of __GNUC__ in gcc-4.8.hpp (#125).
  • PR#121 - Fix compile on armv8 due to broken macro definition; see #122 and #94.
  • PR#129 - Support android by enabling aalloc()'s call to memalign(), available for API 16+.
  • PR#115 - Refactor of c4::blob/c4::cblob. Use SFINAE to invalidate some of the constructors.
  • PR#110/PR#107 - Update fast_float.
  • PR#108 - Fix preprocessor concatenation of strings in C4_NOT_IMPLEMENTED_MSG() and C4_NOT_IMPLEMENTED_IF_MSG().
  • PR#106 - Fix include guard in the gcc 4.8 compatibility header, causing it to be missing from the amalgamated header. See also #125: there was no check for __GNUC__ being defined.
  • PR#123 - Ensure the gcc 4.8 compatibility header is installed (fixes #103).
  • PR#105 - Fix existing throw in c4/ext/sg14/inplace_function.h. Ensure tests run with exceptions disabled and RTTI disabled. Add examples of exceptional control flow with setjmp()/std::longjmp().
  • PR#104/PR#112 - Fix pedantic warnings in gcc, clang and MSVC
  • PR#104 - Fix possible compile error when __GNUC__ is not defined
  • Inject explicit #include <charconv> on the amalgamated header. The amalgamation tool was filtering all prior includes, thus causing a compilation error. Addresses rapidyaml#364.
  • PR#117: Windows: fix compilation with MSVC/clang++.
  • Windows: add missing C4CORE_EXPORT to c4::base64_valid(), c4::base64_encode() and c4::base64_decode().
  • rapidyaml#390 - fix csubstr.first_real_span() when the exponent only has one digit (see fae7106)

Thanks

Release 0.1.11

17 Dec 20:28

Choose a tag to compare

Breaking changes

  • csubstr::operator==(std::nullptr_t) now strictly checks if the pointer is null and no longer looks at the length (rapidyaml#264):
    -bool csubstr::operator== (std::nullptr_t) const noexcept { return str == nullptr || len == 0; }
    -bool csubstr::operator!= (std::nullptr_t) const noexcept { return str != nullptr || len == 0; }
    +bool csubstr::operator== (std::nullptr_t) const noexcept { return str == nullptr; }
    +bool csubstr::operator!= (std::nullptr_t) const noexcept { return str != nullptr; }
  • to_substr(std::string &s) and to_csubstr(std::string const& s) now point at the first element when the string is empty (rapidyaml#264):
    -    return c4::substr(!s.empty() ? &s[0] : nullptr, s.size());
    +    return c4::substr(&s[0], s.size());
    This is OK because an empty std::string is guaranteed to have storage, so calling s[0] is safe.

New features

  • charconv.hpp: added xtoa() floating-point overloads accepting precision and format (PR#88):
    size_t xtoa(substr s,  float v, int precision, RealFormat_e formatting=FTOA_FLEX) noexcept;
    size_t xtoa(substr s, double v, int precision, RealFormat_e formatting=FTOA_FLEX) noexcept;
  • memory_util.hpp: added ipow() overloads for computing powers with integral exponents (PR#88).
  • Add C4_NO_DEBUG_BREAK preprocessor check to disable calls to c4::debug_break() (see rapidyaml#326)
    • The cmake project conditionally enables this macro if the cmake option C4CORE_NO_DEBUG_BREAK is set to ON.

Fixes

  • substr, to_chars(), charconv: ensure memcpy() is not called when the length is zero. Doing this is UB and enabled the optimizer to wreak havoc in the branches of calling code. See comments at rapidyaml#264 for an example and fix. See Raymond Chen's blog for an explanation.
  • atof() and atod() (PR#88):
    • Always use the fastest implementation available: std::from_chars() if available (C++17 or higher standard, with later compilers), fast_float::from_chars() otherwise. On Visual Studio, fast_float::from_chars() is preferred over std::from_chars().
    • If std::from_chars() is not available and C4CORE_NO_FAST_FLOAT is defined, then the fallback is based on sscanf().
    • Ensure hexadecimal floats are accepted. The current fast_float implementation does not accept hexadecimal floats, so an hexfloat scanner was added.
  • Likewise for ftoa() and dtoa(). Prefer the fastest implementation available: std::to_chars()->snprintf().
    • Change the FTOA_* enum values and type to save a function call when converting format. From now on, only the symbols of this enum can be relied on; the values or type will change depending on the selected implementation (std::to_chars() or snprintf()) (PR#91).
  • Fix #84: csubstr::compare(char): refactor to avoid false-positive warning from VS2022.
  • csubstr methods: add noexcept and annotations C4_PURE and C4_ALWAYS_INLINE
  • csubstr: add C4_RESTRICT to incoming string on csubstr::compare()
  • csubstr::first_real_span() (PR#89):
    • Refactor to fix number matching rules. Now fully valid for floating point numbers in decimal (eg 0.123/1.23e+01), hexadecimal (eg 0x123.abc/0x1.23abcp+01), binary (eg 0b101.10/0b1.0110p+01) and octal format (eg 0o701.10/0o7.0110p+01) , with or without exponent or power, in lower or upper case.
    • Also, make the number parsing stateful to fix cases where repeated characters occur, (like e.g. 0.1.0 or 1.23e+e10) which are no longer reported as numbers (see biojppm/rapidyaml#291).
  • csubstr::first_int_span(), csubstr::first_uint_span(): fix edge cases like e.g. 0xzz which were wrongly reported as numbers.
  • Add fully qualified ARM detection macros:
    • __ARM_ARCH_7EM__ (PR#90).
    • __ARM_ARCH_6KZ__ (PR#93).
    • __ARM_ARCH_8A__ (#94).
  • Improve linux and unix platform detection: detect both __linux and __linux__ (PR#92).

Thanks