diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2013-10-24 21:49:52 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2013-10-24 21:49:52 -0700 |
commit | c6862a210f48ee4fd2d7fe7ad0e4eca11bea9963 (patch) | |
tree | ea18db3c64d4edfd8dc17784211d382a434fca45 /lib.c | |
parent | b7f9a8f2e02872fea86827b034278c399fb052dc (diff) | |
download | txr-c6862a210f48ee4fd2d7fe7ad0e4eca11bea9963.tar.gz txr-c6862a210f48ee4fd2d7fe7ad0e4eca11bea9963.tar.bz2 txr-c6862a210f48ee4fd2d7fe7ad0e4eca11bea9963.zip |
Ouch! Turns out the code base has numerous unintended
deviations from C90, like mixed declations and
statements. GCC doesn't diagnose these without the
--pedantic flag.
* configure: GCC's --ansi flag should be spelled -ansi.
* lib.c (split_str, obj_print): Reorder declaration before statements.
(make_sym): Fix similar problem by eliminating a statement.
(funcall1, funcall2, funcall3, funcall4): Use assignment to initialize
local array with non-constant elements. This is actually good for
performance because we only initialize those parts of the array that
we use.
* lib.h (struct func): Change functype member to unsigned,
since enum-typed bitfields are a GCC extension.
* match.c (ml_all, mf_all): Use assignments to initialize local
struct with non-constants.
(do_txeval, v_collect): Slightly revise unwinding macrology with help
of new macros to avoid mixing declarations and statements.
(spec_bind): Removed spurious semicolon from macro expansion.
(v_gather): Reorder two lines to avoid mixed decls and
statements.
(match_filter): Move declaration of ret a few lines up, ahead of
statements.
* unwind.c (uw_pop_until): New function.
* unwind.h (uw_pop_until): Declared.
(uw_mark_frame, uw_fast_return): New macros.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 30 |
1 files changed, 21 insertions, 9 deletions
@@ -2007,11 +2007,11 @@ val split_str(val str, val sep) const wchar_t *cstr = c_str(str); const wchar_t *csep = c_str(sep); + list_collect_decl (out, iter); + prot1(&str); prot1(&sep); - list_collect_decl (out, iter); - for (;;) { const wchar_t *psep = wcsstr(cstr, csep); size_t span = (psep != 0) ? psep - cstr : wcslen(cstr); @@ -2025,8 +2025,10 @@ val split_str(val str, val sep) } break; } + rel1(&sep); rel1(&str); + return out; } } @@ -2416,8 +2418,8 @@ val make_sym(val name) val gensym(val prefix) { - gensym_counter = plus(gensym_counter, one); - val name = format(nil, lit("~a~,04a"), prefix, gensym_counter, nao); + val name = format(nil, lit("~a~,04a"), prefix, + gensym_counter = plus(gensym_counter, one), nao); return make_sym(name); } @@ -2991,7 +2993,8 @@ val funcall1(val fun, val arg) type_check(fun, FUN); if (fun->f.optargs) { - val args[32] = { arg }; + val args[32]; + args[0] = arg; return generic_funcall(fun, args, 1); } @@ -3028,7 +3031,9 @@ val funcall2(val fun, val arg1, val arg2) type_check(fun, FUN); if (fun->f.optargs) { - val arg[32] = { arg1, arg2 }; + val arg[32]; + arg[0] = arg1; + arg[1] = arg2; return generic_funcall(fun, arg, 2); } @@ -3070,7 +3075,10 @@ val funcall3(val fun, val arg1, val arg2, val arg3) type_check(fun, FUN); if (fun->f.optargs) { - val arg[32] = { arg1, arg2, arg3 }; + val arg[32]; + arg[0] = arg1; + arg[1] = arg2; + arg[2] = arg3; return generic_funcall(fun, arg, 3); } @@ -3116,7 +3124,11 @@ val funcall4(val fun, val arg1, val arg2, val arg3, val arg4) type_check(fun, FUN); if (fun->f.optargs) { - val arg[32] = { arg1, arg2, arg3, arg4 }; + val arg[32]; + arg[0] = arg1; + arg[1] = arg2; + arg[2] = arg3; + arg[3] = arg4; return generic_funcall(fun, arg, 4); } @@ -4646,8 +4658,8 @@ val obj_print(val obj, val out) case STR: { const wchar_t *ptr; - put_char(chr('"'), out); int semi_flag = 0; + put_char(chr('"'), out); for (ptr = c_str(obj); *ptr; ptr++) { if (semi_flag && iswxdigit(*ptr)) |