• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2# Add double quotation marks on cl file, this script will
3# be called in top_srcdir/clx_kernel/Makefile.am
4
5CL_FILE=$1
6CLX_FILE=$2
7
8if [ $# -ne 2 ]; then
9    echo "Usage: $0 <cl_file> <clx_file>"
10    exit 1
11fi
12
13gawk '
14    BEGIN { FS = "" }
15    {
16        if ($0~/^[\t " "]*[\/]+/ || $0~/^[\t " "]*[\*]/)
17            print $0
18        else
19        {
20            if ($0~/^[ ]*$/)
21                print
22            else
23            {
24                $0 = gensub (/\\$/, "\\\\\\\\", "g")
25                $0 = gensub (/\"/, "\\\\\\\"", "g")
26                $0 = gensub (/%/, "\\\\%", "g")
27                $0 = gensub (/\\n/, "\\\\\\\\n", "g")
28                $0 = gensub (/\\t/, "\\\\\\\\t", "g")
29                $0 = gensub (/^#/, "\\\\n#", "g")
30
31                print "\""$0"\\n\""
32            }
33        }
34    }
35    ' $CL_FILE > $CLX_FILE.tmp
36
37ret=$?
38if [ $ret != 0 ]; then
39    rm -rf $CLX_FILE.tmp
40    echo "Add double quotation marks on $CL_FILE failed"
41    exit 1
42fi
43
44mv $CLX_FILE.tmp $CLX_FILE
45
46echo "Add double quotation marks on $CL_FILE done"
47