docs/master

changeset 234:eba3744fb238

Added my set of helper scripts. Removes the spell makefile target as it was not use{d,ful} anyway. Btw: I should have ran script/doubles before I printed the document. :-/
author markus schnalke <meillo@marmaro.de>
date Mon, 16 Jul 2012 11:23:30 +0200
parents 348b92755bef
children e58400695ae2
files .hgignore makefile scripts/avg-switches scripts/create-deps scripts/doubles scripts/grep-hidden-switches scripts/list-all-switches scripts/list-all-switches-code scripts/makedeps2dot scripts/wordfreq
diffstat 10 files changed, 112 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/.hgignore	Mon Jul 16 08:26:17 2012 +0200
     1.2 +++ b/.hgignore	Mon Jul 16 11:23:30 2012 +0200
     1.3 @@ -1,17 +1,9 @@
     1.4  syntax: glob
     1.5  
     1.6 -fonts/unused
     1.7 -project-masqmail
     1.8  old
     1.9  
    1.10  thesis.ps
    1.11 -thesis-book.ps
    1.12  thesis.pdf
    1.13  
    1.14  *.ig
    1.15  refs/
    1.16 -
    1.17 -
    1.18 -drafts
    1.19 -aaron
    1.20 -scripts
     2.1 --- a/makefile	Mon Jul 16 08:26:17 2012 +0200
     2.2 +++ b/makefile	Mon Jul 16 11:23:30 2012 +0200
     2.3 @@ -45,7 +45,3 @@
     2.4  	rm -f $(NAME).ps $(NAME).pdf book.ps book.pdf
     2.5  	rm -rf refs
     2.6  	rm -f *.ig
     2.7 -
     2.8 -spell:
     2.9 -	sort -u -o terms terms
    2.10 -	spell +terms *.roff | egrep -v '[0-9a-f]{40}'
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/scripts/avg-switches	Mon Jul 16 11:23:30 2012 +0200
     3.3 @@ -0,0 +1,13 @@
     3.4 +#!/bin/sh
     3.5 +#
     3.6 +# helper script to calculate the average number of switches
     3.7 +
     3.8 +awk '
     3.9 +{
    3.10 +	n1+=$2; n2+=$3; m1+=$4; m2+=$5
    3.11 +}
    3.12 +END {
    3.13 +	printf("avg\t%d\t%d\t%d\t%d\n", n1/NR-2, n2/NR, m1/NR-2, m2/NR)
    3.14 +	printf("sum\t%d\t%d\t%d\t%d\n",
    3.15 +			n1-(NR*2), n2-(NR*2), m1-(NR*2), m2-(NR*2))
    3.16 +}' "$@"
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/scripts/create-deps	Mon Jul 16 11:23:30 2012 +0200
     4.3 @@ -0,0 +1,12 @@
     4.4 +#!/bin/sh
     4.5 +#
     4.6 +# Generate EPS files of the build dependency graph.
     4.7 +#
     4.8 +# Depends on dot(1) from GraphViz.
     4.9 +
    4.10 +if [ $# -ne 1 ] ; then
    4.11 +	echo "Usage: $0 uip/Makefile.in" >&2
    4.12 +	exit 1
    4.13 +fi
    4.14 +
    4.15 +awk -f makedeps2dot "$1" | dot -Teps -o deps_`date +%F`.eps
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/scripts/doubles	Mon Jul 16 11:23:30 2012 +0200
     5.3 @@ -0,0 +1,5 @@
     5.4 +#!/bin/sh
     5.5 +#
     5.6 +# Find doubled words
     5.7 +
     5.8 +grep -r -i --color '\(\<[-a-z.0-9]*\>\) \<\1\>' "$@"
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/scripts/grep-hidden-switches	Mon Jul 16 11:23:30 2012 +0200
     6.3 @@ -0,0 +1,5 @@
     6.4 +#!/bin/sh
     6.5 +#
     6.6 +# Find hidden switches in mmh source code.
     6.7 +
     6.8 +grep '{.*-[0-9][0-9]* *}' "$@"
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/scripts/list-all-switches	Mon Jul 16 11:23:30 2012 +0200
     7.3 @@ -0,0 +1,10 @@
     7.4 +#!/bin/sh
     7.5 +#
     7.6 +# List (approximately) all documented switches of all mmh programs.
     7.7 +# Based on the man pages.
     7.8 +
     7.9 +for i in "$@" ; do
    7.10 +        echo
    7.11 +        echo $i
    7.12 +        sed '/^\.ad/q' $i | grep 'B.*\\-'|sort
    7.13 +done
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/scripts/list-all-switches-code	Mon Jul 16 11:23:30 2012 +0200
     8.3 @@ -0,0 +1,10 @@
     8.4 +#!/bin/sh
     8.5 +#
     8.6 +# List all switches of all mmh programs.
     8.7 +# Based on the source code.
     8.8 +
     8.9 +for i in "$@" ; do
    8.10 +	echo "$i"
    8.11 +	sed -n '/^#define/d;/struct swit [a-z]*switches\[\]/,/^};/p' "$i"
    8.12 +	echo
    8.13 +done
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/scripts/makedeps2dot	Mon Jul 16 11:23:30 2012 +0200
     9.3 @@ -0,0 +1,51 @@
     9.4 +#!/usr/bin/env awk
     9.5 +#
     9.6 +# List dependencies in Makefile input,
     9.7 +# ignore a set of default targets and 1:1 dependencies
     9.8 +# and generate dot graph output
     9.9 +
    9.10 +BEGIN {
    9.11 +	FS = " *: *"
    9.12 +
    9.13 +	ignore["all"] = 1
    9.14 +	ignore["configure"] = 1
    9.15 +	ignore["Makefile"] = 1
    9.16 +	ignore["install"] = 1
    9.17 +	ignore["uninstall"] = 1
    9.18 +	ignore["clean"] = 1
    9.19 +	ignore["distclean"] = 1
    9.20 +	ignore["realclean"] = 1
    9.21 +	ignore["mostlyclean"] = 1
    9.22 +	ignore["superclean"] = 1
    9.23 +	ignore["mmhdist"] = 1
    9.24 +	ignore["lint"] = 1
    9.25 +
    9.26 +	print "digraph foo {"
    9.27 +}
    9.28 +
    9.29 +/^\t/ {
    9.30 +	next
    9.31 +}
    9.32 +
    9.33 +$1 ~ /^[a-zA-Z_]+$/ {
    9.34 +	if ($1 in ignore) {
    9.35 +		next
    9.36 +	}
    9.37 +	split($2, dep, /[ \t]+/)
    9.38 +	for (i in dep) {
    9.39 +		if (dep[i] ~ /^\$/) {
    9.40 +			continue
    9.41 +		}
    9.42 +		if (dep[i] ~ "^"$1"\\.(o|sh)$") {
    9.43 +			continue
    9.44 +		}
    9.45 +		sub(/\.o$/, ".c", dep[i]);
    9.46 +		print "\t\"" dep[i] "\" [shape=box];"
    9.47 +		print "\t\"" dep[i] "\" -> \"" $1 "\";"
    9.48 +	}
    9.49 +	print ""
    9.50 +}
    9.51 +
    9.52 +END {
    9.53 +	print "}"
    9.54 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/scripts/wordfreq	Mon Jul 16 11:23:30 2012 +0200
    10.3 @@ -0,0 +1,6 @@
    10.4 +#!/bin/sh
    10.5 +#
    10.6 +# print frequency of words
    10.7 +
    10.8 +deroff "$@" | tr -cs A-Za-z '\012' | tr A-Z a-z |
    10.9 +	sort | uniq -c | sort -nr | sed 20q