2007-02-20 [colin] 2.7.2cvs56
[claws.git] / src / matcher_parser_lex.l
index 12b421bd955638b9ea568d59d9a9a763cb9d629b..560293a38edbc2a5174cdf6b3afaf8353187ce97 100644 (file)
@@ -1,7 +1,9 @@
+%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
  *
  * 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #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
 
 static char string_buf[MAX_STR_CONST];
 static char *string_buf_ptr;
@@ -55,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 (~)
@@ -80,6 +87,13 @@ void matcher_parser_init(void)
                /* 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) {
+                               strcpy(string_buf, tmp);
+                               g_free(tmp);
+                       }
+               }
                yylval.str = string_buf;
                return MATCHER_STRING;
                }
@@ -101,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;
+               }
 
 %%