Skip to content

Commit

Permalink
🛠 Repair erroneous GCC bounds check and update to windows_1252
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhD committed Dec 23, 2022
1 parent fe03443 commit 828a382
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ if(ZTD_TEXT_IS_TOP_LEVEL_PROJECT)
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95353
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
check_compiler_diagnostic(stringop-overflow)
check_compiler_diagnostic(array-bounds)
endif()
endif()
endif()
Expand Down
1 change: 1 addition & 0 deletions benchmarks/barrier/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ target_compile_options(ztd.text.benchmarks.barrier
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
)
target_link_libraries(ztd.text.benchmarks.barrier
PRIVATE
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/conversion_speed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ function (generate_converion_speed_benchmark_targets name data_name title)
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
)
${--allow-array-bounds}
)
target_compile_definitions(ztd.text.benchmarks.conversion_speed.${name}
PRIVATE
u8_data=u8_${data_name}_data
Expand Down
1 change: 1 addition & 0 deletions benchmarks/function_form/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function (generate_function_form_benchmark_targets name data_name title)
${--warn-extra}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
# MSVC is BROKEN
# ${--warn-errors}
)
Expand Down
1 change: 1 addition & 0 deletions examples/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ foreach (example_source_name ${ztd.text.examples.basic.sources})
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
${--allow-bit-int-extension}
)

Expand Down
1 change: 1 addition & 0 deletions examples/boost.text/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ target_compile_options(ztd.text.examples.boost_text
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
)

target_include_directories(ztd.text.examples.boost_text
Expand Down
1 change: 1 addition & 0 deletions examples/documentation/compile_fails/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ foreach (example_name ${ztd.text.examples.documentation.compile_fails.sources})
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
)
set_target_properties(${example_target}
PROPERTIES
Expand Down
1 change: 1 addition & 0 deletions examples/documentation/quick/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ foreach (example_source_name ${ztd.text.examples.documentation.quick.basic.sourc
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
)

target_link_libraries(${example_target}
Expand Down
1 change: 1 addition & 0 deletions examples/documentation/snippets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ foreach (example_source_name ${ztd.text.examples.documentation.snippets.sources}
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
)
target_include_directories(${example_target}
PRIVATE
Expand Down
1 change: 1 addition & 0 deletions examples/shift_jis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ target_compile_options(ztd.text.examples.shift_jis
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
)
target_include_directories(ztd.text.examples.shift_jis
PRIVATE
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions tests/additional_encodings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ target_compile_options(ztd.text.tests.additional_encodings
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
)
target_include_directories(ztd.text.tests.additional_encodings
PRIVATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@
#include <iostream>
#include <vector>

TEST_CASE("text/additional_encodings/latin1", "test a quick roundtrip using example Latin-1 text to UTF-32") {
constexpr const char* original_filename = "data/tests/additional_encodings/latin1/latin1.txt";
TEST_CASE("text/additional_encodings/windows_1252", "test a quick roundtrip using example Latin-1 text to UTF-32") {
constexpr const char* original_filename = "data/tests/additional_encodings/windows_1252/windows_1252.txt";
std::ifstream original_ifstr(
original_filename, static_cast<std::ios_base::openmode>(std::ios_base::in | std::ios_base::binary));
original_ifstr >> std::noskipws;
std::vector<unsigned char> original_data(
std::istream_iterator<unsigned char>(original_ifstr), std::istream_iterator<unsigned char> {});

constexpr const char* expected_filename = ztd::endian::native == ztd::endian::little
? "data/tests/additional_encodings/latin1/utf-32-le.txt"
: "data/tests/additional_encodings/latin1/utf-32-be.txt";
? "data/tests/additional_encodings/windows_1252/utf-32-le.txt"
: "data/tests/additional_encodings/windows_1252/utf-32-be.txt";
std::ifstream expected_ifstr(
expected_filename, static_cast<std::ios_base::openmode>(std::ios_base::in | std::ios_base::binary));
expected_ifstr >> std::noskipws;
Expand All @@ -59,13 +59,13 @@ TEST_CASE("text/additional_encodings/latin1", "test a quick roundtrip using exam
std::u32string_view expected(
reinterpret_cast<const char32_t*>(expected_data.data()), expected_data.size() / sizeof(char32_t));

auto decoded_result = ztd::text::decode_to(original, ztd::text::latin1, ztd::text::pass_handler);
auto decoded_result = ztd::text::decode_to(original, ztd::text::windows_1252, ztd::text::pass_handler);
const std::u32string& decoded = decoded_result.output;
REQUIRE(decoded_result.error_code == ztd::text::encoding_error::ok);
REQUIRE_FALSE(decoded_result.errors_were_handled());
REQUIRE(ztd::ranges::empty(decoded_result.input));
REQUIRE(decoded == expected);
auto encoded_result = ztd::text::encode_to(decoded, ztd::text::latin1, ztd::text::pass_handler);
auto encoded_result = ztd::text::encode_to(decoded, ztd::text::windows_1252, ztd::text::pass_handler);
const std::string& encoded = encoded_result.output;
REQUIRE(encoded_result.error_code == ztd::text::encoding_error::ok);
REQUIRE_FALSE(encoded_result.errors_were_handled());
Expand Down
1 change: 1 addition & 0 deletions tests/basic_compile_time/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ target_compile_options(ztd.text.tests.basic_compile_time
${--extra-constexpr-steps}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
)
target_include_directories(ztd.text.tests.basic_compile_time
PRIVATE
Expand Down
1 change: 1 addition & 0 deletions tests/basic_run_time/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ target_compile_options(ztd.text.tests.basic_run_time
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
)
target_include_directories(ztd.text.tests.basic_run_time
PRIVATE
Expand Down
1 change: 1 addition & 0 deletions tests/compile_fails/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ foreach (test_name ${ztd.text.tests.tests.compile_fails.sources})
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
)
target_link_libraries(${test_target}
PRIVATE
Expand Down
1 change: 1 addition & 0 deletions tests/iconv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ target_compile_options(ztd.text.tests.iconv
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
)
target_include_directories(ztd.text.tests.iconv
PRIVATE
Expand Down
1 change: 1 addition & 0 deletions tests/inclusion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ target_compile_options(ztd.text.tests.inclusion
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
)
target_link_libraries(ztd.text.tests.inclusion
PRIVATE
Expand Down
1 change: 1 addition & 0 deletions tests/tiny_buffer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ target_compile_options(ztd.text.tests.tiny_buffer
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
${--allow-array-bounds}
)
target_include_directories(ztd.text.tests.tiny_buffer
PRIVATE
Expand Down

0 comments on commit 828a382

Please sign in to comment.