[ PATCH ] fix for unlog.c
Love
lha at stacken.kth.se
Tue Oct 19 03:15:43 CEST 1999
Chris Wing <wingc at engin.umich.edu> writes:
> Until getarg() supports multiple parameter strings for a single argument,
> can we revert the changes as in this patch:
Can you try this patch and see if it does what you want ?
Love
Index: lib/roken/getarg.c
===================================================================
RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/lib/roken/getarg.c,v
retrieving revision 1.16
diff -u -w -r1.16 getarg.c
--- lib/roken/getarg.c 1999/10/05 22:46:49 1.16
+++ lib/roken/getarg.c 1999/10/19 01:00:43
@@ -261,7 +261,8 @@
}
static int
-parse_option(struct getargs *arg, char *optarg, int negate)
+parse_option(struct getargs *arg, int style, char *optarg, char **argv,
+ int *next, int negate)
{
switch(arg->type){
case arg_integer:
@@ -280,6 +281,13 @@
case arg_strings:
{
add_string((getarg_strings*)arg->value, optarg);
+ while ((style & ARG_TRANSLONG)
+ && argv[*next + 1]
+ && argv[*next + 1][0] != '-')
+ {
+ add_string ((getarg_strings*)arg->value, argv[*next + 1]);
+ (*next)++;
+ }
return 0;
}
case arg_flag:
@@ -395,7 +403,7 @@
if(*optarg == '\0' && !ISFLAG(current))
return ARG_ERR_NO_MATCH;
- return parse_option(current, optarg, negate);
+ return parse_option(current, style, optarg, argv, next, negate);
}
int
@@ -413,7 +421,9 @@
if(argv[i][0] != '-' && swcount != -1) {
if (!(style & ARG_SWITCHLESS))
break;
- ret = parse_option(&args[swcount], argv[i], 0);
+ j = 1;
+ ret = parse_option(&args[swcount], style, argv[i],
+ &argv[i], &j, 0);
if (ret) {
*optind = i;
return ret;
Index: appl/afsutils/unlog.c
===================================================================
RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/appl/afsutils/unlog.c,v
retrieving revision 1.2
diff -u -w -r1.2 unlog.c
--- appl/afsutils/unlog.c 1999/08/22 16:44:15 1.2
+++ appl/afsutils/unlog.c 1999/10/19 01:05:28
@@ -70,7 +70,7 @@
static int unlog_version = 0;
static int unlog_help = 0;
-static char *unlog_cells = NULL;
+static getarg_strings unlog_cells;
/*
* Various helper functions that we call
@@ -162,12 +162,14 @@
*/
struct getargs args[] = {
- { "cell", 0, arg_string, &unlog_cells, "only remove tokens for this cell",
+ { "cell", 0, arg_strings, &unlog_cells,
+ "only remove tokens for this cell",
"cell", arg_optional},
{ "help", 0, arg_flag, &unlog_help, "help",
NULL, arg_optional},
{ "version", 0, arg_flag, &unlog_version, "print version",
- NULL, arg_optional}
+ NULL, arg_optional},
+ { NULL, 0, arg_end, NULL, NULL }
};
/*
@@ -188,7 +190,7 @@
int
main(int argc, char **argv)
{
- int i, optind = 0;
+ int i, j, optind = 0;
if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE))
do_help(1);
@@ -203,7 +205,7 @@
errx (1, "You don't seem to have AFS running");
/* Save tokens if need be */
- if(unlog_cells) {
+ if(unlog_cells.num_strings) {
char *cell;
struct token *save;
int token_overflow = 0;
@@ -230,12 +232,14 @@
lost_tokens = 1;
}
- if (strcmp (unlog_cells, cell) == 0)
+ for (j = 0 ; j < unlog_cells.num_strings; j++)
+ if (strcmp (unlog_cells.strings[j], cell) == 0)
keep_this_token = 0;
if(keep_this_token) {
numtokens++;
save++;
+ save_tokens = 1;
}
if(numtokens == MAX_TOKENS) {
More information about the Arla-drinkers
mailing list