OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [features/] [feature_to_c.sh] - Blame information for rev 853

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
#!/bin/sh
2
 
3
# Convert text files to compilable C arrays.
4
#
5
# Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6
#
7
# This file is part of GDB.
8
#
9
# This program is free software; you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation; either version 3 of the License, or
12
# (at your option) any later version.
13
#
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
# GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License
20
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 
22
output=$1
23
shift
24
 
25
if test -z "$output" || test -z "$1"; then
26
  echo "Usage: $0 OUTPUTFILE INPUTFILE..."
27
  exit 1
28
fi
29
 
30
if test -e "$output"; then
31
  echo "Output file \"$output\" already exists; refusing to overwrite."
32
  exit 1
33
fi
34
 
35
for input; do
36
  arrayname=xml_feature_`echo $input | sed 's,.*/,,; s/[-.]/_/g'`
37
 
38
  ${AWK:-awk} 'BEGIN { n = 0
39
      print "static const char '$arrayname'[] = {"
40
      for (i = 0; i < 255; i++)
41
        _ord_[sprintf("%c", i)] = i
42
    } {
43
      split($0, line, "");
44
      printf "  "
45
      for (i = 1; i <= length($0); i++) {
46
        c = line[i]
47
        if (c == "'\''") {
48
          printf "'\''\\'\'''\'', "
49
        } else if (c == "\\") {
50
          printf "'\''\\\\'\'', "
51
        } else if (_ord_[c] >= 32 && _ord_[c] < 127) {
52
          printf "'\''%s'\'', ", c
53
        } else {
54
          printf "'\''\\%03o'\'', ", _ord_[c]
55
        }
56
        if (i % 10 == 0)
57
          printf "\n   "
58
      }
59
      printf "'\''\\n'\'', \n"
60
    } END {
61
      print "  0 };"
62
    }' < $input >> $output
63
done
64
 
65
echo >> $output
66
echo "const char *const xml_builtin[][2] = {" >> $output
67
 
68
for input; do
69
  basename=`echo $input | sed 's,.*/,,'`
70
  arrayname=xml_feature_`echo $input | sed 's,.*/,,; s/[-.]/_/g'`
71
  echo "  { \"$basename\", $arrayname }," >> $output
72
done
73
 
74
echo "  { 0, 0 }" >> $output
75
echo "};" >> $output

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.