[Forensics-changes] [yara] 294/415: Add support for case-insensitive regexp matching on external variables

Hilko Bengen bengen at moszumanska.debian.org
Thu Apr 3 05:43:16 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch debian
in repository yara.

commit f5ed84ba904cf8dd03a037fb51b4b0c753f037b0
Author: Victor Manuel Alvarez <vmalvarez at virustotal.com>
Date:   Fri Dec 6 17:57:38 2013 +0100

    Add support for case-insensitive regexp matching on external variables
---
 libyara/grammar.c  | 141 +++++++++--------
 libyara/grammar.h  |   4 +-
 libyara/grammar.y  |   7 +-
 libyara/lexer.c    | 454 +++++++++++++++++++++++++++--------------------------
 libyara/lexer.l    |   8 +-
 libyara/parser.c   |   3 +
 libyara/re_lexer.c |  36 ++---
 libyara/sizedstr.h |   7 +-
 8 files changed, 342 insertions(+), 318 deletions(-)

diff --git a/libyara/grammar.c b/libyara/grammar.c
index a7b11d3..4dea912 100644
--- a/libyara/grammar.c
+++ b/libyara/grammar.c
@@ -262,8 +262,8 @@ typedef union YYSTYPE
   SIZED_STRING*   sized_string;
   char*           c_string;
   int64_t         integer;
-  YR_STRING*         string;
-  YR_META*           meta;
+  YR_STRING*      string;
+  YR_META*        meta;
 }
 /* Line 193 of yacc.c.  */
 #line 270 "grammar.c"
@@ -617,14 +617,14 @@ static const yytype_uint16 yyrline[] =
      216,   244,   248,   249,   253,   254,   258,   259,   274,   284,
      318,   319,   323,   339,   352,   365,   381,   382,   386,   400,
      399,   417,   433,   434,   438,   439,   440,   441,   445,   446,
-     450,   454,   484,   519,   523,   534,   545,   549,   560,   566,
-     603,   565,   702,   701,   770,   774,   777,   781,   785,   789,
-     793,   797,   801,   805,   809,   813,   820,   839,   853,   854,
-     858,   862,   863,   867,   866,   871,   878,   879,   882,   887,
-     894,   895,   899,   906,   907,   911,   915,   919,   923,   927,
-     931,   935,   939,   943,   954,   965,   979,  1006,  1010,  1014,
-    1018,  1022,  1026,  1030,  1034,  1038,  1042,  1046,  1052,  1053,
-    1054
+     450,   454,   484,   522,   526,   537,   548,   552,   563,   569,
+     606,   568,   705,   704,   773,   777,   780,   784,   788,   792,
+     796,   800,   804,   808,   812,   816,   823,   842,   856,   857,
+     861,   865,   866,   870,   869,   874,   881,   882,   885,   890,
+     897,   898,   902,   909,   910,   914,   918,   922,   926,   930,
+     934,   938,   942,   946,   957,   968,   982,  1009,  1013,  1017,
+    1021,  1025,  1029,  1033,  1037,  1041,  1045,  1049,  1055,  1056,
+    1057
 };
 #endif
 
@@ -2174,6 +2174,9 @@ yyreduce:
                         compiler->last_result = yr_re_compile(
                             sized_string->c_string, &re);
 
