For now we still use 80, but we could vary that in future.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-void opt_show_floatval(char buf[OPT_SHOW_LEN], const float *f)
+void opt_show_floatval(char *buf, size_t len, const float *f)
- opt_show_doubleval(buf, &d);
+ opt_show_doubleval(buf, len, &d);
}
char *opt_set_doubleval(const char *arg, double *d)
}
char *opt_set_doubleval(const char *arg, double *d)
-void opt_show_doubleval(char buf[OPT_SHOW_LEN], const double *d)
+void opt_show_doubleval(char *buf, size_t len, const double *d)
- snprintf(buf, OPT_SHOW_LEN, "%f", *d);
+ snprintf(buf, len, "%f", *d);
}
char *opt_inc_intval(int *i)
}
char *opt_inc_intval(int *i)
-void opt_show_bool(char buf[OPT_SHOW_LEN], const bool *b)
+void opt_show_bool(char *buf, size_t len, const bool *b)
- strncpy(buf, *b ? "true" : "false", OPT_SHOW_LEN);
+ strncpy(buf, *b ? "true" : "false", len);
-void opt_show_invbool(char buf[OPT_SHOW_LEN], const bool *b)
+void opt_show_invbool(char *buf, size_t len, const bool *b)
- strncpy(buf, *b ? "false" : "true", OPT_SHOW_LEN);
+ strncpy(buf, *b ? "false" : "true", len);
-void opt_show_charp(char buf[OPT_SHOW_LEN], char *const *p)
+void opt_show_charp(char *buf, size_t len, char *const *p)
- if (*p){
- size_t len = strlen(*p);
+ if (*p) {
+ size_t plen = strlen(*p);
+ if (len < 2)
+ return;
- if (len > OPT_SHOW_LEN - 2)
- len = OPT_SHOW_LEN - 2;
- strncpy(buf+1, *p, len);
- buf[1+len] = '"';
- if (len < OPT_SHOW_LEN - 2)
- buf[2+len] = '\0';
+ if (plen > len - 2)
+ plen = len - 2;
+ strncpy(buf+1, *p, plen);
+ buf[1+plen] = '"';
+ if (plen < len - 2)
+ buf[2+plen] = '\0';
- strncpy(buf, "(nil)", OPT_SHOW_LEN);
+ strncpy(buf, "(nil)", len);
}
}
/* Show an integer value, various forms. */
}
}
/* Show an integer value, various forms. */
-void opt_show_intval(char buf[OPT_SHOW_LEN], const int *i)
+void opt_show_intval(char *buf, size_t len, const int *i)
- snprintf(buf, OPT_SHOW_LEN, "%i", *i);
+ snprintf(buf, len, "%i", *i);
-void opt_show_uintval(char buf[OPT_SHOW_LEN], const unsigned int *ui)
+void opt_show_uintval(char *buf, size_t len, const unsigned int *ui)
- snprintf(buf, OPT_SHOW_LEN, "%u", *ui);
+ snprintf(buf, len, "%u", *ui);
-void opt_show_longval(char buf[OPT_SHOW_LEN], const long *l)
+void opt_show_longval(char *buf, size_t len, const long *l)
- snprintf(buf, OPT_SHOW_LEN, "%li", *l);
+ snprintf(buf, len, "%li", *l);
-void opt_show_ulongval(char buf[OPT_SHOW_LEN], const unsigned long *ul)
+void opt_show_ulongval(char *buf, size_t len, const unsigned long *ul)
- snprintf(buf, OPT_SHOW_LEN, "%lu", *ul);
+ snprintf(buf, len, "%lu", *ul);
}
/* a helper function that multiplies out an argument's kMGTPE suffix in the
}
/* a helper function that multiplies out an argument's kMGTPE suffix in the
are separate but essentially identical functions for signed and unsigned
values, so that unsigned values greater than LLONG_MAX get suffixes.
*/
are separate but essentially identical functions for signed and unsigned
values, so that unsigned values greater than LLONG_MAX get suffixes.
*/
-static void show_llong_with_suffix(char buf[OPT_SHOW_LEN], long long ll,
- const long long base)
+static void show_llong_with_suffix(char *buf, size_t len, long long ll,
+ const long long base)
{
const char *suffixes = "kMGTPE";
int i;
if (ll == 0){
/*zero is special because everything divides it (you'd get "0E")*/
{
const char *suffixes = "kMGTPE";
int i;
if (ll == 0){
/*zero is special because everything divides it (you'd get "0E")*/
- snprintf(buf, OPT_SHOW_LEN, "0");
+ snprintf(buf, len, "0");
return;
}
for (i = 0; i < strlen(suffixes); i++){
return;
}
for (i = 0; i < strlen(suffixes); i++){
- snprintf(buf, OPT_SHOW_LEN, "%"PRId64, (int64_t)ll);
+ snprintf(buf, len, "%"PRId64, (int64_t)ll);
- snprintf(buf, OPT_SHOW_LEN, "%"PRId64"%c", (int64_t)ll, suffixes[i - 1]);
+ snprintf(buf, len, "%"PRId64"%c", (int64_t)ll, suffixes[i - 1]);
-static void show_ullong_with_suffix(char buf[OPT_SHOW_LEN], unsigned long long ull,
+static void show_ullong_with_suffix(char *buf, size_t len,
+ unsigned long long ull,
const unsigned base)
{
const char *suffixes = "kMGTPE";
int i;
if (ull == 0){
/*zero is special because everything divides it (you'd get "0E")*/
const unsigned base)
{
const char *suffixes = "kMGTPE";
int i;
if (ull == 0){
/*zero is special because everything divides it (you'd get "0E")*/
- snprintf(buf, OPT_SHOW_LEN, "0");
+ snprintf(buf, len, "0");
return;
}
for (i = 0; i < strlen(suffixes); i++){
return;
}
for (i = 0; i < strlen(suffixes); i++){
- snprintf(buf, OPT_SHOW_LEN, "%"PRIu64, (uint64_t)ull);
+ snprintf(buf, len, "%"PRIu64, (uint64_t)ull);
- snprintf(buf, OPT_SHOW_LEN, "%"PRIu64"%c", (uint64_t)ull, suffixes[i - 1]);
+ snprintf(buf, len, "%"PRIu64"%c", (uint64_t)ull, suffixes[i - 1]);
-void opt_show_intval_bi(char buf[OPT_SHOW_LEN], const int *x)
+void opt_show_intval_bi(char *buf, size_t len, const int *x)
- show_llong_with_suffix(buf, *x, 1024);
+ show_llong_with_suffix(buf, len, *x, 1024);
-void opt_show_longval_bi(char buf[OPT_SHOW_LEN], const long *x)
+void opt_show_longval_bi(char *buf, size_t len, const long *x)
- show_llong_with_suffix(buf, *x, 1024);
+ show_llong_with_suffix(buf, len, *x, 1024);
-void opt_show_longlongval_bi(char buf[OPT_SHOW_LEN], const long long *x)
+void opt_show_longlongval_bi(char *buf, size_t len, const long long *x)
- show_llong_with_suffix(buf, *x, 1024);
+ show_llong_with_suffix(buf, len, *x, 1024);
-void opt_show_uintval_bi(char buf[OPT_SHOW_LEN], const unsigned int *x)
+void opt_show_uintval_bi(char *buf, size_t len, const unsigned int *x)
- show_ullong_with_suffix(buf, (unsigned long long) *x, 1024);
+ show_ullong_with_suffix(buf, len, (unsigned long long) *x, 1024);
-void opt_show_ulongval_bi(char buf[OPT_SHOW_LEN], const unsigned long *x)
+void opt_show_ulongval_bi(char *buf, size_t len, const unsigned long *x)
- show_ullong_with_suffix(buf, (unsigned long long) *x, 1024);
+ show_ullong_with_suffix(buf, len, (unsigned long long) *x, 1024);
-void opt_show_ulonglongval_bi(char buf[OPT_SHOW_LEN], const unsigned long long *x)
+void opt_show_ulonglongval_bi(char *buf, size_t len, const unsigned long long *x)
- show_ullong_with_suffix(buf, (unsigned long long) *x, 1024);
+ show_ullong_with_suffix(buf, len, (unsigned long long) *x, 1024);
-void opt_show_intval_si(char buf[OPT_SHOW_LEN], const int *x)
+void opt_show_intval_si(char *buf, size_t len, const int *x)
- show_llong_with_suffix(buf, (long long) *x, 1000);
+ show_llong_with_suffix(buf, len, (long long) *x, 1000);
-void opt_show_longval_si(char buf[OPT_SHOW_LEN], const long *x)
+void opt_show_longval_si(char *buf, size_t len, const long *x)
- show_llong_with_suffix(buf, (long long) *x, 1000);
+ show_llong_with_suffix(buf, len, (long long) *x, 1000);
-void opt_show_longlongval_si(char buf[OPT_SHOW_LEN], const long long *x)
+void opt_show_longlongval_si(char *buf, size_t len, const long long *x)
- show_llong_with_suffix(buf, *x, 1000);
+ show_llong_with_suffix(buf, len, *x, 1000);
-void opt_show_uintval_si(char buf[OPT_SHOW_LEN], const unsigned int *x)
+void opt_show_uintval_si(char *buf, size_t len, const unsigned int *x)
- show_ullong_with_suffix(buf, (unsigned long long) *x, 1000);
+ show_ullong_with_suffix(buf, len, (unsigned long long) *x, 1000);
-void opt_show_ulongval_si(char buf[OPT_SHOW_LEN], const unsigned long *x)
+void opt_show_ulongval_si(char *buf, size_t len, const unsigned long *x)
- show_ullong_with_suffix(buf, (unsigned long long) *x, 1000);
+ show_ullong_with_suffix(buf, len, (unsigned long long) *x, 1000);
-void opt_show_ulonglongval_si(char buf[OPT_SHOW_LEN], const unsigned long long *x)
+void opt_show_ulonglongval_si(char *buf, size_t len, const unsigned long long *x)
- show_ullong_with_suffix(buf, (unsigned long long) *x, 1000);
+ show_ullong_with_suffix(buf, len, (unsigned long long) *x, 1000);
void _opt_register(const char *names, enum opt_type type,
char *(*cb)(void *arg),
char *(*cb_arg)(const char *optarg, void *arg),
void _opt_register(const char *names, enum opt_type type,
char *(*cb)(void *arg),
char *(*cb_arg)(const char *optarg, void *arg),
- void (*show)(char buf[OPT_SHOW_LEN], const void *arg),
+ void (*show)(char *buf, size_t len, const void *arg),
const void *arg, const char *desc)
{
struct opt_table opt;
const void *arg, const char *desc)
{
struct opt_table opt;
* where "type" is the type of the @arg argument. The first argument to the
* @cb is the argument found on the commandline.
*
* where "type" is the type of the @arg argument. The first argument to the
* @cb is the argument found on the commandline.
*
- * Similarly, if @show is not NULL, it should be of type "void *show(char *,
- * const type *)". It should write up to OPT_SHOW_LEN bytes into the first
- * argument; unless it uses the entire OPT_SHOW_LEN bytes it should
- * nul-terminate that buffer.
+ * Similarly, if @show is not NULL, it should be of type "void show(char *,
+ * size_t len, const type *)". It should write up to len bytes into the first
+ * argument; unless it uses the entire len bytes it should nul-terminate that
+ * buffer.
*
* Any number of equivalent short or long options can be listed in @names,
* separated by '|'. Short options are a single hyphen followed by a single
*
* Any number of equivalent short or long options can be listed in @names,
* separated by '|'. Short options are a single hyphen followed by a single
*/
extern const char opt_hidden[];
*/
extern const char opt_hidden[];
-/* Maximum length of arg to show in opt_usage */
-#define OPT_SHOW_LEN 80
-
/* Standard helpers. You can write your own: */
/* Sets the @b to true. */
char *opt_set_bool(bool *b);
/* Sets @b based on arg: (yes/no/true/false). */
char *opt_set_bool_arg(const char *arg, bool *b);
/* Standard helpers. You can write your own: */
/* Sets the @b to true. */
char *opt_set_bool(bool *b);
/* Sets @b based on arg: (yes/no/true/false). */
char *opt_set_bool_arg(const char *arg, bool *b);
-void opt_show_bool(char buf[OPT_SHOW_LEN], const bool *b);
+void opt_show_bool(char *buf, size_t len, const bool *b);
/* The inverse */
char *opt_set_invbool(bool *b);
/* The inverse */
char *opt_set_invbool(bool *b);
-void opt_show_invbool(char buf[OPT_SHOW_LEN], const bool *b);
+void opt_show_invbool(char *buf, size_t len, const bool *b);
/* Sets @b based on !arg: (yes/no/true/false). */
char *opt_set_invbool_arg(const char *arg, bool *b);
/* Set a char *. */
char *opt_set_charp(const char *arg, char **p);
/* Sets @b based on !arg: (yes/no/true/false). */
char *opt_set_invbool_arg(const char *arg, bool *b);
/* Set a char *. */
char *opt_set_charp(const char *arg, char **p);
-void opt_show_charp(char buf[OPT_SHOW_LEN], char *const *p);
+void opt_show_charp(char *buf, size_t len, char *const *p);
/* Set an integer value, various forms. Sets to 1 on arg == NULL. */
char *opt_set_intval(const char *arg, int *i);
/* Set an integer value, various forms. Sets to 1 on arg == NULL. */
char *opt_set_intval(const char *arg, int *i);
-void opt_show_intval(char buf[OPT_SHOW_LEN], const int *i);
+void opt_show_intval(char *buf, size_t len, const int *i);
char *opt_set_uintval(const char *arg, unsigned int *ui);
char *opt_set_uintval(const char *arg, unsigned int *ui);
-void opt_show_uintval(char buf[OPT_SHOW_LEN], const unsigned int *ui);
+void opt_show_uintval(char *buf, size_t len, const unsigned int *ui);
char *opt_set_longval(const char *arg, long *l);
char *opt_set_longval(const char *arg, long *l);
-void opt_show_longval(char buf[OPT_SHOW_LEN], const long *l);
+void opt_show_longval(char *buf, size_t len, const long *l);
char *opt_set_ulongval(const char *arg, unsigned long *ul);
char *opt_set_ulongval(const char *arg, unsigned long *ul);
-void opt_show_ulongval(char buf[OPT_SHOW_LEN], const unsigned long *ul);
+void opt_show_ulongval(char *buf, size_t len, const unsigned long *ul);
/* Set an floating point value, various forms. */
char *opt_set_floatval(const char *arg, float *f);
/* Set an floating point value, various forms. */
char *opt_set_floatval(const char *arg, float *f);
-void opt_show_floatval(char buf[OPT_SHOW_LEN], const float *f);
+void opt_show_floatval(char *buf, size_t len, const float *f);
char *opt_set_doubleval(const char *arg, double *d);
char *opt_set_doubleval(const char *arg, double *d);
-void opt_show_doubleval(char buf[OPT_SHOW_LEN], const double *d);
+void opt_show_doubleval(char *buf, size_t len, const double *d);
/* the following setting functions accept k, M, G, T, P, or E suffixes, which
multiplies the numeric value by the corresponding power of 1000 or 1024
/* the following setting functions accept k, M, G, T, P, or E suffixes, which
multiplies the numeric value by the corresponding power of 1000 or 1024
char *opt_set_ulonglongval_si(const char *arg, unsigned long long *ll);
char *opt_set_ulonglongval_si(const char *arg, unsigned long long *ll);
-void opt_show_intval_bi(char buf[OPT_SHOW_LEN], const int *x);
-void opt_show_longval_bi(char buf[OPT_SHOW_LEN], const long *x);
-void opt_show_longlongval_bi(char buf[OPT_SHOW_LEN], const long long *x);
-void opt_show_uintval_bi(char buf[OPT_SHOW_LEN], const unsigned int *x);
-void opt_show_ulongval_bi(char buf[OPT_SHOW_LEN], const unsigned long *x);
-void opt_show_ulonglongval_bi(char buf[OPT_SHOW_LEN], const unsigned long long *x);
+void opt_show_intval_bi(char *buf, size_t len, const int *x);
+void opt_show_longval_bi(char *buf, size_t len, const long *x);
+void opt_show_longlongval_bi(char *buf, size_t len, const long long *x);
+void opt_show_uintval_bi(char *buf, size_t len, const unsigned int *x);
+void opt_show_ulongval_bi(char *buf, size_t len, const unsigned long *x);
+void opt_show_ulonglongval_bi(char *buf, size_t len, const unsigned long long *x);
-void opt_show_intval_si(char buf[OPT_SHOW_LEN], const int *x);
-void opt_show_longval_si(char buf[OPT_SHOW_LEN], const long *x);
-void opt_show_longlongval_si(char buf[OPT_SHOW_LEN], const long long *x);
-void opt_show_uintval_si(char buf[OPT_SHOW_LEN], const unsigned int *x);
-void opt_show_ulongval_si(char buf[OPT_SHOW_LEN], const unsigned long *x);
-void opt_show_ulonglongval_si(char buf[OPT_SHOW_LEN], const unsigned long long *x);
+void opt_show_intval_si(char *buf, size_t len, const int *x);
+void opt_show_longval_si(char *buf, size_t len, const long *x);
+void opt_show_longlongval_si(char *buf, size_t len, const long long *x);
+void opt_show_uintval_si(char *buf, size_t len, const unsigned int *x);
+void opt_show_ulongval_si(char *buf, size_t len, const unsigned long *x);
+void opt_show_ulonglongval_si(char *buf, size_t len, const unsigned long long *x);
enum opt_type type;
char *(*cb)(void *arg); /* OPT_NOARG */
char *(*cb_arg)(const char *optarg, void *arg); /* OPT_HASARG */
enum opt_type type;
char *(*cb)(void *arg); /* OPT_NOARG */
char *(*cb_arg)(const char *optarg, void *arg); /* OPT_HASARG */
- void (*show)(char buf[OPT_SHOW_LEN], const void *arg);
+ void (*show)(char *buf, size_t len, const void *arg);
union {
const void *carg;
void *arg;
union {
const void *carg;
void *arg;
char *(*)(const char *, const typeof(*(arg))*), \
char *(*)(const char *, const void *), \
(cb)), \
char *(*)(const char *, const typeof(*(arg))*), \
char *(*)(const char *, const void *), \
(cb)), \
- typesafe_cb_cast(void (*)(char buf[], const void *), \
- void (*)(char buf[], const typeof(*(arg))*), (show))
+ typesafe_cb_cast(void (*)(char *buf, size_t, const void *), \
+ void (*)(char *buf, size_t, const typeof(*(arg))*), (show))
/* Non-typesafe register function. */
void _opt_register(const char *names, enum opt_type type,
char *(*cb)(void *arg),
char *(*cb_arg)(const char *optarg, void *arg),
/* Non-typesafe register function. */
void _opt_register(const char *names, enum opt_type type,
char *(*cb)(void *arg),
char *(*cb_arg)(const char *optarg, void *arg),
- void (*show)(char buf[OPT_SHOW_LEN], const void *arg),
+ void (*show)(char *buf, size_t len, const void *arg),
const void *arg, const char *desc);
/* We use this to get typechecking for OPT_SUBTABLE */
const void *arg, const char *desc);
/* We use this to get typechecking for OPT_SUBTABLE */
#include <ccan/opt/helpers.c>
#include <ccan/opt/parse.c>
#include <ccan/opt/helpers.c>
#include <ccan/opt/parse.c>
-static void show_10(char buf[OPT_SHOW_LEN], const void *arg UNNEEDED)
+static void show_10(char *buf, size_t len, const void *arg UNNEEDED)
{
memset(buf, 'X', 10);
buf[10] = '\0';
}
{
memset(buf, 'X', 10);
buf[10] = '\0';
}
-static void show_max(char buf[OPT_SHOW_LEN], const void *arg UNNEEDED)
+static void show_max(char *buf, size_t len, const void *arg UNNEEDED)
{
memset(buf, 'X', OPT_SHOW_LEN);
}
{
memset(buf, 'X', OPT_SHOW_LEN);
}
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = -77;
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = -77;
- opt_show_intval_bi(buf, &i);
+ opt_show_intval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "-77") == 0);
i = 0;
ok1(strcmp(buf, "-77") == 0);
i = 0;
- opt_show_intval_bi(buf, &i);
+ opt_show_intval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "0") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 77;
ok1(strcmp(buf, "0") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 77;
- opt_show_intval_bi(buf, &i);
+ opt_show_intval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = -1234 * k;
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = -1234 * k;
- opt_show_intval_bi(buf, &i);
+ opt_show_intval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "-1234k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
ok1(strcmp(buf, "-1234k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
- opt_show_intval_bi(buf, &i);
+ opt_show_intval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * M;
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * M;
- opt_show_intval_bi(buf, &i);
+ opt_show_intval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = -77;
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = -77;
- opt_show_longval_bi(buf, &i);
+ opt_show_longval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "-77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 77;
ok1(strcmp(buf, "-77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 77;
- opt_show_longval_bi(buf, &i);
+ opt_show_longval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = -1 * k;
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = -1 * k;
- opt_show_longval_bi(buf, &i);
+ opt_show_longval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "-1k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
ok1(strcmp(buf, "-1k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
- opt_show_longval_bi(buf, &i);
+ opt_show_longval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * M;
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * M;
- opt_show_longval_bi(buf, &i);
+ opt_show_longval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 0;
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 0;
- opt_show_longval_bi(buf, &i);
+ opt_show_longval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "0") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "0") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = -7777;
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = -7777;
- opt_show_longlongval_bi(buf, &i);
+ opt_show_longlongval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "-7777") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 7777;
ok1(strcmp(buf, "-7777") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 7777;
- opt_show_longlongval_bi(buf, &i);
+ opt_show_longlongval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "7777") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = -10240000 * k;
ok1(strcmp(buf, "7777") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = -10240000 * k;
- opt_show_longlongval_bi(buf, &i);
+ opt_show_longlongval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "-10000M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 5 * P;
ok1(strcmp(buf, "-10000M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 5 * P;
- opt_show_longlongval_bi(buf, &i);
+ opt_show_longlongval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "5P") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * P;
ok1(strcmp(buf, "5P") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * P;
- opt_show_longlongval_bi(buf, &i);
+ opt_show_longlongval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "1E") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "1E") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = 77;
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = 77;
- opt_show_uintval_bi(buf, &i);
+ opt_show_uintval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1234 * k;
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1234 * k;
- opt_show_uintval_bi(buf, &i);
+ opt_show_uintval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "1234k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
ok1(strcmp(buf, "1234k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
- opt_show_uintval_bi(buf, &i);
+ opt_show_uintval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * M;
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * M;
- opt_show_uintval_bi(buf, &i);
+ opt_show_uintval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = 77;
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = 77;
- opt_show_ulongval_bi(buf, &i);
+ opt_show_ulongval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = k;
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = k;
- opt_show_ulongval_bi(buf, &i);
+ opt_show_ulongval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "1k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
ok1(strcmp(buf, "1k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
- opt_show_ulongval_bi(buf, &i);
+ opt_show_ulongval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * M;
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * M;
- opt_show_ulongval_bi(buf, &i);
+ opt_show_ulongval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 0;
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 0;
- opt_show_ulongval_bi(buf, &i);
+ opt_show_ulongval_bi(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "0") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "0") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = 7777;
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = 7777;
- opt_show_ulonglongval_bi(buf, (unsigned long long *)&i);
+ opt_show_ulonglongval_bi(buf, OPT_SHOW_LEN, (unsigned long long *)&i);
ok1(strcmp(buf, "7777") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 10240000 * k;
ok1(strcmp(buf, "7777") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 10240000 * k;
- opt_show_ulonglongval_bi(buf, (unsigned long long *)&i);
+ opt_show_ulonglongval_bi(buf, OPT_SHOW_LEN, (unsigned long long *)&i);
ok1(strcmp(buf, "10000M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 5 * P;
ok1(strcmp(buf, "10000M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 5 * P;
- opt_show_ulonglongval_bi(buf, (unsigned long long *)&i);
+ opt_show_ulonglongval_bi(buf, OPT_SHOW_LEN, (unsigned long long *)&i);
ok1(strcmp(buf, "5P") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * P;
ok1(strcmp(buf, "5P") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * P;
- opt_show_ulonglongval_bi(buf, (unsigned long long *)&i);
+ opt_show_ulonglongval_bi(buf, OPT_SHOW_LEN, (unsigned long long *)&i);
ok1(strcmp(buf, "1E") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "1E") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = -77;
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = -77;
- opt_show_intval_si(buf, &i);
+ opt_show_intval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "-77") == 0);
i = 0;
ok1(strcmp(buf, "-77") == 0);
i = 0;
- opt_show_intval_si(buf, &i);
+ opt_show_intval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "0") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 77;
ok1(strcmp(buf, "0") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 77;
- opt_show_intval_si(buf, &i);
+ opt_show_intval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = -1234 * k;
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = -1234 * k;
- opt_show_intval_si(buf, &i);
+ opt_show_intval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "-1234k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
ok1(strcmp(buf, "-1234k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
- opt_show_intval_si(buf, &i);
+ opt_show_intval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1000 * M;
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1000 * M;
- opt_show_intval_si(buf, &i);
+ opt_show_intval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = -77;
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = -77;
- opt_show_longval_si(buf, &i);
+ opt_show_longval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "-77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 77;
ok1(strcmp(buf, "-77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 77;
- opt_show_longval_si(buf, &i);
+ opt_show_longval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = -1 * k;
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = -1 * k;
- opt_show_longval_si(buf, &i);
+ opt_show_longval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "-1k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
ok1(strcmp(buf, "-1k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
- opt_show_longval_si(buf, &i);
+ opt_show_longval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1000 * M;
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1000 * M;
- opt_show_longval_si(buf, &i);
+ opt_show_longval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 0;
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 0;
- opt_show_longval_si(buf, &i);
+ opt_show_longval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "0") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "0") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = -7777;
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = -7777;
- opt_show_longlongval_si(buf, &i);
+ opt_show_longlongval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "-7777") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 7777;
ok1(strcmp(buf, "-7777") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 7777;
- opt_show_longlongval_si(buf, &i);
+ opt_show_longlongval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "7777") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = -10240000 * k;
ok1(strcmp(buf, "7777") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = -10240000 * k;
- opt_show_longlongval_si(buf, &i);
+ opt_show_longlongval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "-10240M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 5 * P;
ok1(strcmp(buf, "-10240M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 5 * P;
- opt_show_longlongval_si(buf, &i);
+ opt_show_longlongval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "5P") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 2000 * P;
ok1(strcmp(buf, "5P") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 2000 * P;
- opt_show_longlongval_si(buf, &i);
+ opt_show_longlongval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "2E") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "2E") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = 77;
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = 77;
- opt_show_uintval_si(buf, &i);
+ opt_show_uintval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1234 * k;
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1234 * k;
- opt_show_uintval_si(buf, &i);
+ opt_show_uintval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "1234k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
ok1(strcmp(buf, "1234k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
- opt_show_uintval_si(buf, &i);
+ opt_show_uintval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1000 * M;
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1000 * M;
- opt_show_uintval_si(buf, &i);
+ opt_show_uintval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "1G") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = 77;
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = 77;
- opt_show_ulongval_si(buf, &i);
+ opt_show_ulongval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = k;
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = k;
- opt_show_ulongval_si(buf, &i);
+ opt_show_ulongval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "1k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
ok1(strcmp(buf, "1k") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 500 * M;
- opt_show_ulongval_si(buf, &i);
+ opt_show_ulongval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * M;
ok1(strcmp(buf, "500M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1024 * M;
- opt_show_ulongval_si(buf, &i);
+ opt_show_ulongval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "1024M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 0;
ok1(strcmp(buf, "1024M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 0;
- opt_show_ulongval_si(buf, &i);
+ opt_show_ulongval_si(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "0") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "0") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = 7777;
char buf[OPT_SHOW_LEN+2] = { 0 };
buf[OPT_SHOW_LEN] = '!';
i = 7777;
- opt_show_ulonglongval_si(buf, (unsigned long long *)&i);
+ opt_show_ulonglongval_si(buf, OPT_SHOW_LEN, (unsigned long long *)&i);
ok1(strcmp(buf, "7777") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 10240000 * k;
ok1(strcmp(buf, "7777") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 10240000 * k;
- opt_show_ulonglongval_si(buf, (unsigned long long *)&i);
+ opt_show_ulonglongval_si(buf, OPT_SHOW_LEN, (unsigned long long *)&i);
ok1(strcmp(buf, "10240M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 5 * P;
ok1(strcmp(buf, "10240M") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 5 * P;
- opt_show_ulonglongval_si(buf, (unsigned long long *)&i);
+ opt_show_ulonglongval_si(buf, OPT_SHOW_LEN, (unsigned long long *)&i);
ok1(strcmp(buf, "5P") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1000 * P;
ok1(strcmp(buf, "5P") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 1000 * P;
- opt_show_ulonglongval_si(buf, (unsigned long long *)&i);
+ opt_show_ulonglongval_si(buf, OPT_SHOW_LEN, (unsigned long long *)&i);
ok1(strcmp(buf, "1E") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "1E") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
buf[OPT_SHOW_LEN] = '!';
b = true;
buf[OPT_SHOW_LEN] = '!';
b = true;
- opt_show_bool(buf, &b);
+ opt_show_bool(buf, OPT_SHOW_LEN, &b);
ok1(strcmp(buf, "true") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
b = false;
ok1(strcmp(buf, "true") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
b = false;
- opt_show_bool(buf, &b);
+ opt_show_bool(buf, OPT_SHOW_LEN, &b);
ok1(strcmp(buf, "false") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "false") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
buf[OPT_SHOW_LEN] = '!';
b = true;
buf[OPT_SHOW_LEN] = '!';
b = true;
- opt_show_invbool(buf, &b);
+ opt_show_invbool(buf, OPT_SHOW_LEN, &b);
ok1(strcmp(buf, "false") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
b = false;
ok1(strcmp(buf, "false") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
b = false;
- opt_show_invbool(buf, &b);
+ opt_show_invbool(buf, OPT_SHOW_LEN, &b);
ok1(strcmp(buf, "true") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "true") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
/* Short test. */
p = str;
strcpy(p, "short");
/* Short test. */
p = str;
strcpy(p, "short");
- opt_show_charp(buf, &p);
+ opt_show_charp(buf, OPT_SHOW_LEN, &p);
ok1(strcmp(buf, "\"short\"") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
/* Truncate test. */
memset(p, 'x', OPT_SHOW_LEN*2);
p[OPT_SHOW_LEN*2-1] = '\0';
ok1(strcmp(buf, "\"short\"") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
/* Truncate test. */
memset(p, 'x', OPT_SHOW_LEN*2);
p[OPT_SHOW_LEN*2-1] = '\0';
- opt_show_charp(buf, &p);
+ opt_show_charp(buf, OPT_SHOW_LEN, &p);
ok1(buf[0] == '"');
ok1(buf[OPT_SHOW_LEN-1] == '"');
ok1(buf[OPT_SHOW_LEN] == '!');
ok1(buf[0] == '"');
ok1(buf[OPT_SHOW_LEN-1] == '"');
ok1(buf[OPT_SHOW_LEN] == '!');
buf[OPT_SHOW_LEN] = '!';
i = -77;
buf[OPT_SHOW_LEN] = '!';
i = -77;
- opt_show_intval(buf, &i);
+ opt_show_intval(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "-77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 77;
ok1(strcmp(buf, "-77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
i = 77;
- opt_show_intval(buf, &i);
+ opt_show_intval(buf, OPT_SHOW_LEN, &i);
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "77") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
buf[OPT_SHOW_LEN] = '!';
ui = 4294967295U;
buf[OPT_SHOW_LEN] = '!';
ui = 4294967295U;
- opt_show_uintval(buf, &ui);
+ opt_show_uintval(buf, OPT_SHOW_LEN, &ui);
ok1(strcmp(buf, "4294967295") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "4294967295") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
buf[OPT_SHOW_LEN] = '!';
l = 1234567890L;
buf[OPT_SHOW_LEN] = '!';
l = 1234567890L;
- opt_show_longval(buf, &l);
+ opt_show_longval(buf, OPT_SHOW_LEN, &l);
ok1(strcmp(buf, "1234567890") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "1234567890") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
buf[OPT_SHOW_LEN] = '!';
ul = 4294967295UL;
buf[OPT_SHOW_LEN] = '!';
ul = 4294967295UL;
- opt_show_ulongval(buf, &ul);
+ opt_show_ulongval(buf, OPT_SHOW_LEN, &ul);
ok1(strcmp(buf, "4294967295") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "4294967295") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
buf[OPT_SHOW_LEN] = '!';
f = -77.5;
buf[OPT_SHOW_LEN] = '!';
f = -77.5;
- opt_show_floatval(buf, &f);
+ opt_show_floatval(buf, OPT_SHOW_LEN, &f);
ok1(strcmp(buf, "-77.500000") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
f = 77.5;
ok1(strcmp(buf, "-77.500000") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
f = 77.5;
- opt_show_floatval(buf, &f);
+ opt_show_floatval(buf, OPT_SHOW_LEN, &f);
ok1(strcmp(buf, "77.500000") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "77.500000") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
buf[OPT_SHOW_LEN] = '!';
d = -77;
buf[OPT_SHOW_LEN] = '!';
d = -77;
- opt_show_doubleval(buf, &d);
+ opt_show_doubleval(buf, OPT_SHOW_LEN, &d);
ok1(strcmp(buf, "-77.000000") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
d = 77;
ok1(strcmp(buf, "-77.000000") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
d = 77;
- opt_show_doubleval(buf, &d);
+ opt_show_doubleval(buf, OPT_SHOW_LEN, &d);
ok1(strcmp(buf, "77.000000") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
ok1(strcmp(buf, "77.000000") == 0);
ok1(buf[OPT_SHOW_LEN] == '!');
}
-void show_arg(char buf[OPT_SHOW_LEN], const char *arg)
+void show_arg(char *buf, size_t len, const char *arg)
- strncpy(buf, arg, OPT_SHOW_LEN);
+ strncpy(buf, arg, len);
}
char *err_output = NULL;
}
char *err_output = NULL;
extern unsigned int test_cb_called;
char *test_noarg(void *arg);
char *test_arg(const char *optarg, const char *arg);
extern unsigned int test_cb_called;
char *test_noarg(void *arg);
char *test_arg(const char *optarg, const char *arg);
-void show_arg(char buf[OPT_SHOW_LEN], const char *arg);
+void show_arg(char *buf, size_t len, const char *arg);
extern struct opt_table short_table[];
extern struct opt_table long_table[];
extern struct opt_table short_table[];
extern struct opt_table long_table[];
#define MIN_DESC_WIDTH 40
#define MIN_TOTAL_WIDTH 50
#define MIN_DESC_WIDTH 40
#define MIN_TOTAL_WIDTH 50
+/* Maximum length of arg to show in opt_usage */
+#define OPT_SHOW_LEN 80
+
static unsigned int get_columns(void)
{
int ws_col = 0;
static unsigned int get_columns(void)
{
int ws_col = 0;
if (opt->show) {
char buf[OPT_SHOW_LEN + sizeof("...")];
strcpy(buf + OPT_SHOW_LEN, "...");
if (opt->show) {
char buf[OPT_SHOW_LEN + sizeof("...")];
strcpy(buf + OPT_SHOW_LEN, "...");
- opt->show(buf, opt->u.arg);
+ opt->show(buf, OPT_SHOW_LEN, opt->u.arg);
/* If it doesn't fit on this line, indent. */
if (off + strlen(" (default: ") + strlen(buf) + strlen(")")
/* If it doesn't fit on this line, indent. */
if (off + strlen(" (default: ") + strlen(buf) + strlen(")")