1289720Ssjg/*	$NetBSD: metachar.c,v 1.5 2015/06/19 08:03:35 mlelstv Exp $	*/
2289720Ssjg
3289720Ssjg/*-
4289720Ssjg * Copyright (c) 2015 The NetBSD Foundation, Inc.
5289720Ssjg * All rights reserved.
6289720Ssjg *
7289720Ssjg * This code is derived from software contributed to The NetBSD Foundation
8289720Ssjg * by Christos Zoulas.
9289720Ssjg *
10289720Ssjg * Redistribution and use in source and binary forms, with or without
11289720Ssjg * modification, are permitted provided that the following conditions
12289720Ssjg * are met:
13289720Ssjg * 1. Redistributions of source code must retain the above copyright
14289720Ssjg *    notice, this list of conditions and the following disclaimer.
15289720Ssjg * 2. Redistributions in binary form must reproduce the above copyright
16289720Ssjg *    notice, this list of conditions and the following disclaimer in the
17289720Ssjg *    documentation and/or other materials provided with the distribution.
18289720Ssjg *
19289720Ssjg * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20289720Ssjg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21289720Ssjg * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22289720Ssjg * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23289720Ssjg * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24289720Ssjg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25289720Ssjg * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26289720Ssjg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27289720Ssjg * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28289720Ssjg * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29289720Ssjg * POSSIBILITY OF SUCH DAMAGE.
30289720Ssjg */
31289720Ssjg
32289720Ssjg#if HAVE_NBTOOL_CONFIG_H
33289720Ssjg#include "nbtool_config.h"
34289720Ssjg#endif
35289720Ssjg
36289720Ssjg#if defined(MAKE_NATIVE) || defined(HAVE_NBTOOL_CONFIG_H)
37289720Ssjg#include <sys/cdefs.h>
38289720Ssjg#endif
39289720Ssjg
40289720Ssjg#if defined(__RCSID) && !defined(lint)
41289720Ssjg__RCSID("$NetBSD: metachar.c,v 1.5 2015/06/19 08:03:35 mlelstv Exp $");
42289720Ssjg#endif
43289720Ssjg
44289720Ssjg#include "metachar.h"
45289720Ssjg/*
46289720Ssjg * The following array is used to make a fast determination of which
47289720Ssjg * characters are interpreted specially by the shell.  If a command
48289720Ssjg * contains any of these characters, it is executed by the shell, not
49289720Ssjg * directly by us.
50289720Ssjg *
51289720Ssjg * perhaps move it to ctype?
52289720Ssjg */
53289720Ssjg
54289720Ssjgunsigned char _metachar[128] = {
55289720Ssjg//    nul   soh   stx   etx   eot   enq   ack   bel
56289720Ssjg	1,    0,    0,    0,    0,    0,    0,    0,
57289720Ssjg//     bs    ht    nl    vt    np    cr    so    si
58289720Ssjg	0,    0,    1,    0,	0,    0,    0,    0,
59289720Ssjg//    dle   dc1   dc2   dc3   dc4   nak   syn   etb
60289720Ssjg	0,    0,    0,    0,    0,    0,    0,    0,
61289720Ssjg//    can    em   sub   esc    fs    gs    rs    us
62289720Ssjg	0,    0,    0,    0,    0,    0,    0,    0,
63289720Ssjg//     sp     !     "     #     $     %     &     '
64289720Ssjg	0,    1,    1,    1,    1,    0,    1,    1,
65289720Ssjg//      (     )     *     +     ,     -     .     /
66289720Ssjg	1,    1,    1,    0,    0,    0,    0,    0,
67289720Ssjg//      0     1     2     3     4     5     6     7
68289720Ssjg	0,    0,    0,    0,    0,    0,    0,    0,
69289720Ssjg//      8     9     :     ;     <     =     >     ?
70289720Ssjg	0,    0,    0,    1,    1,    0,    1,    1,
71289720Ssjg//      @     A     B     C     D     E     F     G
72289720Ssjg	0,    0,    0,    0,    0,    0,    0,    0,
73289720Ssjg//      H     I     J     K     L     M     N     O
74289720Ssjg	0,    0,    0,    0,    0,    0,    0,    0,
75289720Ssjg//      P     Q     R     S     T     U     V     W
76289720Ssjg	0,    0,    0,    0,    0,    0,    0,    0,
77289720Ssjg//      X     Y     Z     [     \     ]     ^     _
78289720Ssjg	0,    0,    0,    1,    1,    1,    1,    0,
79289720Ssjg//      `     a     b     c     d     e     f     g
80289720Ssjg	1,    0,    0,    0,    0,    0,    0,    0,
81289720Ssjg//      h     i     j     k     l     m     n     o
82289720Ssjg	0,    0,    0,    0,    0,    0,    0,    0,
83289720Ssjg//      p     q     r     s     t     u     v     w
84289720Ssjg	0,    0,    0,    0,    0,    0,    0,    0,
85289720Ssjg//      x     y     z     {     |     }     ~   del
86289720Ssjg	0,    0,    0,    1,    1,    1,    1,    0,
87289720Ssjg};
88289720Ssjg
89