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 wrap: on
line diff
--- 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
--- 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}'
--- /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))
+}' "$@"
--- /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
--- /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\>' "$@"
--- /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]* *}' "$@"
--- /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
--- /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
--- /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 "}"
+}
--- /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