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,8 +3,6 @@
3 #include <qpdf/JSON_writer.hh> 3 #include <qpdf/JSON_writer.hh>
4 #include <qpdf/QUtil.hh> 4 #include <qpdf/QUtil.hh>
5 5
6 -#include <string_view>  
7 -  
8 QPDF_Name::QPDF_Name(std::string const& name) : 6 QPDF_Name::QPDF_Name(std::string const& name) :
9 QPDFValue(::ot_name, "name"), 7 QPDFValue(::ot_name, "name"),
10 name(name) 8 name(name)
@@ -57,14 +55,12 @@ QPDF_Name::unparse() @@ -57,14 +55,12 @@ QPDF_Name::unparse()
57 std::pair<bool, bool> 55 std::pair<bool, bool>
58 QPDF_Name::analyzeJSONEncoding(const std::string& name) 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 int tail = 0; // Number of continuation characters expected. 58 int tail = 0; // Number of continuation characters expected.
64 bool tail2 = false; // Potential overlong 3 octet utf-8. 59 bool tail2 = false; // Potential overlong 3 octet utf-8.
65 bool tail3 = false; // potential overlong 4 octet 60 bool tail3 = false; // potential overlong 4 octet
66 bool needs_escaping = false; 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 if (tail) { 64 if (tail) {
69 if ((c & 0xc0) != 0x80) { 65 if ((c & 0xc0) != 0x80) {
70 return {false, false}; 66 return {false, false};