X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Foptions.c;h=47dd4337e57382bef58cf8a6663d0e23aa76d129;hp=a08b184d34b5dcc31f91eca7908bcdf102dfbece;hb=4f8ea8cfaf2f3d95e4efcf9494526c2b4be43eb8;hpb=4c176312acdc3444c9afc820f76a393e64668e52 diff --git a/src/options.c b/src/options.c index a08b184..47dd433 100644 --- a/src/options.c +++ b/src/options.c @@ -1,8 +1,8 @@ /* - * Copyright (C) 1995-2005, Index Data ApS + * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: options.c,v 1.3 2005-01-15 19:47:14 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 + */ +