* Copyright (c) 1990 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)odsyntax.c 5.4 (Berkeley) 3/8/91";
extern enum _vflag vflag
;
extern int length
, optind
;
while ((ch
= getopt(argc
, argv
, "aBbcDdeFfHhIiLlOoPpswvXx")) != EOF
)
add("16/1 \"%3_u \" \"\\n\"");
add("8/2 \" %06o \" \"\\n\"");
add("16/1 \"%03o \" \"\\n\"");
add("16/1 \"%3_c \" \"\\n\"");
add("8/2 \" %05u \" \"\\n\"");
add("4/4 \" %010u \" \"\\n\"");
case 'e': /* undocumented in od */
add("2/8 \" %21.14e \" \"\\n\"");
add("4/4 \" %14.7e \" \"\\n\"");
add("4/4 \" %08x \" \"\\n\"");
add("8/2 \" %04x \" \"\\n\"");
add("4/4 \" %11d \" \"\\n\"");
add("8/2 \" %6d \" \"\\n\"");
add("4/4 \" %011o \" \"\\n\"");
"od: od(1) has been deprecated for hexdump(1).\n");
"od: hexdump(1) compatibility doesn't support the -%c option%s\n",
ch
, ch
== 's' ? "; see strings(1)." : ".");
add("\"%07.7_ao \" 8/2 \"%06o \" \"\\n\"");
if(argc
> 1) odoffset(argc
, argvp
);
(c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F')
* The offset syntax of od(1) was genuinely bizarre. First, if
* it started with a plus it had to be an offset. Otherwise, if
* there were at least two arguments, a number or lower-case 'x'
* followed by a number makes it an offset. By default it was
* octal; if it started with 'x' or '0x' it was hex. If it ended
* in a '.', it was decimal. If a 'b' or 'B' was appended, it
* multiplied the number by 512 or 1024 byte units. There was
* no way to assign a block count to a hex offset.
* We assumes it's a file if the offset is bad.
if (*p
!= '+' && (argc
< 2 ||
(!isdigit(p
[0]) && (p
[0] != 'x' || !ishexdigit(p
[1])))))
* skip over leading '+', 'x[0-9a-fA-f]' or '0x', and
if (p
[0] == 'x' && ishexdigit(p
[1])) {
} else if (p
[0] == '0' && p
[1] == 'x') {
/* skip over the number */
for (num
= p
; ishexdigit(*p
); ++p
);
for (num
= p
; isdigit(*p
); ++p
);
/* check for no number */
/* if terminates with a '.', base is decimal */
skip
= strtol(num
, &end
, base
? base
: 8);
/* if end isn't the same as p, we got a non-octal digit */
* If the offset uses a non-octal base, the base of
* the offset is changed as well. This isn't pretty,
fshead
->nextfu
->fmt
[TYPE_OFFSET
] = 'x';
fshead
->nextfs
->nextfu
->fmt
[TYPE_OFFSET
] = 'x';
fshead
->nextfu
->fmt
[TYPE_OFFSET
] = 'd';
fshead
->nextfs
->nextfu
->fmt
[TYPE_OFFSET
] = 'd';