Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #1565
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder02.blueworldhosting.com!news.szaf.org!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!feed.xsnews.nl!border-1.ams.xsnews.nl!post-feeder-02.xsnews.nl!frontend-F10-19.ams.news.kpn.nl |
|---|---|
| From | Cecil Westerhof <Cecil@decebal.nl> |
| Newsgroups | comp.lang.postscript |
| Subject | Needly formatted list of functions |
| Organization | Decebal Computing |
| X-Face | "(y8cC@tg_12{">GF'UXTW]FHI2wMiZNrnf'1EFQ&O#$m:f#O7+7}kR<J%a^F2lh4[N~Yz4 nSp#c+aQo1b5=?HcNEkQ7QzF<])O3X4MDL/AYjys&*mt>,v+Pti8=Vi/Z"g^?b"E |
| X-Homepage | http://www.decebal.nl/ |
| Date | Fri, 02 Aug 2013 17:21:51 +0200 |
| Message-ID | <87haf86ru8.fsf@Aspire.decebal.nl> (permalink) |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) |
| Cancel-Lock | sha1:/7ahf4DWqCC3tlBlwfVtPMFz0bA= |
| MIME-Version | 1.0 |
| Content-Type | text/plain; format=flowed |
| Lines | 144 |
| NNTP-Posting-Host | 77.171.42.144 |
| X-Trace | 1375457735 news.kpn.nl 21322 77.171.42.144@kpn/77.171.42.144:52294 |
| Xref | csiph.com comp.lang.postscript:1565 |
Show key headers only | View raw
When you are commenting your fumctions in the following way:
% input parameters 2 spaces function name 2 spaces output
parameters
Then I have a nice function to display the list of functions in a
nicely formatted way:
#!/usr/bin/env bash
set -o errexit
set -o nounset
declare INPUT_FILE
declare -r SCRIPT_NAME=$(basename ${0})
if [[ ${#} -ne 1 ]] ; then
printf "ERROR: ${SCRIPT_NAME} postscriptFile\n"
exit 1
fi
INPUT_FILE=${1}; shift
readonly INPUT_FILE
awk '
BEGIN {
count = 0
maxCmdLen = 0
maxInputLen = 0
}
END {
format = sprintf("%%-%ds: %%-%ds ===> %%s\n",
maxCmdLen, maxInputLen)
for (i = 1; i <= count; ++i) {
printf(format, commandAr[i], inputAr[i],
outputAr[i])
}
print ""
printf("Extracted %d commands\n", count)
}
/^% (.*)[^ ] ([^ ]*) [^ ](.*)$/ {
if (match($0, " (.*) ")) {
++count
cmdStart = RSTART + 2
cmdLen = RLENGTH - 4
if (cmdLen > maxCmdLen) {
maxCmdLen = cmdLen
}
inputStart = 3
inputLen = RSTART - 3
if (inputLen > maxInputLen) {
maxInputLen = inputLen
}
outputStart = RSTART + RLENGTH
command = substr($0, cmdStart, cmdLen)
input = substr($0, inputStart,
inputLen)
output = substr($0, outputStart)
commandAr[count] = command
inputAr[count] = input
outputAr[count] = output
}
}
' <${INPUT_FILE}
This gives on a certain postscriptfile:
arrow : tailx taily tipx tipy thickness
headthickness headlength ===> -
borderCircles : left bottom right top scaleFactor
===> -
borderLines : left bottom right top step endVal
===> -
borderRectangles : left bottom right top scaleFactor
===> -
centerString : msg [gray] x y
===> -
displayArray : array nrOfLines x_mid x_max y lineHeight
===> -
doShow : msg gray
===> -
drawLeftRightLines: startVal step endVal left right
===> -
drawUpDownLines : startVal step endVal up down
===> -
drawUpDownTubes : startVal step endVal up down width
===> -
endProgram : shoul be empty
===> -
fatalError : errorMessage [surpressStack]
===> -
fileToArray : inputFile
===> lineArray nrOfLines
findhalfAngle : string
===> halfAngle
fontToLatin : fontname
===> -
getDictValues : dictionary nameArray
===> --
getRescaleFont : array lineLen
===> scaleFactor
gradient : left bottom right top startColor endColor
===> -
grayBackground : gray
===> -
insidecircletext : string ptSize centerAngle radius
===> -
line : left bottom right top
===> -
numToString : number
===> string
logoCW : hasBorder x y
===> -
logoDC : hasBorder x y
===> -
logoMF : hasBorder x y
===> -
logoPR : hasBorder x y
===> -
outsidecircletext : string ptSize centerAngle radius
===> -
rectangle : left bottom right top
===> -
rectangleWithText : grey text left bottom right top
===> -
rightString : msg [gray] x y
===> -
setColourScheme : colourScheme
===> -
showString : string [gray] x y
===> -
stringAddNum : string1 number
===> string
stringCat : string1 string2
===> string
textheight : -
===> textHeight
wedge : msg isDownward
===> -
Extracted 36 commands
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
Back to comp.lang.postscript | Previous | Next | Find similar | Unroll thread
Needly formatted list of functions Cecil Westerhof <Cecil@decebal.nl> - 2013-08-02 17:21 +0200
csiph-web