blob: d60d1be97a3e84347d7872ebdb75079c0731df1d [file] [log] [blame]
Devon H. O'Dell553be842009-11-14 15:29:09 -08001#!/usr/bin/env bash
Russ Cox602a4462009-06-01 22:14:57 -07002# Copyright 2009 The Go Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style
4# license that can be found in the LICENSE file.
5
Russ Coxfd1add22009-11-01 11:13:27 -08006# Generate Go code listing errors and other #defined constant
7# values (ENAMETOOLONG etc.), by asking the preprocessor
8# about the definitions.
Russ Cox602a4462009-06-01 22:14:57 -07009
Russ Cox0b126c12009-12-01 16:53:43 -080010unset LANG
11export LC_ALL=C
12export LC_CTYPE=C
13
Kai Backman534dbc72010-08-23 13:25:14 +030014GCC=gcc
Kai Backmane5c884f2009-10-01 06:55:01 -070015
Russ Coxfd1add22009-11-01 11:13:27 -080016uname=$(uname)
Russ Cox602a4462009-06-01 22:14:57 -070017
Russ Coxfd1add22009-11-01 11:13:27 -080018includes_Darwin='
Russ Coxacd858e2011-01-18 14:02:41 -050019#define _DARWIN_C_SOURCE
Russ Coxfd1add22009-11-01 11:13:27 -080020#define KERNEL
21#define _DARWIN_USE_64_BIT_INODE
Mikio Hara9c97af92011-02-11 14:34:00 -050022#include <sys/types.h>
Russ Coxfd1add22009-11-01 11:13:27 -080023#include <sys/event.h>
Jeff Hodges0ce57a72011-06-14 12:56:46 -040024#include <sys/ptrace.h>
Mikio Hara5c0aab92011-01-31 12:50:50 -050025#include <sys/socket.h>
26#include <sys/sockio.h>
Mikio Hara9c97af92011-02-11 14:34:00 -050027#include <sys/sysctl.h>
Russ Cox48ae1f22011-04-06 17:52:02 -040028#include <sys/mman.h>
Mikio Hara9c97af92011-02-11 14:34:00 -050029#include <sys/wait.h>
Mikio Hara380f4ab2011-04-21 16:58:20 -040030#include <net/bpf.h>
Mikio Hara5c0aab92011-01-31 12:50:50 -050031#include <net/if.h>
Mikio Hara12376c92011-05-26 20:02:03 -040032#include <net/if_types.h>
Mikio Hara9c97af92011-02-11 14:34:00 -050033#include <net/route.h>
34#include <netinet/in.h>
Mikio Hara5c0aab92011-01-31 12:50:50 -050035#include <netinet/ip.h>
36#include <netinet/ip_mroute.h>
Ken Rockotc8443d72011-06-22 18:07:20 -040037#include <termios.h>
Russ Coxfd1add22009-11-01 11:13:27 -080038'
39
Joel Sing8f3f4c92013-08-24 01:51:25 +100040includes_DragonFly='
41#include <sys/types.h>
42#include <sys/event.h>
43#include <sys/socket.h>
44#include <sys/sockio.h>
45#include <sys/sysctl.h>
46#include <sys/mman.h>
47#include <sys/wait.h>
48#include <sys/ioctl.h>
49#include <net/bpf.h>
50#include <net/if.h>
51#include <net/if_types.h>
52#include <net/route.h>
53#include <netinet/in.h>
54#include <termios.h>
55#include <netinet/ip.h>
56#include <net/ip_mroute/ip_mroute.h>
57'
58
Devon H. O'Dell553be842009-11-14 15:29:09 -080059includes_FreeBSD='
Mikio Hara9c97af92011-02-11 14:34:00 -050060#include <sys/types.h>
Devon H. O'Dell553be842009-11-14 15:29:09 -080061#include <sys/event.h>
Mikio Hara400ea842011-02-01 08:46:21 -050062#include <sys/socket.h>
63#include <sys/sockio.h>
Mikio Hara9c97af92011-02-11 14:34:00 -050064#include <sys/sysctl.h>
Dave Cheney9dd92d52013-03-09 16:25:30 +110065#include <sys/mman.h>
Mikio Hara9c97af92011-02-11 14:34:00 -050066#include <sys/wait.h>
Ken Rockotc8443d72011-06-22 18:07:20 -040067#include <sys/ioctl.h>
Mikio Hara5a59b9e2011-04-04 15:40:40 -040068#include <net/bpf.h>
Mikio Hara400ea842011-02-01 08:46:21 -050069#include <net/if.h>
Mikio Hara12376c92011-05-26 20:02:03 -040070#include <net/if_types.h>
Mikio Hara9c97af92011-02-11 14:34:00 -050071#include <net/route.h>
Mikio Hara400ea842011-02-01 08:46:21 -050072#include <netinet/in.h>
Russ Coxdfacfd62011-06-27 11:02:32 -040073#include <termios.h>
Mikio Hara400ea842011-02-01 08:46:21 -050074#include <netinet/ip.h>
75#include <netinet/ip_mroute.h>
Devon H. O'Dell553be842009-11-14 15:29:09 -080076'
77
Mikio Hara055b4f72011-12-16 19:51:25 +090078includes_Linux='
79#define _LARGEFILE_SOURCE
80#define _LARGEFILE64_SOURCE
81#define _FILE_OFFSET_BITS 64
82#define _GNU_SOURCE
83
84#include <bits/sockaddr.h>
85#include <sys/epoll.h>
86#include <sys/inotify.h>
87#include <sys/ioctl.h>
88#include <sys/mman.h>
89#include <sys/mount.h>
Albert Strasheim2cb6fcf2012-01-09 21:37:46 +090090#include <sys/prctl.h>
Mikio Hara055b4f72011-12-16 19:51:25 +090091#include <sys/stat.h>
92#include <sys/types.h>
Shenghou Ma46e30c72013-06-11 02:47:04 +080093#include <sys/time.h>
Mikio Haraadbe59e2013-05-23 16:22:05 +090094#include <sys/socket.h>
Mikio Hara055b4f72011-12-16 19:51:25 +090095#include <linux/if_addr.h>
96#include <linux/if_ether.h>
97#include <linux/if_tun.h>
98#include <linux/filter.h>
99#include <linux/netlink.h>
100#include <linux/reboot.h>
101#include <linux/rtnetlink.h>
102#include <linux/ptrace.h>
Rémy Oudomphengd4f719e2013-08-23 22:26:49 +0200103#include <linux/sched.h>
Mikio Hara055b4f72011-12-16 19:51:25 +0900104#include <linux/wait.h>
Mikio Haraadbe59e2013-05-23 16:22:05 +0900105#include <linux/icmpv6.h>
Mikio Hara055b4f72011-12-16 19:51:25 +0900106#include <net/if.h>
107#include <net/if_arp.h>
108#include <net/route.h>
109#include <netpacket/packet.h>
Dave Cheneybd9cd6e2013-09-13 15:01:22 +1000110#include <termios.h>
Brad Fitzpatrickabf57002013-02-27 15:51:51 -0800111
112#ifndef MSG_FASTOPEN
113#define MSG_FASTOPEN 0x20000000
114#endif
Mikio Hara055b4f72011-12-16 19:51:25 +0900115'
116
Christopher Nielsen5425db82011-12-20 03:57:58 +1100117includes_NetBSD='
118#include <sys/types.h>
119#include <sys/param.h>
120#include <sys/event.h>
Joel Sing8f984432014-01-07 23:04:17 +1100121#include <sys/mman.h>
Christopher Nielsen5425db82011-12-20 03:57:58 +1100122#include <sys/socket.h>
123#include <sys/sockio.h>
124#include <sys/sysctl.h>
125#include <sys/termios.h>
126#include <sys/ttycom.h>
127#include <sys/wait.h>
128#include <net/bpf.h>
129#include <net/if.h>
130#include <net/if_types.h>
131#include <net/route.h>
132#include <netinet/in.h>
133#include <netinet/in_systm.h>
134#include <netinet/ip.h>
135#include <netinet/ip_mroute.h>
136#include <netinet/if_ether.h>
Joel Sing2a47e042012-05-14 10:40:13 -0700137
138// Needed since <sys/param.h> refers to it...
Joel Sing495a9dc2012-05-23 01:33:48 +1000139#define schedppq 1
Christopher Nielsen5425db82011-12-20 03:57:58 +1100140'
141
Joel Singbf2d4032011-08-22 23:24:32 -0400142includes_OpenBSD='
143#include <sys/types.h>
144#include <sys/param.h>
145#include <sys/event.h>
Joel Singf40dd8f2014-01-13 11:25:48 +1100146#include <sys/mman.h>
Joel Singbf2d4032011-08-22 23:24:32 -0400147#include <sys/socket.h>
148#include <sys/sockio.h>
149#include <sys/sysctl.h>
150#include <sys/termios.h>
151#include <sys/ttycom.h>
152#include <sys/wait.h>
153#include <net/bpf.h>
154#include <net/if.h>
155#include <net/if_types.h>
156#include <net/route.h>
157#include <netinet/in.h>
158#include <netinet/in_systm.h>
159#include <netinet/ip.h>
160#include <netinet/ip_mroute.h>
161#include <netinet/if_ether.h>
162#include <net/if_bridge.h>
163'
164
Russ Coxfd1add22009-11-01 11:13:27 -0800165includes='
166#include <sys/types.h>
Andrea Spadaccini83c30f32011-12-08 15:12:08 +0900167#include <sys/file.h>
Russ Coxfd1add22009-11-01 11:13:27 -0800168#include <fcntl.h>
169#include <dirent.h>
170#include <sys/socket.h>
171#include <netinet/in.h>
Russ Cox8fbe8be2010-03-30 14:32:59 -0700172#include <netinet/ip.h>
173#include <netinet/ip6.h>
Russ Coxfd1add22009-11-01 11:13:27 -0800174#include <netinet/tcp.h>
175#include <errno.h>
176#include <sys/signal.h>
177#include <signal.h>
Sébastien Paolaccie2467f02011-11-19 15:17:40 +0900178#include <sys/resource.h>
Russ Coxfd1add22009-11-01 11:13:27 -0800179'
Russ Cox602a4462009-06-01 22:14:57 -0700180
Russ Coxdd2abe52011-11-10 19:08:28 -0500181ccflags="$@"
Russ Cox7906e312010-04-29 23:34:06 -0700182
Mikio Hara44122ed2012-02-03 12:22:40 +0900183# Write go tool cgo -godefs input.
Russ Cox602a4462009-06-01 22:14:57 -0700184(
Russ Coxdd2abe52011-11-10 19:08:28 -0500185 echo package syscall
186 echo
187 echo '/*'
Russ Coxfd1add22009-11-01 11:13:27 -0800188 indirect="includes_$(uname)"
189 echo "${!indirect} $includes"
Russ Coxdd2abe52011-11-10 19:08:28 -0500190 echo '*/'
191 echo 'import "C"'
Russ Coxfd1add22009-11-01 11:13:27 -0800192 echo
Russ Coxdd2abe52011-11-10 19:08:28 -0500193 echo 'const ('
Russ Coxfd1add22009-11-01 11:13:27 -0800194
195 # The gcc command line prints all the #defines
196 # it encounters while processing the input
Russ Cox7906e312010-04-29 23:34:06 -0700197 echo "${!indirect} $includes" | $GCC -x c - -E -dM $ccflags |
Russ Coxfd1add22009-11-01 11:13:27 -0800198 awk '
Joel Singbf2d4032011-08-22 23:24:32 -0400199 $1 != "#define" || $2 ~ /\(/ || $3 == "" {next}
Mikio Hara6555cfc2010-12-09 13:55:59 -0500200
Russ Cox23bf4082010-05-03 11:11:01 -0700201 $2 ~ /^E([ABCD]X|[BIS]P|[SD]I|S|FL)$/ {next} # 386 registers
Russ Coxfd1add22009-11-01 11:13:27 -0800202 $2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next}
Albert Strasheimcf6c2122010-12-07 13:40:14 -0500203 $2 ~ /^(SCM_SRCRT)$/ {next}
204 $2 ~ /^(MAP_FAILED)$/ {next}
Russ Coxfd1add22009-11-01 11:13:27 -0800205
Mikio Hara6555cfc2010-12-09 13:55:59 -0500206 $2 !~ /^ETH_/ &&
Mikio Hara9c97af92011-02-11 14:34:00 -0500207 $2 !~ /^EPROC_/ &&
208 $2 !~ /^EQUIV_/ &&
209 $2 !~ /^EXPR_/ &&
Russ Coxfd1add22009-11-01 11:13:27 -0800210 $2 ~ /^E[A-Z0-9_]+$/ ||
Francisco Souza61060ac2012-05-03 17:33:19 -0400211 $2 ~ /^B[0-9_]+$/ ||
212 $2 ~ /^V[A-Z0-9]+$/ ||
213 $2 ~ /^CS[A-Z0-9]/ ||
214 $2 ~ /^I(SIG|CANON|CRNL|EXTEN|MAXBEL|STRIP|UTF8)$/ ||
215 $2 ~ /^IGN/ ||
216 $2 ~ /^IX(ON|ANY|OFF)$/ ||
217 $2 ~ /^IN(LCR|PCK)$/ ||
218 $2 ~ /(^FLU?SH)|(FLU?SH$)/ ||
219 $2 ~ /^C(LOCAL|READ)$/ ||
220 $2 == "BRKINT" ||
221 $2 == "HUPCL" ||
222 $2 == "PENDIN" ||
223 $2 == "TOSTOP" ||
224 $2 ~ /^PAR/ ||
Russ Coxfd1add22009-11-01 11:13:27 -0800225 $2 ~ /^SIG[^_]/ ||
Francisco Souza61060ac2012-05-03 17:33:19 -0400226 $2 ~ /^O[CNPFP][A-Z]+[^_][A-Z]+$/ ||
Balazs Lecz4bfcfcf2010-09-27 11:44:26 -0400227 $2 ~ /^IN_/ ||
Andrea Spadaccini83c30f32011-12-08 15:12:08 +0900228 $2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
Mikio Haraadbe59e2013-05-23 16:22:05 +0900229 $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
230 $2 == "ICMPV6_FILTER" ||
Russ Coxfd1add22009-11-01 11:13:27 -0800231 $2 == "SOMAXCONN" ||
232 $2 == "NAME_MAX" ||
Mikio Hara6555cfc2010-12-09 13:55:59 -0500233 $2 == "IFNAMSIZ" ||
Joel Sing495a9dc2012-05-23 01:33:48 +1000234 $2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ ||
235 $2 ~ /^SYSCTL_VERS/ ||
David Andersonad102e12011-03-09 05:58:47 -0800236 $2 ~ /^(MS|MNT)_/ ||
Mikio Hara6555cfc2010-12-09 13:55:59 -0500237 $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
Jeff Hodges0ce57a72011-06-14 12:56:46 -0400238 $2 ~ /^(O|F|FD|NAME|S|PTRACE|PT)_/ ||
David Anderson05660b72011-03-09 05:45:08 -0800239 $2 ~ /^LINUX_REBOOT_CMD_/ ||
240 $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
Mikio Hara1d550bd2011-05-18 16:33:41 -0700241 $2 !~ "NLA_TYPE_MASK" &&
Mikio Harab1d51c62013-02-24 12:04:48 +0900242 $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P)_/ ||
Mikio Hara9c97af92011-02-11 14:34:00 -0500243 $2 ~ /^SIOC/ ||
Ken Rockotc8443d72011-06-22 18:07:20 -0400244 $2 ~ /^TIOC/ ||
Mikio Hara12376c92011-05-26 20:02:03 -0400245 $2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
Mikio Hara5a59b9e2011-04-04 15:40:40 -0400246 $2 ~ /^BIOC/ ||
Sébastien Paolaccie2467f02011-11-19 15:17:40 +0900247 $2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
248 $2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|NOFILE|STACK)|RLIM_INFINITY/ ||
Shenghou Ma46e30c72013-06-11 02:47:04 +0800249 $2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
Rémy Oudomphengd4f719e2013-08-23 22:26:49 +0200250 $2 ~ /^CLONE_[A-Z_]+/ ||
Mikio Hara380f4ab2011-04-21 16:58:20 -0400251 $2 !~ /^(BPF_TIMEVAL)$/ &&
Mikio Hara5a59b9e2011-04-04 15:40:40 -0400252 $2 ~ /^(BPF|DLT)_/ ||
Mikio Hara9c97af92011-02-11 14:34:00 -0500253 $2 !~ "WMESGLEN" &&
Russ Coxdd2abe52011-11-10 19:08:28 -0500254 $2 ~ /^W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", $2, $2)}
Russ Cox23bf4082010-05-03 11:11:01 -0700255 $2 ~ /^__WCOREFLAG$/ {next}
Russ Coxdd2abe52011-11-10 19:08:28 -0500256 $2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
Mikio Hara6555cfc2010-12-09 13:55:59 -0500257
Russ Coxfd1add22009-11-01 11:13:27 -0800258 {next}
259 ' | sort
260
Russ Coxdd2abe52011-11-10 19:08:28 -0500261 echo ')'
262) >_const.go
Russ Coxfd1add22009-11-01 11:13:27 -0800263
Russ Cox35586f72012-02-13 13:52:37 -0500264# Pull out the error names for later.
Russ Coxfd1add22009-11-01 11:13:27 -0800265errors=$(
Russ Cox7906e312010-04-29 23:34:06 -0700266 echo '#include <errno.h>' | $GCC -x c - -E -dM $ccflags |
Russ Cox0b126c12009-12-01 16:53:43 -0800267 awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' |
268 sort
Russ Coxfd1add22009-11-01 11:13:27 -0800269)
Russ Cox602a4462009-06-01 22:14:57 -0700270
Russ Cox35586f72012-02-13 13:52:37 -0500271# Pull out the signal names for later.
272signals=$(
273 echo '#include <signal.h>' | $GCC -x c - -E -dM $ccflags |
274 awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
275 egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
276 sort
277)
278
Russ Coxc017a822011-11-13 22:44:52 -0500279# Again, writing regexps to a file.
280echo '#include <errno.h>' | $GCC -x c - -E -dM $ccflags |
281 awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' |
282 sort >_error.grep
Russ Cox35586f72012-02-13 13:52:37 -0500283echo '#include <signal.h>' | $GCC -x c - -E -dM $ccflags |
284 awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
285 egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
286 sort >_signal.grep
Russ Coxc017a822011-11-13 22:44:52 -0500287
Rob Pikecd324982009-08-13 13:22:37 -0700288echo '// mkerrors.sh' "$@"
Russ Cox602a4462009-06-01 22:14:57 -0700289echo '// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT'
290echo
Mikio Hara44122ed2012-02-03 12:22:40 +0900291go tool cgo -godefs -- "$@" _const.go >_error.out
Russ Cox35586f72012-02-13 13:52:37 -0500292cat _error.out | grep -vf _error.grep | grep -vf _signal.grep
Russ Coxc017a822011-11-13 22:44:52 -0500293echo
294echo '// Errors'
295echo 'const ('
296cat _error.out | grep -f _error.grep | sed 's/=\(.*\)/= Errno(\1)/'
297echo ')'
Russ Cox602a4462009-06-01 22:14:57 -0700298
Russ Cox35586f72012-02-13 13:52:37 -0500299echo
300echo '// Signals'
301echo 'const ('
302cat _error.out | grep -f _signal.grep | sed 's/=\(.*\)/= Signal(\1)/'
303echo ')'
304
305# Run C program to print error and syscall strings.
Russ Cox602a4462009-06-01 22:14:57 -0700306(
Russ Cox9feee912009-08-24 11:03:23 -0700307 /bin/echo "
Russ Cox602a4462009-06-01 22:14:57 -0700308#include <stdio.h>
309#include <errno.h>
310#include <ctype.h>
311#include <string.h>
Russ Cox35586f72012-02-13 13:52:37 -0500312#include <signal.h>
Russ Cox602a4462009-06-01 22:14:57 -0700313
314#define nelem(x) (sizeof(x)/sizeof((x)[0]))
315
316enum { A = 'A', Z = 'Z', a = 'a', z = 'z' }; // avoid need for single quotes below
317
318int errors[] = {
319"
320 for i in $errors
321 do
Russ Cox9feee912009-08-24 11:03:23 -0700322 /bin/echo ' '$i,
Russ Cox602a4462009-06-01 22:14:57 -0700323 done
324
Russ Cox35586f72012-02-13 13:52:37 -0500325 /bin/echo "
326};
327
328int signals[] = {
329"
330 for i in $signals
331 do
332 /bin/echo ' '$i,
333 done
334
Russ Cox9feee912009-08-24 11:03:23 -0700335 # Use /bin/echo to avoid builtin echo,
336 # which interprets \n itself
337 /bin/echo '
Russ Cox602a4462009-06-01 22:14:57 -0700338};
339
Russ Cox9a96fb32010-09-24 13:37:02 -0400340static int
341intcmp(const void *a, const void *b)
342{
343 return *(int*)a - *(int*)b;
344}
345
Russ Cox602a4462009-06-01 22:14:57 -0700346int
347main(void)
348{
349 int i, j, e;
Russ Cox35586f72012-02-13 13:52:37 -0500350 char buf[1024], *p;
Russ Cox602a4462009-06-01 22:14:57 -0700351
352 printf("\n\n// Error table\n");
353 printf("var errors = [...]string {\n");
Russ Cox9a96fb32010-09-24 13:37:02 -0400354 qsort(errors, nelem(errors), sizeof errors[0], intcmp);
Russ Cox602a4462009-06-01 22:14:57 -0700355 for(i=0; i<nelem(errors); i++) {
356 e = errors[i];
Russ Cox9a96fb32010-09-24 13:37:02 -0400357 if(i > 0 && errors[i-1] == e)
358 continue;
Russ Cox602a4462009-06-01 22:14:57 -0700359 strcpy(buf, strerror(e));
360 // lowercase first letter: Bad -> bad, but STREAM -> STREAM.
361 if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
362 buf[0] += a - A;
363 printf("\t%d: \"%s\",\n", e, buf);
Russ Cox602a4462009-06-01 22:14:57 -0700364 }
365 printf("}\n\n");
Russ Cox35586f72012-02-13 13:52:37 -0500366
367 printf("\n\n// Signal table\n");
368 printf("var signals = [...]string {\n");
369 qsort(signals, nelem(signals), sizeof signals[0], intcmp);
370 for(i=0; i<nelem(signals); i++) {
371 e = signals[i];
372 if(i > 0 && signals[i-1] == e)
373 continue;
374 strcpy(buf, strsignal(e));
375 // lowercase first letter: Bad -> bad, but STREAM -> STREAM.
376 if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
377 buf[0] += a - A;
378 // cut trailing : number.
379 p = strrchr(buf, ":"[0]);
380 if(p)
381 *p = '\0';
382 printf("\t%d: \"%s\",\n", e, buf);
383 }
384 printf("}\n\n");
385
Russ Coxfd1add22009-11-01 11:13:27 -0800386 return 0;
Russ Cox602a4462009-06-01 22:14:57 -0700387}
388
389'
390) >_errors.c
391
Russ Cox35586f72012-02-13 13:52:37 -0500392$GCC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out