1*6eef5f0cSAntonio Huete Jimenez /* $NetBSD: metachar.c,v 1.10 2021/06/21 18:54:41 rillig Exp $ */ 2f445c897SJohn Marino 3a34d5fb1SAntonio Huete Jimenez /* 4f445c897SJohn Marino * Copyright (c) 2015 The NetBSD Foundation, Inc. 5f445c897SJohn Marino * All rights reserved. 6f445c897SJohn Marino * 7f445c897SJohn Marino * This code is derived from software contributed to The NetBSD Foundation 8f445c897SJohn Marino * by Christos Zoulas. 9f445c897SJohn Marino * 10f445c897SJohn Marino * Redistribution and use in source and binary forms, with or without 11f445c897SJohn Marino * modification, are permitted provided that the following conditions 12f445c897SJohn Marino * are met: 13f445c897SJohn Marino * 1. Redistributions of source code must retain the above copyright 14f445c897SJohn Marino * notice, this list of conditions and the following disclaimer. 15f445c897SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright 16f445c897SJohn Marino * notice, this list of conditions and the following disclaimer in the 17f445c897SJohn Marino * documentation and/or other materials provided with the distribution. 18f445c897SJohn Marino * 19f445c897SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20f445c897SJohn Marino * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21f445c897SJohn Marino * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22f445c897SJohn Marino * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23f445c897SJohn Marino * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24f445c897SJohn Marino * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25f445c897SJohn Marino * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26f445c897SJohn Marino * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27f445c897SJohn Marino * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28f445c897SJohn Marino * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29f445c897SJohn Marino * POSSIBILITY OF SUCH DAMAGE. 30f445c897SJohn Marino */ 31f445c897SJohn Marino 32f445c897SJohn Marino #if HAVE_NBTOOL_CONFIG_H 33f445c897SJohn Marino #include "nbtool_config.h" 34f445c897SJohn Marino #endif 35f445c897SJohn Marino 36f445c897SJohn Marino #if defined(MAKE_NATIVE) || defined(HAVE_NBTOOL_CONFIG_H) 37f445c897SJohn Marino #include <sys/cdefs.h> 38f445c897SJohn Marino #endif 39f445c897SJohn Marino 40f445c897SJohn Marino #include "metachar.h" 41a34d5fb1SAntonio Huete Jimenez 42*6eef5f0cSAntonio Huete Jimenez MAKE_RCSID("$NetBSD: metachar.c,v 1.10 2021/06/21 18:54:41 rillig Exp $"); 43a34d5fb1SAntonio Huete Jimenez 44f445c897SJohn Marino /* 45f445c897SJohn Marino * The following array is used to make a fast determination of which 46f445c897SJohn Marino * characters are interpreted specially by the shell. If a command 47f445c897SJohn Marino * contains any of these characters, it is executed by the shell, not 48f445c897SJohn Marino * directly by us. 49f445c897SJohn Marino */ 50f445c897SJohn Marino 51*6eef5f0cSAntonio Huete Jimenez const unsigned char _metachar[128] = { 52a34d5fb1SAntonio Huete Jimenez /* nul soh stx etx eot enq ack bel */ 53f445c897SJohn Marino 1, 0, 0, 0, 0, 0, 0, 0, 54a34d5fb1SAntonio Huete Jimenez /* bs ht nl vt np cr so si */ 55f445c897SJohn Marino 0, 0, 1, 0, 0, 0, 0, 0, 56a34d5fb1SAntonio Huete Jimenez /* dle dc1 dc2 dc3 dc4 nak syn etb */ 57f445c897SJohn Marino 0, 0, 0, 0, 0, 0, 0, 0, 58a34d5fb1SAntonio Huete Jimenez /* can em sub esc fs gs rs us */ 59f445c897SJohn Marino 0, 0, 0, 0, 0, 0, 0, 0, 60a34d5fb1SAntonio Huete Jimenez /* sp ! " # $ % & ' */ 61f445c897SJohn Marino 0, 1, 1, 1, 1, 0, 1, 1, 62a34d5fb1SAntonio Huete Jimenez /* ( ) * + , - . / */ 63f445c897SJohn Marino 1, 1, 1, 0, 0, 0, 0, 0, 64a34d5fb1SAntonio Huete Jimenez /* 0 1 2 3 4 5 6 7 */ 65f445c897SJohn Marino 0, 0, 0, 0, 0, 0, 0, 0, 66a34d5fb1SAntonio Huete Jimenez /* 8 9 : ; < = > ? */ 67f445c897SJohn Marino 0, 0, 0, 1, 1, 0, 1, 1, 68a34d5fb1SAntonio Huete Jimenez /* @ A B C D E F G */ 69f445c897SJohn Marino 0, 0, 0, 0, 0, 0, 0, 0, 70a34d5fb1SAntonio Huete Jimenez /* H I J K L M N O */ 71f445c897SJohn Marino 0, 0, 0, 0, 0, 0, 0, 0, 72a34d5fb1SAntonio Huete Jimenez /* P Q R S T U V W */ 73f445c897SJohn Marino 0, 0, 0, 0, 0, 0, 0, 0, 74a34d5fb1SAntonio Huete Jimenez /* X Y Z [ \ ] ^ _ */ 75f445c897SJohn Marino 0, 0, 0, 1, 1, 1, 1, 0, 76a34d5fb1SAntonio Huete Jimenez /* ` a b c d e f g */ 77f445c897SJohn Marino 1, 0, 0, 0, 0, 0, 0, 0, 78a34d5fb1SAntonio Huete Jimenez /* h i j k l m n o */ 79f445c897SJohn Marino 0, 0, 0, 0, 0, 0, 0, 0, 80a34d5fb1SAntonio Huete Jimenez /* p q r s t u v w */ 81f445c897SJohn Marino 0, 0, 0, 0, 0, 0, 0, 0, 82a34d5fb1SAntonio Huete Jimenez /* x y z { | } ~ del */ 83f445c897SJohn Marino 0, 0, 0, 1, 1, 1, 1, 0, 84f445c897SJohn Marino }; 85