+                        if (sized_string->flags & SIZED_STRING_FLAGS_NO_CASE)
+                          re->flags |= RE_FLAGS_NO_CASE;
+
                         ERROR_IF(compiler->last_result != ERROR_SUCCESS);
 
                         compiler->last_result = yr_re_emit_code(
@@ -2203,14 +2206,14 @@ yyreduce:
     break;
 
   case 43:
-#line 520 "grammar.y"
+#line 523 "grammar.y"
     {
                         yr_parser_emit(yyscanner, CONTAINS, NULL);
                       }
     break;
 
   case 44:
-#line 524 "grammar.y"
+#line 527 "grammar.y"
     {
                         int result = yr_parser_reduce_string_identifier(
                             yyscanner,
@@ -2224,7 +2227,7 @@ yyreduce:
     break;
 
   case 45:
-#line 535 "grammar.y"
+#line 538 "grammar.y"
     {
                         int result = yr_parser_reduce_string_identifier(
                             yyscanner,
@@ -2238,14 +2241,14 @@ yyreduce:
     break;
 
   case 46:
-#line 546 "grammar.y"
+#line 549 "grammar.y"
     {
                         yr_free((yyvsp[(1) - (4)].c_string));
                       }
     break;
 
   case 47:
-#line 550 "grammar.y"
+#line 553 "grammar.y"
     {
                         int result = yr_parser_reduce_string_identifier(
                             yyscanner,
@@ -2259,7 +2262,7 @@ yyreduce:
     break;
 
   case 48:
-#line 561 "grammar.y"
+#line 564 "grammar.y"
     {
                         yr_free((yyvsp[(1) - (6)].c_string));
                         yr_free((yyvsp[(5) - (6)].sized_string));
@@ -2267,7 +2270,7 @@ yyreduce:
     break;
 
   case 49:
-#line 566 "grammar.y"
+#line 569 "grammar.y"
     {
                         YR_COMPILER* compiler = yyget_extra(yyscanner);
                         int result = ERROR_SUCCESS;
@@ -2307,7 +2310,7 @@ yyreduce:
     break;
 
   case 50:
-#line 603 "grammar.y"
+#line 606 "grammar.y"
     {
                         YR_COMPILER* compiler = yyget_extra(yyscanner);
                         int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
@@ -2344,7 +2347,7 @@ yyreduce:
     break;
 
   case 51:
-#line 637 "grammar.y"
+#line 640 "grammar.y"
     {
                         YR_COMPILER* compiler = yyget_extra(yyscanner);
                         int mem_offset;
@@ -2412,7 +2415,7 @@ yyreduce:
     break;
 
   case 52:
-#line 702 "grammar.y"
+#line 705 "grammar.y"
     {
                         YR_COMPILER* compiler = yyget_extra(yyscanner);
                         int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
@@ -2440,7 +2443,7 @@ yyreduce:
     break;
 
   case 53:
-#line 727 "grammar.y"
+#line 730 "grammar.y"
     {
                         YR_COMPILER* compiler = yyget_extra(yyscanner);
                         int mem_offset;
@@ -2487,90 +2490,90 @@ yyreduce:
     break;
 
   case 54:
-#line 771 "grammar.y"
+#line 774 "grammar.y"
     {
                         yr_parser_emit(yyscanner, OF, NULL);
                       }
     break;
 
   case 55:
-#line 775 "grammar.y"
+#line 778 "grammar.y"
     {
                       }
     break;
 
   case 56:
-#line 778 "grammar.y"
+#line 781 "grammar.y"
     {
                         yr_parser_emit(yyscanner, NOT, NULL);
                       }
     break;
 
   case 57:
-#line 782 "grammar.y"
+#line 785 "grammar.y"
     {
                         yr_parser_emit(yyscanner, AND, NULL);
                       }
     break;
 
   case 58:
-#line 786 "grammar.y"
+#line 789 "grammar.y"
     {
                         yr_parser_emit(yyscanner, OR, NULL);
                       }
     break;
 
   case 59:
-#line 790 "grammar.y"
+#line 793 "grammar.y"
     {
                         yr_parser_emit(yyscanner, LT, NULL);
                       }
     break;
 
   case 60:
-#line 794 "grammar.y"
+#line 797 "grammar.y"
     {
                         yr_parser_emit(yyscanner, GT, NULL);
                       }
     break;
 
   case 61:
-#line 798 "grammar.y"
+#line 801 "grammar.y"
     {
                         yr_parser_emit(yyscanner, LE, NULL);
                       }
     break;
 
   case 62:
-#line 802 "grammar.y"
+#line 805 "grammar.y"
     {
                         yr_parser_emit(yyscanner, GE, NULL);
                       }
     break;
 
   case 63:
-#line 806 "grammar.y"
+#line 809 "grammar.y"
     {
                         yr_parser_emit(yyscanner, EQ, NULL);
                       }
     break;
 
   case 64:
-#line 810 "grammar.y"
+#line 813 "grammar.y"
     {
                         yr_parser_emit(yyscanner, EQ, NULL);
                       }
     break;
 
   case 65:
-#line 814 "grammar.y"
+#line 817 "grammar.y"
     {
                         yr_parser_emit(yyscanner, NEQ, NULL);
                       }
     break;
 
   case 66:
-#line 821 "grammar.y"
+#line 824 "grammar.y"
     {
           YR_COMPILER* compiler = yyget_extra(yyscanner);
           SIZED_STRING* sized_string = (yyvsp[(1) - (1)].sized_string);
@@ -2592,7 +2595,7 @@ yyreduce:
     break;
 
   case 67:
-#line 840 "grammar.y"
+#line 843 "grammar.y"
     {
           int result = yr_parser_reduce_external(
               yyscanner,
@@ -2606,24 +2609,24 @@ yyreduce:
     break;
 
   case 68:
-#line 853 "grammar.y"
+#line 856 "grammar.y"
     { (yyval.integer) = INTEGER_SET_ENUMERATION; }
     break;
 
   case 69:
-#line 854 "grammar.y"
+#line 857 "grammar.y"
     { (yyval.integer) = INTEGER_SET_RANGE; }
     break;
 
   case 73:
-#line 867 "grammar.y"
+#line 870 "grammar.y"
     {
                 yr_parser_emit_with_arg(yyscanner, PUSH, UNDEFINED, NULL);
               }
     break;
 
   case 75:
-#line 872 "grammar.y"
+#line 875 "grammar.y"
     {
                 yr_parser_emit_with_arg(yyscanner, PUSH, UNDEFINED, NULL);
                 yr_parser_emit_pushes_for_strings(yyscanner, "$*");
@@ -2631,7 +2634,7 @@ yyreduce:
     break;
 
   case 78:
-#line 883 "grammar.y"
+#line 886 "grammar.y"
     {
                             yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
                             yr_free((yyvsp[(1) - (1)].c_string));
@@ -2639,7 +2642,7 @@ yyreduce:
     break;
 
   case 79:
-#line 888 "grammar.y"
+#line 891 "grammar.y"
     {
                             yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
                             yr_free((yyvsp[(1) - (1)].c_string));
@@ -2647,84 +2650,84 @@ yyreduce:
     break;
 
   case 81:
-#line 896 "grammar.y"
+#line 899 "grammar.y"
     {
                     yr_parser_emit_with_arg(yyscanner, PUSH, UNDEFINED, NULL);
                   }
     break;
 
   case 82:
-#line 900 "grammar.y"
+#line 903 "grammar.y"
     {
                     yr_parser_emit_with_arg(yyscanner, PUSH, 1, NULL);
                   }
     break;
 
   case 84:
-#line 908 "grammar.y"
+#line 911 "grammar.y"
     {
                 yr_parser_emit(yyscanner, SIZE, NULL);
               }
     break;
 
   case 85:
-#line 912 "grammar.y"
+#line 915 "grammar.y"
     {
                 yr_parser_emit(yyscanner, ENTRYPOINT, NULL);
               }
     break;
 
   case 86:
-#line 916 "grammar.y"
+#line 919 "grammar.y"
     {
                 yr_parser_emit(yyscanner, INT8, NULL);
               }
     break;
 
   case 87:
-#line 920 "grammar.y"
+#line 923 "grammar.y"
     {
                 yr_parser_emit(yyscanner, INT16, NULL);
               }
     break;
 
   case 88:
-#line 924 "grammar.y"
+#line 927 "grammar.y"
     {
                 yr_parser_emit(yyscanner, INT32, NULL);
               }
     break;
 
   case 89:
-#line 928 "grammar.y"
+#line 931 "grammar.y"
     {
                 yr_parser_emit(yyscanner, UINT8, NULL);
               }
     break;
 
   case 90:
-#line 932 "grammar.y"
+#line 935 "grammar.y"
     {
                 yr_parser_emit(yyscanner, UINT16, NULL);
               }
     break;
 
   case 91:
-#line 936 "grammar.y"
+#line 939 "grammar.y"
     {
                 yr_parser_emit(yyscanner, UINT32, NULL);
               }
     break;
 
   case 92:
-#line 940 "grammar.y"
+#line 943 "grammar.y"
     {
                 yr_parser_emit_with_arg(yyscanner, PUSH, (yyvsp[(1) - (1)].integer), NULL);
               }
     break;
 
   case 93:
-#line 944 "grammar.y"
+#line 947 "grammar.y"
     {
                 int result = yr_parser_reduce_string_identifier(
                     yyscanner,
@@ -2738,7 +2741,7 @@ yyreduce:
     break;
 
   case 94:
-#line 955 "grammar.y"
+#line 958 "grammar.y"
     {
                 int result = yr_parser_reduce_string_identifier(
                     yyscanner,
@@ -2752,7 +2755,7 @@ yyreduce:
     break;
 
   case 95:
-#line 966 "grammar.y"
+#line 969 "grammar.y"
     {
                 int result = yr_parser_emit_with_arg(yyscanner, PUSH, 1, NULL);
 
@@ -2769,7 +2772,7 @@ yyreduce:
     break;
 
   case 96:
-#line 980 "grammar.y"
+#line 983 "grammar.y"
     {
                 YR_COMPILER* compiler = yyget_extra(yyscanner);
                 int var_index;
@@ -2799,77 +2802,77 @@ yyreduce:
     break;
 
   case 97:
-#line 1007 "grammar.y"
+#line 1010 "grammar.y"
     {
                 yr_parser_emit(yyscanner, ADD, NULL);
               }
     break;
 
   case 98:
-#line 1011 "grammar.y"
+#line 1014 "grammar.y"
     {
                 yr_parser_emit(yyscanner, SUB, NULL);
               }
     break;
 
   case 99:
-#line 1015 "grammar.y"
+#line 1018 "grammar.y"
     {
                 yr_parser_emit(yyscanner, MUL, NULL);
               }
     break;
 
   case 100:
-#line 1019 "grammar.y"
+#line 1022 "grammar.y"
     {
                 yr_parser_emit(yyscanner, DIV, NULL);
               }
     break;
 
   case 101:
-#line 1023 "grammar.y"
+#line 1026 "grammar.y"
     {
                 yr_parser_emit(yyscanner, MOD, NULL);
               }
     break;
 
   case 102:
-#line 1027 "grammar.y"
+#line 1030 "grammar.y"
     {
                 yr_parser_emit(yyscanner, XOR, NULL);
               }
     break;
 
   case 103:
-#line 1031 "grammar.y"
+#line 1034 "grammar.y"
     {
                 yr_parser_emit(yyscanner, AND, NULL);
               }
     break;
 
   case 104:
-#line 1035 "grammar.y"
+#line 1038 "grammar.y"
     {
                 yr_parser_emit(yyscanner, OR, NULL);
               }
     break;
 
   case 105:
-#line 1039 "grammar.y"
+#line 1042 "grammar.y"
     {
                 yr_parser_emit(yyscanner, NEG, NULL);
               }
     break;
 
   case 106:
-#line 1043 "grammar.y"
+#line 1046 "grammar.y"
     {
                 yr_parser_emit(yyscanner, SHL, NULL);
               }
     break;
 
   case 107:
-#line 1047 "grammar.y"
+#line 1050 "grammar.y"
     {
                 yr_parser_emit(yyscanner, SHR, NULL);
               }
@@ -2877,7 +2880,7 @@ yyreduce:
 
 
 /* Line 1267 of yacc.c.  */
-#line 2881 "grammar.c"
+#line 2884 "grammar.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -3091,7 +3094,7 @@ yyreturn:
 }
 
 
-#line 1057 "grammar.y"
+#line 1060 "grammar.y"
 
 
 
diff --git a/libyara/grammar.h b/libyara/grammar.h
index 48b5083..9f9cf2f 100644
--- a/libyara/grammar.h
+++ b/libyara/grammar.h
@@ -175,8 +175,8 @@ typedef union YYSTYPE
   SIZED_STRING*   sized_string;
   char*           c_string;
   int64_t         integer;
-  YR_STRING*         string;
-  YR_META*           meta;
+  YR_STRING*      string;
+  YR_META*        meta;
 }
 /* Line 1529 of yacc.c.  */
 #line 183 "grammar.h"
diff --git a/libyara/grammar.y b/libyara/grammar.y
index 049c2bc..ff2f88f 100644
--- a/libyara/grammar.y
+++ b/libyara/grammar.y
@@ -149,8 +149,8 @@ limitations under the License.
   SIZED_STRING*   sized_string;
   char*           c_string;
   int64_t         integer;
-  YR_STRING*         string;
-  YR_META*           meta;
+  YR_STRING*      string;
+  YR_META*        meta;
 }
 
 
@@ -490,6 +490,9 @@ boolean_expression  : '(' boolean_expression ')'
                         compiler->last_result = yr_re_compile(
                             sized_string->c_string, &re);
 
+                        if (sized_string->flags & SIZED_STRING_FLAGS_NO_CASE)
+                          re->flags |= RE_FLAGS_NO_CASE;
+
                         ERROR_IF(compiler->last_result != ERROR_SUCCESS);
 
                         compiler->last_result = yr_re_emit_code(
diff --git a/libyara/lexer.c b/libyara/lexer.c
index 621ca7b..7f4aa7b 100644
--- a/libyara/lexer.c
+++ b/libyara/lexer.c
@@ -372,7 +372,7 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static yyconst flex_int16_t yy_accept[226] =
+static yyconst flex_int16_t yy_accept[227] =
     {   0,
         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        79,   77,   76,   76,   77,   73,   55,   54,   74,   58,
@@ -385,20 +385,20 @@ static yyconst flex_int16_t yy_accept[226] =
        57,   57,   25,   57,   57,   57,   26,   23,   57,   57,
        57,   57,   57,   57,   57,   57,   57,    0,   65,   67,
 
-       62,   63,   61,   67,   71,   70,   69,   51,   47,   49,
-       58,   59,   29,   22,   30,   57,   57,   57,   57,   57,
-       28,   57,   57,   57,   57,   57,   57,   57,   57,   21,
-       57,   57,   57,   33,   57,   57,   57,   57,   57,   57,
-       75,    0,   57,   57,   57,   57,   57,   35,   57,   57,
-       57,   57,   57,   57,   40,   57,   12,   57,   57,   57,
-       11,   57,   57,   27,   19,   57,   15,   64,   14,   57,
-       57,   57,   20,   57,   57,   57,   57,   45,   41,   42,
-       57,   57,   57,   57,   57,   57,   57,   57,   37,   57,
-       57,   57,   57,   57,   10,   57,   57,   17,   34,   57,
-
-       57,   57,   38,   39,   57,   57,   57,   57,   57,   57,
-       43,    9,   36,   13,   57,   44,   57,   32,   16,    0,
-       18,   57,   50,   31,    0
+       62,   63,   61,   67,   71,   68,   70,   69,   51,   47,
+       49,   58,   59,   29,   22,   30,   57,   57,   57,   57,
+       57,   28,   57,   57,   57,   57,   57,   57,   57,   57,
+       21,   57,   57,   57,   33,   57,   57,   57,   57,   57,
+       57,   75,    0,   57,   57,   57,   57,   57,   35,   57,
+       57,   57,   57,   57,   57,   40,   57,   12,   57,   57,
+       57,   11,   57,   57,   27,   19,   57,   15,   64,   14,
+       57,   57,   57,   20,   57,   57,   57,   57,   45,   41,
+       42,   57,   57,   57,   57,   57,   57,   57,   57,   37,
+       57,   57,   57,   57,   57,   10,   57,   57,   17,   34,
+
+       57,   57,   57,   38,   39,   57,   57,   57,   57,   57,
+       57,   43,    9,   36,   13,   57,   44,   57,   32,   16,
+        0,   18,   57,   50,   31,    0
     } ;
 
 static yyconst flex_int32_t yy_ec[256] =
@@ -443,69 +443,69 @@ static yyconst flex_int32_t yy_meta[55] =
         9,    9,    1,    1
     } ;
 
-static yyconst flex_int16_t yy_base[245] =
+static yyconst flex_int16_t yy_base[246] =
     {   0,
-        0,    0,   52,   53,   54,   57,  356,  355,  350,  349,
-      358,  363,  363,  363,  337,  363,    0,  346,   51,   37,
-       40,   50,  335,   51,    0,    0,   38,  312,  312,   56,
-      313,  310,   44,  308,   53,  305,   28,   55,   55,  310,
-      309,    0,    0,  363,  363,   67,    0,  363,  363,  335,
-        0,  363,  363,  334,  363,    0,  363,  334,  363,    0,
-        0,  319,  318,    0,  363,  363,  363,  363,  363,    0,
+        0,    0,   52,   53,   54,   57,  357,  356,  351,  350,
+      359,  364,  364,  364,  338,  364,    0,  347,   51,   37,
+       40,   50,  336,   51,    0,    0,   38,  313,  313,   56,
+      314,  311,   44,  309,   53,  306,   28,   55,   55,  311,
+      310,    0,    0,  364,  364,   67,    0,  364,  309,  335,
+        0,  364,  364,  334,  364,    0,  364,  334,  364,    0,
+        0,  319,  318,    0,  364,  364,  364,  364,  364,    0,
         0,  302,   58,  308,    0,  298,  292,  298,  297,  291,
       295,  291,   72,  286,  285,   61,  295,    0,  291,  289,
-      297,  294,  281,  290,  276,  281,  288,  266,    0,  363,
-
-      363,  363,  363,    0,    0,  363,  363,    0,  363,    0,
-      363,    0,    0,    0,    0,  281,   69,  274,  272,  282,
-        0,  276,  283,  274,  278,   93,  279,  280,  279,    0,
-      263,  259,  272,    0,  259,  266,  263,  268,  255,  266,
-      363,    0,  261,  260,  267,  245,  261,  249,  244,  262,
-      244,  240,  272,  274,    0,  250,    0,  241,  251,  254,
-        0,  245,  241,    0,    0,  101,    0,  363,    0,  235,
-      242,  236,    0,  240,  235,  237,  242,    0,    0,    0,
-      240,  239,  226,  225,  228,  233,  251,  253,    0,  228,
-      224,  222,  211,  204,    0,  204,  181,    0,    0,  185,
-
-      175,  151,    0,    0,  153,  145,  151,  154,  143,  173,
-        0,    0,    0,    0,  128,    0,   71,    0,    0,   94,
-        0,   64,  363,    0,  363,  119,  130,  141,  152,  157,
-      163,  167,  171,  175,  184,  192,  202,  213,  223,  234,
-      245,  250,  252,  254
+      297,  294,  281,  290,  276,  281,  288,  266,    0,  364,
+
+      364,  364,  364,    0,    0,  364,  364,  364,    0,  364,
+        0,  364,    0,    0,    0,    0,  281,   69,  274,  272,
+      282,    0,  276,  283,  274,  278,   93,  279,  280,  279,
+        0,  263,  259,  272,    0,  259,  266,  263,  268,  255,
+      266,  364,    0,  261,  260,  267,  245,  261,  249,  244,
+      262,  244,  240,  272,  274,    0,  250,    0,  241,  251,
+      254,    0,  245,  241,    0,    0,  101,    0,  364,    0,
+      235,  242,  236,    0,  240,  235,  237,  242,    0,    0,
+        0,  240,  239,  226,  225,  228,  233,  251,  253,    0,
+      228,  224,  222,  211,  204,    0,  204,  181,    0,    0,
+
+      185,  175,  151,    0,    0,  153,  145,  151,  154,  143,
+      173,    0,    0,    0,    0,  128,    0,   71,    0,    0,
+       94,    0,   64,  364,    0,  364,  119,  130,  141,  152,
+      157,  163,  167,  171,  175,  184,  192,  202,  213,  223,
+      234,  245,  250,  252,  254
     } ;
 
-static yyconst flex_int16_t yy_def[245] =
+static yyconst flex_int16_t yy_def[246] =
     {   0,
-      225,    1,  226,  226,  227,  227,  228,  228,  229,  229,
-      225,  225,  225,  225,  225,  225,  230,  231,  225,  232,
-      232,  225,  225,  225,  233,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  235,  236,  225,  225,  237,  238,  225,  225,  239,
-      240,  225,  225,  225,  225,  230,  225,  231,  225,  241,
-       21,  225,  225,  242,  225,  225,  225,  225,  225,  233,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  235,  236,  225,
-
-      225,  225,  225,  243,  238,  225,  225,  240,  225,  241,
-      225,  242,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      225,  244,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  225,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  234,
-      234,  234,  234,  234,  234,  234,  234,  234,  234,  225,
-      234,  234,  225,  234,    0,  225,  225,  225,  225,  225,
-      225,  225,  225,  225,  225,  225,  225,  225,  225,  225,
-      225,  225,  225,  225
+      226,    1,  227,  227,  228,  228,  229,  229,  230,  230,
+      226,  226,  226,  226,  226,  226,  231,  232,  226,  233,
+      233,  226,  226,  226,  234,  235,  235,  235,  235,  235,
+      235,  235,  235,  235,  235,  235,  235,  235,  235,  235,
+      235,  236,  237,  226,  226,  238,  239,  226,  226,  240,
+      241,  226,  226,  226,  226,  231,  226,  232,  226,  242,
+       21,  226,  226,  243,  226,  226,  226,  226,  226,  234,
+      235,  235,  235,  235,  235,  235,  235,  235,  235,  235,
+      235,  235,  235,  235,  235,  235,  235,  235,  235,  235,
+      235,  235,  235,  235,  235,  235,  235,  236,  237,  226,
+
+      226,  226,  226,  244,  239,  226,  226,  226,  241,  226,
+      242,  226,  243,  235,  235,  235,  235,  235,  235,  235,
+      235,  235,  235,  235,  235,  235,  235,  235,  235,  235,
+      235,  235,  235,  235,  235,  235,  235,  235,  235,  235,
+      235,  226,  245,  235,  235,  235,  235,  235,  235,  235,
+      235,  235,  235,  235,  235,  235,  235,  235,  235,  235,
+      235,  235,  235,  235,  235,  235,  235,  235,  226,  235,
+      235,  235,  235,  235,  235,  235,  235,  235,  235,  235,
+      235,  235,  235,  235,  235,  235,  235,  235,  235,  235,
+      235,  235,  235,  235,  235,  235,  235,  235,  235,  235,
+
+      235,  235,  235,  235,  235,  235,  235,  235,  235,  235,
+      235,  235,  235,  235,  235,  235,  235,  235,  235,  235,
+      226,  235,  235,  226,  235,    0,  226,  226,  226,  226,
+      226,  226,  226,  226,  226,  226,  226,  226,  226,  226,
+      226,  226,  226,  226,  226
     } ;
 
-static yyconst flex_int16_t yy_nxt[418] =
+static yyconst flex_int16_t yy_nxt[419] =
     {   0,
        12,   13,   14,   13,   15,   16,   17,   18,   12,   12,
        19,   20,   21,   21,   21,   21,   21,   21,   22,   23,
@@ -515,47 +515,47 @@ static yyconst flex_int16_t yy_nxt[418] =
        26,   26,   42,   12,   44,   44,   48,   45,   45,   48,
        59,   60,   62,   63,   49,   62,   63,   49,   65,   66,
        68,   69,  101,   84,   90,   91,   72,   85,   73,   46,
-       46,   50,   74,   75,   50,   78,   64,   87,   92,  225,
-      114,   94,  129,   79,  102,  220,   88,   80,   95,  223,
+       46,   50,   74,   75,   50,   78,   64,   87,   92,  226,
+      115,   94,  130,   79,  102,  221,   88,   80,   95,  224,
 
-       93,  144,   81,  124,  125,  153,  130,  154,  115,  224,
-      155,  222,  103,  187,  145,  188,  104,  126,  189,   43,
+       93,  145,   81,  125,  126,  154,  131,  155,  116,  225,
+      156,  223,  103,  188,  146,  189,  104,  127,  190,   43,
        43,   43,   43,   43,   43,   43,   43,   43,   43,   43,
        47,   47,   47,   47,   47,   47,   47,   47,   47,   47,
        47,   51,   51,   51,   51,   51,   51,   51,   51,   51,
        51,   51,   53,   53,   53,   53,   53,   53,   53,   53,
-       53,   53,   53,   56,   56,   56,   56,   58,  221,   58,
-       58,   58,   58,   61,  220,  219,   61,   70,   70,   70,
-       70,   71,   71,   71,   71,   98,   98,  218,  217,  216,
-       98,   98,   99,   99,  215,  214,   99,   99,   99,   99,
+       53,   53,   53,   56,   56,   56,   56,   58,  222,   58,
+       58,   58,   58,   61,  221,  220,   61,   70,   70,   70,
+       70,   71,   71,   71,   71,   98,   98,  219,  218,  217,
+       98,   98,   99,   99,  216,  215,   99,   99,   99,   99,
 
        99,   99,  100,  100,  100,  100,  100,  100,  100,  100,
-      100,  100,  100,  105,  105,  213,  105,  105,  212,  105,
-      105,  105,  105,  106,  106,  211,  106,  106,  106,  106,
-      106,  106,  106,  106,  108,  108,  108,  210,  108,  108,
-      108,  108,  108,  108,  108,  110,  110,  209,  110,  110,
-      110,  110,  110,  110,  110,  110,  112,  112,  142,  142,
-      168,  168,  208,  207,  206,  205,  204,  203,  202,  201,
-      200,  199,  198,  197,  196,  195,  194,  193,  192,  191,
-      190,  186,  185,  184,  183,  182,  181,  180,  179,  178,
-      177,  176,  175,  174,  173,  172,  171,  170,  169,  167,
-
-      166,  165,  164,  163,  162,  161,  160,  159,  158,  157,
-      156,  152,  151,  150,  149,  148,  147,  146,  143,  141,
-      140,  139,  138,  137,  136,  135,  134,  133,  132,  131,
-      128,  127,  123,  122,  121,  120,  119,  118,  117,  116,
-      113,  111,  111,   57,  109,  107,   97,   96,   89,   86,
-       83,   82,   77,   76,   67,   57,   55,  225,   54,   54,
-       52,   52,   11,  225,  225,  225,  225,  225,  225,  225,
-      225,  225,  225,  225,  225,  225,  225,  225,  225,  225,
-      225,  225,  225,  225,  225,  225,  225,  225,  225,  225,
-      225,  225,  225,  225,  225,  225,  225,  225,  225,  225,
-
-      225,  225,  225,  225,  225,  225,  225,  225,  225,  225,
-      225,  225,  225,  225,  225,  225,  225
+      100,  100,  100,  105,  105,  214,  105,  105,  213,  105,
+      105,  105,  105,  107,  107,  212,  107,  107,  107,  107,
+      107,  107,  107,  107,  109,  109,  109,  211,  109,  109,
+      109,  109,  109,  109,  109,  111,  111,  210,  111,  111,
+      111,  111,  111,  111,  111,  111,  113,  113,  143,  143,
+      169,  169,  209,  208,  207,  206,  205,  204,  203,  202,
+      201,  200,  199,  198,  197,  196,  195,  194,  193,  192,
+      191,  187,  186,  185,  184,  183,  182,  181,  180,  179,
+      178,  177,  176,  175,  174,  173,  172,  171,  170,  168,
+
+      167,  166,  165,  164,  163,  162,  161,  160,  159,  158,
+      157,  153,  152,  151,  150,  149,  148,  147,  144,  142,
+      141,  140,  139,  138,  137,  136,  135,  134,  133,  132,
+      129,  128,  124,  123,  122,  121,  120,  119,  118,  117,
+      114,  112,  112,   57,  110,  108,  106,   97,   96,   89,
+       86,   83,   82,   77,   76,   67,   57,   55,  226,   54,
+       54,   52,   52,   11,  226,  226,  226,  226,  226,  226,
+      226,  226,  226,  226,  226,  226,  226,  226,  226,  226,
+      226,  226,  226,  226,  226,  226,  226,  226,  226,  226,
+      226,  226,  226,  226,  226,  226,  226,  226,  226,  226,
+
+      226,  226,  226,  226,  226,  226,  226,  226,  226,  226,
+      226,  226,  226,  226,  226,  226,  226,  226
     } ;
 
-static yyconst flex_int16_t yy_chk[418] =
+static yyconst flex_int16_t yy_chk[419] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -566,43 +566,43 @@ static yyconst flex_int16_t yy_chk[418] =
        19,   19,   20,   20,    5,   21,   21,    6,   22,   22,
        24,   24,   46,   33,   37,   37,   27,   33,   27,    3,
         4,    5,   27,   27,    6,   30,   20,   35,   38,   21,
-       73,   39,   86,   30,   46,  220,   35,   30,   39,  220,
+       73,   39,   86,   30,   46,  221,   35,   30,   39,  221,
 
-       38,  117,   30,   83,   83,  126,   86,  126,   73,  222,
-      126,  217,   46,  166,  117,  166,   46,   83,  166,  226,
-      226,  226,  226,  226,  226,  226,  226,  226,  226,  226,
+       38,  118,   30,   83,   83,  127,   86,  127,   73,  223,
+      127,  218,   46,  167,  118,  167,   46,   83,  167,  227,
       227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
-      227,  228,  228,  228,  228,  228,  228,  228,  228,  228,
-      228,  228,  229,  229,  229,  229,  229,  229,  229,  229,
-      229,  229,  229,  230,  230,  230,  230,  231,  215,  231,
-      231,  231,  231,  232,  210,  209,  232,  233,  233,  233,
-      233,  234,  234,  234,  234,  235,  235,  208,  207,  206,
-      235,  235,  236,  236,  205,  202,  236,  236,  236,  236,
-
-      236,  236,  237,  237,  237,  237,  237,  237,  237,  237,
-      237,  237,  237,  238,  238,  201,  238,  238,  200,  238,
-      238,  238,  238,  239,  239,  197,  239,  239,  239,  239,
-      239,  239,  239,  239,  240,  240,  240,  196,  240,  240,
-      240,  240,  240,  240,  240,  241,  241,  194,  241,  241,
-      241,  241,  241,  241,  241,  241,  242,  242,  243,  243,
-      244,  244,  193,  192,  191,  190,  188,  187,  186,  185,
-      184,  183,  182,  181,  177,  176,  175,  174,  172,  171,
-      170,  163,  162,  160,  159,  158,  156,  154,  153,  152,
-      151,  150,  149,  148,  147,  146,  145,  144,  143,  140,
-
-      139,  138,  137,  136,  135,  133,  132,  131,  129,  128,
-      127,  125,  124,  123,  122,  120,  119,  118,  116,   98,
+      228,  228,  228,  228,  228,  228,  228,  228,  228,  228,
+      228,  229,  229,  229,  229,  229,  229,  229,  229,  229,
+      229,  229,  230,  230,  230,  230,  230,  230,  230,  230,
+      230,  230,  230,  231,  231,  231,  231,  232,  216,  232,
+      232,  232,  232,  233,  211,  210,  233,  234,  234,  234,
+      234,  235,  235,  235,  235,  236,  236,  209,  208,  207,
+      236,  236,  237,  237,  206,  203,  237,  237,  237,  237,
+
+      237,  237,  238,  238,  238,  238,  238,  238,  238,  238,
+      238,  238,  238,  239,  239,  202,  239,  239,  201,  239,
+      239,  239,  239,  240,  240,  198,  240,  240,  240,  240,
+      240,  240,  240,  240,  241,  241,  241,  197,  241,  241,
+      241,  241,  241,  241,  241,  242,  242,  195,  242,  242,
+      242,  242,  242,  242,  242,  242,  243,  243,  244,  244,
+      245,  245,  194,  193,  192,  191,  189,  188,  187,  186,
+      185,  184,  183,  182,  178,  177,  176,  175,  173,  172,
+      171,  164,  163,  161,  160,  159,  157,  155,  154,  153,
+      152,  151,  150,  149,  148,  147,  146,  145,  144,  141,
+
+      140,  139,  138,  137,  136,  134,  133,  132,  130,  129,
+      128,  126,  125,  124,  123,  121,  120,  119,  117,   98,
        97,   96,   95,   94,   93,   92,   91,   90,   89,   87,
        85,   84,   82,   81,   80,   79,   78,   77,   76,   74,
-       72,   63,   62,   58,   54,   50,   41,   40,   36,   34,
-       32,   31,   29,   28,   23,   18,   15,   11,   10,    9,
-        8,    7,  225,  225,  225,  225,  225,  225,  225,  225,
-      225,  225,  225,  225,  225,  225,  225,  225,  225,  225,
-      225,  225,  225,  225,  225,  225,  225,  225,  225,  225,
-      225,  225,  225,  225,  225,  225,  225,  225,  225,  225,
-
-      225,  225,  225,  225,  225,  225,  225,  225,  225,  225,
-      225,  225,  225,  225,  225,  225,  225
+       72,   63,   62,   58,   54,   50,   49,   41,   40,   36,
+       34,   32,   31,   29,   28,   23,   18,   15,   11,   10,
+        9,    8,    7,  226,  226,  226,  226,  226,  226,  226,
+      226,  226,  226,  226,  226,  226,  226,  226,  226,  226,
+      226,  226,  226,  226,  226,  226,  226,  226,  226,  226,
+      226,  226,  226,  226,  226,  226,  226,  226,  226,  226,
+
+      226,  226,  226,  226,  226,  226,  226,  226,  226,  226,
+      226,  226,  226,  226,  226,  226,  226,  226
     } ;
 
 /* Table of booleans, true if rule could match eol. */
@@ -651,6 +651,7 @@ limitations under the License.
 #include "mem.h"
 #include "lexer.h"
 #include "utils.h"
+#include "re.h"
 
 
 #define LEX_CHECK_SPACE_OK(data, current_size, max_length) \
@@ -681,7 +682,7 @@ limitations under the License.
 
 
 
-#line 685 "lexer.c"
+#line 686 "lexer.c"
 
 #define INITIAL 0
 #define str 1
@@ -916,10 +917,10 @@ YY_DECL
 	register int yy_act;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-#line 80 "lexer.l"
+#line 81 "lexer.l"
 
 
-#line 923 "lexer.c"
+#line 924 "lexer.c"
 
     yylval = yylval_param;
 
@@ -974,13 +975,13 @@ yy_match:
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 226 )
+				if ( yy_current_state >= 227 )
 					yy_c = yy_meta[(unsigned int) yy_c];
 				}
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 			++yy_cp;
 			}
-		while ( yy_base[yy_current_state] != 363 );
+		while ( yy_base[yy_current_state] != 364 );
 
 yy_find_action:
 		yy_act = yy_accept[yy_current_state];
@@ -1018,253 +1019,253 @@ do_action:	/* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 82 "lexer.l"
+#line 83 "lexer.l"
 { return _LT_;          }
 	YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 83 "lexer.l"
+#line 84 "lexer.l"
 { return _GT_;          }
 	YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 84 "lexer.l"
+#line 85 "lexer.l"
 { return _LE_;          }
 	YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 85 "lexer.l"
+#line 86 "lexer.l"
 { return _GE_;          }
 	YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 86 "lexer.l"
+#line 87 "lexer.l"
 { return _EQ_;          }
 	YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 87 "lexer.l"
+#line 88 "lexer.l"
 { return _NEQ_;         }
 	YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 88 "lexer.l"
+#line 89 "lexer.l"
 { return _SHIFT_LEFT_;  }
 	YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 89 "lexer.l"
+#line 90 "lexer.l"
 { return _SHIFT_RIGHT_; }
 	YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 90 "lexer.l"
+#line 91 "lexer.l"
 { return _PRIVATE_;     }
 	YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 91 "lexer.l"
+#line 92 "lexer.l"
 { return _GLOBAL_;      }
 	YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 92 "lexer.l"
+#line 93 "lexer.l"
 { return _RULE_;        }
 	YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 93 "lexer.l"
+#line 94 "lexer.l"
 { return _META_;        }
 	YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 94 "lexer.l"
+#line 95 "lexer.l"
 { return _STRINGS_;     }
 	YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 95 "lexer.l"
+#line 96 "lexer.l"
 { return _ASCII_;       }
 	YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 96 "lexer.l"
+#line 97 "lexer.l"
 { return _WIDE_;        }
 	YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 97 "lexer.l"
+#line 98 "lexer.l"
 { return _FULLWORD_;    }
 	YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 98 "lexer.l"
+#line 99 "lexer.l"
 { return _NOCASE_;      }
 	YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 99 "lexer.l"
+#line 100 "lexer.l"
 { return _CONDITION_;   }
 	YY_BREAK
 case 19:
 YY_RULE_SETUP
-#line 100 "lexer.l"
+#line 101 "lexer.l"
 { return _TRUE_;        }
 	YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 101 "lexer.l"
+#line 102 "lexer.l"
 { return _FALSE_;       }
 	YY_BREAK
 case 21:
 YY_RULE_SETUP
-#line 102 "lexer.l"
+#line 103 "lexer.l"
 { return _NOT_;         }
 	YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 103 "lexer.l"
+#line 104 "lexer.l"
 { return _AND_;         }
 	YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 104 "lexer.l"
+#line 105 "lexer.l"
 { return _OR_;          }
 	YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 105 "lexer.l"
+#line 106 "lexer.l"
 { return _AT_;          }
 	YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 106 "lexer.l"
+#line 107 "lexer.l"
 { return _IN_;          }
 	YY_BREAK
 case 26:
 YY_RULE_SETUP
-#line 107 "lexer.l"
+#line 108 "lexer.l"
 { return _OF_;          }
 	YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 108 "lexer.l"
+#line 109 "lexer.l"
 { return _THEM_;        }
 	YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 109 "lexer.l"
+#line 110 "lexer.l"
 { return _FOR_;         }
 	YY_BREAK
 case 29:
 YY_RULE_SETUP
-#line 110 "lexer.l"
+#line 111 "lexer.l"
 { return _ALL_;         }
 	YY_BREAK
 case 30:
 YY_RULE_SETUP
-#line 111 "lexer.l"
+#line 112 "lexer.l"
 { return _ANY_;         }
 	YY_BREAK
 case 31:
 YY_RULE_SETUP
-#line 112 "lexer.l"
+#line 113 "lexer.l"
 { return _ENTRYPOINT_;  }
 	YY_BREAK
 case 32:
 YY_RULE_SETUP
-#line 113 "lexer.l"
+#line 114 "lexer.l"
 { return _SIZE_;        }
 	YY_BREAK
 case 33:
 YY_RULE_SETUP
-#line 114 "lexer.l"
+#line 115 "lexer.l"
 { return _RVA_;         }
 	YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 115 "lexer.l"
+#line 116 "lexer.l"
 { return _OFFSET_;      }
 	YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 116 "lexer.l"
+#line 117 "lexer.l"
 { return _FILE_;        }
 	YY_BREAK
 case 36:
 YY_RULE_SETUP
-#line 117 "lexer.l"
+#line 118 "lexer.l"
 { return _SECTION_;     }
 	YY_BREAK
 case 37:
 YY_RULE_SETUP
-#line 118 "lexer.l"
+#line 119 "lexer.l"
 { return _UINT8_;       }
 	YY_BREAK
 case 38:
 YY_RULE_SETUP
-#line 119 "lexer.l"
+#line 120 "lexer.l"
 { return _UINT16_;      }
 	YY_BREAK
 case 39:
 YY_RULE_SETUP
-#line 120 "lexer.l"
+#line 121 "lexer.l"
 { return _UINT32_;      }
 	YY_BREAK
 case 40:
 YY_RULE_SETUP
-#line 121 "lexer.l"
+#line 122 "lexer.l"
 { return _INT8_;        }
 	YY_BREAK
 case 41:
 YY_RULE_SETUP
-#line 122 "lexer.l"
+#line 123 "lexer.l"
 { return _INT16_;       }
 	YY_BREAK
 case 42:
 YY_RULE_SETUP
-#line 123 "lexer.l"
+#line 124 "lexer.l"
 { return _INT32_;       }
 	YY_BREAK
 case 43:
 YY_RULE_SETUP
-#line 124 "lexer.l"
+#line 125 "lexer.l"
 { return _MATCHES_;     }
 	YY_BREAK
 case 44:
 YY_RULE_SETUP
-#line 125 "lexer.l"
+#line 126 "lexer.l"
 { return _CONTAINS_;    }
 	YY_BREAK
 case 45:
 YY_RULE_SETUP
-#line 126 "lexer.l"
+#line 127 "lexer.l"
 { return _INDEX_;       }
 	YY_BREAK
 case 46:
 YY_RULE_SETUP
-#line 129 "lexer.l"
+#line 130 "lexer.l"
 { BEGIN(comment);       }
 	YY_BREAK
 case 47:
 YY_RULE_SETUP
-#line 130 "lexer.l"
+#line 131 "lexer.l"
 { BEGIN(INITIAL);       }
 	YY_BREAK
 case 48:
 /* rule 48 can match eol */
 YY_RULE_SETUP
-#line 131 "lexer.l"
+#line 132 "lexer.l"
 { /* skip comments */   }
 	YY_BREAK
 case 49:
 YY_RULE_SETUP
-#line 134 "lexer.l"
+#line 135 "lexer.l"
 { /* skip single-line comments */ }
 	YY_BREAK
 case 50:
 YY_RULE_SETUP
-#line 137 "lexer.l"
+#line 138 "lexer.l"
 {
                           yyextra->lex_buf_ptr = yyextra->lex_buf;
                           yyextra->lex_buf_len = 0;
@@ -1274,12 +1275,12 @@ YY_RULE_SETUP
 case 51:
 /* rule 51 can match eol */
 YY_RULE_SETUP
-#line 144 "lexer.l"
+#line 145 "lexer.l"
 { YYTEXT_TO_BUFFER; }
 	YY_BREAK
 case 52:
 YY_RULE_SETUP
-#line 147 "lexer.l"
+#line 148 "lexer.l"
 {
 
   char            buffer[1024];
@@ -1381,7 +1382,7 @@ case YY_STATE_EOF(str):
 case YY_STATE_EOF(regexp):
 case YY_STATE_EOF(include):
 case YY_STATE_EOF(comment):
-#line 245 "lexer.l"
+#line 246 "lexer.l"
 {
 
   YR_COMPILER* compiler = yara_yyget_extra(yyscanner);
@@ -1403,7 +1404,7 @@ case YY_STATE_EOF(comment):
 	YY_BREAK
 case 53:
 YY_RULE_SETUP
-#line 265 "lexer.l"
+#line 266 "lexer.l"
 {
 
   yylval->c_string = yr_strdup(yytext);
@@ -1412,7 +1413,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 54:
 YY_RULE_SETUP
-#line 272 "lexer.l"
+#line 273 "lexer.l"
 {
 
   yylval->c_string = yr_strdup(yytext);
@@ -1421,7 +1422,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 55:
 YY_RULE_SETUP
-#line 279 "lexer.l"
+#line 280 "lexer.l"
 {
 
   yylval->c_string = yr_strdup(yytext);
@@ -1431,7 +1432,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 56:
 YY_RULE_SETUP
-#line 287 "lexer.l"
+#line 288 "lexer.l"
 {
 
   yylval->c_string = yr_strdup(yytext);
@@ -1441,7 +1442,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 57:
 YY_RULE_SETUP
-#line 295 "lexer.l"
+#line 296 "lexer.l"
 {
 
   if (strlen(yytext) > 128)
@@ -1455,7 +1456,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 58:
 YY_RULE_SETUP
-#line 307 "lexer.l"
+#line 308 "lexer.l"
 {
 
   yylval->integer = (size_t) atol(yytext);
@@ -1473,7 +1474,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 59:
 YY_RULE_SETUP
-#line 323 "lexer.l"
+#line 324 "lexer.l"
 {
 
   yylval->integer = xtoi(yytext + 2);
@@ -1482,7 +1483,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 60:
 YY_RULE_SETUP
-#line 330 "lexer.l"
+#line 331 "lexer.l"
 {     /* saw closing quote - all done */
 
   SIZED_STRING* s;
@@ -1506,7 +1507,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 61:
 YY_RULE_SETUP
-#line 352 "lexer.l"
+#line 353 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("\t", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1516,7 +1517,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 62:
 YY_RULE_SETUP
-#line 360 "lexer.l"
+#line 361 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("\"", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1526,7 +1527,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 63:
 YY_RULE_SETUP
-#line 368 "lexer.l"
+#line 369 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("\\", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1536,7 +1537,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 64:
 YY_RULE_SETUP
-#line 376 "lexer.l"
+#line 377 "lexer.l"
 {
 
    int result;
@@ -1549,13 +1550,13 @@ YY_RULE_SETUP
 	YY_BREAK
 case 65:
 YY_RULE_SETUP
-#line 387 "lexer.l"
+#line 388 "lexer.l"
 { YYTEXT_TO_BUFFER; }
 	YY_BREAK
 case 66:
 /* rule 66 can match eol */
 YY_RULE_SETUP
-#line 390 "lexer.l"
+#line 391 "lexer.l"
 {
 
   yyerror(yyscanner, "unterminated string");
@@ -1565,7 +1566,7 @@ YY_RULE_SETUP
 case 67:
 /* rule 67 can match eol */
 YY_RULE_SETUP
-#line 396 "lexer.l"
+#line 397 "lexer.l"
 {
 
   yyerror(yyscanner, "illegal escape sequence");
@@ -1573,7 +1574,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 68:
 YY_RULE_SETUP
-#line 402 "lexer.l"
+#line 403 "lexer.l"
 {
 
   SIZED_STRING* s;
@@ -1589,6 +1590,11 @@ YY_RULE_SETUP
 
   s = (SIZED_STRING*) yr_malloc(yyextra->lex_buf_len + sizeof(SIZED_STRING));
 
+  if (yytext[1] == 'i')
+    s->flags = SIZED_STRING_FLAGS_NO_CASE;
+  else
+    s->flags = 0;
+
   s->length = yyextra->lex_buf_len;
   strcpy(s->c_string, yyextra->lex_buf);
 
@@ -1599,7 +1605,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 69:
 YY_RULE_SETUP
-#line 426 "lexer.l"
+#line 432 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("/", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1609,7 +1615,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 70:
 YY_RULE_SETUP
-#line 434 "lexer.l"
+#line 440 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("\\.", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1620,13 +1626,13 @@ YY_RULE_SETUP
 	YY_BREAK
 case 71:
 YY_RULE_SETUP
-#line 443 "lexer.l"
+#line 449 "lexer.l"
 { YYTEXT_TO_BUFFER; }
 	YY_BREAK
 case 72:
 /* rule 72 can match eol */
 YY_RULE_SETUP
-#line 446 "lexer.l"
+#line 452 "lexer.l"
 {
 
   yyerror(yyscanner, "unterminated regular expression");
@@ -1635,7 +1641,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 73:
 YY_RULE_SETUP
-#line 453 "lexer.l"
+#line 459 "lexer.l"
 {
 
   yyextra->lex_buf_ptr = yyextra->lex_buf;
@@ -1645,7 +1651,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 74:
 YY_RULE_SETUP
-#line 461 "lexer.l"
+#line 467 "lexer.l"
 {
 
   yyextra->lex_buf_ptr = yyextra->lex_buf;
@@ -1656,7 +1662,7 @@ YY_RULE_SETUP
 case 75:
 /* rule 75 can match eol */
 YY_RULE_SETUP
-#line 469 "lexer.l"
+#line 475 "lexer.l"
 {
 
   int len = strlen(yytext);
@@ -1672,12 +1678,12 @@ YY_RULE_SETUP
 case 76:
 /* rule 76 can match eol */
 YY_RULE_SETUP
-#line 482 "lexer.l"
+#line 488 "lexer.l"
 /* skip whitespace */
 	YY_BREAK
 case 77:
 YY_RULE_SETUP
-#line 484 "lexer.l"
+#line 490 "lexer.l"
 {
 
   if (yytext[0] >= 32 && yytext[0] < 127)
@@ -1693,10 +1699,10 @@ YY_RULE_SETUP
 	YY_BREAK
 case 78:
 YY_RULE_SETUP
-#line 497 "lexer.l"
+#line 503 "lexer.l"
 ECHO;
 	YY_BREAK
-#line 1700 "lexer.c"
+#line 1706 "lexer.c"
 
 	case YY_END_OF_BUFFER:
 		{
@@ -1988,7 +1994,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 226 )
+			if ( yy_current_state >= 227 )
 				yy_c = yy_meta[(unsigned int) yy_c];
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -2017,11 +2023,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 226 )
+		if ( yy_current_state >= 227 )
 			yy_c = yy_meta[(unsigned int) yy_c];
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-	yy_is_jam = (yy_current_state == 225);
+	yy_is_jam = (yy_current_state == 226);
 
 	return yy_is_jam ? 0 : yy_current_state;
 }
@@ -2829,7 +2835,7 @@ void yara_yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 497 "lexer.l"
+#line 503 "lexer.l"
 
 
 
diff --git a/libyara/lexer.l b/libyara/lexer.l
index d346ceb..eeea6d7 100644
--- a/libyara/lexer.l
+++ b/libyara/lexer.l
@@ -30,6 +30,7 @@ limitations under the License.
 #include "mem.h"
 #include "lexer.h"
 #include "utils.h"
+#include "re.h"
 
 
 #define LEX_CHECK_SPACE_OK(data, current_size, max_length) \
@@ -399,7 +400,7 @@ $({letter}|{digit}|_)*  {
 }
 
 
-<regexp>"/"  {
+<regexp>\/i?  {
 
   SIZED_STRING* s;
 
@@ -414,6 +415,11 @@ $({letter}|{digit}|_)*  {
 
   s = (SIZED_STRING*) yr_malloc(yyextra->lex_buf_len + sizeof(SIZED_STRING));
 
+  if (yytext[1] == 'i')
+    s->flags = SIZED_STRING_FLAGS_NO_CASE;
+  else
+    s->flags = 0;
+
   s->length = yyextra->lex_buf_len;
   strcpy(s->c_string, yyextra->lex_buf);
 
diff --git a/libyara/parser.c b/libyara/parser.c
index df8e6e5..a621604 100644
--- a/libyara/parser.c
+++ b/libyara/parser.c
@@ -246,6 +246,9 @@ YR_STRING* yr_parser_reduce_string_declaration(
   if (!(flags & STRING_GFLAGS_WIDE))
     flags |= STRING_GFLAGS_ASCII;
 
+  if (str->flags & SIZED_STRING_FLAGS_NO_CASE)
+    flags |= STRING_GFLAGS_NO_CASE;
+
   // The STRING_GFLAGS_SINGLE_MATCH flag indicates that finding
   // a single match for the string is enough. This is true in
   // most cases, except when the string count (#) and string offset (@)
diff --git a/libyara/re_lexer.c b/libyara/re_lexer.c
index 03d4525..d5ffa6b 100644
--- a/libyara/re_lexer.c
+++ b/libyara/re_lexer.c
@@ -1016,7 +1016,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 192 "re_lexer.l"
+#line 193 "re_lexer.l"
 {
 
   yyerror(yyscanner, lex_env, "backreferences are not allowed");
@@ -1025,7 +1025,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 199 "re_lexer.l"
+#line 200 "re_lexer.l"
 {
   yylval->integer = read_escaped_char(yyscanner);
   return _CHAR_;
@@ -1033,7 +1033,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 205 "re_lexer.l"
+#line 206 "re_lexer.l"
 {
 
   // End of character class.
@@ -1056,7 +1056,7 @@ YY_RULE_SETUP
 case 17:
 /* rule 17 can match eol */
 YY_RULE_SETUP
-#line 225 "re_lexer.l"
+#line 226 "re_lexer.l"
 {
 
   // A range inside a character class.
@@ -1085,7 +1085,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 252 "re_lexer.l"
+#line 253 "re_lexer.l"
 {
 
   LEX_ENV->class_vector[']' / 8] |= 1 << ']' % 8;
@@ -1093,7 +1093,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 19:
 YY_RULE_SETUP
-#line 258 "re_lexer.l"
+#line 259 "re_lexer.l"
 {
 
   int i;
@@ -1108,7 +1108,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 271 "re_lexer.l"
+#line 272 "re_lexer.l"
 {
 
   int i;
@@ -1123,7 +1123,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 21:
 YY_RULE_SETUP
-#line 284 "re_lexer.l"
+#line 285 "re_lexer.l"
 {
 
   LEX_ENV->class_vector[' ' / 8] |= 1 << ' ' % 8;
@@ -1132,7 +1132,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 291 "re_lexer.l"
+#line 292 "re_lexer.l"
 {
 
   int i;
@@ -1146,7 +1146,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 303 "re_lexer.l"
+#line 304 "re_lexer.l"
 {
 
   char c;
@@ -1157,7 +1157,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 312 "re_lexer.l"
+#line 313 "re_lexer.l"
 {
 
   int i;
@@ -1172,7 +1172,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 325 "re_lexer.l"
+#line 326 "re_lexer.l"
 {
 
   uint8_t c = read_escaped_char(yyscanner);
@@ -1182,7 +1182,7 @@ YY_RULE_SETUP
 case 26:
 /* rule 26 can match eol */
 YY_RULE_SETUP
-#line 332 "re_lexer.l"
+#line 333 "re_lexer.l"
 {
 
   // A character class (i.e: [0-9a-f]) is represented by a 256-bits vector,
@@ -1192,7 +1192,7 @@ YY_RULE_SETUP
 }
 	YY_BREAK
 case YY_STATE_EOF(char_class):
-#line 341 "re_lexer.l"
+#line 342 "re_lexer.l"
 {
 
   // End of regexp reached while scanning a character class.
@@ -1203,7 +1203,7 @@ case YY_STATE_EOF(char_class):
 	YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 350 "re_lexer.l"
+#line 351 "re_lexer.l"
 {
 
   if (yytext[0] >= 32 && yytext[0] < 127)
@@ -1218,7 +1218,7 @@ YY_RULE_SETUP
 }
 	YY_BREAK
 case YY_STATE_EOF(INITIAL):
-#line 364 "re_lexer.l"
+#line 365 "re_lexer.l"
 {
 
   yyterminate();
@@ -1226,7 +1226,7 @@ case YY_STATE_EOF(INITIAL):
 	YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 369 "re_lexer.l"
+#line 370 "re_lexer.l"
 ECHO;
 	YY_BREAK
 #line 1233 "re_lexer.c"
@@ -2404,7 +2404,7 @@ void re_yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 369 "re_lexer.l"
+#line 370 "re_lexer.l"
 
 
 
diff --git a/libyara/sizedstr.h b/libyara/sizedstr.h
index 1ed78ed..5265d75 100644
--- a/libyara/sizedstr.h
+++ b/libyara/sizedstr.h
@@ -18,15 +18,18 @@ limitations under the License.
 #define _SIZEDSTR_H
 
 //
-// This struct is used to support strings containing null chars. The length of 
+// This struct is used to support strings containing null chars. The length of
 // the string is stored along the string data. However the string data is also
 // terminated with a null char.
 //
 
+#define SIZED_STRING_FLAGS_NO_CASE 	1
+
 typedef struct _SIZED_STRING
 {
     int length;
-    char c_string[1];  
+    int flags;
+    char c_string[1];
 
 } SIZED_STRING;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git



More information about the forensics-changes mailing list