Skip to content

Commit

Permalink
fixed incorrect unicode scalar sequence transformations (#125)
Browse files Browse the repository at this point in the history
also:
- fixed extended-precision fractional times causing parse error instead of truncating per the spec (closes #127)
- fixed some non-spec vertical whitespace being accepted as line breaks (closes #128)
- added `format_flags::allow_unicode_strings`
  • Loading branch information
marzer committed Jan 4, 2022
1 parent f3bd22b commit b41e12f
Show file tree
Hide file tree
Showing 37 changed files with 1,009 additions and 452 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ code changes at callsites or in build systems are indicated with ⚠️.
- fixed missing `TOML_API` on interfaces
- fixed parser not correctly round-tripping the format of binary and octal integers in some cases
- fixed strong exception guarantee edge-cases in `toml::table` and `toml::array`
- fixed some incorrect unicode scalar sequence transformations (#125) (@moorereason)
- fixed extended-precision fractional times causing parse error instead of truncating per the spec (#127) (@moorereason)
- fixed some non-spec vertical whitespace being accepted as line breaks (#128) (@moorereason)

#### Additions:
- added `operator->` to `toml::value` for class types
Expand All @@ -48,6 +51,7 @@ code changes at callsites or in build systems are indicated with ⚠️.
- added `toml::format_flags::allow_hexadecimal_integers`
- added `toml::format_flags::allow_octal_integers`
- added `toml::format_flags::allow_real_tabs_in_strings`
- added `toml::format_flags::allow_unicode_strings`
- added `toml::format_flags::indent_array_elements`
- added `toml::format_flags::indent_sub_tables`
- added `toml::format_flags::quote_infinities_and_nans`
Expand Down
5 changes: 3 additions & 2 deletions examples/error_printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// This example shows the error messages the library produces by forcing a set of specific parsing
// failures and printing their results.

#include "examples.hpp"
#include "examples.h"

#define TOML_EXCEPTIONS 0
#define TOML_ENABLE_UNRELEASED_FEATURES 0
Expand All @@ -17,10 +17,11 @@ using namespace std::string_view_literals;
namespace
{
inline constexpr auto invalid_parses = std::array{
"########## comments"sv,
"########## comments and whitespace"sv,
"# bar\rkek"sv,
"# bar\bkek"sv,
"# \xf1\x63"sv,
"# val1 = 1\fval2 = 2"sv,

"########## inline tables"sv,
"val = {,}"sv,
Expand Down
2 changes: 1 addition & 1 deletion examples/error_printer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="examples.hpp" />
<ClInclude Include="examples.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/parse_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// This example is just a short-n-shiny benchmark.

#include "examples.hpp"
#include "examples.h"
#include <toml++/toml.h>

using namespace std::string_view_literals;
Expand Down
2 changes: 1 addition & 1 deletion examples/parse_benchmark.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="examples.hpp" />
<ClInclude Include="examples.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
2 changes: 1 addition & 1 deletion examples/simple_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// This example demonstrates how to parse TOML from a file or stdin and re-serialize it (print it out) to stdout.

#include "examples.hpp"
#include "examples.h"

#define TOML_ENABLE_UNRELEASED_FEATURES 1
#include <toml++/toml.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_parser.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="examples.hpp" />
<ClInclude Include="examples.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
2 changes: 1 addition & 1 deletion examples/toml_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// This example demonstrates the use of some more advanced features to generate a tree of random TOML data.

#include "examples.hpp"
#include "examples.h"

#define TOML_ENABLE_PARSER 0
#include <toml++/toml.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/toml_generator.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="examples.hpp" />
<ClInclude Include="examples.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
2 changes: 1 addition & 1 deletion examples/toml_to_json_transcoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// This example demonstrates how to use the toml::json_formatter to re-serialize TOML data as JSON.

#include "examples.hpp"
#include "examples.h"

#define TOML_ENABLE_UNRELEASED_FEATURES 1
#include <toml++/toml.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/toml_to_json_transcoder.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="examples.hpp" />
<ClInclude Include="examples.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
18 changes: 18 additions & 0 deletions include/toml++/impl/formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,24 @@ TOML_IMPL_NAMESPACE_START
return !!(config_.flags & format_flags::allow_literal_strings);
}

TOML_PURE_INLINE_GETTER
bool multi_line_strings_allowed() const noexcept
{
return !!(config_.flags & format_flags::allow_multi_line_strings);
}

TOML_PURE_INLINE_GETTER
bool real_tabs_in_strings_allowed() const noexcept
{
return !!(config_.flags & format_flags::allow_real_tabs_in_strings);
}

TOML_PURE_INLINE_GETTER
bool unicode_strings_allowed() const noexcept
{
return !!(config_.flags & format_flags::allow_unicode_strings);
}

TOML_API
void attach(std::ostream& stream) noexcept;

Expand Down
Loading

0 comments on commit b41e12f

Please sign in to comment.