3 * SPDX-License-Identifier: BSD-4-Clause
6 * Bill Paul <wpaul@windriver.com>. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Bill Paul.
19 * 4. Neither the name of the author nor the names of any co-contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGE.
36 #include <sys/cdefs.h>
37 __FBSDID("$FreeBSD$");
50 void yyerror(const char *);
53 update_lineno(const char *cp)
69 \n { lineno++; return EOL; }
75 \"(\\\"|[^"]|\"\")*\" {
76 int len = strlen(yytext) - 2;
80 update_lineno(yytext);
81 yylval.str = (char *)malloc(blen);
82 if (yylval.str == NULL)
85 for (i = 1; i <= len; i++) {
86 if (yytext[i] == '\"') {
87 switch (yytext[i + 1]) {
95 if (yytext[i] == '\\') {
96 switch (yytext[i + 1]) {
99 while(isspace(yytext[i]))
112 *walker++ = yytext[i];
118 \[[a-zA-Z0-9%&\{\}\-\.\/_\\\*\ ]+\] {
119 int len = strlen(yytext);
120 yytext[len-1] = '\0';
121 yylval.str = strdup(yytext+1);
124 [a-zA-Z0-9%&\{\}\-\.\/_\\\*]+ {
125 yylval.str = strdup(yytext);
131 yyerror(const char *s)
133 errx(1, "line %d: %s%s %s.", lineno, yytext, yytext?":":"", s);