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
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils