diff --git a/tools/qfcc/include/options.h b/tools/qfcc/include/options.h index 6be963699..4377dab97 100644 --- a/tools/qfcc/include/options.h +++ b/tools/qfcc/include/options.h @@ -44,6 +44,7 @@ typedef struct { qboolean local_merging; // merge function locals into one block unsigned progsversion; // Progs version to generate code for qboolean vector_components; // add *_[xyz] symbols for vectors + qboolean ifstring; // expand if (str) to if (str != "") } code_options_t; typedef struct { diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index 109d0a51f..ff1ebab3e 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -1082,6 +1082,8 @@ test_expr (expr_t *e) } return error (e, "void has no value"); case ev_string: + if (!options.code.ifstring) + return new_alias_expr (type_default, e); new = new_string_expr (0); break; case ev_uinteger: @@ -1211,7 +1213,8 @@ convert_bool (expr_t *e, int block) return b; } - if (e->type == ex_uexpr && e->e.expr.op == '!') { + if (e->type == ex_uexpr && e->e.expr.op == '!' + && get_type (e->e.expr.e1) != &type_string) { e = convert_bool (e->e.expr.e1, 0); if (e->type == ex_error) return e; diff --git a/tools/qfcc/source/options.c b/tools/qfcc/source/options.c index 4209cbbec..4edb03623 100644 --- a/tools/qfcc/source/options.c +++ b/tools/qfcc/source/options.c @@ -470,6 +470,8 @@ DecodeArgs (int argc, char **argv) options.code.optimize = flag; } else if (!(strcasecmp (temp, "short-circuit"))) { options.code.short_circuit = flag; + } else if (!(strcasecmp (temp, "ifstring"))) { + options.code.ifstring = flag; } else if (!(strcasecmp (temp, "single-cpp"))) { options.single_cpp = flag; } else if (!(strcasecmp (temp, "vector-calls"))) { @@ -645,6 +647,8 @@ DecodeArgs (int argc, char **argv) options.advanced = false; if (!options.code.progsversion) options.code.progsversion = PROG_ID_VERSION; + if (options.code.ifstring == (qboolean) -1) + options.code.ifstring = false; if (options.code.short_circuit == (qboolean) -1) options.code.short_circuit = false; if (options.code.local_merging == (qboolean) -1) @@ -658,6 +662,8 @@ DecodeArgs (int argc, char **argv) options.advanced = true; add_cpp_def ("-D__RUAMOKO__=1"); add_cpp_def ("-D__RAUMOKO__=1"); + if (options.code.ifstring == (qboolean) -1) + options.code.ifstring = false; if (options.code.short_circuit == (qboolean) -1) options.code.short_circuit = true; if (options.code.local_merging == (qboolean) -1)