Commit 07bc36322489703fe676ab8d5d2eeaf84826e7ee

Authored by Zoe Clifford
1 parent 3b97c9bd

string_view leads to char_traits which is not standard C++ (background in #1024).

This triggers compilation failures with certain C++20 compiler configurations.

To avoid this I moved the cast to the loop's body.
Showing 1 changed file with 2 additions and 6 deletions
libqpdf/QPDF_Name.cc
... ... @@ -3,8 +3,6 @@
3 3 #include <qpdf/JSON_writer.hh>
4 4 #include <qpdf/QUtil.hh>
5 5  
6   -#include <string_view>
7   -
8 6 QPDF_Name::QPDF_Name(std::string const& name) :
9 7 QPDFValue(::ot_name, "name"),
10 8 name(name)
... ... @@ -57,14 +55,12 @@ QPDF_Name::unparse()
57 55 std::pair<bool, bool>
58 56 QPDF_Name::analyzeJSONEncoding(const std::string& name)
59 57 {
60   - std::basic_string_view<unsigned char> view{
61   - reinterpret_cast<const unsigned char*>(name.data()), name.size()};
62   -
63 58 int tail = 0; // Number of continuation characters expected.
64 59 bool tail2 = false; // Potential overlong 3 octet utf-8.
65 60 bool tail3 = false; // potential overlong 4 octet
66 61 bool needs_escaping = false;
67   - for (auto const& c: view) {
  62 + for (auto it = name.begin(); it != name.end(); ++it) {
  63 + unsigned char c = static_cast<unsigned char>(*it);
68 64 if (tail) {
69 65 if ((c & 0xc0) != 0x80) {
70 66 return {false, false};
... ...