Change close_and_rename() to read_only_bottom_close_and_rename()
[perl.git] / regen / keywords.pl
1 #!/usr/bin/perl -w
2
3 # Regenerate (overwriting only if changed):
4 #
5 #    keywords.h
6 #
7 # from information stored in the DATA section of this file.
8 #
9 # Accepts the standard regen_lib -q and -v args.
10 #
11 # This script is normally invoked from regen.pl.
12
13 use strict;
14
15 require 'regen/regen_lib.pl';
16
17 my $kw = safer_open('keywords.h-new', 'keywords.h');
18 select $kw;
19
20 print read_only_top(lang => 'C', by => 'regen/keywords.pl', from => 'its data',
21                     file => 'keywords.h', style => '*',
22                     copyright => [1994 .. 1997, 1999 .. 2002, 2005 .. 2007]);
23
24 # Read & print data.
25
26 my $keynum = 0;
27 while (<DATA>) {
28     chop;
29     next unless $_;
30     next if /^#/;
31     my ($keyword) = split;
32     print &tab(5, "#define KEY_$keyword"), $keynum++, "\n";
33 }
34
35 read_only_bottom_close_and_rename($kw);
36
37 ###########################################################################
38 sub tab {
39     my ($l, $t) = @_;
40     $t .= "\t" x ($l - (length($t) + 1) / 8);
41     $t;
42 }
43 ###########################################################################
44 __END__
45
46 NULL
47 __FILE__
48 __LINE__
49 __PACKAGE__
50 __DATA__
51 __END__
52 AUTOLOAD
53 BEGIN
54 UNITCHECK
55 CORE
56 DESTROY
57 END
58 INIT
59 CHECK
60 abs
61 accept
62 alarm
63 and
64 atan2
65 bind
66 binmode
67 bless
68 break
69 caller
70 chdir
71 chmod
72 chomp
73 chop
74 chown
75 chr
76 chroot
77 close
78 closedir
79 cmp
80 connect
81 continue
82 cos
83 crypt
84 dbmclose
85 dbmopen
86 default
87 defined
88 delete
89 die
90 do
91 dump
92 each
93 else
94 elsif
95 endgrent
96 endhostent
97 endnetent
98 endprotoent
99 endpwent
100 endservent
101 eof
102 eq
103 eval
104 exec
105 exists
106 exit
107 exp
108 fcntl
109 fileno
110 flock
111 for
112 foreach
113 fork
114 format
115 formline
116 ge
117 getc
118 getgrent
119 getgrgid
120 getgrnam
121 gethostbyaddr
122 gethostbyname
123 gethostent
124 getlogin
125 getnetbyaddr
126 getnetbyname
127 getnetent
128 getpeername
129 getpgrp
130 getppid
131 getpriority
132 getprotobyname
133 getprotobynumber
134 getprotoent
135 getpwent
136 getpwnam
137 getpwuid
138 getservbyname
139 getservbyport
140 getservent
141 getsockname
142 getsockopt
143 given
144 glob
145 gmtime
146 goto
147 grep
148 gt
149 hex
150 if
151 index
152 int
153 ioctl
154 join
155 keys
156 kill
157 last
158 lc
159 lcfirst
160 le
161 length
162 link
163 listen
164 local
165 localtime
166 lock
167 log
168 lstat
169 lt
170 m
171 map
172 mkdir
173 msgctl
174 msgget
175 msgrcv
176 msgsnd
177 my
178 ne
179 next
180 no
181 not
182 oct
183 open
184 opendir
185 or
186 ord
187 our
188 pack
189 package
190 pipe
191 pop
192 pos
193 print
194 printf
195 prototype
196 push
197 q
198 qq
199 qr
200 quotemeta
201 qw
202 qx
203 rand
204 read
205 readdir
206 readline
207 readlink
208 readpipe
209 recv
210 redo
211 ref
212 rename
213 require
214 reset
215 return
216 reverse
217 rewinddir
218 rindex
219 rmdir
220 s
221 say
222 scalar
223 seek
224 seekdir
225 select
226 semctl
227 semget
228 semop
229 send
230 setgrent
231 sethostent
232 setnetent
233 setpgrp
234 setpriority
235 setprotoent
236 setpwent
237 setservent
238 setsockopt
239 shift
240 shmctl
241 shmget
242 shmread
243 shmwrite
244 shutdown
245 sin
246 sleep
247 socket
248 socketpair
249 sort
250 splice
251 split
252 sprintf
253 sqrt
254 srand
255 stat
256 state
257 study
258 sub
259 substr
260 symlink
261 syscall
262 sysopen
263 sysread
264 sysseek
265 system
266 syswrite
267 tell
268 telldir
269 tie
270 tied
271 time
272 times
273 tr
274 truncate
275 uc
276 ucfirst
277 umask
278 undef
279 unless
280 unlink
281 unpack
282 unshift
283 untie
284 until
285 use
286 utime
287 values
288 vec
289 wait
290 waitpid
291 wantarray
292 warn
293 when
294 while
295 write
296 x
297 xor
298 y