~ chicken-core (master) /scripts/csc-trans
Trap1#!/bin/sh23INDENT=indent4INDENT_OPTS="-st"5ENSCRIPT=enscript6ENSCRIPT_OPTS="-q -Ec"7CSC_OPTS="-to-stdout"8CSC=csc910# check for options11COLOR="--color"12MODE=""13OUTPUT=-14ALL=015while getopts ":a23ufbihprcotlI:" opt; do16 case $opt in17 a ) ALL="1";;18 h ) MODE="--language=html";;19 p ) MODE="--language=PostScript";;20 r ) MODE="--language=rtf";;21 t ) NOENSCRIPT="1";;22 c ) COLOR="";; # disable color (on by default)23 o ) OUTPUT=$OPTARG;;24 u ) CSC_OPTS="$CSC_OPTS -unsafe";;25 b ) CSC_OPTS="$CSC_OPTS -block";;26 f ) CSC_OPTS="$CSC_OPTS -fixnum-arithmetic";;27 i ) CSC_OPTS="$CSC_OPTS -inline";;28 I ) CSC_OPTS="$CSC_OPTS -disable-interrupts";;29 2 ) CSC_OPTS="$CSC_OPTS -O2";;30 3 ) CSC_OPTS="$CSC_OPTS -O3";;31 l ) CSC="./csc -compiler ./chicken-static";;32 esac33done34shift $(($OPTIND - 1))3536# First argument after options is the file37FILE=$138if [ "x$FILE" = "x" ]; then39 FILE="/dev/stdin"40fi4142# Only prettify output if the appropriate programs are installed43if type $INDENT >/dev/null 2>&1; then44 PASS2="$INDENT $INDENT_OPTS"45else46 PASS2=cat47fi48if type $ENSCRIPT >/dev/null 2>&1; then49 PASS3="$ENSCRIPT $ENSCRIPT_OPTS $MODE $COLOR -o $OUTPUT"50else51 PASS3=cat52fi53if [ -n "$NOENSCRIPT" ]; then54 PASS3=cat55fi5657# Are we filtering out just the user code?58if [ "x$ALL" = "x1" ]; then59 $CSC $CSC_OPTS $FILE | $PASS2 2>/dev/null | $PASS3 2>/dev/null60else61 $CSC $CSC_OPTS $FILE |\62 perl -an000e 'print if /C_trace/&&!/##sys#implicit/ || (/\/\* [-!%\w]+ in k\d+ / && ! /\/\* k\d+ /)' |\63 $PASS2 | $PASS364fi