xref: /freebsd/contrib/bmake/metachar.h (revision dba7b0ef928af88caa38728a73657b837aeeac93)
1*dba7b0efSSimon J. Gerraty /*	$NetBSD: metachar.h,v 1.15 2021/01/19 20:51:46 rillig Exp $	*/
24c620fe5SSimon J. Gerraty 
3*dba7b0efSSimon 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  */
312c3632d1SSimon J. Gerraty #ifndef MAKE_METACHAR_H
322c3632d1SSimon J. Gerraty #define MAKE_METACHAR_H
334c620fe5SSimon J. Gerraty 
342c3632d1SSimon J. Gerraty #include "make.h"
354c620fe5SSimon J. Gerraty 
364c620fe5SSimon J. Gerraty extern unsigned char _metachar[];
374c620fe5SSimon J. Gerraty 
3806b9b3e0SSimon J. Gerraty #define is_shell_metachar(c)	(_metachar[(c) & 0x7f] != 0)
394c620fe5SSimon J. Gerraty 
40*dba7b0efSSimon J. Gerraty MAKE_INLINE Boolean
41956e45f6SSimon J. Gerraty needshell(const char *cmd)
424c620fe5SSimon J. Gerraty {
43956e45f6SSimon J. Gerraty 	while (!is_shell_metachar(*cmd) && *cmd != ':' && *cmd != '=')
444c620fe5SSimon J. Gerraty 		cmd++;
454c620fe5SSimon J. Gerraty 	return *cmd != '\0';
464c620fe5SSimon J. Gerraty }
474c620fe5SSimon J. Gerraty 
482c3632d1SSimon J. Gerraty #endif /* MAKE_METACHAR_H */
49