gentexifile 1.18 KB
Newer Older
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
#!/bin/sh
if [ $# = 0 ]; then
  echo "Usage: $0 <file to translate>"
  exit 0
fi

SOURCE=$1
SUFFIX=`echo ${SOURCE} | ${SED:-sed} 's/.*\(\.[^.]*\)$/\1/'`

case ${SOURCE} in
  *.idl)
    TARGET=`basename ${SOURCE} ${SUFFIX}`${LABEL}.texi
    SEDFILE=idl.sed;;
  *.c)
    SEDFILE=c.sed ;
    TARGET=`basename ${SOURCE} ${SUFFIX}`${LABEL}.c.texi
    ;;
  *.h)
    TARGET=`basename ${SOURCE} ${SUFFIX}`${LABEL}.h.texi ;
    SEDFILE=c.sed;;
  *.aadl)
    TARGET=`basename ${SOURCE} ${SUFFIX}`${LABEL}.texi ;
    SEDFILE=aadl.sed;;
  *)
    echo "Cannot translate file";
    exit 1;;
esac

TMPTAR=${TARGET}.tmp

${AWK:-awk} 'BEGIN{out=1}$1=="end"&&substr($0,1,1)=="e"{out=1}out==1{print}$1=="private"&&out==1{out=0; print "   --  implementation removed"}' ${SOURCE} > genout

echo "@smallexample"      >${TMPTAR}
if [ $# = 1 ]; then
echo "@cartouche"        >>${TMPTAR}
echo "@group"            >>${TMPTAR}
fi
echo ""                  >>${TMPTAR}
${SED:-sed} -f ${SEDFILE} genout    >>${TMPTAR}
echo ""                  >>${TMPTAR}
if [ $# = 1 ]; then
echo "@end group"        >>${TMPTAR}
echo "@end cartouche"    >>${TMPTAR}
fi
echo "@end smallexample" >>${TMPTAR}

cat ${TMPTAR} | tr -d '\r' > ${TARGET}
rm ${TMPTAR}