File: ckustr.sed

package info (click to toggle)
ckermit 193-3
  • links: PTS
  • area: non-free
  • in suites: slink
  • size: 6,180 kB
  • ctags: 8,803
  • sloc: ansic: 118,504; makefile: 2,474; sh: 52
file content (62 lines) | stat: -rw-r--r-- 1,720 bytes parent folder | download
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
#! /bin/sh
# Special cc preprocessor for using mkstr(1) to extract strings from the
# kermit source.  Change the "CC=cc" line to "CC=./ckustr.sed" to use
# string extraction.  NOTE: the file ckustr.c might need the StringFile
# declaration modified to suit local system requirements.  When installing
# the kermit executable be sure to install kermit.sr and make it readable
# by the public (mode 444).

STRINGS=cku192.sr

# Get filename and arguments.
initargs=$@
while [ -n "$1" ]
do
	if [ $1 = -o ]
	then
		exec cc $initargs
		exit 1
	fi
	if [ `expr substr $1 1 1` = - ]
	then
		if [ $1 != -c ]
		then
			args="$args $1"
		fi
	else
		csrc=$1
	fi
	shift
done

# Only process compilations, and then only for certain files.
if [ $csrc = ckustr.c -o $csrc = ckwart.c ]
then
	exec cc $initargs
	exit 1
fi

# String extractions
echo Extracting strings from ${csrc}...
cc -E $args $csrc > xxmk.c
sed -e 's/ferror(/strferrorf(/'				\
    -e 's/perror("/strperror("/'			\
    -e 's/experror(/strexperrorf(/'			\
    -e 's/sprintf(\([^,][^,]*\),[ ]*\("[^"]*"\)\([,)]\)/strsrerror(\2, \1\3/' \
    -e '/sprintf(\([^,][^,]*\),/{N
s/sprintf(\([^,][^,]*\),\n[ ]*\("[^"]*"\)\([,)]\)/strsrerror(\2, \1\3/
}'							\
    -e 's/fprintf(\([^,][^,]*\),[ ]*\("[^"]*"\)\([,)]\)/strfrerror(\2, \1\3/' \
    -e '/fprintf(\([^,][^,]*\),/{N
s/fprintf(\([^,][^,]*\),\n[ ]*\("[^"]*"\)\([,)]\)/strfrerror(\2, \1\3/
}'							\
    -e 's/printf[ ]*("/strprerror("/'		\
    -e '/printf[ ]*(/{N
s/printf[ ]*(\n"/strprerror("/
}' xxmk.c > mk.c
mkstr - $STRINGS xx mk.c
sed -e 's/^# \([0-9]\)/#line \1/' xxmk.c | xstr -c -
echo Compiling...
cc -Dstrferrorf=ferror -Dstrexperrorf=experror $args -c x.c
mv x.o `basename $csrc .c`.o
rm -f x.c mk.c xxmk.c