Skip to content

Commit

Permalink
Fixed a multiple identical option bug uncovered by Chris Lamb
Browse files Browse the repository at this point in the history
  • Loading branch information
fbb-git committed Apr 30, 2016
1 parent dab1b18 commit 58a4d85
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sourcetar
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
PROJECT=yodl

(cd yodl; ./build clean)
cd ~/git/yodl/src

if [ -e /usr/share/common-licenses/GPL ] ; then
cp /usr/share/common-licenses/GPL ${PROJECT}/LICENSE
Expand Down
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.07.01"
#define VERSION "3.08.00"
#define YEARS "1996-2016"
15 changes: 15 additions & 0 deletions yodl/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
yodl (3.08.00)

* Fixed a bug in handling multiply options of identical types (e.g., -D,
-D). The bug was hidden in args/argsmultiargs.c but sheer accidentally has
never shown itself. Now fixed.

* The usage info now also shows the std. copyright notice, writes its
information to the std. output stream, and returns 0 to the operating
system.

* Fixed an XXfigurecounter increment occurring too early in the figure.raw
macro.

-- Frank B. Brokken <f.b.brokken@rug.nl> Sat, 30 Apr 2016 18:22:23 +0530

yodl (3.07.01)

* Hanno B\"ock reported an invalid memory read found by the address sanitizer
Expand Down
2 changes: 1 addition & 1 deletion yodl/man/yodlconverters.in
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ manpagefiles()

Each bf(yodl2)em(format) converter requires a file em(format.yo) in Yodl's
include path (e.g., tt(@STD_INCLUDE@)). This file is auto-loaded before
tt(FILE) (see the synopsys) is loaded, to make the conversion to
tt(FILE) (see the synopsis) is loaded, to make the conversion to
em(format) possible.

The output is written to one or more files having the extension
Expand Down
18 changes: 14 additions & 4 deletions yodl/src/args/argsmultiarg.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
#include "args.ih"

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

// The full string is a string containing all the single-letter options that
// were specified. E.g., DDvD if -D -D -v -D was specified. When called with a
// non-0 argument str and searchStr are (re)initialized to the beginning of
// the string. Then, and at each subsequent call using a zero-arg the saved
// opchar is searched from where searchStr points. Following this search
// searchStr is incremented, unless it points to the option string's 0-byte
// The location of the optchar in str is then used as index in the array of
// args.d_optarg, returning the associated value.

char const *args_multiarg(int optchar)
{
register char const *pos;

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

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

if (pos)
{
size_t idx = pos - str;
str = pos + 1;
return args.d_optarg[idx]; /* return optionstr. */
}

Expand Down
6 changes: 3 additions & 3 deletions yodl/src/yodl/usage.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@

void usage()
{
fprintf (stderr, "%s%s%s%s%d%s%d%s",
printf("%s%s%s%s%d%s%d%s",
message_version(),
"\n"
"Your Own Document Language\n"
"Copyright (c) GPL " YEARS ". NO WARRANTY.\n"
"\n"
"Usage: yodl [OPTION]... [FILE]...\n"
"Convert to various documentation formats from FILE or <stdin>.\n"
Expand Down Expand Up @@ -62,8 +63,7 @@ void usage()
" -w, --warn warn about no-macro calls\n"
"\n");


exit (1);
exit(0);
}


Expand Down

0 comments on commit 58a4d85

Please sign in to comment.