~dannf/ubuntu/saucy/screen/lp1213278-from-debian

« back to all changes in this revision

Viewing changes to term.sh

  • Committer: Bazaar Package Importer
  • Author(s): Nathaniel McCallum
  • Date: 2004-09-03 15:15:33 UTC
  • Revision ID: james.westby@ubuntu.com-20040903151533-px02yqlrchs4fv2t
Tags: upstream-4.0.2
ImportĀ upstreamĀ versionĀ 4.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
 
 
3
if test -z "$AWK"; then
 
4
  AWK=awk
 
5
fi
 
6
if test -z "$srcdir"; then
 
7
  srcdir=.
 
8
fi
 
9
 
 
10
LC_ALL=C
 
11
export LC_ALL
 
12
 
 
13
rm -f term.h
 
14
cat << EOF > term.h
 
15
/*
 
16
 * This file is automagically created from term.c -- DO NOT EDIT
 
17
 */
 
18
 
 
19
#define T_FLG 0
 
20
#define T_NUM 1
 
21
#define T_STR 2
 
22
 
 
23
struct term
 
24
{
 
25
  char *tcname;
 
26
  int type;
 
27
};
 
28
 
 
29
union tcu
 
30
{
 
31
  int flg;
 
32
  int num;
 
33
  char *str;
 
34
};
 
35
 
 
36
EOF
 
37
 
 
38
#
 
39
# SCO-Unix sufferers may need to use the following lines:
 
40
# perl -p < ${srcdir}/term.c \
 
41
#  -e 's/"/"C/ if /"[A-Z]."/;' \
 
42
#  -e 'y/[a-z]/[A-Z]/ if /"/;' \
 
43
#
 
44
sed < ${srcdir}/term.c \
 
45
  -e '/"[A-Z]."/s/"/"C/' \
 
46
  -e '/"/y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
 
47
| $AWK '
 
48
/^  [{] ".*KMAPDEF[(].*$/{
 
49
  if (min == 0) min = s
 
50
  max = s;
 
51
}
 
52
/^  [{] ".*KMAPADEF[(].*$/{
 
53
  if (amin == 0) amin = s
 
54
  amax = s;
 
55
}
 
56
/^  [{] ".*KMAPMDEF[(].*$/{
 
57
  if (mmin == 0) mmin = s
 
58
  mmax = s;
 
59
}
 
60
/^  [{] ".*$/{
 
61
a=substr($2,2,length($2)-3);
 
62
b=substr($3,3,3);
 
63
if (nolist == 0) {
 
64
    printf "#define d_%s  d_tcs[%d].%s\n",a,s,b
 
65
    printf "#define D_%s (D_tcs[%d].%s)\n",a,s,b
 
66
  }
 
67
s++;
 
68
}
 
69
/\/* define/{
 
70
printf "#define %s %d\n",$3,s
 
71
}
 
72
/\/* nolist/{
 
73
nolist = 1;
 
74
}
 
75
/\/* list/{
 
76
nolist = 0;
 
77
}
 
78
END {
 
79
  printf "\n#ifdef MAPKEYS\n"
 
80
  printf "#  define KMAPDEFSTART %d\n", min
 
81
  printf "#  define NKMAPDEF %d\n", max-min+1
 
82
  printf "#  define KMAPADEFSTART %d\n", amin
 
83
  printf "#  define NKMAPADEF %d\n", amax-amin+1
 
84
  printf "#  define KMAPMDEFSTART %d\n", mmin
 
85
  printf "#  define NKMAPMDEF %d\n", mmax-mmin+1
 
86
  printf "#endif\n"
 
87
}
 
88
' | sed -e s/NUM/num/ -e s/STR/str/ -e s/FLG/flg/ \
 
89
>> term.h
 
90
 
 
91
rm -f kmapdef.c
 
92
cat << EOF > kmapdef.c
 
93
/*
 
94
 * This file is automagically created from term.c -- DO NOT EDIT
 
95
 */
 
96
 
 
97
#include "config.h"
 
98
 
 
99
#ifdef MAPKEYS
 
100
 
 
101
EOF
 
102
 
 
103
$AWK < ${srcdir}/term.c '
 
104
/^  [{] ".*KMAP.*$/{
 
105
  for (i = 0; i < 3; i++) {
 
106
    q = $(5+i)
 
107
    if (substr(q, 1, 5) == "KMAPD") {
 
108
      if (min == 0) min = s
 
109
      max = s
 
110
      arr[s] = substr(q, 9, length(q)-9)
 
111
    }
 
112
    if (substr(q, 1, 5) == "KMAPA") {
 
113
      if (amin == 0) amin = s
 
114
      amax = s
 
115
      anarr[s] = substr(q, 10, length(q)-10)
 
116
    }
 
117
    if (substr(q, 1, 5) == "KMAPM") {
 
118
      if (mmin == 0) mmin = s
 
119
      mmax = s
 
120
      mnarr[s] = substr(q, 10, length(q)-10)
 
121
    }
 
122
  }
 
123
}
 
124
/^  [{] ".*$/{
 
125
  s++;
 
126
}
 
127
END {
 
128
  printf "char *kmapdef[] = {\n"
 
129
  for (s = min; s <= max; s++) {
 
130
    if (arr[s])
 
131
      printf "%s", arr[s]
 
132
    else
 
133
      printf "0"
 
134
    if (s < max)
 
135
      printf ",\n"
 
136
    else
 
137
      printf "\n"
 
138
  }
 
139
  printf "};\n\n"
 
140
  printf "char *kmapadef[] = {\n"
 
141
  for (s = amin; s <= amax; s++) {
 
142
    if (anarr[s])
 
143
      printf "%s", anarr[s]
 
144
    else
 
145
      printf "0"
 
146
    if (s < amax)
 
147
      printf ",\n"
 
148
    else
 
149
      printf "\n"
 
150
  }
 
151
  printf "};\n\n"
 
152
  printf "char *kmapmdef[] = {\n"
 
153
  for (s = mmin; s <= mmax; s++) {
 
154
    if (mnarr[s])
 
155
      printf "%s", mnarr[s]
 
156
    else
 
157
      printf "0"
 
158
    if (s < mmax)
 
159
      printf ",\n"
 
160
    else
 
161
      printf "\n"
 
162
  }
 
163
  printf "};\n\n#endif\n"
 
164
}
 
165
' >> kmapdef.c
 
166
 
 
167
chmod a-w kmapdef.c
 
168
chmod a-w term.h
 
169