[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[help-gengetopt] Patch for gengetopt_strlen()
From: |
Brian Minard |
Subject: |
[help-gengetopt] Patch for gengetopt_strlen() |
Date: |
Mon, 12 Nov 2001 20:49:29 -0500 |
Hi,
I think that gengetopt_strlen() can be removed. The only reason I can
see for keeping this function is to replace strlen(). If this is the
plan then a replacement function should be provided instead (as was
done for strdup()).
I was hard pressed to design a meaningful test for this patch. I did
run the checks and diff the old and new test results. Everything
looked ok.
Thanks,
Brian
---
* gengetopt_strlen(): replaced with strlen(). Redeclare all variables
set by calls to strlen() as size_t.
*** gm.c Sun Jun 24 08:27:16 2001
--- gm.c Sat Nov 10 21:54:05 2001
*************** static void generate_error_handle();
*** 50,63 ****
static char *parser_function_name;
- long
- gengetopt_strlen (char *s)
- {
- char * p = s;
- while (*p) p++;
- return p - s;
- }
-
char *
create_filename (char *name, char *ext)
{
--- 50,55 ----
*************** generate_cmdline_parser (char *function_
*** 169,175 ****
int no_handle_version,
int no_handle_error, char **comment)
{
! long max_long, max_short, w;
struct gengetopt_option * opt;
char *comment_string ;
int i ;
--- 161,167 ----
int no_handle_version,
int no_handle_error, char **comment)
{
! size_t max_long, max_short, w;
struct gengetopt_option * opt;
char *comment_string ;
int i ;
*************** header_filename);
*** 490,496 ****
/* calculate columns */
max_long = max_short = 0;
foropt {
! w = 3 + gengetopt_strlen (opt->long_opt);
if (opt->type == ARG_FLAG || opt->type == ARG_NO)
{
if (w > max_long) max_long = w;
--- 482,488 ----
/* calculate columns */
max_long = max_short = 0;
foropt {
! w = 3 + strlen (opt->long_opt);
if (opt->type == ARG_FLAG || opt->type == ARG_NO)
{
if (w > max_long) max_long = w;
*************** header_filename);
*** 498,506 ****
}
else
{
! w += gengetopt_strlen (arg_names[opt->type]);
if (w > max_long) max_long = w;
! w = (3 + gengetopt_strlen (arg_names[opt->type]));
if (w > max_short) max_short = w;
}
}
--- 490,498 ----
}
else
{
! w += strlen (arg_names[opt->type]);
if (w > max_long) max_long = w;
! w = (3 + strlen (arg_names[opt->type]));
if (w > max_short) max_short = w;
}
}
*************** header_filename);
*** 512,518 ****
else printf (" ");
for (w = 2; w < max_short; w++) printf (" ");
printf (" --%s", opt->long_opt);
! for (w = 2+gengetopt_strlen(opt->long_opt); w < max_long; w++)
printf (" ");
printf (" %s", opt->desc);
if (opt->type == ARG_FLAG)
--- 504,510 ----
else printf (" ");
for (w = 2; w < max_short; w++) printf (" ");
printf (" --%s", opt->long_opt);
! for (w = 2+strlen (opt->long_opt); w < max_long; w++)
printf (" ");
printf (" %s", opt->desc);
if (opt->type == ARG_FLAG)
*************** header_filename);
*** 530,545 ****
printf (" -%c%s", opt->short_opt, arg_names[opt->type]);
else
{
! int type_len = gengetopt_strlen(arg_names[opt->type]);
printf (" ");
for (w = 1; w < type_len; w++) printf (" ");
}
! for (w = 2+gengetopt_strlen(arg_names[opt->type]); w <
max_short; w++)
printf (" ");
printf (" --%s=%s", opt->long_opt, arg_names[opt->type]);
! for (w = 3+gengetopt_strlen(opt->long_opt)+
! gengetopt_strlen(arg_names[opt->type]); w < max_long; w++)
printf (" ");
printf (" %s\\n\\\n", opt->desc);
}
--- 522,537 ----
printf (" -%c%s", opt->short_opt, arg_names[opt->type]);
else
{
! size_t type_len = strlen (arg_names[opt->type]);
printf (" ");
for (w = 1; w < type_len; w++) printf (" ");
}
! for (w = 2+strlen (arg_names[opt->type]); w < max_short; w++)
printf (" ");
printf (" --%s=%s", opt->long_opt, arg_names[opt->type]);
! for (w = 3+strlen (opt->long_opt)+
! strlen (arg_names[opt->type]); w < max_long; w++)
printf (" ");
printf (" %s\\n\\\n", opt->desc);
}
- [help-gengetopt] Patch for gengetopt_strlen(),
Brian Minard <=