libcore: Remove LC_OPT_ENT_NEGBOOL() and LC_OPT_ENT_NEGBIT().
authorChristoph Mallon <christoph.mallon@gmx.de>
Thu, 6 Dec 2012 05:33:02 +0000 (06:33 +0100)
committerChristoph Mallon <christoph.mallon@gmx.de>
Thu, 6 Dec 2012 05:35:54 +0000 (06:35 +0100)
Avoid negative switches.

ir/libcore/lc_opts.c
ir/libcore/lc_opts.h

index 5d34a93..4db025f 100644 (file)
@@ -176,8 +176,6 @@ static const char *get_type_name(lc_opt_type_t type)
                XXX(double);
                XXX(boolean);
                XXX(string);
-               case lc_opt_type_negbit:     res = "bit";     break;
-               case lc_opt_type_negboolean: res = "boolean"; break;
                default:
                res = "<none>";
        }
@@ -360,22 +358,10 @@ int lc_opt_std_cb(const char *name, lc_opt_type_t type, void *data, size_t lengt
                                *(unsigned*)data &= ~length;
                        break;
 
-               case lc_opt_type_negbit:
-                       integer = va_arg(args, int);
-                       if (integer)
-                               *(unsigned*)data &= ~length;
-                       else
-                               *(unsigned*)data |= length;
-                       break;
-
                case lc_opt_type_boolean:
                        *((int *) data) = va_arg(args, int);
                        break;
 
-               case lc_opt_type_negboolean:
-                       *((int *) data) = !va_arg(args, int);
-                       break;
-
                case lc_opt_type_string:
                        strncpy((char*)data, va_arg(args, const char *), length);
                        break;
@@ -405,11 +391,9 @@ int lc_opt_std_dump(char *buf, size_t n, const char *name, lc_opt_type_t type, v
        if (data) {
                switch (type) {
                case lc_opt_type_bit:
-               case lc_opt_type_negbit:
                        res = snprintf(buf, n, "%x", *((unsigned *) data));
                        break;
                case lc_opt_type_boolean:
-               case lc_opt_type_negboolean:
                        res = snprintf(buf, n, "%s", *((int *) data) ? "true" : "false");
                        break;
                case lc_opt_type_string:
@@ -501,9 +485,7 @@ int lc_opt_occurs(lc_opt_entry_t *opt, const char *value, lc_opt_err_info_t *err
                        break;
 
                case lc_opt_type_boolean:
-               case lc_opt_type_negboolean:
                case lc_opt_type_bit:
-               case lc_opt_type_negbit:
                                strtolower(buf, sizeof(buf), value);
                                for (i = 0; i < ARRAY_SIZE(bool_strings); ++i) {
                                        if (strcmp(buf, bool_strings[i].str) == 0) {
index 0dd6503..4e1e0e9 100644 (file)
@@ -37,9 +37,7 @@ typedef enum {
        lc_opt_type_invalid,
        lc_opt_type_enum,
        lc_opt_type_bit,
-       lc_opt_type_negbit,
        lc_opt_type_boolean,
-       lc_opt_type_negboolean,
        lc_opt_type_string,
        lc_opt_type_int,
        lc_opt_type_double
@@ -114,15 +112,9 @@ typedef struct {
 #define LC_OPT_ENT_BIT(name, desc, addr, mask) \
        _LC_OPT_ENT(name, desc, lc_opt_type_bit, unsigned, addr, mask, lc_opt_std_cb, lc_opt_std_dump, NULL)
 
-#define LC_OPT_ENT_NEGBIT(name, desc, addr, mask) \
-       _LC_OPT_ENT(name, desc, lc_opt_type_negbit, unsigned, addr, mask, lc_opt_std_cb, lc_opt_std_dump, NULL)
-
 #define LC_OPT_ENT_BOOL(name, desc, addr) \
        _LC_OPT_ENT(name, desc, lc_opt_type_boolean, int, addr, 0, lc_opt_std_cb, lc_opt_std_dump, lc_opt_bool_dump_vals)
 
-#define LC_OPT_ENT_NEGBOOL(name, desc, addr) \
-       _LC_OPT_ENT(name, desc, lc_opt_type_negboolean, int, addr, 0, lc_opt_std_cb, lc_opt_std_dump, lc_opt_bool_dump_vals)
-
 typedef char lc_opt_str_t[];
 #define LC_OPT_ENT_STR(name, desc, buf) \
        _LC_OPT_ENT(name, desc, lc_opt_type_string, lc_opt_str_t, buf, sizeof(*buf), lc_opt_std_cb, lc_opt_std_dump, NULL)