diff options
Diffstat (limited to 'crypto/heimdal/lib/roken/getarg.c')
-rw-r--r-- | crypto/heimdal/lib/roken/getarg.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/crypto/heimdal/lib/roken/getarg.c b/crypto/heimdal/lib/roken/getarg.c index 342388e..dc2df50 100644 --- a/crypto/heimdal/lib/roken/getarg.c +++ b/crypto/heimdal/lib/roken/getarg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: getarg.c,v 1.37 2000/12/25 17:03:15 assar Exp $"); +RCSID("$Id: getarg.c,v 1.40 2001/04/25 12:06:10 assar Exp $"); #endif #include <stdio.h> @@ -211,7 +211,7 @@ arg_printusage (struct getargs *args, struct winsize ws; if (progname == NULL) - progname = __progname; + progname = getprogname(); if(getenv("GETARGMANDOC")){ mandoc_template(args, num_args, progname, extra_string); @@ -223,6 +223,23 @@ arg_printusage (struct getargs *args, columns = 80; col = 0; col += fprintf (stderr, "Usage: %s", progname); + buf[0] = '\0'; + for (i = 0; i < num_args; ++i) { + if(args[i].short_name && ISFLAG(args[i])) { + char s[2]; + if(buf[0] == '\0') + strlcpy(buf, "[-", sizeof(buf)); + s[0] = args[i].short_name; + s[1] = '\0'; + strlcat(buf, s, sizeof(buf)); + } + } + if(buf[0] != '\0') { + strlcat(buf, "]", sizeof(buf)); + col = check_column(stderr, col, strlen(buf) + 1, columns); + col += fprintf(stderr, " %s", buf); + } + for (i = 0; i < num_args; ++i) { size_t len = 0; @@ -244,7 +261,7 @@ arg_printusage (struct getargs *args, col = check_column(stderr, col, strlen(buf) + 1, columns); col += fprintf(stderr, " %s", buf); } - if (args[i].short_name) { + if (args[i].short_name && !ISFLAG(args[i])) { snprintf(buf, sizeof(buf), "[-%c", args[i].short_name); len += 2; len += print_arg(buf + strlen(buf), sizeof(buf) - strlen(buf), @@ -528,6 +545,12 @@ getarg(struct getargs *args, size_t num_args, return ret; } +void +free_getarg_strings (getarg_strings *s) +{ + free (s->strings); +} + #if TEST int foo_flag = 2; int flag1 = 0; |