#! /usr/bin/awk -f
#
-# $Id: mpx-gen,v 1.1 1999/11/14 13:53:44 mdw Exp $
+# $Id: mpx-gen,v 1.2 1999/12/10 23:26:51 mdw Exp $
#
# Generate test vectors for MPX testing
if (i in ARGV) rep = ARGV[i++]; else rep = 1;
# --- Output filters ---
-
- bc = "bc | sed 'y/ABCDEF/abcdef/; \
- s/^[0-9a-f]\\([0-9a-f][0-9a-f]\\)*$/0&/; \
- s/^/ /; \
- $ s/$/;/'";
+ #
+ # This is complicated. `bc' emits numbers split over multiple lines with
+ # backslashes. It also doesn't pad to an even number of digits, which the
+ # test rig is expecting, or use lower-case, which looks nicer.
+ #
+ # The first bit matches a line ending with a backslash. If it finds one,
+ # it appends the next line, removes the backslash/newline pair, and loops
+ # around to the top.
+ #
+ # The next substitution translates the whole kaboodle into lower-case.
+ #
+ # The next one looks for an off number of hex digits and prepends a zero if
+ # it finds one.
+ #
+ # The one after that just indents by two spaces. The final one sticks a
+ # semicolon on the end.
+
+ bc = "bc | sed '\
+:top\n\
+/\\\\$/ {\n\
+ N\n\
+ s/\\\\\\\n\
+//;\n\
+ b top;\n\
+}\n\
+y/ABCDEF/abcdef/\n\
+s/^[0-9a-f]\\([0-9a-f][0-9a-f]\\)*$/0&/\n\
+s/^/ /\n\
+$ s/$/;/'";
out = "sed 'y/ABCDEF/abcdef/; s/^/ /'"
# --- Main code ---