- register u_int i, s;
- register int nshorts;
-
- char line[81];
-
- nshorts = (u_int) length / sizeof(u_short);
- i = 0;
- memset(line, ' ', 80);
- line[81]='\0';
-
- putchar('\n');
- while (nshorts >= 0) {
-
- sprintf(line+20+i*5, "%02x%02x ", cp[0], cp[1]);
-
- if(isprint(cp[0])) {
- line[62+i*2]=cp[0];
- } else {
- line[62+i*2]='.';
- }
- if(isprint(cp[1])) {
- line[62+i*2+1]=cp[1];
- } else {
- line[62+i*2+1]='.';
- }
- i++;
- if (i == 8) {
- line[60]=' ';
- line[61]=' ';
- line[62+16]='\0';
- puts(line);
- i=0;
- }
- cp += 2;
- nshorts--;
- }
+ register u_int i, s;
+ register int nshorts;
+
+ if (Xflag) {
+ ascii_print(cp, length);
+ return;
+ }
+ nshorts = (u_int) length / sizeof(u_short);
+ i = 0;
+ while (--nshorts >= 0) {
+ if ((i++ % 8) == 0)
+ (void)printf("\n\t\t\t");
+ s = *cp++;
+ (void)printf(" %02x%02x", s, *cp++);
+ }
+ if (length & 1) {
+ if ((i % 8) == 0)
+ (void)printf("\n\t\t\t");
+ (void)printf(" %02x", *cp);
+ }