source: trunk/minix/commands/ash/bltin/mkexpr@ 9

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

Minix 3.1.2a

File size: 1.6 KB
Line 
1# Copyright 1989 by Kenneth Almquist. All rights reserved.
2#
3# This file is part of ash. Ash is distributed under the terms specified
4# by the Ash General Public License. See the file named LICENSE.
5
6# All calls to awk removed, because Minix bawk is deficient. (kjb)
7
8exec > operators.h
9i=0
10sed -e '/^[^#]/!d' unary_op binary_op | while read line
11do
12 set -$- $line
13 echo "#define $1 $i"
14 i=`expr $i + 1`
15done
16echo
17echo "#define FIRST_BINARY_OP" `sed -e '/^[^#]/!d' unary_op | wc -l`
18echo '
19#define OP_INT 1 /* arguments to operator are integer */
20#define OP_STRING 2 /* arguments to operator are string */
21#define OP_FILE 3 /* argument is a file name */
22#define OP_LFILE 4 /* argument is a file name of a symlink? */
23
24extern char *const unary_op[];
25extern char *const binary_op[];
26extern const char op_priority[];
27extern const char op_argflag[];'
28
29exec > operators.c
30echo '/*
31 * Operators used in the expr/test command.
32 */
33
34#include "../shell.h"
35#include "operators.h"
36
37char *const unary_op[] = {'
38sed -e '/^[^#]/!d
39 s/[ ][ ]*/ /g
40 s/^[^ ][^ ]* \([^ ][^ ]*\).*/ "\1",/
41 ' unary_op
42echo ' NULL
43};
44
45char *const binary_op[] = {'
46sed -e '/^[^#]/!d
47 s/[ ][ ]*/ /g
48 s/^[^ ][^ ]* \([^ ][^ ]*\).*/ "\1",/
49 ' binary_op
50echo ' NULL
51};
52
53const char op_priority[] = {'
54sed -e '/^[^#]/!d
55 s/[ ][ ]*/ /g
56 s/^[^ ][^ ]* [^ ][^ ]* \([^ ][^ ]*\).*/ \1,/
57 ' unary_op binary_op
58echo '};
59
60const char op_argflag[] = {'
61sed -e '/^[^#]/!d
62 s/[ ][ ]*/ /g
63 s/^[^ ][^ ]* [^ ][^ ]* [^ ][^ ]*$/& 0/
64 s/^[^ ][^ ]* [^ ][^ ]* [^ ][^ ]* \([^ ][^ ]*\)/ \1,/
65 ' unary_op binary_op
66echo '};'
Note: See TracBrowser for help on using the repository browser.