diff options
author | kan <kan@FreeBSD.org> | 2004-07-28 03:11:36 +0000 |
---|---|---|
committer | kan <kan@FreeBSD.org> | 2004-07-28 03:11:36 +0000 |
commit | 5e00ec74d8ce58f99801200d4d3d0412c7cc1b28 (patch) | |
tree | 052f4bb635f2bea2c5e350bd60c902be100a0d1e /contrib/gcc/hex.c | |
parent | 87b8398a7d9f9bf0e28bbcd54a4fc27db2125f38 (diff) | |
download | FreeBSD-src-5e00ec74d8ce58f99801200d4d3d0412c7cc1b28.zip FreeBSD-src-5e00ec74d8ce58f99801200d4d3d0412c7cc1b28.tar.gz |
Gcc 3.4.2 20040728.
Diffstat (limited to 'contrib/gcc/hex.c')
-rw-r--r-- | contrib/gcc/hex.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/contrib/gcc/hex.c b/contrib/gcc/hex.c index 5f82292..e4c5dfa 100644 --- a/contrib/gcc/hex.c +++ b/contrib/gcc/hex.c @@ -19,6 +19,11 @@ Boston, MA 02111-1307, USA. */ #include <stdio.h> /* for EOF */ #include "libiberty.h" +#include "safe-ctype.h" /* for HOST_CHARSET_ASCII */ + +#if EOF != -1 + #error "hex.c requires EOF == -1" +#endif /* @@ -39,13 +44,19 @@ or zero if it is not. Note that the value you pass will be cast to @end deftypefn -@deftypefn Extension int hex_value (int @var{c}) +@deftypefn Extension unsigned int hex_value (int @var{c}) Returns the numeric equivalent of the given character when interpreted as a hexidecimal digit. The result is undefined if you pass an invalid hex digit. Note that the value you pass will be cast to @code{unsigned char} within the macro. +The @code{hex_value} macro returns @code{unsigned int}, rather than +signed @code{int}, to make it easier to use in parsing addresses from +hex dump files: a signed @code{int} would be sign-extended when +converted to a wider unsigned type --- like @code{bfd_vma}, on some +systems. + @end deftypefn @undocumented _hex_array_size @@ -56,11 +67,9 @@ invalid hex digit. Note that the value you pass will be cast to /* Are we ASCII? */ -#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \ - && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21 \ - && EOF == -1 +#if HOST_CHARSET == HOST_CHARSET_ASCII -const char _hex_value[_hex_array_size] = +const unsigned char _hex_value[_hex_array_size] = { _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* NUL SOH STX ETX */ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* EOT ENQ ACK BEL */ @@ -139,7 +148,7 @@ const char _hex_value[_hex_array_size] = #else -char _hex_value[_hex_array_size]; +unsigned char _hex_value[_hex_array_size]; #endif /* not ASCII */ |