Skip to content

Commit

Permalink
= AWKPaste prerequites =
Browse files Browse the repository at this point in the history
Taking care of a small subset of the prerequisites for awkpaste.  Also,
preparing to rename 'lib/' to 'src/'.

== Build process ==
 * Adding a Makefile to enable a build process as an optimizatoin for awkpaste
   and possibly awkbot, although awkbot has special needs.
    * note: cpp still outputs metric fucktons of warnings as a result of normal
      comments, this should be corrected through whatever means is necessary
      even if it means just figuring out a reasonable way for hiding a
      particular class of warning
 * Added bin/teststrap - a little script to run the tests in t/ and report on
   their status.  Doesn't work particularly well.  Things needed on it:
    * Return error code properly
    * Report success/failure accordingly though stderr
    * Might want to build it into the makefile, actually
 * Added a cpp-filter sed script, this is probably temporary as I've discovered
   it doesn't particularly work well due to the fact that it is unable to
   filter all files that are included

== Additional ==
 * Found atleast one more include directive.  include doesn't work very well
   with awk, so import is being used instead despite the fact that it's a
   deprecated feature.
 * Added lib/tempfile.awk since several things are now dependent upon it


git-svn-id: http://svn.blisted.org/trunk/awkbot@48 ebfa9934-6f10-0410-9599-894cdf3d53f0
  • Loading branch information
scott committed Jul 27, 2007
1 parent fd8d688 commit 42666a6
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 4 deletions.
13 changes: 13 additions & 0 deletions Makefile
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,13 @@

# Awkbot makefile, mostly just to bootstrap the test suite, but will also run
# cpp to perminantly generate awkbot and awkpaste..

awkbot:
cpp -I /usr/share/awk -I lib lib/awkbot-boot.awk 2> /dev/null > bootstrap
cpp -I /usr/share/awk/ -I lib lib/awkbot.awk 2> /dev/null > bootstrap

awkpaste:
cpp -I /usr/share/awk -I lib lib/awkpaste.awk 2> /dev/null > awkpaste

test:
./bin/teststrap
18 changes: 18 additions & 0 deletions bin/teststrap
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

failed=1

for file in t/*.awk
do
tmpfile=`tempfile`
echo processing $file
# Strip comments, stolen from perl!
sed -f cpp-filter.sed $file | cpp -I lib -I /usr/share/awk > $tmpfile
echo running $file
awk -f $tmpfile
if [ $? = 1 ]
then
echo "$file failed"
failed=`expr $failed + 1`
fi
done
28 changes: 28 additions & 0 deletions cpp-filter.sed
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,28 @@
# if it's a comment
/^ *#/ {

# The below would look like this, if it wasn't so way too long to fit
# within a terminal
# /^ *#
# *\(\(if\|ifn\|un\)def\|if\|\(el\|end\)if\|define\|include\|import
# \|else\|error\|pragma\)/b
# print

# if it's a preprocessing directive, or atleast looks like one, leave it.
/^ *# *if/p
/^ *# *else/p
/^ *# *ifdef/p
/^ *# *ifndef/p
/^ *# *undef/p
/^ *# *define/p
/^ *# *include/p
/^ *# *import/p
/^ *# *else/p
/^ *# *elif/p
/^ *# *endif/p
/^ *# *error/p
/^ *# *pragma/p
/^ *# *line/p
# Just delete everything else
d
}
2 changes: 1 addition & 1 deletion lib/awkbot.awk
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ END {
} }


# Nasty hack to clean up every few records # Nasty hack to clean up every few records
NR % 3 == 0 { NR % 10000 == 0 {
print "DEBUG: Truncating file.." print "DEBUG: Truncating file.."
printf "" > irc["tempfile"] printf "" > irc["tempfile"]
fflush(irc["tempfile"]) fflush(irc["tempfile"])
Expand Down
2 changes: 1 addition & 1 deletion lib/queue.awk
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# this stuff is worth it, you can buy me a beer in return. Scott S. McCoy # this stuff is worth it, you can buy me a beer in return. Scott S. McCoy
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------


#include <assert.awk> #import <assert.awk>


function push (array, value,i) { function push (array, value,i) {
i = sizeof(array) + 1 i = sizeof(array) + 1
Expand Down
8 changes: 8 additions & 0 deletions lib/tempfile.awk
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,8 @@

function tempfile (prefix ,call,result) {
call = "tempfile -p " prefix
call | getline result
close(call)
return result
}

2 changes: 1 addition & 1 deletion t/irc_test.awk
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@

#import <irc.awk>
BEGIN { BEGIN {
irc_set("debug", 1) irc_set("debug", 1)


Expand Down
2 changes: 1 addition & 1 deletion t/queue_test.awk
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
# test queue.awk # test queue.awk
#include <queue.awk> #import <queue.awk>


BEGIN { BEGIN {
push(queue, 1) push(queue, 1)
Expand Down

0 comments on commit 42666a6

Please sign in to comment.