# New Ticket Created by Shawn M Moore # Please include the string: [perl #42236] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42236 >
Hi, I'm bored, so I'm going through and fixing some failing tests in t/codingstd/ At the moment I'm working on c_parens.t. Here's one that fixes the majority of the failures in the first third of the tests, which looks that code matches the pattern C-keyword exactly-one-space open-parenthesis I only fixed the ones that were mostly obvious. How is sizeof supposed to be treated? It's a keyword, yes, but most C code I've seen has no space between the sizeof and (. So I didn't touch those failures. I also didn't change things where spacing created a layout, such as in typedef void (*push_number_f) (Parrot_Interp, IMAGE_IO*, FLOATVAL); typedef INTVAL (*shift_integer_f) (Parrot_Interp, IMAGE_IO*); I can try to write something to make the above case pass (look for a parenthesis in the same column a line above or below), but that'll come later. make test obviously returned no new failures; prove t/codingstd/c_paren.t had a reduction of 40 files to 33. A lot of these failures are sizeof or layout related, honest! Affected files (yay diffstat): compilers/imcc/imc.h | 2 - compilers/imcc/imcc.y | 16 +++++++------- compilers/pirc/src/pirlexer.c | 34 ++++++++++++++--------------- compilers/pirc/src/pirparser.c | 30 +++++++++++++------------- include/parrot/encoding.h | 2 - include/parrot/packfile.h | 4 +-- include/parrot/smallobject.h | 2 - languages/cola/cola.y | 42 ++++++++++++++++++------------------- languages/lua/pmc/luastring.pmc | 2 - languages/pugs/pmc/pugscapture.pmc | 2 - languages/tcl/src/pmc/tcllist.pmc | 2 - src/inter_call.c | 6 ++--- 12 files changed, 72 insertions(+), 72 deletions(-) Shawn M Moore
Index: src/inter_call.c =================================================================== --- src/inter_call.c (revision 17872) +++ src/inter_call.c (working copy) @@ -754,7 +754,7 @@ /* verify that a name exists */ INTVAL sig = st->dest.sig = SIG_ITEM(st->dest.u.op.signature, i); - if(sig & PARROT_ARG_NAME) + if (sig & PARROT_ARG_NAME) { INTVAL arg_sig; int last_name_pos; @@ -772,7 +772,7 @@ /* if this named arg is already filled, continue*/ if (st->named_done & (1 << n_named)) { arg_sig = st->dest.sig = SIG_ITEM(st->dest.u.op.signature, i+1); - if(arg_sig & PARROT_ARG_OPT_FLAG) + if (arg_sig & PARROT_ARG_OPT_FLAG) i++; /* skip associated opt flag arg as well */ continue; } @@ -782,7 +782,7 @@ store_arg(st, idx); arg_sig = st->dest.sig = SIG_ITEM(st->dest.u.op.signature, i+1); - if(arg_sig & PARROT_ARG_OPT_FLAG) { + if (arg_sig & PARROT_ARG_OPT_FLAG) { i++; idx = st->dest.u.op.pc[i]; CTX_REG_INT(st->dest.ctx, idx) = 0; Index: include/parrot/smallobject.h =================================================================== --- include/parrot/smallobject.h (revision 17872) +++ include/parrot/smallobject.h (working copy) @@ -18,7 +18,7 @@ struct Small_Object_Pool *, void *); typedef void * (*get_free_object_fn_type)(Interp *, struct Small_Object_Pool *); -typedef void (*alloc_objects_fn_type)(Interp *, +typedef void (*alloc_objects_fn_type)(Interp *, struct Small_Object_Pool *); #if PARROT_GC_GMS Index: include/parrot/encoding.h =================================================================== --- include/parrot/encoding.h (revision 17872) +++ include/parrot/encoding.h (working copy) @@ -34,7 +34,7 @@ struct string_iterator_t; /* s. parrot/string.h */ -typedef void (*encoding_iter_init_t)(Interp *, STRING *src, +typedef void (*encoding_iter_init_t)(Interp *, STRING *src, struct string_iterator_t *); struct _encoding { Index: include/parrot/packfile.h =================================================================== --- include/parrot/packfile.h (revision 17872) +++ include/parrot/packfile.h (working copy) @@ -56,7 +56,7 @@ typedef struct PackFile_Segment * (*PackFile_Segment_new_func_t) (Interp *, struct PackFile *, const char *, int add); -typedef void (*PackFile_Segment_destroy_func_t) (Interp *, +typedef void (*PackFile_Segment_destroy_func_t) (Interp *, struct PackFile_Segment *); typedef size_t (*PackFile_Segment_packed_size_func_t)(Interp *, struct PackFile_Segment *); @@ -64,7 +64,7 @@ struct PackFile_Segment *, opcode_t *dest); typedef opcode_t * (*PackFile_Segment_unpack_func_t) (Interp *, struct PackFile_Segment *, opcode_t *packed); -typedef void (*PackFile_Segment_dump_func_t) (Interp *, +typedef void (*PackFile_Segment_dump_func_t) (Interp *, struct PackFile_Segment *); struct PackFile_funcs { Index: compilers/imcc/imcc.y =================================================================== --- compilers/imcc/imcc.y (revision 17872) +++ compilers/imcc/imcc.y (working copy) @@ -202,7 +202,7 @@ iINDEXFETCH(Interp *interp, IMC_Unit * unit, SymReg * r0, SymReg * r1, SymReg * r2) { - if(r0->set == 'S' && r1->set == 'S' && r2->set == 'I') { + if (r0->set == 'S' && r1->set == 'S' && r2->set == 'I') { SymReg * r3 = mk_const(interp, str_dup("1"), 'I'); return MK_I(interp, unit, "substr %s, %s, %s, 1", 4, r0, r1, r2, r3); } @@ -218,7 +218,7 @@ iINDEXSET(Interp *interp, IMC_Unit * unit, SymReg * r0, SymReg * r1, SymReg * r2) { - if(r0->set == 'S' && r1->set == 'I' && r2->set == 'S') { + if (r0->set == 'S' && r1->set == 'I' && r2->set == 'S') { SymReg * r3 = mk_const(interp, str_dup("1"), 'I'); MK_I(interp, unit, "substr %s, %s, %s, %s", 4, r0, r1,r3, r2); } @@ -296,10 +296,10 @@ Instruction *i, *ins; char name[128]; ins = IMCC_INFO(interp)->cur_unit->instructions; - if(!ins || !ins->r[0] || !(ins->r[0]->type & VT_PCC_SUB)) + if (!ins || !ins->r[0] || !(ins->r[0]->type & VT_PCC_SUB)) IMCC_fataly(interp, E_SyntaxError, "yield or return directive outside pcc subroutine\n"); - if(yield) + if (yield) ins->r[0]->pcc_sub->calls_a_sub = 1 | ITPCCYIELD; sprintf(name, yield ? "%cpcc_sub_yield_%d" : "%cpcc_sub_ret_%d", IMCC_INTERNAL_CHAR, IMCC_INFO(interp)->cnr++); @@ -873,7 +873,7 @@ pcc_results: /* empty */ { $$ = 0; } - | pcc_results pcc_result '\n' { if($2) add_pcc_result(IMCC_INFO(interp)->cur_call, $2); } + | pcc_results pcc_result '\n' { if ($2) add_pcc_result(IMCC_INFO(interp)->cur_call, $2); } ; pcc_result: @@ -929,10 +929,10 @@ pcc_returns: /* empty */ { $$ = 0; } | pcc_returns '\n' { - if($1) add_pcc_return(IMCC_INFO(interp)->sr_return, $1); + if ($1) add_pcc_return(IMCC_INFO(interp)->sr_return, $1); } | pcc_returns pcc_return '\n' { - if($2) add_pcc_return(IMCC_INFO(interp)->sr_return, $2); + if ($2) add_pcc_return(IMCC_INFO(interp)->sr_return, $2); } ; @@ -1076,7 +1076,7 @@ | LOCAL { is_def=1; } type id_list { IdList* l = $4; - while(l) { + while (l) { IdList* l1; if (l->unique_reg) mk_ident_ur(interp, l->id, $3); Index: compilers/imcc/imc.h =================================================================== --- compilers/imcc/imc.h (revision 17872) +++ compilers/imcc/imc.h (working copy) @@ -53,7 +53,7 @@ #define IMCC_TRY(a,e) do{ e=0; switch (setjmp(a)){ case 0: #define IMCC_CATCH(x) break; case x: -#define IMCC_END_TRY } }while(0) +#define IMCC_END_TRY } }while (0) #define IMCC_THROW(a,x) longjmp(a,x) Index: compilers/pirc/src/pirparser.c =================================================================== --- compilers/pirc/src/pirparser.c (revision 17872) +++ compilers/pirc/src/pirparser.c (working copy) @@ -107,7 +107,7 @@ #define next(P) P->curtoken = next_token(P->lexer) /* -#define next(P) do { pirout(P); P->curtoken = next_token(P->lexer); } while(0) +#define next(P) do { pirout(P); P->curtoken = next_token(P->lexer); } while (0) */ @@ -417,7 +417,7 @@ */ static void target(parser_state *p) { - switch(p->curtoken) { + switch (p->curtoken) { case T_PASM_PREG: case T_PREG: case T_PASM_IREG: case T_IREG: case T_PASM_NREG: case T_NREG: case T_PASM_SREG: case T_SREG: case T_IDENTIFIER: @@ -440,7 +440,7 @@ */ static void type(parser_state *p) { - switch(p->curtoken) { + switch (p->curtoken) { case T_INT: case T_NUM: case T_PMC: @@ -495,7 +495,7 @@ keylist(parser_state *p) { match(p, T_LBRACKET); /* skip '[' */ key(p); - while(p->curtoken == T_SEMICOLON || p->curtoken == T_COMMA) { + while (p->curtoken == T_SEMICOLON || p->curtoken == T_COMMA) { next(p); /* skip ';' or ',' */ key(p); } @@ -640,7 +640,7 @@ */ static void arith_expression(parser_state *p) { - switch(p->curtoken) { + switch (p->curtoken) { case T_PLUS: case T_MINUS: case T_DIVIDE: @@ -714,7 +714,7 @@ assignment(parser_state *p) { match(p, T_ASSIGN); - switch(p->curtoken) { + switch (p->curtoken) { case T_NOT: case T_MINUS: case T_BXOR: /* '~' used as binary 'not' op */ @@ -887,7 +887,7 @@ match(p, T_IDENTIFIER); if (p->curtoken == T_UNIQUE_REG_FLAG) next(p); - while(p->curtoken == T_COMMA) { + while (p->curtoken == T_COMMA) { next(p); /* skip comma */ match(p, T_IDENTIFIER); @@ -980,7 +980,7 @@ conditional_expression(parser_state *p) { expression(p); - switch(p->curtoken) { /* optional */ + switch (p->curtoken) { /* optional */ case T_GE: case T_GT: case T_EQ: case T_NE: case T_LT: case T_LE: next(p); /* skip comparison op */ @@ -1054,7 +1054,7 @@ */ static void const_definition(parser_state *p) { - switch(p->curtoken) { + switch (p->curtoken) { case T_INT: next(p); match(p, T_IDENTIFIER); @@ -1155,7 +1155,7 @@ int ok = 1; while (ok) { /* if the current token is a flag, parse it */ - switch(p->curtoken) { + switch (p->curtoken) { case T_SLURPY_FLAG: case T_UNIQUE_REG_FLAG: case T_OPTIONAL_FLAG: @@ -1212,7 +1212,7 @@ match(p, T_NEWLINE); } - switch(p->curtoken) { + switch (p->curtoken) { case T_PCC_CALL: /* ... '.pcc_call' target '\n' ... */ case T_NCI_CALL: /* ... '.nci_call' target '\n' ... */ next(p); @@ -1308,7 +1308,7 @@ target_statement(parser_state *p) { target(p); - switch(p->curtoken) { + switch (p->curtoken) { case T_ASSIGN: /* target '=' expression */ assignment(p); break; @@ -1364,7 +1364,7 @@ target_list(parser_state *p) { match(p, T_LPAREN); target(p); - while(p->curtoken == T_COMMA) { + while (p->curtoken == T_COMMA) { next(p); target(p); param_flags(p); @@ -1386,7 +1386,7 @@ target_list(p); match(p, T_ASSIGN); - switch(p->curtoken) { + switch (p->curtoken) { case T_IDENTIFIER: /* target_list '=' subcall */ case T_PASM_PREG: case T_PREG: @@ -1697,7 +1697,7 @@ int wantmore = 0; /* flag that is set when a ',' is parsed */ while (ok || wantmore) { - switch(p->curtoken) { + switch (p->curtoken) { case T_ANON_FLAG: next(p); break; Index: compilers/pirc/src/pirlexer.c =================================================================== --- compilers/pirc/src/pirlexer.c (revision 17872) +++ compilers/pirc/src/pirlexer.c (working copy) @@ -660,7 +660,7 @@ int index = 0; char const * word = dictionary[index]; /* check all words in dictionary; if equal, return its token enum value */ - while(word) { + while (word) { if (strcmp(word, lexer->token_chars) == 0) return index; word = dictionary[++index]; } @@ -888,7 +888,7 @@ * of the string - is returned */ dest = ptr = (char *)calloc(srclen + 1, sizeof(char)); - while(*src) { + while (*src) { *dest++ = *src++; } return ptr; @@ -1028,7 +1028,7 @@ */ /* now start checking for real tokens */ - switch(c) { + switch (c) { case 'P': buffer_char(lexer, c); /* buffer 'P' */ count = read_digits(lexer); /* read as many digits as you can */ @@ -1224,7 +1224,7 @@ c = read_char(lexer->curfile); if (c == EOF_MARKER) return T_EOF; - switch(c) { + switch (c) { case 'P': regtype = T_PREG; break; case 'N': regtype = T_NREG; break; case 'S': regtype = T_SREG; break; @@ -1273,7 +1273,7 @@ =cut */ - switch(c) { + switch (c) { case '(': buffer_char(lexer, c); return T_LPAREN; case ')': buffer_char(lexer, c); return T_RPAREN; case '[': buffer_char(lexer, c); return T_LBRACKET; @@ -1319,7 +1319,7 @@ /* check for possible multi-character special tokens */ if (c == '*') { c = read_char(lexer->curfile); - switch(c) { + switch (c) { case '*': return T_POWER; /* *= */ case '=': return T_POWER_ASSIGN; /* **= */ case EOF_MARKER: return T_EOF; @@ -1330,7 +1330,7 @@ } else if (c == '%') { c = read_char(lexer->curfile); - switch(c) { + switch (c) { case '=': return T_MODULO_ASSIGN; /* %= */ case EOF_MARKER: return T_EOF; default: @@ -1340,7 +1340,7 @@ } else if (c == '/') { c = read_char(lexer->curfile); - switch(c) { + switch (c) { case '/': c = read_char(lexer->curfile); if (c == '=') { @@ -1360,7 +1360,7 @@ } else if (c == '+') { c = read_char(lexer->curfile); - switch(c) { + switch (c) { case '=': return T_PLUS_ASSIGN; /* += */ case EOF_MARKER: return T_EOF; default: @@ -1370,7 +1370,7 @@ } else if (c == '-') { c = read_char(lexer->curfile); - switch(c) { + switch (c) { case '>': return T_PTR; /* -> */ case '=': return T_MINUS_ASSIGN; /* -= */ case EOF_MARKER: return T_EOF; @@ -1381,7 +1381,7 @@ } else if (c == '!') { c = read_char(lexer->curfile); - switch(c) { + switch (c) { case '=': return T_NE; /* != */ case EOF_MARKER: return T_EOF; default: /* ! */ @@ -1391,7 +1391,7 @@ } else if (c == '=') { c = read_char(lexer->curfile); - switch(c) { + switch (c) { case '>': return T_ARROW; /* => */ case '=': return T_EQ; /* == */ case EOF_MARKER: return T_EOF; @@ -1402,7 +1402,7 @@ } else if (c == '>') { c = read_char(lexer->curfile); - switch(c) { + switch (c) { case '>': c = read_char(lexer->curfile); if (c == '>') { /* >>> */ @@ -1431,7 +1431,7 @@ } else if (c == '<') { c = read_char(lexer->curfile); - switch(c) { + switch (c) { case '=': return T_LE; /* <= */ case '<': /* <<? */ c = read_char(lexer->curfile); @@ -1462,7 +1462,7 @@ } else if (c == '~') { c = read_char(lexer->curfile); - switch(c) { + switch (c) { case '~': return T_XOR; /* ~~ */ case '=': return T_BXOR_ASSIGN; /* ~= */ case EOF_MARKER: return T_EOF; @@ -1473,7 +1473,7 @@ } else if (c == '&') { c = read_char(lexer->curfile); - switch(c) { + switch (c) { case '&': return T_AND; /* && */ case '=': return T_BAND_ASSIGN; /* &= */ case EOF_MARKER: return T_EOF; @@ -1484,7 +1484,7 @@ } else if (c == '|') { c = read_char(lexer->curfile); - switch(c) { + switch (c) { case '|': return T_OR; /* || */ case '=': return T_BOR_ASSIGN; /* |= */ case EOF_MARKER: return T_EOF; Index: languages/pugs/pmc/pugscapture.pmc =================================================================== --- languages/pugs/pmc/pugscapture.pmc (revision 17872) +++ languages/pugs/pmc/pugscapture.pmc (working copy) @@ -253,7 +253,7 @@ parrot_mark_hash(INTERP, siva_hash(SELF)); if (siva_ary(SELF)) list_mark(INTERP, siva_ary(SELF)); - if(PMC_str_val(SELF)) + if (PMC_str_val(SELF)) pobject_lives(INTERP, (PObj *)siva_str(SELF)); } Index: languages/lua/pmc/luastring.pmc =================================================================== --- languages/lua/pmc/luastring.pmc (revision 17872) +++ languages/lua/pmc/luastring.pmc (working copy) @@ -113,7 +113,7 @@ */ void mark () { - if(PMC_str_val(SELF)) + if (PMC_str_val(SELF)) pobject_lives(INTERP, (PObj *)PMC_str_val(SELF)); } Index: languages/tcl/src/pmc/tcllist.pmc =================================================================== --- languages/tcl/src/pmc/tcllist.pmc (revision 17872) +++ languages/tcl/src/pmc/tcllist.pmc (working copy) @@ -117,7 +117,7 @@ size = VTABLE_elements(INTERP,other); DYNSELF.set_integer_native(size); - for(i = 0; i < size; i++) { + for (i = 0; i < size; i++) { PMC* elem = VTABLE_get_pmc_keyed_int(INTERP, other, i); DYNSELF.set_pmc_keyed_int(i, elem); } Index: languages/cola/cola.y =================================================================== --- languages/cola/cola.y (revision 17872) +++ languages/cola/cola.y (working copy) @@ -154,11 +154,11 @@ NAMESPACE qualified_name { Symbol *n, *t, *last = current_namespace; - if(lookup_type_symbol($2)) { + if (lookup_type_symbol($2)) { printf("Error, redefinition of [%s]\n", $2->name); exit(0); } - for(n = split(".", $2->name); n; n = n->tnext) { + for (n = split(".", $2->name); n; n = n->tnext) { n->kind = $2->kind; t = mk_namespace_symbol(n); store_symbol(last->table, t); @@ -183,7 +183,7 @@ '{' using_directives namespace_member_decls '}' { $$ = $2; - if($3) + if ($3) unshift_ast(&($$), $3); } ; @@ -194,7 +194,7 @@ namespace_member_decls namespace_member_decl { $$ = $1; - if($2) + if ($2) unshift_ast(&($$), $2); } ; @@ -297,7 +297,7 @@ store_symbol(current_symbol_table, $3); $$ = new_statement(ASTT_CONSTANT_DECL, NULL, NULL); $$->typename = $2; - if(lookup_symbol_in_tab(current_symbol_table, $$->sym->name)) { + if (lookup_symbol_in_tab(current_symbol_table, $$->sym->name)) { printf("Warning: declaration of '%s' shadows previous instance.\n", $$->sym->name); } @@ -308,11 +308,11 @@ type var_declarators { AST * decl; - if($1 == NULL) { + if ($1 == NULL) { printf("Internal compiler error: local_var_decl: type is NULL\n"); abort(); } - for(decl=$2; decl; decl = decl->next) { + for (decl=$2; decl; decl = decl->next) { #if DEBUG fprintf(stderr, "local_var: [%s] typename [%s]\n", decl->arg1->sym->name, $1->name); @@ -327,11 +327,11 @@ opt_modifiers type var_declarators ';' { AST * decl; - if($2 == NULL) { + if ($2 == NULL) { printf("Internal compiler error: field_decl: type is NULL\n"); abort(); } - for(decl=$3; decl; decl = decl->next) { + for (decl=$3; decl; decl = decl->next) { #if DEBUG fprintf(stderr, "field: [%s] typename [%s]\n", decl->arg1->sym->name, $2->name); @@ -396,9 +396,9 @@ * We can store these at parse time. */ store_symbol(current_symbol_table, $$->sym); - if($1 & MOD_STATIC) { - if(!strcmp($3->name, "Main")) { - if(main_method) + if ($1 & MOD_STATIC) { + if (!strcmp($3->name, "Main")) { + if (main_method) fprintf(stderr, "Warning: multiple definitions of a static Main()\n"); main_method = $3; @@ -418,9 +418,9 @@ * We can store these at parse time. */ store_symbol(current_symbol_table, $$->sym); - if($1 & MOD_STATIC) { - if(!strcmp($3->name, "Main")) { - if(main_method) + if ($1 & MOD_STATIC) { + if (!strcmp($3->name, "Main")) { + if (main_method) fprintf(stderr, "Warning: multiple definitions of a static Main()\n"); main_method = $3; @@ -481,7 +481,7 @@ '{' block_scope statement_list '}' { $$ = $3; - if($$) { + if ($$) { $$->vars = pop_scope(); } else { @@ -617,7 +617,7 @@ FOR '(' statement_expr ';' boolean_expr ';' statement_expr ')' embedded_statement { - if($3 == NULL) { + if ($3 == NULL) { printf("for_statement: NULL init statement\n"); exit(0); } @@ -803,7 +803,7 @@ method_call: primary_expr '(' arg_list ')' { - if($1->asttype != ASTT_IDENTIFIER) { + if ($1->asttype != ASTT_IDENTIFIER) { fprintf(stderr, "Error (line %d), method call must be a simple name or member access.\n", line); exit(0); } @@ -988,8 +988,8 @@ { fprintf(stderr, "Cola - Copyright (C) 2002 Melvin Smith <[EMAIL PROTECTED]>\n"); fprintf(stderr, "colac version %s\n\n", COLA_VERSION); - if(argc > 1) { - if(!(yyin = fopen(argv[1], "r"))) { + if (argc > 1) { + if (!(yyin = fopen(argv[1], "r"))) { printf( "Error reading source file %s.\n", argv[1] ); exit(0); } @@ -1040,7 +1040,7 @@ fprintf(stderr, "Pass 4: Code generation...\n"); - if(ast_start) { + if (ast_start) { gen_ast(ast_start); }