I've updated my last patch and split it into three pieces. It's all fairly trivial. First, some simple POD fixups to core.ops. Second, a few minor code tweaks to silence a few compiler or lint warnings. Third, a change to the makefile to turn on -Wall and (optionally) -pedantic for gcc users.
Here they are (attached): -- Josh Wilmes ([EMAIL PROTECTED]) | http://www.hitchhiker.org
Index: Configure.pl =================================================================== RCS file: /home/perlcvs/parrot/Configure.pl,v retrieving revision 1.44 diff -u -r1.44 Configure.pl --- Configure.pl 26 Dec 2001 05:12:25 -0000 1.44 +++ Configure.pl 30 Dec 2001 07:36:34 -0000 @@ -9,7 +9,7 @@ use ExtUtils::Manifest qw(manicheck); use File::Copy; -my($opt_debugging, $opt_defaults, $opt_version, $opt_help) = (0, 0, 0, 0); +my($opt_debugging, $opt_defaults, $opt_version, $opt_help, $opt_pedantic) = (0, 0, 0, 0, 0); my(%opt_defines); my $result = GetOptions( 'debugging!' => \$opt_debugging, @@ -17,6 +17,7 @@ 'version' => \$opt_version, 'help' => \$opt_help, 'define=s' => \%opt_defines, + 'pedantic!' => \$opt_pedantic, ); if($opt_version) { @@ -29,6 +30,7 @@ $0 - Parrot Configure Options: --debugging Enable debugging + --pedantic Add "-ansi -pedantic" if using gcc --defaults Accept all default values --define name=value Defines value name as value --help This text @@ -93,9 +95,11 @@ cc => $Config{cc}, #ADD C COMPILER FLAGS HERE + cc_inc => "-I./include", ccflags => $Config{ccflags}, libs => $Config{libs}, cc_debug => '-g', + cc_warn => '', o => '.o', # object files extension exe => $Config{_exe}, @@ -129,6 +133,15 @@ cp => 'cp', slash => '/', ); + + +# If using gcc, crank up its warnings as much as possible and make it behave +# ansi-ish. +if ($Config{ccname} eq "gcc") { + $c{cc_warn} = " -Wall"; + $c{cc_warn} .= " -ansi -pedantic" if $opt_pedantic; +} + #copy the things from --define foo=bar @c{keys %opt_defines}=values %opt_defines; Index: Makefile.in =================================================================== RCS file: /home/perlcvs/parrot/Makefile.in,v retrieving revision 1.85 diff -u -r1.85 Makefile.in --- Makefile.in 27 Dec 2001 23:57:58 -0000 1.85 +++ Makefile.in 30 Dec 2001 07:36:34 -0000 @@ -24,7 +24,7 @@ #DO NOT ADD C COMPILER FLAGS HERE #Add them in Configure.pl--look for the #comment 'ADD C COMPILER FLAGS HERE' -CFLAGS = ${ccflags} ${cc_debug} -I./include +CFLAGS = ${ccflags} ${cc_warn} ${cc_debug} ${cc_inc} C_LIBS = ${libs} @@ -33,6 +33,8 @@ PERL = ${perl} TEST_PROG = ${test_prog} PDUMP = pdump${exe} +LINT = lclint +LINTFLAGS = +showscan +posixlib -weak +longintegral +matchanyintegral -formattype # This is set to MAKE=$make if your $make command doesn't # do it for you. ${make_set_make} @@ -191,3 +193,6 @@ update: cvs -q update -dP +lint: ${test_prog} + $(LINT) ${cc_inc} -Iclasses $(LINTFLAGS) `echo $(O_FILES) | sed 's/\.o/\.c/g'` + $(LINT) ${cc_inc} $(LINTFLAGS) test_main.c
Index: packfile.c =================================================================== RCS file: /home/perlcvs/parrot/packfile.c,v retrieving revision 1.16 diff -u -r1.16 packfile.c --- packfile.c 6 Dec 2001 21:22:13 -0000 1.16 +++ packfile.c 30 Dec 2001 07:36:37 -0000 @@ -333,7 +333,7 @@ if (segment_size % sizeof(opcode_t)) { fprintf(stderr, "PackFile_unpack: Illegal fixup table segment size %d (must be multiple of %d)!\n", - segment_size, sizeof(opcode_t)); + (int)segment_size, sizeof(opcode_t)); return 0; } @@ -358,7 +358,7 @@ if (segment_size % sizeof(opcode_t)) { fprintf(stderr, "PackFile_unpack: Illegal constant table segment size %d (must be multiple of %d)!\n", - segment_size, sizeof(opcode_t)); + (int)segment_size, sizeof(opcode_t)); return 0; } @@ -1718,7 +1718,8 @@ (long) self->string->bufused); /* TODO: Won't do anything reasonable for most encodings */ printf(" DATA => '%.*s'\n", - self->string->bufused, (char *) self->string->bufstart); + (int)self->string->bufused, + (char *) self->string->bufstart); printf(" } ],\n"); break; Index: pdump.c =================================================================== RCS file: /home/perlcvs/parrot/pdump.c,v retrieving revision 1.6 diff -u -r1.6 pdump.c --- pdump.c 6 Dec 2001 17:48:58 -0000 1.6 +++ pdump.c 30 Dec 2001 07:36:37 -0000 @@ -62,7 +62,10 @@ pf = PackFile_new(); - PackFile_unpack(interpreter, pf, packed, packed_size); + if (!PackFile_unpack(interpreter, pf, packed, packed_size)) { + printf( "Can't unpack.\n" ); + return 1; + } PackFile_dump(pf); PackFile_DELETE(pf); Index: register.c =================================================================== RCS file: /home/perlcvs/parrot/register.c,v retrieving revision 1.13 diff -u -r1.13 register.c --- register.c 29 Dec 2001 22:12:37 -0000 1.13 +++ register.c 30 Dec 2001 07:36:37 -0000 @@ -314,7 +314,7 @@ Parrot_clear_n(struct Parrot_Interp *interpreter) { int i; for (i=0; i<NUM_REGISTERS; i++) { - interpreter->num_reg->registers[i] = 0; + interpreter->num_reg->registers[i] = 0.0; } } Index: string.c =================================================================== RCS file: /home/perlcvs/parrot/string.c,v retrieving revision 1.27 diff -u -r1.27 string.c --- string.c 29 Dec 2001 22:12:37 -0000 1.27 +++ string.c 30 Dec 2001 07:36:38 -0000 @@ -48,7 +48,7 @@ s->encoding = encoding; s->buflen = s->bufused = buflen; s->flags = flags; - string_compute_strlen(s); + (void)string_compute_strlen(s); s->type = type; return s; Index: include/parrot/key.h =================================================================== RCS file: /home/perlcvs/parrot/include/parrot/key.h,v retrieving revision 1.2 diff -u -r1.2 key.h --- include/parrot/key.h 12 Dec 2001 02:12:15 -0000 1.2 +++ include/parrot/key.h 30 Dec 2001 07:36:38 -0000 @@ -46,6 +46,7 @@ INTVAL key_size(struct Parrot_Interp *interpreter, KEY *key); void key_set_size(struct Parrot_Interp *interpreter, KEY *key, INTVAL size); void key_destroy(struct Parrot_Interp *interpreter, KEY *key); +INTVAL key_element_type(struct Parrot_Interp *interpreter, KEY* key, INTVAL index); KEY_PAIR* key_element_value_i(struct Parrot_Interp *interpreter, KEY *key, INTVAL index); KEY_PAIR* key_element_value_s(struct Parrot_Interp *interpreter, KEY *key, STRING* index); void key_set_element_value_i(struct Parrot_Interp *interpreter, KEY *key, INTVAL index, KEY_PAIR* value); Index: include/parrot/trace.h =================================================================== RCS file: /home/perlcvs/parrot/include/parrot/trace.h,v retrieving revision 1.2 diff -u -r1.2 trace.h --- include/parrot/trace.h 13 Dec 2001 16:21:55 -0000 1.2 +++ include/parrot/trace.h 30 Dec 2001 07:36:38 -0000 @@ -19,6 +19,9 @@ trace_op_dump(struct Parrot_Interp *interpreter, opcode_t *code_start, opcode_t *pc); void +trace_op(struct Parrot_Interp *interpreter, opcode_t * code_start, opcode_t * code_end, opcode_t *pc); + +void trace_op_b0(struct Parrot_Interp *interpreter, opcode_t * code_start, opcode_t *pc); void Index: platforms/generic.c =================================================================== RCS file: /home/perlcvs/parrot/platforms/generic.c,v retrieving revision 1.3 diff -u -r1.3 generic.c --- platforms/generic.c 27 Dec 2001 17:08:48 -0000 1.3 +++ platforms/generic.c 30 Dec 2001 07:36:38 -0000 @@ -2,6 +2,7 @@ ** platform.c [generic version] */ +#include <time.h> #include <sys/time.h> #include <dlfcn.h>
Index: core.ops =================================================================== RCS file: /home/perlcvs/parrot/core.ops,v retrieving revision 1.60 diff -u -r1.60 core.ops --- core.ops 28 Dec 2001 21:20:19 -0000 1.60 +++ core.ops 30 Dec 2001 07:36:35 -0000 @@ -73,7 +73,7 @@ ######################################## -=item close(i|ic) +=item B<close>(i|ic) Close file opened on file descriptor $1. @@ -87,11 +87,11 @@ ######################################## -=item err(i) +=item B<err>(i) Store the system error code in $1. -=item err(s) +=item B<err>(s) Store the system error message in $1. @@ -329,15 +329,15 @@ ######################################## -=item read(i, i|ic) +=item B<read>(i, i|ic) Read an INTVAL from file descriptor $2 into $1. -=item read(n, i|ic) +=item B<read>(n, i|ic) Read a FLOATVAL from file descriptor $2 into $1. -=item read(s, i|ic, i|ic) +=item B<read>(s, i|ic, i|ic) Read $3 bytes from file descriptor $2 into string $1. @@ -400,11 +400,11 @@ ######################################## -=item write(i|ic, i|ic) +=item B<write>(i|ic, i|ic) -=item write(i|ic, n|nc) +=item B<write>(i|ic, n|nc) -=item write(i|ic, s|sc) +=item B<write>(i|ic, s|sc) Write $2 to file descriptor $1. @@ -1065,6 +1065,7 @@ =over 4 =cut + ######################################## =item B<abs>(i|n, i|ic|n|nc) @@ -1130,22 +1131,23 @@ NOTE: This "uncorrected mod" algorithm uses the C language's built-in mod operator (x % y), which is - ... the remainder when x is divided by y, and thus is zero when y - divides x exactly. + ... the remainder when x is divided by y, and thus is zero + when y divides x exactly. ... - The direction of truncation for / and the sign of the result for % - are machine-dependent for negative operands, as is the action taken - on overflow or underflow. - -- [1], page 41 + The direction of truncation for / and the sign of the result + for % are machine-dependent for negative operands, as is the + action taken on overflow or underflow. + -- [1], page 41 Also: - ... if the second operand is 0, the result is undefined. Otherwise, it - is always true that (a/b)*b + a%b is equal to z. If both operands are - non-negative, then the remainder is non-negative and smaller than the - divisor; if not, it is guaranteed only that the absolute value of the - remainder is smaller than the absolute value of the divisor. - -- [1], page 205 + ... if the second operand is 0, the result is undefined. + Otherwise, it is always true that (a/b)*b + a%b is equal to z. If + both operands are non-negative, then the remainder is non- + negative and smaller than the divisor; if not, it is guaranteed + only that the absolute value of the remainder is smaller than + the absolute value of the divisor. + -- [1], page 205 This op is provided for those who need it (such as speed-sensitive applications with heavy use of mod, but using it only with positive @@ -1176,15 +1178,15 @@ NOTE: This "uncorrected mod" algorithm uses the built-in C math library's fmod() function, which computes - ... the remainder of dividing x by y. The return value is x - n * y, - where n is the quotient of x / y, rounded towards zero to an - integer. - -- fmod() manpage on RedHat Linux 7.0 + ... the remainder of dividing x by y. The return value is + x - n * y, where n is the quotient of x / y, rounded towards + zero to an integer. + -- fmod() manpage on RedHat Linux 7.0 In addition, fmod() returns - the remainder, unless y is zero, when the function fails and errno - is set. + the remainder, unless y is zero, when the function fails and + errno is set. According to page 251 of [1], the result when y is zero is implementation- defined. @@ -1497,6 +1499,8 @@ These operations operate on STRINGs. +=over 4 + =cut @@ -2354,6 +2358,23 @@ } +######################################## + +=item B<rotate_up>(i) + +=item B<rotate_up>(ic) + +Rotate the top $1 entries in the user stack so that the top entry +becomes the bottom entry in that range. + +=cut + +inline op rotate_up(i|ic) { + rotate_entries(interpreter, interpreter->user_stack_base, interpreter->user_stack_top, $1); + goto NEXT(); +} + + =back =cut @@ -2367,6 +2388,7 @@ =over 4 +=cut ######################################## @@ -2422,6 +2444,20 @@ goto OFFSET($1); } +=back + +=cut + +############################################################################### + +=head2 Miscellaneous + +Opcodes which need to be sorted into better categories. + +=over 4 + +=cut + ######################################## =item B<newinterp>(p, i|ic) @@ -2492,27 +2528,6 @@ ######################################## -=item B<rotate_up>(i) - -=item B<rotate_up>(ic) - -Rotate the top $1 entries in the user stack so that the top entry -becomes the bottom entry in that range. - -=cut - -inline op rotate_up(i|ic) { - rotate_entries(interpreter, interpreter->user_stack_base, interpreter->user_stack_top, $1); - goto NEXT(); -} - - -=back - -=cut - -######################################## - =item B<sleep>(i) =item B<sleep>(ic) @@ -2596,6 +2611,10 @@ $1 = interpreter->current_package; goto NEXT(); } + +=back + +=cut ###############################################################################