1 | #! /bin/sh |
---|
2 | # Special cc preprocessor for using mkstr(1) to extract strings from the |
---|
3 | # kermit source. Change the "CC=cc" line to "CC=./ckustr.sed" to use |
---|
4 | # string extraction. NOTE: the file ckustr.c might need the StringFile |
---|
5 | # declaration modified to suit local system requirements. When installing |
---|
6 | # the kermit executable be sure to install kermit.sr and make it readable |
---|
7 | # by the public (mode 444). |
---|
8 | |
---|
9 | STRINGS=cku192.sr |
---|
10 | |
---|
11 | # Get filename and arguments. |
---|
12 | initargs=$@ |
---|
13 | while [ -n "$1" ] |
---|
14 | do |
---|
15 | if [ $1 = -o ] |
---|
16 | then |
---|
17 | exec cc $initargs |
---|
18 | exit 1 |
---|
19 | fi |
---|
20 | if [ `expr substr $1 1 1` = - ] |
---|
21 | then |
---|
22 | if [ $1 != -c ] |
---|
23 | then |
---|
24 | args="$args $1" |
---|
25 | fi |
---|
26 | else |
---|
27 | csrc=$1 |
---|
28 | fi |
---|
29 | shift |
---|
30 | done |
---|
31 | |
---|
32 | # Only process compilations, and then only for certain files. |
---|
33 | if [ $csrc = ckustr.c -o $csrc = ckwart.c ] |
---|
34 | then |
---|
35 | exec cc $initargs |
---|
36 | exit 1 |
---|
37 | fi |
---|
38 | |
---|
39 | # String extractions |
---|
40 | echo Extracting strings from ${csrc}... |
---|
41 | cc -E $args $csrc > xxmk.c |
---|
42 | sed -e 's/ferror(/strferrorf(/' \ |
---|
43 | -e 's/perror("/strperror("/' \ |
---|
44 | -e 's/experror(/strexperrorf(/' \ |
---|
45 | -e 's/sprintf(\([^,][^,]*\),[ ]*\("[^"]*"\)\([,)]\)/strsrerror(\2, \1\3/' \ |
---|
46 | -e '/sprintf(\([^,][^,]*\),/{N |
---|
47 | s/sprintf(\([^,][^,]*\),\n[ ]*\("[^"]*"\)\([,)]\)/strsrerror(\2, \1\3/ |
---|
48 | }' \ |
---|
49 | -e 's/fprintf(\([^,][^,]*\),[ ]*\("[^"]*"\)\([,)]\)/strfrerror(\2, \1\3/' \ |
---|
50 | -e '/fprintf(\([^,][^,]*\),/{N |
---|
51 | s/fprintf(\([^,][^,]*\),\n[ ]*\("[^"]*"\)\([,)]\)/strfrerror(\2, \1\3/ |
---|
52 | }' \ |
---|
53 | -e 's/printf[ ]*("/strprerror("/' \ |
---|
54 | -e '/printf[ ]*(/{N |
---|
55 | s/printf[ ]*(\n"/strprerror("/ |
---|
56 | }' xxmk.c > mk.c |
---|
57 | mkstr - $STRINGS xx mk.c |
---|
58 | sed -e 's/^# \([0-9]\)/#line \1/' xxmk.c | xstr -c - |
---|
59 | echo Compiling... |
---|
60 | cc -Dstrferrorf=ferror -Dstrexperrorf=experror $args -c x.c |
---|
61 | mv x.o `basename $csrc .c`.o |
---|
62 | rm -f x.c mk.c xxmk.c |
---|