diff options
author | Bill Kendall <wkendall@sgi.com> | 2011-07-27 16:41:53 +0000 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2011-08-09 15:55:48 -0500 |
commit | 5e127af43be3c31198d1dcf616958af19321dcd9 (patch) | |
tree | 7644a05b15468e9593f7c9cb9fb685b03c564548 | |
parent | 1c728a7caae4fb65e976049a4a69bc03fda0cd4a (diff) | |
download | xfsdump-dev-5e127af43be3c31198d1dcf616958af19321dcd9.tar.gz |
xfsdump: allow multi-digit dialog prompts
xfsdump issues a multiple-choice dialog in various circumstances
(e.g., media change request). An assert incorrectly limits this to
at most 8 choices even though the code can handle up to 9. Remove
the assert and change the code to handle multi-digit responses.
Signed-off-by: Bill Kendall <wkendall@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
-rw-r--r-- | common/dlog.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/common/dlog.c b/common/dlog.c index 6a243ef8..c81edc62 100644 --- a/common/dlog.c +++ b/common/dlog.c @@ -19,6 +19,7 @@ #include <xfs/xfs.h> #include <xfs/jdm.h> +#include <stdlib.h> #include <sys/stat.h> #include <fcntl.h> #include <time.h> @@ -186,7 +187,6 @@ dlog_multi_query( char *querystr[ ], /* sanity */ ASSERT( dlog_allowed_flag ); - ASSERT( choicecnt < 9 ); /* display query description strings */ @@ -245,24 +245,21 @@ dlog_multi_query( char *querystr[ ], prepromptstr, choicecnt ); if ( ok ) { + long int val; + char *end = buf; + if ( ! strlen( buf )) { return defaultix; } - if ( strlen( buf ) != 1 ) { - prepromptstr = _( - "please enter a single " - "digit response (1 to %d)"); - continue; - } - if ( buf[ 0 ] < '1' - || - buf[ 0 ] >= '1' + ( u_char_t )choicecnt ) { + + val = strtol( buf, &end, 10 ); + if ( *end != '\0' || val < 1 || val > choicecnt ) { prepromptstr = _( - "please enter a single digit " + "please enter a value " "between 1 and %d inclusive "); continue; } - return ( size_t )( buf[ 0 ] - '1' ); + return val - 1; // return value is a 0-based index } else { return exceptionix; } |