Coverity fixes
[claws.git] / src / matcher_parser_lex.l
index 4437b35a4ec2b79411c26b214506affb2b839488..209e50373a714358821ffb5738bdb2ac0fe524b6 100644 (file)
@@ -1,11 +1,13 @@
+%option nounput never-interactive
+
 %{
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (c) 2001-2002 by Hiroyuki Yamamoto & The Sylpheed Claws Team.
+ * Copyright (c) 2001-2007 by Hiroyuki Yamamoto & The Claws Mail Team
  *
  * 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; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * 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.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #include <string.h>
 #include <glib.h>
 
+#include "codeconv.h"
+#include "matcher.h"
 #include "matcher_parser_lex.h"
+
+#ifndef YYSTYPE
 #include "matcher_parser_parse.h"
+#endif
 
-#define MAX_STR_CONST 512
-#define YY_NO_UNPUT 1
+#define MAX_STR_CONST 8192
 
 static char string_buf[MAX_STR_CONST];
 static char *string_buf_ptr;
@@ -54,6 +60,8 @@ void matcher_parser_init(void)
 
 %%
                        
+"in"   return MATCHER_IN; 
+
                        /*
                         * a keyword consists of alpha and underscore 
                         * characters, possibly preceded by a tilde (~)
@@ -75,27 +83,29 @@ void matcher_parser_init(void)
                BEGIN(string);
                string_buf_ptr = string_buf;
                }
-               /* alfons - OK, the new attempt is to just swallow 
-                * *EVERYTHING* and make sure everything is escaped
-                * when actually performing things. */
-<string>\\\"   {
-               /* take care of escaped \" because this means the
-                * quote char should be skipped */
-               add_char('\\');
-               add_char('\"');
-               }
 <string>\"     {
                /* get out of the state: string ends. */
                BEGIN(0);
                *string_buf_ptr = '\0';
+               if (!g_utf8_validate(string_buf, -1, NULL)) {
+                       gchar *tmp = conv_codeset_strdup(string_buf, conv_get_locale_charset_str(), CS_INTERNAL);
+                       if (tmp) {
+                               g_strlcpy(string_buf, tmp, sizeof(string_buf));
+                               g_free(tmp);
+                       }
+               }
                yylval.str = string_buf;
                return MATCHER_STRING;
                }
-               /* put everything else in the output. */
+<string>\\.    {
+                /* take care of quoted characters */
+               add_char(yytext[1]);
+               }
 <string>.      {
                add_char(yytext[0]);
                }
-\[[^\[\]]*\]   {
+^\[.*\]$       {
+                /* for section name in configuration file */
                BEGIN(0);
                yylval.str = yytext + 1;
                yytext[strlen(yytext) - 1] = '\0';
@@ -105,5 +115,17 @@ void matcher_parser_init(void)
                yylval.str = yytext;
                return MATCHER_INTEGER;
                }
+rulename       {
+               return MATCHER_RULENAME;
+               }
+disabled       {
+               return MATCHER_DISABLED;
+               }
+account        {
+               return MATCHER_ACCOUNT;
+               }
+enabled        {
+               return MATCHER_ENABLED;
+               }
 
 %%