tst.aggpackbanner.ksh revision 33093f5bcdc51014933497dd39374080c1ac5705
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# This file and its contents are supplied under the terms of the
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Common Development and Distribution License ("CDDL"), version 1.0.
199767f8919635c4928607450d9e0abb932109ceToomas Soome# You may only use this file in accordance with the terms of version
199767f8919635c4928607450d9e0abb932109ceToomas Soome# 1.0 of the CDDL.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# A full copy of the text of the CDDL should have accompanied this
199767f8919635c4928607450d9e0abb932109ceToomas Soome# source. A copy of the CDDL is also available via the Internet at
199767f8919635c4928607450d9e0abb932109ceToomas Soome# http://www.illumos.org/license/CDDL.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Copyright (c) 2013 Joyent, Inc. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomelet width=8
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomefunction outputchar
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome banner $3 | /bin/nawk -v line=$1 -v pos=$2 -v width=$width '{ \
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (i = 1; i <= length($0); i++) { \
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (substr($0, i, 1) == " ") \
199767f8919635c4928607450d9e0abb932109ceToomas Soome continue; \
199767f8919635c4928607450d9e0abb932109ceToomas Soome printf("\t@letter%d[%d] = lquantize(%d, 0, 40, 1);\n", \
199767f8919635c4928607450d9e0abb932109ceToomas Soome line, NR, i + (pos * width));
199767f8919635c4928607450d9e0abb932109ceToomas Soome } \
199767f8919635c4928607450d9e0abb932109ceToomas Soome }'
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomefunction outputstr
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome let pos=0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome let line=0
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome printf "#pragma D option aggpack\n#pragma D option aggsortkey\n"
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome printf "BEGIN\n{\n"
199767f8919635c4928607450d9e0abb932109ceToomas Soome for c in `echo "$1" | /bin/nawk '{ \
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (i = 1; i <= length($0); i++) { \
199767f8919635c4928607450d9e0abb932109ceToomas Soome c = substr($0, i, 1); \
199767f8919635c4928607450d9e0abb932109ceToomas Soome printf("%s\n", c == " " ? "space" : \
199767f8919635c4928607450d9e0abb932109ceToomas Soome c == "\n" ? "newline" : c); \
199767f8919635c4928607450d9e0abb932109ceToomas Soome } \
199767f8919635c4928607450d9e0abb932109ceToomas Soome }'`; do
199767f8919635c4928607450d9e0abb932109ceToomas Soome if [[ "$c" == "space" ]]; then
199767f8919635c4928607450d9e0abb932109ceToomas Soome let line=line+1
199767f8919635c4928607450d9e0abb932109ceToomas Soome let pos=0
199767f8919635c4928607450d9e0abb932109ceToomas Soome continue
199767f8919635c4928607450d9e0abb932109ceToomas Soome fi
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome outputchar $line $pos $c
199767f8919635c4928607450d9e0abb932109ceToomas Soome let pos=pos+1
199767f8919635c4928607450d9e0abb932109ceToomas Soome done
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome let i=0
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome while [[ $i -le $line ]]; do
199767f8919635c4928607450d9e0abb932109ceToomas Soome printf "\tprinta(@letter%d);\n" $i
let i=i+1
done
printf "\texit(0);\n}\n"
}
dtrace -qs /dev/stdin -x encoding=utf8 <<EOF
`outputstr "why must i do this"`
EOF
dtrace -qs /dev/stdin -x encoding=ascii -x aggzoom <<EOF
`outputstr "i am not well"`
EOF
dtrace -qs /dev/stdin -x encoding=utf8 -x aggzoom <<EOF
`outputstr "send help"`
EOF