#!/usr/bin/perl # Convert forth source files to a giant C string $now = localtime; print <) { s"\n$""; # remove EOL s"\t" "g; # replace each tab with 4 spaces s/\"/\\\"/g; # escape quotes next if /^\s*\\\s*$/;# toss empty comments next if /^\s*$/; # toss empty lines if (/^\\\s\*\*/) { # emit / ** lines as C comments s"^\\ ""; if ($commenting == 0) { print "/*\n"; } $commenting = 1; print "$_\n"; next; } if ($commenting == 1) { print "*/\n"; } $commenting = 0; if (/^\\\s#/) { # pass commented preprocessor directives s"^\\ ""; print "$_\n"; next; } next if /^\s*\\ /; # toss all other comments s"\\\s+.*$"" ; # lop off trailing \ comments s"\s+$" "; # remove trailing space # # emit all other lines as quoted string fragments # $out = " \"" . $_ . " \\n\""; print "$out\n"; } if ($commenting == 1) { print "*/\n"; } print <