source: trunk/minix/commands/ash/mkbuiltins@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 3.1 KB
Line 
1#!/bin/sh -
2#
3# Copyright (c) 1991 The Regents of the University of California.
4# All rights reserved.
5#
6# This code is derived from software contributed to Berkeley by
7# Kenneth Almquist.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions
11# are met:
12# 1. Redistributions of source code must retain the above copyright
13# notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15# notice, this list of conditions and the following disclaimer in the
16# documentation and/or other materials provided with the distribution.
17# 3. All advertising materials mentioning features or use of this software
18# must display the following acknowledgement:
19# This product includes software developed by the University of
20# California, Berkeley and its contributors.
21# 4. Neither the name of the University nor the names of its contributors
22# may be used to endorse or promote products derived from this software
23# without specific prior written permission.
24#
25# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35# SUCH DAMAGE.
36#
37# @(#)mkbuiltins 5.2 (Berkeley) 3/8/91
38
39# All calls to awk removed, because Minix bawk is deficient. (kjb)
40
41if [ $# != 2 ]
42then
43 echo "USAGE: $0 shell.h builtins"
44 exit 1
45fi
46SHL=$1
47BLTINS=$2
48
49temp=/tmp/ka$$
50exec > builtins.c
51cat <<\!
52/*
53 * This file was generated by the mkbuiltins program.
54 */
55
56#include "shell.h"
57#include "builtins.h"
58
59!
60if grep '^#define JOBS[ ]*1' $SHL > /dev/null
61then
62 # Job control.
63 sed -e '/^#/d
64 s/ / /g
65 s/ #.*//
66 /^ *$/d
67 s/-j//' $BLTINS > $temp
68else
69 # No job control.
70 sed -e '/^#/d
71 s/ / /g
72 s/ #.*//
73 /^ *$/d
74 /-j/d' $BLTINS > $temp
75fi
76sed -e 's/ .*//
77 s/\(.*\)/int \1();/' $temp
78echo '
79int (*const builtinfunc[])() = {'
80sed -e 's/ .*//
81 s/\(.*\)/ \1,/' $temp
82echo '};
83
84const struct builtincmd builtincmd[] = {'
85i=0
86while read line
87do
88 set -$- $line
89 shift
90 for fun
91 do
92 echo " \"$fun\", $i,"
93 done
94 i=`expr $i + 1`
95done < $temp
96echo ' NULL, 0
97};'
98
99exec > builtins.h
100cat <<\!
101/*
102 * This file was generated by the mkbuiltins program.
103 */
104
105#include <sys/cdefs.h>
106!
107i=0
108tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ < $temp |
109 while read line
110 do
111 set -$- $line
112 echo "#define $1 $i"
113 i=`expr $i + 1`
114 done
115echo '
116struct builtincmd {
117 char *name;
118 int code;
119};
120
121extern int (*const builtinfunc[])();
122extern const struct builtincmd builtincmd[];'
123rm -f $temp
Note: See TracBrowser for help on using the repository browser.