xref: /dragonfly/contrib/bmake/metachar.h (revision 6eef5f0c)
1*6eef5f0cSAntonio Huete Jimenez /*	$NetBSD: metachar.h,v 1.20 2022/01/08 11:04:13 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  */
31a34d5fb1SAntonio Huete Jimenez #ifndef MAKE_METACHAR_H
32a34d5fb1SAntonio Huete Jimenez #define MAKE_METACHAR_H
33f445c897SJohn Marino 
34a34d5fb1SAntonio Huete Jimenez #include "make.h"
35f445c897SJohn Marino 
36*6eef5f0cSAntonio Huete Jimenez extern const unsigned char _metachar[];
37f445c897SJohn Marino 
38*6eef5f0cSAntonio Huete Jimenez MAKE_INLINE bool MAKE_ATTR_USE
ch_is_shell_meta(char c)39*6eef5f0cSAntonio Huete Jimenez ch_is_shell_meta(char c)
40*6eef5f0cSAntonio Huete Jimenez {
41*6eef5f0cSAntonio Huete Jimenez 	return _metachar[c & 0x7f] != 0;
42*6eef5f0cSAntonio Huete Jimenez }
43f445c897SJohn Marino 
44*6eef5f0cSAntonio Huete Jimenez MAKE_INLINE bool MAKE_ATTR_USE
needshell(const char * cmd)45a34d5fb1SAntonio Huete Jimenez needshell(const char *cmd)
46f445c897SJohn Marino {
47*6eef5f0cSAntonio Huete Jimenez 	while (!ch_is_shell_meta(*cmd) && *cmd != ':' && *cmd != '=')
48f445c897SJohn Marino 		cmd++;
49f445c897SJohn Marino 	return *cmd != '\0';
50f445c897SJohn Marino }
51f445c897SJohn Marino 
52*6eef5f0cSAntonio Huete Jimenez #endif
53