1*12904384SSimon J. Gerraty /* $NetBSD: metachar.c,v 1.10 2021/06/21 18:54:41 rillig Exp $ */ 24c620fe5SSimon J. Gerraty 3dba7b0efSSimon J. Gerraty /* 44c620fe5SSimon J. Gerraty * Copyright (c) 2015 The NetBSD Foundation, Inc. 54c620fe5SSimon J. Gerraty * All rights reserved. 64c620fe5SSimon J. Gerraty * 74c620fe5SSimon J. Gerraty * This code is derived from software contributed to The NetBSD Foundation 84c620fe5SSimon J. Gerraty * by Christos Zoulas. 94c620fe5SSimon J. Gerraty * 104c620fe5SSimon J. Gerraty * Redistribution and use in source and binary forms, with or without 114c620fe5SSimon J. Gerraty * modification, are permitted provided that the following conditions 124c620fe5SSimon J. Gerraty * are met: 134c620fe5SSimon J. Gerraty * 1. Redistributions of source code must retain the above copyright 144c620fe5SSimon J. Gerraty * notice, this list of conditions and the following disclaimer. 154c620fe5SSimon J. Gerraty * 2. Redistributions in binary form must reproduce the above copyright 164c620fe5SSimon J. Gerraty * notice, this list of conditions and the following disclaimer in the 174c620fe5SSimon J. Gerraty * documentation and/or other materials provided with the distribution. 184c620fe5SSimon J. Gerraty * 194c620fe5SSimon J. Gerraty * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 204c620fe5SSimon J. Gerraty * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 214c620fe5SSimon J. Gerraty * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 224c620fe5SSimon J. Gerraty * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 234c620fe5SSimon J. Gerraty * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 244c620fe5SSimon J. Gerraty * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 254c620fe5SSimon J. Gerraty * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 264c620fe5SSimon J. Gerraty * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 274c620fe5SSimon J. Gerraty * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 284c620fe5SSimon J. Gerraty * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 294c620fe5SSimon J. Gerraty * POSSIBILITY OF SUCH DAMAGE. 304c620fe5SSimon J. Gerraty */ 314c620fe5SSimon J. Gerraty 324c620fe5SSimon J. Gerraty #if HAVE_NBTOOL_CONFIG_H 334c620fe5SSimon J. Gerraty #include "nbtool_config.h" 344c620fe5SSimon J. Gerraty #endif 354c620fe5SSimon J. Gerraty 364c620fe5SSimon J. Gerraty #if defined(MAKE_NATIVE) || defined(HAVE_NBTOOL_CONFIG_H) 374c620fe5SSimon J. Gerraty #include <sys/cdefs.h> 384c620fe5SSimon J. Gerraty #endif 394c620fe5SSimon J. Gerraty 404c620fe5SSimon J. Gerraty #include "metachar.h" 41956e45f6SSimon J. Gerraty 42*12904384SSimon J. Gerraty MAKE_RCSID("$NetBSD: metachar.c,v 1.10 2021/06/21 18:54:41 rillig Exp $"); 43956e45f6SSimon J. Gerraty 444c620fe5SSimon J. Gerraty /* 454c620fe5SSimon J. Gerraty * The following array is used to make a fast determination of which 464c620fe5SSimon J. Gerraty * characters are interpreted specially by the shell. If a command 474c620fe5SSimon J. Gerraty * contains any of these characters, it is executed by the shell, not 484c620fe5SSimon J. Gerraty * directly by us. 494c620fe5SSimon J. Gerraty */ 504c620fe5SSimon J. Gerraty 51*12904384SSimon J. Gerraty const unsigned char _metachar[128] = { 522c3632d1SSimon J. Gerraty /* nul soh stx etx eot enq ack bel */ 534c620fe5SSimon J. Gerraty 1, 0, 0, 0, 0, 0, 0, 0, 542c3632d1SSimon J. Gerraty /* bs ht nl vt np cr so si */ 554c620fe5SSimon J. Gerraty 0, 0, 1, 0, 0, 0, 0, 0, 562c3632d1SSimon J. Gerraty /* dle dc1 dc2 dc3 dc4 nak syn etb */ 574c620fe5SSimon J. Gerraty 0, 0, 0, 0, 0, 0, 0, 0, 582c3632d1SSimon J. Gerraty /* can em sub esc fs gs rs us */ 594c620fe5SSimon J. Gerraty 0, 0, 0, 0, 0, 0, 0, 0, 602c3632d1SSimon J. Gerraty /* sp ! " # $ % & ' */ 614c620fe5SSimon J. Gerraty 0, 1, 1, 1, 1, 0, 1, 1, 622c3632d1SSimon J. Gerraty /* ( ) * + , - . / */ 634c620fe5SSimon J. Gerraty 1, 1, 1, 0, 0, 0, 0, 0, 642c3632d1SSimon J. Gerraty /* 0 1 2 3 4 5 6 7 */ 654c620fe5SSimon J. Gerraty 0, 0, 0, 0, 0, 0, 0, 0, 662c3632d1SSimon J. Gerraty /* 8 9 : ; < = > ? */ 674c620fe5SSimon J. Gerraty 0, 0, 0, 1, 1, 0, 1, 1, 682c3632d1SSimon J. Gerraty /* @ A B C D E F G */ 694c620fe5SSimon J. Gerraty 0, 0, 0, 0, 0, 0, 0, 0, 702c3632d1SSimon J. Gerraty /* H I J K L M N O */ 714c620fe5SSimon J. Gerraty 0, 0, 0, 0, 0, 0, 0, 0, 722c3632d1SSimon J. Gerraty /* P Q R S T U V W */ 734c620fe5SSimon J. Gerraty 0, 0, 0, 0, 0, 0, 0, 0, 742c3632d1SSimon J. Gerraty /* X Y Z [ \ ] ^ _ */ 754c620fe5SSimon J. Gerraty 0, 0, 0, 1, 1, 1, 1, 0, 762c3632d1SSimon J. Gerraty /* ` a b c d e f g */ 774c620fe5SSimon J. Gerraty 1, 0, 0, 0, 0, 0, 0, 0, 782c3632d1SSimon J. Gerraty /* h i j k l m n o */ 794c620fe5SSimon J. Gerraty 0, 0, 0, 0, 0, 0, 0, 0, 802c3632d1SSimon J. Gerraty /* p q r s t u v w */ 814c620fe5SSimon J. Gerraty 0, 0, 0, 0, 0, 0, 0, 0, 822c3632d1SSimon J. Gerraty /* x y z { | } ~ del */ 834c620fe5SSimon J. Gerraty 0, 0, 0, 1, 1, 1, 1, 0, 844c620fe5SSimon J. Gerraty }; 85