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