hexdump: correctly display signed single byte integers
When using the format string '/1 "%d"', the byte did not display as a signed integer as expected, it was interpreted as unsigned.
This commit is contained in:
parent
d3363ef6d7
commit
a27ff267f0
|
@ -145,13 +145,15 @@ print(struct hexdump_pr *pr, unsigned char *bp) {
|
||||||
}
|
}
|
||||||
case F_INT:
|
case F_INT:
|
||||||
{
|
{
|
||||||
|
char cval; /* int8_t */
|
||||||
short sval; /* int16_t */
|
short sval; /* int16_t */
|
||||||
int ival; /* int32_t */
|
int ival; /* int32_t */
|
||||||
long long Lval; /* int64_t, int64_t */
|
long long Lval; /* int64_t, int64_t */
|
||||||
|
|
||||||
switch(pr->bcnt) {
|
switch(pr->bcnt) {
|
||||||
case 1:
|
case 1:
|
||||||
printf(pr->fmt, (unsigned long long) *bp);
|
memmove(&cval, bp, sizeof(cval));
|
||||||
|
printf(pr->fmt, (unsigned long long) cval);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
memmove(&sval, bp, sizeof(sval));
|
memmove(&sval, bp, sizeof(sval));
|
||||||
|
|
Loading…
Reference in New Issue