Permalink
Browse files

get the regex for cuddled elses a little broader, and then fix the cu…

…ddled elses it found
  • Loading branch information...
1 parent d054e19 commit bb282e3e9b4d110e0f363589f1d1451320f52d43 @petdance petdance committed Apr 5, 2012
Showing with 19 additions and 11 deletions.
  1. +3 −1 compilers/imcc/imcc.l
  2. +7 −5 compilers/imcc/optimizer.c
  3. +4 −2 src/hash.c
  4. +4 −2 src/pmc/managedstruct.pmc
  5. +1 −1 t/codingstd/cuddled_else.t
View
@@ -788,8 +788,10 @@ destroy_frame(struct macro_frame_t *frame, void *yyscanner)
if (frame->heredoc_rest) {
mem_sys_free(frame->heredoc_rest);
frame->heredoc_rest = NULL;
- } else
+ }
+ else {
ret = frame->s.line;
+ }
mem_sys_free(frame);
View
@@ -686,7 +686,8 @@ constant_propagation(ARGMOD(imc_info_t *imcc), ARGMOD(IMC_Unit *unit))
found = 1;
c = ins->symregs[1];
o = ins->symregs[0];
- } else if (STREQ(ins->opname, "null") && ins->symregs[0]->set == 'I') {
+ }
+ else if (STREQ(ins->opname, "null") && ins->symregs[0]->set == 'I') {
found = 1;
c = mk_const(imcc, "0", 'I');
o = ins->symregs[0];
@@ -1374,12 +1375,13 @@ branch_cond_loop(ARGMOD(imc_info_t *imcc), ARGMOD(IMC_Unit *unit))
/* no good if it's an unconditional branch*/
if (cond->type & IF_goto && STREQ(cond->opname, "branch")) {
break;
- } else if (cond->type & ITPCCRET || cond->type & ITPCCSUB
- || cond->type & ITCALL) {
+ }
+ else if ((cond->type & ITPCCRET) || (cond->type & ITPCCSUB)
+ || (cond->type & ITCALL)) {
break;
/* just until we can copy set_args et al */
- } else if (cond->type & ITBRANCH &&
- get_branch_regno(cond) >= 0) {
+ }
+ else if ((cond->type & ITBRANCH) && (get_branch_regno(cond) >= 0)) {
found = 1;
break;
}
View
@@ -1344,8 +1344,10 @@ parrot_hash_get_bucket_string(PARROT_INTERP, ARGIN(const Hash *hash),
if ((STRING_byte_length(s) == STRING_byte_length(s2))
&& (memcmp(s->strstart, s2->strstart, STRING_byte_length(s)) == 0))
break;
- } else if (STRING_equal(interp, s, s2))
- break;
+ }
+ else if (STRING_equal(interp, s, s2)) {
+ break;
+ }
}
bucket = bucket->next;
}
@@ -85,10 +85,12 @@ Otherwise, mem_gc_free() is used.
if (ptr) {
const custom_free_func_t free_func = PARROT_MANAGEDSTRUCT(SELF)->custom_free_func;
if (free_func) {
- void *free_data = PARROT_MANAGEDSTRUCT(SELF)->custom_free_priv;
+ void * const free_data = PARROT_MANAGEDSTRUCT(SELF)->custom_free_priv;
free_func(INTERP, ptr, free_data);
- } else
+ }
+ else {
mem_gc_free(INTERP, ptr);
+ }
}
}
@@ -41,7 +41,7 @@ my @files = @ARGV ? <@ARGV> : (
Parrot::Test::Util::Runloop->testloop(
name => 'no cuddled elses',
files => [@files],
- per_line => sub { $_[0] !~ /}\s*else\s*{/ },
+ per_line => sub { $_[0] !~ /}\s*else/ },
diag_prefix => 'Cuddled else found'
);

0 comments on commit bb282e3

Please sign in to comment.