source: trunk/third/kermit/ckustr.sed @ 10780

Revision 10780, 1.7 KB checked in by brlewis, 27 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r10779, which included commits to RCS files with non-trunk default branches.
Line 
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
9STRINGS=cku192.sr
10
11# Get filename and arguments.
12initargs=$@
13while [ -n "$1" ]
14do
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
30done
31
32# Only process compilations, and then only for certain files.
33if [ $csrc = ckustr.c -o $csrc = ckwart.c ]
34then
35        exec cc $initargs
36        exit 1
37fi
38
39# String extractions
40echo Extracting strings from ${csrc}...
41cc -E $args $csrc > xxmk.c
42sed -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
47s/sprintf(\([^,][^,]*\),\n[ ]*\("[^"]*"\)\([,)]\)/strsrerror(\2, \1\3/
48}'                                                      \
49    -e 's/fprintf(\([^,][^,]*\),[ ]*\("[^"]*"\)\([,)]\)/strfrerror(\2, \1\3/' \
50    -e '/fprintf(\([^,][^,]*\),/{N
51s/fprintf(\([^,][^,]*\),\n[ ]*\("[^"]*"\)\([,)]\)/strfrerror(\2, \1\3/
52}'                                                      \
53    -e 's/printf[ ]*("/strprerror("/'           \
54    -e '/printf[ ]*(/{N
55s/printf[ ]*(\n"/strprerror("/
56}' xxmk.c > mk.c
57mkstr - $STRINGS xx mk.c
58sed -e 's/^# \([0-9]\)/#line \1/' xxmk.c | xstr -c -
59echo Compiling...
60cc -Dstrferrorf=ferror -Dstrexperrorf=experror $args -c x.c
61mv x.o `basename $csrc .c`.o
62rm -f x.c mk.c xxmk.c
Note: See TracBrowser for help on using the repository browser.