Skip to content

Commit

Permalink
get the regex for cuddled elses a little broader, and then fix the cu…
Browse files Browse the repository at this point in the history
…ddled elses it found
  • Loading branch information
petdance committed Apr 5, 2012
1 parent d054e19 commit bb282e3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
4 changes: 3 additions & 1 deletion compilers/imcc/imcc.l
Expand Up @@ -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);

Expand Down
12 changes: 7 additions & 5 deletions compilers/imcc/optimizer.c
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions src/hash.c
Expand Up @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions src/pmc/managedstruct.pmc
Expand Up @@ -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);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion t/codingstd/cuddled_else.t
Expand Up @@ -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'
);

Expand Down

0 comments on commit bb282e3

Please sign in to comment.