metachar.c revision 289842
118334Speter/* $NetBSD: metachar.c,v 1.5 2015/06/19 08:03:35 mlelstv Exp $ */ 290075Sobrien 3169689Skan/*- 418334Speter * Copyright (c) 2015 The NetBSD Foundation, Inc. 590075Sobrien * All rights reserved. 618334Speter * 790075Sobrien * This code is derived from software contributed to The NetBSD Foundation 890075Sobrien * by Christos Zoulas. 990075Sobrien * 1090075Sobrien * Redistribution and use in source and binary forms, with or without 1118334Speter * modification, are permitted provided that the following conditions 1290075Sobrien * are met: 1390075Sobrien * 1. Redistributions of source code must retain the above copyright 1490075Sobrien * notice, this list of conditions and the following disclaimer. 1590075Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1618334Speter * notice, this list of conditions and the following disclaimer in the 1718334Speter * documentation and/or other materials provided with the distribution. 1890075Sobrien * 19169689Skan * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20169689Skan * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2118334Speter * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2218334Speter * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2318334Speter * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2450397Sobrien * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25132718Skan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26132718Skan * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2718334Speter * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2850397Sobrien * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29117395Skan * POSSIBILITY OF SUCH DAMAGE. 30117395Skan */ 3190075Sobrien 3290075Sobrien#if HAVE_NBTOOL_CONFIG_H 33169689Skan#include "nbtool_config.h" 34132718Skan#endif 35169689Skan 36169689Skan#if defined(MAKE_NATIVE) || defined(HAVE_NBTOOL_CONFIG_H) 3718334Speter#include <sys/cdefs.h> 38132718Skan#endif 39132718Skan 40169689Skan#if defined(__RCSID) && !defined(lint) 41169689Skan__RCSID("$NetBSD: metachar.c,v 1.5 2015/06/19 08:03:35 mlelstv Exp $"); 4218334Speter#endif 4390075Sobrien 4490075Sobrien#include "metachar.h" 4590075Sobrien/* 46117395Skan * The following array is used to make a fast determination of which 4750397Sobrien * characters are interpreted specially by the shell. If a command 48169689Skan * contains any of these characters, it is executed by the shell, not 4990075Sobrien * directly by us. 5090075Sobrien * 51117395Skan * perhaps move it to ctype? 52117395Skan */ 53117395Skan 54117395Skanunsigned char _metachar[128] = { 55169689Skan// nul soh stx etx eot enq ack bel 56117395Skan 1, 0, 0, 0, 0, 0, 0, 0, 57169689Skan// bs ht nl vt np cr so si 58117395Skan 0, 0, 1, 0, 0, 0, 0, 0, 59117395Skan// dle dc1 dc2 dc3 dc4 nak syn etb 60117395Skan 0, 0, 0, 0, 0, 0, 0, 0, 61117395Skan// can em sub esc fs gs rs us 62117395Skan 0, 0, 0, 0, 0, 0, 0, 0, 63117395Skan// sp ! " # $ % & ' 64117395Skan 0, 1, 1, 1, 1, 0, 1, 1, 65117395Skan// ( ) * + , - . / 66117395Skan 1, 1, 1, 0, 0, 0, 0, 0, 67117395Skan// 0 1 2 3 4 5 6 7 68117395Skan 0, 0, 0, 0, 0, 0, 0, 0, 69117395Skan// 8 9 : ; < = > ? 70117395Skan 0, 0, 0, 1, 1, 0, 1, 1, 71117395Skan// @ A B C D E F G 72117395Skan 0, 0, 0, 0, 0, 0, 0, 0, 73117395Skan// H I J K L M N O 74117395Skan 0, 0, 0, 0, 0, 0, 0, 0, 75117395Skan// P Q R S T U V W 76117395Skan 0, 0, 0, 0, 0, 0, 0, 0, 77117395Skan// X Y Z [ \ ] ^ _ 78117395Skan 0, 0, 0, 1, 1, 1, 1, 0, 79117395Skan// ` a b c d e f g 80117395Skan 1, 0, 0, 0, 0, 0, 0, 0, 81117395Skan// h i j k l m n o 82117395Skan 0, 0, 0, 0, 0, 0, 0, 0, 83117395Skan// p q r s t u v w 84117395Skan 0, 0, 0, 0, 0, 0, 0, 0, 85117395Skan// x y z { | } ~ del 86169689Skan 0, 0, 0, 1, 1, 1, 1, 0, 87169689Skan}; 8818334Speter 89132718Skan