#!/bin/sh # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # This is a B-to-C translator, designed to be called from a makefile as: # # .b.c: ;bc 0-6t 7-9x version <$*.b >$@ # # What this command does is enable all lines that start with ":0" thru # # ":6" or ":t" and disable all lines that start with ":7" thru ":9" or # ":x". Enabling is done by just removing the ":."; disabling is done by # blanking out the line (but leaving it there so cc's line numbers will # be accurate). We also look for an initial line of the form: # # static char ID[] = "@(#) foobar %D"; # # We replace the %D with the date. This will convert a foo.b file to a # # compilable foo.c file, with an ID string containing the current date, # # and with debug lines ":0" thru ":6" enabled. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # if [ $# -lt 2 ];then echo 'Usage: $0 0-x y-9 version x.c'; exit 1;fi E="$1";shift D="$1";shift if [ $# -gt 0 ];then V="$1";shift; fi if [ -f Copyright ];then cat Copyright; fi sed -e 's/^:['$E']//' \ -e 's/^:['$D'].*//' \ -e '1,3s|%D|'`date +%y/%m/%d`'|' \ -e '1,3s|%V|Version '$V'|' exit 0 # The "exit 0" is done because some seds give a bogus exit status.