File: transform_sql.sh

package info (click to toggle)
subversion 1.6.12dfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 48,292 kB
  • ctags: 47,714
  • sloc: ansic: 578,414; python: 77,551; sh: 13,100; ruby: 12,194; cpp: 10,097; java: 8,428; lisp: 7,702; perl: 7,320; makefile: 1,035; xml: 759; sql: 62
file content (42 lines) | stat: -rwxr-xr-x 843 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

varname=`basename $1 | tr "[a-z]" "[A-Z]" | tr "-" "_" | tr "." "_"`

echo "/* This file is automatically generated from"
echo " * $1"
echo " * Do not edit it directly, but edit the source file and rerun 'make'"
echo " */"
echo
echo "#define $varname \\"

comment=false

IFS="
"
while read line; do
  line=`echo "$line" | sed -e 's/\/\*.*\*\///g' | sed -e 's/[ ]*$//g'`

  if [ -z "$line" ]; then
    continue
  fi

  if [ "$comment" = "false" ] && echo "$line" | fgrep '/*' >/dev/null; then
    comment=true
  fi

  if [ "$comment" = "true" ] && echo "$line" | fgrep '*/' >/dev/null; then
    comment=false
    continue
  fi

  if [ "$comment" = "true" ]; then
    continue
  fi

  line="`echo "$line" | sed -e 's/"/\\"/g'`"  #' hi, emacs syntax coloring!
  if [ -n "$line" ]; then
    echo "  \"$line \"\\"
  fi
done

echo '  ""'