V0.9: Fix the display of characters with the MSB set (cast to unsigned char).
When a verinum is displayed as a string we need to make sure that any character that will be displayed as an octal constant must be converted correctly. Also change to isprint() instead of isgraph() since it is the same as isgraph() plus a space.
This commit is contained in:
parent
5a536b88c9
commit
1c8f00e90d
|
|
@ -620,14 +620,14 @@ S [afpnumkKMGT]
|
||||||
error_count += 1; }
|
error_count += 1; }
|
||||||
|
|
||||||
/* Final catchall. something got lost or mishandled. */
|
/* Final catchall. something got lost or mishandled. */
|
||||||
/* XXX Should we tell the luser something about the lexical state? */
|
/* XXX Should we tell the user something about the lexical state? */
|
||||||
|
|
||||||
<*>.|\n { cerr << yylloc.text << ":" << yylloc.first_line
|
<*>.|\n { cerr << yylloc.text << ":" << yylloc.first_line
|
||||||
<< ": error: unmatched character (";
|
<< ": error: unmatched character (";
|
||||||
if (isgraph(yytext[0]))
|
if (isprint(yytext[0]))
|
||||||
cerr << yytext[0];
|
cerr << yytext[0];
|
||||||
else
|
else
|
||||||
cerr << "hex " << hex << (0xffU & ((unsigned) (yytext[0])));
|
cerr << "hex " << hex << ((unsigned char) yytext[0]);
|
||||||
|
|
||||||
cerr << ")" << endl;
|
cerr << ")" << endl;
|
||||||
error_count += 1; }
|
error_count += 1; }
|
||||||
|
|
|
||||||
|
|
@ -516,11 +516,11 @@ string verinum::as_string() const
|
||||||
char tmp[5];
|
char tmp[5];
|
||||||
snprintf(tmp, sizeof tmp, "\\%03o", char_val);
|
snprintf(tmp, sizeof tmp, "\\%03o", char_val);
|
||||||
res = res + tmp;
|
res = res + tmp;
|
||||||
} else if (char_val == ' ' || isgraph(char_val)) {
|
} else if (isprint(char_val)) {
|
||||||
res = res + char_val;
|
res = res + char_val;
|
||||||
} else {
|
} else {
|
||||||
char tmp[5];
|
char tmp[5];
|
||||||
snprintf(tmp, sizeof tmp, "\\%03o", char_val);
|
snprintf(tmp, sizeof tmp, "\\%03o", (unsigned char)char_val);
|
||||||
res = res + tmp;
|
res = res + tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue