Skip to content

Commit

Permalink
[docopt_c.py] Improve bool; [test/docopt{.h,.c}] Regenerate
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelMarks committed Aug 18, 2021
1 parent 9921c63 commit 4b4fa48
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
18 changes: 11 additions & 7 deletions docopt_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
#include <stdbool.h>
#else
#elif !defined(_STDBOOL_H)
#define _STDBOOL_H
#include <stdlib.h>
#ifdef true
#undef true
Expand All @@ -62,8 +65,8 @@
#endif
#define true 1
#define false !true
typedef int bool;
#define false (!true)
typedef size_t bool;
#endif
Expand Down Expand Up @@ -389,7 +392,6 @@
usage_pattern,
$help_message
};
struct Tokens ts;
struct Command commands[] = {$elems_cmds
};
struct Argument arguments[] = {$elems_args
Expand All @@ -412,9 +414,11 @@
return_code = EXIT_FAILURE;
}
ts = tokens_new(argc, argv);
if (parse_args(&ts, &elements))
exit(EXIT_FAILURE);
{
struct Tokens ts = tokens_new(argc, argv);
if (parse_args(&ts, &elements))
exit(EXIT_FAILURE);
}
if (elems_to_args(&elements, &args, help, version))
exit(return_code);
return args;
Expand Down
9 changes: 5 additions & 4 deletions test/docopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ struct DocoptArgs docopt(int argc, char *argv[], const bool help, const char *ve
" --drifting Drifting mine.",
""}
};
struct Tokens ts;
struct Command commands[] = {
{"create", 0},
{"mine", 0},
Expand Down Expand Up @@ -362,9 +361,11 @@ struct DocoptArgs docopt(int argc, char *argv[], const bool help, const char *ve
return_code = EXIT_FAILURE;
}

ts = tokens_new(argc, argv);
if (parse_args(&ts, &elements))
exit(EXIT_FAILURE);
{
struct Tokens ts = tokens_new(argc, argv);
if (parse_args(&ts, &elements))
exit(EXIT_FAILURE);
}
if (elems_to_args(&elements, &args, help, version))
exit(return_code);
return args;
Expand Down
12 changes: 7 additions & 5 deletions test/docopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

#include <stdbool.h>

#else
#elif !defined(_STDBOOL_H)
#define _STDBOOL_H

#include <stdlib.h>

#ifdef true
#undef true
Expand All @@ -20,8 +23,8 @@
#endif

#define true 1
#define false !true
typedef int bool;
#define false (!true)
typedef size_t bool;

#endif

Expand Down Expand Up @@ -55,8 +58,7 @@ typedef int bool;

#endif

#elif (defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) \
|| defined(__DragonFly__) || defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))
#elif (defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))

#include <sys/param.h>

Expand Down

0 comments on commit 4b4fa48

Please sign in to comment.