bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] support 0x prefix on number arguments passed to dd


From: Bart Trojanowski
Subject: [PATCH] support 0x prefix on number arguments passed to dd
Date: Thu, 4 Oct 2007 18:09:41 -0400
User-agent: Mutt/1.5.12-2006-07-14

This is a trivial patch that adds hexadecimal support for numerical
arguments passed to dd.

---
 src/dd.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/dd.c b/src/dd.c
index 56e3a03..75eb97e 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -829,7 +829,15 @@ parse_integer (const char *str, bool *invalid)
 {
   uintmax_t n;
   char *suffix;
-  enum strtol_error e = xstrtoumax (str, &suffix, 10, &n, "bcEGkKMPTwYZ0");
+  enum strtol_error e;
+  int base = 10;
+  
+  if (str[0] == '0' && str[1] == 'x')
+    {
+      str += 2;
+      base = 16;
+    }
+  e = xstrtoumax (str, &suffix, base, &n, "bcEGkKMPTwYZ0");
 
   if (e == LONGINT_INVALID_SUFFIX_CHAR && *suffix == 'x')
     {
@@ -927,7 +935,7 @@ scanargs (int argc, char **argv)
            }
 
          if (invalid)
-           error (EXIT_FAILURE, 0, _("invalid number %s"), quote (val));
+           error (EXIT_FAILURE, 0, _("invalid number %s (%d)"), quote (val), 
n);
        }
     }
 
-- 
1.5.2.rc0.56.g6169a




reply via email to

[Prev in Thread] Current Thread [Next in Thread]