Make hexdump ACK-compilable and add it to the base system

This commit is contained in:
Erik van der Kouwe 2010-09-03 07:37:31 +00:00
parent 9e4e26e0c8
commit 18ad0b52d3
5 changed files with 34 additions and 6 deletions

View file

@ -12,7 +12,7 @@ SUBDIR= aal add_route adduser advent arp ash at autil awk \
dhrystone diff dirname dis88 diskctl du dumpcore \
ed eject elle elvis env expand factor file \
find finger fingerd fix fold format fortune fsck.mfs \
fsck1 ftp101 ftpd200 gcov-pull getty grep gomoku head host \
fsck1 ftp101 ftpd200 gcov-pull getty grep gomoku head hexdump host \
hostaddr id ifconfig ifdef indent install \
intr ipcrm ipcs irdpd isoread join kill last leave \
less lex life loadkeys loadramdisk logger login look lp \
@ -41,9 +41,4 @@ SUBDIR+= atnormalize dosread fdisk loadfont \
SUBDIR+= acd asmconv gas2ack
.endif
# Build only with clang and GCC
.if ${COMPILER_TYPE} == "gnu"
SUBDIR+= hexdump
.endif
.include <bsd.subdir.mk>

View file

@ -128,10 +128,14 @@ print(PR *pr, u_char *bp)
float f4;
int16_t s2;
int32_t s4;
#ifdef __LONG_LONG_SUPPORTED
int64_t s8;
#endif
uint16_t u2;
uint32_t u4;
#ifdef __LONG_LONG_SUPPORTED
uint64_t u8;
#endif
switch(pr->flags) {
case F_ADDRESS:
@ -171,10 +175,12 @@ print(PR *pr, u_char *bp)
memmove(&s4, bp, sizeof(s4));
(void)printf(pr->fmt, (int64_t)s4);
break;
#ifdef __LONG_LONG_SUPPORTED
case 8:
memmove(&s8, bp, sizeof(s8));
(void)printf(pr->fmt, (int64_t)s8);
break;
#endif
}
break;
case F_P:
@ -202,10 +208,12 @@ print(PR *pr, u_char *bp)
memmove(&u4, bp, sizeof(u4));
(void)printf(pr->fmt, (uint64_t)u4);
break;
#ifdef __LONG_LONG_SUPPORTED
case 8:
memmove(&u8, bp, sizeof(u8));
(void)printf(pr->fmt, (uint64_t)u8);
break;
#endif
}
break;
}

View file

@ -310,6 +310,10 @@ option.
.Pp
.Nm
exits 0 on success and \*[Gt]0 if an error occurred.
.Sh MINIX-SPECIFIC notes
If hexdump is compiled on a compiler that does not support long long (that is,
ACK), 64-bit (8 byte) integer formats are not supported. Conversions where this
is the default are changed to use a 32-bit 4 byte) default instead.
.Sh EXAMPLES
Display the input in perusal format:
.Bd -literal -offset indent

View file

@ -68,6 +68,17 @@ typedef struct _fs { /* format strings */
int bcnt;
} FS;
#ifdef __minix
#define inline
#ifndef __LONG_LONG_SUPPORTED
#include <minix/u64.h>
typedef long int64_t;
typedef unsigned long uint64_t;
#define PRId64 "ld"
#endif
#endif
enum _vflag { ALL, DUP, FIRST, WAIT }; /* -v values */
extern int blocksize; /* data block size */

View file

@ -194,7 +194,11 @@ size(FS *fs)
bcnt += 4;
break;
case 'e': case 'E': case 'f': case 'g': case 'G':
#ifdef __LONG_LONG_SUPPORTED
bcnt += 8;
#else
bcnt += 4;
#endif
break;
case 's':
bcnt += prec;
@ -320,9 +324,11 @@ isint:
case 2:
pr->bcnt = 2;
break;
#ifdef __LONG_LONG_SUPPORTED
case 8:
pr->bcnt = 8;
break;
#endif
default:
p1[1] = '\0';
badcnt(p1);
@ -331,9 +337,13 @@ isint:
case 'e': case 'E': case 'f': case 'g': case 'G':
pr->flags = F_DBL;
switch(fu->bcnt) {
#ifdef __LONG_LONG_SUPPORTED
case 0: case 8:
pr->bcnt = 8;
break;
#else
case 0:
#endif
case 4:
pr->bcnt = 4;
break;