isprint() wants value in range [-1, 255]

The MSVC impl. assert()s this
This commit is contained in:
Michael Davidsaver
2022-11-26 10:44:02 -08:00
parent 45671faaea
commit 0b424a71ec
2 changed files with 4 additions and 4 deletions

View File

@@ -497,7 +497,7 @@ std::ostream& operator<<(std::ostream& strm, const escape& Q)
case '\'': next = '\''; break;
case '\"': next = '\"'; if(Q.S==escape::CSV) quote = '"'; break;
default:
if(!isprint(C)) {
if(!isprint((unsigned char)C)) {
// print three charator escape
strm<<"\\x"<<hexdigit(C>>4)<<hexdigit(C);
} else {
@@ -534,7 +534,7 @@ std::ostream& operator<<(std::ostream& strm, const maybeQuote& q)
esc = true;
break;
default:
if(!isprint(q.s[i])) {
if(!isprint((unsigned char)q.s[i])) {
esc = true;
}
break;

View File

@@ -247,7 +247,7 @@ void showNTTable()
iarr.push_back(42); // will not be shown
input->getSubFieldT<pvd::PVIntArray>("value.colA")->replace(pvd::freeze(iarr));
sarr.push_back("one\x7f");
sarr.push_back("one\x7f\x80");
sarr.push_back("two words");
sarr.push_back("A '\"'");
input->getSubFieldT<pvd::PVStringArray>("value.colB")->replace(pvd::freeze(sarr));
@@ -255,7 +255,7 @@ void showNTTable()
testDiff("<undefined> \n"
"labelA \"label B\"\n"
" 1 one\\x7F\n"
" 1 one\\x7F\\x80\n"
" 2 \"two words\"\n"
" 3 \"A \\'\"\"\\'\"\n"
, print(input->stream()),