X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Foptions.c;h=47dd4337e57382bef58cf8a6663d0e23aa76d129;hp=4f86d83e51b9c5393012de8d2eb4d87af9f9a93d;hb=cf30376bd9e43ad653c6292f275ee4dd10b70a6c;hpb=05c274ef315384faafcc5900c17468f0ea2474e6 diff --git a/src/options.c b/src/options.c index 4f86d83..47dd433 100644 --- a/src/options.c +++ b/src/options.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 1995-2004, Index Data + * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: options.c,v 1.2 2004-10-15 00:19:00 adam Exp $ + * $Id: options.c,v 1.5 2007-01-03 08:42:15 adam Exp $ */ /** * \file options.c @@ -46,44 +46,52 @@ int options (const char *desc, char **argv, int argc, char **arg) int desc_char = desc[i++]; int type = 0; if (desc[i] == ':') - { /* string argument */ + { /* string argument */ type = desc[i++]; - } + } if (desc_char == ch) - { /* option with argument */ + { /* option with argument */ if (type) - { + { if (argv[arg_no][arg_off]) - { + { *arg = argv[arg_no]+arg_off; arg_no++; arg_off = 0; - } + } else - { + { arg_no++; arg_off = 0; if (arg_no < argc) *arg = argv[arg_no++]; else *arg = ""; - } - } + } + } else /* option with no argument */ - { + { if (argv[arg_no][arg_off]) arg_off++; else - { + { arg_off = 0; arg_no++; - } - } + } + } return ch; - } + } } *arg = argv[arg_no]+arg_off-1; arg_no = arg_no + 1; arg_off = 0; return -1; } +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +