#!/usr/pkg/bin/perl
# bwbport.pl - Port BASIC source from MicroSoft BASIC to Bywater BASIC

while (<>) {

       # Automatic fixes ...
       $_ =~ s/^([0-9]+ +REM)(\w)/\1 REM\2/;
       $_ =~ s/^([0-9]+ +REM)([-*])/\1 \2/;
       $_ =~ s/PRINT:/PRINT :/g;

       # Fix by hand ...
       if ($_ =~ /^([0-9]+) .*: *NEXT/) {
               print STDERR "*** Line $1: NEXT not first command on line\n";
       }
       if ($_ =~ /^([0-9]+) .* STEP +[0-9]+\.[0-9]/) {
               print STDERR "*** Line $1: Non-integer STEP on FOR loop\n";
       }

       print $_;
}