# HG changeset patch # User markus schnalke # Date 1342430610 -7200 # Node ID eba3744fb238da3264e1738a06566cf64c8939a2 # Parent 348b92755bef076fc0c3101bfe945413acfe6acd 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. :-/ diff -r 348b92755bef -r eba3744fb238 .hgignore --- a/.hgignore Mon Jul 16 08:26:17 2012 +0200 +++ b/.hgignore Mon Jul 16 11:23:30 2012 +0200 @@ -1,17 +1,9 @@ syntax: glob -fonts/unused -project-masqmail old thesis.ps -thesis-book.ps thesis.pdf *.ig refs/ - - -drafts -aaron -scripts diff -r 348b92755bef -r eba3744fb238 makefile --- a/makefile Mon Jul 16 08:26:17 2012 +0200 +++ b/makefile Mon Jul 16 11:23:30 2012 +0200 @@ -45,7 +45,3 @@ rm -f $(NAME).ps $(NAME).pdf book.ps book.pdf rm -rf refs rm -f *.ig - -spell: - sort -u -o terms terms - spell +terms *.roff | egrep -v '[0-9a-f]{40}' diff -r 348b92755bef -r eba3744fb238 scripts/avg-switches --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/avg-switches Mon Jul 16 11:23:30 2012 +0200 @@ -0,0 +1,13 @@ +#!/bin/sh +# +# helper script to calculate the average number of switches + +awk ' +{ + n1+=$2; n2+=$3; m1+=$4; m2+=$5 +} +END { + printf("avg\t%d\t%d\t%d\t%d\n", n1/NR-2, n2/NR, m1/NR-2, m2/NR) + printf("sum\t%d\t%d\t%d\t%d\n", + n1-(NR*2), n2-(NR*2), m1-(NR*2), m2-(NR*2)) +}' "$@" diff -r 348b92755bef -r eba3744fb238 scripts/create-deps --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/create-deps Mon Jul 16 11:23:30 2012 +0200 @@ -0,0 +1,12 @@ +#!/bin/sh +# +# Generate EPS files of the build dependency graph. +# +# Depends on dot(1) from GraphViz. + +if [ $# -ne 1 ] ; then + echo "Usage: $0 uip/Makefile.in" >&2 + exit 1 +fi + +awk -f makedeps2dot "$1" | dot -Teps -o deps_`date +%F`.eps diff -r 348b92755bef -r eba3744fb238 scripts/doubles --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/doubles Mon Jul 16 11:23:30 2012 +0200 @@ -0,0 +1,5 @@ +#!/bin/sh +# +# Find doubled words + +grep -r -i --color '\(\<[-a-z.0-9]*\>\) \<\1\>' "$@" diff -r 348b92755bef -r eba3744fb238 scripts/grep-hidden-switches --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/grep-hidden-switches Mon Jul 16 11:23:30 2012 +0200 @@ -0,0 +1,5 @@ +#!/bin/sh +# +# Find hidden switches in mmh source code. + +grep '{.*-[0-9][0-9]* *}' "$@" diff -r 348b92755bef -r eba3744fb238 scripts/list-all-switches --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/list-all-switches Mon Jul 16 11:23:30 2012 +0200 @@ -0,0 +1,10 @@ +#!/bin/sh +# +# List (approximately) all documented switches of all mmh programs. +# Based on the man pages. + +for i in "$@" ; do + echo + echo $i + sed '/^\.ad/q' $i | grep 'B.*\\-'|sort +done diff -r 348b92755bef -r eba3744fb238 scripts/list-all-switches-code --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/list-all-switches-code Mon Jul 16 11:23:30 2012 +0200 @@ -0,0 +1,10 @@ +#!/bin/sh +# +# List all switches of all mmh programs. +# Based on the source code. + +for i in "$@" ; do + echo "$i" + sed -n '/^#define/d;/struct swit [a-z]*switches\[\]/,/^};/p' "$i" + echo +done diff -r 348b92755bef -r eba3744fb238 scripts/makedeps2dot --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/makedeps2dot Mon Jul 16 11:23:30 2012 +0200 @@ -0,0 +1,51 @@ +#!/usr/bin/env awk +# +# List dependencies in Makefile input, +# ignore a set of default targets and 1:1 dependencies +# and generate dot graph output + +BEGIN { + FS = " *: *" + + ignore["all"] = 1 + ignore["configure"] = 1 + ignore["Makefile"] = 1 + ignore["install"] = 1 + ignore["uninstall"] = 1 + ignore["clean"] = 1 + ignore["distclean"] = 1 + ignore["realclean"] = 1 + ignore["mostlyclean"] = 1 + ignore["superclean"] = 1 + ignore["mmhdist"] = 1 + ignore["lint"] = 1 + + print "digraph foo {" +} + +/^\t/ { + next +} + +$1 ~ /^[a-zA-Z_]+$/ { + if ($1 in ignore) { + next + } + split($2, dep, /[ \t]+/) + for (i in dep) { + if (dep[i] ~ /^\$/) { + continue + } + if (dep[i] ~ "^"$1"\\.(o|sh)$") { + continue + } + sub(/\.o$/, ".c", dep[i]); + print "\t\"" dep[i] "\" [shape=box];" + print "\t\"" dep[i] "\" -> \"" $1 "\";" + } + print "" +} + +END { + print "}" +} diff -r 348b92755bef -r eba3744fb238 scripts/wordfreq --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/wordfreq Mon Jul 16 11:23:30 2012 +0200 @@ -0,0 +1,6 @@ +#!/bin/sh +# +# print frequency of words + +deroff "$@" | tr -cs A-Za-z '\012' | tr A-Z a-z | + sort | uniq -c | sort -nr | sed 20q