%{ /* BuGLe: an OpenGL debugging tool * Copyright (C) 2004-2006 Bruce Merry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #if HAVE_CONFIG_H # include #endif #ifndef _POSIX_SOURCE # define _POSIX_SOURCE #endif #include #include #include #include "common/safemem.h" #include "src/conffile.h" #include "src/confparse.h" static char *current_string = NULL; static int current_string_length = 0; static int current_string_memory = 0; static void free_string(void) { if (current_string) free(current_string); } static void append_char(char ch) { current_string_length++; if (current_string_length >= current_string_memory) { if (current_string_memory == 0) { current_string_memory = 64; atexit(free_string); } current_string = bugle_realloc(current_string, current_string_memory); } current_string[current_string_length - 1] = ch; current_string[current_string_length] = '\0'; } static void clear_string(void) { current_string_length = 0; if (current_string) current_string[0] = '\0'; } %} %x STRING_MODE %% chain { return CHAIN; } filterset { return FILTERSET; } active { return ACTIVE; } inactive { return INACTIVE; } [A-Za-z0-9_-]+ { yylval.str = bugle_strdup(yytext); return WORD; } \" { BEGIN(STRING_MODE); } #.*$ /* Do nothing: eats comments */ "{"|"}" { return yytext[0]; } [ \t\r\n] /* Do nothing: eats whitespace */ . { fprintf(stderr, "unexpected character in config file: %c\n", yytext[0]); exit(1); } \\\n /* Do nothing */ \\. { append_char(yytext[1]); } \" { BEGIN(INITIAL); yylval.str = bugle_strdup(current_string); clear_string(); return STRING; } <> { fprintf(stderr, "End of file in string in config file\n"); exit(1); } . { append_char(yytext[0]); } %% int yywrap() { return 1; }