X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Foptions.c;h=c91e7f0010dae310f37a5b443571c51550754f98;hp=a08b184d34b5dcc31f91eca7908bcdf102dfbece;hb=95d8bd04e10519a635972a24176270ef4dbe8d2c;hpb=4c176312acdc3444c9afc820f76a393e64668e52 diff --git a/src/options.c b/src/options.c index a08b184..c91e7f0 100644 --- a/src/options.c +++ b/src/options.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, 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.4 2005-06-25 15:46:04 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 + */ +