diff --git a/Makefile b/Makefile index 03ba9ac..c14928f 100644 --- a/Makefile +++ b/Makefile @@ -1,79 +1,53 @@ -include $(GOROOT)/src/Make.inc - -TARG=github.com/knieriem/markdown -GOFILES=\ - markdown.go\ - output.go\ - parser.leg.go\ - -package: - -include $(GOROOT)/src/Make.pkg - -all: cmd +all: + @echo 'targets: test nuke parser clean' # -# mdtest runs MarkdownTests-1.0.3 that come with original C sources +# run MarkdownTests-1.0.3 that come with original C sources # -mdtest: package cmd orig-c-src - make -C cmd test +test: package cmd orig-c-src + cd orig-c-src/MarkdownTest_1.0.3; \ + ./MarkdownTest.pl --script=../../cmd/markdown/markdown --tidy cmd: package - make -C cmd + cd cmd/markdown && go build -v +package: parser.leg.go + go install -v -CLEANFILES=\ - parser.leg.go\ - _obj\ - ,,c\ - ,,fmt\ - -distclean: clean clean-sub +clean: + go clean . ./... rm -rf orig-c-src + rm -rf ,,prevmd ,,pmd + +parser: parser.leg.go -clean-sub: - for dir in cmd peg peg/leg; do make -C $$dir clean; done - - -VCS = git -GITHUB = git://github.com -# also, if hggit extension is available: -# VCS = hg -VCS-PULLFLAGS = +nuke: + rm -f parser.leg.go +# LEG parser rules # -# LEG parser generator stuff -# -LEG = ./peg/leg/leg +ifeq ($(MAKECMDGOALS),parser) +include $(shell go list -f '{{.Dir}}' github.com/knieriem/peg)/Make.inc %.leg.go: %.leg $(LEG) $(LEG) -switch $< -$(LEG): - if(! test -d peg); then make peg; fi - make -C peg all GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) - make -C peg/leg all GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) - -peg: - $(VCS) clone $(GITHUB)/knieriem/peg - -update-peg: - cd peg && $(VCS) pull $(VCS-PULLFLAGS) - cd peg/leg && make clean +endif # -# access to original C source files +# get access to original C source files # - orig-c-src: - $(VCS) clone $(GITHUB)/jgm/peg-markdown.git $@ - + hg clone git://github.com/jgm/peg-markdown.git $@ include misc/devel.mk .PHONY: \ + all\ cmd\ - distclean\ - mdtest\ + nuke\ + package\ + parser\ + test\ diff --git a/cmd/Makefile b/cmd/Makefile deleted file mode 100644 index 2aa0bec..0000000 --- a/cmd/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -include $(GOROOT)/src/Make.inc - -TARG=markdown -GOFILES=\ - main.go\ - -LIBMD = github.com/knieriem/markdown -R = .. -PREREQ += $(R)/_obj/$(LIBMD).a - -include $(GOROOT)/src/Make.cmd - - -test: $(TARG) - cd $(R)/orig-c-src/MarkdownTest_1.0.3; \ - ./MarkdownTest.pl --script=../../cmd/$< --tidy diff --git a/cmd/main.go b/cmd/markdown/main.go similarity index 96% rename from cmd/main.go rename to cmd/markdown/main.go index b49d524..0e10ddb 100644 --- a/cmd/main.go +++ b/cmd/markdown/main.go @@ -1,9 +1,9 @@ package main import ( - "../_obj/github.com/knieriem/markdown" "flag" "fmt" + "github.com/knieriem/markdown" "os" "bufio" "io/ioutil" diff --git a/misc/benchmark.rc b/misc/benchmark.rc index c9d271a..4d3d79e 100644 --- a/misc/benchmark.rc +++ b/misc/benchmark.rc @@ -1,12 +1,13 @@ #!/usr/local/plan9/bin/rc nrun=20 +md=./cmd/markdown/markdown fn timego{ - run ./cmd/markdown go + run $md go } fn timegoprev{ - run ./,,prevmd/cmd/markdown goprev + run ./,,prevmd/src/github.com/knieriem/markdown/$md goprev } fn timec{ diff --git a/misc/bmprepare.rc b/misc/bmprepare.rc index 9d4dfb1..dc2be72 100644 --- a/misc/bmprepare.rc +++ b/misc/bmprepare.rc @@ -3,26 +3,28 @@ flag e + fn updatetree{ # hg-id dir hg-url make-target + wd=`{pwd} if (test -d $2) { cd $2 if (! ~ `{hg id -n} $1) { hg update $1 make $4 } - cd .. + cd $wd } if (! test -d $2) { hg clone $3 $2 cd $2 hg update $1 make $4 - cd .. + cd $wd } ~ 0 0 } test -f portid test -f previd +mkdir -p ,,prevmd/src/github.com/knieriem id=`{cat portid} echo '*' prepare original c-based peg-markdown $id @@ -30,4 +32,6 @@ updatetree $id ,,pmd git://github.com/jgm/peg-markdown.git () id=`{cat previd} echo '*' prepare "previous version" $id -updatetree $id ,,prevmd . all +cd ,,prevmd +GOPATH=`{pwd} +updatetree $id src/github.com/knieriem/markdown .. cmd diff --git a/misc/devel.mk b/misc/devel.mk index 9f35799..9264ed9 100644 --- a/misc/devel.mk +++ b/misc/devel.mk @@ -1,3 +1,5 @@ +MD=./cmd/markdown/markdown + # # development utilities # @@ -24,9 +26,9 @@ benchmark: m ,,pmd ,,prevmd # pprof # pprof: cmd m - ./cmd/markdown -cpuprofile /tmp/md.prof /tmp/,,md.out - @echo gopprof \'--nodefraction=0.1\' ./cmd/markdown /tmp/md.prof - @echo gopprof ./cmd/markdown /tmp/md.prof + $(MD) -cpuprofile /tmp/md.prof /tmp/,,md.out + @echo gopprof \'--nodefraction=0.1\' $(MD) /tmp/md.prof + @echo gopprof $(MD) /tmp/md.prof .PHONY:\ diff\ diff --git a/output.go b/output.go index 52d834d..a106a9c 100644 --- a/output.go +++ b/output.go @@ -28,7 +28,7 @@ import ( type Writer interface { WriteString(string) (int, error) - WriteRune(int) (int, error) + WriteRune(rune) (int, error) WriteByte(byte) error }