@@ -163,31 +163,49 @@ if (defined $opt_t) {
163163 $fmt = \&hex2;
164164 } elsif ($opt_t eq ' x4' ) {
165165 $fmt = \&hex4;
166+ } elsif ($opt_t eq ' x8' ) {
167+ $fmt = \&hex8;
166168 } elsif ($opt_t eq ' o1' ) {
167169 $fmt = \&octal1;
168170 } elsif ($opt_t eq ' o2' ) {
169171 $fmt = \&octal2;
170172 } elsif ($opt_t eq ' o4' ) {
171173 $fmt = \&octal4;
174+ } elsif ($opt_t eq ' o8' ) {
175+ $fmt = \&octal8;
172176 } elsif ($opt_t eq ' d1' ) {
173177 $fmt = \&decimal1;
174178 } elsif ($opt_t eq ' d2' ) {
175179 $fmt = \&decimal2;
176180 } elsif ($opt_t eq ' d4' ) {
177181 $fmt = \&decimal4;
182+ } elsif ($opt_t eq ' d8' ) {
183+ $fmt = \&decimal8;
178184 } elsif ($opt_t eq ' u1' ) {
179185 $fmt = \&udecimal1;
180186 } elsif ($opt_t eq ' u2' ) {
181187 $fmt = \&udecimal2;
182188 } elsif ($opt_t eq ' u4' ) {
183189 $fmt = \&udecimal4;
190+ } elsif ($opt_t eq ' u8' ) {
191+ $fmt = \&udecimal8;
184192 } elsif ($opt_t eq ' a' ) {
185193 $fmt = \&char7bit;
186194 } elsif ($opt_t eq ' c' ) {
187195 $fmt = \&char1;
188196 } else {
189197 warn " $Program : unexpected output format specifier\n " ;
190- exit EX_FAILURE;
198+ exit EX_FAILURE;
199+ }
200+ if ($opt_t =~ m /\A [doux] 8\Z / ) {
201+ my $has_quad = eval {
202+ unpack ' Q' , ' ' ;
203+ 1;
204+ };
205+ unless ($has_quad ) {
206+ warn " $Program : 64-bit perl needed for $opt_t format\n " ;
207+ exit EX_FAILURE;
208+ }
191209 }
192210}
193211
@@ -397,6 +415,26 @@ sub hex4 {
397415 $strfmt = ' %.8x ' x (scalar @arr );
398416}
399417
418+ sub hex8 {
419+ @arr = unpack ' Q*' , $data . zeropad(length ($data ), 8);
420+ $strfmt = ' %.16x ' x (scalar @arr );
421+ }
422+
423+ sub octal8 {
424+ @arr = unpack ' Q*' , $data . zeropad(length ($data ), 8);
425+ $strfmt = ' %.22o ' x (scalar @arr );
426+ }
427+
428+ sub udecimal8 {
429+ @arr = unpack ' Q*' , $data . zeropad(length ($data ), 8);
430+ $strfmt = ' %22u ' x (scalar @arr );
431+ }
432+
433+ sub decimal8 {
434+ @arr = unpack ' Q*' , $data . zeropad(length ($data ), 8);
435+ $strfmt = ' %22d ' x (scalar @arr );
436+ }
437+
400438sub zeropad {
401439 my ($len , $wantbytes ) = @_ ;
402440 my $remain = $len % $wantbytes ;
@@ -518,15 +556,19 @@ Select output format as one of the following:
518556 o1 1-byte unsigned octal
519557 o2 2-byte unsigned octal
520558 o4 4-byte unsigned octal
559+ o8 8-byte unsigned octal
521560 d1 1-byte signed decimal
522561 d2 2-byte signed decimal
523562 d4 4-byte signed decimal
563+ d8 8-byte signed decimal
524564 u1 1-byte unsigned decimal
525565 u2 2-byte unsigned decimal
526566 u4 4-byte unsigned decimal
567+ u8 8-byte unsigned decimal
527568 x1 1-byte unsigned hexadecimal
528569 x2 2-byte unsigned hexadecimal
529570 x4 4-byte unsigned hexadecimal
571+ x8 8-byte unsigned hexadecimal
530572
531573This option overrides other formatting options.
532574
0 commit comments