# New Ticket Created by Jürgen Bömmels # Please include the string: [perl #22535] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=22535 >
Hi, In many places in the code we use the idiom PIO_fprintf(interpreter, PIO_STDERR(interpreter), ...); But there is a function for doing exactly this PIO_eprintf(interpreter, ...); This may be slightly more optimal, but the main reason for this change is to make changes in the io-code more maintainable. bye boe -- attachment 1 ------------------------------------------------------ url: http://rt.perl.org/rt2/attach/58661/43655/54bbb2/eprintf.diff
Index: debug.c =================================================================== RCS file: /cvs/public/parrot/debug.c,v retrieving revision 1.77 diff -u -r1.77 debug.c --- debug.c 27 May 2003 18:06:48 -0000 1.77 +++ debug.c 2 Jun 2003 22:12:34 -0000 @@ -639,7 +639,7 @@ /* Don't do anything if there is already a breakpoint at this line */ if (sbreak && sbreak->skip > -1) { - PIO_fprintf(interpreter, PIO_STDERR(interpreter), + PIO_eprintf(interpreter, "Breakpoint %li already at line %li\n",i,line->number); return; } @@ -708,7 +708,7 @@ pdb->breakpoint = newbreak; } - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Breakpoint %li at line %li\n",i,line->number); + PIO_eprintf(interpreter, "Breakpoint %li at line %li\n",i,line->number); } /* PDB_init @@ -754,7 +754,7 @@ /* Restart if we are already running */ if (pdb->state & PDB_RUNNING) - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Restarting\n"); + PIO_eprintf(interpreter, "Restarting\n"); /* Get the bytecode start */ pdb->cur_opcode = interpreter->code->byte_code; @@ -775,7 +775,7 @@ /* Skip any breakpoint? */ if (command && *command) { if (!pdb->breakpoint) { - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"No breakpoints to skip\n"); + PIO_eprintf(interpreter, "No breakpoints to skip\n"); return; } ln = atol(command); @@ -873,7 +873,7 @@ /* Remove the RUNNING state */ pdb->state &= ~PDB_RUNNING; - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Program exited.\n"); + PIO_eprintf(interpreter, "Program exited.\n"); return 1; } @@ -1385,7 +1385,7 @@ pline = pline->next; if (!(pline)) { - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Label number %li out of bounds.\n",label->number); + PIO_eprintf(interpreter, "Label number %li out of bounds.\n",label->number); return; } @@ -1492,7 +1492,7 @@ /* abort if fopen failed */ if (!file) { - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Unable to load %s\n", f); + PIO_eprintf(interpreter, "Unable to load %s\n", f); return; } @@ -1609,14 +1609,14 @@ i = 1; while (line->next) { - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"%li ",pdb->file->list_line + i); + PIO_eprintf(interpreter, "%li ",pdb->file->list_line + i); /* If it has a label print it */ if (line->label) - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"L%li:\t",line->label->number); + PIO_eprintf(interpreter, "L%li:\t",line->label->number); c = pdb->file->source + line->source_offset; while (*c != '\n') - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"%c",*(c++)); - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"\n"); + PIO_eprintf(interpreter, "%c",*(c++)); + PIO_eprintf(interpreter, "\n"); line = line->next; if (i++ == n) break; @@ -1798,7 +1798,7 @@ PDB_print_stack_pmc(interpreter, command); break; default: - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Unknown argument \"%s\" to 'stack'\n", command); + PIO_eprintf(interpreter, "Unknown argument \"%s\" to 'stack'\n", command); break; } } @@ -1817,11 +1817,12 @@ if (!chunk) { i = depth / FRAMES_PER_INT_REG_CHUNK; - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"There are only %li frames\n",i); + PIO_eprintf(interpreter, "There are only %li frames\n",i); return; } - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Integer stack, frame %li, depth %li\n", i, depth); + PIO_eprintf(interpreter, "Integer stack, frame %li, depth %li\n", + i, depth); na(command); PDB_print_int(interpreter, &chunk->IReg[depth], atoi(command)); @@ -1840,11 +1841,11 @@ if (!chunk) { i = depth / FRAMES_PER_NUM_REG_CHUNK; - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"There are only %li frames\n",i); + PIO_eprintf(interpreter, "There are only %li frames\n",i); return; } - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Float stack, frame %li, depth %li\n", i, depth); + PIO_eprintf(interpreter, "Float stack, frame %li, depth %li\n", i, depth); na(command); PDB_print_num(interpreter, &chunk->NReg[depth], atoi(command)); @@ -1863,11 +1864,12 @@ if (!chunk) { i = depth / FRAMES_PER_STR_REG_CHUNK; - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"There are only %li frames\n",i); + PIO_eprintf(interpreter, "There are only %li frames\n",i); return; } - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"String stack, frame %li, depth %li\n", i, depth); + PIO_eprintf(interpreter, "String stack, frame %li, depth %li\n", + i, depth); na(command); PDB_print_string(interpreter,&chunk->SReg[depth], atoi(command)); @@ -1886,11 +1888,11 @@ if (!chunk) { i = depth / FRAMES_PER_PMC_REG_CHUNK; - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"There are only %li frames\n",i); + PIO_eprintf(interpreter, "There are only %li frames\n",i); return; } - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"PMC stack, frame %li, depth %li\n", i, depth); + PIO_eprintf(interpreter, "PMC stack, frame %li, depth %li\n", i, depth); na(command); PDB_print_pmc(interpreter,&chunk->PReg[depth], atoi(command), NULL); @@ -1900,14 +1902,13 @@ dump_string(struct Parrot_Interp *interpreter, STRING* s) { if (s) { - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"\tBuflen =\t%12ld\n",s->buflen); - PIO_fprintf(interpreter, PIO_STDERR(interpreter), - "\tFlags =\t%12ld\n", PObj_get_FLAGS(s)); - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"\tBufused =\t%12ld\n",s->bufused); - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"\tStrlen =\t%12ld\n",s->strlen); - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"\tOffset =\t%12d\n", - (char*) s->strstart - (char*) s->bufstart); - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"\tString =\t%S\n", s); + PIO_eprintf(interpreter, "\tBuflen =\t%12ld\n",s->buflen); + PIO_eprintf(interpreter, "\tFlags =\t%12ld\n", PObj_get_FLAGS(s)); + PIO_eprintf(interpreter, "\tBufused =\t%12ld\n",s->bufused); + PIO_eprintf(interpreter, "\tStrlen =\t%12ld\n",s->strlen); + PIO_eprintf(interpreter, "\tOffset =\t%12d\n", + (char*) s->strstart - (char*) s->bufstart); + PIO_eprintf(interpreter, "\tString =\t%S\n", s); } } @@ -1927,26 +1928,28 @@ switch (entry->entry_type) { case STACK_ENTRY_INT: - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Integer\t=\t%8vi\n",entry->entry.int_val); + PIO_eprintf(interpreter, "Integer\t=\t%8vi\n", + entry->entry.int_val); break; case STACK_ENTRY_FLOAT: - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Float\t=\t%8.4vf\n",entry->entry.num_val); + PIO_eprintf(interpreter, "Float\t=\t%8.4vf\n", + entry->entry.num_val); break; case STACK_ENTRY_STRING: - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"String =\n"); + PIO_eprintf(interpreter, "String =\n"); dump_string(interpreter, entry->entry.string_val); break; case STACK_ENTRY_PMC: - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"PMC =\n%PS\n", entry->entry.pmc_val); + PIO_eprintf(interpreter, "PMC =\n%PS\n", entry->entry.pmc_val); break; case STACK_ENTRY_POINTER: - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"POINTER\n"); + PIO_eprintf(interpreter, "POINTER\n"); break; case STACK_ENTRY_DESTINATION: - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"DESTINATION\n"); + PIO_eprintf(interpreter, "DESTINATION\n"); break; default: - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Invalid stack_entry_type!\n"); + PIO_eprintf(interpreter, "Invalid stack_entry_type!\n"); break; } } @@ -2030,12 +2033,12 @@ k = regnum + 1; } else { - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Integer Registers:\n"); + PIO_eprintf(interpreter, "Integer Registers:\n"); } for (i = j; i < k; i++) { - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"I%i =\t",i); - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"%11vi\n",int_reg->registers[i]); + PIO_eprintf(interpreter, "I%i =\t",i); + PIO_eprintf(interpreter, "%11vi\n",int_reg->registers[i]); } } @@ -2056,12 +2059,12 @@ k = regnum + 1; } else { - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Float Registers:\n"); + PIO_eprintf(interpreter, "Float Registers:\n"); } for (i = j; i < k; i++) { - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"N%i =\t",i); - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"%20.4f\n",num_reg->registers[i]); + PIO_eprintf(interpreter, "N%i =\t",i); + PIO_eprintf(interpreter, "%20.4f\n",num_reg->registers[i]); } } @@ -2083,11 +2086,11 @@ k = regnum + 1; } else { - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"String Registers:\n"); + PIO_eprintf(interpreter, "String Registers:\n"); } for (i = j; i < k; i++) { - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"S%i =\n",i); + PIO_eprintf(interpreter, "S%i =\n",i); dump_string(interpreter, string_reg->registers[i]); } } @@ -2100,7 +2103,7 @@ if (s) { PIO_eprintf(interpreter, " [%S]\n", s); } - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"Stringified: %PS\n", + PIO_eprintf(interpreter, "Stringified: %PS\n", VTABLE_get_string(interpreter, pmc)); } else { @@ -2123,15 +2126,15 @@ k = regnum + 1; } else { - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"PMC Registers:\n"); + PIO_eprintf(interpreter, "PMC Registers:\n"); } for (i = j; i < k; i++) { PMC* pmc = pmc_reg->registers[i]; - PIO_fprintf(interpreter, PIO_STDERR(interpreter),"P%i", i); + PIO_eprintf(interpreter, "P%i", i); if (key) trace_key_dump(interpreter, key); - PIO_fprintf(interpreter, PIO_STDERR(interpreter)," ="); + PIO_eprintf(interpreter, " ="); if (key) pmc = VTABLE_get_pmc_keyed(interpreter, pmc, key); print_pmc(interpreter, pmc); Index: hash.c =================================================================== RCS file: /cvs/public/parrot/hash.c,v retrieving revision 1.37 diff -u -r1.37 hash.c --- hash.c 19 May 2003 13:06:52 -0000 1.37 +++ hash.c 2 Jun 2003 22:12:34 -0000 @@ -91,8 +91,8 @@ dump_hash(Interp *interpreter, HASH *hash) { HashIndex i; - PIO_fprintf(interpreter, PIO_STDERR(interpreter), - "Hashtable[%vd/%vd]\n", hash->entries, hash->max_chain + 1); + PIO_eprintf(interpreter, "Hashtable[%vd/%vd]\n", hash->entries, + hash->max_chain + 1); /* Iterate one past the end of the hashtable, so we can use the * last value as a special case for dumping out the free bucket Index: embed.c =================================================================== RCS file: /cvs/public/parrot/embed.c,v retrieving revision 1.66 diff -u -r1.66 embed.c --- embed.c 1 Jun 2003 00:17:44 -0000 1.66 +++ embed.c 2 Jun 2003 22:12:35 -0000 @@ -153,7 +153,7 @@ if (NULL == program_code) { /* Whoops, out of memory. */ - PIO_fprintf(interpreter, PIO_STDERR(interpreter), + PIO_eprintf(interpreter, "Parrot VM: Could not allocate buffer to read packfile from PIO.\n"); return NULL; @@ -171,8 +171,8 @@ realloc(program_code, program_size + chunk_size); if (NULL == program_code) { - PIO_fprintf(interpreter, PIO_STDERR(interpreter), - "Parrot VM: Could not reallocate buffer while reading packfile from PIO.\n"); + PIO_eprintf(interpreter, + "Parrot VM: Could not reallocate buffer while reading packfile from PIO.\n"); return NULL; } @@ -180,7 +180,7 @@ } if (read_result < 0) { - PIO_fprintf(interpreter, PIO_STDERR(interpreter), + PIO_eprintf(interpreter, "Parrot VM: Problem reading packfile from PIO.\n"); return NULL; } @@ -265,7 +265,7 @@ PMC *userargv; if (Interp_flags_TEST(interpreter, PARROT_DEBUG_FLAG)) { - PIO_fprintf(interpreter, PIO_STDERR(interpreter), + PIO_eprintf(interpreter, "*** Parrot VM: Setting up ARGV array in P0. Current argc: %d ***\n", argc); }
-- Juergen Boemmels [EMAIL PROTECTED] Fachbereich Physik Tel: ++49-(0)631-205-2817 Universitaet Kaiserslautern Fax: ++49-(0)631-205-3906 PGP Key fingerprint = 9F 56 54 3D 45 C1 32 6F 23 F6 C7 2F 85 93 DD 47