File: errorstring

package info (click to toggle)
edbrowse 3.8.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,992 kB
  • sloc: ansic: 48,603; javascript: 16,211; perl: 6,825; sh: 120; makefile: 81; cpp: 56
file content (43 lines) | stat: -rwxr-xr-x 828 bytes parent folder | download | duplicates (4)
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
#!/bin/sh

#  find a string in the lang/msg-en file, map back to its symbolic constants,
#  and see which sourcefiles contain it.
#  This is meant to be run from the src directory. -
#  won't work properly if run from anywhere else.

if [ $# != 1 ]
then
echo "usage: errorstring message"
exit 1
fi

#  the error message, or a fragment thereof
e="$1"

nl ../lang/msg-en | fgrep "$e" >/tmp/elines
count=`cat /tmp/elines | wc -l`

if [ $count = 0 ]
then
echo "message not found, try a smaller fragment"
rm /tmp/elines
exit 1
fi

if [ $count != 1 ]
then
echo "multiple messages found"
cat /tmp/elines
rm /tmp/elines
exit 1
fi

#  line number
ln=`sed </tmp/elines -e 's/	.*//' -e 's/^ *//'`
rm /tmp/elines
ln=$((ln+100))
symbol=`sed <messages.h -e "$ln!d" -e 's/[ ,]*$//' -e 's/^[ 	]*//'`
echo $symbol
fgrep -l "$symbol" *.c

exit 0