1*53834Selan# Copyright 1989 by Kenneth Almquist. All rights reserved. 2*53834Selan# 3*53834Selan# This file is part of ash. Ash is distributed under the terms specified 4*53834Selan# by the Ash General Public License. See the file named LICENSE. 5*53834Selan 6*53834Selanexec > operators.h 7*53834Selanawk '/^[^#]/ {printf "#define %s %d\n", $1, n++}' unary_op binary_op 8*53834Selanawk '/^[^#]/ {n++} 9*53834SelanEND {printf "\n#define FIRST_BINARY_OP %d\n", n} 10*53834Selan' unary_op 11*53834Selanecho ' 12*53834Selan#define OP_INT 1 /* arguments to operator are integer */ 13*53834Selan#define OP_STRING 2 /* arguments to operator are string */ 14*53834Selan#define OP_FILE 3 /* argument is a file name */ 15*53834Selan 16*53834Selanextern char *const unary_op[]; 17*53834Selanextern char *const binary_op[]; 18*53834Selanextern const char op_priority[]; 19*53834Selanextern const char op_argflag[];' 20*53834Selan 21*53834Selanexec > operators.c 22*53834Selanecho '/* 23*53834Selan * Operators used in the test command. 24*53834Selan */ 25*53834Selan 26*53834Selan#include <stdio.h> 27*53834Selan#include "operators.h" 28*53834Selan 29*53834Selanchar *const unary_op[] = {' 30*53834Selanawk '/^[^#]/ {printf " \"%s\",\n", $2}' unary_op 31*53834Selanecho ' NULL 32*53834Selan}; 33*53834Selan 34*53834Selanchar *const binary_op[] = {' 35*53834Selanawk '/^[^#]/ {printf " \"%s\",\n", $2}' binary_op 36*53834Selanecho ' NULL 37*53834Selan}; 38*53834Selan 39*53834Selanconst char op_priority[] = {' 40*53834Selanawk '/^[^#]/ {printf " %s,\n", $3}' unary_op binary_op 41*53834Selanecho '}; 42*53834Selan 43*53834Selanconst char op_argflag[] = {' 44*53834Selanawk '/^[^#]/ {if (length($4) > 0) printf " %s,\n", $4 45*53834Selan else printf " 0,\n"} 46*53834Selan' unary_op binary_op 47*53834Selanecho '};' 48