1*9f45a3c8SSimon J. Gerraty /* $NetBSD: metachar.h,v 1.20 2022/01/08 11:04:13 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 */
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
3612904384SSimon J. Gerraty extern const unsigned char _metachar[];
374c620fe5SSimon J. Gerraty
38*9f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
ch_is_shell_meta(char c)39*9f45a3c8SSimon J. Gerraty ch_is_shell_meta(char c)
4012904384SSimon J. Gerraty {
4112904384SSimon J. Gerraty return _metachar[c & 0x7f] != 0;
4212904384SSimon J. Gerraty }
434c620fe5SSimon J. Gerraty
44*9f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
needshell(const char * cmd)45956e45f6SSimon J. Gerraty needshell(const char *cmd)
464c620fe5SSimon J. Gerraty {
47*9f45a3c8SSimon J. Gerraty while (!ch_is_shell_meta(*cmd) && *cmd != ':' && *cmd != '=')
484c620fe5SSimon J. Gerraty cmd++;
494c620fe5SSimon J. Gerraty return *cmd != '\0';
504c620fe5SSimon J. Gerraty }
514c620fe5SSimon J. Gerraty
52*9f45a3c8SSimon J. Gerraty #endif
53