X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fstrings.c;h=f60e4b4d70a968fa5a25059bcf06ee836246a58e;hb=a286dd013ef8d46edf013efc0908822a59d8ac81;hp=084eb999ffe896986ee632b1ae73e0362ea2c8de;hpb=18a667176dd196f7bc3a9cdf1cbd87d4c7b31c7f;p=platform%2Fupstream%2Felfutils.git diff --git a/src/strings.c b/src/strings.c index 084eb99..f60e4b4 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1,5 +1,5 @@ /* Print the strings of printable characters in files. - Copyright (C) 2005-2010, 2012 Red Hat, Inc. + Copyright (C) 2005-2010, 2012, 2014 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 2005. @@ -116,8 +116,15 @@ static bool char_7bit; /* True if file names should be printed before strings. */ static bool print_file_name; -/* Location print format string. */ -static const char *locfmt; +/* Radix for printed numbers. */ +static enum +{ + radix_none = 0, + radix_decimal, + radix_hex, + radix_octal +} radix = radix_none; + /* Page size in use. */ static size_t ps; @@ -279,16 +286,16 @@ parse_opt (int key, char *arg, switch (arg[0]) { case 'd': - locfmt = "%7" PRId64 " "; + radix = radix_decimal; break; case 'o': octfmt: - locfmt = "%7" PRIo64 " "; + radix = radix_octal; break; case 'x': - locfmt = "%7" PRIx64 " "; + radix = radix_hex; break; default: @@ -355,8 +362,11 @@ process_chunk_mb (const char *fname, const unsigned char *buf, off64_t to, fputs_unlocked (": ", stdout); } - if (unlikely (locfmt != NULL)) - printf (locfmt, (int64_t) to - len - (buf - start)); + if (unlikely (radix != radix_none)) + printf ((radix == radix_octal ? "%7" PRIo64 " " + : (radix == radix_decimal ? "%7" PRId64 " " + : "%7" PRIx64 " ")), + (int64_t) to - len - (buf - start)); if (unlikely (*unprinted != NULL)) { @@ -420,8 +430,11 @@ process_chunk (const char *fname, const unsigned char *buf, off64_t to, fputs_unlocked (": ", stdout); } - if (likely (locfmt != NULL)) - printf (locfmt, (int64_t) to - len - (buf - start)); + if (likely (radix != radix_none)) + printf ((radix == radix_octal ? "%7" PRIo64 " " + : (radix == radix_decimal ? "%7" PRId64 " " + : "%7" PRIx64 " ")), + (int64_t) to - len - (buf - start)); if (unlikely (*unprinted != NULL)) { @@ -452,13 +465,6 @@ process_chunk (const char *fname, const unsigned char *buf, off64_t to, static void * map_file (int fd, off64_t start_off, off64_t fdlen, size_t *map_sizep) { -#if _MUDFLAP - (void) fd; - (void) start_off; - (void) fdlen; - (void) map_sizep; - return MAP_FAILED; -#else /* Maximum size we mmap. We use an #ifdef to avoid overflows on 32-bit machines. 64-bit machines these days do not have usable address spaces larger than about 43 bits. Not that any file @@ -500,7 +506,6 @@ map_file (int fd, off64_t start_off, off64_t fdlen, size_t *map_sizep) *map_sizep = map_size; return mem; -#endif }