File: csc-trans

package info (click to toggle)
chicken 5.3.0-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 32,892 kB
  • sloc: ansic: 580,083; lisp: 71,987; tcl: 1,445; sh: 588; makefile: 60
file content (64 lines) | stat: -rwxr-xr-x 1,578 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh

INDENT=indent
INDENT_OPTS="-st"
ENSCRIPT=enscript
ENSCRIPT_OPTS="-q -Ec"
CSC_OPTS="-to-stdout"
CSC=csc

# check for options
COLOR="--color"
MODE=""
OUTPUT=-
ALL=0
while getopts ":a23ufbihprcotlI:" opt; do
   case $opt in
      a ) ALL="1";;
      h ) MODE="--language=html";;
      p ) MODE="--language=PostScript";;
      r ) MODE="--language=rtf";;
      t ) NOENSCRIPT="1";;
      c ) COLOR="";; # disable color (on by default)
      o ) OUTPUT=$OPTARG;;
      u ) CSC_OPTS="$CSC_OPTS -unsafe";;
      b ) CSC_OPTS="$CSC_OPTS -block";;
      f ) CSC_OPTS="$CSC_OPTS -fixnum-arithmetic";;
      i ) CSC_OPTS="$CSC_OPTS -inline";;
      I ) CSC_OPTS="$CSC_OPTS -disable-interrupts";;
      2 ) CSC_OPTS="$CSC_OPTS -O2";;
      3 ) CSC_OPTS="$CSC_OPTS -O3";;
      l ) CSC="./csc -compiler ./chicken-static";;
   esac
done
shift $(($OPTIND - 1))

# First argument after options is the file
FILE=$1
if [ "x$FILE" = "x" ]; then
    FILE="/dev/stdin"
fi

# Only prettify output if the appropriate programs are installed
if type $INDENT >/dev/null 2>&1; then
  PASS2="$INDENT $INDENT_OPTS"
else
  PASS2=cat
fi
if type $ENSCRIPT >/dev/null 2>&1; then
  PASS3="$ENSCRIPT $ENSCRIPT_OPTS $MODE $COLOR -o $OUTPUT"
else
  PASS3=cat
fi
if [ -n "$NOENSCRIPT" ]; then
    PASS3=cat
fi

# Are we filtering out just the user code?
if [ "x$ALL" = "x1" ]; then
  $CSC $CSC_OPTS $FILE | $PASS2 2>/dev/null | $PASS3 2>/dev/null
else
  $CSC $CSC_OPTS $FILE |\
  perl -an000e 'print if /C_trace/&&!/##sys#implicit/ || (/\/\* [-!%\w]+ in k\d+ / && ! /\/\* k\d+ /)' |\
  $PASS2 | $PASS3
fi