Skip to content

Commit

Permalink
re-implemented multiple options handling in src/args/argsmultiarg.c
Browse files Browse the repository at this point in the history
  • Loading branch information
fbb-git committed May 7, 2016
1 parent 58a4d85 commit 547a648
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion yodl/VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#define VERSION "3.08.00"
#define VERSION "3.08.01"
#define YEARS "1996-2016"
9 changes: 9 additions & 0 deletions yodl/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
yodl (3.08.01)

* The multiple options handling bug emerged in another context (zsh
documentation, reported by Axel Beckert). The option handling
implementation required some additional fine-tuning: realized in this
release.

-- Frank B. Brokken <f.b.brokken@rug.nl> Sat, 07 May 2016 20:59:50 +0530

yodl (3.08.00)

* Fixed a bug in handling multiply options of identical types (e.g., -D,
Expand Down
25 changes: 14 additions & 11 deletions yodl/src/args/argsmultiarg.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "args.ih"

static char const *str;
static char const *searchStr;
static char *str;
static int option;

// The full string is a string containing all the single-letter options that
Expand All @@ -15,22 +14,26 @@ static int option;

char const *args_multiarg(int optchar)
{
if (optchar) /* new option: */
if (optchar) // new option:
{
str = string_str(&args.d_option); /* use full string */
searchStr = str;
option = optchar; /* save the option char */
if (!str)
str = (char *)string_str(&args.d_option); // use full string

option = optchar; // save the option char
}

register char const *pos = strchr(searchStr, option);
if (*searchStr != 0) // shift to the next ch.*/
++searchStr;
register char *pos = strchr(str, option);

if (pos)
{
size_t idx = pos - str;
return args.d_optarg[idx]; /* return optionstr. */
*pos = ' '; // this option has now
// been processed.

return args.d_optarg[idx]; // return optionstr.
}

return PFAILED; /* or return PFAILED */
return PFAILED; // or return PFAILED
// in which case there was
// no option argument
}

0 comments on commit 547a648

Please sign in to comment.