aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkatherine <shmibs@shmibbles.me>2018-03-21 23:15:58 -0700
committerkatherine <shmibs@shmibbles.me>2018-03-21 23:15:58 -0700
commit9e843b2dda247b5e61d168a77bf93afa3f0e78db (patch)
tree75bf47fc044e4ca7efd85687eaba4d5882e5ef21
parentd2043c1d4cc0a1ec2d7c4b2ed7f9b6d529514172 (diff)
downloadsimple-opt-9e843b2dda247b5e61d168a77bf93afa3f0e78db.tar.gz
resolve some pedantic warnings
-rw-r--r--README.md2
-rw-r--r--doc/interface.md9
-rw-r--r--simple-opt.h11
3 files changed, 13 insertions, 9 deletions
diff --git a/README.md b/README.md
index 4d0dfe9..9c51045 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ simple-opt
simple, flexible, and portable version of command line option parsing for
programs written in C. it is designed to be (hopefully) intuitive while also
being (hopefully) more powerful than traditional getopt or similar. it has no
-dependencies outside the standard library and is C99 compatible.
+dependencies outside the standard library.
what follows is a simple example usage. refer to
[interface.md](doc/interface.md) for more detail.
diff --git a/doc/interface.md b/doc/interface.md
index 86937f8..da07986 100644
--- a/doc/interface.md
+++ b/doc/interface.md
@@ -53,9 +53,12 @@ the fields which are set by `simple_opt_parse` are:
union {
bool val_bool;
- int val_int;
- unsigned val_unsigned;
- char val_string[SIMPLE_OPT_ARG_MAX_WIDTH];
+ long val_int;
+ unsigned long val_unsigned;
+ double val_double;
+ char val_char;
+ char val_string[SIMPLE_OPT_OPT_ARG_MAX_WIDTH];
+ int val_string_set_idx;
};
```
diff --git a/simple-opt.h b/simple-opt.h
index ada6233..736d8e0 100644
--- a/simple-opt.h
+++ b/simple-opt.h
@@ -5,6 +5,7 @@
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
+#include <stdint.h>
#include <ctype.h>
#include <errno.h>
@@ -105,7 +106,7 @@ static void simple_opt_print_usage(FILE *f, unsigned width, char *usage_name,
static bool sub_simple_opt_parse(struct simple_opt *o, char *s)
{
- int i, j;
+ unsigned i, j;
char *str, *cp;
bool match;
@@ -410,11 +411,11 @@ opt_copy_and_return:
goto end;
}
-static int sub_simple_opt_wrap_print(FILE *f, unsigned width, int col,
- int line_start, const char *s)
+static int sub_simple_opt_wrap_print(FILE *f, unsigned width, unsigned col,
+ unsigned line_start, const char *s)
{
bool add_newline = false, first_word = true, first_line = true;;
- int i, j, word_start, word_end;
+ unsigned i, j, word_start, word_end;
if (width != 0 && line_start >= width) {
line_start = 0;
@@ -510,7 +511,7 @@ static void simple_opt_print_usage(FILE *f, unsigned width, char *usage_name,
char *usage_options, char *usage_summary, struct simple_opt *options)
{
char print_buffer[SIMPLE_OPT_USAGE_PRINT_BUFFER_WIDTH];
- int i, j, col, print_buffer_offset, desc_line_start;
+ unsigned i, j, col, print_buffer_offset, desc_line_start;
/* calculate the required line_start for printing descriptions (leaving
* space for the widest existing long-option) */